@x12i/files-ingest 0.0.0-stage → 0.1.1
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/client.d.ts +13 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +38 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +35 -4
- package/README.md +0 -3
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type IngestArtifact, type IngestClient } from "@x12i/files-core";
|
|
2
|
+
export type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
3
|
+
export declare class X12iIngestClient implements IngestClient {
|
|
4
|
+
private readonly options;
|
|
5
|
+
private readonly fetchImpl;
|
|
6
|
+
constructor(options: {
|
|
7
|
+
url: string;
|
|
8
|
+
token: string;
|
|
9
|
+
fetchImpl?: FetchLike;
|
|
10
|
+
});
|
|
11
|
+
push(artifact: IngestArtifact): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,YAAY,EAClB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AAEjF,qBAAa,gBAAiB,YAAW,YAAY;IAGvC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAFpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;gBAET,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,CAAA;KAAE;IAIrF,IAAI,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CA4BpD"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { idempotencyKey, PermanentFileError, RetryableSyncError, } from "@x12i/files-core";
|
|
2
|
+
export class X12iIngestClient {
|
|
3
|
+
options;
|
|
4
|
+
fetchImpl;
|
|
5
|
+
constructor(options) {
|
|
6
|
+
this.options = options;
|
|
7
|
+
this.fetchImpl = options.fetchImpl ?? ((input, init) => fetch(input, init));
|
|
8
|
+
}
|
|
9
|
+
async push(artifact) {
|
|
10
|
+
let response;
|
|
11
|
+
try {
|
|
12
|
+
response = await this.fetchImpl(this.options.url, {
|
|
13
|
+
method: "POST",
|
|
14
|
+
redirect: "error",
|
|
15
|
+
signal: AbortSignal.timeout(200_000),
|
|
16
|
+
headers: {
|
|
17
|
+
Authorization: `Bearer ${this.options.token}`,
|
|
18
|
+
"Content-Type": "application/json",
|
|
19
|
+
"Idempotency-Key": idempotencyKey(artifact),
|
|
20
|
+
},
|
|
21
|
+
body: JSON.stringify(artifact),
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
throw new RetryableSyncError(error instanceof Error ? error.message : "X12i ingest network error");
|
|
26
|
+
}
|
|
27
|
+
if (response.status >= 200 && response.status < 300) {
|
|
28
|
+
await response.body?.cancel();
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
await response.body?.cancel();
|
|
32
|
+
if (response.status === 401 || response.status === 429 || response.status >= 500) {
|
|
33
|
+
throw new RetryableSyncError(`X12i ingest failed with ${response.status}`, response.status);
|
|
34
|
+
}
|
|
35
|
+
throw new PermanentFileError("ingest_rejected", `X12i ingest rejected the file with ${response.status}`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
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,CAAC;YAC9B,OAAO;QACT,CAAC;QACD,MAAM,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,CAAC;QAC9B,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;YACjF,MAAM,IAAI,kBAAkB,CAAC,2BAA2B,QAAQ,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC9F,CAAC;QACD,MAAM,IAAI,kBAAkB,CAAC,iBAAiB,EAAE,sCAAsC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3G,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAkB,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,37 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@x12i/files-ingest",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"exports": {
|
|
6
|
+
".": {
|
|
7
|
+
"development": "./src/index.ts",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "tsc -p tsconfig.json"
|
|
14
|
+
},
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"@x12i/files-core": "workspace:*"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@x12i/platform": "workspace:*"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"repository": {
|
|
28
|
+
"type": "git",
|
|
29
|
+
"url": "git+https://github.com/x12i/collaboration-connectors.git",
|
|
30
|
+
"directory": "packages/files-ingest"
|
|
31
|
+
},
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/x12i/collaboration-connectors/issues"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://github.com/x12i/collaboration-connectors#readme",
|
|
36
|
+
"license": "MIT"
|
|
37
|
+
}
|
package/README.md
DELETED