@theholocron/postman-client 1.58.0-alpha.30 → 1.58.0-alpha.31
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 +10 -0
- package/dist/index.d.mts +37 -1
- package/dist/index.mjs +17 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -29,6 +29,16 @@ const { collections } = await postman.collections.list("workspace-id");
|
|
|
29
29
|
// Delete a collection
|
|
30
30
|
await postman.collections.delete("collection-uid");
|
|
31
31
|
|
|
32
|
+
// Create or replace a collection from a Postman collection document
|
|
33
|
+
await postman.collections.create("workspace-id", collection);
|
|
34
|
+
await postman.collections.update("collection-uid", collection);
|
|
35
|
+
|
|
36
|
+
// Make a workspace
|
|
37
|
+
await postman.workspaces.create({ name: "Holocron", type: "personal" });
|
|
38
|
+
|
|
39
|
+
// Read one environment with its variables
|
|
40
|
+
const { environment } = await postman.environments.get("environment-uid");
|
|
41
|
+
|
|
32
42
|
// Import an OpenAPI spec as a collection
|
|
33
43
|
const { collections: imported } = await postman.import.openapi("workspace-id", spec);
|
|
34
44
|
|
package/dist/index.d.mts
CHANGED
|
@@ -27,6 +27,22 @@ interface PostmanCollectionsResponse {
|
|
|
27
27
|
/** The collections returned. */
|
|
28
28
|
collections: PostmanCollection[];
|
|
29
29
|
}
|
|
30
|
+
/** The response of fetching, creating or updating one collection. */
|
|
31
|
+
interface PostmanCollectionResponse {
|
|
32
|
+
/** The collection. */
|
|
33
|
+
collection: PostmanCollection;
|
|
34
|
+
}
|
|
35
|
+
/** One variable of an environment. */
|
|
36
|
+
interface PostmanEnvironmentValue {
|
|
37
|
+
/** The variable's name. */
|
|
38
|
+
key: string;
|
|
39
|
+
/** The variable's value. */
|
|
40
|
+
value?: string;
|
|
41
|
+
/** The variable's type, such as `default` or `secret`. */
|
|
42
|
+
type?: string;
|
|
43
|
+
/** Whether the variable is in use. */
|
|
44
|
+
enabled?: boolean;
|
|
45
|
+
}
|
|
30
46
|
/** A Postman environment, as listed by the API. */
|
|
31
47
|
interface PostmanEnvironment {
|
|
32
48
|
/** The environment's id. */
|
|
@@ -35,6 +51,8 @@ interface PostmanEnvironment {
|
|
|
35
51
|
uid: string;
|
|
36
52
|
/** The environment's name. */
|
|
37
53
|
name: string;
|
|
54
|
+
/** The variables; only present when one environment is fetched. */
|
|
55
|
+
values?: PostmanEnvironmentValue[];
|
|
38
56
|
}
|
|
39
57
|
/** The response of listing environments. */
|
|
40
58
|
interface PostmanEnvironmentsResponse {
|
|
@@ -106,6 +124,20 @@ interface PostmanWorkspacesResponse {
|
|
|
106
124
|
/** The workspaces returned. */
|
|
107
125
|
workspaces: PostmanWorkspace[];
|
|
108
126
|
}
|
|
127
|
+
/** What `workspaces.create` takes. */
|
|
128
|
+
interface PostmanCreateWorkspaceInput {
|
|
129
|
+
/** The workspace's name. */
|
|
130
|
+
name: string;
|
|
131
|
+
/** The workspace's type: `personal` or `team`. */
|
|
132
|
+
type: "personal" | "team";
|
|
133
|
+
/** A description shown in Postman. */
|
|
134
|
+
description?: string;
|
|
135
|
+
}
|
|
136
|
+
/** The response of creating one workspace. */
|
|
137
|
+
interface PostmanWorkspaceResponse {
|
|
138
|
+
/** The workspace made. */
|
|
139
|
+
workspace: Pick<PostmanWorkspace, "id" | "name">;
|
|
140
|
+
}
|
|
109
141
|
/**
|
|
110
142
|
* Thrown when Postman returns a `limitReachedError` (e.g., a Free-tier
|
|
111
143
|
* account hitting the "0 APIs" cap).
|
|
@@ -129,10 +161,13 @@ export declare function detectPlanLimit(body: string): string | null;
|
|
|
129
161
|
export declare function createPostmanClient(opts: PostmanClientOptions): {
|
|
130
162
|
collections: {
|
|
131
163
|
list: (workspaceId: string) => Promise<PostmanCollectionsResponse>;
|
|
164
|
+
create: (workspaceId: string, collection: unknown) => Promise<PostmanCollectionResponse>;
|
|
165
|
+
update: (uid: string, collection: unknown) => Promise<PostmanCollectionResponse>;
|
|
132
166
|
delete: (uid: string) => Promise<void>;
|
|
133
167
|
};
|
|
134
168
|
environments: {
|
|
135
169
|
list: (workspaceId: string) => Promise<PostmanEnvironmentsResponse>;
|
|
170
|
+
get: (uid: string) => Promise<PostmanEnvironmentResponse>;
|
|
136
171
|
create: (workspaceId: string, environment: unknown) => Promise<PostmanEnvironmentResponse>;
|
|
137
172
|
update: (uid: string, environment: unknown) => Promise<PostmanEnvironmentResponse>;
|
|
138
173
|
};
|
|
@@ -149,8 +184,9 @@ export declare function createPostmanClient(opts: PostmanClientOptions): {
|
|
|
149
184
|
};
|
|
150
185
|
workspaces: {
|
|
151
186
|
list: () => Promise<PostmanWorkspacesResponse>;
|
|
187
|
+
create: (input: PostmanCreateWorkspaceInput) => Promise<PostmanWorkspaceResponse>;
|
|
152
188
|
};
|
|
153
189
|
};
|
|
154
190
|
/** The client `createPostmanClient` returns. */
|
|
155
191
|
export type PostmanClient = ReturnType<typeof createPostmanClient>;
|
|
156
|
-
export type { PostmanClientOptions, PostmanCollection, PostmanCollectionsResponse, PostmanCreateSpecInput, PostmanEnvironment, PostmanEnvironmentResponse, PostmanEnvironmentsResponse, PostmanImportOpenApiResponse, PostmanMeResponse, PostmanSpec, PostmanSpecsResponse, PostmanUser, PostmanWorkspace, PostmanWorkspacesResponse };
|
|
192
|
+
export type { PostmanClientOptions, PostmanCollection, PostmanCollectionResponse, PostmanCollectionsResponse, PostmanCreateSpecInput, PostmanCreateWorkspaceInput, PostmanEnvironment, PostmanEnvironmentResponse, PostmanEnvironmentValue, PostmanEnvironmentsResponse, PostmanImportOpenApiResponse, PostmanMeResponse, PostmanSpec, PostmanSpecsResponse, PostmanUser, PostmanWorkspace, PostmanWorkspaceResponse, PostmanWorkspacesResponse };
|
package/dist/index.mjs
CHANGED
|
@@ -3,6 +3,15 @@ import { createRestClient } from "@theholocron/http-client";
|
|
|
3
3
|
function collections(rest) {
|
|
4
4
|
return {
|
|
5
5
|
list: (workspaceId) => rest.request("/collections", { query: { workspace: workspaceId } }),
|
|
6
|
+
create: (workspaceId, collection) => rest.request("/collections", {
|
|
7
|
+
method: "POST",
|
|
8
|
+
query: { workspace: workspaceId },
|
|
9
|
+
body: { collection }
|
|
10
|
+
}),
|
|
11
|
+
update: (uid, collection) => rest.request(`/collections/${encodeURIComponent(uid)}`, {
|
|
12
|
+
method: "PUT",
|
|
13
|
+
body: { collection }
|
|
14
|
+
}),
|
|
6
15
|
delete: (uid) => rest.request(`/collections/${encodeURIComponent(uid)}`, { method: "DELETE" })
|
|
7
16
|
};
|
|
8
17
|
}
|
|
@@ -10,6 +19,7 @@ function collections(rest) {
|
|
|
10
19
|
function environments(rest) {
|
|
11
20
|
return {
|
|
12
21
|
list: (workspaceId) => rest.request("/environments", { query: { workspace: workspaceId } }),
|
|
22
|
+
get: (uid) => rest.request(`/environments/${encodeURIComponent(uid)}`),
|
|
13
23
|
create: (workspaceId, environment) => rest.request("/environments", {
|
|
14
24
|
method: "POST",
|
|
15
25
|
query: { workspace: workspaceId },
|
|
@@ -112,7 +122,13 @@ function createPostmanRestClient(opts) {
|
|
|
112
122
|
}
|
|
113
123
|
// src/workspaces/workspaces.ts
|
|
114
124
|
function workspaces(rest) {
|
|
115
|
-
return {
|
|
125
|
+
return {
|
|
126
|
+
list: () => rest.request("/workspaces"),
|
|
127
|
+
create: (input) => rest.request("/workspaces", {
|
|
128
|
+
method: "POST",
|
|
129
|
+
body: { workspace: input }
|
|
130
|
+
})
|
|
131
|
+
};
|
|
116
132
|
}
|
|
117
133
|
// src/index.ts
|
|
118
134
|
/** Creates a Postman client with `collections`, `environments`, `import`, `me`, `specs` and `workspaces` groups sharing one REST client. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/postman-client",
|
|
3
|
-
"version": "1.58.0-alpha.
|
|
3
|
+
"version": "1.58.0-alpha.31",
|
|
4
4
|
"description": "A TypeScript client for the Postman API",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"postman",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dist"
|
|
32
32
|
],
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@theholocron/http-client": "^1.58.0-alpha.
|
|
34
|
+
"@theholocron/http-client": "^1.58.0-alpha.31",
|
|
35
35
|
"@theholocron/observability": "^0.7.0-alpha.4"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"typescript": "^5.9.3",
|
|
46
46
|
"vitest": "^5.1.0",
|
|
47
47
|
"@theholocron/eslint-config": "^8.9.0-alpha.17",
|
|
48
|
-
"@theholocron/tsconfig": "^8.9.0-alpha.17",
|
|
49
48
|
"@theholocron/tsdown-config": "^8.9.0-alpha.17",
|
|
49
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.17",
|
|
50
50
|
"@theholocron/vitest-config": "^8.9.0-alpha.17"
|
|
51
51
|
},
|
|
52
52
|
"engines": {
|