aeria-sdk 0.0.15 → 0.0.16
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 +2 -9
- package/dist/auth.js +1 -1
- package/dist/auth.mjs +1 -1
- package/dist/cli.js +3 -10
- package/dist/cli.mjs +15 -13
- package/dist/http.d.ts +1 -1
- package/dist/http.js +1 -1
- package/dist/http.mjs +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +5 -1
- package/dist/index.mjs +5 -1
- package/dist/mirror.d.ts +2 -1
- package/dist/mirror.js +13 -9
- package/dist/mirror.mjs +38 -21
- package/dist/topLevel.d.ts +1 -1
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +36 -1
- package/dist/utils.mjs +151 -0
- package/package.json +18 -3
package/README.md
CHANGED
package/dist/auth.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.signout = exports.authenticate = exports.authMemo = void 0;
|
|
4
|
-
const common_1 = require("@
|
|
4
|
+
const common_1 = require("@aeriajs/common");
|
|
5
5
|
const http_js_1 = require("./http.js");
|
|
6
6
|
const utils_js_1 = require("./utils.js");
|
|
7
7
|
const storage_js_1 = require("./storage.js");
|
package/dist/auth.mjs
CHANGED
|
@@ -122,7 +122,7 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { isRight, unwrapEither } from "@
|
|
125
|
+
import { isRight, unwrapEither } from "@aeriajs/common";
|
|
126
126
|
import { request } from "./http.mjs";
|
|
127
127
|
import { apiUrl } from "./utils.mjs";
|
|
128
128
|
import { getStorage } from "./storage.mjs";
|
package/dist/cli.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const path_1 = __importDefault(require("path"));
|
|
7
3
|
const mirror_js_1 = require("./mirror.js");
|
|
4
|
+
const utils_js_1 = require("./utils.js");
|
|
8
5
|
const main = async () => {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
console.log('aeriaSdk is absent in package.json');
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
(0, mirror_js_1.mirror)(aeriaSdk);
|
|
6
|
+
const config = await (0, utils_js_1.getConfig)();
|
|
7
|
+
(0, mirror_js_1.mirrorRemotely)(config);
|
|
15
8
|
};
|
|
16
9
|
main();
|
package/dist/cli.mjs
CHANGED
|
@@ -122,23 +122,25 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import
|
|
126
|
-
import {
|
|
125
|
+
import { mirrorRemotely } from "./mirror.mjs";
|
|
126
|
+
import { getConfig } from "./utils.mjs";
|
|
127
127
|
var main = function() {
|
|
128
128
|
var _ref = _async_to_generator(function() {
|
|
129
|
-
var
|
|
129
|
+
var config;
|
|
130
130
|
return _ts_generator(this, function(_state) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
131
|
+
switch(_state.label){
|
|
132
|
+
case 0:
|
|
133
|
+
return [
|
|
134
|
+
4,
|
|
135
|
+
getConfig()
|
|
136
|
+
];
|
|
137
|
+
case 1:
|
|
138
|
+
config = _state.sent();
|
|
139
|
+
mirrorRemotely(config);
|
|
140
|
+
return [
|
|
141
|
+
2
|
|
142
|
+
];
|
|
137
143
|
}
|
|
138
|
-
mirror(aeriaSdk);
|
|
139
|
-
return [
|
|
140
|
-
2
|
|
141
|
-
];
|
|
142
144
|
});
|
|
143
145
|
});
|
|
144
146
|
return function main() {
|
package/dist/http.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { InstanceConfig } from './types.js';
|
|
2
|
-
import { type RequestConfig } from '@
|
|
2
|
+
import { type RequestConfig } from '@aeriajs/common';
|
|
3
3
|
export declare const request: <Return = any>(config: InstanceConfig, url: string, payload?: any, _requestConfig?: RequestConfig) => Promise<Return>;
|
package/dist/http.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.request = void 0;
|
|
4
|
-
const common_1 = require("@
|
|
4
|
+
const common_1 = require("@aeriajs/common");
|
|
5
5
|
const storage_js_1 = require("./storage.js");
|
|
6
6
|
const request = (config, url, payload, _requestConfig) => {
|
|
7
7
|
const requestConfig = Object.assign({}, _requestConfig);
|
package/dist/http.mjs
CHANGED
|
@@ -122,7 +122,7 @@ function _ts_generator(thisArg, body) {
|
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
import { request as originalRequest, defaultRequestTransformer } from "@
|
|
125
|
+
import { request as originalRequest, defaultRequestTransformer } from "@aeriajs/common";
|
|
126
126
|
import { getStorage } from "./storage.mjs";
|
|
127
127
|
export var request = function(config, url, payload, _requestConfig) {
|
|
128
128
|
var _$_requestConfig;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
export * from '@aeriajs/common/either';
|
|
1
2
|
export { topLevel as Aeria, } from './topLevel.js';
|
|
2
|
-
export * from '@sonata-api/common';
|
|
3
3
|
export * from './topLevel.js';
|
|
4
4
|
export * from './runtime.js';
|
|
5
5
|
export * from './storage.js';
|
|
6
|
+
export * from './mirror.js';
|
|
7
|
+
export * from './utils.js';
|
|
8
|
+
export * from './http.js';
|
|
9
|
+
export * from './types.js';
|
package/dist/index.js
CHANGED
|
@@ -15,9 +15,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.Aeria = void 0;
|
|
18
|
+
__exportStar(require("@aeriajs/common/either"), exports);
|
|
18
19
|
var topLevel_js_1 = require("./topLevel.js");
|
|
19
20
|
Object.defineProperty(exports, "Aeria", { enumerable: true, get: function () { return topLevel_js_1.topLevel; } });
|
|
20
|
-
__exportStar(require("@sonata-api/common"), exports);
|
|
21
21
|
__exportStar(require("./topLevel.js"), exports);
|
|
22
22
|
__exportStar(require("./runtime.js"), exports);
|
|
23
23
|
__exportStar(require("./storage.js"), exports);
|
|
24
|
+
__exportStar(require("./mirror.js"), exports);
|
|
25
|
+
__exportStar(require("./utils.js"), exports);
|
|
26
|
+
__exportStar(require("./http.js"), exports);
|
|
27
|
+
__exportStar(require("./types.js"), exports);
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
export * from "@aeriajs/common/either";
|
|
1
2
|
export { topLevel as Aeria } from "./topLevel.mjs";
|
|
2
|
-
export * from "@sonata-api/common";
|
|
3
3
|
export * from "./topLevel.mjs";
|
|
4
4
|
export * from "./runtime.mjs";
|
|
5
5
|
export * from "./storage.mjs";
|
|
6
|
+
export * from "./mirror.mjs";
|
|
7
|
+
export * from "./utils.mjs";
|
|
8
|
+
export * from "./http.mjs";
|
|
9
|
+
export * from "./types.mjs";
|
package/dist/mirror.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { InstanceConfig } from './types';
|
|
2
2
|
export declare const runtimeCjs: (config: InstanceConfig) => string;
|
|
3
3
|
export declare const runtimeEsm: (config: InstanceConfig) => string;
|
|
4
|
-
export declare const mirror:
|
|
4
|
+
export declare const writeMirrorFiles: (mirror: any, config: InstanceConfig) => Promise<void>;
|
|
5
|
+
export declare const mirrorRemotely: (config: InstanceConfig) => Promise<void>;
|
package/dist/mirror.js
CHANGED
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.mirrorRemotely = exports.writeMirrorFiles = exports.runtimeEsm = exports.runtimeCjs = void 0;
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const common_1 = require("@
|
|
8
|
+
const common_1 = require("@aeriajs/common");
|
|
9
9
|
const promises_1 = require("fs/promises");
|
|
10
10
|
const topLevel_js_1 = require("./topLevel.js");
|
|
11
11
|
const utils_js_1 = require("./utils.js");
|
|
@@ -19,7 +19,7 @@ const mirrorDts = (mirrorObj) => {
|
|
|
19
19
|
RequestMethod,
|
|
20
20
|
CollectionFunctions
|
|
21
21
|
|
|
22
|
-
} from '@
|
|
22
|
+
} from '@aeriajs/types'
|
|
23
23
|
|
|
24
24
|
declare type MirrorDescriptions = ${JSON.stringify(collections, null, 2)}\n
|
|
25
25
|
|
|
@@ -90,12 +90,8 @@ export const aeria = Aeria(config)
|
|
|
90
90
|
export const storage = getStorage(config)
|
|
91
91
|
\n`;
|
|
92
92
|
exports.runtimeEsm = runtimeEsm;
|
|
93
|
-
const
|
|
94
|
-
const api = (0, topLevel_js_1.topLevel)(config);
|
|
93
|
+
const writeMirrorFiles = async (mirror, config) => {
|
|
95
94
|
const runtimeBase = path_1.default.dirname(require.resolve('aeria-sdk'));
|
|
96
|
-
const mirror = (0, common_1.deserialize)(await api.describe.POST({
|
|
97
|
-
router: true,
|
|
98
|
-
}));
|
|
99
95
|
await (0, promises_1.mkdir)(runtimeBase, {
|
|
100
96
|
recursive: true,
|
|
101
97
|
});
|
|
@@ -103,4 +99,12 @@ const mirror = async (config) => {
|
|
|
103
99
|
await (0, promises_1.writeFile)(path_1.default.join(runtimeBase, 'runtime.js'), (0, exports.runtimeCjs)(config));
|
|
104
100
|
await (0, promises_1.writeFile)(path_1.default.join(runtimeBase, 'runtime.mjs'), (0, exports.runtimeEsm)(config));
|
|
105
101
|
};
|
|
106
|
-
exports.
|
|
102
|
+
exports.writeMirrorFiles = writeMirrorFiles;
|
|
103
|
+
const mirrorRemotely = async (config) => {
|
|
104
|
+
const api = (0, topLevel_js_1.topLevel)(config);
|
|
105
|
+
const mirror = (0, common_1.deserialize)(await api.describe.POST({
|
|
106
|
+
router: true,
|
|
107
|
+
}));
|
|
108
|
+
return (0, exports.writeMirrorFiles)(mirror, config);
|
|
109
|
+
};
|
|
110
|
+
exports.mirrorRemotely = mirrorRemotely;
|
package/dist/mirror.mjs
CHANGED
|
@@ -123,13 +123,13 @@ function _ts_generator(thisArg, body) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
import path from "path";
|
|
126
|
-
import { deserialize } from "@
|
|
126
|
+
import { deserialize } from "@aeriajs/common";
|
|
127
127
|
import { writeFile, mkdir } from "fs/promises";
|
|
128
128
|
import { topLevel } from "./topLevel.mjs";
|
|
129
129
|
import { apiUrl } from "./utils.mjs";
|
|
130
130
|
var mirrorDts = function(mirrorObj) {
|
|
131
131
|
var collections = mirrorObj.descriptions;
|
|
132
|
-
return "import type {\n InferProperty,\n InferResponse,\n SchemaWithId,\n MakeEndpoint,\n RequestMethod,\n CollectionFunctions\n\n} from '@
|
|
132
|
+
return "import type {\n InferProperty,\n InferResponse,\n SchemaWithId,\n MakeEndpoint,\n RequestMethod,\n CollectionFunctions\n\n} from '@aeriajs/types'\n\ndeclare type MirrorDescriptions = ".concat(JSON.stringify(collections, null, 2), "\n\n\ndeclare type MirrorRouter = ").concat(JSON.stringify(mirrorObj.router, null, 2), "\n\n\ndeclare global {\n type Collections = {\n [K in keyof MirrorDescriptions]: {\n item: SchemaWithId<MirrorDescriptions[K]>\n }\n }\n}\n\ndeclare module 'aeria-sdk' {\n import { TopLevelObject, TLOFunctions } from 'aeria-sdk'\n\n type UnionToIntersection<T> = (T extends any ? ((x: T) => 0) : never) extends ((x: infer R) => 0)\n ? R\n : never\n\n type Endpoints = {\n [Route in keyof MirrorRouter]: {\n [Method in keyof MirrorRouter[Route]]: Method extends RequestMethod\n ? MirrorRouter[Route][Method] extends infer Contract\n ? Contract extends\n | { response: infer RouteResponse }\n | { payload: infer RoutePayload }\n | { query: infer RoutePayload }\n ? MakeEndpoint<Route, Method, InferResponse<RouteResponse>, InferProperty<RoutePayload>>\n : MakeEndpoint<Route, Method>\n : never\n : never\n } extends infer Methods\n ? Methods[keyof Methods]\n : never\n } extends infer Endpoints\n ? UnionToIntersection<Endpoints[keyof Endpoints]>\n : never\n\n type StrongelyTypedTLO = TopLevelObject & Endpoints & {\n [K in keyof MirrorDescriptions]: SchemaWithId<MirrorDescriptions[K]> extends infer Document\n ? CollectionFunctions<Document> extends infer Functions\n ? Omit<TLOFunctions, keyof Functions> & {\n [P in keyof Functions]: {\n POST: Functions[P]\n }\n }\n : never\n : never\n }\n\n export const url: string\n export const aeria: StrongelyTypedTLO\n}\n\n ");
|
|
133
133
|
};
|
|
134
134
|
export var runtimeCjs = function(config) {
|
|
135
135
|
return "const config = ".concat(JSON.stringify(config), "\nexports.config = config\nexports.url = '").concat(apiUrl(config), "'\nexports.aeria = require('aeria-sdk/topLevel').topLevel(config)\nexports.storage = require('aeria-sdk/storage').getStorage(config)\n\n");
|
|
@@ -137,49 +137,38 @@ export var runtimeCjs = function(config) {
|
|
|
137
137
|
export var runtimeEsm = function(config) {
|
|
138
138
|
return "import { Aeria, getStorage } from 'aeria-sdk'\nexport const config = ".concat(JSON.stringify(config), "\nexport const url = '").concat(apiUrl(config), "'\nexport const aeria = Aeria(config)\nexport const storage = getStorage(config)\n\n");
|
|
139
139
|
};
|
|
140
|
-
export var
|
|
141
|
-
var _ref = _async_to_generator(function(config) {
|
|
142
|
-
var
|
|
140
|
+
export var writeMirrorFiles = function() {
|
|
141
|
+
var _ref = _async_to_generator(function(mirror, config) {
|
|
142
|
+
var runtimeBase;
|
|
143
143
|
return _ts_generator(this, function(_state) {
|
|
144
144
|
switch(_state.label){
|
|
145
145
|
case 0:
|
|
146
|
-
api = topLevel(config);
|
|
147
146
|
runtimeBase = path.dirname(require.resolve("aeria-sdk"));
|
|
148
|
-
return [
|
|
149
|
-
4,
|
|
150
|
-
api.describe.POST({
|
|
151
|
-
router: true
|
|
152
|
-
})
|
|
153
|
-
];
|
|
154
|
-
case 1:
|
|
155
|
-
mirror = deserialize.apply(void 0, [
|
|
156
|
-
_state.sent()
|
|
157
|
-
]);
|
|
158
147
|
return [
|
|
159
148
|
4,
|
|
160
149
|
mkdir(runtimeBase, {
|
|
161
150
|
recursive: true
|
|
162
151
|
})
|
|
163
152
|
];
|
|
164
|
-
case
|
|
153
|
+
case 1:
|
|
165
154
|
_state.sent();
|
|
166
155
|
return [
|
|
167
156
|
4,
|
|
168
157
|
writeFile(path.join(process.cwd(), "aeria-sdk.d.ts"), mirrorDts(mirror))
|
|
169
158
|
];
|
|
170
|
-
case
|
|
159
|
+
case 2:
|
|
171
160
|
_state.sent();
|
|
172
161
|
return [
|
|
173
162
|
4,
|
|
174
163
|
writeFile(path.join(runtimeBase, "runtime.mjs"), runtimeCjs(config))
|
|
175
164
|
];
|
|
176
|
-
case
|
|
165
|
+
case 3:
|
|
177
166
|
_state.sent();
|
|
178
167
|
return [
|
|
179
168
|
4,
|
|
180
169
|
writeFile(path.join(runtimeBase, "runtime.mjs"), runtimeEsm(config))
|
|
181
170
|
];
|
|
182
|
-
case
|
|
171
|
+
case 4:
|
|
183
172
|
_state.sent();
|
|
184
173
|
return [
|
|
185
174
|
2
|
|
@@ -187,7 +176,35 @@ export var mirror = function() {
|
|
|
187
176
|
}
|
|
188
177
|
});
|
|
189
178
|
});
|
|
190
|
-
return function mirror
|
|
179
|
+
return function writeMirrorFiles(mirror, config) {
|
|
180
|
+
return _ref.apply(this, arguments);
|
|
181
|
+
};
|
|
182
|
+
}();
|
|
183
|
+
export var mirrorRemotely = function() {
|
|
184
|
+
var _ref = _async_to_generator(function(config) {
|
|
185
|
+
var api, mirror;
|
|
186
|
+
return _ts_generator(this, function(_state) {
|
|
187
|
+
switch(_state.label){
|
|
188
|
+
case 0:
|
|
189
|
+
api = topLevel(config);
|
|
190
|
+
return [
|
|
191
|
+
4,
|
|
192
|
+
api.describe.POST({
|
|
193
|
+
router: true
|
|
194
|
+
})
|
|
195
|
+
];
|
|
196
|
+
case 1:
|
|
197
|
+
mirror = deserialize.apply(void 0, [
|
|
198
|
+
_state.sent()
|
|
199
|
+
]);
|
|
200
|
+
return [
|
|
201
|
+
2,
|
|
202
|
+
writeMirrorFiles(mirror, config)
|
|
203
|
+
];
|
|
204
|
+
}
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
return function mirrorRemotely(config) {
|
|
191
208
|
return _ref.apply(this, arguments);
|
|
192
209
|
};
|
|
193
210
|
}();
|
package/dist/topLevel.d.ts
CHANGED
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
2
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.apiUrl = void 0;
|
|
29
|
+
exports.getConfig = exports.apiUrl = void 0;
|
|
30
|
+
const path_1 = __importDefault(require("path"));
|
|
4
31
|
const apiUrl = (config) => {
|
|
5
32
|
if (typeof config.apiUrl === 'string') {
|
|
6
33
|
return config.apiUrl;
|
|
@@ -10,3 +37,11 @@ const apiUrl = (config) => {
|
|
|
10
37
|
: config.apiUrl.development;
|
|
11
38
|
};
|
|
12
39
|
exports.apiUrl = apiUrl;
|
|
40
|
+
const getConfig = async () => {
|
|
41
|
+
const { aeriaSdk } = await Promise.resolve(`${path_1.default.join(process.cwd(), 'package.json')}`).then(s => __importStar(require(s)));
|
|
42
|
+
if (typeof aeriaSdk !== 'object' || !aeriaSdk) {
|
|
43
|
+
throw new Error('aeriaSdk is absent in package.json');
|
|
44
|
+
}
|
|
45
|
+
return aeriaSdk;
|
|
46
|
+
};
|
|
47
|
+
exports.getConfig = getConfig;
|
package/dist/utils.mjs
CHANGED
|
@@ -1,6 +1,157 @@
|
|
|
1
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
2
|
+
try {
|
|
3
|
+
var info = gen[key](arg);
|
|
4
|
+
var value = info.value;
|
|
5
|
+
} catch (error) {
|
|
6
|
+
reject(error);
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (info.done) {
|
|
10
|
+
resolve(value);
|
|
11
|
+
} else {
|
|
12
|
+
Promise.resolve(value).then(_next, _throw);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function _async_to_generator(fn) {
|
|
16
|
+
return function() {
|
|
17
|
+
var self = this, args = arguments;
|
|
18
|
+
return new Promise(function(resolve, reject) {
|
|
19
|
+
var gen = fn.apply(self, args);
|
|
20
|
+
function _next(value) {
|
|
21
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
22
|
+
}
|
|
23
|
+
function _throw(err) {
|
|
24
|
+
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
25
|
+
}
|
|
26
|
+
_next(undefined);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function _ts_generator(thisArg, body) {
|
|
31
|
+
var f, y, t, g, _ = {
|
|
32
|
+
label: 0,
|
|
33
|
+
sent: function() {
|
|
34
|
+
if (t[0] & 1) throw t[1];
|
|
35
|
+
return t[1];
|
|
36
|
+
},
|
|
37
|
+
trys: [],
|
|
38
|
+
ops: []
|
|
39
|
+
};
|
|
40
|
+
return g = {
|
|
41
|
+
next: verb(0),
|
|
42
|
+
"throw": verb(1),
|
|
43
|
+
"return": verb(2)
|
|
44
|
+
}, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
45
|
+
return this;
|
|
46
|
+
}), g;
|
|
47
|
+
function verb(n) {
|
|
48
|
+
return function(v) {
|
|
49
|
+
return step([
|
|
50
|
+
n,
|
|
51
|
+
v
|
|
52
|
+
]);
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function step(op) {
|
|
56
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
57
|
+
while(_)try {
|
|
58
|
+
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;
|
|
59
|
+
if (y = 0, t) op = [
|
|
60
|
+
op[0] & 2,
|
|
61
|
+
t.value
|
|
62
|
+
];
|
|
63
|
+
switch(op[0]){
|
|
64
|
+
case 0:
|
|
65
|
+
case 1:
|
|
66
|
+
t = op;
|
|
67
|
+
break;
|
|
68
|
+
case 4:
|
|
69
|
+
_.label++;
|
|
70
|
+
return {
|
|
71
|
+
value: op[1],
|
|
72
|
+
done: false
|
|
73
|
+
};
|
|
74
|
+
case 5:
|
|
75
|
+
_.label++;
|
|
76
|
+
y = op[1];
|
|
77
|
+
op = [
|
|
78
|
+
0
|
|
79
|
+
];
|
|
80
|
+
continue;
|
|
81
|
+
case 7:
|
|
82
|
+
op = _.ops.pop();
|
|
83
|
+
_.trys.pop();
|
|
84
|
+
continue;
|
|
85
|
+
default:
|
|
86
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
87
|
+
_ = 0;
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
91
|
+
_.label = op[1];
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
95
|
+
_.label = t[1];
|
|
96
|
+
t = op;
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
if (t && _.label < t[2]) {
|
|
100
|
+
_.label = t[2];
|
|
101
|
+
_.ops.push(op);
|
|
102
|
+
break;
|
|
103
|
+
}
|
|
104
|
+
if (t[2]) _.ops.pop();
|
|
105
|
+
_.trys.pop();
|
|
106
|
+
continue;
|
|
107
|
+
}
|
|
108
|
+
op = body.call(thisArg, _);
|
|
109
|
+
} catch (e) {
|
|
110
|
+
op = [
|
|
111
|
+
6,
|
|
112
|
+
e
|
|
113
|
+
];
|
|
114
|
+
y = 0;
|
|
115
|
+
} finally{
|
|
116
|
+
f = t = 0;
|
|
117
|
+
}
|
|
118
|
+
if (op[0] & 5) throw op[1];
|
|
119
|
+
return {
|
|
120
|
+
value: op[0] ? op[1] : void 0,
|
|
121
|
+
done: true
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
import path from "path";
|
|
1
126
|
export var apiUrl = function(config) {
|
|
2
127
|
if (typeof config.apiUrl === "string") {
|
|
3
128
|
return config.apiUrl;
|
|
4
129
|
}
|
|
5
130
|
return process.env.NODE_ENV === "production" ? config.apiUrl.production : config.apiUrl.development;
|
|
6
131
|
};
|
|
132
|
+
export var getConfig = function() {
|
|
133
|
+
var _ref = _async_to_generator(function() {
|
|
134
|
+
var aeriaSdk;
|
|
135
|
+
return _ts_generator(this, function(_state) {
|
|
136
|
+
switch(_state.label){
|
|
137
|
+
case 0:
|
|
138
|
+
return [
|
|
139
|
+
4,
|
|
140
|
+
import(path.join(process.cwd(), "package.json"))
|
|
141
|
+
];
|
|
142
|
+
case 1:
|
|
143
|
+
aeriaSdk = _state.sent().aeriaSdk;
|
|
144
|
+
if (typeof aeriaSdk !== "object" || !aeriaSdk) {
|
|
145
|
+
throw new Error("aeriaSdk is absent in package.json");
|
|
146
|
+
}
|
|
147
|
+
return [
|
|
148
|
+
2,
|
|
149
|
+
aeriaSdk
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
|
+
return function getConfig() {
|
|
155
|
+
return _ref.apply(this, arguments);
|
|
156
|
+
};
|
|
157
|
+
}();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aeria-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -24,6 +24,9 @@
|
|
|
24
24
|
"require": "./dist/index.js",
|
|
25
25
|
"types": "./dist/index.d.ts"
|
|
26
26
|
},
|
|
27
|
+
"./types": {
|
|
28
|
+
"types": "./types.d.ts"
|
|
29
|
+
},
|
|
27
30
|
"./storage": {
|
|
28
31
|
"import": "./dist/storage.mjs",
|
|
29
32
|
"require": "./dist/storage.js",
|
|
@@ -33,14 +36,26 @@
|
|
|
33
36
|
"import": "./dist/topLevel.mjs",
|
|
34
37
|
"require": "./dist/topLevel.js",
|
|
35
38
|
"types": "./dist/topLevel.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./utils": {
|
|
41
|
+
"import": "./dist/utils.mjs",
|
|
42
|
+
"require": "./dist/utils.js",
|
|
43
|
+
"types": "./dist/utils.d.ts"
|
|
44
|
+
},
|
|
45
|
+
"./mirror": {
|
|
46
|
+
"import": "./dist/mirror.mjs",
|
|
47
|
+
"require": "./dist/mirror.js",
|
|
48
|
+
"types": "./dist/mirror.d.ts"
|
|
36
49
|
}
|
|
37
50
|
},
|
|
38
51
|
"peerDependencies": {
|
|
39
|
-
"@
|
|
40
|
-
"@
|
|
52
|
+
"@aeriajs/common": "^0.0.0",
|
|
53
|
+
"@aeriajs/types": "^0.0.0"
|
|
41
54
|
},
|
|
42
55
|
"scripts": {
|
|
43
56
|
"test": "echo skipping",
|
|
57
|
+
"lint": "eslint src",
|
|
58
|
+
"lint:fix": "eslint src --fix",
|
|
44
59
|
"build": "pnpm build:cjs && pnpm build:esm",
|
|
45
60
|
"build:cjs": "tsc",
|
|
46
61
|
"build:esm": "swc src/* -d dist --strip-leading-paths -C module.type=es6 --out-file-extension=mjs && pnpm build:esm-transform",
|