@toa.io/origin 0.1.0 → 1.0.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/.github/workflows/release.yaml +36 -0
- package/.releaserc +17 -0
- package/CHANGELOG.md +14 -0
- package/package.json +12 -4
- package/transpiled/Failure.js +2 -6
- package/transpiled/Failure.js.map +1 -1
- package/transpiled/Method.js +7 -14
- package/transpiled/Method.js.map +1 -1
- package/transpiled/Octets.js +1 -2
- package/transpiled/Resource.js +7 -11
- package/transpiled/Resource.js.map +1 -1
- package/transpiled/events.js +2 -8
- package/transpiled/events.js.map +1 -1
- package/transpiled/fail.js +5 -8
- package/transpiled/fail.js.map +1 -1
- package/transpiled/index.js +5 -16
- package/transpiled/index.js.map +1 -1
- package/transpiled/ok.js +5 -8
- package/transpiled/ok.js.map +1 -1
- package/transpiled/request.js +11 -17
- package/transpiled/request.js.map +1 -1
- package/tsconfig.json +4 -3
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- dev
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
issues: write
|
|
11
|
+
pull-requests: write
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
release:
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0
|
|
22
|
+
persist-credentials: false
|
|
23
|
+
|
|
24
|
+
- name: Setup Node
|
|
25
|
+
uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
node-version: "22"
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: npm ci
|
|
31
|
+
|
|
32
|
+
- name: Semantic release
|
|
33
|
+
env:
|
|
34
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
35
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
36
|
+
run: npx semantic-release
|
package/.releaserc
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
{
|
|
2
|
+
"branches": ["dev"],
|
|
3
|
+
"plugins": [
|
|
4
|
+
"@semantic-release/commit-analyzer",
|
|
5
|
+
"@semantic-release/release-notes-generator",
|
|
6
|
+
|
|
7
|
+
["@semantic-release/changelog", { "changelogFile": "CHANGELOG.md" }],
|
|
8
|
+
["@semantic-release/npm"],
|
|
9
|
+
|
|
10
|
+
["@semantic-release/git", {
|
|
11
|
+
"assets": ["package.json", "package-lock.json", "CHANGELOG.md"],
|
|
12
|
+
"message": "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"
|
|
13
|
+
}],
|
|
14
|
+
|
|
15
|
+
"@semantic-release/github"
|
|
16
|
+
]
|
|
17
|
+
}
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# 1.0.0 (2025-10-05)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* actually use `settings.delay` ([350af9c](https://github.com/toa-io/origin/commit/350af9c1db7874dafcbf6699f255c9fa7a4a021b))
|
|
7
|
+
* assert origin ([e1c6dd1](https://github.com/toa-io/origin/commit/e1c6dd15ec31b2b9bb6b8fa2d16a193c6d2600ce))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* import implementation ([b5b769f](https://github.com/toa-io/origin/commit/b5b769fc78c9b0e1a2886c0564066992501a5655))
|
|
13
|
+
* set file type as content-type ([58e24f2](https://github.com/toa-io/origin/commit/58e24f246c07f753fe897f9828212a0d7a745e00))
|
|
14
|
+
* update tsconfig ([7d583c1](https://github.com/toa-io/origin/commit/7d583c1c8fe7df2aca3cd2150cd3cb4628b6b1d4))
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toa.io/origin",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -16,11 +16,18 @@
|
|
|
16
16
|
"typescript": "^5.8.3"
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
|
-
"@
|
|
19
|
+
"@semantic-release/changelog": "^6.0.3",
|
|
20
|
+
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
21
|
+
"@semantic-release/git": "^10.0.1",
|
|
22
|
+
"@semantic-release/github": "^11.0.6",
|
|
23
|
+
"@semantic-release/npm": "^12.0.2",
|
|
24
|
+
"@semantic-release/release-notes-generator": "^14.1.0",
|
|
25
|
+
"@types/node": "^24.6.2",
|
|
20
26
|
"eslint": "^9.27.0",
|
|
21
27
|
"eslint-plugin-import": "^2.31.0",
|
|
22
28
|
"husky": "^9.1.7",
|
|
23
|
-
"neostandard": "^0.12.
|
|
29
|
+
"neostandard": "^0.12.2",
|
|
30
|
+
"semantic-release": "^24.2.9"
|
|
24
31
|
},
|
|
25
32
|
"scripts": {
|
|
26
33
|
"prepare": "husky",
|
|
@@ -28,7 +35,8 @@
|
|
|
28
35
|
"transpile": "rm -rf transpiled tsconfig.tsbuildinfo && tsc",
|
|
29
36
|
"lint": "eslint .",
|
|
30
37
|
"format": "eslint . --fix",
|
|
31
|
-
"test": "
|
|
38
|
+
"test": "npm run lint && node --test",
|
|
39
|
+
"ci": "rm -rf node_modules && rm -rf package-lock.json && npm i"
|
|
32
40
|
},
|
|
33
41
|
"dependencies": {
|
|
34
42
|
"error-value": "^0.4.4",
|
package/transpiled/Failure.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Failure = void 0;
|
|
4
|
-
const error_value_1 = require("error-value");
|
|
5
|
-
class Failure extends error_value_1.Err {
|
|
1
|
+
import { Err } from 'error-value';
|
|
2
|
+
export class Failure extends Err {
|
|
6
3
|
}
|
|
7
|
-
exports.Failure = Failure;
|
|
8
4
|
//# sourceMappingURL=Failure.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Failure.js","sourceRoot":"","sources":["../source/Failure.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Failure.js","sourceRoot":"","sources":["../source/Failure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AAEjC,MAAM,OAAO,OAAQ,SAAQ,GAAW;CAAG"}
|
package/transpiled/Method.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Method = void 0;
|
|
7
|
-
const error_value_1 = require("error-value");
|
|
8
|
-
const mitt_1 = __importDefault(require("mitt"));
|
|
9
|
-
const request_1 = require("./request");
|
|
10
|
-
class Method {
|
|
1
|
+
import { Err } from 'error-value';
|
|
2
|
+
import mitt from 'mitt';
|
|
3
|
+
import { request } from './request';
|
|
4
|
+
export class Method {
|
|
11
5
|
base;
|
|
12
6
|
options;
|
|
13
7
|
constructor(base, options) {
|
|
@@ -45,14 +39,14 @@ class Method {
|
|
|
45
39
|
return generator;
|
|
46
40
|
const chunk = await generator.next();
|
|
47
41
|
const entry = chunk.value;
|
|
48
|
-
const emitter = (
|
|
42
|
+
const emitter = mitt();
|
|
49
43
|
void (async () => {
|
|
50
44
|
for await (const part of generator) {
|
|
51
45
|
const workflow = part;
|
|
52
46
|
console.debug('octets chunk:', workflow);
|
|
53
47
|
const payload = workflow.error === undefined
|
|
54
48
|
? workflow.output
|
|
55
|
-
: new
|
|
49
|
+
: new Err(workflow.error.code, workflow.error.message);
|
|
56
50
|
emitter.emit(workflow.step, payload);
|
|
57
51
|
}
|
|
58
52
|
emitter.off('*');
|
|
@@ -61,13 +55,12 @@ class Method {
|
|
|
61
55
|
}
|
|
62
56
|
async request(segments, options) {
|
|
63
57
|
const path = toPath(segments);
|
|
64
|
-
return await
|
|
58
|
+
return await request(`${this.base}${path}`, {
|
|
65
59
|
...this.options,
|
|
66
60
|
...options
|
|
67
61
|
});
|
|
68
62
|
}
|
|
69
63
|
}
|
|
70
|
-
exports.Method = Method;
|
|
71
64
|
function toPath(segments) {
|
|
72
65
|
if (segments === undefined)
|
|
73
66
|
return '';
|
package/transpiled/Method.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Method.js","sourceRoot":"","sources":["../source/Method.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Method.js","sourceRoot":"","sources":["../source/Method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAA;AACjC,OAAO,IAAsB,MAAM,MAAM,CAAA;AACzC,OAAO,EAAE,OAAO,EAAgB,MAAM,WAAW,CAAA;AAIjD,MAAM,OAAO,MAAM;IACA,IAAI,CAAQ;IACZ,OAAO,CAAU;IAElC,YAAY,IAAY,EAAE,OAAiB;QACzC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,QAA4B,EAAE,OAAiB;QAC/D,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;IAEM,KAAK,CAAC,KAAK,CAAa,QAA4B,EAAE,OAAiB;QAC5E,OAAO,MAAM,IAAI,CAAC,OAAO,CAAI,QAAQ,EAAE,OAAO,CAAC,CAAA;IACjD,CAAC;IAEM,KAAK,CAAC,KAAK,CAAe,QAA4B,EAAE,OAAiB;QAC9E,OAAO,MAAM,IAAI,CAAC,OAAO,CAAM,QAAQ,EAAE,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eAAe,EAAE,QAAQ,CAAC,CAAA;gBAExC,MAAM,OAAO,GACX,QAAQ,CAAC,KAAK,KAAK,SAAS;oBAC1B,CAAC,CAAC,QAAQ,CAAC,MAAM;oBACjB,CAAC,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;gBAE1D,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAuC,CAAC,CAAA;YACtE,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QAClB,CAAC,CAAC,EAAE,CAAA;QAEJ,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACzB,CAAC;IAEO,KAAK,CAAC,OAAO,CAAI,QAA4B,EAAE,OAAiB;QACtE,MAAM,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;QAE7B,OAAO,MAAM,OAAO,CAAI,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,EAAE,EAAE;YAC7C,GAAG,IAAI,CAAC,OAAO;YACf,GAAG,OAAO;SACX,CAAC,CAAA;IACJ,CAAC;CACF;AAED,SAAS,MAAM,CAAC,QAAuC;IACrD,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,CAAA;IAErC,IAAI,OAAO,QAAQ,KAAK,QAAQ;QAAE,OAAO,QAAQ,CAAA;IAEjD,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,GAAG,CAAA;AAChE,CAAC"}
|
package/transpiled/Octets.js
CHANGED
package/transpiled/Resource.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.Resource = void 0;
|
|
4
|
-
const Method_1 = require("./Method");
|
|
5
|
-
class Resource {
|
|
1
|
+
import { Method } from './Method';
|
|
2
|
+
export class Resource {
|
|
6
3
|
get;
|
|
7
4
|
post;
|
|
8
5
|
patch;
|
|
9
6
|
put;
|
|
10
7
|
delete;
|
|
11
8
|
constructor(base, options) {
|
|
12
|
-
this.get = new
|
|
13
|
-
this.post = new
|
|
14
|
-
this.patch = new
|
|
15
|
-
this.put = new
|
|
16
|
-
this.delete = new
|
|
9
|
+
this.get = new Method(base, { method: 'GET', ...options });
|
|
10
|
+
this.post = new Method(base, { method: 'POST', ...options });
|
|
11
|
+
this.patch = new Method(base, { method: 'PATCH', ...options });
|
|
12
|
+
this.put = new Method(base, { method: 'PUT', ...options });
|
|
13
|
+
this.delete = new Method(base, { method: 'DELETE', ...options });
|
|
17
14
|
}
|
|
18
15
|
}
|
|
19
|
-
exports.Resource = Resource;
|
|
20
16
|
//# sourceMappingURL=Resource.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Resource.js","sourceRoot":"","sources":["../source/Resource.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Resource.js","sourceRoot":"","sources":["../source/Resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,MAAM,OAAO,QAAQ;IACZ,GAAG,CAAW;IACd,IAAI,CAAW;IACf,KAAK,CAAW;IAChB,GAAG,CAAW;IACd,MAAM,CAAe;IAE5B,YAAmB,IAAY,EAAE,OAAiC;QAChE,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,CAAI,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;QAC7D,IAAI,CAAC,IAAI,GAAG,IAAI,MAAM,CAAI,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;QAC/D,IAAI,CAAC,KAAK,GAAG,IAAI,MAAM,CAAI,IAAI,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;QACjE,IAAI,CAAC,GAAG,GAAG,IAAI,MAAM,CAAI,IAAI,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;QAC7D,IAAI,CAAC,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,OAAO,EAAE,CAAC,CAAA;IAClE,CAAC;CACF"}
|
package/transpiled/events.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.events = void 0;
|
|
7
|
-
const mitt_1 = __importDefault(require("mitt"));
|
|
8
|
-
exports.events = (0, mitt_1.default)();
|
|
1
|
+
import mitt from 'mitt';
|
|
2
|
+
export const events = mitt();
|
|
9
3
|
//# sourceMappingURL=events.js.map
|
package/transpiled/events.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../source/events.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../source/events.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AAGvB,MAAM,CAAC,MAAM,MAAM,GAAG,IAAI,EAAU,CAAA"}
|
package/transpiled/fail.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const Failure_1 = require("./Failure");
|
|
5
|
-
const events_1 = require("./events");
|
|
6
|
-
async function fail(response) {
|
|
1
|
+
import { Failure } from './Failure';
|
|
2
|
+
import { events } from './events';
|
|
3
|
+
export async function fail(response) {
|
|
7
4
|
const payload = response.headers.get('content-type') === 'application/json'
|
|
8
5
|
? await response.json()
|
|
9
6
|
: await response.text();
|
|
10
|
-
|
|
11
|
-
return new
|
|
7
|
+
events.emit(response.status, payload);
|
|
8
|
+
return new Failure(response.status);
|
|
12
9
|
}
|
|
13
10
|
//# sourceMappingURL=fail.js.map
|
package/transpiled/fail.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fail.js","sourceRoot":"","sources":["../source/fail.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fail.js","sourceRoot":"","sources":["../source/fail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,CAAC,KAAK,UAAU,IAAI,CAAC,QAAkB;IAC3C,MAAM,OAAO,GACX,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,KAAK,kBAAkB;QACzD,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE;QACvB,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAE3B,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAErC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAA;AACrC,CAAC"}
|
package/transpiled/index.js
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var Method_1 = require("./Method");
|
|
7
|
-
Object.defineProperty(exports, "Method", { enumerable: true, get: function () { return Method_1.Method; } });
|
|
8
|
-
var Failure_1 = require("./Failure");
|
|
9
|
-
Object.defineProperty(exports, "Failure", { enumerable: true, get: function () { return Failure_1.Failure; } });
|
|
10
|
-
var request_1 = require("./request");
|
|
11
|
-
Object.defineProperty(exports, "authenticate", { enumerable: true, get: function () { return request_1.authenticate; } });
|
|
12
|
-
Object.defineProperty(exports, "request", { enumerable: true, get: function () { return request_1.request; } });
|
|
13
|
-
Object.defineProperty(exports, "use", { enumerable: true, get: function () { return request_1.use; } });
|
|
14
|
-
Object.defineProperty(exports, "connect", { enumerable: true, get: function () { return request_1.connect; } });
|
|
15
|
-
var events_1 = require("./events");
|
|
16
|
-
Object.defineProperty(exports, "events", { enumerable: true, get: function () { return events_1.events; } });
|
|
1
|
+
export { Resource } from './Resource';
|
|
2
|
+
export { Method } from './Method';
|
|
3
|
+
export { Failure } from './Failure';
|
|
4
|
+
export { authenticate, request, use, connect } from './request';
|
|
5
|
+
export { events } from './events';
|
|
17
6
|
//# sourceMappingURL=index.js.map
|
package/transpiled/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../source/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,EAAE,YAAY,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAgB,MAAM,WAAW,CAAA;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA"}
|
package/transpiled/ok.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const browser_1 = require("meros/browser");
|
|
5
|
-
const events_1 = require("./events");
|
|
6
|
-
async function ok(response) {
|
|
1
|
+
import { meros } from 'meros/browser';
|
|
2
|
+
import { events } from './events';
|
|
3
|
+
export async function ok(response) {
|
|
7
4
|
const challenge = response.headers.get('authorization');
|
|
8
5
|
if (challenge !== null)
|
|
9
|
-
|
|
6
|
+
events.emit('challenge', challenge);
|
|
10
7
|
const type = response.headers.get('content-type');
|
|
11
8
|
if (type?.startsWith('multipart/'))
|
|
12
|
-
return (await
|
|
9
|
+
return (await meros(response));
|
|
13
10
|
else if (type === 'application/json')
|
|
14
11
|
return (await response.json());
|
|
15
12
|
else if (type?.startsWith('text/'))
|
package/transpiled/ok.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ok.js","sourceRoot":"","sources":["../source/ok.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ok.js","sourceRoot":"","sources":["../source/ok.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,CAAC,KAAK,UAAU,EAAE,CAAI,QAAkB;IAC5C,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAA;IAEvD,IAAI,SAAS,KAAK,IAAI;QAAE,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;IAE3D,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAEjD,IAAI,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC;QAAE,OAAO,CAAC,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAM,CAAA;SAClE,IAAI,IAAI,KAAK,kBAAkB;QAAE,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAA;SACpE,IAAI,IAAI,EAAE,UAAU,CAAC,OAAO,CAAC;QAAE,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAA;;QAClE,OAAO,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAM,CAAA;AAC1C,CAAC"}
|
package/transpiled/request.js
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.use = use;
|
|
5
|
-
exports.connect = connect;
|
|
6
|
-
exports.request = request;
|
|
7
|
-
const events_1 = require("./events");
|
|
8
|
-
const fail_1 = require("./fail");
|
|
9
|
-
const ok_1 = require("./ok");
|
|
1
|
+
import { events } from './events';
|
|
2
|
+
import { fail } from './fail';
|
|
3
|
+
import { ok } from './ok';
|
|
10
4
|
let challenge = null;
|
|
11
|
-
function authenticate(value) {
|
|
5
|
+
export function authenticate(value) {
|
|
12
6
|
challenge = value;
|
|
13
7
|
}
|
|
14
8
|
let _fetch = fetch;
|
|
15
|
-
function use(fetcher) {
|
|
9
|
+
export function use(fetcher) {
|
|
16
10
|
_fetch = fetcher;
|
|
17
11
|
}
|
|
18
12
|
const settings = {};
|
|
19
|
-
function connect(values) {
|
|
13
|
+
export function connect(values) {
|
|
20
14
|
Object.assign(settings, values);
|
|
21
15
|
}
|
|
22
|
-
async function request(path, options = {}) {
|
|
16
|
+
export async function request(path, options = {}) {
|
|
23
17
|
if (settings.origin === undefined)
|
|
24
18
|
throw new Error('Origin not connected');
|
|
25
19
|
options.headers ??= {};
|
|
@@ -46,13 +40,13 @@ async function request(path, options = {}) {
|
|
|
46
40
|
const start = performance.now();
|
|
47
41
|
const id = typeof window !== 'undefined' && (window.crypto.randomUUID?.() ?? Math.random().toString());
|
|
48
42
|
if (id)
|
|
49
|
-
|
|
43
|
+
events.emit('request', { id, path, options });
|
|
50
44
|
const response = await _fetch(settings.origin + path, options);
|
|
51
45
|
if (id)
|
|
52
|
-
|
|
46
|
+
events.emit('response', { id, response, duration: performance.now() - start });
|
|
53
47
|
if (!response.ok)
|
|
54
|
-
return await
|
|
48
|
+
return await fail(response);
|
|
55
49
|
else
|
|
56
|
-
return await
|
|
50
|
+
return await ok(response);
|
|
57
51
|
}
|
|
58
52
|
//# sourceMappingURL=request.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.js","sourceRoot":"","sources":["../source/request.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file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IAAI,CAAC,UAAU,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,WAAW,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAA;IAEhF,IAAI,CAAC,QAAQ,CAAC,EAAE;QAAE,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,CAAA;;QACxC,OAAO,MAAM,EAAE,CAAI,QAAQ,CAAC,CAAA;AACnC,CAAC"}
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
2
3
|
"compilerOptions": {
|
|
3
4
|
"outDir": "./transpiled",
|
|
4
5
|
"rootDir": "./source",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"target": "
|
|
6
|
+
"moduleResolution": "bundler",
|
|
7
|
+
"module": "esnext",
|
|
8
|
+
"target": "esnext",
|
|
8
9
|
"sourceMap": true,
|
|
9
10
|
"declaration": true,
|
|
10
11
|
"esModuleInterop": true,
|