@theholocron/holocron-plugin-postman 5.0.0-alpha.27 → 5.0.0-alpha.271
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/index.d.mts +16 -33
- package/dist/index.mjs +23 -18
- package/package.json +21 -19
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { AuthError, ResolveTokenInput, Tooling, ToolingDoctorReport } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, PluginToken, ResolveTokenInput, Tooling, ToolingDoctorReport, VerifyTokenFailure, VerifyTokenResult, VerifyTokenResult as VerifyTokenResult$1, VerifyTokenSuccess } from "@theholocron/cli";
|
|
2
2
|
import { PostmanClient, PostmanClient as PostmanClient$1, PostmanClientOptions, PostmanCollection, PostmanEnvironment, PostmanPlanLimitError, PostmanSpec, PostmanUser, PostmanWorkspace, createPostmanClient, detectPlanLimit } from "@theholocron/postman-client";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
//#region src/capabilities/tooling.d.ts
|
|
3
|
+
export declare const resolveToken: import("@theholocron/cli").TokenResolver;
|
|
4
|
+
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
5
|
+
export declare const tokens: PluginToken[];
|
|
7
6
|
interface PostmanToolingOptions {
|
|
8
7
|
workspaceId: string;
|
|
9
8
|
/** Local OpenAPI JSON path (relative to repoRoot). */
|
|
@@ -17,7 +16,7 @@ interface PostmanToolingOptions {
|
|
|
17
16
|
/** Working repo root. Defaults to process.cwd(). */
|
|
18
17
|
repoRoot?: string;
|
|
19
18
|
}
|
|
20
|
-
declare class PostmanTooling implements Tooling {
|
|
19
|
+
export declare class PostmanTooling implements Tooling {
|
|
21
20
|
private readonly client;
|
|
22
21
|
readonly key: "tooling";
|
|
23
22
|
readonly providerName = "postman";
|
|
@@ -69,30 +68,12 @@ declare class PostmanTooling implements Tooling {
|
|
|
69
68
|
content: string;
|
|
70
69
|
}): Promise<void>;
|
|
71
70
|
}
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region src/verify-token.d.ts
|
|
74
|
-
/**
|
|
75
|
-
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
76
|
-
* `holocron auth check`. Hits Postman's `/me` endpoint (returns the
|
|
77
|
-
* authenticated user).
|
|
78
|
-
*/
|
|
79
|
-
interface VerifyTokenSuccess {
|
|
80
|
-
ok: true;
|
|
81
|
-
subject: string;
|
|
82
|
-
}
|
|
83
|
-
interface VerifyTokenFailure {
|
|
84
|
-
ok: false;
|
|
85
|
-
message: string;
|
|
86
|
-
}
|
|
87
|
-
type VerifyTokenResult = VerifyTokenSuccess | VerifyTokenFailure;
|
|
88
71
|
interface VerifyTokenOptions {
|
|
89
72
|
baseUrl?: string;
|
|
90
73
|
fetch?: typeof fetch;
|
|
91
74
|
}
|
|
92
|
-
declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
|
|
93
|
-
|
|
94
|
-
//#region src/index.d.ts
|
|
95
|
-
interface PostmanPluginOptions extends ResolveTokenInput, PostmanToolingOptions {
|
|
75
|
+
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
76
|
+
export interface PostmanPluginOptions extends ResolveTokenInput, PostmanToolingOptions {
|
|
96
77
|
/** Working repo root. Used to resolve relative paths in specFile/envFiles. Defaults to process.cwd(). */
|
|
97
78
|
repoRoot?: string;
|
|
98
79
|
/** Override base URL for tests. */
|
|
@@ -100,14 +81,17 @@ interface PostmanPluginOptions extends ResolveTokenInput, PostmanToolingOptions
|
|
|
100
81
|
/** Override `fetch` for tests. */
|
|
101
82
|
fetch?: typeof fetch;
|
|
102
83
|
}
|
|
103
|
-
interface PluginContext {
|
|
84
|
+
export interface PluginContext {
|
|
104
85
|
options: PostmanPluginOptions;
|
|
105
86
|
client: () => PostmanClient;
|
|
106
87
|
}
|
|
107
|
-
declare function createContext(options: PostmanPluginOptions): PluginContext;
|
|
108
|
-
declare function tooling(ctx: PluginContext): Tooling;
|
|
109
|
-
declare function createPlugin(options: PostmanPluginOptions): {
|
|
88
|
+
export declare function createContext(options: PostmanPluginOptions): PluginContext;
|
|
89
|
+
export declare function tooling(ctx: PluginContext): Tooling;
|
|
90
|
+
export declare function createPlugin(options: PostmanPluginOptions): {
|
|
110
91
|
name: string;
|
|
92
|
+
probes: {
|
|
93
|
+
connection: import("@theholocron/cli").Probe;
|
|
94
|
+
};
|
|
111
95
|
capabilities: {
|
|
112
96
|
tooling: () => Tooling;
|
|
113
97
|
};
|
|
@@ -116,6 +100,5 @@ declare function createPlugin(options: PostmanPluginOptions): {
|
|
|
116
100
|
* One-line hint printed by `holocron auth set postman` when no
|
|
117
101
|
* token is supplied or the supplied token is rejected.
|
|
118
102
|
*/
|
|
119
|
-
declare const AUTH_HINT: string;
|
|
120
|
-
|
|
121
|
-
export { AUTH_HINT, AuthError, PluginContext, type PostmanClient, type PostmanClientOptions, PostmanPlanLimitError, PostmanPluginOptions, PostmanTooling, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createContext, createPlugin, createPostmanClient, detectPlanLimit, resolveToken, tooling, verifyToken };
|
|
103
|
+
export declare const AUTH_HINT: string;
|
|
104
|
+
export { AuthError, type PostmanClient, type PostmanClientOptions, PostmanPlanLimitError, type ResolveTokenInput, type VerifyTokenFailure, type VerifyTokenResult, type VerifyTokenSuccess, createPostmanClient, detectPlanLimit };
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
import { AuthError, ProviderApiError, createResolveToken } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, ProviderApiError, connectionProbe, createResolveToken } from "@theholocron/cli";
|
|
2
2
|
import { readFile } from "node:fs/promises";
|
|
3
3
|
import { basename, resolve } from "node:path";
|
|
4
|
+
import { errorMessage } from "@theholocron/misc-utils";
|
|
4
5
|
import { PostmanPlanLimitError, createPostmanClient, detectPlanLimit } from "@theholocron/postman-client";
|
|
5
|
-
|
|
6
|
+
// src/auth.ts
|
|
6
7
|
const resolveToken = createResolveToken({
|
|
7
8
|
envName: "HOLOCRON_POSTMAN_API_KEY",
|
|
8
9
|
vendorEnvName: "POSTMAN_API_KEY",
|
|
9
10
|
keyringService: "postman",
|
|
10
11
|
errorMessage: "no Postman API key found. Pass --token <KEY>, set HOLOCRON_POSTMAN_API_KEY / POSTMAN_API_KEY, or run: holocron auth set postman <KEY>"
|
|
11
12
|
});
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
/** Every token this plugin takes, for `holocron doctor tokens`. */
|
|
14
|
+
const tokens = [resolveToken.token];
|
|
15
|
+
// src/capabilities/tooling.ts
|
|
14
16
|
/**
|
|
15
17
|
* `tooling` capability for Postman.
|
|
16
18
|
*
|
|
@@ -77,7 +79,8 @@ var PostmanTooling = class {
|
|
|
77
79
|
spec: specObj
|
|
78
80
|
});
|
|
79
81
|
for (const file of this.opts.envFiles ?? []) {
|
|
80
|
-
const
|
|
82
|
+
const envPath = resolve(this.repoRoot, file);
|
|
83
|
+
const envText = await readFile(envPath, "utf8");
|
|
81
84
|
const envObj = JSON.parse(envText);
|
|
82
85
|
if (!envObj.name) throw new Error(`Postman environment file ${file} is missing a "name" field`);
|
|
83
86
|
const existing = await this.findEnvironmentByName({
|
|
@@ -109,7 +112,7 @@ var PostmanTooling = class {
|
|
|
109
112
|
} catch (err) {
|
|
110
113
|
return {
|
|
111
114
|
ok: false,
|
|
112
|
-
message:
|
|
115
|
+
message: errorMessage(err)
|
|
113
116
|
};
|
|
114
117
|
}
|
|
115
118
|
}
|
|
@@ -164,13 +167,7 @@ var PostmanTooling = class {
|
|
|
164
167
|
await this.client().specs.updateFile(input.specId, input.filePath, input.content);
|
|
165
168
|
}
|
|
166
169
|
};
|
|
167
|
-
|
|
168
|
-
//#region src/verify-token.ts
|
|
169
|
-
/**
|
|
170
|
-
* `verifyToken` — plugin-level export used by `holocron auth set` +
|
|
171
|
-
* `holocron auth check`. Hits Postman's `/me` endpoint (returns the
|
|
172
|
-
* authenticated user).
|
|
173
|
-
*/
|
|
170
|
+
// src/verify-token.ts
|
|
174
171
|
async function verifyToken(token, opts = {}) {
|
|
175
172
|
const client = createPostmanClient({
|
|
176
173
|
token,
|
|
@@ -186,12 +183,11 @@ async function verifyToken(token, opts = {}) {
|
|
|
186
183
|
} catch (err) {
|
|
187
184
|
return {
|
|
188
185
|
ok: false,
|
|
189
|
-
message:
|
|
186
|
+
message: errorMessage(err)
|
|
190
187
|
};
|
|
191
188
|
}
|
|
192
189
|
}
|
|
193
|
-
|
|
194
|
-
//#region src/index.ts
|
|
190
|
+
// src/index.ts
|
|
195
191
|
function createContext(options) {
|
|
196
192
|
if (!options.workspaceId) throw new Error("@theholocron/holocron-plugin-postman requires `workspaceId` in options");
|
|
197
193
|
let client;
|
|
@@ -217,6 +213,16 @@ function createPlugin(options) {
|
|
|
217
213
|
const ctx = createContext(options);
|
|
218
214
|
return {
|
|
219
215
|
name: "@theholocron/holocron-plugin-postman",
|
|
216
|
+
probes: { connection: connectionProbe({
|
|
217
|
+
provider: "Postman",
|
|
218
|
+
url: options.baseUrl ?? "https://api.getpostman.com",
|
|
219
|
+
fetch: options.fetch,
|
|
220
|
+
token: () => resolveToken(options),
|
|
221
|
+
verify: (token) => verifyToken(token, {
|
|
222
|
+
baseUrl: options.baseUrl,
|
|
223
|
+
fetch: options.fetch
|
|
224
|
+
})
|
|
225
|
+
}) },
|
|
220
226
|
capabilities: { tooling: () => tooling(ctx) }
|
|
221
227
|
};
|
|
222
228
|
}
|
|
@@ -225,5 +231,4 @@ function createPlugin(options) {
|
|
|
225
231
|
* token is supplied or the supplied token is rejected.
|
|
226
232
|
*/
|
|
227
233
|
const AUTH_HINT = "generate a Postman API key at https://postman.co/settings/me/api-keys, then run: holocron auth set postman <KEY>";
|
|
228
|
-
|
|
229
|
-
export { AUTH_HINT, AuthError, PostmanPlanLimitError, PostmanTooling, createContext, createPlugin, createPostmanClient, detectPlanLimit, resolveToken, tooling, verifyToken };
|
|
234
|
+
export { AUTH_HINT, AuthError, PostmanPlanLimitError, PostmanTooling, createContext, createPlugin, createPostmanClient, detectPlanLimit, resolveToken, tokens, tooling, verifyToken };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theholocron/holocron-plugin-postman",
|
|
3
|
-
"version": "5.0.0-alpha.
|
|
3
|
+
"version": "5.0.0-alpha.271",
|
|
4
4
|
"description": "Holocron plugin for Postman. Implements the tooling capability against Postman's REST API — workspace + collection + spec + environment sync.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"holocron",
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"postman",
|
|
9
9
|
"tooling"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://
|
|
11
|
+
"homepage": "https://docs.theholocron.dev/holocron/plugins/postman/",
|
|
12
12
|
"bugs": "https://github.com/theholocron/holocron/issues",
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
15
|
"url": "git+https://github.com/theholocron/holocron.git",
|
|
16
|
-
"directory": "
|
|
16
|
+
"directory": "plugins/holocron-plugin-postman"
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"author": "Newton Koumantzelis",
|
|
@@ -30,27 +30,29 @@
|
|
|
30
30
|
"dist"
|
|
31
31
|
],
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@theholocron/eslint-config": "^8.0.0",
|
|
34
|
-
"@theholocron/http-client": "^1.23.0",
|
|
35
|
-
"@theholocron/postman-client": "^1.23.0",
|
|
36
|
-
"@theholocron/tsconfig": "^8.0.0",
|
|
37
|
-
"@theholocron/tsdown-config": "^8.0.0",
|
|
38
|
-
"@theholocron/vitest-config": "^8.0.0",
|
|
39
33
|
"@types/node": "^26",
|
|
40
|
-
"@vitest/coverage-v8": "^
|
|
34
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
41
35
|
"@vitest/eslint-plugin": "^1.6.27",
|
|
42
36
|
"eslint": "^10.8.1",
|
|
43
37
|
"eslint-plugin-n": "^18.3.0",
|
|
44
38
|
"globals": "^17.11.0",
|
|
45
|
-
"tsdown": "^0.
|
|
46
|
-
"tsx": "4.23.
|
|
39
|
+
"tsdown": "^0.23.3",
|
|
40
|
+
"tsx": "4.23.15",
|
|
47
41
|
"typescript": "^5.9.3",
|
|
48
|
-
"vitest": "^
|
|
49
|
-
"@theholocron/
|
|
42
|
+
"vitest": "^5.0.5",
|
|
43
|
+
"@theholocron/http-client": "^1.58.0-alpha.2",
|
|
44
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.3",
|
|
45
|
+
"@theholocron/misc-utils": "^1.16.1-alpha.1",
|
|
46
|
+
"@theholocron/postman-client": "^1.58.0-alpha.2",
|
|
47
|
+
"@theholocron/tsconfig": "^8.9.0-alpha.3",
|
|
48
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.3",
|
|
49
|
+
"@theholocron/cli": "5.0.0-alpha.271",
|
|
50
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.3"
|
|
50
51
|
},
|
|
51
52
|
"peerDependencies": {
|
|
52
|
-
"@theholocron/
|
|
53
|
-
"@theholocron/
|
|
53
|
+
"@theholocron/misc-utils": "^1.16.0",
|
|
54
|
+
"@theholocron/postman-client": "^1.43.1",
|
|
55
|
+
"@theholocron/cli": "5.0.0-alpha.271"
|
|
54
56
|
},
|
|
55
57
|
"peerDependenciesMeta": {
|
|
56
58
|
"@theholocron/postman-client": {}
|
|
@@ -63,10 +65,10 @@
|
|
|
63
65
|
},
|
|
64
66
|
"scripts": {
|
|
65
67
|
"delivery.build": "tsdown",
|
|
66
|
-
"sourceQuality.staticAnalysis": "
|
|
68
|
+
"sourceQuality.staticAnalysis": "eslint .",
|
|
67
69
|
"test:watch": "vitest",
|
|
68
70
|
"validate": "tsx scripts/validate.mjs",
|
|
69
|
-
"verification.typeSafety": "
|
|
70
|
-
"verification.unitTests": "
|
|
71
|
+
"verification.typeSafety": "tsc --noEmit",
|
|
72
|
+
"verification.unitTests": "vitest run"
|
|
71
73
|
}
|
|
72
74
|
}
|