fortepiano 0.1.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.
- package/README.md +3 -0
- package/lib/Aggregate.d.ts +4 -0
- package/lib/Aggregate.js +2 -0
- package/lib/Binary.d.ts +5 -0
- package/lib/Binary.js +15 -0
- package/lib/Buffer.d.ts +5 -0
- package/lib/Buffer.js +45 -0
- package/lib/Cache.d.ts +18 -0
- package/lib/Cache.js +50 -0
- package/lib/Console.d.ts +20 -0
- package/lib/Console.js +25 -0
- package/lib/Crypto.d.ts +5 -0
- package/lib/Crypto.js +39 -0
- package/lib/Date.d.ts +4 -0
- package/lib/Date.js +30 -0
- package/lib/Eq.d.ts +4 -0
- package/lib/Eq.js +29 -0
- package/lib/Error.d.ts +6 -0
- package/lib/Error.js +56 -0
- package/lib/GeneratorL.d.ts +208 -0
- package/lib/GeneratorL.js +501 -0
- package/lib/Http.d.ts +60 -0
- package/lib/Http.js +131 -0
- package/lib/IOAsyncGenerator.d.ts +102 -0
- package/lib/IOAsyncGenerator.js +456 -0
- package/lib/Log.d.ts +4 -0
- package/lib/Log.js +5 -0
- package/lib/Magma.d.ts +2 -0
- package/lib/Magma.js +26 -0
- package/lib/Matrix.d.ts +9 -0
- package/lib/Matrix.js +36 -0
- package/lib/Mock.d.ts +76 -0
- package/lib/Mock.js +113 -0
- package/lib/Option.d.ts +2 -0
- package/lib/Option.js +26 -0
- package/lib/Random.d.ts +7 -0
- package/lib/Random.js +7 -0
- package/lib/Reader.d.ts +4 -0
- package/lib/Reader.js +31 -0
- package/lib/ReaderEither.d.ts +9 -0
- package/lib/ReaderEither.js +34 -0
- package/lib/ReaderTask.d.ts +8 -0
- package/lib/ReaderTask.js +35 -0
- package/lib/ReaderTaskEither.d.ts +17 -0
- package/lib/ReaderTaskEither.js +42 -0
- package/lib/ReadonlyArray.d.ts +75 -0
- package/lib/ReadonlyArray.js +70 -0
- package/lib/ReadonlyRecord.d.ts +4 -0
- package/lib/ReadonlyRecord.js +28 -0
- package/lib/ReadonlyTuple.d.ts +14 -0
- package/lib/ReadonlyTuple.js +34 -0
- package/lib/Storage.d.ts +15 -0
- package/lib/Storage.js +57 -0
- package/lib/Stream.d.ts +5 -0
- package/lib/Stream.js +31 -0
- package/lib/TaskEither.d.ts +2 -0
- package/lib/TaskEither.js +32 -0
- package/lib/Type.d.ts +11 -0
- package/lib/Type.js +53 -0
- package/lib/Validation.d.ts +4 -0
- package/lib/Validation.js +30 -0
- package/lib/cache/Memcached.d.ts +4 -0
- package/lib/cache/Memcached.js +50 -0
- package/lib/cache/Memory.d.ts +2 -0
- package/lib/cache/Memory.js +66 -0
- package/lib/cache/Redis.d.ts +4 -0
- package/lib/cache/Redis.js +58 -0
- package/lib/cache/Storage.d.ts +4 -0
- package/lib/cache/Storage.js +62 -0
- package/lib/function.d.ts +52 -0
- package/lib/function.js +101 -0
- package/lib/http/Axios.d.ts +3 -0
- package/lib/http/Axios.js +59 -0
- package/lib/http/Fetch.d.ts +2 -0
- package/lib/http/Fetch.js +71 -0
- package/lib/http/Got.d.ts +3 -0
- package/lib/http/Got.js +60 -0
- package/lib/http/Mock.d.ts +2 -0
- package/lib/http/Mock.js +52 -0
- package/lib/index.d.ts +48 -0
- package/lib/index.js +86 -0
- package/lib/log/Void.d.ts +3 -0
- package/lib/log/Void.js +6 -0
- package/lib/number.d.ts +3 -0
- package/lib/number.js +8 -0
- package/lib/storage/Flydrive.d.ts +4 -0
- package/lib/storage/Flydrive.js +67 -0
- package/lib/storage/Fs.d.ts +3 -0
- package/lib/storage/Fs.js +53 -0
- package/lib/string.d.ts +5 -0
- package/lib/string.js +33 -0
- package/lib/struct.d.ts +9 -0
- package/lib/struct.js +47 -0
- package/package.json +87 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.$axios = void 0;
|
|
23
|
+
const E = __importStar(require("fp-ts/Either"));
|
|
24
|
+
const function_1 = require("fp-ts/function");
|
|
25
|
+
const RR = __importStar(require("fp-ts/ReadonlyRecord"));
|
|
26
|
+
const t = __importStar(require("io-ts"));
|
|
27
|
+
const $E = __importStar(require("../Error"));
|
|
28
|
+
const $H = __importStar(require("../Http"));
|
|
29
|
+
const $S = __importStar(require("../string"));
|
|
30
|
+
const $TE = __importStar(require("../TaskEither"));
|
|
31
|
+
const response = (url) => (response) => ({
|
|
32
|
+
url: response.config.url || url,
|
|
33
|
+
status: response.status,
|
|
34
|
+
headers: function_1.pipe(response.headers, t.readonly(t.record(t.string, t.unknown)).decode, E.map(RR.filter(t.union([t.string, t.readonlyArray(t.string)]).is)), E.getOrElse(() => ({}))),
|
|
35
|
+
body: response.data,
|
|
36
|
+
});
|
|
37
|
+
const request = (axios, method, url, options = {}) => $TE.tryCatch(() => axios
|
|
38
|
+
.request(Object.assign(Object.assign({ data: options.body, headers: Object.assign(Object.assign({}, options.headers), (options.json ? { 'Content-Type': 'application/json' } : null)), method, params: options.query }, (options.json
|
|
39
|
+
? { responseType: 'json' }
|
|
40
|
+
: options.buffer
|
|
41
|
+
? { responseType: 'arraybuffer' }
|
|
42
|
+
: null)), { url }))
|
|
43
|
+
.then(response(url))
|
|
44
|
+
.catch((error) => {
|
|
45
|
+
if (!axios.isAxiosError(error) || undefined === error.response) {
|
|
46
|
+
throw error;
|
|
47
|
+
}
|
|
48
|
+
throw $E.wrap(new $H.HttpError(response(url)(error.response), `Cannot make HTTP request "${$S.uppercase(method)} ${url}": ${error.message}`))(error);
|
|
49
|
+
}), $E.fromUnknown(Error(`Cannot make HTTP request "${$S.uppercase(method)} ${url}"`)));
|
|
50
|
+
const $axios = (_axios) => ({
|
|
51
|
+
delete: (url, options) => request(_axios, 'delete', url, options),
|
|
52
|
+
get: (url, options) => request(_axios, 'get', url, options),
|
|
53
|
+
patch: (url, options) => request(_axios, 'patch', url, options),
|
|
54
|
+
post: (url, options) => request(_axios, 'post', url, options),
|
|
55
|
+
put: (url, options) => request(_axios, 'put', url, options),
|
|
56
|
+
head: (url, options) => request(_axios, 'head', url, options),
|
|
57
|
+
options: (url, options) => request(_axios, 'options', url, options),
|
|
58
|
+
});
|
|
59
|
+
exports.$axios = $axios;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.$fetch = void 0;
|
|
23
|
+
const Ei = __importStar(require("fp-ts/Either"));
|
|
24
|
+
const function_1 = require("fp-ts/function");
|
|
25
|
+
const J = __importStar(require("fp-ts/Json"));
|
|
26
|
+
const O = __importStar(require("fp-ts/Option"));
|
|
27
|
+
const RA = __importStar(require("fp-ts/ReadonlyArray"));
|
|
28
|
+
const RR = __importStar(require("fp-ts/ReadonlyRecord"));
|
|
29
|
+
const Se = __importStar(require("fp-ts/Semigroup"));
|
|
30
|
+
const t = __importStar(require("io-ts"));
|
|
31
|
+
const io_ts_types_1 = require("io-ts-types");
|
|
32
|
+
const $Er = __importStar(require("../Error"));
|
|
33
|
+
const $H = __importStar(require("../Http"));
|
|
34
|
+
const $St = __importStar(require("../string"));
|
|
35
|
+
const $TE = __importStar(require("../TaskEither"));
|
|
36
|
+
const request = (_fetch, method, url, options = {}) => $TE.tryCatch(() => _fetch(function_1.pipe(options.query, O.fromNullable, O.map(RR.map((value) => value.toString())), O.map((query) => new URLSearchParams(query)), O.map((params) => params.toString()), O.filter(io_ts_types_1.NonEmptyString.is), O.match(() => url, (queryString) => `${url}?${queryString}`)), {
|
|
37
|
+
// eslint-disable-next-line no-nested-ternary
|
|
38
|
+
body: options.json
|
|
39
|
+
? function_1.pipe(options.body, J.stringify, Ei.getOrElseW(function_1.constUndefined))
|
|
40
|
+
: t.record(t.string, t.unknown).is(options.body)
|
|
41
|
+
? function_1.pipe(options.body, O.fromNullable, O.map(RR.reduceWithIndex(new FormData(), (name, form, value) => {
|
|
42
|
+
if (t.union([t.boolean, t.number, t.string]).is(value)) {
|
|
43
|
+
form.append(name, value.toString());
|
|
44
|
+
}
|
|
45
|
+
return form;
|
|
46
|
+
})), O.getOrElseW(function_1.constUndefined))
|
|
47
|
+
: undefined,
|
|
48
|
+
headers: Object.assign(Object.assign({}, options.headers), (options.json ? { 'Content-Type': 'application/json' } : null)),
|
|
49
|
+
method: $St.uppercase(method),
|
|
50
|
+
}).then((response) => (response.ok && options.json ? response.json() : response.text()).then((body) => {
|
|
51
|
+
const _response = {
|
|
52
|
+
url: response.url,
|
|
53
|
+
status: response.status,
|
|
54
|
+
headers: function_1.pipe([...response.headers.entries()], RR.fromFoldable(Se.last(), RA.Foldable)),
|
|
55
|
+
body,
|
|
56
|
+
};
|
|
57
|
+
if (!response.ok) {
|
|
58
|
+
throw new $H.HttpError(_response, `Cannot make HTTP request "${$St.uppercase(method)} ${url}": ${response.statusText}`);
|
|
59
|
+
}
|
|
60
|
+
return _response;
|
|
61
|
+
})), $Er.fromUnknown(Error(`Cannot make HTTP request "${$St.uppercase(method)} ${url}"`)));
|
|
62
|
+
const $fetch = (_fetch) => ({
|
|
63
|
+
delete: (url, options) => request(_fetch, 'delete', url, options),
|
|
64
|
+
get: (url, options) => request(_fetch, 'get', url, options),
|
|
65
|
+
patch: (url, options) => request(_fetch, 'patch', url, options),
|
|
66
|
+
post: (url, options) => request(_fetch, 'post', url, options),
|
|
67
|
+
put: (url, options) => request(_fetch, 'put', url, options),
|
|
68
|
+
head: (url, options) => request(_fetch, 'head', url, options),
|
|
69
|
+
options: (url, options) => request(_fetch, 'options', url, options),
|
|
70
|
+
});
|
|
71
|
+
exports.$fetch = $fetch;
|
package/lib/http/Got.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.$got = void 0;
|
|
23
|
+
const function_1 = require("fp-ts/function");
|
|
24
|
+
const RR = __importStar(require("fp-ts/ReadonlyRecord"));
|
|
25
|
+
const got_1 = require("got");
|
|
26
|
+
const t = __importStar(require("io-ts"));
|
|
27
|
+
const $E = __importStar(require("../Error"));
|
|
28
|
+
const $H = __importStar(require("../Http"));
|
|
29
|
+
const $S = __importStar(require("../string"));
|
|
30
|
+
const $TE = __importStar(require("../TaskEither"));
|
|
31
|
+
const request = (_got, method, url, options = {}) => $TE.tryCatch(() => _got(url, Object.assign({ headers: options.headers, method, retry: 0, searchParams: options.query }, (options.json
|
|
32
|
+
? { json: options.body, responseType: 'json' }
|
|
33
|
+
: { form: options.body })))
|
|
34
|
+
.then((response) => ({
|
|
35
|
+
url: response.url,
|
|
36
|
+
status: response.statusCode,
|
|
37
|
+
headers: function_1.pipe(response.headers, RR.filter(t.union([t.string, t.readonlyArray(t.string)]).is)),
|
|
38
|
+
body: response.body,
|
|
39
|
+
}))
|
|
40
|
+
.catch((error) => {
|
|
41
|
+
if (!(error instanceof got_1.HTTPError)) {
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
throw $E.wrap(new $H.HttpError({
|
|
45
|
+
url: error.response.url,
|
|
46
|
+
status: error.response.statusCode,
|
|
47
|
+
headers: function_1.pipe(error.response.headers, RR.filter(t.union([t.string, t.readonlyArray(t.string)]).is)),
|
|
48
|
+
body: error.response.body,
|
|
49
|
+
}, `Cannot make HTTP request "${$S.uppercase(method)} ${url}": ${error.message}`))(error);
|
|
50
|
+
}), $E.fromUnknown(Error(`Cannot make HTTP request "${$S.uppercase(method)} ${url}"`)));
|
|
51
|
+
const $got = (_got) => ({
|
|
52
|
+
delete: (url, options) => request(_got, 'delete', url, options),
|
|
53
|
+
get: (url, options) => request(_got, 'get', url, options),
|
|
54
|
+
patch: (url, options) => request(_got, 'patch', url, options),
|
|
55
|
+
post: (url, options) => request(_got, 'post', url, options),
|
|
56
|
+
put: (url, options) => request(_got, 'put', url, options),
|
|
57
|
+
head: (url, options) => request(_got, 'head', url, options),
|
|
58
|
+
options: (url, options) => request(_got, 'options', url, options),
|
|
59
|
+
});
|
|
60
|
+
exports.$got = $got;
|
package/lib/http/Mock.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.mock = void 0;
|
|
23
|
+
const function_1 = require("fp-ts/function");
|
|
24
|
+
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
25
|
+
const t = __importStar(require("io-ts"));
|
|
26
|
+
const function_2 = require("../function");
|
|
27
|
+
const $H = __importStar(require("../Http"));
|
|
28
|
+
const $M = __importStar(require("../Mock"));
|
|
29
|
+
const response = (url, error = false) => $M.struct({
|
|
30
|
+
url: $M.literal(url),
|
|
31
|
+
status: error ? $M.integer(300, 599) : $M.integer(200, 299),
|
|
32
|
+
headers: $M.readonlyRecord($M.string, $M.union($M.string, $M.readonlyArray($M.string))),
|
|
33
|
+
body: $M.unknown(),
|
|
34
|
+
});
|
|
35
|
+
const error = (url) => $M.struct({
|
|
36
|
+
name: $M.string,
|
|
37
|
+
message: $M.string,
|
|
38
|
+
stack: $M.string,
|
|
39
|
+
response: $M.nullable(response(url, true)),
|
|
40
|
+
});
|
|
41
|
+
const request = (url) => function_1.pipe($M.union(error(url), response(url)), TE.fromIOK(function_2.run), TE.chain((mock) => $H.HttpResponseC(t.unknown).is(mock)
|
|
42
|
+
? TE.right(mock)
|
|
43
|
+
: TE.left(mock)));
|
|
44
|
+
exports.mock = {
|
|
45
|
+
delete: request,
|
|
46
|
+
get: request,
|
|
47
|
+
patch: request,
|
|
48
|
+
post: request,
|
|
49
|
+
put: request,
|
|
50
|
+
head: request,
|
|
51
|
+
options: request,
|
|
52
|
+
};
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as $aggregate from './Aggregate';
|
|
2
|
+
import * as $binary from './Binary';
|
|
3
|
+
import * as $buffer from './Buffer';
|
|
4
|
+
import * as $cache from './Cache';
|
|
5
|
+
import * as $console from './Console';
|
|
6
|
+
import * as $crypto from './Crypto';
|
|
7
|
+
import * as $date from './Date';
|
|
8
|
+
import * as $eq from './Eq';
|
|
9
|
+
import * as $error from './Error';
|
|
10
|
+
import * as $generatorL from './GeneratorL';
|
|
11
|
+
import * as $http from './Http';
|
|
12
|
+
import * as $log from './Log';
|
|
13
|
+
import * as $magma from './Magma';
|
|
14
|
+
import * as $matrix from './Matrix';
|
|
15
|
+
import * as $mock from './Mock';
|
|
16
|
+
import * as $number from './number';
|
|
17
|
+
import * as $option from './Option';
|
|
18
|
+
import * as $random from './Random';
|
|
19
|
+
import * as $reader from './Reader';
|
|
20
|
+
import * as $readerEither from './ReaderEither';
|
|
21
|
+
import * as $readerTask from './ReaderTask';
|
|
22
|
+
import * as $readerTaskEither from './ReaderTaskEither';
|
|
23
|
+
import * as $readonlyArray from './ReadonlyArray';
|
|
24
|
+
import * as $readonlyRecord from './ReadonlyRecord';
|
|
25
|
+
import * as $readonlyTuple from './ReadonlyTuple';
|
|
26
|
+
import * as $storage from './Storage';
|
|
27
|
+
import * as $stream from './Stream';
|
|
28
|
+
import * as $string from './string';
|
|
29
|
+
import * as $struct from './struct';
|
|
30
|
+
import * as $taskEither from './TaskEither';
|
|
31
|
+
import * as $type from './Type';
|
|
32
|
+
import * as $validation from './Validation';
|
|
33
|
+
export declare type PartialDeep<A> = A extends {
|
|
34
|
+
readonly [x: string]: unknown;
|
|
35
|
+
} ? Partial<{
|
|
36
|
+
readonly [K in keyof A]: PartialDeep<A[K]>;
|
|
37
|
+
}> : A;
|
|
38
|
+
export declare type ValuesDeep<A> = A extends {
|
|
39
|
+
readonly [x: string]: unknown;
|
|
40
|
+
} & {
|
|
41
|
+
readonly [K in keyof A]: unknown;
|
|
42
|
+
} ? A[keyof A] | ValuesDeep<A[keyof A]> : A;
|
|
43
|
+
export declare type IntersectionDeep<A, B> = A extends {
|
|
44
|
+
readonly [x: string]: unknown;
|
|
45
|
+
} ? A & {
|
|
46
|
+
readonly [K in keyof B]: IntersectionDeep<K extends keyof A ? A[K] : unknown, B[K]>;
|
|
47
|
+
} : B;
|
|
48
|
+
export { $aggregate, $binary, $buffer, $cache, $console, $crypto, $date, $eq, $error, $generatorL, $http, $log, $magma, $matrix, $mock, $number, $option, $random, $reader, $readerEither, $readerTask, $readerTaskEither, $readonlyArray, $readonlyRecord, $readonlyTuple, $storage, $stream, $string, $struct, $taskEither, $type, $validation, };
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.$validation = exports.$type = exports.$taskEither = exports.$struct = exports.$string = exports.$stream = exports.$storage = exports.$readonlyTuple = exports.$readonlyRecord = exports.$readonlyArray = exports.$readerTaskEither = exports.$readerTask = exports.$readerEither = exports.$reader = exports.$random = exports.$option = exports.$number = exports.$mock = exports.$matrix = exports.$magma = exports.$log = exports.$http = exports.$generatorL = exports.$error = exports.$eq = exports.$date = exports.$crypto = exports.$console = exports.$cache = exports.$buffer = exports.$binary = exports.$aggregate = void 0;
|
|
23
|
+
const $aggregate = __importStar(require("./Aggregate"));
|
|
24
|
+
exports.$aggregate = $aggregate;
|
|
25
|
+
const $binary = __importStar(require("./Binary"));
|
|
26
|
+
exports.$binary = $binary;
|
|
27
|
+
const $buffer = __importStar(require("./Buffer"));
|
|
28
|
+
exports.$buffer = $buffer;
|
|
29
|
+
const $cache = __importStar(require("./Cache"));
|
|
30
|
+
exports.$cache = $cache;
|
|
31
|
+
const $console = __importStar(require("./Console"));
|
|
32
|
+
exports.$console = $console;
|
|
33
|
+
const $crypto = __importStar(require("./Crypto"));
|
|
34
|
+
exports.$crypto = $crypto;
|
|
35
|
+
const $date = __importStar(require("./Date"));
|
|
36
|
+
exports.$date = $date;
|
|
37
|
+
const $eq = __importStar(require("./Eq"));
|
|
38
|
+
exports.$eq = $eq;
|
|
39
|
+
const $error = __importStar(require("./Error"));
|
|
40
|
+
exports.$error = $error;
|
|
41
|
+
const $generatorL = __importStar(require("./GeneratorL"));
|
|
42
|
+
exports.$generatorL = $generatorL;
|
|
43
|
+
const $http = __importStar(require("./Http"));
|
|
44
|
+
exports.$http = $http;
|
|
45
|
+
const $log = __importStar(require("./Log"));
|
|
46
|
+
exports.$log = $log;
|
|
47
|
+
const $magma = __importStar(require("./Magma"));
|
|
48
|
+
exports.$magma = $magma;
|
|
49
|
+
const $matrix = __importStar(require("./Matrix"));
|
|
50
|
+
exports.$matrix = $matrix;
|
|
51
|
+
const $mock = __importStar(require("./Mock"));
|
|
52
|
+
exports.$mock = $mock;
|
|
53
|
+
const $number = __importStar(require("./number"));
|
|
54
|
+
exports.$number = $number;
|
|
55
|
+
const $option = __importStar(require("./Option"));
|
|
56
|
+
exports.$option = $option;
|
|
57
|
+
const $random = __importStar(require("./Random"));
|
|
58
|
+
exports.$random = $random;
|
|
59
|
+
const $reader = __importStar(require("./Reader"));
|
|
60
|
+
exports.$reader = $reader;
|
|
61
|
+
const $readerEither = __importStar(require("./ReaderEither"));
|
|
62
|
+
exports.$readerEither = $readerEither;
|
|
63
|
+
const $readerTask = __importStar(require("./ReaderTask"));
|
|
64
|
+
exports.$readerTask = $readerTask;
|
|
65
|
+
const $readerTaskEither = __importStar(require("./ReaderTaskEither"));
|
|
66
|
+
exports.$readerTaskEither = $readerTaskEither;
|
|
67
|
+
const $readonlyArray = __importStar(require("./ReadonlyArray"));
|
|
68
|
+
exports.$readonlyArray = $readonlyArray;
|
|
69
|
+
const $readonlyRecord = __importStar(require("./ReadonlyRecord"));
|
|
70
|
+
exports.$readonlyRecord = $readonlyRecord;
|
|
71
|
+
const $readonlyTuple = __importStar(require("./ReadonlyTuple"));
|
|
72
|
+
exports.$readonlyTuple = $readonlyTuple;
|
|
73
|
+
const $storage = __importStar(require("./Storage"));
|
|
74
|
+
exports.$storage = $storage;
|
|
75
|
+
const $stream = __importStar(require("./Stream"));
|
|
76
|
+
exports.$stream = $stream;
|
|
77
|
+
const $string = __importStar(require("./string"));
|
|
78
|
+
exports.$string = $string;
|
|
79
|
+
const $struct = __importStar(require("./struct"));
|
|
80
|
+
exports.$struct = $struct;
|
|
81
|
+
const $taskEither = __importStar(require("./TaskEither"));
|
|
82
|
+
exports.$taskEither = $taskEither;
|
|
83
|
+
const $type = __importStar(require("./Type"));
|
|
84
|
+
exports.$type = $type;
|
|
85
|
+
const $validation = __importStar(require("./Validation"));
|
|
86
|
+
exports.$validation = $validation;
|
package/lib/log/Void.js
ADDED
package/lib/number.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const floor: (digits?: number, discardZeroSign?: boolean) => (a: number) => number;
|
|
2
|
+
export declare const round: (digits?: number, discardZeroSign?: boolean) => (a: number) => number;
|
|
3
|
+
export declare const ceil: (digits?: number, discardZeroSign?: boolean) => (a: number) => number;
|
package/lib/number.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ceil = exports.round = exports.floor = void 0;
|
|
4
|
+
const function_1 = require("fp-ts/function");
|
|
5
|
+
const approx = (method) => (digits = 0, discardZeroSign = true) => (a) => function_1.pipe(a.toString().split('e'), ([mantissa, exponent]) => `${mantissa}e${(exponent ? Number(exponent) : 0) + digits}`, (s) => Math[method](Number(s)), (n) => n.toString().split('e'), ([mantissa, exponent]) => `${mantissa}e${(exponent ? Number(exponent) : 0) - digits}`, Number, (n) => n === 0 && discardZeroSign ? Math.abs(n) : Math.sign(a) * Math.abs(n));
|
|
6
|
+
exports.floor = approx('floor');
|
|
7
|
+
exports.round = approx('round');
|
|
8
|
+
exports.ceil = approx('ceil');
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.$flydrive = void 0;
|
|
32
|
+
const function_1 = require("fp-ts/function");
|
|
33
|
+
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
34
|
+
const $E = __importStar(require("../Error"));
|
|
35
|
+
const function_2 = require("../function");
|
|
36
|
+
const $Str = __importStar(require("../struct"));
|
|
37
|
+
const $TE = __importStar(require("../TaskEither"));
|
|
38
|
+
const $flydrive = (flydrive) => {
|
|
39
|
+
const _flydrive = function_2.memoize(flydrive);
|
|
40
|
+
return {
|
|
41
|
+
getStream: (path, { fileSystem } = {}) => $TE.tryCatch(() => __awaiter(void 0, void 0, void 0, function* () { return _flydrive().disk(fileSystem).getStream(path); }), $E.fromUnknown(Error(`Cannot get stream for file "${path}"${undefined !== fileSystem ? ` on file system "${fileSystem}"` : ''}`))),
|
|
42
|
+
getUrl: (path, { fileSystem } = {}) => function_1.pipe($TE.tryCatch(() => _flydrive()
|
|
43
|
+
.disk(fileSystem)
|
|
44
|
+
.exists(path)
|
|
45
|
+
.then(({ exists }) => exists ? Promise.resolve() : Promise.reject()), $E.fromUnknown(Error(`Cannot find file "${path}"${undefined !== fileSystem
|
|
46
|
+
? ` on file system "${fileSystem}"`
|
|
47
|
+
: ''}`))), TE.apSecond($TE.tryCatch(() => Promise.resolve(_flydrive().disk(fileSystem).getUrl(path)), $E.fromUnknown(Error(`Cannot get URL for file "${path}"${undefined !== fileSystem
|
|
48
|
+
? ` on file system "${fileSystem}"`
|
|
49
|
+
: ''}`))))),
|
|
50
|
+
read: (path, { fileSystem } = {}) => $TE.tryCatch(() => _flydrive()
|
|
51
|
+
.disk(fileSystem)
|
|
52
|
+
.getBuffer(path)
|
|
53
|
+
.then($Str.lookup('content')), $E.fromUnknown(Error(`Cannot read file "${path}"${undefined !== fileSystem
|
|
54
|
+
? ` from file system "${fileSystem}"`
|
|
55
|
+
: ''}`))),
|
|
56
|
+
write: (path, { fileSystem } = {}) => (data) => $TE.tryCatch(() => _flydrive().disk(fileSystem).put(path, data).then(function_1.constVoid), $E.fromUnknown(Error(`Cannot write file "${path}"${undefined !== fileSystem
|
|
57
|
+
? ` to file system "${fileSystem}"`
|
|
58
|
+
: ''}`))),
|
|
59
|
+
delete: (path, { fileSystem } = {}) => $TE.tryCatch(() => _flydrive()
|
|
60
|
+
.disk(fileSystem)
|
|
61
|
+
.delete(path)
|
|
62
|
+
.then(({ wasDeleted }) => false === wasDeleted ? Promise.reject() : Promise.resolve()), $E.fromUnknown(Error(`Cannot delete file "${path}"${undefined !== fileSystem
|
|
63
|
+
? ` from file system "${fileSystem}"`
|
|
64
|
+
: ''}`))),
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.$flydrive = $flydrive;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
22
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
23
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
24
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
25
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
26
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
27
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
31
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
32
|
+
};
|
|
33
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.$fs = void 0;
|
|
35
|
+
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
36
|
+
const path_1 = __importDefault(require("path"));
|
|
37
|
+
const $E = __importStar(require("../Error"));
|
|
38
|
+
const $Str = __importStar(require("../Stream"));
|
|
39
|
+
const $TE = __importStar(require("../TaskEither"));
|
|
40
|
+
const $fs = (fs, root) => ({
|
|
41
|
+
getStream: (path) => $TE.tryCatch(() => __awaiter(void 0, void 0, void 0, function* () { return fs.createReadStream(path_1.default.join(root, path)); }), $E.fromUnknown(Error(`Cannot get stream for file "${path}"`))),
|
|
42
|
+
getUrl: (path) => TE.left(Error(`Cannot get URL for file "${path}"`)),
|
|
43
|
+
read: (path) => $TE.tryCatch(() => fs.promises.readFile(path_1.default.join(root, path)), $E.fromUnknown(Error(`Cannot read file "${path}"`))),
|
|
44
|
+
write: (path) => (data) => $TE.tryCatch(() => $Str.ReadableStreamC.is(data)
|
|
45
|
+
? new Promise((resolve, reject) => {
|
|
46
|
+
data
|
|
47
|
+
.pipe(fs.createWriteStream(path).on('error', reject))
|
|
48
|
+
.on('end', resolve);
|
|
49
|
+
})
|
|
50
|
+
: fs.promises.writeFile(path_1.default.join(root, path), data), $E.fromUnknown(Error(`Cannot write file "${path}"`))),
|
|
51
|
+
delete: (path) => $TE.tryCatch(() => fs.promises.rm(path_1.default.join(root, path)), $E.fromUnknown(Error(`Cannot delete file "${path}"`))),
|
|
52
|
+
});
|
|
53
|
+
exports.$fs = $fs;
|
package/lib/string.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const uppercase: <S extends string>(s: S) => Uppercase<S>;
|
|
2
|
+
export declare const lowercase: <S extends string>(s: S) => Lowercase<S>;
|
|
3
|
+
export declare const capitalize: <S extends string>(s: S) => Capitalize<S>;
|
|
4
|
+
export declare const uncapitalize: <S extends string>(s: S) => Uncapitalize<S>;
|
|
5
|
+
export declare const test: (re: RegExp) => (s: string) => boolean;
|
package/lib/string.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.test = exports.uncapitalize = exports.capitalize = exports.lowercase = exports.uppercase = void 0;
|
|
23
|
+
const S = __importStar(require("fp-ts/string"));
|
|
24
|
+
const uppercase = (s) => s.toUpperCase();
|
|
25
|
+
exports.uppercase = uppercase;
|
|
26
|
+
const lowercase = (s) => s.toLowerCase();
|
|
27
|
+
exports.lowercase = lowercase;
|
|
28
|
+
const capitalize = (s) => (S.isEmpty(s) ? s : s[0].toUpperCase() + s.slice(1));
|
|
29
|
+
exports.capitalize = capitalize;
|
|
30
|
+
const uncapitalize = (s) => (S.isEmpty(s) ? s : s[0].toLowerCase() + s.slice(1));
|
|
31
|
+
exports.uncapitalize = uncapitalize;
|
|
32
|
+
const test = (re) => (s) => re.test(s);
|
|
33
|
+
exports.test = test;
|
package/lib/struct.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Predicate } from 'fp-ts/function';
|
|
2
|
+
import { IntersectionDeep, PartialDeep } from '.';
|
|
3
|
+
export declare type struct = object;
|
|
4
|
+
export declare const toReadonlyArray: <A extends object>(a: A) => readonly (readonly [keyof A, A[keyof A]])[];
|
|
5
|
+
export declare const lookup: <S extends object, K extends keyof S>(k: K) => (s: S) => S[K];
|
|
6
|
+
export declare const modifyAt: <S extends object, K extends keyof S>(k: K, f: (a: S[K]) => S[K]) => (s: S) => S;
|
|
7
|
+
export declare const updateAt: <S extends object, K extends keyof S>(k: K, a: S[K]) => (s: S) => S;
|
|
8
|
+
export declare const filterDeep: <A extends object>(f: Predicate<unknown>) => (a: A) => PartialDeep<A>;
|
|
9
|
+
export declare const patch: <A extends object, B extends PartialDeep<A> & object>(b: B) => (a: A) => IntersectionDeep<A, B>;
|