aeria-sdk 0.0.13 → 0.0.15
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/dist/auth.d.ts +1 -1
- package/dist/auth.js +6 -6
- package/dist/auth.mjs +3 -3
- package/dist/cli.js +2 -2
- package/dist/cli.mjs +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/http.js +2 -2
- package/dist/http.mjs +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/index.mjs +4 -4
- package/dist/mirror.js +5 -5
- package/dist/mirror.mjs +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/storage.d.ts +2 -2
- package/dist/topLevel.d.ts +3 -3
- package/dist/topLevel.js +6 -6
- package/dist/topLevel.mjs +3 -3
- package/dist/utils.d.ts +1 -1
- package/package.json +11 -1
package/dist/auth.d.ts
CHANGED
package/dist/auth.js
CHANGED
|
@@ -2,21 +2,21 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.signout = exports.authenticate = exports.authMemo = void 0;
|
|
4
4
|
const common_1 = require("@sonata-api/common");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const http_js_1 = require("./http.js");
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
|
+
const storage_js_1 = require("./storage.js");
|
|
8
8
|
exports.authMemo = {};
|
|
9
9
|
const authenticate = (config) => async (payload) => {
|
|
10
|
-
const response = await (0,
|
|
10
|
+
const response = await (0, http_js_1.request)(config, `${(0, utils_js_1.apiUrl)(config)}/user/authenticate`, payload);
|
|
11
11
|
const resultEither = response.data;
|
|
12
12
|
if ((0, common_1.isRight)(resultEither)) {
|
|
13
13
|
const result = (0, common_1.unwrapEither)(resultEither);
|
|
14
|
-
(0,
|
|
14
|
+
(0, storage_js_1.getStorage)(config).set('auth', result);
|
|
15
15
|
}
|
|
16
16
|
return resultEither;
|
|
17
17
|
};
|
|
18
18
|
exports.authenticate = authenticate;
|
|
19
19
|
const signout = (config) => async () => {
|
|
20
|
-
(0,
|
|
20
|
+
(0, storage_js_1.getStorage)(config).remove('auth');
|
|
21
21
|
};
|
|
22
22
|
exports.signout = signout;
|
package/dist/auth.mjs
CHANGED
|
@@ -123,9 +123,9 @@ function _ts_generator(thisArg, body) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
import { isRight, unwrapEither } from "@sonata-api/common";
|
|
126
|
-
import { request } from "./http";
|
|
127
|
-
import { apiUrl } from "./utils";
|
|
128
|
-
import { getStorage } from "./storage";
|
|
126
|
+
import { request } from "./http.mjs";
|
|
127
|
+
import { apiUrl } from "./utils.mjs";
|
|
128
|
+
import { getStorage } from "./storage.mjs";
|
|
129
129
|
export var authMemo = {};
|
|
130
130
|
export var authenticate = function(config) {
|
|
131
131
|
return function() {
|
package/dist/cli.js
CHANGED
|
@@ -4,13 +4,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const path_1 = __importDefault(require("path"));
|
|
7
|
-
const
|
|
7
|
+
const mirror_js_1 = require("./mirror.js");
|
|
8
8
|
const main = async () => {
|
|
9
9
|
const { aeriaSdk } = require(path_1.default.join(process.cwd(), 'package.json'));
|
|
10
10
|
if (typeof aeriaSdk !== 'object' || !aeriaSdk) {
|
|
11
11
|
console.log('aeriaSdk is absent in package.json');
|
|
12
12
|
return;
|
|
13
13
|
}
|
|
14
|
-
(0,
|
|
14
|
+
(0, mirror_js_1.mirror)(aeriaSdk);
|
|
15
15
|
};
|
|
16
16
|
main();
|
package/dist/cli.mjs
CHANGED
|
@@ -123,7 +123,7 @@ function _ts_generator(thisArg, body) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
import path from "path";
|
|
126
|
-
import { mirror } from "./mirror";
|
|
126
|
+
import { mirror } from "./mirror.mjs";
|
|
127
127
|
var main = function() {
|
|
128
128
|
var _ref = _async_to_generator(function() {
|
|
129
129
|
var aeriaSdk;
|
package/dist/http.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type { InstanceConfig } from './types';
|
|
1
|
+
import type { InstanceConfig } from './types.js';
|
|
2
2
|
import { type RequestConfig } from '@sonata-api/common';
|
|
3
3
|
export declare const request: <Return = any>(config: InstanceConfig, url: string, payload?: any, _requestConfig?: RequestConfig) => Promise<Return>;
|
package/dist/http.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.request = void 0;
|
|
4
4
|
const common_1 = require("@sonata-api/common");
|
|
5
|
-
const
|
|
5
|
+
const storage_js_1 = require("./storage.js");
|
|
6
6
|
const request = (config, url, payload, _requestConfig) => {
|
|
7
7
|
const requestConfig = Object.assign({}, _requestConfig);
|
|
8
8
|
requestConfig.requestTransformer ??= async (url, payload, _params) => {
|
|
9
9
|
const params = Object.assign({}, _params);
|
|
10
|
-
const auth = (0,
|
|
10
|
+
const auth = (0, storage_js_1.getStorage)(config).get('auth');
|
|
11
11
|
if (auth?.token) {
|
|
12
12
|
params.headers ??= {};
|
|
13
13
|
switch (auth.token.type) {
|
package/dist/http.mjs
CHANGED
|
@@ -123,7 +123,7 @@ function _ts_generator(thisArg, body) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
import { request as originalRequest, defaultRequestTransformer } from "@sonata-api/common";
|
|
126
|
-
import { getStorage } from "./storage";
|
|
126
|
+
import { getStorage } from "./storage.mjs";
|
|
127
127
|
export var request = function(config, url, payload, _requestConfig) {
|
|
128
128
|
var _$_requestConfig;
|
|
129
129
|
var requestConfig = Object.assign({}, _requestConfig);
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { topLevel as Aeria, } from './topLevel';
|
|
1
|
+
export { topLevel as Aeria, } from './topLevel.js';
|
|
2
2
|
export * from '@sonata-api/common';
|
|
3
|
-
export * from './topLevel';
|
|
4
|
-
export * from './runtime';
|
|
5
|
-
export * from './storage';
|
|
3
|
+
export * from './topLevel.js';
|
|
4
|
+
export * from './runtime.js';
|
|
5
|
+
export * from './storage.js';
|
package/dist/index.js
CHANGED
|
@@ -15,9 +15,9 @@ 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
|
-
var
|
|
19
|
-
Object.defineProperty(exports, "Aeria", { enumerable: true, get: function () { return
|
|
18
|
+
var topLevel_js_1 = require("./topLevel.js");
|
|
19
|
+
Object.defineProperty(exports, "Aeria", { enumerable: true, get: function () { return topLevel_js_1.topLevel; } });
|
|
20
20
|
__exportStar(require("@sonata-api/common"), exports);
|
|
21
|
-
__exportStar(require("./topLevel"), exports);
|
|
22
|
-
__exportStar(require("./runtime"), exports);
|
|
23
|
-
__exportStar(require("./storage"), exports);
|
|
21
|
+
__exportStar(require("./topLevel.js"), exports);
|
|
22
|
+
__exportStar(require("./runtime.js"), exports);
|
|
23
|
+
__exportStar(require("./storage.js"), exports);
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { topLevel as Aeria } from "./topLevel";
|
|
1
|
+
export { topLevel as Aeria } from "./topLevel.mjs";
|
|
2
2
|
export * from "@sonata-api/common";
|
|
3
|
-
export * from "./topLevel";
|
|
4
|
-
export * from "./runtime";
|
|
5
|
-
export * from "./storage";
|
|
3
|
+
export * from "./topLevel.mjs";
|
|
4
|
+
export * from "./runtime.mjs";
|
|
5
|
+
export * from "./storage.mjs";
|
package/dist/mirror.js
CHANGED
|
@@ -7,8 +7,8 @@ exports.mirror = exports.runtimeEsm = exports.runtimeCjs = void 0;
|
|
|
7
7
|
const path_1 = __importDefault(require("path"));
|
|
8
8
|
const common_1 = require("@sonata-api/common");
|
|
9
9
|
const promises_1 = require("fs/promises");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
10
|
+
const topLevel_js_1 = require("./topLevel.js");
|
|
11
|
+
const utils_js_1 = require("./utils.js");
|
|
12
12
|
const mirrorDts = (mirrorObj) => {
|
|
13
13
|
const collections = mirrorObj.descriptions;
|
|
14
14
|
return `import type {
|
|
@@ -78,20 +78,20 @@ declare module 'aeria-sdk' {
|
|
|
78
78
|
};
|
|
79
79
|
const runtimeCjs = (config) => `const config = ${JSON.stringify(config)}
|
|
80
80
|
exports.config = config
|
|
81
|
-
exports.url = '${(0,
|
|
81
|
+
exports.url = '${(0, utils_js_1.apiUrl)(config)}'
|
|
82
82
|
exports.aeria = require('aeria-sdk/topLevel').topLevel(config)
|
|
83
83
|
exports.storage = require('aeria-sdk/storage').getStorage(config)
|
|
84
84
|
\n`;
|
|
85
85
|
exports.runtimeCjs = runtimeCjs;
|
|
86
86
|
const runtimeEsm = (config) => `import { Aeria, getStorage } from 'aeria-sdk'
|
|
87
87
|
export const config = ${JSON.stringify(config)}
|
|
88
|
-
export const url = '${(0,
|
|
88
|
+
export const url = '${(0, utils_js_1.apiUrl)(config)}'
|
|
89
89
|
export const aeria = Aeria(config)
|
|
90
90
|
export const storage = getStorage(config)
|
|
91
91
|
\n`;
|
|
92
92
|
exports.runtimeEsm = runtimeEsm;
|
|
93
93
|
const mirror = async (config) => {
|
|
94
|
-
const api = (0,
|
|
94
|
+
const api = (0, topLevel_js_1.topLevel)(config);
|
|
95
95
|
const runtimeBase = path_1.default.dirname(require.resolve('aeria-sdk'));
|
|
96
96
|
const mirror = (0, common_1.deserialize)(await api.describe.POST({
|
|
97
97
|
router: true,
|
package/dist/mirror.mjs
CHANGED
|
@@ -125,8 +125,8 @@ function _ts_generator(thisArg, body) {
|
|
|
125
125
|
import path from "path";
|
|
126
126
|
import { deserialize } from "@sonata-api/common";
|
|
127
127
|
import { writeFile, mkdir } from "fs/promises";
|
|
128
|
-
import { topLevel } from "./topLevel";
|
|
129
|
-
import { apiUrl } from "./utils";
|
|
128
|
+
import { topLevel } from "./topLevel.mjs";
|
|
129
|
+
import { apiUrl } from "./utils.mjs";
|
|
130
130
|
var mirrorDts = function(mirrorObj) {
|
|
131
131
|
var collections = mirrorObj.descriptions;
|
|
132
132
|
return "import type {\n InferProperty,\n InferResponse,\n SchemaWithId,\n MakeEndpoint,\n RequestMethod,\n CollectionFunctions\n\n} from '@sonata-api/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 ");
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { InstanceConfig } from './types';
|
|
1
|
+
import type { InstanceConfig } from './types.js';
|
|
2
2
|
export declare const instanceConfig: InstanceConfig;
|
|
3
3
|
export declare const url = "";
|
|
4
4
|
export declare const aeria: {};
|
|
5
5
|
export declare const storage: {
|
|
6
|
-
get: (key: "auth") => import("./auth").AuthenticationResult | null;
|
|
6
|
+
get: (key: "auth") => import("./auth.js").AuthenticationResult | null;
|
|
7
7
|
remove: (key: string) => void;
|
|
8
8
|
set: (key: string, value: any) => void;
|
|
9
9
|
};
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { InstanceConfig } from './types';
|
|
2
|
-
import type { AuthenticationResult } from './auth';
|
|
1
|
+
import type { InstanceConfig } from './types.js';
|
|
2
|
+
import type { AuthenticationResult } from './auth.js';
|
|
3
3
|
export declare const storageMemo: Record<string, string>;
|
|
4
4
|
export declare const storageKey: (key: string, config: InstanceConfig) => string;
|
|
5
5
|
export declare const getStorage: (config: InstanceConfig) => {
|
package/dist/topLevel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import {
|
|
3
|
-
import { type AuthenticationPayload } from './auth';
|
|
1
|
+
import type { RequestMethod } from '@sonata-api/types';
|
|
2
|
+
import type { InstanceConfig } from './types.js';
|
|
3
|
+
import { type AuthenticationPayload } from './auth.js';
|
|
4
4
|
type UserFunctions = {
|
|
5
5
|
user: TLOFunctions & {
|
|
6
6
|
authenticate: (payload: AuthenticationPayload) => Promise<any>;
|
package/dist/topLevel.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.topLevel = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
4
|
+
const auth_js_1 = require("./auth.js");
|
|
5
|
+
const http_js_1 = require("./http.js");
|
|
6
|
+
const utils_js_1 = require("./utils.js");
|
|
7
7
|
const topLevel = (config) => {
|
|
8
8
|
const proxify = (target, parent) => new Proxy(target, {
|
|
9
9
|
get: (_, key) => {
|
|
@@ -11,8 +11,8 @@ const topLevel = (config) => {
|
|
|
11
11
|
return target[key];
|
|
12
12
|
}
|
|
13
13
|
switch (`${parent}/${key}`) {
|
|
14
|
-
case 'user/authenticate': return (0,
|
|
15
|
-
case 'user/signout': return (0,
|
|
14
|
+
case 'user/authenticate': return (0, auth_js_1.authenticate)(config);
|
|
15
|
+
case 'user/signout': return (0, auth_js_1.signout)(config);
|
|
16
16
|
}
|
|
17
17
|
const endpoint = parent;
|
|
18
18
|
const fn = async (payload) => {
|
|
@@ -29,7 +29,7 @@ const topLevel = (config) => {
|
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
const response = await (0,
|
|
32
|
+
const response = await (0, http_js_1.request)(config, `${(0, utils_js_1.apiUrl)(config)}/${endpoint}`, payload, requestConfig);
|
|
33
33
|
return response.data;
|
|
34
34
|
};
|
|
35
35
|
const path = parent
|
package/dist/topLevel.mjs
CHANGED
|
@@ -126,9 +126,9 @@ function _ts_generator(thisArg, body) {
|
|
|
126
126
|
};
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
|
-
import { authenticate, signout } from "./auth";
|
|
130
|
-
import { request } from "./http";
|
|
131
|
-
import { apiUrl } from "./utils";
|
|
129
|
+
import { authenticate, signout } from "./auth.mjs";
|
|
130
|
+
import { request } from "./http.mjs";
|
|
131
|
+
import { apiUrl } from "./utils.mjs";
|
|
132
132
|
export var topLevel = function(config) {
|
|
133
133
|
var proxify = function(target, parent) {
|
|
134
134
|
return new Proxy(target, {
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { InstanceConfig } from './types';
|
|
1
|
+
import type { InstanceConfig } from './types.js';
|
|
2
2
|
export declare const apiUrl: (config: InstanceConfig) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aeria-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -23,6 +23,16 @@
|
|
|
23
23
|
"import": "./dist/index.mjs",
|
|
24
24
|
"require": "./dist/index.js",
|
|
25
25
|
"types": "./dist/index.d.ts"
|
|
26
|
+
},
|
|
27
|
+
"./storage": {
|
|
28
|
+
"import": "./dist/storage.mjs",
|
|
29
|
+
"require": "./dist/storage.js",
|
|
30
|
+
"types": "./dist/storage.d.ts"
|
|
31
|
+
},
|
|
32
|
+
"./topLevel": {
|
|
33
|
+
"import": "./dist/topLevel.mjs",
|
|
34
|
+
"require": "./dist/topLevel.js",
|
|
35
|
+
"types": "./dist/topLevel.d.ts"
|
|
26
36
|
}
|
|
27
37
|
},
|
|
28
38
|
"peerDependencies": {
|