@ownlate/cli 1.0.2 → 1.0.3

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.
Files changed (2) hide show
  1. package/dist/index.cjs +11 -8
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -7,12 +7,15 @@ let node_path = require("node:path");
7
7
 
8
8
  //#region src/lib/api-client.ts
9
9
  var ApiClient = class {
10
- constructor(baseUrl, apiKey) {
10
+ constructor(baseUrl, apiKey, workspaceId) {
11
11
  this.baseUrl = baseUrl.replace(/\/$/, "");
12
12
  this.apiKey = apiKey;
13
+ this.workspaceId = workspaceId;
13
14
  }
14
15
  authHeaders() {
15
- return { Authorization: `Bearer ${this.apiKey}` };
16
+ const headers = { Authorization: `Bearer ${this.apiKey}` };
17
+ if (this.workspaceId) headers["X-Tenant-Id"] = this.workspaceId;
18
+ return headers;
16
19
  }
17
20
  async request(path, init) {
18
21
  const res = await fetch(`${this.baseUrl}${path}`, {
@@ -147,7 +150,7 @@ async function logoutCommand() {
147
150
  //#region src/commands/workspace.ts
148
151
  async function workspaceListCommand() {
149
152
  const auth = await requireGlobalConfig();
150
- const workspaces = await new ApiClient(auth.apiUrl, auth.apiKey).listWorkspaces();
153
+ const workspaces = await new ApiClient(auth.apiUrl, auth.apiKey, auth.currentWorkspaceId).listWorkspaces();
151
154
  if (workspaces.length === 0) {
152
155
  console.log("No workspaces found.");
153
156
  return;
@@ -159,7 +162,7 @@ async function workspaceListCommand() {
159
162
  }
160
163
  async function workspaceUseCommand(idOrName) {
161
164
  const auth = await requireGlobalConfig();
162
- const found = (await new ApiClient(auth.apiUrl, auth.apiKey).listWorkspaces()).find((w) => w.id === idOrName || w.name === idOrName);
165
+ const found = (await new ApiClient(auth.apiUrl, auth.apiKey, auth.currentWorkspaceId).listWorkspaces()).find((w) => w.id === idOrName || w.name === idOrName);
163
166
  if (!found) {
164
167
  console.error(`Workspace not found: "${idOrName}"`);
165
168
  console.log("Run \"ownlate workspace list\" to see available workspaces.");
@@ -180,7 +183,7 @@ async function projectListCommand() {
180
183
  console.error("No workspace selected. Run \"ownlate workspace use <id>\" first.");
181
184
  process.exit(1);
182
185
  }
183
- const projects = await new ApiClient(auth.apiUrl, auth.apiKey).listProjects(auth.currentWorkspaceId);
186
+ const projects = await new ApiClient(auth.apiUrl, auth.apiKey, auth.currentWorkspaceId).listProjects(auth.currentWorkspaceId);
184
187
  if (projects.length === 0) {
185
188
  console.log("No projects found in current workspace.");
186
189
  return;
@@ -201,7 +204,7 @@ async function initCommand(options) {
201
204
  process.exit(1);
202
205
  } catch {}
203
206
  const auth = await requireGlobalConfig();
204
- const client = new ApiClient(auth.apiUrl, auth.apiKey);
207
+ const client = new ApiClient(auth.apiUrl, auth.apiKey, auth.currentWorkspaceId);
205
208
  const rl = (0, node_readline_promises.createInterface)({
206
209
  input: process.stdin,
207
210
  output: process.stdout
@@ -286,7 +289,7 @@ function detectFormat$1(filePath) {
286
289
  }
287
290
  async function pushCommand(options) {
288
291
  const [auth, config] = await Promise.all([requireGlobalConfig(), readProjectConfig(options.config)]);
289
- const client = new ApiClient(auth.apiUrl, auth.apiKey);
292
+ const client = new ApiClient(auth.apiUrl, auth.apiKey, auth.currentWorkspaceId);
290
293
  let configUpdated = false;
291
294
  console.log(`Pushing to ${auth.apiUrl} (project: ${config.projectId})\n`);
292
295
  for (const file of config.files) {
@@ -338,7 +341,7 @@ function detectFormat(pattern) {
338
341
  }
339
342
  async function pullCommand(options) {
340
343
  const [auth, config] = await Promise.all([requireGlobalConfig(), readProjectConfig(options.config)]);
341
- const client = new ApiClient(auth.apiUrl, auth.apiKey);
344
+ const client = new ApiClient(auth.apiUrl, auth.apiKey, auth.currentWorkspaceId);
342
345
  const languages = options.lang ? [options.lang] : config.targetLanguages;
343
346
  console.log(`Pulling from ${auth.apiUrl} (project: ${config.projectId})\n`);
344
347
  for (const file of config.files) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ownlate/cli",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
4
4
  "description": "Ownlate CLI — push source files and pull translations",
5
5
  "type": "module",
6
6
  "files": [