@theholocron/holocron-plugin-postman 5.0.0-alpha.27 → 5.0.0-alpha.270
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 +14 -33
- package/dist/index.mjs +20 -17
- package/package.json +21 -19
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { AuthError, ResolveTokenInput, Tooling, ToolingDoctorReport } from "@theholocron/cli";
|
|
1
|
+
import { AuthError, 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
|
-
declare const resolveToken: (input?: ResolveTokenInput) => string;
|
|
5
|
-
//#endregion
|
|
6
|
-
//#region src/capabilities/tooling.d.ts
|
|
3
|
+
export declare const resolveToken: (input?: ResolveTokenInput) => string;
|
|
7
4
|
interface PostmanToolingOptions {
|
|
8
5
|
workspaceId: string;
|
|
9
6
|
/** Local OpenAPI JSON path (relative to repoRoot). */
|
|
@@ -17,7 +14,7 @@ interface PostmanToolingOptions {
|
|
|
17
14
|
/** Working repo root. Defaults to process.cwd(). */
|
|
18
15
|
repoRoot?: string;
|
|
19
16
|
}
|
|
20
|
-
declare class PostmanTooling implements Tooling {
|
|
17
|
+
export declare class PostmanTooling implements Tooling {
|
|
21
18
|
private readonly client;
|
|
22
19
|
readonly key: "tooling";
|
|
23
20
|
readonly providerName = "postman";
|
|
@@ -69,30 +66,12 @@ declare class PostmanTooling implements Tooling {
|
|
|
69
66
|
content: string;
|
|
70
67
|
}): Promise<void>;
|
|
71
68
|
}
|
|
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
69
|
interface VerifyTokenOptions {
|
|
89
70
|
baseUrl?: string;
|
|
90
71
|
fetch?: typeof fetch;
|
|
91
72
|
}
|
|
92
|
-
declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult>;
|
|
93
|
-
|
|
94
|
-
//#region src/index.d.ts
|
|
95
|
-
interface PostmanPluginOptions extends ResolveTokenInput, PostmanToolingOptions {
|
|
73
|
+
export declare function verifyToken(token: string, opts?: VerifyTokenOptions): Promise<VerifyTokenResult$1>;
|
|
74
|
+
export interface PostmanPluginOptions extends ResolveTokenInput, PostmanToolingOptions {
|
|
96
75
|
/** Working repo root. Used to resolve relative paths in specFile/envFiles. Defaults to process.cwd(). */
|
|
97
76
|
repoRoot?: string;
|
|
98
77
|
/** Override base URL for tests. */
|
|
@@ -100,14 +79,17 @@ interface PostmanPluginOptions extends ResolveTokenInput, PostmanToolingOptions
|
|
|
100
79
|
/** Override `fetch` for tests. */
|
|
101
80
|
fetch?: typeof fetch;
|
|
102
81
|
}
|
|
103
|
-
interface PluginContext {
|
|
82
|
+
export interface PluginContext {
|
|
104
83
|
options: PostmanPluginOptions;
|
|
105
84
|
client: () => PostmanClient;
|
|
106
85
|
}
|
|
107
|
-
declare function createContext(options: PostmanPluginOptions): PluginContext;
|
|
108
|
-
declare function tooling(ctx: PluginContext): Tooling;
|
|
109
|
-
declare function createPlugin(options: PostmanPluginOptions): {
|
|
86
|
+
export declare function createContext(options: PostmanPluginOptions): PluginContext;
|
|
87
|
+
export declare function tooling(ctx: PluginContext): Tooling;
|
|
88
|
+
export declare function createPlugin(options: PostmanPluginOptions): {
|
|
110
89
|
name: string;
|
|
90
|
+
probes: {
|
|
91
|
+
connection: import("@theholocron/cli").Probe;
|
|
92
|
+
};
|
|
111
93
|
capabilities: {
|
|
112
94
|
tooling: () => Tooling;
|
|
113
95
|
};
|
|
@@ -116,6 +98,5 @@ declare function createPlugin(options: PostmanPluginOptions): {
|
|
|
116
98
|
* One-line hint printed by `holocron auth set postman` when no
|
|
117
99
|
* token is supplied or the supplied token is rejected.
|
|
118
100
|
*/
|
|
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 };
|
|
101
|
+
export declare const AUTH_HINT: string;
|
|
102
|
+
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,16 @@
|
|
|
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
|
-
//#region src/capabilities/tooling.ts
|
|
13
|
+
// src/capabilities/tooling.ts
|
|
14
14
|
/**
|
|
15
15
|
* `tooling` capability for Postman.
|
|
16
16
|
*
|
|
@@ -77,7 +77,8 @@ var PostmanTooling = class {
|
|
|
77
77
|
spec: specObj
|
|
78
78
|
});
|
|
79
79
|
for (const file of this.opts.envFiles ?? []) {
|
|
80
|
-
const
|
|
80
|
+
const envPath = resolve(this.repoRoot, file);
|
|
81
|
+
const envText = await readFile(envPath, "utf8");
|
|
81
82
|
const envObj = JSON.parse(envText);
|
|
82
83
|
if (!envObj.name) throw new Error(`Postman environment file ${file} is missing a "name" field`);
|
|
83
84
|
const existing = await this.findEnvironmentByName({
|
|
@@ -109,7 +110,7 @@ var PostmanTooling = class {
|
|
|
109
110
|
} catch (err) {
|
|
110
111
|
return {
|
|
111
112
|
ok: false,
|
|
112
|
-
message:
|
|
113
|
+
message: errorMessage(err)
|
|
113
114
|
};
|
|
114
115
|
}
|
|
115
116
|
}
|
|
@@ -164,13 +165,7 @@ var PostmanTooling = class {
|
|
|
164
165
|
await this.client().specs.updateFile(input.specId, input.filePath, input.content);
|
|
165
166
|
}
|
|
166
167
|
};
|
|
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
|
-
*/
|
|
168
|
+
// src/verify-token.ts
|
|
174
169
|
async function verifyToken(token, opts = {}) {
|
|
175
170
|
const client = createPostmanClient({
|
|
176
171
|
token,
|
|
@@ -186,12 +181,11 @@ async function verifyToken(token, opts = {}) {
|
|
|
186
181
|
} catch (err) {
|
|
187
182
|
return {
|
|
188
183
|
ok: false,
|
|
189
|
-
message:
|
|
184
|
+
message: errorMessage(err)
|
|
190
185
|
};
|
|
191
186
|
}
|
|
192
187
|
}
|
|
193
|
-
|
|
194
|
-
//#region src/index.ts
|
|
188
|
+
// src/index.ts
|
|
195
189
|
function createContext(options) {
|
|
196
190
|
if (!options.workspaceId) throw new Error("@theholocron/holocron-plugin-postman requires `workspaceId` in options");
|
|
197
191
|
let client;
|
|
@@ -217,6 +211,16 @@ function createPlugin(options) {
|
|
|
217
211
|
const ctx = createContext(options);
|
|
218
212
|
return {
|
|
219
213
|
name: "@theholocron/holocron-plugin-postman",
|
|
214
|
+
probes: { connection: connectionProbe({
|
|
215
|
+
provider: "Postman",
|
|
216
|
+
url: options.baseUrl ?? "https://api.getpostman.com",
|
|
217
|
+
fetch: options.fetch,
|
|
218
|
+
token: () => resolveToken(options),
|
|
219
|
+
verify: (token) => verifyToken(token, {
|
|
220
|
+
baseUrl: options.baseUrl,
|
|
221
|
+
fetch: options.fetch
|
|
222
|
+
})
|
|
223
|
+
}) },
|
|
220
224
|
capabilities: { tooling: () => tooling(ctx) }
|
|
221
225
|
};
|
|
222
226
|
}
|
|
@@ -225,5 +229,4 @@ function createPlugin(options) {
|
|
|
225
229
|
* token is supplied or the supplied token is rejected.
|
|
226
230
|
*/
|
|
227
231
|
const AUTH_HINT = "generate a Postman API key at https://postman.co/settings/me/api-keys, then run: holocron auth set postman <KEY>";
|
|
228
|
-
//#endregion
|
|
229
232
|
export { AUTH_HINT, AuthError, PostmanPlanLimitError, PostmanTooling, createContext, createPlugin, createPostmanClient, detectPlanLimit, resolveToken, 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.270",
|
|
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/cli": "5.0.0-alpha.
|
|
42
|
+
"vitest": "^5.0.5",
|
|
43
|
+
"@theholocron/cli": "5.0.0-alpha.270",
|
|
44
|
+
"@theholocron/misc-utils": "^1.16.1-alpha.1",
|
|
45
|
+
"@theholocron/eslint-config": "^8.9.0-alpha.3",
|
|
46
|
+
"@theholocron/postman-client": "^1.58.0-alpha.2",
|
|
47
|
+
"@theholocron/http-client": "^1.58.0-alpha.2",
|
|
48
|
+
"@theholocron/tsdown-config": "^8.9.0-alpha.3",
|
|
49
|
+
"@theholocron/vitest-config": "^8.9.0-alpha.3",
|
|
50
|
+
"@theholocron/tsconfig": "^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.270"
|
|
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
|
}
|