@http-forge/core 0.2.0 → 0.2.2

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 (168) hide show
  1. package/README.md +25 -4
  2. package/dist/application/dto/index.d.ts +8 -0
  3. package/dist/application/dto/request-dtos.d.ts +105 -0
  4. package/dist/application/dto/response-dtos.d.ts +185 -0
  5. package/dist/application/events/application-events.d.ts +53 -0
  6. package/dist/application/events/index.d.ts +6 -0
  7. package/dist/application/index.d.ts +25 -0
  8. package/dist/application/mappers/collection-mapper.d.ts +39 -0
  9. package/dist/application/mappers/execution-result-mapper.d.ts +16 -0
  10. package/dist/application/mappers/index.d.ts +9 -0
  11. package/dist/application/mappers/request-mapper.d.ts +29 -0
  12. package/dist/application/queries/get-request-schema.query.d.ts +32 -0
  13. package/dist/application/queries/index.d.ts +6 -0
  14. package/dist/application/use-cases/create-request.use-case.d.ts +23 -0
  15. package/dist/application/use-cases/delete-request.use-case.d.ts +15 -0
  16. package/dist/application/use-cases/execute-request.use-case.d.ts +46 -0
  17. package/dist/application/use-cases/export-collection.use-case.d.ts +22 -0
  18. package/dist/application/use-cases/get-collection.use-case.d.ts +13 -0
  19. package/dist/application/use-cases/index.d.ts +12 -0
  20. package/dist/application/use-cases/list-requests.use-case.d.ts +14 -0
  21. package/dist/application/use-cases/load-collection.use-case.d.ts +30 -0
  22. package/dist/application/use-cases/save-collection.use-case.d.ts +25 -0
  23. package/dist/application/use-cases/update-request.use-case.d.ts +17 -0
  24. package/dist/container.d.ts +34 -18
  25. package/dist/di/core-bootstrap.d.ts +25 -0
  26. package/dist/di/index.d.ts +19 -0
  27. package/dist/di/platform-adapters.d.ts +66 -0
  28. package/dist/di/service-container.d.ts +97 -0
  29. package/dist/di/service-identifiers.d.ts +34 -0
  30. package/dist/domain/errors/domain-errors.d.ts +52 -0
  31. package/dist/domain/errors/index.d.ts +4 -0
  32. package/dist/domain/index.d.ts +24 -0
  33. package/dist/domain/models/execution.d.ts +88 -0
  34. package/dist/domain/models/index.d.ts +4 -0
  35. package/dist/domain/services/domain-events.d.ts +60 -0
  36. package/dist/domain/services/execution-planner.domain-service.d.ts +40 -0
  37. package/dist/domain/services/index.d.ts +9 -0
  38. package/dist/domain/services/schema-inference.domain-service.d.ts +54 -0
  39. package/dist/domain/value-objects/entity-id.d.ts +26 -0
  40. package/dist/domain/value-objects/http-method.d.ts +30 -0
  41. package/dist/domain/value-objects/index.d.ts +9 -0
  42. package/dist/domain/value-objects/request-url.d.ts +28 -0
  43. package/dist/index.d.ts +90 -84
  44. package/dist/index.js +187 -187
  45. package/dist/index.mjs +187 -187
  46. package/dist/infrastructure/adapters/index.d.ts +5 -0
  47. package/dist/infrastructure/adapters/logger.adapter.d.ts +25 -0
  48. package/dist/infrastructure/adapters/node-file-system.adapter.d.ts +18 -0
  49. package/dist/{auth → infrastructure/auth}/interfaces.d.ts +1 -1
  50. package/dist/{auth → infrastructure/auth}/oauth2-token-manager.d.ts +3 -3
  51. package/dist/{collection → infrastructure/collection}/collection-loader.d.ts +3 -3
  52. package/dist/{collection → infrastructure/collection}/collection-service.d.ts +2 -2
  53. package/dist/{collection → infrastructure/collection}/collection-store.d.ts +2 -2
  54. package/dist/infrastructure/collection/folder-collection-loader.d.ts +45 -0
  55. package/dist/{collection → infrastructure/collection}/folder-collection-store.d.ts +9 -2
  56. package/dist/infrastructure/collection/folder-io.d.ts +113 -0
  57. package/dist/{collection → infrastructure/collection}/json-collection-loader.d.ts +1 -1
  58. package/dist/{collection → infrastructure/collection}/parser-registry.d.ts +1 -1
  59. package/dist/{config → infrastructure/config}/config-service.d.ts +1 -1
  60. package/dist/{cookie → infrastructure/cookie}/cookie-service.d.ts +1 -1
  61. package/dist/infrastructure/di/complete-bootstrap.d.ts +24 -0
  62. package/dist/infrastructure/di/index.d.ts +6 -0
  63. package/dist/infrastructure/di/infrastructure-di-config.d.ts +33 -0
  64. package/dist/infrastructure/di/simple-event-publisher.d.ts +17 -0
  65. package/dist/{environment → infrastructure/environment}/environment-config-service.d.ts +6 -3
  66. package/dist/infrastructure/environment/environment-file-loader.d.ts +42 -0
  67. package/dist/{environment → infrastructure/environment}/environment-resolver.d.ts +1 -1
  68. package/dist/{environment → infrastructure/environment}/forge-env.d.ts +1 -1
  69. package/dist/{environment → infrastructure/environment}/variable-interpolator.d.ts +1 -1
  70. package/dist/{execution → infrastructure/execution}/collection-request-executor-interfaces.d.ts +1 -1
  71. package/dist/{execution → infrastructure/execution}/collection-request-executor.d.ts +3 -3
  72. package/dist/{execution → infrastructure/execution}/request-executor.d.ts +4 -4
  73. package/dist/{execution → infrastructure/execution}/request-preparer-interfaces.d.ts +2 -2
  74. package/dist/{execution → infrastructure/execution}/request-preparer.d.ts +5 -5
  75. package/dist/{graphql → infrastructure/graphql}/graphql-schema-service.d.ts +1 -1
  76. package/dist/{history → infrastructure/history}/history-interfaces.d.ts +1 -1
  77. package/dist/{history → infrastructure/history}/request-history.d.ts +1 -1
  78. package/dist/{http → infrastructure/http}/fetch-http-client.d.ts +2 -2
  79. package/dist/{http → infrastructure/http}/http-request-service.d.ts +2 -2
  80. package/dist/infrastructure/http/index.d.ts +4 -0
  81. package/dist/{http → infrastructure/http}/interceptor-chain.d.ts +1 -1
  82. package/dist/{http → infrastructure/http}/interfaces.d.ts +1 -1
  83. package/dist/{http → infrastructure/http}/merge-request-settings.d.ts +1 -1
  84. package/dist/{http → infrastructure/http}/native-http-client.d.ts +2 -2
  85. package/dist/infrastructure/http/node-http-executor.adapter.d.ts +25 -0
  86. package/dist/{http → infrastructure/http}/request-preprocessor.d.ts +1 -1
  87. package/dist/{import-export → infrastructure/import-export}/import-postman-environment.d.ts +3 -3
  88. package/dist/{import-export → infrastructure/import-export}/rest-client-export.d.ts +3 -3
  89. package/dist/infrastructure/index.d.ts +31 -0
  90. package/dist/{openapi → infrastructure/openapi}/example-generator.d.ts +1 -1
  91. package/dist/{openapi → infrastructure/openapi}/history-analyzer.d.ts +1 -1
  92. package/dist/{openapi → infrastructure/openapi}/interfaces.d.ts +2 -2
  93. package/dist/{openapi → infrastructure/openapi}/openapi-exporter.d.ts +2 -2
  94. package/dist/{openapi → infrastructure/openapi}/openapi-importer.d.ts +2 -2
  95. package/dist/{openapi → infrastructure/openapi}/schema-inference-service.d.ts +1 -1
  96. package/dist/{openapi → infrastructure/openapi}/schema-inferrer.d.ts +1 -1
  97. package/dist/infrastructure/parsers/collection-parser.adapter.d.ts +32 -0
  98. package/dist/{parsers → infrastructure/parsers}/http-forge-parser.d.ts +2 -2
  99. package/dist/infrastructure/parsers/index.d.ts +7 -0
  100. package/dist/infrastructure/persistence/file-system-history-loader.d.ts +31 -0
  101. package/dist/infrastructure/persistence/index.d.ts +6 -0
  102. package/dist/{platform → infrastructure/platform}/node-file-system.d.ts +1 -1
  103. package/dist/infrastructure/repositories/file-system/fs-collection-repository.d.ts +72 -0
  104. package/dist/infrastructure/repositories/file-system/fs-environment-file-loader.adapter.d.ts +41 -0
  105. package/dist/infrastructure/repositories/file-system/fs-environment-repository.d.ts +34 -0
  106. package/dist/infrastructure/repositories/file-system/fs-request-repository.d.ts +31 -0
  107. package/dist/infrastructure/repositories/file-system/index.d.ts +7 -0
  108. package/dist/infrastructure/repositories/in-memory/in-memory-collection-repository.d.ts +18 -0
  109. package/dist/infrastructure/repositories/in-memory/in-memory-environment-repository.d.ts +25 -0
  110. package/dist/infrastructure/repositories/in-memory/in-memory-request-repository.d.ts +25 -0
  111. package/dist/infrastructure/repositories/in-memory/index.d.ts +7 -0
  112. package/dist/infrastructure/script/index.d.ts +4 -0
  113. package/dist/{script → infrastructure/script}/interfaces.d.ts +13 -1
  114. package/dist/{script → infrastructure/script}/request-script-session.d.ts +3 -0
  115. package/dist/{script → infrastructure/script}/script-factories.d.ts +15 -4
  116. package/dist/{script → infrastructure/script}/script-utils.d.ts +3 -2
  117. package/dist/infrastructure/script/vm-script-executor.adapter.d.ts +19 -0
  118. package/dist/{test-suite → infrastructure/test-suite}/result-storage-service.d.ts +1 -1
  119. package/dist/{test-suite → infrastructure/test-suite}/result-storage.d.ts +1 -1
  120. package/dist/{test-suite → infrastructure/test-suite}/test-suite-service.d.ts +1 -1
  121. package/dist/{test-suite → infrastructure/test-suite}/test-suite-store.d.ts +1 -1
  122. package/dist/ports/executors/http-executor.interface.d.ts +34 -0
  123. package/dist/ports/executors/index.d.ts +5 -0
  124. package/dist/ports/executors/script-executor.interface.d.ts +43 -0
  125. package/dist/ports/external/file-system.interface.d.ts +44 -0
  126. package/dist/ports/external/http-client.interface.d.ts +25 -0
  127. package/dist/ports/external/index.d.ts +7 -0
  128. package/dist/ports/external/logger.interface.d.ts +17 -0
  129. package/dist/ports/index.d.ts +17 -0
  130. package/dist/ports/parsers/collection-parser.interface.d.ts +23 -0
  131. package/dist/ports/parsers/index.d.ts +4 -0
  132. package/dist/ports/repositories/collection-repository.interface.d.ts +32 -0
  133. package/dist/ports/repositories/environment-repository.interface.d.ts +31 -0
  134. package/dist/ports/repositories/index.d.ts +6 -0
  135. package/dist/ports/repositories/request-repository.interface.d.ts +32 -0
  136. package/dist/ports/storage/cache-store.interface.d.ts +26 -0
  137. package/dist/ports/storage/history-loader.interface.d.ts +37 -0
  138. package/dist/ports/storage/index.d.ts +5 -0
  139. package/dist/{collection/collection-service-interfaces.d.ts → types/collection.d.ts} +19 -4
  140. package/dist/types/environment-config.d.ts +143 -0
  141. package/dist/types/types.d.ts +27 -7
  142. package/package.json +2 -2
  143. package/dist/collection/folder-collection-loader.d.ts +0 -256
  144. package/dist/collection/interfaces.d.ts +0 -32
  145. package/dist/parsers/index.d.ts +0 -6
  146. package/dist/{collection → infrastructure/collection}/collection-loader-factory.d.ts +1 -1
  147. package/dist/{config → infrastructure/config}/config.interface.d.ts +0 -0
  148. package/dist/{config → infrastructure/config}/default-config.d.ts +0 -0
  149. package/dist/{config → infrastructure/config}/index.d.ts +0 -0
  150. package/dist/{cookie → infrastructure/cookie}/cookie-jar.d.ts +0 -0
  151. package/dist/{cookie → infrastructure/cookie}/cookie-utils.d.ts +0 -0
  152. package/dist/{cookie → infrastructure/cookie}/in-memory-cookie-jar.d.ts +1 -1
  153. package/dist/{cookie → infrastructure/cookie}/interfaces.d.ts +0 -0
  154. package/dist/{cookie → infrastructure/cookie}/persistent-cookie-jar.d.ts +1 -1
  155. package/dist/{environment → infrastructure/environment}/interfaces.d.ts +0 -0
  156. package/dist/{graphql → infrastructure/graphql}/graphql-completion-provider.d.ts +0 -0
  157. package/dist/{history → infrastructure/history}/request-history-service-interfaces.d.ts +0 -0
  158. package/dist/{history → infrastructure/history}/request-history-service.d.ts +0 -0
  159. package/dist/{http → infrastructure/http}/url-builder.d.ts +0 -0
  160. package/dist/{openapi → infrastructure/openapi}/index.d.ts +0 -0
  161. package/dist/{openapi → infrastructure/openapi}/ref-resolver.d.ts +0 -0
  162. package/dist/{openapi → infrastructure/openapi}/script-analyzer.d.ts +0 -0
  163. package/dist/{platform → infrastructure/platform}/data-file-parser.d.ts +0 -0
  164. package/dist/{script → infrastructure/script}/module-loader.d.ts +0 -0
  165. package/dist/{script → infrastructure/script}/script-executor.d.ts +1 -1
  166. /package/dist/{test-suite → infrastructure/test-suite}/index.d.ts +0 -0
  167. /package/dist/{test-suite → infrastructure/test-suite}/interfaces.d.ts +0 -0
  168. /package/dist/{test-suite → infrastructure/test-suite}/statistics-service.d.ts +0 -0
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Environment Configuration Types
3
+ *
4
+ * Migrated from src/environment/ for better organization
5
+ * These types define the contracts for environment management
6
+ */
7
+ /**
8
+ * Environment configuration structure
9
+ */
10
+ export interface EnvironmentConfig {
11
+ description?: string;
12
+ requiresConfirmation?: boolean;
13
+ variables?: Record<string, string>;
14
+ }
15
+ /**
16
+ * Shared configuration file structure
17
+ */
18
+ export interface SharedConfig {
19
+ environments: Record<string, EnvironmentConfig>;
20
+ globalVariables?: Record<string, string>;
21
+ defaultHeaders?: Record<string, string>;
22
+ }
23
+ /**
24
+ * Local configuration file structure
25
+ */
26
+ export interface LocalConfig {
27
+ credentials?: Record<string, {
28
+ variables?: Record<string, string>;
29
+ }>;
30
+ variables?: Record<string, string>;
31
+ }
32
+ /**
33
+ * Resolved environment with all inherited values
34
+ */
35
+ export interface ResolvedEnvironment {
36
+ name: string;
37
+ description?: string;
38
+ requiresConfirmation?: boolean;
39
+ headers: Record<string, string>;
40
+ variables: Record<string, string>;
41
+ }
42
+ /**
43
+ * Representation of an imported environment (from Postman)
44
+ */
45
+ export interface ImportedEnvironment {
46
+ name: string;
47
+ variables: Record<string, string>;
48
+ description?: string;
49
+ }
50
+ /**
51
+ * Import operations for environments
52
+ */
53
+ export interface IEnvironmentImporter {
54
+ importPostmanEnvironmentFile(filePath: string): ImportedEnvironment | null;
55
+ }
56
+ /**
57
+ * Read operations for environment configuration
58
+ */
59
+ export interface IEnvironmentConfigReader {
60
+ getWorkspaceFolder(): string;
61
+ getRootPath(): string;
62
+ getEnvironmentNames(): string[];
63
+ getSelectedEnvironment(): string;
64
+ getSharedConfig(): SharedConfig | null;
65
+ getSharedConfigPath(): string;
66
+ getLocalConfig(): LocalConfig | null;
67
+ getLocalConfigPath(): string;
68
+ getEnvironmentConfigPath(envName: string): string;
69
+ getEnvLocalPath(envName: string): string;
70
+ getResolvedEnvironment(envName: string): ResolvedEnvironment | null;
71
+ }
72
+ /**
73
+ * Write operations for environment configuration
74
+ */
75
+ export interface IEnvironmentConfigWriter {
76
+ saveSharedConfig(config: SharedConfig): void;
77
+ saveLocalConfig(config: LocalConfig): void;
78
+ }
79
+ /**
80
+ * Environment selection operations
81
+ */
82
+ export interface IEnvironmentSelector {
83
+ setSelectedEnvironment(envName: string): Promise<void>;
84
+ }
85
+ /**
86
+ * Variable resolution operations
87
+ */
88
+ export interface IVariableResolver {
89
+ resolveVariables(text: string, envName?: string): string;
90
+ resolveVariablesWithExtra(text: string, extraVariables: Record<string, string>, envName?: string): string;
91
+ resolveVariablesInObject<T extends Record<string, any>>(obj: T, envName?: string): T;
92
+ resolveVariablesInObjectWithExtra<T extends Record<string, any>>(obj: T, extraVariables: Record<string, string>, envName?: string): T;
93
+ }
94
+ /**
95
+ * Variable management operations (for scripts)
96
+ */
97
+ export interface IVariableManager {
98
+ setEnvironmentVariable(key: string, value: unknown): void;
99
+ deleteEnvironmentVariable(key: string): void;
100
+ clearEnvironmentVariables(): void;
101
+ getEnvironmentVariableLocals(): Record<string, string>;
102
+ setGlobalVariable(key: string, value: unknown): void;
103
+ getGlobalVariable(key: string): string | undefined;
104
+ deleteGlobalVariable(key: string): void;
105
+ clearGlobalVariables(): void;
106
+ setSessionVariable(key: string, value: unknown): void;
107
+ deleteSessionVariable(key: string): Promise<void>;
108
+ clearSessionVariables(): Promise<void>;
109
+ getSessionVariables(): Record<string, string>;
110
+ getGlobalVariables(): Record<string, string>;
111
+ }
112
+ /**
113
+ * Full environment configuration service interface
114
+ */
115
+ export interface IEnvironmentConfigService extends IEnvironmentConfigReader, IEnvironmentConfigWriter, IEnvironmentSelector, IVariableResolver, IVariableManager {
116
+ loadConfigs(): void;
117
+ exportEnvironmentsToFolder(outDir: string, mergeGlobals?: boolean): void;
118
+ }
119
+ /**
120
+ * Interface for storing and retrieving environment variables
121
+ */
122
+ export interface IEnvironmentStore {
123
+ get(key: string): string | undefined;
124
+ set(key: string, value: string): void;
125
+ getAll(): Record<string, string>;
126
+ getActive(): string | undefined;
127
+ setActive(name: string): void;
128
+ getVariables(environmentName?: string): Record<string, string>;
129
+ }
130
+ /**
131
+ * Interface for interpolating variables in strings
132
+ * Handles {{variable}} syntax replacement
133
+ */
134
+ export interface IVariableInterpolator {
135
+ interpolate(input: string, variables: Record<string, string>): string;
136
+ extractVariables(input: string): string[];
137
+ interpolateObject<T>(obj: T, variables: Record<string, string>): T;
138
+ }
139
+ /**
140
+ * ForgeEnv type for environment representation
141
+ * @see src/infrastructure/environment/forge-env.ts for the canonical definition
142
+ */
143
+ export type { IForgeEnv } from '../infrastructure/environment/forge-env';
@@ -4,7 +4,7 @@
4
4
  * Core data types used throughout the framework.
5
5
  * Simplified design for maximum compatibility.
6
6
  */
7
- import { ParsedCookie } from '../cookie/interfaces';
7
+ import { ParsedCookie } from '../infrastructure/cookie/interfaces';
8
8
  export type { ParsedCookie };
9
9
  /**
10
10
  * Unified Collection - the common format all parsers produce
@@ -24,6 +24,8 @@ export interface UnifiedCollection {
24
24
  filePath: string;
25
25
  version?: string;
26
26
  };
27
+ /** Metadata (parser info, load timestamps, etc.) */
28
+ meta?: Record<string, any>;
27
29
  }
28
30
  /**
29
31
  * Unified Folder within a collection
@@ -39,6 +41,7 @@ export interface UnifiedFolder {
39
41
  }
40
42
  /**
41
43
  * Unified Request - normalized request format
44
+ * Supports full feature set from CollectionRequest with metadata preservation
42
45
  */
43
46
  export interface UnifiedRequest {
44
47
  type: 'request';
@@ -47,16 +50,26 @@ export interface UnifiedRequest {
47
50
  description?: string;
48
51
  method: string;
49
52
  url: string;
50
- /** Headers as simple key-value pairs */
51
- headers: Record<string, string>;
52
- /** Query parameters as simple key-value pairs */
53
- query: Record<string, string>;
54
- /** Path parameters */
55
- params?: Record<string, string>;
53
+ /** Headers with per-header enabled/disabled flag and OpenAPI metadata */
54
+ headers: KeyValueEntry[];
55
+ /** Query parameters with per-item enabled/disabled flag and OpenAPI metadata */
56
+ query: KeyValueEntry[];
57
+ /** Path parameters with OpenAPI metadata */
58
+ params?: Record<string, string | PathParamEntry>;
56
59
  body?: RequestBody;
60
+ /** Content-Type override for request body */
61
+ bodyContentType?: string;
57
62
  auth?: CollectionAuth;
58
63
  settings?: RequestSettings;
59
64
  scripts?: CollectionScripts;
65
+ /** Mark request as disabled (not editable via UI) */
66
+ disabled?: boolean;
67
+ /** Mark request as deprecated */
68
+ deprecated?: boolean;
69
+ /** Response schema for validation */
70
+ responseSchema?: ResponseSchemaDefinition;
71
+ /** Body schema for validation */
72
+ bodySchema?: BodySchemaDefinition;
60
73
  }
61
74
  /**
62
75
  * Collection-level scripts
@@ -575,4 +588,11 @@ export interface ExecutionResult {
575
588
  modifiedCollectionVariables?: Record<string, string>;
576
589
  modifiedSessionVariables?: Record<string, string>;
577
590
  error?: string;
591
+ /** Postman-compatible: pm.execution.setNextRequest() value. null = stop runner. */
592
+ nextRequest?: string | null;
593
+ /** Postman-compatible: pm.visualizer.set(template, data) output */
594
+ visualizerData?: {
595
+ template: string;
596
+ data?: any;
597
+ };
578
598
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@http-forge/core",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Headless HTTP testing engine with Postman collection support, dynamic variables, and script-based automation.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -48,7 +48,7 @@
48
48
  "directory": "packages/core"
49
49
  },
50
50
  "engines": {
51
- "node": ">=18.0.0"
51
+ "node": ">=20.0.0"
52
52
  },
53
53
  "dependencies": {
54
54
  "@apidevtools/json-schema-ref-parser": "^11.7.3",
@@ -1,256 +0,0 @@
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 {};
@@ -1,32 +0,0 @@
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
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Collection Parsers
3
- *
4
- * Export all parser implementations
5
- */
6
- export { HttpForgeParser } from './http-forge-parser';
@@ -3,8 +3,8 @@
3
3
  *
4
4
  * Factory Pattern: Creates appropriate loader based on configuration
5
5
  */
6
- import { ICollectionStore } from './collection-store';
7
6
  import { IConfigService } from '../config';
7
+ import { ICollectionStore } from './collection-store';
8
8
  /**
9
9
  * Factory for creating collection loaders
10
10
  */
@@ -8,8 +8,8 @@
8
8
  * For persistent cookie handling (across requests in a session), use
9
9
  * PersistentCookieJar which wraps an ICookieService backend.
10
10
  */
11
- import type { Cookie } from './interfaces';
12
11
  import type { ICookieJar } from '../script/interfaces';
12
+ import type { Cookie } from './interfaces';
13
13
  export declare class InMemoryCookieJar implements ICookieJar {
14
14
  private cookies;
15
15
  /**
@@ -9,8 +9,8 @@
9
9
  *
10
10
  * Extracted from extension's request-execution/PersistentCookieJar.ts.
11
11
  */
12
- import { Cookie, IAsyncCookieService, ICookieService } from './interfaces';
13
12
  import { ICookieJar } from '../script/interfaces';
13
+ import { Cookie, IAsyncCookieService, ICookieService } from './interfaces';
14
14
  export declare class PersistentCookieJar implements ICookieJar {
15
15
  private cookieService;
16
16
  /** Local cache that reflects script modifications */
@@ -8,8 +8,8 @@
8
8
  * This is the main entry point for script execution.
9
9
  * It configures the VM sandbox and delegates session management to RequestScriptSession.
10
10
  */
11
- import { IRequestScriptSession, IScriptExecutor, PreRequestScriptContext } from './interfaces';
12
11
  import { IHttpRequestService } from '../http/interfaces';
12
+ import { IRequestScriptSession, IScriptExecutor, PreRequestScriptContext } from './interfaces';
13
13
  /**
14
14
  * Script Executor Implementation
15
15
  *