@typeship-ax/cli 0.6.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/LICENSE +9 -0
- package/README.md +40 -0
- package/api.json +5163 -0
- package/api.md +512 -0
- package/dist/cli-agent.d.ts +204 -0
- package/dist/cli-agent.d.ts.map +1 -0
- package/dist/cli-agent.js +525 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +2811 -0
- package/dist/core/http.d.ts +303 -0
- package/dist/core/http.d.ts.map +1 -0
- package/dist/core/http.js +770 -0
- package/dist/core/pagination.d.ts +51 -0
- package/dist/core/pagination.d.ts.map +1 -0
- package/dist/core/pagination.js +154 -0
- package/dist/dates.d.ts +33 -0
- package/dist/dates.d.ts.map +1 -0
- package/dist/dates.js +136 -0
- package/dist/errors.d.ts +81 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +103 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +86 -0
- package/dist/ops.d.ts +115 -0
- package/dist/ops.d.ts.map +1 -0
- package/dist/ops.js +79 -0
- package/dist/resources/account.d.ts +18 -0
- package/dist/resources/account.d.ts.map +1 -0
- package/dist/resources/account.js +26 -0
- package/dist/resources/api-keys.d.ts +37 -0
- package/dist/resources/api-keys.d.ts.map +1 -0
- package/dist/resources/api-keys.js +67 -0
- package/dist/resources/generate.d.ts +25 -0
- package/dist/resources/generate.d.ts.map +1 -0
- package/dist/resources/generate.js +41 -0
- package/dist/resources/generations.d.ts +31 -0
- package/dist/resources/generations.d.ts.map +1 -0
- package/dist/resources/generations.js +56 -0
- package/dist/resources/projects.d.ts +110 -0
- package/dist/resources/projects.d.ts.map +1 -0
- package/dist/resources/projects.js +220 -0
- package/dist/resources/spec-revisions.d.ts +47 -0
- package/dist/resources/spec-revisions.d.ts.map +1 -0
- package/dist/resources/spec-revisions.js +90 -0
- package/dist/schemas.d.ts +6 -0
- package/dist/schemas.d.ts.map +1 -0
- package/dist/schemas.js +88 -0
- package/dist/types.d.ts +759 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +37 -0
- package/package.json +43 -0
- package/src/cli-agent.ts +685 -0
- package/src/cli.ts +2695 -0
- package/src/core/http.ts +1008 -0
- package/src/core/pagination.ts +195 -0
- package/src/dates.ts +126 -0
- package/src/errors.ts +117 -0
- package/src/index.ts +153 -0
- package/src/ops.ts +174 -0
- package/src/resources/account.ts +43 -0
- package/src/resources/api-keys.ts +105 -0
- package/src/resources/generate.ts +69 -0
- package/src/resources/generations.ts +100 -0
- package/src/resources/projects.ts +391 -0
- package/src/resources/spec-revisions.ts +150 -0
- package/src/schemas.ts +90 -0
- package/src/types.ts +825 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// typeship — client entry point.
|
|
2
|
+
// Generated by typeship — https://typeship.dev — do not edit by hand.
|
|
3
|
+
import { HttpCore, formatDebugEvent, bearerAuth, } from "./core/http.js";
|
|
4
|
+
import { DEFS, SCHEMAS } from "./schemas.js";
|
|
5
|
+
import { GenerateResource } from "./resources/generate.js";
|
|
6
|
+
import { ProjectsResource } from "./resources/projects.js";
|
|
7
|
+
import { GenerationsResource } from "./resources/generations.js";
|
|
8
|
+
import { SpecRevisionsResource } from "./resources/spec-revisions.js";
|
|
9
|
+
import { AccountResource } from "./resources/account.js";
|
|
10
|
+
import { ApiKeysResource } from "./resources/api-keys.js";
|
|
11
|
+
/** This package's version, also sent as the `User-Agent`. */
|
|
12
|
+
export const VERSION = "0.6.0";
|
|
13
|
+
const USER_AGENT = "@typeship-ax/cli/0.6.0 (typeship)";
|
|
14
|
+
/**
|
|
15
|
+
* typeship — v0.6.0
|
|
16
|
+
*
|
|
17
|
+
* Generate production SDKs, CLIs, and MCP servers from an OpenAPI or
|
|
18
|
+
* GraphQL spec, and keep every selected output current.
|
|
19
|
+
*
|
|
20
|
+
* Every operation but one requires an API key, created in the console and
|
|
21
|
+
* sent as `Authorization: Bearer ak_...`. A browser session is not a
|
|
22
|
+
* credential for this API. The exception is POST /generate, which works
|
|
23
|
+
* anonymously with the free plan's limits.
|
|
24
|
+
*/
|
|
25
|
+
export class TypeshipClient {
|
|
26
|
+
generate;
|
|
27
|
+
projects;
|
|
28
|
+
generations;
|
|
29
|
+
specRevisions;
|
|
30
|
+
account;
|
|
31
|
+
apiKeys;
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
// Identifies this package to the API (ignored by browsers, which
|
|
34
|
+
// control their own User-Agent); override via defaultHeaders.
|
|
35
|
+
const headers = { "User-Agent": USER_AGENT, ...options.defaultHeaders };
|
|
36
|
+
const debugOption = options.debug
|
|
37
|
+
?? (typeof process !== "undefined" && process.env?.["TYPESHIP_DEBUG"] === "1");
|
|
38
|
+
const debug = typeof debugOption === "function"
|
|
39
|
+
? debugOption
|
|
40
|
+
: debugOption === true
|
|
41
|
+
? (event) => console.error(formatDebugEvent("typeship", event))
|
|
42
|
+
: undefined;
|
|
43
|
+
const query = {};
|
|
44
|
+
if (options.bearerToken !== undefined)
|
|
45
|
+
headers["Authorization"] = bearerAuth(options.bearerToken);
|
|
46
|
+
const v = options.validate;
|
|
47
|
+
const validate = v
|
|
48
|
+
? {
|
|
49
|
+
requests: typeof v === "object" ? v.requests !== false : true,
|
|
50
|
+
responses: typeof v === "object" ? v.responses !== false : true,
|
|
51
|
+
mode: (typeof v === "object" && v.mode) || "throw",
|
|
52
|
+
}
|
|
53
|
+
: undefined;
|
|
54
|
+
const core = new HttpCore({
|
|
55
|
+
baseUrl: options.baseUrl ?? "https://typeship.dev/api/v1",
|
|
56
|
+
headers,
|
|
57
|
+
query,
|
|
58
|
+
fetch: options.fetch ?? fetch,
|
|
59
|
+
timeoutMs: options.timeoutMs ?? 30_000,
|
|
60
|
+
maxRetries: options.maxRetries ?? 2,
|
|
61
|
+
onRequest: options.onRequest,
|
|
62
|
+
onResponse: options.onResponse,
|
|
63
|
+
onError: options.onError,
|
|
64
|
+
debug,
|
|
65
|
+
validate,
|
|
66
|
+
schemas: validate ? SCHEMAS : undefined,
|
|
67
|
+
schemaDefs: validate ? DEFS : undefined,
|
|
68
|
+
});
|
|
69
|
+
this.generate = new GenerateResource(core);
|
|
70
|
+
this.projects = new ProjectsResource(core);
|
|
71
|
+
this.generations = new GenerationsResource(core);
|
|
72
|
+
this.specRevisions = new SpecRevisionsResource(core);
|
|
73
|
+
this.account = new AccountResource(core);
|
|
74
|
+
this.apiKeys = new ApiKeysResource(core);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export * from "./types.js";
|
|
78
|
+
export * from "./errors.js";
|
|
79
|
+
export { formatDebugEvent, } from "./core/http.js";
|
|
80
|
+
export { Page, PagePromise } from "./core/pagination.js";
|
|
81
|
+
export * from "./resources/generate.js";
|
|
82
|
+
export * from "./resources/projects.js";
|
|
83
|
+
export * from "./resources/generations.js";
|
|
84
|
+
export * from "./resources/spec-revisions.js";
|
|
85
|
+
export * from "./resources/account.js";
|
|
86
|
+
export * from "./resources/api-keys.js";
|
package/dist/ops.d.ts
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
export interface ParamSpec {
|
|
2
|
+
/** wire name (JSON key, query name, or path placeholder) */
|
|
3
|
+
name: string;
|
|
4
|
+
/** CLI flag, without the leading dashes */
|
|
5
|
+
flag: string;
|
|
6
|
+
/** property name the SDK params object uses */
|
|
7
|
+
ts: string;
|
|
8
|
+
kind: "path" | "query" | "header" | "body";
|
|
9
|
+
/** "file": a binary multipart field; the CLI takes a path and uploads it.
|
|
10
|
+
* "array"/"object": the schema says so (a lone scalar flag value becomes a
|
|
11
|
+
* one-item array; an object must be JSON). "json": a union or untyped
|
|
12
|
+
* value — JSON if it parses, else the raw text. */
|
|
13
|
+
type: "string" | "number" | "boolean" | "array" | "object" | "json" | "file";
|
|
14
|
+
required: boolean;
|
|
15
|
+
enum?: string[];
|
|
16
|
+
/** Element type of an "array" param: what each repeated/comma value coerces to. */
|
|
17
|
+
items?: {
|
|
18
|
+
type: "string" | "number" | "boolean" | "object" | "json";
|
|
19
|
+
enum?: string[];
|
|
20
|
+
};
|
|
21
|
+
/** A date-shaped string: the CLI and MCP server resolve relative forms (-P7D, today). */
|
|
22
|
+
format?: "date" | "date-time";
|
|
23
|
+
description?: string;
|
|
24
|
+
/** Settable once on the client (globals option); optional per call. */
|
|
25
|
+
global?: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface OpSpec {
|
|
28
|
+
resource: string;
|
|
29
|
+
method: string;
|
|
30
|
+
command: [string, string];
|
|
31
|
+
/** Full kebab method name, still routable, when command[1] was shortened. */
|
|
32
|
+
commandAlias?: string;
|
|
33
|
+
tool: string;
|
|
34
|
+
httpMethod: string;
|
|
35
|
+
path: string;
|
|
36
|
+
summary?: string;
|
|
37
|
+
/** Full operation description, for the docs command (help stays terse). */
|
|
38
|
+
description?: string;
|
|
39
|
+
/** What agents see in tools/list: summary, the description's first
|
|
40
|
+
* sentence, method + path. Computed once so package and hosted agree. */
|
|
41
|
+
toolDescription: string;
|
|
42
|
+
paginated: boolean;
|
|
43
|
+
hasBody: boolean;
|
|
44
|
+
bodyStyle: "none" | "fields" | "data";
|
|
45
|
+
/** wire encoding of the body, for generic executors */
|
|
46
|
+
bodyKind: "json" | "form" | "multipart" | "binary" | "text" | null;
|
|
47
|
+
/** Success body is a text/event-stream: the CLI streams events as NDJSON;
|
|
48
|
+
* not an MCP tool. */
|
|
49
|
+
sse: boolean;
|
|
50
|
+
hasParams: boolean;
|
|
51
|
+
/** GraphQL ops whose field returns an object accept a selection-set
|
|
52
|
+
* override (a leaf-returning field has nothing to select). */
|
|
53
|
+
select: boolean;
|
|
54
|
+
/** present for GraphQL ops: enough to build the request document */
|
|
55
|
+
graphql?: {
|
|
56
|
+
field: string;
|
|
57
|
+
kind: "query" | "mutation";
|
|
58
|
+
docPrefix: string;
|
|
59
|
+
defaultSelection: string;
|
|
60
|
+
};
|
|
61
|
+
/** Retried by default (idempotent verb), like the SDK method. */
|
|
62
|
+
idempotent: boolean;
|
|
63
|
+
/** Header the SDK fills with one UUID per call (Idempotency-Key). */
|
|
64
|
+
idempotencyHeader?: string;
|
|
65
|
+
/** Operation-level retry policy (x-typeship-retries). */
|
|
66
|
+
retry?: {
|
|
67
|
+
maxRetries?: number;
|
|
68
|
+
statuses?: number[];
|
|
69
|
+
initialDelayMs?: number;
|
|
70
|
+
maxDelayMs?: number;
|
|
71
|
+
retryNonIdempotent?: boolean;
|
|
72
|
+
};
|
|
73
|
+
/** Page-walking config for generic executors, same shape as the SDK's PageConfig. */
|
|
74
|
+
pagination?: {
|
|
75
|
+
style: "cursor" | "cursorFromLastId" | "page" | "offset";
|
|
76
|
+
itemsField: string;
|
|
77
|
+
cursorParam?: string;
|
|
78
|
+
nextCursorField?: string;
|
|
79
|
+
hasMoreField?: string;
|
|
80
|
+
idField?: string;
|
|
81
|
+
pageParam?: string;
|
|
82
|
+
offsetParam?: string;
|
|
83
|
+
limitParam?: string;
|
|
84
|
+
};
|
|
85
|
+
/** The spec's security requirement: "required" fails fast without a
|
|
86
|
+
* credential; "none" works anonymously; "optional" is either. */
|
|
87
|
+
auth: "required" | "optional" | "none";
|
|
88
|
+
/** Whether calling this operation only reads, writes, or destroys state. */
|
|
89
|
+
safety: "read" | "write" | "destructive";
|
|
90
|
+
params: ParamSpec[];
|
|
91
|
+
inputSchema: Record<string, unknown>;
|
|
92
|
+
/** Deterministic arguments derived from inputSchema for runnable examples. */
|
|
93
|
+
exampleArguments: Record<string, unknown>;
|
|
94
|
+
/** What the tool returns (JSON Schema 2020-12), when the spec documents
|
|
95
|
+
* a success body; paginated tools describe { items, hasMore, nextPage }. */
|
|
96
|
+
outputSchema?: Record<string, unknown>;
|
|
97
|
+
}
|
|
98
|
+
export declare const OPS: OpSpec[];
|
|
99
|
+
/** Parameters settable once on the client (globals option): CLI/MCP fill
|
|
100
|
+
* them from flags or environment; the SDK falls back per request. */
|
|
101
|
+
export declare const GLOBALS: {
|
|
102
|
+
name: string;
|
|
103
|
+
option: string;
|
|
104
|
+
flag: string;
|
|
105
|
+
envSuffix: string;
|
|
106
|
+
}[];
|
|
107
|
+
export declare function findOp(resource: string, method: string): OpSpec | undefined;
|
|
108
|
+
export declare function missingRequired(op: OpSpec, values: Record<string, unknown>): string[];
|
|
109
|
+
/**
|
|
110
|
+
* Assemble the SDK method's positional arguments from a flat map of values
|
|
111
|
+
* keyed by wire name (plus an optional raw body for bodyStyle "data" or a
|
|
112
|
+
* --data base object).
|
|
113
|
+
*/
|
|
114
|
+
export declare function buildArgs(op: OpSpec, values: Record<string, unknown>, dataBody?: unknown, select?: string): unknown[];
|
|
115
|
+
//# sourceMappingURL=ops.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../src/ops.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,SAAS;IACxB,4DAA4D;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,+CAA+C;IAC/C,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,CAAC;IAC3C;;;uDAGmD;IACnD,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7E,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,mFAAmF;IACnF,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;KAAE,CAAC;IACvF,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAC9B,WAAW,CAAC,EA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