@toloka-platform/sdk 0.1.0-preview.4 → 0.1.0-preview.6
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 +1 -1
- package/dist/cli/toloka.js +132 -126
- package/dist/cli/toloka.js.jsc +0 -0
- package/dist/cli/toloka.js.jsc.sha256 +1 -1
- package/dist/cli/toloka.js.sha256 +1 -1
- package/docs/cli-v2.md +4 -0
- package/docs/cli.md +82 -6
- package/docs/datasets.md +8 -9
- package/docs/getting-started.md +2 -2
- package/docs/limitations.md +5 -8
- package/docs/troubleshooting.md +0 -11
- package/openapi/gen/api.ts +782 -876
- package/openapi/gen/models/baseModel.ts +9 -0
- package/openapi/gen/models/baseModelId.ts +2 -0
- package/openapi/gen/models/baseModelIdProperty.ts +2 -0
- package/openapi/gen/models/createDatasetBody.ts +2 -0
- package/openapi/gen/models/createDatasetBodyProfile.ts +2 -0
- package/openapi/gen/models/createDatasetUploadBodyFormat.ts +1 -1
- package/openapi/gen/models/createProjectModelBody.ts +8 -0
- package/openapi/gen/models/createProjectModelBodyDescription.ts +2 -0
- package/openapi/gen/models/dataset.ts +2 -0
- package/openapi/gen/models/datasetProfile.ts +3 -0
- package/openapi/gen/models/datasetProfileStamp.ts +6 -0
- package/openapi/gen/models/datasetProfileStampName.ts +2 -0
- package/openapi/gen/models/generationNodeSettingsAudienceAndPricingOneOfOneone.ts +1 -0
- package/openapi/gen/models/index.ts +21 -0
- package/openapi/gen/models/listBaseModels200.ts +5 -0
- package/openapi/gen/models/listModelVersions200.ts +7 -0
- package/openapi/gen/models/listModelVersionsParams.ts +5 -0
- package/openapi/gen/models/listProjectModels200.ts +7 -0
- package/openapi/gen/models/listProjectModelsParams.ts +5 -0
- package/openapi/gen/models/model.ts +16 -0
- package/openapi/gen/models/modelArchivedAt.ts +2 -0
- package/openapi/gen/models/modelDescription.ts +2 -0
- package/openapi/gen/models/modelId.ts +2 -0
- package/openapi/gen/models/modelVersion.ts +9 -0
- package/openapi/gen/models/modelVersionId.ts +2 -0
- package/openapi/gen/models/pipelineGraphSnapshotGraphNodesItemOneOfThreeoneSettingsAudienceAndPricingOneOfOneone.ts +1 -0
- package/openapi/gen/models/runCost.ts +7 -0
- package/openapi/gen/models/validatePipelineGraphBodyGraphNodesItemOneOfThreeoneSettingsAudienceAndPricingOneOfOneone.ts +1 -0
- package/package.json +2 -1
- package/skills/catalog.json +22 -0
- package/skills/{SKILL.md → toloka-build/SKILL.md} +2 -2
- package/skills/{references → toloka-build/references}/workflow-and-cli.md +26 -5
- package/skills/toloka-report-issue/SKILL.md +25 -0
- package/skills/toloka-report-issue/references/report-template.md +34 -0
- package/src/cli/analytics.ts +53 -1
- package/src/cli/data.ts +148 -25
- package/src/cli/file-system.ts +34 -0
- package/src/cli/format-error.ts +19 -0
- package/src/cli/init.ts +149 -194
- package/src/cli/models.ts +188 -0
- package/src/cli/program.ts +202 -22
- package/src/cli/report.ts +144 -0
- package/src/cli/skill.ts +363 -0
- package/src/client.ts +109 -35
- package/src/errors.ts +25 -10
- package/src/pipeline-graph-v1.contract.json +5 -1
- package/src/transport.ts +16 -13
- /package/skills/{references → toloka-build/references}/node-semantics.md +0 -0
package/src/transport.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { assert } from
|
|
2
|
-
import { PotatoApiError } from
|
|
1
|
+
import { assert } from "es-toolkit";
|
|
2
|
+
import { PotatoApiError } from "./errors";
|
|
3
3
|
|
|
4
|
-
const BASE_URL_HEADER =
|
|
4
|
+
const BASE_URL_HEADER = "x-potato-sdk-base-url";
|
|
5
5
|
|
|
6
6
|
type TransportRequestInit = RequestInit & {
|
|
7
7
|
readonly fetch?: typeof globalThis.fetch;
|
|
@@ -10,18 +10,18 @@ type TransportRequestInit = RequestInit & {
|
|
|
10
10
|
export const createRequestOptions = (
|
|
11
11
|
baseUrl: string,
|
|
12
12
|
apiKey: string,
|
|
13
|
-
fetch?: typeof globalThis.fetch
|
|
13
|
+
fetch?: typeof globalThis.fetch,
|
|
14
14
|
): TransportRequestInit => {
|
|
15
|
-
assert(baseUrl.length > 0,
|
|
16
|
-
assert(apiKey.length > 0,
|
|
15
|
+
assert(baseUrl.length > 0, "The SDK base URL cannot be empty");
|
|
16
|
+
assert(apiKey.length > 0, "The SDK API key cannot be empty");
|
|
17
17
|
|
|
18
18
|
return {
|
|
19
19
|
headers: {
|
|
20
|
-
Accept:
|
|
20
|
+
Accept: "application/json",
|
|
21
21
|
Authorization: `ApiKey ${apiKey}`,
|
|
22
|
-
[BASE_URL_HEADER]: new URL(baseUrl).toString()
|
|
22
|
+
[BASE_URL_HEADER]: new URL(baseUrl).toString(),
|
|
23
23
|
},
|
|
24
|
-
fetch
|
|
24
|
+
fetch,
|
|
25
25
|
};
|
|
26
26
|
};
|
|
27
27
|
|
|
@@ -30,7 +30,7 @@ export async function potatoFetch(url: string, options: TransportRequestInit): P
|
|
|
30
30
|
const { fetch: fetchImplementation = globalThis.fetch, ...requestOptions } = options;
|
|
31
31
|
const headers = new Headers(requestOptions.headers);
|
|
32
32
|
const baseUrl = headers.get(BASE_URL_HEADER);
|
|
33
|
-
assert(baseUrl,
|
|
33
|
+
assert(baseUrl, "The SDK base URL is missing");
|
|
34
34
|
headers.delete(BASE_URL_HEADER);
|
|
35
35
|
|
|
36
36
|
const response = await fetchImplementation(new URL(url, baseUrl), { ...requestOptions, headers });
|
|
@@ -41,13 +41,16 @@ export async function potatoFetch(url: string, options: TransportRequestInit): P
|
|
|
41
41
|
|
|
42
42
|
if (text.length === 0) {
|
|
43
43
|
body = undefined;
|
|
44
|
-
} else if (response.headers.get(
|
|
44
|
+
} else if (response.headers.get("content-type")?.includes("application/json")) {
|
|
45
45
|
body = JSON.parse(text);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
throw PotatoApiError.fromResponse(
|
|
48
|
+
throw PotatoApiError.fromResponse(
|
|
49
|
+
response.status,
|
|
50
|
+
body,
|
|
51
|
+
response.headers.get("x-request-id") ?? undefined,
|
|
52
|
+
);
|
|
49
53
|
}
|
|
50
54
|
|
|
51
55
|
return text.length === 0 ? undefined : JSON.parse(text);
|
|
52
56
|
}
|
|
53
|
-
|
|
File without changes
|