@lukoweb/apitogo 0.1.118 → 0.1.119

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/cli/cli.js CHANGED
@@ -5067,12 +5067,12 @@ async function loadZudokuConfigWithMeta(rootDir) {
5067
5067
  };
5068
5068
  return configWithMetadata;
5069
5069
  }
5070
- function findOutputPathOfServerConfig(output3) {
5071
- if (Array.isArray(output3)) {
5070
+ function findOutputPathOfServerConfig(output4) {
5071
+ if (Array.isArray(output4)) {
5072
5072
  throw new Error("Expected a single output, but got an array");
5073
5073
  }
5074
- if ("output" in output3) {
5075
- const result = output3.output.find(
5074
+ if ("output" in output4) {
5075
+ const result = output4.output.find(
5076
5076
  (o) => "isEntry" in o && o.isEntry && serverConfigOutputFiles.includes(o.fileName)
5077
5077
  );
5078
5078
  if (result) {
@@ -5802,7 +5802,7 @@ import {
5802
5802
  // package.json
5803
5803
  var package_default = {
5804
5804
  name: "@lukoweb/apitogo",
5805
- version: "0.1.118",
5805
+ version: "0.1.119",
5806
5806
  type: "module",
5807
5807
  sideEffects: [
5808
5808
  "**/*.css",
@@ -7633,13 +7633,13 @@ var generateCode = (schema2, filePath) => {
7633
7633
 
7634
7634
  // src/vite/api/SchemaManager.ts
7635
7635
  var FALLBACK_VERSION = "default";
7636
- var parseInputString = (input4) => {
7637
- const idx = input4.indexOf("?");
7636
+ var parseInputString = (input5) => {
7637
+ const idx = input5.indexOf("?");
7638
7638
  if (idx === -1)
7639
- return { filePath: input4, params: {} };
7639
+ return { filePath: input5, params: {} };
7640
7640
  return {
7641
- filePath: input4.slice(0, idx),
7642
- params: Object.fromEntries(new URLSearchParams(input4.slice(idx)))
7641
+ filePath: input5.slice(0, idx),
7642
+ params: Object.fromEntries(new URLSearchParams(input5.slice(idx)))
7643
7643
  };
7644
7644
  };
7645
7645
  var canonicalParams = (params) => Object.entries(params).sort(([a], [b]) => a.localeCompare(b)).map(([k, v]) => `${k}=${v}`).join("&");
@@ -7675,8 +7675,8 @@ var SchemaManager = class {
7675
7675
  ...processors
7676
7676
  ];
7677
7677
  }
7678
- getPathForFile = (input4, params) => {
7679
- const filePath = path11.resolve(this.config.__meta.rootDir, input4);
7678
+ getPathForFile = (input5, params) => {
7679
+ const filePath = path11.resolve(this.config.__meta.rootDir, input5);
7680
7680
  const apis = ensureArray(this.config.apis ?? []);
7681
7681
  for (const apiConfig of apis) {
7682
7682
  if (!apiConfig || apiConfig.type !== "file" || !apiConfig.path) continue;
@@ -7686,12 +7686,12 @@ var SchemaManager = class {
7686
7686
  if (match) return apiConfig.path;
7687
7687
  }
7688
7688
  };
7689
- processSchema = async (input4) => {
7690
- const filePath = path11.resolve(this.config.__meta.rootDir, input4.input);
7691
- const params = input4.params;
7692
- const configuredPath = this.getPathForFile(input4.input, params);
7689
+ processSchema = async (input5) => {
7690
+ const filePath = path11.resolve(this.config.__meta.rootDir, input5.input);
7691
+ const params = input5.params;
7692
+ const configuredPath = this.getPathForFile(input5.input, params);
7693
7693
  if (!configuredPath) {
7694
- console.warn(`No path found for file ${input4.input}`);
7694
+ console.warn(`No path found for file ${input5.input}`);
7695
7695
  return;
7696
7696
  }
7697
7697
  const parser = new $RefParser2();
@@ -7798,20 +7798,20 @@ var SchemaManager = class {
7798
7798
  if (apiConfig.type !== "file" || !apiConfig.path) continue;
7799
7799
  const inputs = normalizeInputs(apiConfig.input);
7800
7800
  if (inputs.length === 0) throw new Error("No schema found");
7801
- this.processedSchemas[apiConfig.path] = inputs.map((input4) => ({
7801
+ this.processedSchemas[apiConfig.path] = inputs.map((input5) => ({
7802
7802
  schema: {},
7803
7803
  version: "",
7804
- path: input4.path ?? "",
7805
- label: input4.label,
7806
- inputPath: path11.resolve(this.config.__meta.rootDir, input4.input),
7807
- params: input4.params,
7804
+ path: input5.path ?? "",
7805
+ label: input5.label,
7806
+ inputPath: path11.resolve(this.config.__meta.rootDir, input5.input),
7807
+ params: input5.params,
7808
7808
  importKey: "",
7809
7809
  downloadUrl: "",
7810
7810
  processedJsonPath: "",
7811
7811
  processedTime: 0
7812
7812
  }));
7813
7813
  const results = await Promise.allSettled(
7814
- inputs.map((input4) => this.processSchema(input4))
7814
+ inputs.map((input5) => this.processSchema(input5))
7815
7815
  );
7816
7816
  const errors = results.flatMap(
7817
7817
  (r) => r.status === "rejected" ? r.reason : []
@@ -7890,7 +7890,7 @@ import { readFile as readFile2 } from "node:fs/promises";
7890
7890
  import matter from "gray-matter";
7891
7891
  import { parse, stringify as stringify2 } from "yaml";
7892
7892
  var yaml = {
7893
- parse: (input4) => parse(input4) ?? {},
7893
+ parse: (input5) => parse(input5) ?? {},
7894
7894
  stringify: (obj) => stringify2(obj)
7895
7895
  };
7896
7896
  var readFrontmatter = async (filePath) => {
@@ -10163,25 +10163,25 @@ function generateOutput({
10163
10163
  });
10164
10164
  }
10165
10165
  }
10166
- const output3 = {
10166
+ const output4 = {
10167
10167
  version: 3,
10168
10168
  framework: {
10169
10169
  version: pkgJson.version
10170
10170
  },
10171
10171
  routes
10172
10172
  };
10173
- return output3;
10173
+ return output4;
10174
10174
  }
10175
10175
  async function writeOutput(dir, {
10176
10176
  config: config2,
10177
10177
  redirects,
10178
10178
  rewrites
10179
10179
  }) {
10180
- const output3 = generateOutput({ config: config2, redirects, rewrites });
10180
+ const output4 = generateOutput({ config: config2, redirects, rewrites });
10181
10181
  const outputDir = process.env.VERCEL ? path27.join(dir, ".vercel/output") : path27.join(dir, "dist/.output");
10182
10182
  await mkdir3(outputDir, { recursive: true });
10183
10183
  const outputFile = path27.join(outputDir, "config.json");
10184
- await writeFile4(outputFile, JSON.stringify(output3, null, 2), "utf-8");
10184
+ await writeFile4(outputFile, JSON.stringify(output4, null, 2), "utf-8");
10185
10185
  if (process.env.VERCEL) {
10186
10186
  console.log("Wrote Vercel output to", outputDir);
10187
10187
  }
@@ -10202,12 +10202,12 @@ init_invariant();
10202
10202
  init_joinUrl();
10203
10203
 
10204
10204
  // src/vite/reporter.ts
10205
- function writeLine(output3) {
10205
+ function writeLine(output4) {
10206
10206
  clearLine();
10207
- if (output3.length < process.stdout.columns) {
10208
- process.stdout.write(output3);
10207
+ if (output4.length < process.stdout.columns) {
10208
+ process.stdout.write(output4);
10209
10209
  } else {
10210
- process.stdout.write(output3.substring(0, process.stdout.columns - 1));
10210
+ process.stdout.write(output4.substring(0, process.stdout.columns - 1));
10211
10211
  }
10212
10212
  }
10213
10213
  function isTTY() {
@@ -10877,7 +10877,7 @@ function isNetworkError(error) {
10877
10877
  const message = error.message.toLowerCase();
10878
10878
  return message.includes("fetch failed") || message.includes("network") || message.includes("econnreset") || message.includes("etimedout") || message.includes("socket hang up") || error.name === "AbortError" || error.name === "TypeError";
10879
10879
  }
10880
- async function fetchWithRetry(input4, init4, options) {
10880
+ async function fetchWithRetry(input5, init4, options) {
10881
10881
  const maxRetries = options?.maxRetries ?? 3;
10882
10882
  const baseDelayMs = options?.baseDelayMs ?? 1e3;
10883
10883
  const maxDelayMs = options?.maxDelayMs ?? 15e3;
@@ -10887,7 +10887,7 @@ async function fetchWithRetry(input4, init4, options) {
10887
10887
  let attempt = 0;
10888
10888
  while (true) {
10889
10889
  try {
10890
- const response = await fetch(input4, init4);
10890
+ const response = await fetch(input5, init4);
10891
10891
  const retriableStatus = isRetriableHttpStatus(response.status);
10892
10892
  const mayRetryStatus = retriableStatus && (isSafeMethod || response.status === 429 || retryMutatingOnServerError);
10893
10893
  if (mayRetryStatus && attempt < maxRetries) {
@@ -12763,15 +12763,15 @@ function runCommand(command2, args, cwd, env) {
12763
12763
  env: env ? { ...process.env, ...env } : process.env,
12764
12764
  shell: process.platform === "win32"
12765
12765
  });
12766
- let output3 = "";
12766
+ let output4 = "";
12767
12767
  child.stdout.on("data", (chunk) => {
12768
- output3 += chunk.toString();
12768
+ output4 += chunk.toString();
12769
12769
  });
12770
12770
  child.stderr.on("data", (chunk) => {
12771
- output3 += chunk.toString();
12771
+ output4 += chunk.toString();
12772
12772
  });
12773
12773
  child.on("error", reject);
12774
- child.on("close", (exitCode) => resolve({ exitCode, output: output3 }));
12774
+ child.on("close", (exitCode) => resolve({ exitCode, output: output4 }));
12775
12775
  });
12776
12776
  }
12777
12777
  async function runNpmInstall(sourceDirectory, options) {
@@ -14428,15 +14428,15 @@ function runCommand2(command2, args, cwd) {
14428
14428
  env: process.env,
14429
14429
  shell: process.platform === "win32"
14430
14430
  });
14431
- let output3 = "";
14431
+ let output4 = "";
14432
14432
  child.stdout.on("data", (chunk) => {
14433
- output3 += chunk.toString();
14433
+ output4 += chunk.toString();
14434
14434
  });
14435
14435
  child.stderr.on("data", (chunk) => {
14436
- output3 += chunk.toString();
14436
+ output4 += chunk.toString();
14437
14437
  });
14438
14438
  child.on("error", reject);
14439
- child.on("close", (exitCode) => resolve({ exitCode, output: output3 }));
14439
+ child.on("close", (exitCode) => resolve({ exitCode, output: output4 }));
14440
14440
  });
14441
14441
  }
14442
14442
  function buildCreateApitogoCliArgs(invocationArgs, projectName, options) {
@@ -14622,10 +14622,10 @@ function patchApisConfig(content, config2) {
14622
14622
  const asArray = match[0].includes("apis: [");
14623
14623
  return content.replace(APIS_CONFIG_PATTERN, renderApisConfig(config2, asArray));
14624
14624
  }
14625
- function patchApitogoConfigOpenApiToFile(content, input4 = "./openapi.json") {
14625
+ function patchApitogoConfigOpenApiToFile(content, input5 = "./openapi.json") {
14626
14626
  return patchApisConfig(content, {
14627
14627
  type: "file",
14628
- input: input4,
14628
+ input: input5,
14629
14629
  path: "api"
14630
14630
  });
14631
14631
  }
@@ -14837,7 +14837,7 @@ async function discoverOpenApiByMode(siteDirectory, mode) {
14837
14837
  async function wireDevPortalOpenApi(sourceDirectory, openApiPath) {
14838
14838
  const resolvedSource = path47.resolve(sourceDirectory);
14839
14839
  const resolvedOpenApi = path47.resolve(openApiPath);
14840
- const input4 = toSiteRelativeOpenApiInput(resolvedSource, resolvedOpenApi);
14840
+ const input5 = toSiteRelativeOpenApiInput(resolvedSource, resolvedOpenApi);
14841
14841
  const validation = await validateOpenApiFile(resolvedOpenApi);
14842
14842
  if (!validation.valid) {
14843
14843
  return {
@@ -14851,7 +14851,7 @@ async function wireDevPortalOpenApi(sourceDirectory, openApiPath) {
14851
14851
  const raw = await readFile12(jsonConfigPath, "utf8");
14852
14852
  const siteConfig = JSON.parse(raw);
14853
14853
  const updated = applyOpenApiToSiteConfig(siteConfig, {
14854
- input: input4,
14854
+ input: input5,
14855
14855
  apiPath: "api"
14856
14856
  });
14857
14857
  await writeFile11(
@@ -14864,7 +14864,7 @@ async function wireDevPortalOpenApi(sourceDirectory, openApiPath) {
14864
14864
  const tsxConfigPath = path47.join(resolvedSource, "apitogo.config.tsx");
14865
14865
  const configContent = await readFile12(tsxConfigPath, "utf8");
14866
14866
  try {
14867
- const patched = patchApitogoConfigOpenApiToFile(configContent, input4);
14867
+ const patched = patchApitogoConfigOpenApiToFile(configContent, input5);
14868
14868
  await writeFile11(tsxConfigPath, patched);
14869
14869
  } catch (error) {
14870
14870
  return {
@@ -14877,13 +14877,13 @@ async function wireDevPortalOpenApi(sourceDirectory, openApiPath) {
14877
14877
  const manifest = await readManifest(resolvedSource) ?? createScaffoldManifest();
14878
14878
  manifest.backend = {
14879
14879
  ...manifest.backend,
14880
- openApiPath: input4
14880
+ openApiPath: input5
14881
14881
  };
14882
14882
  await writeManifest(resolvedSource, manifest);
14883
14883
  return {
14884
14884
  status: "succeeded",
14885
14885
  openApiPath: resolvedOpenApi,
14886
- openApiInput: input4,
14886
+ openApiInput: input5,
14887
14887
  openApiTitle: validation.title ?? null,
14888
14888
  openApiVersion: validation.version
14889
14889
  };
@@ -15304,12 +15304,12 @@ function mergeDocumentationNavigation(navigation, docRoutePaths, options) {
15304
15304
  }
15305
15305
  return [documentation, ...rest];
15306
15306
  }
15307
- function applyOpenApiToJsonConfig(config2, input4) {
15307
+ function applyOpenApiToJsonConfig(config2, input5) {
15308
15308
  const next = { ...config2 };
15309
15309
  next.apis = [
15310
15310
  {
15311
15311
  type: "file",
15312
- input: input4,
15312
+ input: input5,
15313
15313
  path: "api"
15314
15314
  }
15315
15315
  ];
@@ -15352,15 +15352,15 @@ function buildLimits(rateLimitCalls, monthlyQuota) {
15352
15352
  quota: { calls: monthlyQuota, renewalPeriodDays: 30 }
15353
15353
  };
15354
15354
  }
15355
- function buildPlanItemFromWizard(input4) {
15356
- const sku = input4.sku ?? slugifyPlanSku(input4.displayName);
15355
+ function buildPlanItemFromWizard(input5) {
15356
+ const sku = input5.sku ?? slugifyPlanSku(input5.displayName);
15357
15357
  const item = {
15358
15358
  sku,
15359
- displayName: input4.displayName,
15360
- priceAmount: input4.priceAmount,
15361
- limits: buildLimits(input4.rateLimitCalls, input4.monthlyQuota)
15359
+ displayName: input5.displayName,
15360
+ priceAmount: input5.priceAmount,
15361
+ limits: buildLimits(input5.rateLimitCalls, input5.monthlyQuota)
15362
15362
  };
15363
- if (input4.priceAmount > 0) {
15363
+ if (input5.priceAmount > 0) {
15364
15364
  item.priceCurrency = "usd";
15365
15365
  item.billingPeriod = "month";
15366
15366
  }
@@ -17039,13 +17039,13 @@ async function resolveActionKeysOrAllProjectActions(manifestPlan, existingPlan,
17039
17039
  var GATEWAY_PLAN_SORT_TEMP_OFFSET = 1e3;
17040
17040
  function buildGatewayPlanSortTargetsFromIds(manifestPlans, planIdsBySku, skuById) {
17041
17041
  const targets = [];
17042
- for (const [index, input4] of manifestPlans.entries()) {
17043
- const key = input4.sku.toLowerCase();
17042
+ for (const [index, input5] of manifestPlans.entries()) {
17043
+ const key = input5.sku.toLowerCase();
17044
17044
  const planId = planIdsBySku.get(key);
17045
17045
  if (!planId) {
17046
- throw new Error(`Gateway plan '${input4.sku}' was not found; upsert plans before reordering.`);
17046
+ throw new Error(`Gateway plan '${input5.sku}' was not found; upsert plans before reordering.`);
17047
17047
  }
17048
- const sku = skuById?.get(key)?.sku ?? input4.sku;
17048
+ const sku = skuById?.get(key)?.sku ?? input5.sku;
17049
17049
  targets.push({ planId, sku, sortOrder: index });
17050
17050
  }
17051
17051
  return targets;
@@ -17091,12 +17091,12 @@ async function upsertGatewayPlansFromManifest(client, config2, projectId, plans,
17091
17091
  return cachedProjectActionKeys;
17092
17092
  };
17093
17093
  for (const [index, inputRaw] of plans.entries()) {
17094
- const input4 = normalizePlanForGatewayApi(inputRaw);
17095
- const found = bySku.get(input4.sku.toLowerCase());
17094
+ const input5 = normalizePlanForGatewayApi(inputRaw);
17095
+ const found = bySku.get(input5.sku.toLowerCase());
17096
17096
  if (found) {
17097
17097
  if (options?.syncActionsOnly) {
17098
17098
  const actionKeys = await resolveActionKeysOrAllProjectActions(
17099
- input4,
17099
+ input5,
17100
17100
  found,
17101
17101
  projectActionKeys
17102
17102
  );
@@ -17109,29 +17109,29 @@ async function upsertGatewayPlansFromManifest(client, config2, projectId, plans,
17109
17109
  includedActionKeys: actionKeys
17110
17110
  });
17111
17111
  results.push(JSON.parse(patchedJson2));
17112
- planIdsBySku.set(input4.sku.toLowerCase(), found.id);
17112
+ planIdsBySku.set(input5.sku.toLowerCase(), found.id);
17113
17113
  continue;
17114
17114
  }
17115
17115
  const patchArgs = {
17116
17116
  projectId,
17117
17117
  planId: found.id,
17118
- displayName: input4.displayName,
17118
+ displayName: input5.displayName,
17119
17119
  isActive: true,
17120
- limitsJson: planLimitsForPlatform(input4),
17121
- priceAmount: input4.priceAmount,
17122
- priceCurrency: input4.priceCurrency,
17123
- billingPeriod: input4.billingPeriod ? normalizeBillingPeriod2(input4.billingPeriod) : void 0
17120
+ limitsJson: planLimitsForPlatform(input5),
17121
+ priceAmount: input5.priceAmount,
17122
+ priceCurrency: input5.priceCurrency,
17123
+ billingPeriod: input5.billingPeriod ? normalizeBillingPeriod2(input5.billingPeriod) : void 0
17124
17124
  };
17125
17125
  if (!options?.deferActionKeys) {
17126
17126
  patchArgs.includedActionKeys = await resolveActionKeysOrAllProjectActions(
17127
- input4,
17127
+ input5,
17128
17128
  found,
17129
17129
  projectActionKeys
17130
17130
  );
17131
17131
  }
17132
17132
  const patchedJson = await handlePatchGatewayPlan(client, config2, patchArgs);
17133
17133
  results.push(JSON.parse(patchedJson));
17134
- planIdsBySku.set(input4.sku.toLowerCase(), found.id);
17134
+ planIdsBySku.set(input5.sku.toLowerCase(), found.id);
17135
17135
  continue;
17136
17136
  }
17137
17137
  if (options?.syncActionsOnly) {
@@ -17139,19 +17139,19 @@ async function upsertGatewayPlansFromManifest(client, config2, projectId, plans,
17139
17139
  }
17140
17140
  const createdJson = await handleCreateGatewayPlan(client, config2, {
17141
17141
  projectId,
17142
- sku: input4.sku,
17143
- displayName: input4.displayName,
17144
- priceAmount: input4.priceAmount,
17145
- priceCurrency: input4.priceCurrency ?? "usd",
17146
- billingPeriod: normalizeBillingPeriod2(input4.billingPeriod),
17147
- limitsJson: planLimitsForPlatform(input4),
17148
- includedActionKeys: options?.deferActionKeys ? [] : await resolveActionKeysOrAllProjectActions(input4, void 0, projectActionKeys),
17142
+ sku: input5.sku,
17143
+ displayName: input5.displayName,
17144
+ priceAmount: input5.priceAmount,
17145
+ priceCurrency: input5.priceCurrency ?? "usd",
17146
+ billingPeriod: normalizeBillingPeriod2(input5.billingPeriod),
17147
+ limitsJson: planLimitsForPlatform(input5),
17148
+ includedActionKeys: options?.deferActionKeys ? [] : await resolveActionKeysOrAllProjectActions(input5, void 0, projectActionKeys),
17149
17149
  skipDefaultActions: true,
17150
17150
  sortOrder: index
17151
17151
  });
17152
17152
  const created = JSON.parse(createdJson);
17153
17153
  if (created.plan?.id) {
17154
- planIdsBySku.set(input4.sku.toLowerCase(), created.plan.id);
17154
+ planIdsBySku.set(input5.sku.toLowerCase(), created.plan.id);
17155
17155
  }
17156
17156
  results.push(created);
17157
17157
  }
@@ -18074,8 +18074,8 @@ async function prepareOpenApiServersForGatewayBuild(options) {
18074
18074
  try {
18075
18075
  const raw = await readFile16(path56.join(siteDirectory, APITOGO_CONFIG_FILENAME2), "utf8");
18076
18076
  const config2 = JSON.parse(raw);
18077
- const input4 = Array.isArray(config2.apis) ? config2.apis[0]?.input?.trim() : void 0;
18078
- openApiPath = resolveBackendOpenApiPath(input4, { siteDirectory });
18077
+ const input5 = Array.isArray(config2.apis) ? config2.apis[0]?.input?.trim() : void 0;
18078
+ openApiPath = resolveBackendOpenApiPath(input5, { siteDirectory });
18079
18079
  } catch {
18080
18080
  }
18081
18081
  }
@@ -18124,15 +18124,15 @@ function runDotnetPublish(projectDir, outputDir) {
18124
18124
  shell: process.platform === "win32"
18125
18125
  }
18126
18126
  );
18127
- let output3 = "";
18127
+ let output4 = "";
18128
18128
  child.stdout.on("data", (chunk) => {
18129
- output3 += chunk.toString();
18129
+ output4 += chunk.toString();
18130
18130
  });
18131
18131
  child.stderr.on("data", (chunk) => {
18132
- output3 += chunk.toString();
18132
+ output4 += chunk.toString();
18133
18133
  });
18134
18134
  child.on("error", reject);
18135
- child.on("close", (exitCode) => resolve({ exitCode, output: output3 }));
18135
+ child.on("close", (exitCode) => resolve({ exitCode, output: output4 }));
18136
18136
  });
18137
18137
  }
18138
18138
  async function findCsproj(projectDir) {
@@ -18219,12 +18219,12 @@ async function packageBackendDirectory(sourceDirectory) {
18219
18219
  `apitogo-backend-${Date.now()}-${Math.random().toString(36).slice(2)}.zip`
18220
18220
  );
18221
18221
  await new Promise((resolve, reject) => {
18222
- const output3 = createWriteStream2(zipPath);
18222
+ const output4 = createWriteStream2(zipPath);
18223
18223
  const archive = new ZipArchive({ zlib: { level: 6 } });
18224
- output3.on("close", () => resolve());
18224
+ output4.on("close", () => resolve());
18225
18225
  archive.on("error", reject);
18226
- output3.on("error", reject);
18227
- archive.pipe(output3);
18226
+ output4.on("error", reject);
18227
+ archive.pipe(output4);
18228
18228
  for (const rel of files) {
18229
18229
  archive.append(createReadStream2(path58.join(resolved, rel)), { name: rel.split(path58.sep).join("/") });
18230
18230
  }
@@ -19604,7 +19604,24 @@ async function resolveProjectIdForPublish(client, config2, args, wait, progress,
19604
19604
  const completedSteps = [];
19605
19605
  if (args.projectId) {
19606
19606
  const projectId = resolveProjectId(args.projectId, config2);
19607
- const project = await client.getProject(projectId);
19607
+ let project;
19608
+ try {
19609
+ project = await client.getProject(projectId);
19610
+ } catch (error) {
19611
+ if (isNotFoundError(error)) {
19612
+ return {
19613
+ blocked: true,
19614
+ payload: {
19615
+ status: "blocked",
19616
+ reason: "project_not_found",
19617
+ projectId,
19618
+ userMessage: `Project ${projectId} was not found. It may have been deleted, or it belongs to a different account than the one you're currently logged in as.`,
19619
+ nextStep: "create_or_fix_project"
19620
+ }
19621
+ };
19622
+ }
19623
+ throw error;
19624
+ }
19608
19625
  if (!isPlatformPlanUnselected(project.planTier)) {
19609
19626
  await ensureModulesProvisioned(
19610
19627
  client,
@@ -19618,7 +19635,7 @@ async function resolveProjectIdForPublish(client, config2, args, wait, progress,
19618
19635
  );
19619
19636
  }
19620
19637
  completedSteps.push({ step: "resolve_project", status: "succeeded", detail: { projectId } });
19621
- return { projectId, completedSteps };
19638
+ return { blocked: false, projectId, completedSteps };
19622
19639
  }
19623
19640
  if (!args.projectName?.trim()) {
19624
19641
  throw new Error("projectName is required when projectId is not provided.");
@@ -19640,7 +19657,7 @@ async function resolveProjectIdForPublish(client, config2, args, wait, progress,
19640
19657
  );
19641
19658
  const bootstrap = parseHandlerResult(bootstrapJson, "bootstrap_project");
19642
19659
  completedSteps.push({ step: "bootstrap_project", status: "succeeded", detail: bootstrap });
19643
- return { projectId: bootstrap.projectId, completedSteps };
19660
+ return { blocked: false, projectId: bootstrap.projectId, completedSteps };
19644
19661
  }
19645
19662
 
19646
19663
  // src/cli/platform/tools/dev-portal.ts
@@ -19669,12 +19686,12 @@ async function packageDirectoryAsTarGz(sourceDirectory, options) {
19669
19686
  `apitogo-docs-${Date.now()}-${Math.random().toString(36).slice(2)}.tgz`
19670
19687
  );
19671
19688
  await new Promise((resolve, reject) => {
19672
- const output3 = createWriteStream3(archivePath);
19689
+ const output4 = createWriteStream3(archivePath);
19673
19690
  const archive = new TarArchive({ gzip: true, gzipOptions: { level: 6 } });
19674
- output3.on("close", () => resolve());
19691
+ output4.on("close", () => resolve());
19675
19692
  archive.on("error", reject);
19676
- output3.on("error", reject);
19677
- archive.pipe(output3);
19693
+ output4.on("error", reject);
19694
+ archive.pipe(output4);
19678
19695
  for (const rel of files) {
19679
19696
  const entryName = entryPrefix + rel.split(path59.sep).join("/");
19680
19697
  archive.append(createReadStream3(path59.join(resolved, rel)), { name: entryName });
@@ -20556,13 +20573,13 @@ async function runApplyFromSiteDirectory(client, config2, args, progress) {
20556
20573
  const ledgerResume = resolveResumeStepFromLedger(ledger, PUBLISH_STEPS);
20557
20574
  const effectiveResumeFromStep = args.resumeFromStep ?? ledgerResume;
20558
20575
  let publicRouteWarnings = [];
20559
- if (shouldRunPublishStep("resolve_project", effectiveResumeFromStep, completedSteps)) {
20576
+ if (args.createNewProject || shouldRunPublishStep("resolve_project", effectiveResumeFromStep, completedSteps)) {
20560
20577
  const timer = new StepTimer();
20561
20578
  const resolved = await resolveProjectIdForPublish(
20562
20579
  client,
20563
20580
  config2,
20564
20581
  {
20565
- projectId: args.projectId ?? manifest.projectId,
20582
+ projectId: args.createNewProject ? void 0 : args.projectId ?? manifest.projectId,
20566
20583
  projectName: args.projectName ?? resolveProjectDisplayName(manifest)
20567
20584
  },
20568
20585
  wait,
@@ -20570,13 +20587,48 @@ async function runApplyFromSiteDirectory(client, config2, args, progress) {
20570
20587
  args.timeoutMs,
20571
20588
  args.pollIntervalMs
20572
20589
  );
20590
+ if (resolved.blocked) {
20591
+ return JSON.stringify(
20592
+ {
20593
+ ...resolved.payload,
20594
+ completedSteps,
20595
+ sourceDirectory: args.sourceDirectory
20596
+ },
20597
+ null,
20598
+ 2
20599
+ );
20600
+ }
20573
20601
  projectId = resolved.projectId;
20574
20602
  for (const step of resolved.completedSteps) {
20575
20603
  completedSteps.push(step);
20576
20604
  }
20577
20605
  recordStep("resolve_project", "succeeded", timer.finish({ projectId }));
20578
20606
  } else {
20579
- projectId = resolveProjectId(args.projectId ?? manifest.projectId, config2);
20607
+ const candidateProjectId = resolveProjectId(
20608
+ args.projectId ?? manifest.projectId,
20609
+ config2
20610
+ );
20611
+ try {
20612
+ await client.getProject(candidateProjectId);
20613
+ } catch (error) {
20614
+ if (isNotFoundError(error)) {
20615
+ return JSON.stringify(
20616
+ {
20617
+ status: "blocked",
20618
+ reason: "project_not_found",
20619
+ projectId: candidateProjectId,
20620
+ userMessage: `Project ${candidateProjectId} was not found. It may have been deleted, or it belongs to a different account than the one you're currently logged in as.`,
20621
+ nextStep: "create_or_fix_project",
20622
+ completedSteps,
20623
+ sourceDirectory: args.sourceDirectory
20624
+ },
20625
+ null,
20626
+ 2
20627
+ );
20628
+ }
20629
+ throw error;
20630
+ }
20631
+ projectId = candidateProjectId;
20580
20632
  recordStep("resolve_project", "skipped", new StepTimer().finish());
20581
20633
  }
20582
20634
  manifest.projectId = projectId;
@@ -21226,6 +21278,20 @@ function formatNonSuccessResultForHuman(parsed) {
21226
21278
  );
21227
21279
  return lines;
21228
21280
  }
21281
+ if (status2 === "blocked" && parsed.reason === "project_not_found") {
21282
+ const projectId = typeof parsed.projectId === "string" ? parsed.projectId : void 0;
21283
+ const lines = [
21284
+ typeof parsed.userMessage === "string" ? parsed.userMessage : `Deploy is blocked: project${projectId ? ` ${projectId}` : ""} was not found.`
21285
+ ];
21286
+ lines.push(
21287
+ "This usually means the project was deleted, or it belongs to a different account than the one you're logged in as.",
21288
+ "",
21289
+ "To fix this:",
21290
+ " Run `apitogo login` and confirm you're using the right account, then re-run `apitogo deploy`",
21291
+ ' Or create a new project: remove "projectId" from apitogo.config.json and re-run `apitogo deploy`'
21292
+ );
21293
+ return lines;
21294
+ }
21229
21295
  if (status2 === "blocked" && parsed.reason === "paid_gateway_plans_require_starter") {
21230
21296
  const lines = [];
21231
21297
  lines.push(
@@ -21385,6 +21451,33 @@ ${ensured.checkoutUrl}`
21385
21451
  return true;
21386
21452
  }
21387
21453
 
21454
+ // src/cli/apply/project-not-found-prompt.ts
21455
+ import { stdin as input4, stdout as output3 } from "node:process";
21456
+ import { createInterface as createInterface3 } from "node:readline/promises";
21457
+ async function resolveProjectNotFoundInteractively(payload, defaultProjectName) {
21458
+ const projectId = typeof payload.projectId === "string" ? payload.projectId : "";
21459
+ const message = typeof payload.userMessage === "string" ? payload.userMessage : `Project ${projectId} was not found.`;
21460
+ printWarningToConsole(message);
21461
+ printDiagnosticsToConsole(
21462
+ "This usually means the project was deleted, or it belongs to a different account than the one you're logged in as."
21463
+ );
21464
+ printDiagnosticsToConsole(
21465
+ "If that's unexpected, cancel here and run `apitogo login` to check your account."
21466
+ );
21467
+ printDiagnosticsToConsole("");
21468
+ const rl = createInterface3({ input: input4, output: output3 });
21469
+ try {
21470
+ const createAnswer = (await rl.question("Create a new project instead? [Y/n] ")).trim().toLowerCase();
21471
+ if (createAnswer === "n" || createAnswer === "no") {
21472
+ return null;
21473
+ }
21474
+ const nameAnswer = (await rl.question(`Project name [${defaultProjectName}]: `)).trim();
21475
+ return { projectName: nameAnswer || defaultProjectName };
21476
+ } finally {
21477
+ rl.close();
21478
+ }
21479
+ }
21480
+
21388
21481
  // src/cli/apply/handler.ts
21389
21482
  function normalizeOnly(only) {
21390
21483
  if (!only) return [];
@@ -21429,18 +21522,22 @@ async function apply(argv) {
21429
21522
  }
21430
21523
  const platformPlan = argv.platformPlan?.trim();
21431
21524
  const progress = createConsoleProgressReporter();
21525
+ let effectiveProjectId = argv.projectId?.trim();
21526
+ let effectiveProjectName = argv.projectName?.trim();
21527
+ let createNewProject = false;
21432
21528
  const runOnce = (plan) => runApplyFromSiteDirectory(
21433
21529
  client,
21434
21530
  config2,
21435
21531
  {
21436
21532
  sourceDirectory,
21437
- projectId: argv.projectId?.trim(),
21438
- projectName: argv.projectName?.trim(),
21533
+ projectId: effectiveProjectId,
21534
+ projectName: effectiveProjectName,
21439
21535
  platformPlan: plan,
21440
21536
  only,
21441
21537
  force: argv.force,
21442
21538
  resumeFromStep: argv.resumeFrom?.trim(),
21443
- wait: argv.wait !== false
21539
+ wait: argv.wait !== false,
21540
+ createNewProject
21444
21541
  },
21445
21542
  progress
21446
21543
  );
@@ -21455,6 +21552,26 @@ async function apply(argv) {
21455
21552
  }
21456
21553
  let parsed = safeParseResult(result);
21457
21554
  const canPromptInteractively = !argv.json && Boolean(process.stdin.isTTY) && Boolean(process.stdout.isTTY);
21555
+ if (canPromptInteractively && parsed?.status === "blocked" && parsed.reason === "project_not_found") {
21556
+ const resolution = await resolveProjectNotFoundInteractively(
21557
+ parsed,
21558
+ path63.basename(sourceDirectory)
21559
+ );
21560
+ if (resolution) {
21561
+ effectiveProjectId = void 0;
21562
+ effectiveProjectName = resolution.projectName;
21563
+ createNewProject = true;
21564
+ try {
21565
+ result = await runOnce(platformPlan);
21566
+ } catch (error) {
21567
+ await printCriticalFailureToConsoleAndExit(
21568
+ error instanceof Error ? error.message : String(error)
21569
+ );
21570
+ return;
21571
+ }
21572
+ parsed = safeParseResult(result);
21573
+ }
21574
+ }
21458
21575
  if (canPromptInteractively && parsed?.status === "blocked" && parsed.reason === "platform_plan_unselected") {
21459
21576
  const resolved = await resolvePlatformPlanInteractively(
21460
21577
  client,
@@ -21869,10 +21986,10 @@ function siteRelative(siteDirectory, filePath) {
21869
21986
  function formatOpenApiDiscoveryLines(siteDirectory, openApiDiscovery) {
21870
21987
  const status2 = String(openApiDiscovery.status ?? "unknown");
21871
21988
  if (status2 === "wired") {
21872
- const input4 = typeof openApiDiscovery.openApiInput === "string" ? openApiDiscovery.openApiInput : typeof openApiDiscovery.openApiPath === "string" ? siteRelative(siteDirectory, openApiDiscovery.openApiPath) : "OpenAPI";
21989
+ const input5 = typeof openApiDiscovery.openApiInput === "string" ? openApiDiscovery.openApiInput : typeof openApiDiscovery.openApiPath === "string" ? siteRelative(siteDirectory, openApiDiscovery.openApiPath) : "OpenAPI";
21873
21990
  const title = typeof openApiDiscovery.openApiTitle === "string" ? ` (${openApiDiscovery.openApiTitle})` : "";
21874
21991
  const apiPath = typeof openApiDiscovery.apiReferencePath === "string" ? openApiDiscovery.apiReferencePath : "/api";
21875
- return [`OpenAPI: wired ${input4}${title} \u2192 ${apiPath}`];
21992
+ return [`OpenAPI: wired ${input5}${title} \u2192 ${apiPath}`];
21876
21993
  }
21877
21994
  if (status2 === "skipped") {
21878
21995
  return ["OpenAPI: search skipped"];
@@ -21924,23 +22041,23 @@ async function pathExists6(filePath) {
21924
22041
  }
21925
22042
  }
21926
22043
  async function wireOpenApiIntoJsonConfig(siteDirectory, openApiPath) {
21927
- const input4 = toSiteRelativeOpenApiInput(siteDirectory, openApiPath);
22044
+ const input5 = toSiteRelativeOpenApiInput(siteDirectory, openApiPath);
21928
22045
  const jsonConfigPath = path65.join(siteDirectory, "apitogo.config.json");
21929
22046
  const raw = await readFile19(jsonConfigPath, "utf8");
21930
22047
  const siteConfig = JSON.parse(raw);
21931
22048
  const updated = applyOpenApiToSiteConfig(siteConfig, {
21932
- input: input4,
22049
+ input: input5,
21933
22050
  apiPath: "api"
21934
22051
  });
21935
22052
  const backend = updated.backend && typeof updated.backend === "object" && !Array.isArray(updated.backend) ? { ...updated.backend } : {};
21936
- updated.backend = { ...backend, openApiPath: input4 };
22053
+ updated.backend = { ...backend, openApiPath: input5 };
21937
22054
  await writeFile18(
21938
22055
  jsonConfigPath,
21939
22056
  `${JSON.stringify(updated, null, 2)}
21940
22057
  `,
21941
22058
  "utf8"
21942
22059
  );
21943
- return { input: input4 };
22060
+ return { input: input5 };
21944
22061
  }
21945
22062
  async function discoverAndWireOpenApiLite(siteDirectory, mode) {
21946
22063
  if (mode === "none") {
@@ -21992,7 +22109,7 @@ async function discoverAndWireOpenApiLite(siteDirectory, mode) {
21992
22109
  };
21993
22110
  }
21994
22111
  try {
21995
- const { input: input4 } = await wireOpenApiIntoJsonConfig(
22112
+ const { input: input5 } = await wireOpenApiIntoJsonConfig(
21996
22113
  siteDirectory,
21997
22114
  selected.path
21998
22115
  );
@@ -22000,7 +22117,7 @@ async function discoverAndWireOpenApiLite(siteDirectory, mode) {
22000
22117
  openApiDiscovery: {
22001
22118
  status: "wired",
22002
22119
  openApiPath: selected.path,
22003
- openApiInput: input4,
22120
+ openApiInput: input5,
22004
22121
  openApiTitle: selected.title ?? null,
22005
22122
  openApiVersion: selected.version ?? null,
22006
22123
  apiReferencePath: "/api",
@@ -1,4 +1,4 @@
1
- import type { PlatformApiClient } from "../client/platform-api.js";
1
+ import { type PlatformApiClient } from "../client/platform-api.js";
2
2
  import { type ApitogoConfig } from "../config.js";
3
3
  import type { ProgressReporter } from "../helpers/progress.js";
4
4
  export interface StepRecord {
@@ -16,10 +16,15 @@ export declare function parseHandlerResult<T extends {
16
16
  }>(json: string, step: string): T;
17
17
  export declare function ensureModuleProvisioned(client: PlatformApiClient, config: ApitogoConfig, projectId: string, moduleType: string, wait: boolean, timeoutMs?: number, pollIntervalMs?: number, progress?: ProgressReporter): Promise<void>;
18
18
  export declare function ensureModulesProvisioned(client: PlatformApiClient, config: ApitogoConfig, projectId: string, moduleTypes: string[], wait: boolean, timeoutMs?: number, pollIntervalMs?: number, progress?: ProgressReporter): Promise<void>;
19
+ export type ResolveProjectIdResult = {
20
+ blocked: false;
21
+ projectId: string;
22
+ completedSteps: StepRecord[];
23
+ } | {
24
+ blocked: true;
25
+ payload: Record<string, unknown>;
26
+ };
19
27
  export declare function resolveProjectIdForPublish(client: PlatformApiClient, config: ApitogoConfig, args: {
20
28
  projectId?: string;
21
29
  projectName?: string;
22
- }, wait: boolean, progress?: ProgressReporter, timeoutMs?: number, pollIntervalMs?: number): Promise<{
23
- projectId: string;
24
- completedSteps: StepRecord[];
25
- }>;
30
+ }, wait: boolean, progress?: ProgressReporter, timeoutMs?: number, pollIntervalMs?: number): Promise<ResolveProjectIdResult>;
@@ -1,4 +1,4 @@
1
- import type { PlatformApiClient } from "../client/platform-api.js";
1
+ import { type PlatformApiClient } from "../client/platform-api.js";
2
2
  import { type ApitogoConfig } from "../config.js";
3
3
  import { type DevPortalLocalManifest } from "../helpers/dev-portal-manifest.js";
4
4
  import { type DevPortalLocalSecrets } from "../helpers/dev-portal-secrets.js";
@@ -23,6 +23,7 @@ export interface PublishDevPortalArgs {
23
23
  only?: ApplyResource[];
24
24
  force?: boolean;
25
25
  resumeFromStep?: PublishStepId;
26
+ createNewProject?: boolean;
26
27
  }
27
28
  export type ApplyFromSiteDirectoryArgs = PublishDevPortalArgs;
28
29
  export declare function validateManifestForPublish(manifest: DevPortalLocalManifest, secrets: DevPortalLocalSecrets, emailOptions?: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lukoweb/apitogo",
3
- "version": "0.1.118",
3
+ "version": "0.1.119",
4
4
  "type": "module",
5
5
  "sideEffects": [
6
6
  "**/*.css",