api-farmer 0.1.2 → 0.1.3
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/dist/{chunk-FOIQWD3Q.js → chunk-RIXLRGPZ.js} +12 -6
- package/dist/cli.cjs +12 -6
- package/dist/cli.js +1 -1
- package/dist/{generate-K6NGTXOH.js → generate-4J5VPBTS.js} +1 -1
- package/dist/index.cjs +12 -6
- package/dist/index.d.cts +7 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -146,8 +146,8 @@ function createTransformer() {
|
|
|
146
146
|
|
|
147
147
|
// src/generate.ts
|
|
148
148
|
function transformPayloads(pathItems, options) {
|
|
149
|
-
const { transformer, path, fullPath, base, uncountableNouns, validateStatus } = options;
|
|
150
|
-
return Object.entries(pathItems).filter(([key]) => SUPPORTED_HTTP_METHODS.includes(key)).reduce((payloads, [method, operation]) => {
|
|
149
|
+
const { transformer, path, fullPath, base, uncountableNouns, validateStatus, excludeDeprecated } = options;
|
|
150
|
+
return Object.entries(pathItems).filter(([key]) => SUPPORTED_HTTP_METHODS.includes(key)).filter(([, operation]) => !(excludeDeprecated && operation.deprecated)).reduce((payloads, [method, operation]) => {
|
|
151
151
|
const url = transformer.url({ path, base, fullPath });
|
|
152
152
|
const args = { path, base, fullPath, url, method, uncountableNouns, operation };
|
|
153
153
|
const entity = transformer.entity(args);
|
|
@@ -192,7 +192,7 @@ function transformPayloads(pathItems, options) {
|
|
|
192
192
|
}, []);
|
|
193
193
|
}
|
|
194
194
|
function partitionApiModules(schema, options) {
|
|
195
|
-
const { base, transformer, uncountableNouns, validateStatus } = options;
|
|
195
|
+
const { base, transformer, uncountableNouns, validateStatus, excludeDeprecated } = options;
|
|
196
196
|
const schemaPaths = schema.paths ?? {};
|
|
197
197
|
const schemaPathKeys = base ? Object.keys(schemaPaths).map((key) => key.replace(base, "")) : Object.keys(schemaPaths);
|
|
198
198
|
const keyToPaths = groupBy(schemaPathKeys, (key) => key.split("/")[1]);
|
|
@@ -207,7 +207,8 @@ function partitionApiModules(schema, options) {
|
|
|
207
207
|
fullPath,
|
|
208
208
|
transformer,
|
|
209
209
|
uncountableNouns,
|
|
210
|
-
validateStatus
|
|
210
|
+
validateStatus,
|
|
211
|
+
excludeDeprecated
|
|
211
212
|
})
|
|
212
213
|
);
|
|
213
214
|
return payloads2;
|
|
@@ -284,7 +285,8 @@ async function generate(userOptions = {}) {
|
|
|
284
285
|
validateStatus = (status) => status >= 200 && status < 300,
|
|
285
286
|
transformer = {},
|
|
286
287
|
uncountableNouns = [],
|
|
287
|
-
openapiTsOptions = {}
|
|
288
|
+
openapiTsOptions = {},
|
|
289
|
+
excludeDeprecated = false
|
|
288
290
|
} = options;
|
|
289
291
|
const mergedTransformer = { ...createTransformer(), ...transformer };
|
|
290
292
|
const schema = await readSchema(input);
|
|
@@ -293,6 +295,9 @@ async function generate(userOptions = {}) {
|
|
|
293
295
|
logger.info(`Cleaned output directory: ${resolve(CWD, output)}`);
|
|
294
296
|
}
|
|
295
297
|
logger.info("Generating API modules...");
|
|
298
|
+
if (openapiTsOptions.excludeDeprecated === void 0) {
|
|
299
|
+
openapiTsOptions.excludeDeprecated = excludeDeprecated;
|
|
300
|
+
}
|
|
296
301
|
if (ts2) {
|
|
297
302
|
await generateTypes(schema, output, typesFilename, openapiTsOptions);
|
|
298
303
|
}
|
|
@@ -300,7 +305,8 @@ async function generate(userOptions = {}) {
|
|
|
300
305
|
base,
|
|
301
306
|
uncountableNouns,
|
|
302
307
|
transformer: mergedTransformer,
|
|
303
|
-
validateStatus
|
|
308
|
+
validateStatus,
|
|
309
|
+
excludeDeprecated
|
|
304
310
|
});
|
|
305
311
|
await renderApiModules(apiModules, { output, typesFilename, ts: ts2, typesOnly, overrides, preset });
|
|
306
312
|
logger.success("Done");
|
package/dist/cli.cjs
CHANGED
|
@@ -273,8 +273,8 @@ __export(generate_exports, {
|
|
|
273
273
|
transformPayloads: () => transformPayloads
|
|
274
274
|
});
|
|
275
275
|
function transformPayloads(pathItems, options) {
|
|
276
|
-
const { transformer, path, fullPath, base, uncountableNouns, validateStatus } = options;
|
|
277
|
-
return Object.entries(pathItems).filter(([key]) => SUPPORTED_HTTP_METHODS.includes(key)).reduce((payloads, [method, operation]) => {
|
|
276
|
+
const { transformer, path, fullPath, base, uncountableNouns, validateStatus, excludeDeprecated } = options;
|
|
277
|
+
return Object.entries(pathItems).filter(([key]) => SUPPORTED_HTTP_METHODS.includes(key)).filter(([, operation]) => !(excludeDeprecated && operation.deprecated)).reduce((payloads, [method, operation]) => {
|
|
278
278
|
const url = transformer.url({ path, base, fullPath });
|
|
279
279
|
const args = { path, base, fullPath, url, method, uncountableNouns, operation };
|
|
280
280
|
const entity = transformer.entity(args);
|
|
@@ -319,7 +319,7 @@ function transformPayloads(pathItems, options) {
|
|
|
319
319
|
}, []);
|
|
320
320
|
}
|
|
321
321
|
function partitionApiModules(schema, options) {
|
|
322
|
-
const { base, transformer, uncountableNouns, validateStatus } = options;
|
|
322
|
+
const { base, transformer, uncountableNouns, validateStatus, excludeDeprecated } = options;
|
|
323
323
|
const schemaPaths = schema.paths ?? {};
|
|
324
324
|
const schemaPathKeys = base ? Object.keys(schemaPaths).map((key) => key.replace(base, "")) : Object.keys(schemaPaths);
|
|
325
325
|
const keyToPaths = (0, import_rattail3.groupBy)(schemaPathKeys, (key) => key.split("/")[1]);
|
|
@@ -334,7 +334,8 @@ function partitionApiModules(schema, options) {
|
|
|
334
334
|
fullPath,
|
|
335
335
|
transformer,
|
|
336
336
|
uncountableNouns,
|
|
337
|
-
validateStatus
|
|
337
|
+
validateStatus,
|
|
338
|
+
excludeDeprecated
|
|
338
339
|
})
|
|
339
340
|
);
|
|
340
341
|
return payloads2;
|
|
@@ -411,7 +412,8 @@ async function generate(userOptions = {}) {
|
|
|
411
412
|
validateStatus = (status) => status >= 200 && status < 300,
|
|
412
413
|
transformer = {},
|
|
413
414
|
uncountableNouns = [],
|
|
414
|
-
openapiTsOptions = {}
|
|
415
|
+
openapiTsOptions = {},
|
|
416
|
+
excludeDeprecated = false
|
|
415
417
|
} = options;
|
|
416
418
|
const mergedTransformer = { ...createTransformer(), ...transformer };
|
|
417
419
|
const schema = await readSchema(input);
|
|
@@ -420,6 +422,9 @@ async function generate(userOptions = {}) {
|
|
|
420
422
|
import_rslog2.logger.info(`Cleaned output directory: ${(0, import_path3.resolve)(CWD, output)}`);
|
|
421
423
|
}
|
|
422
424
|
import_rslog2.logger.info("Generating API modules...");
|
|
425
|
+
if (openapiTsOptions.excludeDeprecated === void 0) {
|
|
426
|
+
openapiTsOptions.excludeDeprecated = excludeDeprecated;
|
|
427
|
+
}
|
|
423
428
|
if (ts2) {
|
|
424
429
|
await generateTypes(schema, output, typesFilename, openapiTsOptions);
|
|
425
430
|
}
|
|
@@ -427,7 +432,8 @@ async function generate(userOptions = {}) {
|
|
|
427
432
|
base,
|
|
428
433
|
uncountableNouns,
|
|
429
434
|
transformer: mergedTransformer,
|
|
430
|
-
validateStatus
|
|
435
|
+
validateStatus,
|
|
436
|
+
excludeDeprecated
|
|
431
437
|
});
|
|
432
438
|
await renderApiModules(apiModules, { output, typesFilename, ts: ts2, typesOnly, overrides, preset });
|
|
433
439
|
import_rslog2.logger.success("Done");
|
package/dist/cli.js
CHANGED
|
@@ -8,7 +8,7 @@ import { Command } from "commander";
|
|
|
8
8
|
var program = new Command();
|
|
9
9
|
program.version(getCliVersion());
|
|
10
10
|
program.action(async () => {
|
|
11
|
-
const { generate } = await import("./generate-
|
|
11
|
+
const { generate } = await import("./generate-4J5VPBTS.js");
|
|
12
12
|
return generate();
|
|
13
13
|
});
|
|
14
14
|
program.parse();
|
package/dist/index.cjs
CHANGED
|
@@ -314,8 +314,8 @@ function getResponseMetadataItems(operation, validateStatus) {
|
|
|
314
314
|
|
|
315
315
|
// src/generate.ts
|
|
316
316
|
function transformPayloads(pathItems, options) {
|
|
317
|
-
const { transformer, path, fullPath, base, uncountableNouns, validateStatus } = options;
|
|
318
|
-
return Object.entries(pathItems).filter(([key]) => SUPPORTED_HTTP_METHODS.includes(key)).reduce((payloads, [method, operation]) => {
|
|
317
|
+
const { transformer, path, fullPath, base, uncountableNouns, validateStatus, excludeDeprecated } = options;
|
|
318
|
+
return Object.entries(pathItems).filter(([key]) => SUPPORTED_HTTP_METHODS.includes(key)).filter(([, operation]) => !(excludeDeprecated && operation.deprecated)).reduce((payloads, [method, operation]) => {
|
|
319
319
|
const url = transformer.url({ path, base, fullPath });
|
|
320
320
|
const args = { path, base, fullPath, url, method, uncountableNouns, operation };
|
|
321
321
|
const entity = transformer.entity(args);
|
|
@@ -360,7 +360,7 @@ function transformPayloads(pathItems, options) {
|
|
|
360
360
|
}, []);
|
|
361
361
|
}
|
|
362
362
|
function partitionApiModules(schema, options) {
|
|
363
|
-
const { base, transformer, uncountableNouns, validateStatus } = options;
|
|
363
|
+
const { base, transformer, uncountableNouns, validateStatus, excludeDeprecated } = options;
|
|
364
364
|
const schemaPaths = schema.paths ?? {};
|
|
365
365
|
const schemaPathKeys = base ? Object.keys(schemaPaths).map((key) => key.replace(base, "")) : Object.keys(schemaPaths);
|
|
366
366
|
const keyToPaths = (0, import_rattail3.groupBy)(schemaPathKeys, (key) => key.split("/")[1]);
|
|
@@ -375,7 +375,8 @@ function partitionApiModules(schema, options) {
|
|
|
375
375
|
fullPath,
|
|
376
376
|
transformer,
|
|
377
377
|
uncountableNouns,
|
|
378
|
-
validateStatus
|
|
378
|
+
validateStatus,
|
|
379
|
+
excludeDeprecated
|
|
379
380
|
})
|
|
380
381
|
);
|
|
381
382
|
return payloads2;
|
|
@@ -452,7 +453,8 @@ async function generate(userOptions = {}) {
|
|
|
452
453
|
validateStatus = (status) => status >= 200 && status < 300,
|
|
453
454
|
transformer = {},
|
|
454
455
|
uncountableNouns = [],
|
|
455
|
-
openapiTsOptions = {}
|
|
456
|
+
openapiTsOptions = {},
|
|
457
|
+
excludeDeprecated = false
|
|
456
458
|
} = options;
|
|
457
459
|
const mergedTransformer = { ...createTransformer(), ...transformer };
|
|
458
460
|
const schema = await readSchema(input);
|
|
@@ -461,6 +463,9 @@ async function generate(userOptions = {}) {
|
|
|
461
463
|
import_rslog2.logger.info(`Cleaned output directory: ${(0, import_path3.resolve)(CWD, output)}`);
|
|
462
464
|
}
|
|
463
465
|
import_rslog2.logger.info("Generating API modules...");
|
|
466
|
+
if (openapiTsOptions.excludeDeprecated === void 0) {
|
|
467
|
+
openapiTsOptions.excludeDeprecated = excludeDeprecated;
|
|
468
|
+
}
|
|
464
469
|
if (ts2) {
|
|
465
470
|
await generateTypes(schema, output, typesFilename, openapiTsOptions);
|
|
466
471
|
}
|
|
@@ -468,7 +473,8 @@ async function generate(userOptions = {}) {
|
|
|
468
473
|
base,
|
|
469
474
|
uncountableNouns,
|
|
470
475
|
transformer: mergedTransformer,
|
|
471
|
-
validateStatus
|
|
476
|
+
validateStatus,
|
|
477
|
+
excludeDeprecated
|
|
472
478
|
});
|
|
473
479
|
await renderApiModules(apiModules, { output, typesFilename, ts: ts2, typesOnly, overrides, preset });
|
|
474
480
|
import_rslog2.logger.success("Done");
|
package/dist/index.d.cts
CHANGED
|
@@ -294,6 +294,11 @@ interface GenerateOptions {
|
|
|
294
294
|
* A function to transform the generated types AST before printing to string.
|
|
295
295
|
*/
|
|
296
296
|
openapiTsOptions?: OpenAPITSOptions;
|
|
297
|
+
/**
|
|
298
|
+
* Whether to exclude deprecated API endpoints.
|
|
299
|
+
* @default false
|
|
300
|
+
*/
|
|
301
|
+
excludeDeprecated?: boolean;
|
|
297
302
|
}
|
|
298
303
|
declare function transformPayloads(pathItems: Record<string, OperationObject>, options: {
|
|
299
304
|
path: string;
|
|
@@ -302,12 +307,14 @@ declare function transformPayloads(pathItems: Record<string, OperationObject>, o
|
|
|
302
307
|
transformer: Transformer;
|
|
303
308
|
uncountableNouns: string[];
|
|
304
309
|
validateStatus: (status: number) => boolean;
|
|
310
|
+
excludeDeprecated?: boolean;
|
|
305
311
|
}): ApiModulePayload[];
|
|
306
312
|
declare function partitionApiModules(schema: OpenAPI3, options: {
|
|
307
313
|
transformer: Transformer;
|
|
308
314
|
base: string | undefined;
|
|
309
315
|
uncountableNouns: string[];
|
|
310
316
|
validateStatus: (status: number) => boolean;
|
|
317
|
+
excludeDeprecated?: boolean;
|
|
311
318
|
}): ApiModule[];
|
|
312
319
|
declare function renderApiModules(apiModules: ApiModule[], options: {
|
|
313
320
|
output: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -294,6 +294,11 @@ interface GenerateOptions {
|
|
|
294
294
|
* A function to transform the generated types AST before printing to string.
|
|
295
295
|
*/
|
|
296
296
|
openapiTsOptions?: OpenAPITSOptions;
|
|
297
|
+
/**
|
|
298
|
+
* Whether to exclude deprecated API endpoints.
|
|
299
|
+
* @default false
|
|
300
|
+
*/
|
|
301
|
+
excludeDeprecated?: boolean;
|
|
297
302
|
}
|
|
298
303
|
declare function transformPayloads(pathItems: Record<string, OperationObject>, options: {
|
|
299
304
|
path: string;
|
|
@@ -302,12 +307,14 @@ declare function transformPayloads(pathItems: Record<string, OperationObject>, o
|
|
|
302
307
|
transformer: Transformer;
|
|
303
308
|
uncountableNouns: string[];
|
|
304
309
|
validateStatus: (status: number) => boolean;
|
|
310
|
+
excludeDeprecated?: boolean;
|
|
305
311
|
}): ApiModulePayload[];
|
|
306
312
|
declare function partitionApiModules(schema: OpenAPI3, options: {
|
|
307
313
|
transformer: Transformer;
|
|
308
314
|
base: string | undefined;
|
|
309
315
|
uncountableNouns: string[];
|
|
310
316
|
validateStatus: (status: number) => boolean;
|
|
317
|
+
excludeDeprecated?: boolean;
|
|
311
318
|
}): ApiModule[];
|
|
312
319
|
declare function renderApiModules(apiModules: ApiModule[], options: {
|
|
313
320
|
output: string;
|
package/dist/index.js
CHANGED