betterstart-cli 0.0.115 → 0.0.116

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.
@@ -5,6 +5,7 @@ import type { UploadedFile } from '@admin/types'
5
5
  import { createMedia } from '@admin/actions/media'
6
6
  import { saveUpload } from '@admin/actions/storage'
7
7
  import { requireRole, UserRole } from '@admin/auth/middleware'
8
+ import { toActionError } from '@admin/utils/error/to-action-error'
8
9
 
9
10
  export async function uploadFiles(
10
11
  formData: FormData,
@@ -89,7 +90,6 @@ export async function uploadFiles(
89
90
 
90
91
  return { success: true, files: uploadedFiles }
91
92
  } catch (error) {
92
- const message = error instanceof Error ? error.message : 'Failed to upload files'
93
- return { success: false, error: message }
93
+ return { success: false, error: toActionError(error, 'Failed to upload files') }
94
94
  }
95
95
  }
@@ -4,6 +4,7 @@ import type { RemoteUploadOptions, UploadResult } from './types'
4
4
  import { createMedia } from '@admin/actions/media'
5
5
  import { saveUpload } from '@admin/actions/storage'
6
6
  import { requireRole, UserRole } from '@admin/auth/middleware'
7
+ import { toActionError } from '@admin/utils/error/to-action-error'
7
8
  import { DEFAULT_REMOTE_ACCEPT } from '@admin/utils/upload/default-remote-accept'
8
9
  import { getRemoteFilename } from '@admin/utils/upload/get-remote-filename'
9
10
  import { isAcceptedRemoteType } from '@admin/utils/upload/is-accepted-remote-type'
@@ -128,7 +129,6 @@ export async function uploadMediaFromUrl(
128
129
  ]
129
130
  }
130
131
  } catch (error) {
131
- const message = error instanceof Error ? error.message : 'Failed to upload media from URL'
132
- return { success: false, error: message }
132
+ return { success: false, error: toActionError(error, 'Failed to upload media from URL') }
133
133
  }
134
134
  }
@@ -1,8 +1,11 @@
1
1
  import { dynamicIconImports } from 'lucide-react/dynamic'
2
2
 
3
- export const iconsData = Object.keys(dynamicIconImports).map((name) => ({
3
+ export interface IconData {
4
+ name: string
5
+ categories: string[]
6
+ }
7
+
8
+ export const iconsData: IconData[] = Object.keys(dynamicIconImports).map((name) => ({
4
9
  name,
5
- categories: [] as string[]
10
+ categories: []
6
11
  }))
7
-
8
- export type IconData = (typeof iconsData)[number]
package/dist/cli.js CHANGED
@@ -531,7 +531,7 @@ function unique(values) {
531
531
  return Array.from(new Set(values));
532
532
  }
533
533
  function arraysEqual(a, b) {
534
- return Boolean(a && a.length === b.length && a.every((value, index) => value === b[index]));
534
+ return Array.isArray(a) && a.length === b.length && a.every((value, index) => value === b[index]);
535
535
  }
536
536
  function isValidPort(port) {
537
537
  return Number.isInteger(port) && port > 0 && port <= 65535;
@@ -1125,25 +1125,41 @@ function flattenSlotLayout(slot) {
1125
1125
 
1126
1126
  // core-engine/schema/schema-reader/walk-slot-aware-field.ts
1127
1127
  function walkSlotAwareField(field, fieldPath, errors, options) {
1128
+ if (!isRecord(field)) {
1129
+ errors.push(`Field "${fieldPath}" must be an object.`);
1130
+ return;
1131
+ }
1128
1132
  options.checkField(field, fieldPath, errors);
1133
+ const childPath = (parentPath, child) => `${parentPath}.${isRecord(child) && isNonEmptyString(child.name) ? child.name : "unnamed"}`;
1129
1134
  const descend = (children, parentPath) => {
1135
+ if (!Array.isArray(children)) {
1136
+ errors.push(`Field "${parentPath}" has a "fields" value that must be an array.`);
1137
+ return;
1138
+ }
1130
1139
  for (const child of children) {
1131
- walkSlotAwareField(child, `${parentPath}.${child.name ?? "unnamed"}`, errors, options);
1140
+ walkSlotAwareField(child, childPath(parentPath, child), errors, options);
1132
1141
  }
1133
1142
  };
1134
- if (field.fields) {
1143
+ if (field.fields !== void 0) {
1135
1144
  descend(field.fields, fieldPath);
1136
1145
  }
1137
- if (field.tabs) {
1138
- for (const tab of field.tabs) {
1139
- const tabPath = `${fieldPath}.${tab.name ?? "unnamed"}`;
1140
- options.onTab?.(tab, tabPath, errors);
1141
- if (options.descendTabSlots && tab.slot !== void 0) {
1142
- descend(flattenSlotLayout(tab.slot), tabPath);
1143
- }
1144
- if (tab.fields) {
1145
- descend(tab.fields, tabPath);
1146
- }
1146
+ if (field.tabs === void 0) return;
1147
+ if (!Array.isArray(field.tabs)) {
1148
+ errors.push(`Field "${fieldPath}" has a "tabs" value that must be an array.`);
1149
+ return;
1150
+ }
1151
+ for (const tab of field.tabs) {
1152
+ const tabPath = childPath(fieldPath, tab);
1153
+ if (!isRecord(tab)) {
1154
+ errors.push(`Tab "${tabPath}" must be an object.`);
1155
+ continue;
1156
+ }
1157
+ options.onTab?.(tab, tabPath, errors);
1158
+ if (options.descendTabSlots && tab.slot !== void 0) {
1159
+ descend(flattenSlotLayout(tab.slot), tabPath);
1160
+ }
1161
+ if (tab.fields !== void 0) {
1162
+ descend(tab.fields, tabPath);
1147
1163
  }
1148
1164
  }
1149
1165
  }
@@ -1166,7 +1182,8 @@ function walkHeight(field, fieldPath, errors) {
1166
1182
  function collectInvalidHeightErrors(topLevelFields, rootPath, errors) {
1167
1183
  const prefix = rootPath ? `${rootPath}.` : "";
1168
1184
  for (const field of topLevelFields) {
1169
- walkHeight(field, `${prefix}${field.name ?? "unnamed"}`, errors);
1185
+ const name = isRecord(field) && isNonEmptyString(field.name) ? field.name : "unnamed";
1186
+ walkHeight(field, `${prefix}${name}`, errors);
1170
1187
  }
1171
1188
  }
1172
1189
 
@@ -1240,7 +1257,8 @@ function collectSlotAreaErrors(value, path113, errors) {
1240
1257
  return;
1241
1258
  }
1242
1259
  for (const field of fields) {
1243
- walkSlot(field, `${path113}.fields.${field.name ?? "unnamed"}`, errors);
1260
+ const name = isRecord(field) && isNonEmptyString(field.name) ? field.name : "unnamed";
1261
+ walkSlot(field, `${path113}.fields.${name}`, errors);
1244
1262
  }
1245
1263
  }
1246
1264
 
@@ -1297,7 +1315,8 @@ function walkSlot(field, fieldPath, errors) {
1297
1315
  function collectInvalidSlotErrors(fields, rootPath, errors) {
1298
1316
  const prefix = rootPath ? `${rootPath}.` : "";
1299
1317
  for (const field of fields) {
1300
- walkSlot(field, `${prefix}${field.name ?? "unnamed"}`, errors);
1318
+ const name = isRecord(field) && isNonEmptyString(field.name) ? field.name : "unnamed";
1319
+ walkSlot(field, `${prefix}${name}`, errors);
1301
1320
  }
1302
1321
  }
1303
1322
 
@@ -2167,8 +2186,7 @@ function loadSchema(schemasDir, name) {
2167
2186
  const filePath = resolveSchemaFilePath(schemasDir, name);
2168
2187
  const content = fs10.readFileSync(filePath, "utf-8");
2169
2188
  const parsed = parseSchemaJson(content, filePath);
2170
- const obj = parsed;
2171
- switch (schemaKindFromType(name, obj.type)) {
2189
+ switch (schemaKindFromType(name, isRecord(parsed) ? parsed.type : void 0)) {
2172
2190
  case "form":
2173
2191
  return { type: "form", schema: parsed, filePath };
2174
2192
  case "single":
@@ -2287,7 +2305,7 @@ function detectPackageManager(cwd) {
2287
2305
  if (!fs14.existsSync(pkgPath)) return void 0;
2288
2306
  try {
2289
2307
  const pkg = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
2290
- if (typeof pkg.packageManager === "string") {
2308
+ if (isRecord(pkg) && typeof pkg.packageManager === "string") {
2291
2309
  const name = pkg.packageManager.split("@")[0];
2292
2310
  if (name === "pnpm" || name === "npm" || name === "yarn" || name === "bun") return name;
2293
2311
  }
@@ -5931,7 +5949,7 @@ function formatTsValue(value, indent = 0) {
5931
5949
  ${value.map((item) => `${childIndent}${formatTsValue(item, indent + 2)}`).join(",\n")}
5932
5950
  ${currentIndent}]`;
5933
5951
  }
5934
- if (value && typeof value === "object") {
5952
+ if (isRecord(value)) {
5935
5953
  return formatTsObject(value, indent);
5936
5954
  }
5937
5955
  return JSON.stringify(value);
@@ -9237,11 +9255,13 @@ function genBarrelContent(files, ctx) {
9237
9255
  `${ctx.Singular}UpdateInput`,
9238
9256
  `${ctx.Singular}UpdateResult`,
9239
9257
  `${ctx.Singular}DeleteResult`,
9240
- ctx.hasCreatableSelectFields ? `${ctx.Singular}SelectOption` : null,
9241
- ctx.hasCreatableSelectFields ? `${ctx.Singular}SelectOptionFieldName` : null,
9242
- ctx.hasCreatableSelectFields ? `Create${ctx.Singular}SelectOptionInput` : null,
9243
- ctx.hasCreatableSelectFields ? `Create${ctx.Singular}SelectOptionResult` : null
9244
- ].filter(Boolean);
9258
+ ...ctx.hasCreatableSelectFields ? [
9259
+ `${ctx.Singular}SelectOption`,
9260
+ `${ctx.Singular}SelectOptionFieldName`,
9261
+ `Create${ctx.Singular}SelectOptionInput`,
9262
+ `Create${ctx.Singular}SelectOptionResult`
9263
+ ] : []
9264
+ ];
9245
9265
  lines.push(`export type { ${typeNames.join(", ")} } from './types'`);
9246
9266
  lines.push("");
9247
9267
  for (const file of files) {
@@ -25965,36 +25985,26 @@ function buildLeafField(input) {
25965
25985
  if (errors.length > 0) {
25966
25986
  throw new Error(errors.join("\n"));
25967
25987
  }
25968
- const field = {
25988
+ if (input.kind === "form") {
25989
+ return {
25990
+ name: input.name,
25991
+ type: input.type,
25992
+ label: input.label,
25993
+ ...input.required ? { required: true } : {},
25994
+ ...input.multiple && input.type === "file" ? { multiple: true } : {},
25995
+ ...input.options?.length ? { options: input.options } : {}
25996
+ };
25997
+ }
25998
+ return {
25969
25999
  name: input.name,
25970
26000
  type: input.type,
25971
- label: input.label
26001
+ label: input.label,
26002
+ ...input.required ? { required: true } : {},
26003
+ ...input.multiple && ["select", "relationship"].includes(input.type) ? { multiple: true } : {},
26004
+ ...input.creatable && input.type === "select" ? { creatable: true } : {},
26005
+ ...input.options?.length ? { options: input.options } : {},
26006
+ ...input.relationship && input.type === "relationship" ? { relationship: input.relationship } : {}
25972
26007
  };
25973
- if (input.required) {
25974
- field.required = true;
25975
- }
25976
- if (input.kind === "form") {
25977
- if (input.multiple && input.type === "file") {
25978
- field.multiple = true;
25979
- }
25980
- if (input.options && input.options.length > 0) {
25981
- field.options = input.options;
25982
- }
25983
- return field;
25984
- }
25985
- if (input.multiple && ["select", "relationship"].includes(input.type)) {
25986
- field.multiple = true;
25987
- }
25988
- if (input.creatable && input.type === "select") {
25989
- field.creatable = true;
25990
- }
25991
- if (input.options && input.options.length > 0) {
25992
- field.options = input.options;
25993
- }
25994
- if (input.relationship && input.type === "relationship") {
25995
- field.relationship = input.relationship;
25996
- }
25997
- return field;
25998
26008
  }
25999
26009
 
26000
26010
  // adapters/next/commands/schema-prompts/apply-advanced-options.ts
@@ -26112,14 +26122,12 @@ function applyDerivedFieldDefaults(field, type, options) {
26112
26122
  if (!options.derivePlaceholder) {
26113
26123
  return;
26114
26124
  }
26115
- const record = field;
26116
- if (typeof record.placeholder === "string" && record.placeholder.trim()) {
26125
+ if (typeof field.placeholder === "string" && field.placeholder.trim()) {
26117
26126
  return;
26118
26127
  }
26119
- const label = typeof record.label === "string" ? record.label : "";
26120
- const placeholder = derivePlaceholderFromLabel(type, label);
26128
+ const placeholder = derivePlaceholderFromLabel(type, field.label ?? "");
26121
26129
  if (placeholder) {
26122
- record.placeholder = placeholder;
26130
+ field.placeholder = placeholder;
26123
26131
  }
26124
26132
  }
26125
26133
 
@@ -29830,17 +29838,19 @@ function guardPackageJson(cwd, restores) {
29830
29838
  } catch {
29831
29839
  return { localSpecDeps: [], removedCliDep: false };
29832
29840
  }
29841
+ if (!isRecord(parsed)) {
29842
+ return { localSpecDeps: [], removedCliDep: false };
29843
+ }
29833
29844
  const localSpecDeps = [];
29834
29845
  let removedCliDep = false;
29835
29846
  for (const section of ["dependencies", "devDependencies"]) {
29836
29847
  const deps = parsed[section];
29837
- if (!deps || typeof deps !== "object") continue;
29838
- const record = deps;
29839
- if ("betterstart-cli" in record) {
29840
- Reflect.deleteProperty(record, "betterstart-cli");
29848
+ if (!isRecord(deps)) continue;
29849
+ if ("betterstart-cli" in deps) {
29850
+ Reflect.deleteProperty(deps, "betterstart-cli");
29841
29851
  removedCliDep = true;
29842
29852
  }
29843
- for (const [name, spec] of Object.entries(record)) {
29853
+ for (const [name, spec] of Object.entries(deps)) {
29844
29854
  if (typeof spec === "string" && LOCAL_PROTOCOL_PATTERN.test(spec)) {
29845
29855
  localSpecDeps.push(name);
29846
29856
  }
@@ -30007,13 +30017,12 @@ function parseRailwayJson(output) {
30007
30017
 
30008
30018
  // adapters/next/init/railway/resources/parse-service.ts
30009
30019
  function parseService(value) {
30010
- if (!value || typeof value !== "object") return void 0;
30011
- const service = value;
30012
- if (!isNonEmptyString(service.id) || !isNonEmptyString(service.name)) return void 0;
30013
- const replicas = service.replicas && typeof service.replicas === "object" ? service.replicas : void 0;
30020
+ if (!isRecord(value)) return void 0;
30021
+ if (!isNonEmptyString(value.id) || !isNonEmptyString(value.name)) return void 0;
30022
+ const replicas = isRecord(value.replicas) ? value.replicas : void 0;
30014
30023
  return {
30015
- id: service.id,
30016
- name: service.name,
30024
+ id: value.id,
30025
+ name: value.name,
30017
30026
  replicaCount: typeof replicas?.configured === "number" ? replicas.configured : void 0
30018
30027
  };
30019
30028
  }
@@ -30039,8 +30048,8 @@ ${result.stderr}`) ?? "Could not list Railway services."
30039
30048
  if (!Array.isArray(payload)) {
30040
30049
  throw new Error("Railway returned an invalid service list response.");
30041
30050
  }
30042
- const services = payload.map(parseService);
30043
- if (services.some((service) => !service)) {
30051
+ const services = payload.map(parseService).filter((service) => service !== void 0);
30052
+ if (services.length !== payload.length) {
30044
30053
  throw new Error("Railway returned an invalid service list response.");
30045
30054
  }
30046
30055
  return services;
@@ -30076,7 +30085,7 @@ function deploymentLine(line) {
30076
30085
  let message = line;
30077
30086
  try {
30078
30087
  const parsed = JSON.parse(line);
30079
- const jsonMessage = parsed.message ?? parsed.status;
30088
+ const jsonMessage = isRecord(parsed) ? parsed.message ?? parsed.status : void 0;
30080
30089
  if (typeof jsonMessage === "string") message = jsonMessage;
30081
30090
  } catch {
30082
30091
  }
@@ -30094,26 +30103,21 @@ function parseDomainUrl(value) {
30094
30103
  return void 0;
30095
30104
  }
30096
30105
  }
30097
- if (!value || typeof value !== "object") return void 0;
30098
- const record = value;
30099
- return parseDomainUrl(record.domain);
30106
+ return isRecord(value) ? parseDomainUrl(value.domain) : void 0;
30100
30107
  }
30101
30108
 
30102
30109
  // adapters/next/init/railway/deploy/first-domain-url.ts
30103
30110
  function firstDomainUrl(payload) {
30104
30111
  const direct = parseDomainUrl(payload);
30105
30112
  if (direct) return direct;
30106
- if (!payload || typeof payload !== "object") return void 0;
30107
- const domains = payload.domains;
30108
- return Array.isArray(domains) ? domains.map(parseDomainUrl).find((domain) => Boolean(domain)) : void 0;
30113
+ if (!isRecord(payload) || !Array.isArray(payload.domains)) return void 0;
30114
+ return payload.domains.map(parseDomainUrl).find((domain) => Boolean(domain));
30109
30115
  }
30110
30116
 
30111
30117
  // adapters/next/init/railway/deploy/parse-domain-list.ts
30112
30118
  function parseDomainList(payload) {
30113
- if (!payload || typeof payload !== "object" || Array.isArray(payload)) return void 0;
30114
- const domains = payload.domains;
30115
- if (!Array.isArray(domains)) return void 0;
30116
- const parsed = domains.map(parseDomainUrl);
30119
+ if (!isRecord(payload) || !Array.isArray(payload.domains)) return void 0;
30120
+ const parsed = payload.domains.map(parseDomainUrl);
30117
30121
  return parsed.every((domain) => Boolean(domain)) ? parsed : void 0;
30118
30122
  }
30119
30123
 
@@ -30198,14 +30202,17 @@ ${result.stderr}`) ?? `Could not read Railway variables for ${service}.`
30198
30202
  );
30199
30203
  }
30200
30204
  const payload = parseRailwayJson(result.stdout);
30201
- if (!payload || typeof payload !== "object" || Array.isArray(payload)) {
30205
+ if (!isRecord(payload)) {
30202
30206
  throw new Error(`Railway returned an invalid variable list response for ${service}.`);
30203
30207
  }
30204
- const entries = Object.entries(payload);
30205
- if (entries.some(([, value]) => typeof value !== "string")) {
30206
- throw new Error(`Railway returned an invalid variable list response for ${service}.`);
30208
+ const variables = {};
30209
+ for (const [name, value] of Object.entries(payload)) {
30210
+ if (typeof value !== "string") {
30211
+ throw new Error(`Railway returned an invalid variable list response for ${service}.`);
30212
+ }
30213
+ variables[name] = value;
30207
30214
  }
30208
- return Object.fromEntries(entries);
30215
+ return variables;
30209
30216
  }
30210
30217
 
30211
30218
  // adapters/next/init/railway/deploy/collect-railway-deploy-env-vars.ts
@@ -30412,32 +30419,18 @@ ${deploy.stderr}`) ?? deploy.errorMessage
30412
30419
 
30413
30420
  // adapters/next/init/railway/resources/parse-bucket-credentials.ts
30414
30421
  function parseBucketCredentials(value) {
30415
- if (!value || typeof value !== "object") return void 0;
30416
- const credentials = value;
30417
- const keys = [
30418
- "endpoint",
30419
- "accessKeyId",
30420
- "secretAccessKey",
30421
- "bucketName",
30422
- "region",
30423
- "urlStyle"
30424
- ];
30425
- if (!keys.every((key) => isNonEmptyString(credentials[key]))) return void 0;
30426
- return {
30427
- endpoint: credentials.endpoint,
30428
- accessKeyId: credentials.accessKeyId,
30429
- secretAccessKey: credentials.secretAccessKey,
30430
- bucketName: credentials.bucketName,
30431
- region: credentials.region,
30432
- urlStyle: credentials.urlStyle
30433
- };
30422
+ if (!isRecord(value)) return void 0;
30423
+ const { endpoint, accessKeyId, secretAccessKey, bucketName, region, urlStyle } = value;
30424
+ if (!isNonEmptyString(endpoint) || !isNonEmptyString(accessKeyId) || !isNonEmptyString(secretAccessKey) || !isNonEmptyString(bucketName) || !isNonEmptyString(region) || !isNonEmptyString(urlStyle)) {
30425
+ return void 0;
30426
+ }
30427
+ return { endpoint, accessKeyId, secretAccessKey, bucketName, region, urlStyle };
30434
30428
  }
30435
30429
 
30436
30430
  // adapters/next/init/railway/resources/parse-bucket.ts
30437
30431
  function parseBucket(value) {
30438
- if (!value || typeof value !== "object") return void 0;
30439
- const bucket = value;
30440
- return isNonEmptyString(bucket.id) && isNonEmptyString(bucket.name) ? { id: bucket.id, name: bucket.name } : void 0;
30432
+ if (!isRecord(value)) return void 0;
30433
+ return isNonEmptyString(value.id) && isNonEmptyString(value.name) ? { id: value.id, name: value.name } : void 0;
30441
30434
  }
30442
30435
 
30443
30436
  // adapters/next/init/railway/resources/provision-railway-bucket-resource.ts
@@ -30573,10 +30566,9 @@ import pc5 from "picocolors";
30573
30566
 
30574
30567
  // adapters/next/init/railway/auth/is-railway-account.ts
30575
30568
  function isRailwayAccount(value) {
30576
- if (!value || typeof value !== "object") return false;
30577
- const account = value;
30578
- return typeof account.email === "string" && Array.isArray(account.workspaces) && account.workspaces.every(
30579
- (workspace) => workspace !== null && typeof workspace === "object" && typeof workspace.id === "string" && typeof workspace.name === "string"
30569
+ if (!isRecord(value)) return false;
30570
+ return typeof value.email === "string" && Array.isArray(value.workspaces) && value.workspaces.every(
30571
+ (workspace) => isRecord(workspace) && typeof workspace.id === "string" && typeof workspace.name === "string"
30580
30572
  );
30581
30573
  }
30582
30574
 
@@ -30607,9 +30599,7 @@ async function checkRailwayProjectToken(runner, cwd, env) {
30607
30599
  return { authed: false, reason: result.timedOut ? "timeout" : "invalid-token" };
30608
30600
  }
30609
30601
  const project2 = parseRailwayJson(result.stdout);
30610
- if (!project2 || typeof project2 !== "object") return { authed: false, reason: "failed" };
30611
- const record = project2;
30612
- return typeof record.id === "string" && typeof record.name === "string" ? { authed: true } : { authed: false, reason: "failed" };
30602
+ return isRecord(project2) && typeof project2.id === "string" && typeof project2.name === "string" ? { authed: true } : { authed: false, reason: "failed" };
30613
30603
  }
30614
30604
 
30615
30605
  // adapters/next/init/railway/auth/ensure-railway-auth.ts
@@ -30686,18 +30676,14 @@ function isRailwayProjectNameConflict(detail) {
30686
30676
 
30687
30677
  // adapters/next/init/railway/project/parse-project-summary.ts
30688
30678
  function parseProjectSummary(value) {
30689
- if (!value || typeof value !== "object") return void 0;
30690
- const project2 = value;
30691
- if (!isNonEmptyString(project2.id) || !isNonEmptyString(project2.name)) return void 0;
30692
- const workspaceValue = project2.workspace;
30679
+ if (!isRecord(value)) return void 0;
30680
+ if (!isNonEmptyString(value.id) || !isNonEmptyString(value.name)) return void 0;
30681
+ const candidate = value.workspace;
30693
30682
  let workspace;
30694
- if (workspaceValue && typeof workspaceValue === "object") {
30695
- const candidate = workspaceValue;
30696
- if (isNonEmptyString(candidate.id) && isNonEmptyString(candidate.name)) {
30697
- workspace = { id: candidate.id, name: candidate.name };
30698
- }
30683
+ if (isRecord(candidate) && isNonEmptyString(candidate.id) && isNonEmptyString(candidate.name)) {
30684
+ workspace = { id: candidate.id, name: candidate.name };
30699
30685
  }
30700
- return { id: project2.id, name: project2.name, workspace };
30686
+ return { id: value.id, name: value.name, workspace };
30701
30687
  }
30702
30688
 
30703
30689
  // adapters/next/init/railway/project/railway-project-name-is-taken.ts
@@ -30735,9 +30721,7 @@ ${result.stderr}`);
30735
30721
 
30736
30722
  // adapters/next/init/railway/project/is-deleted-railway-project.ts
30737
30723
  function isDeletedRailwayProject(value) {
30738
- if (!value || typeof value !== "object") return false;
30739
- const deletedAt = value.deletedAt;
30740
- return isNonEmptyString(deletedAt);
30724
+ return isRecord(value) && isNonEmptyString(value.deletedAt);
30741
30725
  }
30742
30726
 
30743
30727
  // adapters/next/init/railway/project/list-railway-projects.ts
@@ -30757,8 +30741,9 @@ ${result.stderr}`) ?? "Could not list Railway projects."
30757
30741
  if (!Array.isArray(payload)) {
30758
30742
  throw new Error("Railway returned an invalid project list response.");
30759
30743
  }
30760
- const projects = payload.filter((project2) => !isDeletedRailwayProject(project2)).map(parseProjectSummary);
30761
- if (projects.some((project2) => !project2)) {
30744
+ const live = payload.filter((project2) => !isDeletedRailwayProject(project2));
30745
+ const projects = live.map(parseProjectSummary).filter((project2) => project2 !== void 0);
30746
+ if (projects.length !== live.length) {
30762
30747
  throw new Error("Railway returned an invalid project list response.");
30763
30748
  }
30764
30749
  return projects;
@@ -33343,8 +33328,12 @@ function scaffoldTsconfig(cwd, config) {
33343
33328
  skipped.push("Failed to parse tsconfig.json");
33344
33329
  return { added, skipped };
33345
33330
  }
33346
- const compilerOptions = tsconfig.compilerOptions ?? {};
33347
- const paths = compilerOptions.paths ?? {};
33331
+ if (!isRecord(tsconfig)) {
33332
+ skipped.push("Failed to parse tsconfig.json");
33333
+ return { added, skipped };
33334
+ }
33335
+ const compilerOptions = isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : {};
33336
+ const paths = isRecord(compilerOptions.paths) ? compilerOptions.paths : {};
33348
33337
  if (compilerOptions.resolveJsonModule === true) {
33349
33338
  skipped.push("compilerOptions.resolveJsonModule");
33350
33339
  } else {
@@ -33706,7 +33695,9 @@ function readLinkedProjectJson(cwd) {
33706
33695
  try {
33707
33696
  const projectJsonPath = path82.join(cwd, ".vercel", "project.json");
33708
33697
  if (!fs70.existsSync(projectJsonPath)) return void 0;
33709
- return JSON.parse(fs70.readFileSync(projectJsonPath, "utf-8"));
33698
+ const parsed = JSON.parse(fs70.readFileSync(projectJsonPath, "utf-8"));
33699
+ if (!isRecord(parsed)) return void 0;
33700
+ return typeof parsed.projectId === "string" ? { projectId: parsed.projectId } : {};
33710
33701
  } catch {
33711
33702
  return void 0;
33712
33703
  }
@@ -34478,11 +34469,11 @@ function parseIdList(value, isId, formatUnknownMessage) {
34478
34469
  return [];
34479
34470
  }
34480
34471
  const ids = value.split(",").map((entry) => entry.trim()).filter(Boolean);
34481
- const invalid = ids.filter((id) => !isId(id));
34482
- if (invalid.length > 0) {
34483
- throw new Error(formatUnknownMessage(invalid));
34472
+ const valid = ids.filter(isId);
34473
+ if (valid.length !== ids.length) {
34474
+ throw new Error(formatUnknownMessage(ids.filter((id) => !isId(id))));
34484
34475
  }
34485
- return unique(ids);
34476
+ return unique(valid);
34486
34477
  }
34487
34478
 
34488
34479
  // adapters/next/integration-runtime/parse-integration-list.ts
@@ -39426,21 +39417,18 @@ function collectSchemaRelationshipTargets(loaded) {
39426
39417
  function walkFields2(fields) {
39427
39418
  if (!Array.isArray(fields)) return;
39428
39419
  for (const field of fields) {
39429
- if (!field || typeof field !== "object") {
39420
+ if (!isRecord(field)) {
39430
39421
  continue;
39431
39422
  }
39432
- const fieldRecord = field;
39433
- const relationship = typeof fieldRecord.relationship === "string" ? fieldRecord.relationship : void 0;
39434
- if (relationship) {
39435
- targets.add(relationship);
39423
+ if (typeof field.relationship === "string") {
39424
+ targets.add(field.relationship);
39436
39425
  }
39437
- walkFields2(fieldRecord.fields);
39438
- if (Array.isArray(fieldRecord.tabs)) {
39439
- for (const tab of fieldRecord.tabs) {
39440
- if (!tab || typeof tab !== "object") {
39441
- continue;
39426
+ walkFields2(field.fields);
39427
+ if (Array.isArray(field.tabs)) {
39428
+ for (const tab of field.tabs) {
39429
+ if (isRecord(tab)) {
39430
+ walkFields2(tab.fields);
39442
39431
  }
39443
- walkFields2(tab.fields);
39444
39432
  }
39445
39433
  }
39446
39434
  }
@@ -39964,8 +39952,9 @@ function cleanTsconfig(tsconfigPath, aliasRoot = "@admin") {
39964
39952
  } catch {
39965
39953
  return [];
39966
39954
  }
39967
- const compilerOptions = tsconfig.compilerOptions ?? {};
39968
- const paths = compilerOptions.paths ?? {};
39955
+ if (!isRecord(tsconfig)) return [];
39956
+ const compilerOptions = isRecord(tsconfig.compilerOptions) ? tsconfig.compilerOptions : {};
39957
+ const paths = isRecord(compilerOptions.paths) ? compilerOptions.paths : {};
39969
39958
  const removed = [];
39970
39959
  for (const key of Object.keys(paths)) {
39971
39960
  if (key.startsWith("@admin/") || key === "@admin/*" || key.startsWith(`${aliasRoot}/`) || key === `${aliasRoot}/*`) {