@caplets/core 0.18.2 → 0.18.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.
@@ -257,8 +257,16 @@ export type CapletFileLoadResult = {
257
257
  config: CapletFileConfig;
258
258
  paths: Record<string, string>;
259
259
  };
260
+ export type CapletFileWarning = {
261
+ path?: string | undefined;
262
+ message: string;
263
+ };
264
+ export type BestEffortCapletFileLoadResult = CapletFileLoadResult & {
265
+ warnings: CapletFileWarning[];
266
+ };
260
267
  export declare function loadCapletFiles(root: string): CapletFileConfig | undefined;
261
268
  export declare function loadCapletFilesWithPaths(root: string): CapletFileLoadResult | undefined;
269
+ export declare function loadCapletFilesWithPathsBestEffort(root: string): BestEffortCapletFileLoadResult | undefined;
262
270
  export declare function discoverCapletFiles(root: string): Array<{
263
271
  id: string;
264
272
  path: string;
@@ -1,12 +1,14 @@
1
1
  import { type GenericAuthTarget } from "../auth";
2
- import { loadConfig, type GraphQlEndpointConfig, type HttpApiConfig } from "../config";
2
+ import { loadConfig, type CapletsConfig, type GraphQlEndpointConfig, type HttpApiConfig } from "../config";
3
3
  type AuthTarget = ReturnType<typeof authTargets>[number];
4
4
  type AuthListFormat = "plain" | "markdown" | "json";
5
+ export type AuthSource = "project" | "global" | "remote";
5
6
  export type AuthStatusRow = {
6
7
  server: string;
7
8
  status: "missing" | "expired" | "authenticated";
8
9
  expiresAt?: string;
9
10
  scope?: string;
11
+ source?: AuthSource;
10
12
  };
11
13
  export declare function loginAuth(serverId: string, options: {
12
14
  configPath?: string;
@@ -14,15 +16,18 @@ export declare function loginAuth(serverId: string, options: {
14
16
  writeOut: (value: string) => void;
15
17
  writeErr: (value: string) => void;
16
18
  authDir?: string;
19
+ config?: CapletsConfig;
17
20
  }): Promise<void>;
18
21
  export declare function logoutAuth(serverId: string, options: {
19
22
  authDir?: string;
20
23
  configPath?: string;
24
+ config?: CapletsConfig;
21
25
  writeOut: (value: string) => void;
22
26
  }): void;
23
27
  export declare function logoutAuthResult(serverId: string, options: {
24
28
  authDir?: string;
25
29
  configPath?: string;
30
+ config?: CapletsConfig;
26
31
  }): {
27
32
  server: string;
28
33
  deleted: boolean;
@@ -37,8 +42,27 @@ export declare function listAuthRows(options: {
37
42
  authDir?: string;
38
43
  configPath?: string;
39
44
  }): AuthStatusRow[];
45
+ export declare function listLocalAuthRows(options: {
46
+ authDir?: string;
47
+ configPath?: string;
48
+ projectConfigPath?: string;
49
+ source?: Exclude<AuthSource, "remote">;
50
+ }): AuthStatusRow[];
51
+ export declare function localAuthTargets(options: {
52
+ configPath?: string;
53
+ projectConfigPath?: string;
54
+ source?: Exclude<AuthSource, "remote">;
55
+ }): (AuthTarget & {
56
+ source: Exclude<AuthSource, "remote">;
57
+ })[];
58
+ export declare function localAuthConfigForTarget(options: {
59
+ serverId: string;
60
+ configPath?: string;
61
+ projectConfigPath?: string;
62
+ source: Exclude<AuthSource, "remote">;
63
+ }): CapletsConfig;
40
64
  export declare function formatAuthRows(rows: AuthStatusRow[], format: Exclude<AuthListFormat, "json">): string;
41
- export declare function findAuthTarget(serverId: string, config?: import("../config").CapletsConfig): AuthTarget | undefined;
65
+ export declare function findAuthTarget(serverId: string, config?: CapletsConfig): AuthTarget | undefined;
42
66
  declare function authTargets(config: ReturnType<typeof loadConfig>): (import("../config").CapletServerConfig | import("../config").OpenApiEndpointConfig | (GraphQlEndpointConfig & GenericAuthTarget) | (HttpApiConfig & GenericAuthTarget))[];
43
67
  export declare function assertLoginTarget(target: AuthTarget | undefined, serverId: string): asserts target is AuthTarget;
44
68
  export {};
@@ -7,7 +7,7 @@ type CapletListRow = {
7
7
  description: string;
8
8
  disabled: boolean;
9
9
  status: ServerStatus;
10
- source: ConfigSource["kind"] | "unknown";
10
+ source: ConfigSource["kind"] | "remote" | "unknown";
11
11
  path: string | null;
12
12
  shadows: ConfigSource[];
13
13
  };
@@ -25,6 +25,6 @@ export declare function listCaplets(configWithSources: ConfigWithSources, option
25
25
  }): CapletListRow[];
26
26
  type CliOutputFormat = "markdown" | "plain" | "json";
27
27
  export declare function formatCapletList(rows: CapletListRow[], format?: Exclude<CliOutputFormat, "json">): string;
28
- export declare function resolveCliConfigPaths(envConfigPath: string | undefined, authDir?: string): ConfigPaths;
28
+ export declare function resolveCliConfigPaths(envConfigPath: string | undefined, projectConfigPath?: string, authDir?: string): ConfigPaths;
29
29
  export declare function formatConfigPaths(paths: ConfigPaths, format?: Exclude<CliOutputFormat, "json">): string;
30
30
  export {};
@@ -1,4 +1,4 @@
1
- import { Ct as resolveProjectConfigPath, Mt as __exportAll, Ot as CapletsError, St as resolveProjectCapletsRoot, bt as resolveCapletsRoot, gt as loadConfigWithSources, vt as DEFAULT_AUTH_DIR, xt as resolveConfigPath, yt as DEFAULT_COMPLETION_CACHE_DIR } from "./options-bnsSREid.js";
1
+ import { Ct as resolveCapletsRoot, Et as resolveProjectConfigPath, Ft as __exportAll, St as DEFAULT_COMPLETION_CACHE_DIR, gt as loadConfigWithSources, jt as CapletsError, wt as resolveConfigPath, xt as DEFAULT_AUTH_DIR } from "./options-BlNyqF_E.js";
2
2
  import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
3
3
  import { dirname, join } from "node:path";
4
4
  import { createHash } from "node:crypto";
@@ -115,7 +115,8 @@ function allCaplets(config) {
115
115
  ...Object.values(config.openapiEndpoints),
116
116
  ...Object.values(config.graphqlEndpoints),
117
117
  ...Object.values(config.httpApis),
118
- ...Object.values(config.cliTools)
118
+ ...Object.values(config.cliTools),
119
+ ...Object.values(config.capletSets)
119
120
  ];
120
121
  }
121
122
  function formatCapletList(rows, format = "plain") {
@@ -167,15 +168,15 @@ function formatSourceKind(kind) {
167
168
  if (kind.startsWith("global")) return "global";
168
169
  return kind;
169
170
  }
170
- function resolveCliConfigPaths(envConfigPath, authDir) {
171
+ function resolveCliConfigPaths(envConfigPath, projectConfigPath = resolveProjectConfigPath(), authDir) {
171
172
  const configPath = resolveConfigPath(envConfigPath);
172
173
  const effectiveAuthDir = authDir ?? DEFAULT_AUTH_DIR;
173
174
  return {
174
175
  userConfig: configPath,
175
- projectConfig: resolveProjectConfigPath(),
176
+ projectConfig: projectConfigPath,
176
177
  userRoot: resolveCapletsRoot(configPath),
177
178
  stateRoot: dirname(effectiveAuthDir),
178
- projectRoot: resolveProjectCapletsRoot(),
179
+ projectRoot: dirname(projectConfigPath),
179
180
  authDir: effectiveAuthDir,
180
181
  envConfig: envConfigPath ?? null
181
182
  };
package/dist/config.d.ts CHANGED
@@ -209,6 +209,14 @@ export type ConfigWithSources = {
209
209
  sources: Record<string, ConfigSource>;
210
210
  shadows: Record<string, ConfigSource[]>;
211
211
  };
212
+ export type LocalOverlayConfigWarning = {
213
+ kind: ConfigSourceKind;
214
+ path: string;
215
+ message: string;
216
+ };
217
+ export type LocalOverlayConfigWithSources = ConfigWithSources & {
218
+ warnings: LocalOverlayConfigWarning[];
219
+ };
212
220
  export declare const configFileSchema: z.ZodObject<{
213
221
  $schema: z.ZodOptional<z.ZodString>;
214
222
  version: z.ZodDefault<z.ZodLiteral<1>>;
@@ -230,6 +238,9 @@ export declare const configFileSchema: z.ZodObject<{
230
238
  export declare function configJsonSchema(): unknown;
231
239
  export declare function loadConfig(path?: string, projectPath?: string): CapletsConfig;
232
240
  export declare function loadConfigWithSources(path?: string, projectPath?: string): ConfigWithSources;
241
+ export declare function loadGlobalConfig(path?: string): CapletsConfig;
242
+ export declare function loadProjectConfig(projectPath?: string): CapletsConfig;
243
+ export declare function loadLocalOverlayConfigWithSources(path?: string, projectPath?: string): LocalOverlayConfigWithSources;
233
244
  export declare function loadIsolatedConfig(options: {
234
245
  configPath?: string;
235
246
  capletsRoot?: string;
package/dist/engine.d.ts CHANGED
@@ -6,6 +6,7 @@ export type CapletsEngineOptions = {
6
6
  watchDebounceMs?: number;
7
7
  watch?: boolean;
8
8
  writeErr?: (value: string) => void;
9
+ configLoader?: (configPath: string, projectConfigPath: string) => CapletsConfig;
9
10
  };
10
11
  export type CapletsEngineReloadEvent = {
11
12
  previous: CapletsConfig;
@@ -24,6 +25,7 @@ export declare class CapletsEngine {
24
25
  private readonly watchDebounceMs;
25
26
  private readonly watchEnabled;
26
27
  private readonly writeErr;
28
+ private readonly configLoader;
27
29
  private readonly reloadListeners;
28
30
  private watchers;
29
31
  private reloadTimer;