@http-forge/core 0.2.3 → 0.2.5
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/README.md +33 -0
- package/dist/index.js +99 -97
- package/dist/index.mjs +98 -96
- package/dist/infrastructure/collection/collection-service.d.ts +7 -2
- package/dist/infrastructure/collection/folder-collection-loader.d.ts +1 -1
- package/dist/infrastructure/environment/environment-config-service.d.ts +12 -3
- package/dist/infrastructure/openapi/openapi-exporter.d.ts +31 -0
- package/dist/infrastructure/openapi/openapi-importer.d.ts +10 -0
- package/dist/types/types.d.ts +20 -0
- package/package.json +1 -1
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
* - ConfigService for configuration
|
|
9
9
|
* - CollectionLoader for storage abstraction (supports folder and json formats)
|
|
10
10
|
*/
|
|
11
|
-
import { IConfigService } from '../config';
|
|
12
|
-
import { IFileWatcherFactory } from '../../types/platform';
|
|
13
11
|
import type { Collection, CollectionItem, CollectionRequestItem, CreateRequestOptions, ICollectionService } from '../../types/collection';
|
|
12
|
+
import { IFileWatcherFactory } from '../../types/platform';
|
|
13
|
+
import { IConfigService } from '../config';
|
|
14
14
|
/**
|
|
15
15
|
* Service for managing HTTP Forge collections
|
|
16
16
|
*/
|
|
@@ -26,6 +26,11 @@ export declare class CollectionService implements ICollectionService {
|
|
|
26
26
|
* In-memory Local Values for collection variables (not persisted)
|
|
27
27
|
*/
|
|
28
28
|
private localCollectionValues;
|
|
29
|
+
/**
|
|
30
|
+
* Callback invoked when collections are reloaded due to file system changes.
|
|
31
|
+
* Set by the extension host to refresh tree views and panels.
|
|
32
|
+
*/
|
|
33
|
+
onCollectionsChanged?: () => void;
|
|
29
34
|
constructor(workspaceRoot: string, configService: IConfigService, fileWatcherFactory?: IFileWatcherFactory | undefined);
|
|
30
35
|
private ensureCollectionsDir;
|
|
31
36
|
private loadCollections;
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
* All disk I/O is delegated to FolderCollectionStore — this class only
|
|
10
10
|
* performs type conversion on the way in and out.
|
|
11
11
|
*/
|
|
12
|
+
import type { ICollectionLoader } from '../../types/collection';
|
|
12
13
|
import type { CollectionScripts, UnifiedCollection, UnifiedFolder, UnifiedRequest } from '../../types/types';
|
|
13
14
|
import type { CollectionMetadata } from './collection-store';
|
|
14
|
-
import type { ICollectionLoader } from '../../types/collection';
|
|
15
15
|
export { generateSlug } from './folder-io';
|
|
16
16
|
type UnifiedItem = UnifiedFolder | UnifiedRequest;
|
|
17
17
|
/**
|
|
@@ -4,13 +4,14 @@
|
|
|
4
4
|
* Platform-agnostic — uses IKeyValueStore for persistence instead of
|
|
5
5
|
* VS Code's workspaceState/globalState.
|
|
6
6
|
*/
|
|
7
|
-
import { IConfigService } from '../config';
|
|
8
|
-
import { IKeyValueStore } from '../../types/platform';
|
|
9
7
|
import type { IEnvironmentConfigService, ImportedEnvironment, LocalConfig, ResolvedEnvironment, SharedConfig } from '../../types/environment-config';
|
|
8
|
+
import { IFileWatcherFactory, IKeyValueStore } from '../../types/platform';
|
|
9
|
+
import { IConfigService } from '../config';
|
|
10
10
|
export declare class EnvironmentConfigService implements IEnvironmentConfigService {
|
|
11
11
|
private workspaceFolder;
|
|
12
12
|
private workspaceStore;
|
|
13
13
|
private configService;
|
|
14
|
+
private fileWatcherFactory?;
|
|
14
15
|
private environmentsPath;
|
|
15
16
|
private sharedConfigPath;
|
|
16
17
|
private localConfigPath;
|
|
@@ -18,6 +19,7 @@ export declare class EnvironmentConfigService implements IEnvironmentConfigServi
|
|
|
18
19
|
private sharedConfig;
|
|
19
20
|
private localConfig;
|
|
20
21
|
private selectedEnvironment;
|
|
22
|
+
private fileWatcher?;
|
|
21
23
|
/**
|
|
22
24
|
* In-memory Local Values for variables (not persisted)
|
|
23
25
|
* These are set via forge.*.set() in scripts and override file values
|
|
@@ -25,7 +27,14 @@ export declare class EnvironmentConfigService implements IEnvironmentConfigServi
|
|
|
25
27
|
*/
|
|
26
28
|
private localGlobalValues;
|
|
27
29
|
private localEnvironmentValues;
|
|
28
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Callback invoked when environment files change on disk.
|
|
32
|
+
* Set by the extension host to refresh tree views and panels.
|
|
33
|
+
*/
|
|
34
|
+
onEnvironmentsChanged?: () => void;
|
|
35
|
+
constructor(workspaceFolder: string, workspaceStore: IKeyValueStore, configService: IConfigService, fileWatcherFactory?: IFileWatcherFactory | undefined);
|
|
36
|
+
private setupFileWatcher;
|
|
37
|
+
dispose(): void;
|
|
29
38
|
getWorkspaceFolder(): string;
|
|
30
39
|
getRootPath(): string;
|
|
31
40
|
loadConfigs(): void;
|
|
@@ -34,6 +34,37 @@ export declare class OpenApiExporter {
|
|
|
34
34
|
private buildServers;
|
|
35
35
|
private processItems;
|
|
36
36
|
private processRequest;
|
|
37
|
+
/**
|
|
38
|
+
* Merge a new operation into an existing one at the same path+method.
|
|
39
|
+
* - Parameters: union enum values for same-name params; append new params
|
|
40
|
+
* - Description: append the variant name
|
|
41
|
+
* - Tags: union
|
|
42
|
+
* - Responses: merge (new status codes added, existing kept)
|
|
43
|
+
*/
|
|
44
|
+
private mergeOperation;
|
|
45
|
+
/**
|
|
46
|
+
* Merge parameter schemas when the same parameter appears in colliding operations.
|
|
47
|
+
*
|
|
48
|
+
* Strategy: if both variants use the SAME constraint kind (both enum, both pattern,
|
|
49
|
+
* both numeric range, etc.) they are merged in-place (union enum, widen range, etc.).
|
|
50
|
+
* If they use DIFFERENT constraint kinds the schemas are incompatible,
|
|
51
|
+
* so we wrap them in `oneOf` — each variant keeps its own self-consistent schema.
|
|
52
|
+
*
|
|
53
|
+
* Description and examples are always accumulated.
|
|
54
|
+
*/
|
|
55
|
+
private mergeParameterSchema;
|
|
56
|
+
/** Identify the primary constraint kind of a schema. */
|
|
57
|
+
private getConstraintKind;
|
|
58
|
+
/** Merge constraints when both schemas use the same kind. */
|
|
59
|
+
private mergeSameKindConstraints;
|
|
60
|
+
/** Build a self-contained variant schema from constraint properties. */
|
|
61
|
+
private buildVariantSchema;
|
|
62
|
+
/** Remove constraint properties from a schema (keeps type, oneOf, etc.). */
|
|
63
|
+
private stripConstraints;
|
|
64
|
+
/** Extract constraint properties from a schema into a new object. */
|
|
65
|
+
private extractConstraints;
|
|
66
|
+
/** Widen the type field if the incoming type differs. */
|
|
67
|
+
private widenType;
|
|
37
68
|
private normalizeUrl;
|
|
38
69
|
private generateOperationId;
|
|
39
70
|
private collectOperationIds;
|
|
@@ -31,6 +31,16 @@ export declare class OpenApiImporter {
|
|
|
31
31
|
*/
|
|
32
32
|
private convertPathParams;
|
|
33
33
|
private processParameters;
|
|
34
|
+
/**
|
|
35
|
+
* Apply all schema constraints to a KeyValueEntry (query/header params).
|
|
36
|
+
*/
|
|
37
|
+
private applySchemaConstraints;
|
|
38
|
+
/**
|
|
39
|
+
* When a parameter schema uses oneOf (from merged exports), derive
|
|
40
|
+
* combined enum and type hints for UI display.
|
|
41
|
+
* e.g. oneOf: [{enum: ["1.5"]}, {pattern: "^T\\d+"}] → enum: ["1.5"] as a hint
|
|
42
|
+
*/
|
|
43
|
+
private applyOneOfHints;
|
|
34
44
|
/**
|
|
35
45
|
* Generate an example value string for a parameter from its schema.
|
|
36
46
|
*/
|
package/dist/types/types.d.ts
CHANGED
|
@@ -48,6 +48,7 @@ export interface UnifiedRequest {
|
|
|
48
48
|
id: string;
|
|
49
49
|
name: string;
|
|
50
50
|
description?: string;
|
|
51
|
+
doc?: string;
|
|
51
52
|
method: string;
|
|
52
53
|
url: string;
|
|
53
54
|
/** Headers with per-header enabled/disabled flag and OpenAPI metadata */
|
|
@@ -397,6 +398,15 @@ export interface KeyValueEntry {
|
|
|
397
398
|
format?: string;
|
|
398
399
|
enum?: string[];
|
|
399
400
|
deprecated?: boolean;
|
|
401
|
+
pattern?: string;
|
|
402
|
+
minimum?: number;
|
|
403
|
+
maximum?: number;
|
|
404
|
+
exclusiveMinimum?: number;
|
|
405
|
+
exclusiveMaximum?: number;
|
|
406
|
+
minLength?: number;
|
|
407
|
+
maxLength?: number;
|
|
408
|
+
/** When multiple incompatible constraint sets exist (e.g. from merged endpoints) */
|
|
409
|
+
oneOf?: Array<Record<string, any>>;
|
|
400
410
|
}
|
|
401
411
|
/**
|
|
402
412
|
* Path parameter entry with OpenAPI metadata
|
|
@@ -408,6 +418,15 @@ export interface PathParamEntry {
|
|
|
408
418
|
format?: string;
|
|
409
419
|
enum?: string[];
|
|
410
420
|
deprecated?: boolean;
|
|
421
|
+
pattern?: string;
|
|
422
|
+
minimum?: number;
|
|
423
|
+
maximum?: number;
|
|
424
|
+
exclusiveMinimum?: number;
|
|
425
|
+
exclusiveMaximum?: number;
|
|
426
|
+
minLength?: number;
|
|
427
|
+
maxLength?: number;
|
|
428
|
+
/** When multiple incompatible constraint sets exist (e.g. from merged endpoints) */
|
|
429
|
+
oneOf?: Array<Record<string, any>>;
|
|
411
430
|
}
|
|
412
431
|
/**
|
|
413
432
|
* Per-property encoding metadata for multipart/form-data request bodies.
|
|
@@ -542,6 +561,7 @@ export interface CollectionRequest {
|
|
|
542
561
|
scripts?: RequestScripts;
|
|
543
562
|
auth?: RequestAuth;
|
|
544
563
|
description?: string;
|
|
564
|
+
doc?: string;
|
|
545
565
|
disabled?: boolean;
|
|
546
566
|
deprecated?: boolean;
|
|
547
567
|
responseSchema?: ResponseSchemaDefinition;
|
package/package.json
CHANGED