@postplus/cli 0.1.24 → 0.1.26
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/build/auth-lifecycle.js
CHANGED
|
@@ -3,6 +3,7 @@ import { clearAuthState, generateAuthStatusReport } from './auth.js';
|
|
|
3
3
|
import { buildPostPlusClientCompatibilityHeaders, formatPostPlusCompatibilityError, } from './client-compatibility.js';
|
|
4
4
|
import { requireHostedBaseUrl } from './hosted-release.js';
|
|
5
5
|
import { resolveCliSessionTokenState } from './local-state.js';
|
|
6
|
+
import { readSubscriptionStatusField } from './subscription-status.js';
|
|
6
7
|
export async function refreshRemoteAuth() {
|
|
7
8
|
const refreshed = await refreshRemoteAuthSession();
|
|
8
9
|
return {
|
|
@@ -22,7 +23,7 @@ export function formatAuthRefreshReport(report) {
|
|
|
22
23
|
`PostPlus Cloud: ${report.apiBaseUrl}`,
|
|
23
24
|
`Account: ${report.accountId}`,
|
|
24
25
|
`User: ${report.userEmail ?? report.userId}`,
|
|
25
|
-
`Subscription: ${report.
|
|
26
|
+
`Subscription: ${readSubscriptionStatusField(report).label}`,
|
|
26
27
|
].join('\n');
|
|
27
28
|
}
|
|
28
29
|
export async function revokeRemoteAuth() {
|
package/build/auth-validate.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveFreshRemoteAuth } from './auth-session.js';
|
|
2
2
|
import { buildPostPlusClientCompatibilityHeaders, formatPostPlusCompatibilityError, } from './client-compatibility.js';
|
|
3
|
+
import { readSubscriptionStatusField } from './subscription-status.js';
|
|
3
4
|
export async function validateRemoteAuth() {
|
|
4
5
|
let auth = await resolveFreshRemoteAuth();
|
|
5
6
|
let response = await fetchWhoami(auth);
|
|
@@ -19,15 +20,20 @@ export async function validateRemoteAuth() {
|
|
|
19
20
|
? payload.error
|
|
20
21
|
: 'Failed to validate remote PostPlus auth.');
|
|
21
22
|
}
|
|
22
|
-
const
|
|
23
|
+
const hasSubscriptionStatus = Object.prototype.hasOwnProperty.call(payload, 'subscriptionStatus');
|
|
24
|
+
const accountId = readRequiredString(payload, 'accountId');
|
|
25
|
+
const userId = readRequiredString(payload, 'userId');
|
|
26
|
+
const userEmail = readNullableString(payload, 'userEmail');
|
|
23
27
|
return {
|
|
24
|
-
accountId
|
|
28
|
+
accountId,
|
|
25
29
|
apiBaseUrl: auth.apiBaseUrl,
|
|
26
30
|
ok: true,
|
|
27
31
|
source: auth.source,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
...(hasSubscriptionStatus
|
|
33
|
+
? { subscriptionStatus: payload.subscriptionStatus }
|
|
34
|
+
: {}),
|
|
35
|
+
userEmail,
|
|
36
|
+
userId,
|
|
31
37
|
};
|
|
32
38
|
}
|
|
33
39
|
export function formatAuthValidateReport(report) {
|
|
@@ -38,7 +44,7 @@ export function formatAuthValidateReport(report) {
|
|
|
38
44
|
`PostPlus Cloud: ${report.apiBaseUrl}`,
|
|
39
45
|
`Account: ${report.accountId}`,
|
|
40
46
|
`User: ${report.userEmail ?? report.userId}`,
|
|
41
|
-
`Subscription: ${report.
|
|
47
|
+
`Subscription: ${readSubscriptionStatusField(report).label}`,
|
|
42
48
|
].join('\n');
|
|
43
49
|
}
|
|
44
50
|
async function fetchWhoami(input) {
|
|
@@ -53,3 +59,20 @@ async function fetchWhoami(input) {
|
|
|
53
59
|
signal: AbortSignal.timeout(15000),
|
|
54
60
|
});
|
|
55
61
|
}
|
|
62
|
+
function readRequiredString(payload, fieldName) {
|
|
63
|
+
const value = payload[fieldName];
|
|
64
|
+
if (typeof value !== 'string' || !value.trim()) {
|
|
65
|
+
throw new Error(`Invalid PostPlus auth response: ${fieldName} must be a non-empty string.`);
|
|
66
|
+
}
|
|
67
|
+
return value.trim();
|
|
68
|
+
}
|
|
69
|
+
function readNullableString(payload, fieldName) {
|
|
70
|
+
const value = payload[fieldName];
|
|
71
|
+
if (value === null) {
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
if (typeof value !== 'string') {
|
|
75
|
+
throw new Error(`Invalid PostPlus auth response: ${fieldName} must be a string or null.`);
|
|
76
|
+
}
|
|
77
|
+
return value;
|
|
78
|
+
}
|
|
@@ -60,6 +60,7 @@ export function formatPostPlusClientUpgradeError(payload) {
|
|
|
60
60
|
typeof record.error === 'string' && record.error.trim().length > 0
|
|
61
61
|
? record.error.trim()
|
|
62
62
|
: 'Your PostPlus CLI or PostPlus skills are out of date.',
|
|
63
|
+
'If you are an agent, run both update commands now before retrying.',
|
|
63
64
|
`Update CLI: ${cliCommand}.`,
|
|
64
65
|
`Update skills: ${skillsCommand}.`,
|
|
65
66
|
restart.trim(),
|
package/build/doctor.js
CHANGED
|
@@ -2,6 +2,7 @@ import { resolveFreshRemoteAuth, } from './auth-session.js';
|
|
|
2
2
|
import { buildPostPlusClientCompatibilityHeaders, formatPostPlusCompatibilityError, } from './client-compatibility.js';
|
|
3
3
|
import { resolveHostedBaseUrl } from './hosted-release.js';
|
|
4
4
|
import { formatLocalDependencyReport, generateLocalDependencyReport, } from './local-dependencies.js';
|
|
5
|
+
import { readSubscriptionStatusField } from './subscription-status.js';
|
|
5
6
|
function createPass(id, label, detail, severity = 'required') {
|
|
6
7
|
return {
|
|
7
8
|
id,
|
|
@@ -104,9 +105,7 @@ async function checkRemoteAuth(input) {
|
|
|
104
105
|
: typeof payload.userId === 'string'
|
|
105
106
|
? payload.userId
|
|
106
107
|
: 'unknown';
|
|
107
|
-
const subscription =
|
|
108
|
-
? payload.subscriptionStatus
|
|
109
|
-
: 'unknown';
|
|
108
|
+
const subscription = readSubscriptionStatusField(payload).label;
|
|
110
109
|
return createPass('remote_auth', 'Remote auth', `Account ${accountId}; user ${user}; subscription ${subscription}`);
|
|
111
110
|
}
|
|
112
111
|
catch (error) {
|
|
@@ -137,9 +136,7 @@ async function checkHostedCapabilities(input) {
|
|
|
137
136
|
if (payload.ok !== true || failedLabels.length > 0) {
|
|
138
137
|
return createFail('hosted_capabilities', 'Hosted capabilities', `Not ready: ${failedLabels.join(', ') || 'unknown capability failure'}`, 'Check PostPlus Cloud provider configuration and subscription state.');
|
|
139
138
|
}
|
|
140
|
-
const subscription =
|
|
141
|
-
? payload.subscriptionStatus
|
|
142
|
-
: 'unknown';
|
|
139
|
+
const subscription = readSubscriptionStatusField(payload).label;
|
|
143
140
|
return createPass('hosted_capabilities', 'Hosted capabilities', `Ready (${capabilities.length} capability checks passed; subscription ${subscription})`);
|
|
144
141
|
}
|
|
145
142
|
catch (error) {
|
|
@@ -69,9 +69,12 @@ async function checkLocalDependency(dependency, skillIds, runDependencyCheck) {
|
|
|
69
69
|
function buildLocalDependencyCommand(dependency) {
|
|
70
70
|
const parts = dependency.split(':');
|
|
71
71
|
if (parts.length === 1) {
|
|
72
|
+
const args = dependency === 'ffmpeg' || dependency === 'ffprobe'
|
|
73
|
+
? ['-version']
|
|
74
|
+
: ['--version'];
|
|
72
75
|
return {
|
|
73
76
|
command: dependency,
|
|
74
|
-
args
|
|
77
|
+
args,
|
|
75
78
|
};
|
|
76
79
|
}
|
|
77
80
|
const [runtime, moduleName] = parts;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export function readSubscriptionStatusField(payload, fieldName = 'subscriptionStatus') {
|
|
2
|
+
if (!Object.prototype.hasOwnProperty.call(payload, fieldName)) {
|
|
3
|
+
return {
|
|
4
|
+
label: 'unknown',
|
|
5
|
+
state: 'missing',
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
const value = payload[fieldName];
|
|
9
|
+
if (value === null) {
|
|
10
|
+
return {
|
|
11
|
+
label: 'none',
|
|
12
|
+
state: 'none',
|
|
13
|
+
value: null,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
if (typeof value === 'string') {
|
|
17
|
+
return {
|
|
18
|
+
label: value,
|
|
19
|
+
state: 'string',
|
|
20
|
+
value,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
label: 'invalid',
|
|
25
|
+
state: 'invalid',
|
|
26
|
+
};
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@postplus/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.26",
|
|
4
4
|
"packageManager": "pnpm@10.30.3+sha512.c961d1e0a2d8e354ecaa5166b822516668b7f44cb5bd95122d590dd81922f606f5473b6d23ec4a5be05e7fcd18e8488d47d978bbe981872f1145d06e9a740017",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "PostPlus CLI for PostPlus Cloud auth, status, and diagnostics.",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"build/skill-catalog.js",
|
|
22
22
|
"build/skill-management.js",
|
|
23
23
|
"build/status.js",
|
|
24
|
+
"build/subscription-status.js",
|
|
24
25
|
"build/update-check.js",
|
|
25
26
|
"LICENSE",
|
|
26
27
|
"NOTICE",
|