@toloka-platform/sdk 0.1.0-preview.3 → 0.1.0-preview.4

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/src/cli/auth.ts CHANGED
@@ -74,12 +74,12 @@ export type LoginResult = {
74
74
  export async function login(options: LoginOptions = {}): Promise<LoginResult> {
75
75
  const environment = options.environment ?? process.env;
76
76
  const write = options.write ?? (() => undefined);
77
- const baseUrl = (
77
+ const baseUrl = normalizeBaseUrl(
78
78
  options.baseUrl ??
79
- environment.POTATO_BASE_URL ??
80
- resolveInternalBaseUrl(environment) ??
81
- PRODUCTION_BASE_URL
82
- ).replace(/\/+$/u, "");
79
+ environment.POTATO_BASE_URL ??
80
+ resolveInternalBaseUrl(environment) ??
81
+ PRODUCTION_BASE_URL,
82
+ );
83
83
 
84
84
  let apiKey = options.apiKey;
85
85
  if (apiKey === undefined) {
@@ -52,13 +52,19 @@ export const credentialsPath = (environment: CliEnvironment = process.env): stri
52
52
  export const legacyCredentialsPath = (environment: CliEnvironment = process.env): string =>
53
53
  join(home(environment), ".toloka", "credentials.json");
54
54
 
55
+ const removeTrailingSlashes = (value: string): string => {
56
+ let end = value.length;
57
+ while (end > 0 && value.charCodeAt(end - 1) === 47) end -= 1;
58
+ return end === value.length ? value : value.slice(0, end);
59
+ };
60
+
55
61
  export const normalizeBaseUrl = (baseUrl: string): string => {
56
- const trimmed = baseUrl.trim().replace(/\/+$/u, "");
62
+ const trimmed = removeTrailingSlashes(baseUrl.trim());
57
63
  try {
58
64
  const url = new URL(trimmed);
59
65
  url.hash = "";
60
66
  url.search = "";
61
- return url.toString().replace(/\/+$/u, "");
67
+ return removeTrailingSlashes(url.toString());
62
68
  } catch {
63
69
  return trimmed;
64
70
  }
package/src/cli/init.ts CHANGED
@@ -128,7 +128,7 @@ const guidance = async (
128
128
  <!-- toloka:skill-digest sha256:${skillDigest} -->
129
129
 
130
130
  ${await bundledSkillBody(sectionHeading)}
131
- Use the globally installed \`toloka\` binary. Install it with \`bun add --global ${SDK_PACKAGE_NAME}@preview\` if it is not on \`PATH\`.
131
+ Use the globally installed \`toloka\` binary. Install it with \`curl -fsSL https://platform.toloka.ai/cli/install.sh | sh\` if it is not on \`PATH\`.
132
132
 
133
133
  If the reference paths above are missing, keep following the workflow and constraints in this file, do not invent SDK helpers or CLI commands, and install the project's declared dependencies before validating, planning, or applying. When no project is selected, use \`toloka project add\` to adopt one or \`toloka project create\` to create one. Adopt live source with \`toloka import\`.
134
134