@theholocron/postman-client 1.58.0-alpha.4 → 1.58.0-alpha.41

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 CHANGED
@@ -1,3 +1,5 @@
1
+ <!-- alex disable postman-postwoman -->
2
+
1
3
  # `@theholocron/postman-client`
2
4
 
3
5
  TypeScript client for the [Postman API](https://www.postman.com/postman/postman-public-workspace/documentation/8kv5pif/postman-api).
@@ -27,6 +29,16 @@ const { collections } = await postman.collections.list("workspace-id");
27
29
  // Delete a collection
28
30
  await postman.collections.delete("collection-uid");
29
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
+
30
42
  // Import an OpenAPI spec as a collection
31
43
  const { collections: imported } = await postman.import.openapi("workspace-id", spec);
32
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 { list: () => rest.request("/workspaces") };
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.4",
3
+ "version": "1.58.0-alpha.41",
4
4
  "description": "A TypeScript client for the Postman API",
5
5
  "keywords": [
6
6
  "postman",
@@ -31,23 +31,23 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@theholocron/http-client": "^1.58.0-alpha.4",
35
- "@theholocron/observability": "^0.6.1-alpha.1"
34
+ "@theholocron/http-client": "^1.58.0-alpha.41",
35
+ "@theholocron/observability": "^0.7.0-alpha.5"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/node": "^26",
39
- "@vitest/coverage-v8": "^5.0.5",
40
- "@vitest/eslint-plugin": "^1.6.27",
41
- "eslint": "^10.8.1",
42
- "eslint-plugin-n": "^18.3.0",
43
- "globals": "^17.11.0",
44
- "tsdown": "^0.23.3",
39
+ "@vitest/coverage-v8": "^5.1.0",
40
+ "@vitest/eslint-plugin": "^1.6.28",
41
+ "eslint": "^10.14.0",
42
+ "eslint-plugin-n": "^18.5.0",
43
+ "globals": "^17.14.0",
44
+ "tsdown": "^0.23.7",
45
45
  "typescript": "^5.9.3",
46
- "vitest": "^5.0.5",
47
- "@theholocron/tsconfig": "^8.9.0-alpha.5",
48
- "@theholocron/vitest-config": "^8.9.0-alpha.5",
49
- "@theholocron/tsdown-config": "^8.9.0-alpha.5",
50
- "@theholocron/eslint-config": "^8.9.0-alpha.5"
46
+ "vitest": "^5.1.0",
47
+ "@theholocron/tsconfig": "^8.9.0-alpha.21",
48
+ "@theholocron/tsdown-config": "^8.9.0-alpha.21",
49
+ "@theholocron/vitest-config": "^8.9.0-alpha.21",
50
+ "@theholocron/eslint-config": "^8.9.0-alpha.21"
51
51
  },
52
52
  "engines": {
53
53
  "node": ">=22.0.0"
@@ -56,10 +56,10 @@
56
56
  "access": "public"
57
57
  },
58
58
  "scripts": {
59
- "delivery.build": "tsdown && node ../scripts/check-bundle-size.mjs",
60
- "sourceQuality.staticAnalysis": "eslint .",
59
+ "build": "tsdown && node ../scripts/check-bundle-size.mjs",
60
+ "lint:code": "eslint .",
61
+ "test:unit": "vitest run --coverage",
61
62
  "test:watch": "vitest",
62
- "verification.typeSafety": "tsc --noEmit",
63
- "verification.unitTests": "vitest run"
63
+ "typecheck": "tsc --noEmit"
64
64
  }
65
65
  }