@http-forge/core 0.1.0 → 0.2.0

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 (128) hide show
  1. package/README.md +194 -41
  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 +256 -0
  10. package/dist/collection/folder-collection-store.d.ts +168 -0
  11. package/dist/collection/interfaces.d.ts +32 -0
  12. package/dist/collection/json-collection-loader.d.ts +95 -0
  13. package/dist/{services → collection}/parser-registry.d.ts +1 -2
  14. package/dist/config/config-service.d.ts +79 -0
  15. package/dist/config/config.interface.d.ts +140 -0
  16. package/dist/config/default-config.d.ts +29 -0
  17. package/dist/config/index.d.ts +6 -0
  18. package/dist/container.d.ts +22 -14
  19. package/dist/{implementations → cookie}/cookie-jar.d.ts +2 -3
  20. package/dist/cookie/cookie-service.d.ts +98 -0
  21. package/dist/{implementations → cookie}/cookie-utils.d.ts +1 -2
  22. package/dist/cookie/in-memory-cookie-jar.d.ts +44 -0
  23. package/dist/{interfaces/cookie.d.ts → cookie/interfaces.d.ts} +22 -3
  24. package/dist/cookie/persistent-cookie-jar.d.ts +35 -0
  25. package/dist/environment/environment-config-service.d.ts +95 -0
  26. package/dist/{services → environment}/environment-resolver.d.ts +6 -5
  27. package/dist/{services → environment}/forge-env.d.ts +1 -2
  28. package/dist/environment/interfaces.d.ts +139 -0
  29. package/dist/environment/variable-interpolator.d.ts +100 -0
  30. package/dist/execution/collection-request-executor-interfaces.d.ts +36 -0
  31. package/dist/execution/collection-request-executor.d.ts +78 -0
  32. package/dist/{services → execution}/request-executor.d.ts +23 -11
  33. package/dist/execution/request-preparer-interfaces.d.ts +36 -0
  34. package/dist/execution/request-preparer.d.ts +35 -0
  35. package/dist/graphql/graphql-completion-provider.d.ts +39 -0
  36. package/dist/graphql/graphql-schema-service.d.ts +89 -0
  37. package/dist/{interfaces/history.d.ts → history/history-interfaces.d.ts} +29 -6
  38. package/dist/history/request-history-service-interfaces.d.ts +43 -0
  39. package/dist/history/request-history-service.d.ts +133 -0
  40. package/dist/{implementations → history}/request-history.d.ts +2 -3
  41. package/dist/{implementations → http}/fetch-http-client.d.ts +4 -5
  42. package/dist/http/http-request-service.d.ts +36 -0
  43. package/dist/{implementations → http}/interceptor-chain.d.ts +1 -2
  44. package/dist/http/interfaces.d.ts +25 -0
  45. package/dist/http/merge-request-settings.d.ts +12 -0
  46. package/dist/{implementations → http}/native-http-client.d.ts +6 -15
  47. package/dist/{implementations → http}/request-preprocessor.d.ts +1 -2
  48. package/dist/{services → http}/url-builder.d.ts +7 -10
  49. package/dist/import-export/import-postman-environment.d.ts +21 -0
  50. package/dist/import-export/rest-client-export.d.ts +35 -0
  51. package/dist/index.d.ts +88 -6
  52. package/dist/index.js +262 -35
  53. package/dist/index.mjs +262 -35
  54. package/dist/openapi/example-generator.d.ts +26 -0
  55. package/dist/openapi/history-analyzer.d.ts +29 -0
  56. package/dist/openapi/index.d.ts +16 -0
  57. package/dist/openapi/interfaces.d.ts +42 -0
  58. package/dist/openapi/openapi-exporter.d.ts +73 -0
  59. package/dist/openapi/openapi-importer.d.ts +72 -0
  60. package/dist/openapi/ref-resolver.d.ts +28 -0
  61. package/dist/openapi/schema-inference-service.d.ts +40 -0
  62. package/dist/openapi/schema-inferrer.d.ts +26 -0
  63. package/dist/openapi/script-analyzer.d.ts +41 -0
  64. package/dist/parsers/http-forge-parser.d.ts +2 -3
  65. package/dist/parsers/index.d.ts +0 -1
  66. package/dist/{implementations → platform}/data-file-parser.d.ts +0 -1
  67. package/dist/{implementations → platform}/node-file-system.d.ts +1 -2
  68. package/dist/script/interfaces.d.ts +149 -0
  69. package/dist/script/module-loader.d.ts +115 -0
  70. package/dist/script/request-script-session.d.ts +70 -0
  71. package/dist/script/script-executor.d.ts +60 -0
  72. package/dist/script/script-factories.d.ts +83 -0
  73. package/dist/script/script-utils.d.ts +41 -0
  74. package/dist/test-suite/index.d.ts +10 -0
  75. package/dist/test-suite/interfaces.d.ts +164 -0
  76. package/dist/test-suite/result-storage-service.d.ts +70 -0
  77. package/dist/test-suite/result-storage.d.ts +296 -0
  78. package/dist/test-suite/statistics-service.d.ts +51 -0
  79. package/dist/test-suite/test-suite-service.d.ts +97 -0
  80. package/dist/test-suite/test-suite-store.d.ts +155 -0
  81. package/dist/types/console-service.d.ts +40 -0
  82. package/dist/types/platform.d.ts +206 -0
  83. package/dist/{interfaces → types}/types.d.ts +282 -12
  84. package/dist/utils/dynamic-variables.d.ts +38 -0
  85. package/dist/utils/expression-evaluator.d.ts +34 -0
  86. package/dist/utils/filter-engine.d.ts +47 -0
  87. package/dist/utils/helpers.d.ts +47 -0
  88. package/package.json +11 -3
  89. package/dist/container.d.ts.map +0 -1
  90. package/dist/implementations/cookie-jar.d.ts.map +0 -1
  91. package/dist/implementations/cookie-utils.d.ts.map +0 -1
  92. package/dist/implementations/data-file-parser.d.ts.map +0 -1
  93. package/dist/implementations/fetch-http-client.d.ts.map +0 -1
  94. package/dist/implementations/index.d.ts +0 -22
  95. package/dist/implementations/index.d.ts.map +0 -1
  96. package/dist/implementations/interceptor-chain.d.ts.map +0 -1
  97. package/dist/implementations/module-loader.d.ts +0 -74
  98. package/dist/implementations/module-loader.d.ts.map +0 -1
  99. package/dist/implementations/native-http-client.d.ts.map +0 -1
  100. package/dist/implementations/node-file-system.d.ts.map +0 -1
  101. package/dist/implementations/request-history.d.ts.map +0 -1
  102. package/dist/implementations/request-preprocessor.d.ts.map +0 -1
  103. package/dist/implementations/variable-interpolator.d.ts +0 -55
  104. package/dist/implementations/variable-interpolator.d.ts.map +0 -1
  105. package/dist/implementations/vm2-script-runner.d.ts +0 -76
  106. package/dist/implementations/vm2-script-runner.d.ts.map +0 -1
  107. package/dist/index.d.ts.map +0 -1
  108. package/dist/interfaces/cookie.d.ts.map +0 -1
  109. package/dist/interfaces/history.d.ts.map +0 -1
  110. package/dist/interfaces/index.d.ts +0 -170
  111. package/dist/interfaces/index.d.ts.map +0 -1
  112. package/dist/interfaces/types.d.ts.map +0 -1
  113. package/dist/parsers/http-forge-parser.d.ts.map +0 -1
  114. package/dist/parsers/index.d.ts.map +0 -1
  115. package/dist/services/collection-loader.d.ts.map +0 -1
  116. package/dist/services/environment-resolver.d.ts.map +0 -1
  117. package/dist/services/folder-collection-loader.d.ts +0 -91
  118. package/dist/services/folder-collection-loader.d.ts.map +0 -1
  119. package/dist/services/forge-env.d.ts.map +0 -1
  120. package/dist/services/index.d.ts +0 -20
  121. package/dist/services/index.d.ts.map +0 -1
  122. package/dist/services/parser-registry.d.ts.map +0 -1
  123. package/dist/services/request-executor.d.ts.map +0 -1
  124. package/dist/services/script-pipeline.d.ts +0 -43
  125. package/dist/services/script-pipeline.d.ts.map +0 -1
  126. package/dist/services/script-session.d.ts +0 -66
  127. package/dist/services/script-session.d.ts.map +0 -1
  128. 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 { Collection, CollectionItem, CollectionRequestItem, CreateRequestOptions, ICollectionService } from './collection-service-interfaces';
12
+ import { IFileWatcherFactory } from '../types/platform';
13
+ import { IConfigService } from '../config';
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 { Collection, CollectionItem, RequestScripts } from './collection-service-interfaces';
10
+ import type { CollectionRequest } from '../types/types';
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,256 @@
1
+ /**
2
+ * Folder Collection Loader
3
+ *
4
+ * Loads collections from directory structure (folder format)
5
+ * Each collection is a folder containing:
6
+ * - collection.json (metadata)
7
+ * - scripts/ (pre-request.js, post-response.js)
8
+ * - {folder-slug}/ (subfolders with folder.json)
9
+ * - {request-slug}/ (request folders with request.json)
10
+ *
11
+ * This is a port of the VS Code extension's FolderCollectionLoader
12
+ */
13
+ import type { CollectionScripts, RequestBody, UnifiedCollection, UnifiedFolder, UnifiedRequest } from '../types/types';
14
+ import type { ICollectionLoader } from './interfaces';
15
+ /**
16
+ * Collection metadata structure
17
+ */
18
+ interface CollectionMetadata {
19
+ id: string;
20
+ name: string;
21
+ description?: string;
22
+ version?: string;
23
+ variables?: Record<string, string>;
24
+ auth?: any;
25
+ order?: string[];
26
+ }
27
+ /**
28
+ * Scripts structure
29
+ */
30
+ interface Scripts {
31
+ preRequest?: string;
32
+ postResponse?: string;
33
+ }
34
+ /**
35
+ * Collection item (folder or request)
36
+ */
37
+ type CollectionItem = UnifiedFolder | UnifiedRequest;
38
+ /**
39
+ * Folder Collection Loader
40
+ *
41
+ * Loads collections from folder structure:
42
+ * collections/
43
+ * {collection-slug}/
44
+ * collection.json
45
+ * scripts/
46
+ * pre-request.js
47
+ * post-response.js
48
+ * {folder-slug}/
49
+ * folder.json
50
+ * scripts/
51
+ * {request-slug}/
52
+ * request.json
53
+ * scripts/
54
+ * {request-slug}/
55
+ * request.json
56
+ * scripts/
57
+ */
58
+ export declare class FolderCollectionLoader implements ICollectionLoader {
59
+ protected collectionsDir: string;
60
+ protected cache: Map<string, UnifiedCollection>;
61
+ protected slugToIdMap: Map<string, string>;
62
+ protected idToSlugMap: Map<string, string>;
63
+ constructor(collectionsDir: string);
64
+ /**
65
+ * Ensure collections directory exists
66
+ */
67
+ protected ensureDirectory(): void;
68
+ /**
69
+ * Load all collections from disk
70
+ */
71
+ loadAll(): UnifiedCollection[];
72
+ /**
73
+ * Get collection slug from ID
74
+ */
75
+ getSlugById(id: string): string | undefined;
76
+ /**
77
+ * Get collection ID from slug
78
+ */
79
+ getIdBySlug(slug: string): string | undefined;
80
+ /**
81
+ * Load a collection from a folder
82
+ */
83
+ protected loadCollectionFromFolder(slug: string): UnifiedCollection | undefined;
84
+ /**
85
+ * Load items from a directory
86
+ * @param dirPath - Directory path to load items from
87
+ * @param parentId - Parent ID for tracking
88
+ * @param order - Optional order array (slugs) to sort items
89
+ */
90
+ protected loadItemsFromDir(dirPath: string, parentId: string, order?: string[]): CollectionItem[];
91
+ /**
92
+ * Load a folder from directory
93
+ */
94
+ protected loadFolderFromDir(folderPath: string, slug: string): UnifiedFolder | undefined;
95
+ /**
96
+ * Load a request from directory
97
+ */
98
+ protected loadRequestFromDir(requestPath: string, slug: string): UnifiedRequest | undefined;
99
+ /**
100
+ * Convert array of { key, value, enabled } to Record<string, string>
101
+ * Also handles Record format (pass-through)
102
+ * Only includes enabled items (or all if enabled is undefined)
103
+ */
104
+ protected arrayToRecord(arr?: Array<{
105
+ key: string;
106
+ value: string;
107
+ enabled?: boolean;
108
+ }> | Record<string, string>): Record<string, string>;
109
+ /**
110
+ * Load scripts from a scripts directory
111
+ */
112
+ protected loadScriptsFromDir(scriptsPath: string): Scripts | undefined;
113
+ /**
114
+ * Load body from external file if present
115
+ * Supports: body.json, body.xml, body.txt, body.html, body.js, body.graphql
116
+ */
117
+ protected loadBodyFromDir(requestPath: string): RequestBody | undefined;
118
+ /**
119
+ * Load a JSON schema file if it exists.
120
+ * Returns the parsed object or undefined.
121
+ */
122
+ protected loadSchemaFile(filePath: string): any | undefined;
123
+ /**
124
+ * Load a single collection by ID.
125
+ * Checks the in-memory cache first, then falls back to slug-map → loadAll().
126
+ */
127
+ load(id: string): UnifiedCollection | undefined;
128
+ /**
129
+ * Create a new empty collection and persist it to disk.
130
+ */
131
+ create(name: string, id?: string): Promise<UnifiedCollection>;
132
+ /**
133
+ * Save (create or update) an entire collection to disk.
134
+ */
135
+ save(collection: UnifiedCollection): Promise<void>;
136
+ /**
137
+ * Delete a collection by ID (removes directory from disk).
138
+ */
139
+ delete(id: string): Promise<boolean>;
140
+ /**
141
+ * Check if a collection exists on disk.
142
+ */
143
+ exists(id: string): boolean;
144
+ /**
145
+ * Get the filesystem path for a collection.
146
+ */
147
+ getCollectionPath(id: string): string;
148
+ /**
149
+ * Update collection-level metadata (name, description, variables, etc.)
150
+ * without rewriting every item.
151
+ */
152
+ updateCollectionMetadata(collectionId: string, updates: Partial<CollectionMetadata>): Promise<void>;
153
+ /**
154
+ * Save (create or update) a single item within a collection.
155
+ * @param collectionId - The owning collection
156
+ * @param item - Folder or request to save
157
+ * @param parentId - Optional parent folder (omit for root-level)
158
+ */
159
+ saveItem(collectionId: string, item: CollectionItem, parentId?: string): Promise<void>;
160
+ /**
161
+ * Update a single item's metadata in-place.
162
+ */
163
+ updateItem(collectionId: string, itemId: string, updates: Partial<CollectionItem>): Promise<boolean>;
164
+ /**
165
+ * Delete a single item (and its directory) from a collection.
166
+ */
167
+ deleteItem(collectionId: string, itemId: string): Promise<boolean>;
168
+ /**
169
+ * Move an item to a different parent within the same collection.
170
+ * @param newParentId - Target folder ID, or `undefined` for collection root
171
+ */
172
+ moveItem(collectionId: string, itemId: string, newParentId?: string): Promise<boolean>;
173
+ /**
174
+ * Reorder items within a parent (folder or collection root).
175
+ * Writes an `order` array into the parent's metadata file.
176
+ */
177
+ reorderItems(collectionId: string, parentId: string | undefined, orderedItemIds: string[]): Promise<boolean>;
178
+ /**
179
+ * Save scripts for a specific item (collection, folder, or request).
180
+ */
181
+ saveScripts(collectionId: string, itemId: string, scripts: CollectionScripts): Promise<void>;
182
+ /**
183
+ * Load scripts for a specific item by ID.
184
+ */
185
+ loadScripts(collectionId: string, itemId: string): CollectionScripts | undefined;
186
+ /**
187
+ * Persist a list of items to a parent directory.
188
+ */
189
+ protected saveItemsToDir(parentPath: string, items: CollectionItem[]): Promise<void>;
190
+ /**
191
+ * Persist a folder's metadata, scripts, and nested items.
192
+ */
193
+ protected saveFolderToDir(folderPath: string, folder: UnifiedFolder): Promise<void>;
194
+ /**
195
+ * Persist a request's metadata, body files, schema files, and scripts.
196
+ */
197
+ protected saveRequestToDir(requestPath: string, request: UnifiedRequest): Promise<void>;
198
+ /**
199
+ * Write scripts to a scripts/ directory.
200
+ */
201
+ protected saveScriptsToDir(scriptsPath: string, scripts: CollectionScripts): Promise<void>;
202
+ /**
203
+ * Separate body content into metadata-inline vs. external-file parts.
204
+ */
205
+ protected prepareBodyForSave(body: RequestBody | undefined): {
206
+ bodyForMetadata: any;
207
+ externalBodyFile?: {
208
+ filename: string;
209
+ content: string;
210
+ };
211
+ };
212
+ /**
213
+ * Remove stale body files that don't match the current format.
214
+ */
215
+ protected cleanupOldBodyFiles(requestPath: string, currentBodyFile?: string): Promise<void>;
216
+ /**
217
+ * Save OpenAPI schema files (response.schema.json, body.schema.json).
218
+ */
219
+ protected saveSchemaFiles(requestPath: string, request: UnifiedRequest): Promise<void>;
220
+ /**
221
+ * Convert Record<string, string> to the array format used in metadata files.
222
+ */
223
+ protected recordToArray(record?: Record<string, string>): Array<{
224
+ key: string;
225
+ value: string;
226
+ enabled: boolean;
227
+ }> | undefined;
228
+ /**
229
+ * Resolve a filesystem path for an item within a collection.
230
+ */
231
+ protected findItemPath(collectionId: string, itemId: string): string | undefined;
232
+ /**
233
+ * Recursively search for a directory named `targetSlug` under `basePath`.
234
+ */
235
+ protected searchForItemPath(basePath: string, targetSlug: string): string | undefined;
236
+ /**
237
+ * Find an item by ID in the in-memory tree (recursive).
238
+ */
239
+ protected findItemById(items: CollectionItem[], id: string): CollectionItem | undefined;
240
+ /**
241
+ * Remove an item from the in-memory tree by ID (mutates the array).
242
+ */
243
+ protected deleteItemFromTree(items: CollectionItem[], id: string): boolean;
244
+ /**
245
+ * Re-sort items to match an ordered list of IDs.
246
+ * Items not in `orderedIds` are appended at the end.
247
+ */
248
+ protected sortItemsByOrder(items: CollectionItem[], orderedIds: string[]): CollectionItem[];
249
+ }
250
+ /**
251
+ * Generate a slug from a name
252
+ * Handles HTTP method prefixes, version indicators (T7, 1.5), path parameters,
253
+ * and deduplication with counter suffixes.
254
+ */
255
+ export declare function generateSlug(name: string, existingSlugs?: string[]): string;
256
+ export {};
@@ -0,0 +1,168 @@
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
+ * Ensure collections directory exists
42
+ */
43
+ private ensureDirectory;
44
+ /**
45
+ * Load all collections from disk
46
+ */
47
+ loadAll(): Collection[];
48
+ /**
49
+ * Load a collection from a folder
50
+ */
51
+ private loadCollectionFromFolder;
52
+ /**
53
+ * Load items from a directory
54
+ */
55
+ private loadItemsFromDir;
56
+ /**
57
+ * Load a folder from directory
58
+ */
59
+ private loadFolderFromDir;
60
+ /**
61
+ * Load a request from directory
62
+ */
63
+ private loadRequestFromDir;
64
+ /**
65
+ * Load scripts from a scripts directory
66
+ */
67
+ private loadScriptsFromDir;
68
+ /**
69
+ * Load body from external file if present
70
+ */
71
+ private loadBodyFromDir;
72
+ /**
73
+ * Load a JSON schema file if it exists.
74
+ */
75
+ private loadSchemaFile;
76
+ /**
77
+ * Save OpenAPI schema files if present.
78
+ */
79
+ private saveSchemaFiles;
80
+ /**
81
+ * Load a single collection by ID
82
+ */
83
+ load(id: string): Collection | undefined;
84
+ /**
85
+ * Save a collection
86
+ */
87
+ save(collection: Collection): Promise<void>;
88
+ /**
89
+ * Save items to a directory
90
+ */
91
+ private saveItemsToDir;
92
+ /**
93
+ * Save a folder to directory
94
+ */
95
+ private saveFolderToDir;
96
+ /**
97
+ * Save a request to directory
98
+ */
99
+ private saveRequestToDir;
100
+ /**
101
+ * Prepare body for saving - determine what goes in metadata vs external file
102
+ */
103
+ private prepareBodyForSave;
104
+ /**
105
+ * Clean up old body files that don't match current format
106
+ */
107
+ private cleanupOldBodyFiles;
108
+ /**
109
+ * Save scripts to a directory
110
+ */
111
+ private saveScriptsToDir;
112
+ /**
113
+ * Delete a collection
114
+ */
115
+ delete(id: string): Promise<boolean>;
116
+ /**
117
+ * Check if a collection exists
118
+ */
119
+ exists(id: string): boolean;
120
+ /**
121
+ * Get the path for a collection
122
+ */
123
+ getCollectionPath(id: string): string;
124
+ /**
125
+ * Create a new collection
126
+ */
127
+ create(name: string, id?: string): Promise<Collection>;
128
+ /**
129
+ * Save scripts for a specific item
130
+ */
131
+ saveScripts(collectionId: string, itemId: string, scripts: RequestScripts): Promise<void>;
132
+ /**
133
+ * Load scripts for a specific item
134
+ */
135
+ loadScripts(collectionId: string, itemId: string): RequestScripts | undefined;
136
+ /**
137
+ * Update collection metadata only
138
+ */
139
+ updateCollectionMetadata(collectionId: string, updates: Partial<CollectionMetadata>): Promise<void>;
140
+ /**
141
+ * Save/update a single item
142
+ */
143
+ saveItem(collectionId: string, item: CollectionItem, parentId?: string): Promise<void>;
144
+ /**
145
+ * Delete a single item
146
+ */
147
+ deleteItem(collectionId: string, itemId: string): Promise<boolean>;
148
+ /**
149
+ * Update a single item's metadata
150
+ */
151
+ updateItem(collectionId: string, itemId: string, updates: Partial<CollectionItem>): Promise<boolean>;
152
+ /**
153
+ * Move an item to a new parent
154
+ */
155
+ moveItem(collectionId: string, itemId: string, newParentId?: string): Promise<boolean>;
156
+ /**
157
+ * Reorder items within a parent
158
+ */
159
+ reorderItems(collectionId: string, parentId: string | undefined, orderedItemIds: string[]): Promise<boolean>;
160
+ /**
161
+ * Sort items array by ID order
162
+ */
163
+ private sortItemsByOrder;
164
+ private findItemPath;
165
+ private searchForItemPath;
166
+ private findItemById;
167
+ private deleteItemFromTree;
168
+ }
@@ -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
+ }