@stackwright-pro/cli-data-explorer 0.1.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.
@@ -0,0 +1,157 @@
1
+ /**
2
+ * CLI plugin types for the Data Explorer plugin.
3
+ */
4
+ /**
5
+ * Plugin registrar function signature.
6
+ * The OSS CLI calls this to register plugin commands.
7
+ */
8
+ interface PluginRegistrar {
9
+ (program: Command): void;
10
+ }
11
+ /**
12
+ * Placeholder import for Commander - actual type used at runtime.
13
+ * This is a simplified type definition for the CLI plugin interface.
14
+ */
15
+ interface Command {
16
+ command(name?: string): Command;
17
+ description(text: string): Command;
18
+ option(flags: string, description?: string, defaultValue?: unknown): Command;
19
+ requiredOption(flags: string, description?: string): Command;
20
+ action(handler: (options: Record<string, unknown>, cmd?: Command) => void | Promise<void>): Command;
21
+ hook(event: string, handler: (thisCommand: Command) => void | Promise<void>): Command;
22
+ addHelpText(after: string, text: string): Command;
23
+ }
24
+ /**
25
+ * Represents a single entity (schema) discovered from OpenAPI or Zod schemas.
26
+ */
27
+ interface EntityInfo {
28
+ /** Display name, e.g. "Equipment" */
29
+ name: string;
30
+ /** URL-safe slug, e.g. "equipment" */
31
+ slug: string;
32
+ /** Primary endpoint path, e.g. "/equipment" */
33
+ endpoint: string;
34
+ /** Number of fields in this entity */
35
+ fieldCount: number;
36
+ /** Detailed field information */
37
+ fields: FieldInfo[];
38
+ /** Source file containing this schema */
39
+ sourceFile: string;
40
+ }
41
+ /**
42
+ * Represents a single field within an entity.
43
+ */
44
+ interface FieldInfo {
45
+ /** Field name, e.g. "status" */
46
+ name: string;
47
+ /** Type as string, e.g. "string", "enum" */
48
+ type: string;
49
+ /** Whether this field is required */
50
+ required: boolean;
51
+ /** Optional description from schema */
52
+ description?: string;
53
+ }
54
+ /**
55
+ * Result of listing entities.
56
+ */
57
+ interface ListEntitiesResult {
58
+ success: boolean;
59
+ entities: EntityInfo[];
60
+ errors?: string[];
61
+ }
62
+ /**
63
+ * Options for listing entities.
64
+ */
65
+ interface ListEntitiesOptions {
66
+ /** Path to OpenAPI spec file */
67
+ specPath?: string;
68
+ /** Path to compiled Zod schema module (e.g., ./dist/schemas.js) */
69
+ schemaPath?: string;
70
+ /** Project root for resolving paths */
71
+ projectRoot?: string;
72
+ }
73
+ /**
74
+ * Endpoint filter configuration.
75
+ */
76
+ interface EndpointFilter {
77
+ /** Endpoints to include */
78
+ include: string[];
79
+ /** Patterns to exclude */
80
+ exclude: string[];
81
+ }
82
+ /**
83
+ * Result of generating a filter.
84
+ */
85
+ interface GenerateFilterResult {
86
+ success: boolean;
87
+ filter: EndpointFilter;
88
+ warnings?: string[];
89
+ outputPath?: string;
90
+ }
91
+ /**
92
+ * Options for generating a filter.
93
+ */
94
+ interface GenerateFilterOptions {
95
+ /** Path to OpenAPI spec file */
96
+ specPath?: string;
97
+ /** Path to compiled Zod schema module */
98
+ schemaPath?: string;
99
+ /** Entity slugs to include */
100
+ selectedEntities: string[];
101
+ /** Glob patterns to exclude */
102
+ excludePatterns?: string[];
103
+ /** Path to write stackwright.yml */
104
+ outputPath?: string;
105
+ /** Project root */
106
+ projectRoot?: string;
107
+ }
108
+
109
+ /**
110
+ * Discover available entities from Zod schemas or OpenAPI spec.
111
+ *
112
+ * Priority:
113
+ * 1. schemaPath (explicit Zod schemas)
114
+ * 2. specPath (explicit OpenAPI spec)
115
+ * 3. Auto-detect (look for compiled schemas or OpenAPI spec)
116
+ *
117
+ * Pure function: same inputs → same outputs, no side effects.
118
+ */
119
+ declare function listEntities(options?: ListEntitiesOptions): ListEntitiesResult;
120
+
121
+ /**
122
+ * Generates endpoint filter configuration from selected entities.
123
+ *
124
+ * Pure function: same inputs → same outputs.
125
+ *
126
+ * Logic:
127
+ * 1. For each selected entity, include: /entity and /entity/{id}
128
+ * 2. Apply default exclusions (admin, reports, delete)
129
+ * 3. Return filter config
130
+ */
131
+ declare function generateFilter(options: GenerateFilterOptions): GenerateFilterResult;
132
+ /**
133
+ * Discover entities from an OpenAPI spec and generate filter.
134
+ * Single function for the common workflow.
135
+ */
136
+ declare function discoverAndFilter(options: {
137
+ specPath: string;
138
+ selectedEntities: string[];
139
+ excludePatterns?: string[];
140
+ outputPath?: string;
141
+ projectRoot?: string;
142
+ }): GenerateFilterResult;
143
+
144
+ /**
145
+ * CLI plugin registration.
146
+ * Called by the OSS CLI when this package is installed.
147
+ *
148
+ * Usage in OSS CLI:
149
+ * ```ts
150
+ * // In cli-plugin-loader.ts
151
+ * import { registerCommands } from '@stackwright-pro/cli-data-explorer';
152
+ * registerCommands(program);
153
+ * ```
154
+ */
155
+ declare const registerCommands: PluginRegistrar;
156
+
157
+ export { type EndpointFilter, type EntityInfo, type FieldInfo, type GenerateFilterOptions, type GenerateFilterResult, type ListEntitiesOptions, type ListEntitiesResult, registerCommands as default, discoverAndFilter, generateFilter, listEntities, registerCommands };
@@ -0,0 +1,157 @@
1
+ /**
2
+ * CLI plugin types for the Data Explorer plugin.
3
+ */
4
+ /**
5
+ * Plugin registrar function signature.
6
+ * The OSS CLI calls this to register plugin commands.
7
+ */
8
+ interface PluginRegistrar {
9
+ (program: Command): void;
10
+ }
11
+ /**
12
+ * Placeholder import for Commander - actual type used at runtime.
13
+ * This is a simplified type definition for the CLI plugin interface.
14
+ */
15
+ interface Command {
16
+ command(name?: string): Command;
17
+ description(text: string): Command;
18
+ option(flags: string, description?: string, defaultValue?: unknown): Command;
19
+ requiredOption(flags: string, description?: string): Command;
20
+ action(handler: (options: Record<string, unknown>, cmd?: Command) => void | Promise<void>): Command;
21
+ hook(event: string, handler: (thisCommand: Command) => void | Promise<void>): Command;
22
+ addHelpText(after: string, text: string): Command;
23
+ }
24
+ /**
25
+ * Represents a single entity (schema) discovered from OpenAPI or Zod schemas.
26
+ */
27
+ interface EntityInfo {
28
+ /** Display name, e.g. "Equipment" */
29
+ name: string;
30
+ /** URL-safe slug, e.g. "equipment" */
31
+ slug: string;
32
+ /** Primary endpoint path, e.g. "/equipment" */
33
+ endpoint: string;
34
+ /** Number of fields in this entity */
35
+ fieldCount: number;
36
+ /** Detailed field information */
37
+ fields: FieldInfo[];
38
+ /** Source file containing this schema */
39
+ sourceFile: string;
40
+ }
41
+ /**
42
+ * Represents a single field within an entity.
43
+ */
44
+ interface FieldInfo {
45
+ /** Field name, e.g. "status" */
46
+ name: string;
47
+ /** Type as string, e.g. "string", "enum" */
48
+ type: string;
49
+ /** Whether this field is required */
50
+ required: boolean;
51
+ /** Optional description from schema */
52
+ description?: string;
53
+ }
54
+ /**
55
+ * Result of listing entities.
56
+ */
57
+ interface ListEntitiesResult {
58
+ success: boolean;
59
+ entities: EntityInfo[];
60
+ errors?: string[];
61
+ }
62
+ /**
63
+ * Options for listing entities.
64
+ */
65
+ interface ListEntitiesOptions {
66
+ /** Path to OpenAPI spec file */
67
+ specPath?: string;
68
+ /** Path to compiled Zod schema module (e.g., ./dist/schemas.js) */
69
+ schemaPath?: string;
70
+ /** Project root for resolving paths */
71
+ projectRoot?: string;
72
+ }
73
+ /**
74
+ * Endpoint filter configuration.
75
+ */
76
+ interface EndpointFilter {
77
+ /** Endpoints to include */
78
+ include: string[];
79
+ /** Patterns to exclude */
80
+ exclude: string[];
81
+ }
82
+ /**
83
+ * Result of generating a filter.
84
+ */
85
+ interface GenerateFilterResult {
86
+ success: boolean;
87
+ filter: EndpointFilter;
88
+ warnings?: string[];
89
+ outputPath?: string;
90
+ }
91
+ /**
92
+ * Options for generating a filter.
93
+ */
94
+ interface GenerateFilterOptions {
95
+ /** Path to OpenAPI spec file */
96
+ specPath?: string;
97
+ /** Path to compiled Zod schema module */
98
+ schemaPath?: string;
99
+ /** Entity slugs to include */
100
+ selectedEntities: string[];
101
+ /** Glob patterns to exclude */
102
+ excludePatterns?: string[];
103
+ /** Path to write stackwright.yml */
104
+ outputPath?: string;
105
+ /** Project root */
106
+ projectRoot?: string;
107
+ }
108
+
109
+ /**
110
+ * Discover available entities from Zod schemas or OpenAPI spec.
111
+ *
112
+ * Priority:
113
+ * 1. schemaPath (explicit Zod schemas)
114
+ * 2. specPath (explicit OpenAPI spec)
115
+ * 3. Auto-detect (look for compiled schemas or OpenAPI spec)
116
+ *
117
+ * Pure function: same inputs → same outputs, no side effects.
118
+ */
119
+ declare function listEntities(options?: ListEntitiesOptions): ListEntitiesResult;
120
+
121
+ /**
122
+ * Generates endpoint filter configuration from selected entities.
123
+ *
124
+ * Pure function: same inputs → same outputs.
125
+ *
126
+ * Logic:
127
+ * 1. For each selected entity, include: /entity and /entity/{id}
128
+ * 2. Apply default exclusions (admin, reports, delete)
129
+ * 3. Return filter config
130
+ */
131
+ declare function generateFilter(options: GenerateFilterOptions): GenerateFilterResult;
132
+ /**
133
+ * Discover entities from an OpenAPI spec and generate filter.
134
+ * Single function for the common workflow.
135
+ */
136
+ declare function discoverAndFilter(options: {
137
+ specPath: string;
138
+ selectedEntities: string[];
139
+ excludePatterns?: string[];
140
+ outputPath?: string;
141
+ projectRoot?: string;
142
+ }): GenerateFilterResult;
143
+
144
+ /**
145
+ * CLI plugin registration.
146
+ * Called by the OSS CLI when this package is installed.
147
+ *
148
+ * Usage in OSS CLI:
149
+ * ```ts
150
+ * // In cli-plugin-loader.ts
151
+ * import { registerCommands } from '@stackwright-pro/cli-data-explorer';
152
+ * registerCommands(program);
153
+ * ```
154
+ */
155
+ declare const registerCommands: PluginRegistrar;
156
+
157
+ export { type EndpointFilter, type EntityInfo, type FieldInfo, type GenerateFilterOptions, type GenerateFilterResult, type ListEntitiesOptions, type ListEntitiesResult, registerCommands as default, discoverAndFilter, generateFilter, listEntities, registerCommands };