@http-forge/core 0.1.0 → 0.2.1

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 (135) hide show
  1. package/README.md +217 -43
  2. package/dist/auth/interfaces.d.ts +63 -0
  3. package/dist/auth/oauth2-token-manager.d.ts +103 -0
  4. package/dist/collection/collection-loader-factory.d.ts +20 -0
  5. package/dist/{services → collection}/collection-loader.d.ts +3 -3
  6. package/dist/collection/collection-service-interfaces.d.ts +119 -0
  7. package/dist/collection/collection-service.d.ts +75 -0
  8. package/dist/collection/collection-store.d.ts +109 -0
  9. package/dist/collection/folder-collection-loader.d.ts +45 -0
  10. package/dist/collection/folder-collection-store.d.ts +175 -0
  11. package/dist/collection/folder-io.d.ts +113 -0
  12. package/dist/collection/interfaces.d.ts +32 -0
  13. package/dist/collection/json-collection-loader.d.ts +95 -0
  14. package/dist/{services → collection}/parser-registry.d.ts +1 -2
  15. package/dist/config/config-service.d.ts +79 -0
  16. package/dist/config/config.interface.d.ts +140 -0
  17. package/dist/config/default-config.d.ts +29 -0
  18. package/dist/config/index.d.ts +6 -0
  19. package/dist/container.d.ts +26 -19
  20. package/dist/{implementations → cookie}/cookie-jar.d.ts +2 -3
  21. package/dist/cookie/cookie-service.d.ts +98 -0
  22. package/dist/{implementations → cookie}/cookie-utils.d.ts +1 -2
  23. package/dist/cookie/in-memory-cookie-jar.d.ts +44 -0
  24. package/dist/{interfaces/cookie.d.ts → cookie/interfaces.d.ts} +22 -3
  25. package/dist/cookie/persistent-cookie-jar.d.ts +35 -0
  26. package/dist/di/core-bootstrap.d.ts +25 -0
  27. package/dist/di/index.d.ts +11 -0
  28. package/dist/di/platform-adapters.d.ts +53 -0
  29. package/dist/di/service-container.d.ts +97 -0
  30. package/dist/di/service-identifiers.d.ts +34 -0
  31. package/dist/environment/environment-config-service.d.ts +98 -0
  32. package/dist/environment/environment-file-loader.d.ts +42 -0
  33. package/dist/{services → environment}/environment-resolver.d.ts +6 -5
  34. package/dist/{services → environment}/forge-env.d.ts +1 -2
  35. package/dist/environment/interfaces.d.ts +139 -0
  36. package/dist/environment/variable-interpolator.d.ts +100 -0
  37. package/dist/execution/collection-request-executor-interfaces.d.ts +36 -0
  38. package/dist/execution/collection-request-executor.d.ts +78 -0
  39. package/dist/{services → execution}/request-executor.d.ts +23 -11
  40. package/dist/execution/request-preparer-interfaces.d.ts +36 -0
  41. package/dist/execution/request-preparer.d.ts +35 -0
  42. package/dist/graphql/graphql-completion-provider.d.ts +39 -0
  43. package/dist/graphql/graphql-schema-service.d.ts +89 -0
  44. package/dist/{interfaces/history.d.ts → history/history-interfaces.d.ts} +29 -6
  45. package/dist/history/request-history-service-interfaces.d.ts +43 -0
  46. package/dist/history/request-history-service.d.ts +133 -0
  47. package/dist/{implementations → history}/request-history.d.ts +2 -3
  48. package/dist/{implementations → http}/fetch-http-client.d.ts +4 -5
  49. package/dist/http/http-request-service.d.ts +36 -0
  50. package/dist/{implementations → http}/interceptor-chain.d.ts +1 -2
  51. package/dist/http/interfaces.d.ts +25 -0
  52. package/dist/http/merge-request-settings.d.ts +12 -0
  53. package/dist/{implementations → http}/native-http-client.d.ts +6 -15
  54. package/dist/{implementations → http}/request-preprocessor.d.ts +1 -2
  55. package/dist/{services → http}/url-builder.d.ts +7 -10
  56. package/dist/import-export/import-postman-environment.d.ts +21 -0
  57. package/dist/import-export/rest-client-export.d.ts +35 -0
  58. package/dist/index.d.ts +94 -6
  59. package/dist/index.js +262 -35
  60. package/dist/index.mjs +262 -35
  61. package/dist/openapi/example-generator.d.ts +26 -0
  62. package/dist/openapi/history-analyzer.d.ts +29 -0
  63. package/dist/openapi/index.d.ts +16 -0
  64. package/dist/openapi/interfaces.d.ts +42 -0
  65. package/dist/openapi/openapi-exporter.d.ts +73 -0
  66. package/dist/openapi/openapi-importer.d.ts +72 -0
  67. package/dist/openapi/ref-resolver.d.ts +28 -0
  68. package/dist/openapi/schema-inference-service.d.ts +40 -0
  69. package/dist/openapi/schema-inferrer.d.ts +26 -0
  70. package/dist/openapi/script-analyzer.d.ts +41 -0
  71. package/dist/parsers/http-forge-parser.d.ts +2 -3
  72. package/dist/parsers/index.d.ts +0 -1
  73. package/dist/{implementations → platform}/data-file-parser.d.ts +0 -1
  74. package/dist/{implementations → platform}/node-file-system.d.ts +1 -2
  75. package/dist/script/interfaces.d.ts +161 -0
  76. package/dist/script/module-loader.d.ts +115 -0
  77. package/dist/script/request-script-session.d.ts +73 -0
  78. package/dist/script/script-executor.d.ts +60 -0
  79. package/dist/script/script-factories.d.ts +94 -0
  80. package/dist/script/script-utils.d.ts +42 -0
  81. package/dist/test-suite/index.d.ts +10 -0
  82. package/dist/test-suite/interfaces.d.ts +164 -0
  83. package/dist/test-suite/result-storage-service.d.ts +70 -0
  84. package/dist/test-suite/result-storage.d.ts +296 -0
  85. package/dist/test-suite/statistics-service.d.ts +51 -0
  86. package/dist/test-suite/test-suite-service.d.ts +97 -0
  87. package/dist/test-suite/test-suite-store.d.ts +155 -0
  88. package/dist/types/console-service.d.ts +40 -0
  89. package/dist/types/platform.d.ts +206 -0
  90. package/dist/{interfaces → types}/types.d.ts +289 -12
  91. package/dist/utils/dynamic-variables.d.ts +38 -0
  92. package/dist/utils/expression-evaluator.d.ts +34 -0
  93. package/dist/utils/filter-engine.d.ts +47 -0
  94. package/dist/utils/helpers.d.ts +47 -0
  95. package/package.json +12 -4
  96. package/dist/container.d.ts.map +0 -1
  97. package/dist/implementations/cookie-jar.d.ts.map +0 -1
  98. package/dist/implementations/cookie-utils.d.ts.map +0 -1
  99. package/dist/implementations/data-file-parser.d.ts.map +0 -1
  100. package/dist/implementations/fetch-http-client.d.ts.map +0 -1
  101. package/dist/implementations/index.d.ts +0 -22
  102. package/dist/implementations/index.d.ts.map +0 -1
  103. package/dist/implementations/interceptor-chain.d.ts.map +0 -1
  104. package/dist/implementations/module-loader.d.ts +0 -74
  105. package/dist/implementations/module-loader.d.ts.map +0 -1
  106. package/dist/implementations/native-http-client.d.ts.map +0 -1
  107. package/dist/implementations/node-file-system.d.ts.map +0 -1
  108. package/dist/implementations/request-history.d.ts.map +0 -1
  109. package/dist/implementations/request-preprocessor.d.ts.map +0 -1
  110. package/dist/implementations/variable-interpolator.d.ts +0 -55
  111. package/dist/implementations/variable-interpolator.d.ts.map +0 -1
  112. package/dist/implementations/vm2-script-runner.d.ts +0 -76
  113. package/dist/implementations/vm2-script-runner.d.ts.map +0 -1
  114. package/dist/index.d.ts.map +0 -1
  115. package/dist/interfaces/cookie.d.ts.map +0 -1
  116. package/dist/interfaces/history.d.ts.map +0 -1
  117. package/dist/interfaces/index.d.ts +0 -170
  118. package/dist/interfaces/index.d.ts.map +0 -1
  119. package/dist/interfaces/types.d.ts.map +0 -1
  120. package/dist/parsers/http-forge-parser.d.ts.map +0 -1
  121. package/dist/parsers/index.d.ts.map +0 -1
  122. package/dist/services/collection-loader.d.ts.map +0 -1
  123. package/dist/services/environment-resolver.d.ts.map +0 -1
  124. package/dist/services/folder-collection-loader.d.ts +0 -91
  125. package/dist/services/folder-collection-loader.d.ts.map +0 -1
  126. package/dist/services/forge-env.d.ts.map +0 -1
  127. package/dist/services/index.d.ts +0 -20
  128. package/dist/services/index.d.ts.map +0 -1
  129. package/dist/services/parser-registry.d.ts.map +0 -1
  130. package/dist/services/request-executor.d.ts.map +0 -1
  131. package/dist/services/script-pipeline.d.ts +0 -43
  132. package/dist/services/script-pipeline.d.ts.map +0 -1
  133. package/dist/services/script-session.d.ts +0 -66
  134. package/dist/services/script-session.d.ts.map +0 -1
  135. package/dist/services/url-builder.d.ts.map +0 -1
@@ -0,0 +1,75 @@
1
+ /**
2
+ * Collection Service
3
+ *
4
+ * Service for managing HTTP Forge collections.
5
+ * Platform-agnostic — uses IFileWatcherFactory instead of VS Code APIs.
6
+ *
7
+ * Refactored to use:
8
+ * - ConfigService for configuration
9
+ * - CollectionLoader for storage abstraction (supports folder and json formats)
10
+ */
11
+ import { IConfigService } from '../config';
12
+ import { IFileWatcherFactory } from '../types/platform';
13
+ import { Collection, CollectionItem, CollectionRequestItem, CreateRequestOptions, ICollectionService } from './collection-service-interfaces';
14
+ /**
15
+ * Service for managing HTTP Forge collections
16
+ */
17
+ export declare class CollectionService implements ICollectionService {
18
+ private workspaceRoot;
19
+ private configService;
20
+ private fileWatcherFactory?;
21
+ private collectionsDir;
22
+ private collections;
23
+ private fileWatcher?;
24
+ private loader;
25
+ /**
26
+ * In-memory Local Values for collection variables (not persisted)
27
+ */
28
+ private localCollectionValues;
29
+ constructor(workspaceRoot: string, configService: IConfigService, fileWatcherFactory?: IFileWatcherFactory | undefined);
30
+ private ensureCollectionsDir;
31
+ private loadCollections;
32
+ private setupFileWatcher;
33
+ getAllCollections(): Collection[];
34
+ getCollection(id: string): Collection | undefined;
35
+ getCollectionById(id: string): Collection | undefined;
36
+ getCollectionByName(name: string): Collection | undefined;
37
+ saveCollection(collection: Collection): Promise<void>;
38
+ getCollectionVariables(collectionId: string): Record<string, string>;
39
+ getCollectionVariableLocals(collectionId: string): Record<string, string>;
40
+ setCollectionVariable(collectionId: string, key: string, value: unknown): void;
41
+ deleteCollectionVariable(collectionId: string, key: string): void;
42
+ clearCollectionVariables(collectionId: string): void;
43
+ deleteCollection(id: string): Promise<boolean>;
44
+ findRequest(collectionId: string, requestId: string): CollectionRequestItem | undefined;
45
+ findRequestByPath(collectionId: string, requestPath: string): CollectionItem | undefined;
46
+ updateRequest(collectionId: string, requestId: string, updates: Partial<CollectionRequestItem>): Promise<boolean>;
47
+ addRequest(collectionId: string, request: CollectionRequestItem, parentFolderId?: string): Promise<boolean>;
48
+ deleteRequest(collectionId: string, requestId: string): Promise<boolean>;
49
+ getAllRequests(collectionId: string): CollectionItem[];
50
+ private findItemRecursive;
51
+ private findItemByPath;
52
+ private updateItemRecursive;
53
+ private deleteItemRecursive;
54
+ private collectRequestsRecursive;
55
+ createCollection(name: string): Promise<Collection>;
56
+ renameCollection(id: string, newName: string): Promise<boolean>;
57
+ createFolder(options: {
58
+ name: string;
59
+ collectionId: string;
60
+ parentId?: string;
61
+ }): Promise<CollectionItem>;
62
+ deleteFolder(collectionId: string, folderId: string): Promise<boolean>;
63
+ renameFolder(collectionId: string, folderId: string, newName: string): Promise<boolean>;
64
+ createRequest(options: CreateRequestOptions): Promise<CollectionRequestItem>;
65
+ renameRequest(collectionId: string, requestId: string, newName: string): Promise<boolean>;
66
+ moveItem(collectionId: string, itemId: string, newParentId?: string): Promise<boolean>;
67
+ reorderItems(collectionId: string, parentId: string | undefined, orderedItemIds: string[]): Promise<boolean>;
68
+ private findItemById;
69
+ private deleteItemById;
70
+ importCollection(filePath: string): Promise<Collection>;
71
+ private importPostmanCollection;
72
+ exportCollection(collectionId: string, filePath: string): Promise<void>;
73
+ exportCollectionAsRestClientFolder(collectionId: string, outDir: string): Promise<void>;
74
+ dispose(): void;
75
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Collection Store Interface
3
+ *
4
+ * Rich CRUD interface for collection storage operations.
5
+ * Strategy Pattern: Different stores for different storage formats
6
+ * - JsonCollectionLoader: Loads from single JSON files
7
+ * - FolderCollectionStore: Loads from directory structure
8
+ */
9
+ import type { CollectionRequest } from '../types/types';
10
+ import type { Collection, CollectionItem, RequestScripts } from './collection-service-interfaces';
11
+ /**
12
+ * Rich interface for loading, saving, and managing collections
13
+ */
14
+ export interface ICollectionStore {
15
+ /**
16
+ * Load all collections from storage
17
+ */
18
+ loadAll(): Collection[];
19
+ /**
20
+ * Load a single collection by ID
21
+ */
22
+ load(id: string): Collection | undefined;
23
+ /**
24
+ * Save an entire collection (use for bulk operations or JSON format)
25
+ */
26
+ save(collection: Collection): Promise<void>;
27
+ /**
28
+ * Delete a collection
29
+ */
30
+ delete(id: string): Promise<boolean>;
31
+ /**
32
+ * Check if a collection exists
33
+ */
34
+ exists(id: string): boolean;
35
+ /**
36
+ * Get the path for a collection
37
+ */
38
+ getCollectionPath(id: string): string;
39
+ /**
40
+ * Create a new collection with default structure
41
+ */
42
+ create(name: string, id?: string): Promise<Collection>;
43
+ /**
44
+ * Update collection metadata only (name, description, variables, auth)
45
+ */
46
+ updateCollectionMetadata(collectionId: string, updates: Partial<CollectionMetadata>): Promise<void>;
47
+ /**
48
+ * Save/update a single item (request or folder)
49
+ * For folder format: only writes the specific item's files
50
+ * For JSON format: falls back to save()
51
+ */
52
+ saveItem(collectionId: string, item: CollectionItem, parentId?: string): Promise<void>;
53
+ /**
54
+ * Delete a single item by ID
55
+ */
56
+ deleteItem(collectionId: string, itemId: string): Promise<boolean>;
57
+ /**
58
+ * Update a single item's metadata (not scripts)
59
+ * For folder format: only updates request.json or folder.json
60
+ */
61
+ updateItem(collectionId: string, itemId: string, updates: Partial<CollectionItem>): Promise<boolean>;
62
+ /**
63
+ * Move an item to a new parent
64
+ */
65
+ moveItem(collectionId: string, itemId: string, newParentId?: string): Promise<boolean>;
66
+ /**
67
+ * Reorder items within a parent (collection or folder)
68
+ * @param collectionId - The collection ID
69
+ * @param parentId - The parent folder ID (undefined for collection root)
70
+ * @param orderedItemIds - Array of item IDs in the desired order
71
+ */
72
+ reorderItems(collectionId: string, parentId: string | undefined, orderedItemIds: string[]): Promise<boolean>;
73
+ /**
74
+ * Save scripts for a specific item
75
+ */
76
+ saveScripts(collectionId: string, itemId: string, scripts: RequestScripts): Promise<void>;
77
+ /**
78
+ * Load scripts for a specific item
79
+ */
80
+ loadScripts(collectionId: string, itemId: string): RequestScripts | undefined;
81
+ }
82
+ /**
83
+ * Metadata stored in collection.json for folder format
84
+ */
85
+ export interface CollectionMetadata {
86
+ id: string;
87
+ name: string;
88
+ description?: string;
89
+ version?: string;
90
+ variables?: Record<string, string>;
91
+ auth?: Collection['auth'];
92
+ /** Order of child items (folder slugs). If not specified, filesystem order is used. */
93
+ order?: string[];
94
+ }
95
+ /**
96
+ * Metadata stored in folder.json
97
+ */
98
+ export interface FolderMetadata {
99
+ id: string;
100
+ name: string;
101
+ description?: string;
102
+ auth?: Collection['auth'];
103
+ /** Order of child items (folder slugs). If not specified, filesystem order is used. */
104
+ order?: string[];
105
+ }
106
+ /**
107
+ * Metadata stored in request.json (scripts stored separately in scripts/ directory)
108
+ */
109
+ export type RequestMetadata = Omit<CollectionRequest, 'scripts' | 'disabled' | 'bodyContentType'>;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Folder Collection Loader
3
+ *
4
+ * Thin adapter around FolderCollectionStore that converts between the
5
+ * `Collection` / `CollectionItem` types (array-based headers/query with
6
+ * `enabled` flag) and the simpler `UnifiedCollection` / `UnifiedRequest`
7
+ * types (Record-based headers/query) used by ForgeContainer.
8
+ *
9
+ * All disk I/O is delegated to FolderCollectionStore — this class only
10
+ * performs type conversion on the way in and out.
11
+ */
12
+ import type { CollectionScripts, UnifiedCollection, UnifiedFolder, UnifiedRequest } from '../types/types';
13
+ import type { CollectionMetadata } from './collection-store';
14
+ import type { ICollectionLoader } from './interfaces';
15
+ export { generateSlug } from './folder-io';
16
+ type UnifiedItem = UnifiedFolder | UnifiedRequest;
17
+ /**
18
+ * Folder Collection Loader
19
+ *
20
+ * Implements `ICollectionLoader` and exposes CRUD using `UnifiedCollection` /
21
+ * `UnifiedRequest` types. All disk I/O is handled by the underlying
22
+ * `FolderCollectionStore`; this class converts types on the boundary.
23
+ */
24
+ export declare class FolderCollectionLoader implements ICollectionLoader {
25
+ /** The underlying canonical store that handles all disk I/O */
26
+ private readonly store;
27
+ constructor(collectionsDir: string);
28
+ loadAll(): UnifiedCollection[];
29
+ getSlugById(id: string): string | undefined;
30
+ getIdBySlug(slug: string): string | undefined;
31
+ load(id: string): UnifiedCollection | undefined;
32
+ create(name: string, id?: string): Promise<UnifiedCollection>;
33
+ save(collection: UnifiedCollection): Promise<void>;
34
+ delete(id: string): Promise<boolean>;
35
+ exists(id: string): boolean;
36
+ getCollectionPath(id: string): string;
37
+ updateCollectionMetadata(collectionId: string, updates: Partial<CollectionMetadata>): Promise<void>;
38
+ saveItem(collectionId: string, item: UnifiedItem, parentId?: string): Promise<void>;
39
+ updateItem(collectionId: string, itemId: string, updates: Partial<UnifiedItem>): Promise<boolean>;
40
+ deleteItem(collectionId: string, itemId: string): Promise<boolean>;
41
+ moveItem(collectionId: string, itemId: string, newParentId?: string): Promise<boolean>;
42
+ reorderItems(collectionId: string, parentId: string | undefined, orderedItemIds: string[]): Promise<boolean>;
43
+ saveScripts(collectionId: string, itemId: string, scripts: CollectionScripts): Promise<void>;
44
+ loadScripts(collectionId: string, itemId: string): CollectionScripts | undefined;
45
+ }
@@ -0,0 +1,175 @@
1
+ /**
2
+ * Folder Collection Store
3
+ *
4
+ * Loads and manages collections from directory structure using Collection types.
5
+ * Implements the rich ICollectionStore interface with full CRUD operations.
6
+ *
7
+ * Each collection is a folder containing:
8
+ * - collection.json (metadata)
9
+ * - scripts/ (pre-request.js, post-response.js)
10
+ * - {folder-slug}/ (subfolders)
11
+ * - {request-slug}/ (request folders)
12
+ *
13
+ * Ported from the VS Code extension's FolderCollectionLoader.
14
+ */
15
+ import type { Collection, CollectionItem, RequestScripts } from './collection-service-interfaces';
16
+ import type { CollectionMetadata, ICollectionStore } from './collection-store';
17
+ /**
18
+ * Loads and manages collections from folder structure using Collection types.
19
+ *
20
+ * Structure:
21
+ * collections/
22
+ * {collection-slug}/
23
+ * collection.json
24
+ * scripts/
25
+ * pre-request.js
26
+ * post-response.js
27
+ * {folder-slug}/
28
+ * folder.json
29
+ * scripts/
30
+ * {request-slug}/
31
+ * request.json
32
+ * scripts/
33
+ */
34
+ export declare class FolderCollectionStore implements ICollectionStore {
35
+ private collectionsDir;
36
+ private cache;
37
+ private slugToIdMap;
38
+ private idToSlugMap;
39
+ constructor(collectionsDir: string);
40
+ /**
41
+ * Get collection/item slug from ID
42
+ */
43
+ getSlugById(id: string): string | undefined;
44
+ /**
45
+ * Get collection/item ID from slug
46
+ */
47
+ getIdBySlug(slug: string): string | undefined;
48
+ /**
49
+ * Ensure collections directory exists
50
+ */
51
+ private ensureDirectory;
52
+ /**
53
+ * Load all collections from disk
54
+ */
55
+ loadAll(): Collection[];
56
+ /**
57
+ * Load a collection from a folder
58
+ */
59
+ private loadCollectionFromFolder;
60
+ /**
61
+ * Load items from a directory
62
+ */
63
+ private loadItemsFromDir;
64
+ /**
65
+ * Load a folder from directory
66
+ */
67
+ private loadFolderFromDir;
68
+ /**
69
+ * Load a request from directory
70
+ */
71
+ private loadRequestFromDir;
72
+ /**
73
+ * Load scripts from a scripts directory
74
+ */
75
+ private loadScriptsFromDir;
76
+ /**
77
+ * Load body from external file if present
78
+ */
79
+ private loadBodyFromDir;
80
+ /**
81
+ * Load a JSON schema file if it exists.
82
+ */
83
+ private loadSchemaFile;
84
+ /**
85
+ * Save OpenAPI schema files if present.
86
+ */
87
+ private saveSchemaFiles;
88
+ /**
89
+ * Load a single collection by ID
90
+ */
91
+ load(id: string): Collection | undefined;
92
+ /**
93
+ * Save a collection
94
+ */
95
+ save(collection: Collection): Promise<void>;
96
+ /**
97
+ * Save items to a directory
98
+ */
99
+ private saveItemsToDir;
100
+ /**
101
+ * Save a folder to directory
102
+ */
103
+ private saveFolderToDir;
104
+ /**
105
+ * Save a request to directory
106
+ */
107
+ private saveRequestToDir;
108
+ /**
109
+ * Prepare body for saving - determine what goes in metadata vs external file
110
+ */
111
+ private prepareBodyForSave;
112
+ /**
113
+ * Clean up old body files that don't match current format
114
+ */
115
+ private cleanupOldBodyFiles;
116
+ /**
117
+ * Save scripts to a directory
118
+ */
119
+ private saveScriptsToDir;
120
+ /**
121
+ * Delete a collection
122
+ */
123
+ delete(id: string): Promise<boolean>;
124
+ /**
125
+ * Check if a collection exists
126
+ */
127
+ exists(id: string): boolean;
128
+ /**
129
+ * Get the path for a collection
130
+ */
131
+ getCollectionPath(id: string): string;
132
+ /**
133
+ * Create a new collection
134
+ */
135
+ create(name: string, id?: string): Promise<Collection>;
136
+ /**
137
+ * Save scripts for a specific item
138
+ */
139
+ saveScripts(collectionId: string, itemId: string, scripts: RequestScripts): Promise<void>;
140
+ /**
141
+ * Load scripts for a specific item
142
+ */
143
+ loadScripts(collectionId: string, itemId: string): RequestScripts | undefined;
144
+ /**
145
+ * Update collection metadata only
146
+ */
147
+ updateCollectionMetadata(collectionId: string, updates: Partial<CollectionMetadata>): Promise<void>;
148
+ /**
149
+ * Save/update a single item
150
+ */
151
+ saveItem(collectionId: string, item: CollectionItem, parentId?: string): Promise<void>;
152
+ /**
153
+ * Delete a single item
154
+ */
155
+ deleteItem(collectionId: string, itemId: string): Promise<boolean>;
156
+ /**
157
+ * Update a single item's metadata
158
+ */
159
+ updateItem(collectionId: string, itemId: string, updates: Partial<CollectionItem>): Promise<boolean>;
160
+ /**
161
+ * Move an item to a new parent
162
+ */
163
+ moveItem(collectionId: string, itemId: string, newParentId?: string): Promise<boolean>;
164
+ /**
165
+ * Reorder items within a parent
166
+ */
167
+ reorderItems(collectionId: string, parentId: string | undefined, orderedItemIds: string[]): Promise<boolean>;
168
+ /**
169
+ * Sort items array by ID order
170
+ */
171
+ private sortItemsByOrder;
172
+ private findItemPath;
173
+ private findItemById;
174
+ private deleteItemFromTree;
175
+ }
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Folder Format I/O Primitives
3
+ *
4
+ * Shared file I/O operations for the folder-based collection storage format.
5
+ * Used by both FolderCollectionLoader (read-only, UnifiedCollection types)
6
+ * and FolderCollectionStore (full CRUD, Collection types).
7
+ *
8
+ * Eliminates ~200 lines of duplicated code between the two implementations.
9
+ */
10
+ import type { RequestBody } from '../types/types';
11
+ /** Script file names within a scripts/ directory */
12
+ export declare const SCRIPT_FILES: {
13
+ preRequest: string;
14
+ postResponse: string;
15
+ };
16
+ /** Metadata file names that identify item types */
17
+ export declare const METADATA_FILES: {
18
+ collection: string;
19
+ folder: string;
20
+ request: string;
21
+ };
22
+ /**
23
+ * Body file extensions mapped to body type/format.
24
+ * Files stored externally get syntax highlighting benefits.
25
+ * Other types (form-data, urlencoded, binary, none) stay in request.json.
26
+ */
27
+ export declare const BODY_FILE_MAP: Record<string, {
28
+ type: 'raw' | 'graphql';
29
+ format?: 'json' | 'text' | 'xml' | 'html' | 'javascript';
30
+ }>;
31
+ /** Schema files stored alongside request.json for OpenAPI round-trip support */
32
+ export declare const SCHEMA_FILES: {
33
+ responseSchema: string;
34
+ bodySchema: string;
35
+ };
36
+ /** Scripts directory name */
37
+ export declare const SCRIPTS_DIR = "scripts";
38
+ /**
39
+ * Scripts structure (shared shape between CollectionScripts and RequestScripts)
40
+ */
41
+ export interface ScriptsData {
42
+ preRequest?: string;
43
+ postResponse?: string;
44
+ }
45
+ /**
46
+ * Read scripts from a scripts/ directory.
47
+ * Returns undefined if the directory doesn't exist or has no scripts.
48
+ */
49
+ export declare function readScriptsFromDir(scriptsPath: string): ScriptsData | undefined;
50
+ /**
51
+ * Write scripts to a scripts/ directory.
52
+ */
53
+ export declare function writeScriptsToDir(scriptsPath: string, scripts: ScriptsData): Promise<void>;
54
+ /**
55
+ * Load body from external file if present.
56
+ * Supports: body.json, body.xml, body.txt, body.html, body.js, body.graphql
57
+ */
58
+ export declare function readBodyFromDir(requestPath: string): RequestBody | undefined;
59
+ /**
60
+ * Separate body content into metadata-inline vs. external-file parts.
61
+ */
62
+ export declare function prepareBodyForSave(body: any): {
63
+ bodyForMetadata: any;
64
+ externalBodyFile?: {
65
+ filename: string;
66
+ content: string;
67
+ };
68
+ };
69
+ /**
70
+ * Remove stale body files that don't match the current format.
71
+ */
72
+ export declare function cleanupOldBodyFiles(requestPath: string, currentBodyFile?: string): Promise<void>;
73
+ /**
74
+ * Load a JSON schema file if it exists.
75
+ * Returns the parsed object or undefined.
76
+ */
77
+ export declare function readSchemaFile(filePath: string): any | undefined;
78
+ /**
79
+ * Save OpenAPI schema files (response.schema.json, body.schema.json).
80
+ */
81
+ export declare function writeSchemaFiles(requestPath: string, responseSchema?: any, bodySchema?: any): Promise<void>;
82
+ /** Minimal interface for tree traversal — both UnifiedFolder/UnifiedRequest and CollectionItem satisfy this */
83
+ interface TreeNode {
84
+ id: string;
85
+ type: string;
86
+ items?: TreeNode[];
87
+ }
88
+ /**
89
+ * Find an item by ID in a tree (recursive).
90
+ */
91
+ export declare function findItemById<T extends TreeNode>(items: T[], id: string): T | undefined;
92
+ /**
93
+ * Remove an item from a tree by ID (mutates the array).
94
+ */
95
+ export declare function deleteItemFromTree<T extends TreeNode>(items: T[], id: string): boolean;
96
+ /**
97
+ * Re-sort items to match an ordered list of IDs.
98
+ * Items not in orderedIds are appended at the end.
99
+ */
100
+ export declare function sortItemsByOrder<T extends {
101
+ id: string;
102
+ }>(items: T[], orderedIds: string[]): T[];
103
+ /**
104
+ * Recursively search for a directory named targetSlug under basePath.
105
+ */
106
+ export declare function searchForItemPath(basePath: string, targetSlug: string): string | undefined;
107
+ /**
108
+ * Generate a slug from a name.
109
+ * Handles HTTP method prefixes, version indicators (T7, 1.5), path parameters,
110
+ * and deduplication with counter suffixes.
111
+ */
112
+ export declare function generateSlug(name: string, existingSlugs?: string[]): string;
113
+ export {};
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Collection Domain Interfaces
3
+ *
4
+ * Re-exports from collection-service-interfaces.ts and collection-store.ts,
5
+ * plus inline interfaces for ICollectionLoader and ICollectionParser.
6
+ */
7
+ import { UnifiedCollection } from '../types/types';
8
+ export * from './collection-service-interfaces';
9
+ export * from './collection-store';
10
+ /**
11
+ * Interface for loading collections from storage.
12
+ *
13
+ * Implementations:
14
+ * - CollectionLoader: Loads single-file collections (.forge.json)
15
+ * - FolderCollectionLoader: Loads folder-based collections
16
+ */
17
+ export interface ICollectionLoader {
18
+ loadAll(): Promise<UnifiedCollection[]> | UnifiedCollection[];
19
+ }
20
+ /**
21
+ * Interface for parsing collection files into unified format.
22
+ *
23
+ * Implementations:
24
+ * - HttpForgeParser: Parses .forge.json files
25
+ * - PostmanParser: Parses .postman_collection.json (future)
26
+ * - InsomniaParser: Parses Insomnia exports (future)
27
+ */
28
+ export interface ICollectionParser {
29
+ readonly format: string;
30
+ canParse(content: string): boolean;
31
+ parse(content: string, filePath: string): UnifiedCollection;
32
+ }
@@ -0,0 +1,95 @@
1
+ /**
2
+ * JSON Collection Loader
3
+ *
4
+ * Loads collections from single JSON files (legacy format)
5
+ * Each collection is stored as a single .json file
6
+ *
7
+ * For JSON format, all item-level operations fall back to saving the entire collection
8
+ * since everything is in one file anyway.
9
+ */
10
+ import type { Collection, CollectionItem, RequestScripts } from './collection-service-interfaces';
11
+ import type { CollectionMetadata, ICollectionStore } from './collection-store';
12
+ /**
13
+ * Loads collections from JSON files
14
+ * Format: collections/{collection-id}.json
15
+ */
16
+ export declare class JsonCollectionLoader implements ICollectionStore {
17
+ private collectionsDir;
18
+ private cache;
19
+ constructor(collectionsDir: string);
20
+ /**
21
+ * Ensure collections directory exists
22
+ */
23
+ private ensureDirectory;
24
+ /**
25
+ * Load all collections from disk
26
+ */
27
+ loadAll(): Collection[];
28
+ /**
29
+ * Load a single collection by ID
30
+ */
31
+ load(id: string): Collection | undefined;
32
+ /**
33
+ * Save a collection
34
+ */
35
+ save(collection: Collection): Promise<void>;
36
+ /**
37
+ * Delete a collection
38
+ */
39
+ delete(id: string): Promise<boolean>;
40
+ /**
41
+ * Check if a collection exists
42
+ */
43
+ exists(id: string): boolean;
44
+ /**
45
+ * Get the file path for a collection
46
+ */
47
+ getCollectionPath(id: string): string;
48
+ /**
49
+ * Create a new collection
50
+ */
51
+ create(name: string, id?: string): Promise<Collection>;
52
+ /**
53
+ * Save scripts for a specific item
54
+ * In JSON format, scripts are embedded in the collection JSON
55
+ */
56
+ saveScripts(collectionId: string, itemId: string, scripts: RequestScripts): Promise<void>;
57
+ /**
58
+ * Load scripts for a specific item
59
+ */
60
+ loadScripts(collectionId: string, itemId: string): RequestScripts | undefined;
61
+ /**
62
+ * Update collection metadata
63
+ */
64
+ updateCollectionMetadata(collectionId: string, updates: Partial<CollectionMetadata>): Promise<void>;
65
+ /**
66
+ * Save/update a single item
67
+ * For JSON format: saves entire collection
68
+ */
69
+ saveItem(collectionId: string, item: CollectionItem, parentId?: string): Promise<void>;
70
+ /**
71
+ * Delete a single item
72
+ */
73
+ deleteItem(collectionId: string, itemId: string): Promise<boolean>;
74
+ /**
75
+ * Update a single item
76
+ */
77
+ updateItem(collectionId: string, itemId: string, updates: Partial<CollectionItem>): Promise<boolean>;
78
+ /**
79
+ * Move an item to a new parent
80
+ */
81
+ moveItem(collectionId: string, itemId: string, newParentId?: string): Promise<boolean>;
82
+ /**
83
+ * Reorder items within a parent (collection or folder)
84
+ * For JSON format, just reorder the items array and save
85
+ */
86
+ reorderItems(collectionId: string, parentId: string | undefined, orderedItemIds: string[]): Promise<boolean>;
87
+ /**
88
+ * Find an item by ID in the collection tree
89
+ */
90
+ private findItemById;
91
+ /**
92
+ * Delete an item by ID from the collection tree
93
+ */
94
+ private deleteItemById;
95
+ }
@@ -4,7 +4,7 @@
4
4
  * Open/Closed Principle: New parsers can be added without modifying existing code
5
5
  * Single Responsibility: Manage collection parser registration and lookup
6
6
  */
7
- import { ICollectionParser } from '../interfaces';
7
+ import { ICollectionParser } from './interfaces';
8
8
  /**
9
9
  * Registry for collection parsers
10
10
  * Allows registering parsers for different collection formats
@@ -46,4 +46,3 @@ export declare class ParserRegistry {
46
46
  */
47
47
  clear(): void;
48
48
  }
49
- //# sourceMappingURL=parser-registry.d.ts.map