@constructive-io/graphql-codegen 2.19.0 → 2.20.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.
- package/README.md +1818 -113
- package/__tests__/codegen/input-types-generator.test.d.ts +1 -0
- package/__tests__/codegen/input-types-generator.test.js +635 -0
- package/cli/codegen/barrel.d.ts +27 -0
- package/cli/codegen/barrel.js +163 -0
- package/cli/codegen/client.d.ts +4 -0
- package/cli/codegen/client.js +170 -0
- package/cli/codegen/custom-mutations.d.ts +38 -0
- package/cli/codegen/custom-mutations.js +149 -0
- package/cli/codegen/custom-queries.d.ts +38 -0
- package/cli/codegen/custom-queries.js +358 -0
- package/cli/codegen/filters.d.ts +27 -0
- package/cli/codegen/filters.js +357 -0
- package/cli/codegen/gql-ast.d.ts +41 -0
- package/cli/codegen/gql-ast.js +329 -0
- package/cli/codegen/index.d.ts +71 -0
- package/cli/codegen/index.js +147 -0
- package/cli/codegen/mutations.d.ts +30 -0
- package/cli/codegen/mutations.js +410 -0
- package/cli/codegen/orm/barrel.d.ts +18 -0
- package/cli/codegen/orm/barrel.js +48 -0
- package/cli/codegen/orm/client-generator.d.ts +45 -0
- package/cli/codegen/orm/client-generator.js +646 -0
- package/cli/codegen/orm/custom-ops-generator.d.ts +30 -0
- package/cli/codegen/orm/custom-ops-generator.js +350 -0
- package/cli/codegen/orm/index.d.ts +38 -0
- package/cli/codegen/orm/index.js +88 -0
- package/cli/codegen/orm/input-types-generator.d.ts +21 -0
- package/cli/codegen/orm/input-types-generator.js +705 -0
- package/cli/codegen/orm/input-types-generator.test.d.ts +1 -0
- package/cli/codegen/orm/input-types-generator.test.js +75 -0
- package/cli/codegen/orm/model-generator.d.ts +32 -0
- package/cli/codegen/orm/model-generator.js +264 -0
- package/cli/codegen/orm/query-builder.d.ts +161 -0
- package/cli/codegen/orm/query-builder.js +366 -0
- package/cli/codegen/orm/select-types.d.ts +169 -0
- package/cli/codegen/orm/select-types.js +16 -0
- package/cli/codegen/orm/select-types.test.d.ts +11 -0
- package/cli/codegen/orm/select-types.test.js +22 -0
- package/cli/codegen/queries.d.ts +25 -0
- package/cli/codegen/queries.js +438 -0
- package/cli/codegen/scalars.d.ts +12 -0
- package/cli/codegen/scalars.js +71 -0
- package/cli/codegen/schema-gql-ast.d.ts +51 -0
- package/cli/codegen/schema-gql-ast.js +385 -0
- package/cli/codegen/ts-ast.d.ts +122 -0
- package/cli/codegen/ts-ast.js +280 -0
- package/cli/codegen/type-resolver.d.ts +96 -0
- package/cli/codegen/type-resolver.js +246 -0
- package/cli/codegen/types.d.ts +12 -0
- package/cli/codegen/types.js +69 -0
- package/cli/codegen/utils.d.ts +163 -0
- package/cli/codegen/utils.js +326 -0
- package/cli/commands/generate-orm.d.ts +37 -0
- package/cli/commands/generate-orm.js +195 -0
- package/cli/commands/generate.d.ts +39 -0
- package/cli/commands/generate.js +299 -0
- package/cli/commands/index.d.ts +7 -0
- package/cli/commands/index.js +12 -0
- package/cli/commands/init.d.ts +35 -0
- package/cli/commands/init.js +176 -0
- package/cli/index.d.ts +4 -0
- package/cli/index.js +291 -0
- package/cli/introspect/fetch-meta.d.ts +31 -0
- package/cli/introspect/fetch-meta.js +108 -0
- package/cli/introspect/fetch-schema.d.ts +21 -0
- package/cli/introspect/fetch-schema.js +86 -0
- package/cli/introspect/index.d.ts +8 -0
- package/cli/introspect/index.js +16 -0
- package/cli/introspect/meta-query.d.ts +111 -0
- package/cli/introspect/meta-query.js +191 -0
- package/cli/introspect/schema-query.d.ts +20 -0
- package/cli/introspect/schema-query.js +123 -0
- package/cli/introspect/transform-schema.d.ts +74 -0
- package/cli/introspect/transform-schema.js +269 -0
- package/cli/introspect/transform-schema.test.d.ts +1 -0
- package/cli/introspect/transform-schema.test.js +67 -0
- package/cli/introspect/transform.d.ts +21 -0
- package/cli/introspect/transform.js +216 -0
- package/cli/watch/cache.d.ts +45 -0
- package/cli/watch/cache.js +111 -0
- package/cli/watch/debounce.d.ts +19 -0
- package/cli/watch/debounce.js +89 -0
- package/cli/watch/hash.d.ts +17 -0
- package/cli/watch/hash.js +48 -0
- package/cli/watch/index.d.ts +10 -0
- package/cli/watch/index.js +22 -0
- package/cli/watch/orchestrator.d.ts +63 -0
- package/cli/watch/orchestrator.js +228 -0
- package/cli/watch/poller.d.ts +65 -0
- package/cli/watch/poller.js +203 -0
- package/cli/watch/types.d.ts +67 -0
- package/cli/watch/types.js +5 -0
- package/client/error.d.ts +95 -0
- package/client/error.js +255 -0
- package/client/execute.d.ts +57 -0
- package/client/execute.js +124 -0
- package/client/index.d.ts +6 -0
- package/client/index.js +18 -0
- package/client/typed-document.d.ts +31 -0
- package/client/typed-document.js +44 -0
- package/core/ast.d.ts +10 -0
- package/core/ast.js +593 -0
- package/core/custom-ast.d.ts +35 -0
- package/core/custom-ast.js +204 -0
- package/core/index.d.ts +8 -0
- package/core/index.js +33 -0
- package/core/meta-object/convert.d.ts +65 -0
- package/core/meta-object/convert.js +63 -0
- package/core/meta-object/format.json +93 -0
- package/core/meta-object/index.d.ts +2 -0
- package/core/meta-object/index.js +18 -0
- package/core/meta-object/validate.d.ts +9 -0
- package/core/meta-object/validate.js +34 -0
- package/core/query-builder.d.ts +46 -0
- package/core/query-builder.js +412 -0
- package/core/types.d.ts +139 -0
- package/core/types.js +28 -0
- package/esm/__tests__/codegen/input-types-generator.test.d.ts +1 -0
- package/esm/__tests__/codegen/input-types-generator.test.js +633 -0
- package/esm/cli/codegen/barrel.d.ts +27 -0
- package/esm/cli/codegen/barrel.js +156 -0
- package/esm/cli/codegen/client.d.ts +4 -0
- package/esm/cli/codegen/client.js +167 -0
- package/esm/cli/codegen/custom-mutations.d.ts +38 -0
- package/esm/cli/codegen/custom-mutations.js +145 -0
- package/esm/cli/codegen/custom-queries.d.ts +38 -0
- package/esm/cli/codegen/custom-queries.js +354 -0
- package/esm/cli/codegen/filters.d.ts +27 -0
- package/esm/cli/codegen/filters.js +351 -0
- package/esm/cli/codegen/gql-ast.d.ts +41 -0
- package/esm/cli/codegen/gql-ast.js +288 -0
- package/esm/cli/codegen/index.d.ts +71 -0
- package/esm/cli/codegen/index.js +124 -0
- package/esm/cli/codegen/mutations.d.ts +30 -0
- package/esm/cli/codegen/mutations.js +404 -0
- package/esm/cli/codegen/orm/barrel.d.ts +18 -0
- package/esm/cli/codegen/orm/barrel.js +44 -0
- package/esm/cli/codegen/orm/client-generator.d.ts +45 -0
- package/esm/cli/codegen/orm/client-generator.js +640 -0
- package/esm/cli/codegen/orm/custom-ops-generator.d.ts +30 -0
- package/esm/cli/codegen/orm/custom-ops-generator.js +346 -0
- package/esm/cli/codegen/orm/index.d.ts +38 -0
- package/esm/cli/codegen/orm/index.js +75 -0
- package/esm/cli/codegen/orm/input-types-generator.d.ts +21 -0
- package/esm/cli/codegen/orm/input-types-generator.js +700 -0
- package/esm/cli/codegen/orm/input-types-generator.test.d.ts +1 -0
- package/esm/cli/codegen/orm/input-types-generator.test.js +73 -0
- package/esm/cli/codegen/orm/model-generator.d.ts +32 -0
- package/esm/cli/codegen/orm/model-generator.js +260 -0
- package/esm/cli/codegen/orm/query-builder.d.ts +161 -0
- package/esm/cli/codegen/orm/query-builder.js +353 -0
- package/esm/cli/codegen/orm/select-types.d.ts +169 -0
- package/esm/cli/codegen/orm/select-types.js +15 -0
- package/esm/cli/codegen/orm/select-types.test.d.ts +11 -0
- package/esm/cli/codegen/orm/select-types.test.js +21 -0
- package/esm/cli/codegen/queries.d.ts +25 -0
- package/esm/cli/codegen/queries.js +433 -0
- package/esm/cli/codegen/scalars.d.ts +12 -0
- package/esm/cli/codegen/scalars.js +66 -0
- package/esm/cli/codegen/schema-gql-ast.d.ts +51 -0
- package/esm/cli/codegen/schema-gql-ast.js +343 -0
- package/esm/cli/codegen/ts-ast.d.ts +122 -0
- package/esm/cli/codegen/ts-ast.js +260 -0
- package/esm/cli/codegen/type-resolver.d.ts +96 -0
- package/esm/cli/codegen/type-resolver.js +224 -0
- package/esm/cli/codegen/types.d.ts +12 -0
- package/esm/cli/codegen/types.js +65 -0
- package/esm/cli/codegen/utils.d.ts +163 -0
- package/esm/cli/codegen/utils.js +288 -0
- package/esm/cli/commands/generate-orm.d.ts +37 -0
- package/esm/cli/commands/generate-orm.js +192 -0
- package/esm/cli/commands/generate.d.ts +39 -0
- package/esm/cli/commands/generate.js +262 -0
- package/esm/cli/commands/index.d.ts +7 -0
- package/esm/cli/commands/index.js +5 -0
- package/esm/cli/commands/init.d.ts +35 -0
- package/esm/cli/commands/init.js +138 -0
- package/esm/cli/index.d.ts +4 -0
- package/esm/cli/index.js +256 -0
- package/esm/cli/introspect/fetch-meta.d.ts +31 -0
- package/esm/cli/introspect/fetch-meta.js +104 -0
- package/esm/cli/introspect/fetch-schema.d.ts +21 -0
- package/esm/cli/introspect/fetch-schema.js +83 -0
- package/esm/cli/introspect/index.d.ts +8 -0
- package/esm/cli/introspect/index.js +6 -0
- package/esm/cli/introspect/meta-query.d.ts +111 -0
- package/esm/cli/introspect/meta-query.js +188 -0
- package/esm/cli/introspect/schema-query.d.ts +20 -0
- package/esm/cli/introspect/schema-query.js +120 -0
- package/esm/cli/introspect/transform-schema.d.ts +74 -0
- package/esm/cli/introspect/transform-schema.js +259 -0
- package/esm/cli/introspect/transform-schema.test.d.ts +1 -0
- package/esm/cli/introspect/transform-schema.test.js +65 -0
- package/esm/cli/introspect/transform.d.ts +21 -0
- package/esm/cli/introspect/transform.js +210 -0
- package/esm/cli/watch/cache.d.ts +45 -0
- package/esm/cli/watch/cache.js +73 -0
- package/esm/cli/watch/debounce.d.ts +19 -0
- package/esm/cli/watch/debounce.js +85 -0
- package/esm/cli/watch/hash.d.ts +17 -0
- package/esm/cli/watch/hash.js +43 -0
- package/esm/cli/watch/index.d.ts +10 -0
- package/esm/cli/watch/index.js +8 -0
- package/esm/cli/watch/orchestrator.d.ts +63 -0
- package/esm/cli/watch/orchestrator.js +223 -0
- package/esm/cli/watch/poller.d.ts +65 -0
- package/esm/cli/watch/poller.js +198 -0
- package/esm/cli/watch/types.d.ts +67 -0
- package/esm/cli/watch/types.js +4 -0
- package/esm/client/error.d.ts +95 -0
- package/esm/client/error.js +249 -0
- package/esm/client/execute.d.ts +57 -0
- package/esm/client/execute.js +120 -0
- package/esm/client/index.d.ts +6 -0
- package/esm/client/index.js +6 -0
- package/esm/client/typed-document.d.ts +31 -0
- package/esm/client/typed-document.js +40 -0
- package/esm/core/ast.d.ts +10 -0
- package/esm/core/ast.js +549 -0
- package/esm/core/custom-ast.d.ts +35 -0
- package/esm/core/custom-ast.js +161 -0
- package/esm/core/index.d.ts +8 -0
- package/esm/core/index.js +12 -0
- package/esm/core/meta-object/convert.d.ts +65 -0
- package/esm/core/meta-object/convert.js +60 -0
- package/esm/core/meta-object/format.json +93 -0
- package/esm/core/meta-object/index.d.ts +2 -0
- package/esm/core/meta-object/index.js +2 -0
- package/esm/core/meta-object/validate.d.ts +9 -0
- package/esm/core/meta-object/validate.js +28 -0
- package/esm/core/query-builder.d.ts +46 -0
- package/esm/core/query-builder.js +375 -0
- package/esm/core/types.d.ts +139 -0
- package/esm/core/types.js +24 -0
- package/esm/generators/field-selector.d.ts +30 -0
- package/esm/generators/field-selector.js +355 -0
- package/esm/generators/index.d.ts +6 -0
- package/esm/generators/index.js +9 -0
- package/esm/generators/mutations.d.ts +31 -0
- package/esm/generators/mutations.js +197 -0
- package/esm/generators/select.d.ts +50 -0
- package/esm/generators/select.js +636 -0
- package/esm/index.d.ts +12 -0
- package/esm/index.js +17 -3
- package/esm/react/index.d.ts +5 -0
- package/esm/react/index.js +6 -0
- package/esm/types/config.d.ts +199 -0
- package/esm/types/config.js +106 -0
- package/esm/types/index.d.ts +9 -0
- package/esm/types/index.js +4 -0
- package/esm/types/introspection.d.ts +121 -0
- package/esm/types/introspection.js +54 -0
- package/esm/types/mutation.d.ts +45 -0
- package/esm/types/mutation.js +4 -0
- package/esm/types/query.d.ts +82 -0
- package/esm/types/query.js +4 -0
- package/esm/types/schema.d.ts +253 -0
- package/esm/types/schema.js +5 -0
- package/esm/types/selection.d.ts +43 -0
- package/esm/types/selection.js +4 -0
- package/esm/utils/index.d.ts +4 -0
- package/esm/utils/index.js +4 -0
- package/generators/field-selector.d.ts +30 -0
- package/generators/field-selector.js +361 -0
- package/generators/index.d.ts +6 -0
- package/generators/index.js +27 -0
- package/generators/mutations.d.ts +31 -0
- package/generators/mutations.js +235 -0
- package/generators/select.d.ts +50 -0
- package/generators/select.js +679 -0
- package/index.d.ts +12 -3
- package/index.js +19 -3
- package/package.json +59 -38
- package/react/index.d.ts +5 -0
- package/react/index.js +9 -0
- package/types/config.d.ts +199 -0
- package/types/config.js +111 -0
- package/types/index.d.ts +9 -0
- package/types/index.js +10 -0
- package/types/introspection.d.ts +121 -0
- package/types/introspection.js +62 -0
- package/types/mutation.d.ts +45 -0
- package/types/mutation.js +5 -0
- package/types/query.d.ts +82 -0
- package/types/query.js +5 -0
- package/types/schema.d.ts +253 -0
- package/types/schema.js +6 -0
- package/types/selection.d.ts +43 -0
- package/types/selection.js +5 -0
- package/utils/index.d.ts +4 -0
- package/utils/index.js +7 -0
- package/codegen.d.ts +0 -13
- package/codegen.js +0 -293
- package/esm/codegen.js +0 -253
- package/esm/gql.js +0 -939
- package/esm/options.js +0 -27
- package/gql.d.ts +0 -188
- package/gql.js +0 -992
- package/options.d.ts +0 -45
- package/options.js +0 -31
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Generate ORM command - generates Prisma-like ORM client
|
|
4
|
+
*
|
|
5
|
+
* This command:
|
|
6
|
+
* 1. Fetches _meta query for table-based CRUD operations
|
|
7
|
+
* 2. Fetches __schema introspection for custom operations
|
|
8
|
+
* 3. Generates a Prisma-like ORM client with fluent API
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.generateOrmCommand = generateOrmCommand;
|
|
12
|
+
const config_1 = require("../../types/config");
|
|
13
|
+
const fetch_meta_1 = require("../introspect/fetch-meta");
|
|
14
|
+
const fetch_schema_1 = require("../introspect/fetch-schema");
|
|
15
|
+
const transform_1 = require("../introspect/transform");
|
|
16
|
+
const transform_schema_1 = require("../introspect/transform-schema");
|
|
17
|
+
const init_1 = require("./init");
|
|
18
|
+
const generate_1 = require("./generate");
|
|
19
|
+
const orm_1 = require("../codegen/orm");
|
|
20
|
+
/**
|
|
21
|
+
* Execute the generate-orm command
|
|
22
|
+
*/
|
|
23
|
+
async function generateOrmCommand(options = {}) {
|
|
24
|
+
const log = options.verbose ? console.log : () => { };
|
|
25
|
+
// 1. Load config
|
|
26
|
+
log('Loading configuration...');
|
|
27
|
+
const configResult = await loadConfig(options);
|
|
28
|
+
if (!configResult.success) {
|
|
29
|
+
return {
|
|
30
|
+
success: false,
|
|
31
|
+
message: configResult.error,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
const config = configResult.config;
|
|
35
|
+
// Use ORM output directory if specified, otherwise default
|
|
36
|
+
const outputDir = options.output || config.orm?.output || './generated/orm';
|
|
37
|
+
log(` Endpoint: ${config.endpoint}`);
|
|
38
|
+
log(` Output: ${outputDir}`);
|
|
39
|
+
// 2. Validate endpoint
|
|
40
|
+
const endpointValidation = (0, fetch_meta_1.validateEndpoint)(config.endpoint);
|
|
41
|
+
if (!endpointValidation.valid) {
|
|
42
|
+
return {
|
|
43
|
+
success: false,
|
|
44
|
+
message: `Invalid endpoint: ${endpointValidation.error}`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
// Build authorization header if provided
|
|
48
|
+
const authHeader = options.authorization || config.headers['Authorization'];
|
|
49
|
+
// 3. Fetch _meta for table-based operations
|
|
50
|
+
log('Fetching schema metadata (_meta)...');
|
|
51
|
+
const metaResult = await (0, fetch_meta_1.fetchMeta)({
|
|
52
|
+
endpoint: config.endpoint,
|
|
53
|
+
authorization: authHeader,
|
|
54
|
+
headers: config.headers,
|
|
55
|
+
timeout: 30000,
|
|
56
|
+
});
|
|
57
|
+
if (!metaResult.success) {
|
|
58
|
+
return {
|
|
59
|
+
success: false,
|
|
60
|
+
message: `Failed to fetch _meta: ${metaResult.error}`,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
// 4. Transform to CleanTable[]
|
|
64
|
+
log('Transforming table schema...');
|
|
65
|
+
let tables = (0, transform_1.transformMetaToCleanTables)(metaResult.data);
|
|
66
|
+
log(` Found ${tables.length} tables`);
|
|
67
|
+
// 5. Filter tables
|
|
68
|
+
tables = (0, transform_1.filterTables)(tables, config.tables.include, config.tables.exclude);
|
|
69
|
+
log(` After filtering: ${tables.length} tables`);
|
|
70
|
+
if (tables.length === 0) {
|
|
71
|
+
return {
|
|
72
|
+
success: false,
|
|
73
|
+
message: 'No tables found after filtering. Check your include/exclude patterns.',
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
// Get table operation names for filtering custom operations
|
|
77
|
+
const tableOperationNames = (0, transform_schema_1.getTableOperationNames)(tables);
|
|
78
|
+
// 6. Fetch __schema for custom operations (unless skipped)
|
|
79
|
+
let customQueries = [];
|
|
80
|
+
let customMutations = [];
|
|
81
|
+
let customOperationsData;
|
|
82
|
+
if (!options.skipCustomOperations) {
|
|
83
|
+
log('Fetching schema introspection (__schema)...');
|
|
84
|
+
const schemaResult = await (0, fetch_schema_1.fetchSchema)({
|
|
85
|
+
endpoint: config.endpoint,
|
|
86
|
+
authorization: authHeader,
|
|
87
|
+
headers: config.headers,
|
|
88
|
+
timeout: 30000,
|
|
89
|
+
});
|
|
90
|
+
if (schemaResult.success && schemaResult.data) {
|
|
91
|
+
log('Transforming custom operations...');
|
|
92
|
+
// Transform to CleanOperation[]
|
|
93
|
+
const { queries: allQueries, mutations: allMutations, typeRegistry } = (0, transform_schema_1.transformSchemaToOperations)(schemaResult.data);
|
|
94
|
+
log(` Found ${allQueries.length} queries and ${allMutations.length} mutations total`);
|
|
95
|
+
// Filter by config include/exclude
|
|
96
|
+
const filteredQueries = (0, transform_schema_1.filterOperations)(allQueries, config.queries.include, config.queries.exclude);
|
|
97
|
+
const filteredMutations = (0, transform_schema_1.filterOperations)(allMutations, config.mutations.include, config.mutations.exclude);
|
|
98
|
+
log(` After config filtering: ${filteredQueries.length} queries, ${filteredMutations.length} mutations`);
|
|
99
|
+
// Remove table operations (already handled by table generators)
|
|
100
|
+
const customQueriesOps = (0, transform_schema_1.getCustomOperations)(filteredQueries, tableOperationNames);
|
|
101
|
+
const customMutationsOps = (0, transform_schema_1.getCustomOperations)(filteredMutations, tableOperationNames);
|
|
102
|
+
log(` Custom operations: ${customQueriesOps.length} queries, ${customMutationsOps.length} mutations`);
|
|
103
|
+
customQueries = customQueriesOps.map((q) => q.name);
|
|
104
|
+
customMutations = customMutationsOps.map((m) => m.name);
|
|
105
|
+
customOperationsData = {
|
|
106
|
+
queries: customQueriesOps,
|
|
107
|
+
mutations: customMutationsOps,
|
|
108
|
+
typeRegistry,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
log(` Warning: Could not fetch __schema: ${schemaResult.error}`);
|
|
113
|
+
log(' Continuing with table-only generation...');
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
// 7. Generate ORM code
|
|
117
|
+
log('Generating ORM client...');
|
|
118
|
+
const { files: generatedFiles, stats } = (0, orm_1.generateOrm)({
|
|
119
|
+
tables,
|
|
120
|
+
customOperations: customOperationsData,
|
|
121
|
+
config,
|
|
122
|
+
});
|
|
123
|
+
log(` Generated ${stats.tables} table models`);
|
|
124
|
+
log(` Generated ${stats.customQueries} custom query operations`);
|
|
125
|
+
log(` Generated ${stats.customMutations} custom mutation operations`);
|
|
126
|
+
log(` Total files: ${stats.totalFiles}`);
|
|
127
|
+
if (options.dryRun) {
|
|
128
|
+
return {
|
|
129
|
+
success: true,
|
|
130
|
+
message: `Dry run complete. Would generate ${generatedFiles.length} files for ${tables.length} tables and ${customQueries.length + customMutations.length} custom operations.`,
|
|
131
|
+
tables: tables.map((t) => t.name),
|
|
132
|
+
customQueries,
|
|
133
|
+
customMutations,
|
|
134
|
+
filesWritten: generatedFiles.map((f) => f.path),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
// 8. Write files
|
|
138
|
+
log('Writing files...');
|
|
139
|
+
const writeResult = await (0, generate_1.writeGeneratedFiles)(generatedFiles, outputDir, ['models', 'query', 'mutation']);
|
|
140
|
+
if (!writeResult.success) {
|
|
141
|
+
return {
|
|
142
|
+
success: false,
|
|
143
|
+
message: `Failed to write files: ${writeResult.errors?.join(', ')}`,
|
|
144
|
+
errors: writeResult.errors,
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
const totalOps = customQueries.length + customMutations.length;
|
|
148
|
+
const customOpsMsg = totalOps > 0 ? ` and ${totalOps} custom operations` : '';
|
|
149
|
+
return {
|
|
150
|
+
success: true,
|
|
151
|
+
message: `Generated ORM client for ${tables.length} tables${customOpsMsg}. Files written to ${outputDir}`,
|
|
152
|
+
tables: tables.map((t) => t.name),
|
|
153
|
+
customQueries,
|
|
154
|
+
customMutations,
|
|
155
|
+
filesWritten: writeResult.filesWritten,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
async function loadConfig(options) {
|
|
159
|
+
// Find config file
|
|
160
|
+
let configPath = options.config;
|
|
161
|
+
if (!configPath) {
|
|
162
|
+
configPath = (0, init_1.findConfigFile)() ?? undefined;
|
|
163
|
+
}
|
|
164
|
+
let baseConfig = {};
|
|
165
|
+
if (configPath) {
|
|
166
|
+
const loadResult = await (0, init_1.loadConfigFile)(configPath);
|
|
167
|
+
if (!loadResult.success) {
|
|
168
|
+
return { success: false, error: loadResult.error };
|
|
169
|
+
}
|
|
170
|
+
baseConfig = loadResult.config;
|
|
171
|
+
}
|
|
172
|
+
// Override with CLI options
|
|
173
|
+
const mergedConfig = {
|
|
174
|
+
endpoint: options.endpoint || baseConfig.endpoint || '',
|
|
175
|
+
output: options.output || baseConfig.output,
|
|
176
|
+
headers: baseConfig.headers,
|
|
177
|
+
tables: baseConfig.tables,
|
|
178
|
+
queries: baseConfig.queries,
|
|
179
|
+
mutations: baseConfig.mutations,
|
|
180
|
+
excludeFields: baseConfig.excludeFields,
|
|
181
|
+
hooks: baseConfig.hooks,
|
|
182
|
+
postgraphile: baseConfig.postgraphile,
|
|
183
|
+
codegen: baseConfig.codegen,
|
|
184
|
+
orm: baseConfig.orm,
|
|
185
|
+
};
|
|
186
|
+
if (!mergedConfig.endpoint) {
|
|
187
|
+
return {
|
|
188
|
+
success: false,
|
|
189
|
+
error: 'No endpoint specified. Use --endpoint or create a config file with "graphql-codegen init".',
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
// Resolve with defaults
|
|
193
|
+
const config = (0, config_1.resolveConfig)(mergedConfig);
|
|
194
|
+
return { success: true, config };
|
|
195
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export interface GenerateOptions {
|
|
2
|
+
/** Path to config file */
|
|
3
|
+
config?: string;
|
|
4
|
+
/** GraphQL endpoint URL (overrides config) */
|
|
5
|
+
endpoint?: string;
|
|
6
|
+
/** Output directory (overrides config) */
|
|
7
|
+
output?: string;
|
|
8
|
+
/** Authorization header */
|
|
9
|
+
authorization?: string;
|
|
10
|
+
/** Verbose output */
|
|
11
|
+
verbose?: boolean;
|
|
12
|
+
/** Dry run - don't write files */
|
|
13
|
+
dryRun?: boolean;
|
|
14
|
+
/** Skip custom operations (only generate table CRUD) */
|
|
15
|
+
skipCustomOperations?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export interface GenerateResult {
|
|
18
|
+
success: boolean;
|
|
19
|
+
message: string;
|
|
20
|
+
tables?: string[];
|
|
21
|
+
customQueries?: string[];
|
|
22
|
+
customMutations?: string[];
|
|
23
|
+
filesWritten?: string[];
|
|
24
|
+
errors?: string[];
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Execute the generate command
|
|
28
|
+
*/
|
|
29
|
+
export declare function generateCommand(options?: GenerateOptions): Promise<GenerateResult>;
|
|
30
|
+
export interface GeneratedFile {
|
|
31
|
+
path: string;
|
|
32
|
+
content: string;
|
|
33
|
+
}
|
|
34
|
+
export interface WriteResult {
|
|
35
|
+
success: boolean;
|
|
36
|
+
filesWritten?: string[];
|
|
37
|
+
errors?: string[];
|
|
38
|
+
}
|
|
39
|
+
export declare function writeGeneratedFiles(files: GeneratedFile[], outputDir: string, subdirs: string[]): Promise<WriteResult>;
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.generateCommand = generateCommand;
|
|
37
|
+
exports.writeGeneratedFiles = writeGeneratedFiles;
|
|
38
|
+
/**
|
|
39
|
+
* Generate command - introspects endpoint and generates SDK
|
|
40
|
+
*
|
|
41
|
+
* This command:
|
|
42
|
+
* 1. Fetches _meta query for table-based CRUD operations
|
|
43
|
+
* 2. Fetches __schema introspection for ALL operations
|
|
44
|
+
* 3. Filters out table operations from custom operations to avoid duplicates
|
|
45
|
+
* 4. Generates hooks for both table CRUD and custom operations
|
|
46
|
+
*/
|
|
47
|
+
const fs = __importStar(require("node:fs"));
|
|
48
|
+
const path = __importStar(require("node:path"));
|
|
49
|
+
const prettier = __importStar(require("prettier"));
|
|
50
|
+
const config_1 = require("../../types/config");
|
|
51
|
+
const fetch_meta_1 = require("../introspect/fetch-meta");
|
|
52
|
+
const fetch_schema_1 = require("../introspect/fetch-schema");
|
|
53
|
+
const transform_1 = require("../introspect/transform");
|
|
54
|
+
const transform_schema_1 = require("../introspect/transform-schema");
|
|
55
|
+
const init_1 = require("./init");
|
|
56
|
+
const codegen_1 = require("../codegen");
|
|
57
|
+
/**
|
|
58
|
+
* Execute the generate command
|
|
59
|
+
*/
|
|
60
|
+
async function generateCommand(options = {}) {
|
|
61
|
+
const log = options.verbose ? console.log : () => { };
|
|
62
|
+
// 1. Load config
|
|
63
|
+
log('Loading configuration...');
|
|
64
|
+
const configResult = await loadConfig(options);
|
|
65
|
+
if (!configResult.success) {
|
|
66
|
+
return {
|
|
67
|
+
success: false,
|
|
68
|
+
message: configResult.error,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const config = configResult.config;
|
|
72
|
+
log(` Endpoint: ${config.endpoint}`);
|
|
73
|
+
log(` Output: ${config.output}`);
|
|
74
|
+
// 2. Validate endpoint
|
|
75
|
+
const endpointValidation = (0, fetch_meta_1.validateEndpoint)(config.endpoint);
|
|
76
|
+
if (!endpointValidation.valid) {
|
|
77
|
+
return {
|
|
78
|
+
success: false,
|
|
79
|
+
message: `Invalid endpoint: ${endpointValidation.error}`,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
// Build authorization header if provided
|
|
83
|
+
const authHeader = options.authorization || config.headers['Authorization'];
|
|
84
|
+
// 3. Fetch _meta for table-based operations
|
|
85
|
+
log('Fetching schema metadata (_meta)...');
|
|
86
|
+
const metaResult = await (0, fetch_meta_1.fetchMeta)({
|
|
87
|
+
endpoint: config.endpoint,
|
|
88
|
+
authorization: authHeader,
|
|
89
|
+
headers: config.headers,
|
|
90
|
+
timeout: 30000,
|
|
91
|
+
});
|
|
92
|
+
if (!metaResult.success) {
|
|
93
|
+
return {
|
|
94
|
+
success: false,
|
|
95
|
+
message: `Failed to fetch _meta: ${metaResult.error}`,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// 4. Transform to CleanTable[]
|
|
99
|
+
log('Transforming table schema...');
|
|
100
|
+
let tables = (0, transform_1.transformMetaToCleanTables)(metaResult.data);
|
|
101
|
+
log(` Found ${tables.length} tables`);
|
|
102
|
+
// 5. Filter tables
|
|
103
|
+
tables = (0, transform_1.filterTables)(tables, config.tables.include, config.tables.exclude);
|
|
104
|
+
log(` After filtering: ${tables.length} tables`);
|
|
105
|
+
if (tables.length === 0) {
|
|
106
|
+
return {
|
|
107
|
+
success: false,
|
|
108
|
+
message: 'No tables found after filtering. Check your include/exclude patterns.',
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// Get table operation names for filtering custom operations
|
|
112
|
+
const tableOperationNames = (0, transform_schema_1.getTableOperationNames)(tables);
|
|
113
|
+
// 6. Fetch __schema for custom operations (unless skipped)
|
|
114
|
+
let customQueries = [];
|
|
115
|
+
let customMutations = [];
|
|
116
|
+
let customOperationsData;
|
|
117
|
+
if (!options.skipCustomOperations) {
|
|
118
|
+
log('Fetching schema introspection (__schema)...');
|
|
119
|
+
const schemaResult = await (0, fetch_schema_1.fetchSchema)({
|
|
120
|
+
endpoint: config.endpoint,
|
|
121
|
+
authorization: authHeader,
|
|
122
|
+
headers: config.headers,
|
|
123
|
+
timeout: 30000,
|
|
124
|
+
});
|
|
125
|
+
if (schemaResult.success && schemaResult.data) {
|
|
126
|
+
log('Transforming custom operations...');
|
|
127
|
+
// Transform to CleanOperation[]
|
|
128
|
+
const { queries: allQueries, mutations: allMutations, typeRegistry } = (0, transform_schema_1.transformSchemaToOperations)(schemaResult.data);
|
|
129
|
+
log(` Found ${allQueries.length} queries and ${allMutations.length} mutations total`);
|
|
130
|
+
// Filter by config include/exclude
|
|
131
|
+
const filteredQueries = (0, transform_schema_1.filterOperations)(allQueries, config.queries.include, config.queries.exclude);
|
|
132
|
+
const filteredMutations = (0, transform_schema_1.filterOperations)(allMutations, config.mutations.include, config.mutations.exclude);
|
|
133
|
+
log(` After config filtering: ${filteredQueries.length} queries, ${filteredMutations.length} mutations`);
|
|
134
|
+
// Remove table operations (already handled by table generators)
|
|
135
|
+
const customQueriesOps = (0, transform_schema_1.getCustomOperations)(filteredQueries, tableOperationNames);
|
|
136
|
+
const customMutationsOps = (0, transform_schema_1.getCustomOperations)(filteredMutations, tableOperationNames);
|
|
137
|
+
log(` Custom operations: ${customQueriesOps.length} queries, ${customMutationsOps.length} mutations`);
|
|
138
|
+
customQueries = customQueriesOps.map((q) => q.name);
|
|
139
|
+
customMutations = customMutationsOps.map((m) => m.name);
|
|
140
|
+
customOperationsData = {
|
|
141
|
+
queries: customQueriesOps,
|
|
142
|
+
mutations: customMutationsOps,
|
|
143
|
+
typeRegistry,
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
log(` Warning: Could not fetch __schema: ${schemaResult.error}`);
|
|
148
|
+
log(' Continuing with table-only generation...');
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
// 7. Generate code
|
|
152
|
+
log('Generating code...');
|
|
153
|
+
const { files: generatedFiles, stats } = (0, codegen_1.generate)({
|
|
154
|
+
tables,
|
|
155
|
+
customOperations: customOperationsData,
|
|
156
|
+
config,
|
|
157
|
+
});
|
|
158
|
+
log(` Generated ${stats.queryHooks} table query hooks`);
|
|
159
|
+
log(` Generated ${stats.mutationHooks} table mutation hooks`);
|
|
160
|
+
log(` Generated ${stats.customQueryHooks} custom query hooks`);
|
|
161
|
+
log(` Generated ${stats.customMutationHooks} custom mutation hooks`);
|
|
162
|
+
log(` Total files: ${stats.totalFiles}`);
|
|
163
|
+
if (options.dryRun) {
|
|
164
|
+
return {
|
|
165
|
+
success: true,
|
|
166
|
+
message: `Dry run complete. Would generate ${generatedFiles.length} files for ${tables.length} tables and ${customQueries.length + customMutations.length} custom operations.`,
|
|
167
|
+
tables: tables.map((t) => t.name),
|
|
168
|
+
customQueries,
|
|
169
|
+
customMutations,
|
|
170
|
+
filesWritten: generatedFiles.map((f) => f.path),
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// 8. Write files
|
|
174
|
+
log('Writing files...');
|
|
175
|
+
const writeResult = await writeGeneratedFiles(generatedFiles, config.output, ['queries', 'mutations']);
|
|
176
|
+
if (!writeResult.success) {
|
|
177
|
+
return {
|
|
178
|
+
success: false,
|
|
179
|
+
message: `Failed to write files: ${writeResult.errors?.join(', ')}`,
|
|
180
|
+
errors: writeResult.errors,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
const totalOps = customQueries.length + customMutations.length;
|
|
184
|
+
const customOpsMsg = totalOps > 0 ? ` and ${totalOps} custom operations` : '';
|
|
185
|
+
return {
|
|
186
|
+
success: true,
|
|
187
|
+
message: `Generated SDK for ${tables.length} tables${customOpsMsg}. Files written to ${config.output}`,
|
|
188
|
+
tables: tables.map((t) => t.name),
|
|
189
|
+
customQueries,
|
|
190
|
+
customMutations,
|
|
191
|
+
filesWritten: writeResult.filesWritten,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
async function loadConfig(options) {
|
|
195
|
+
// Find config file
|
|
196
|
+
let configPath = options.config;
|
|
197
|
+
if (!configPath) {
|
|
198
|
+
configPath = (0, init_1.findConfigFile)() ?? undefined;
|
|
199
|
+
}
|
|
200
|
+
let baseConfig = {};
|
|
201
|
+
if (configPath) {
|
|
202
|
+
const loadResult = await (0, init_1.loadConfigFile)(configPath);
|
|
203
|
+
if (!loadResult.success) {
|
|
204
|
+
return { success: false, error: loadResult.error };
|
|
205
|
+
}
|
|
206
|
+
baseConfig = loadResult.config;
|
|
207
|
+
}
|
|
208
|
+
// Override with CLI options
|
|
209
|
+
const mergedConfig = {
|
|
210
|
+
endpoint: options.endpoint || baseConfig.endpoint || '',
|
|
211
|
+
output: options.output || baseConfig.output,
|
|
212
|
+
headers: baseConfig.headers,
|
|
213
|
+
tables: baseConfig.tables,
|
|
214
|
+
queries: baseConfig.queries,
|
|
215
|
+
mutations: baseConfig.mutations,
|
|
216
|
+
excludeFields: baseConfig.excludeFields,
|
|
217
|
+
hooks: baseConfig.hooks,
|
|
218
|
+
postgraphile: baseConfig.postgraphile,
|
|
219
|
+
codegen: baseConfig.codegen,
|
|
220
|
+
};
|
|
221
|
+
if (!mergedConfig.endpoint) {
|
|
222
|
+
return {
|
|
223
|
+
success: false,
|
|
224
|
+
error: 'No endpoint specified. Use --endpoint or create a config file with "graphql-codegen init".',
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
// Resolve with defaults
|
|
228
|
+
const config = (0, config_1.resolveConfig)(mergedConfig);
|
|
229
|
+
return { success: true, config };
|
|
230
|
+
}
|
|
231
|
+
async function writeGeneratedFiles(files, outputDir, subdirs) {
|
|
232
|
+
const errors = [];
|
|
233
|
+
const written = [];
|
|
234
|
+
// Ensure output directory exists
|
|
235
|
+
try {
|
|
236
|
+
fs.mkdirSync(outputDir, { recursive: true });
|
|
237
|
+
}
|
|
238
|
+
catch (err) {
|
|
239
|
+
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
240
|
+
return {
|
|
241
|
+
success: false,
|
|
242
|
+
errors: [`Failed to create output directory: ${message}`],
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
// Create subdirectories
|
|
246
|
+
for (const subdir of subdirs) {
|
|
247
|
+
const subdirPath = path.join(outputDir, subdir);
|
|
248
|
+
try {
|
|
249
|
+
fs.mkdirSync(subdirPath, { recursive: true });
|
|
250
|
+
}
|
|
251
|
+
catch (err) {
|
|
252
|
+
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
253
|
+
errors.push(`Failed to create directory ${subdirPath}: ${message}`);
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
if (errors.length > 0) {
|
|
257
|
+
return { success: false, errors };
|
|
258
|
+
}
|
|
259
|
+
for (const file of files) {
|
|
260
|
+
const filePath = path.join(outputDir, file.path);
|
|
261
|
+
// Ensure parent directory exists
|
|
262
|
+
const parentDir = path.dirname(filePath);
|
|
263
|
+
try {
|
|
264
|
+
fs.mkdirSync(parentDir, { recursive: true });
|
|
265
|
+
}
|
|
266
|
+
catch {
|
|
267
|
+
// Ignore if already exists
|
|
268
|
+
}
|
|
269
|
+
try {
|
|
270
|
+
// Format with prettier
|
|
271
|
+
const formattedContent = await formatCode(file.content);
|
|
272
|
+
fs.writeFileSync(filePath, formattedContent, 'utf-8');
|
|
273
|
+
written.push(filePath);
|
|
274
|
+
}
|
|
275
|
+
catch (err) {
|
|
276
|
+
const message = err instanceof Error ? err.message : 'Unknown error';
|
|
277
|
+
errors.push(`Failed to write ${filePath}: ${message}`);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
return {
|
|
281
|
+
success: errors.length === 0,
|
|
282
|
+
filesWritten: written,
|
|
283
|
+
errors: errors.length > 0 ? errors : undefined,
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
async function formatCode(code) {
|
|
287
|
+
try {
|
|
288
|
+
return await prettier.format(code, {
|
|
289
|
+
parser: 'typescript',
|
|
290
|
+
singleQuote: true,
|
|
291
|
+
trailingComma: 'es5',
|
|
292
|
+
tabWidth: 2,
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
catch {
|
|
296
|
+
// If prettier fails, return unformatted code
|
|
297
|
+
return code;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI commands exports
|
|
3
|
+
*/
|
|
4
|
+
export { initCommand, findConfigFile, loadConfigFile } from './init';
|
|
5
|
+
export type { InitOptions, InitResult } from './init';
|
|
6
|
+
export { generateCommand } from './generate';
|
|
7
|
+
export type { GenerateOptions, GenerateResult } from './generate';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* CLI commands exports
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.generateCommand = exports.loadConfigFile = exports.findConfigFile = exports.initCommand = void 0;
|
|
7
|
+
var init_1 = require("./init");
|
|
8
|
+
Object.defineProperty(exports, "initCommand", { enumerable: true, get: function () { return init_1.initCommand; } });
|
|
9
|
+
Object.defineProperty(exports, "findConfigFile", { enumerable: true, get: function () { return init_1.findConfigFile; } });
|
|
10
|
+
Object.defineProperty(exports, "loadConfigFile", { enumerable: true, get: function () { return init_1.loadConfigFile; } });
|
|
11
|
+
var generate_1 = require("./generate");
|
|
12
|
+
Object.defineProperty(exports, "generateCommand", { enumerable: true, get: function () { return generate_1.generateCommand; } });
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export interface InitOptions {
|
|
2
|
+
/** Target directory for the config file */
|
|
3
|
+
directory?: string;
|
|
4
|
+
/** Force overwrite existing config */
|
|
5
|
+
force?: boolean;
|
|
6
|
+
/** GraphQL endpoint URL to pre-populate */
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
/** Output directory to pre-populate */
|
|
9
|
+
output?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface InitResult {
|
|
12
|
+
success: boolean;
|
|
13
|
+
message: string;
|
|
14
|
+
configPath?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Execute the init command
|
|
18
|
+
*/
|
|
19
|
+
export declare function initCommand(options?: InitOptions): Promise<InitResult>;
|
|
20
|
+
/**
|
|
21
|
+
* Find the nearest config file by walking up directories
|
|
22
|
+
*/
|
|
23
|
+
export declare function findConfigFile(startDir?: string): string | null;
|
|
24
|
+
/**
|
|
25
|
+
* Load and validate a config file
|
|
26
|
+
*
|
|
27
|
+
* Uses jiti to support TypeScript config files (.ts) in addition to
|
|
28
|
+
* JavaScript (.js, .mjs, .cjs) without requiring the user to have
|
|
29
|
+
* tsx or ts-node installed.
|
|
30
|
+
*/
|
|
31
|
+
export declare function loadConfigFile(configPath: string): Promise<{
|
|
32
|
+
success: boolean;
|
|
33
|
+
config?: any;
|
|
34
|
+
error?: string;
|
|
35
|
+
}>;
|