@xpoz/xpoz 0.2.0 → 0.2.1
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.cjs +50 -3
- package/dist/index.d.cts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +48 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -29,7 +29,8 @@ __export(index_exports, {
|
|
|
29
29
|
VERSION: () => VERSION,
|
|
30
30
|
XpozClient: () => XpozClient,
|
|
31
31
|
XpozConnectionError: () => XpozConnectionError,
|
|
32
|
-
XpozError: () => XpozError
|
|
32
|
+
XpozError: () => XpozError,
|
|
33
|
+
checkForUpdates: () => checkForUpdates
|
|
33
34
|
});
|
|
34
35
|
module.exports = __toCommonJS(index_exports);
|
|
35
36
|
|
|
@@ -283,7 +284,7 @@ function coerce(value) {
|
|
|
283
284
|
}
|
|
284
285
|
|
|
285
286
|
// src/version.ts
|
|
286
|
-
var VERSION = "0.2.
|
|
287
|
+
var VERSION = "0.2.1";
|
|
287
288
|
|
|
288
289
|
// src/mcp/transport.ts
|
|
289
290
|
var USER_AGENT = `xpoz-ts-sdk/${VERSION}`;
|
|
@@ -930,12 +931,53 @@ var RedditNamespace = class extends BaseNamespace {
|
|
|
930
931
|
}
|
|
931
932
|
};
|
|
932
933
|
|
|
934
|
+
// src/versionCheck.ts
|
|
935
|
+
var NPM_REGISTRY_URL = "https://registry.npmjs.org/@xpoz/xpoz/latest";
|
|
936
|
+
var CHECK_TIMEOUT_MS = 3e3;
|
|
937
|
+
var PACKAGE_NAME = "@xpoz/xpoz";
|
|
938
|
+
var hasWarned = false;
|
|
939
|
+
async function checkForUpdates() {
|
|
940
|
+
if (hasWarned) return;
|
|
941
|
+
try {
|
|
942
|
+
const controller = new AbortController();
|
|
943
|
+
const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS);
|
|
944
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
945
|
+
signal: controller.signal,
|
|
946
|
+
headers: { Accept: "application/json" }
|
|
947
|
+
});
|
|
948
|
+
clearTimeout(timeout);
|
|
949
|
+
if (!response.ok) return;
|
|
950
|
+
const data = await response.json();
|
|
951
|
+
const latest = data.version;
|
|
952
|
+
if (!latest || latest === VERSION) return;
|
|
953
|
+
if (isNewerVersion(latest, VERSION)) {
|
|
954
|
+
hasWarned = true;
|
|
955
|
+
console.warn(
|
|
956
|
+
`[xpoz] A newer version of ${PACKAGE_NAME} is available: ${latest} (current: ${VERSION}). Run \`npm install ${PACKAGE_NAME}@latest\` to update.`
|
|
957
|
+
);
|
|
958
|
+
}
|
|
959
|
+
} catch {
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
function isNewerVersion(latestVersion, currentVersion) {
|
|
963
|
+
const latestVersionParts = latestVersion.split(".").map(Number);
|
|
964
|
+
const currentVersionParts = currentVersion.split(".").map(Number);
|
|
965
|
+
for (let i = 0; i < 3; i++) {
|
|
966
|
+
const latestVersionPart = latestVersionParts[i] ?? 0;
|
|
967
|
+
const currentVersionPart = currentVersionParts[i] ?? 0;
|
|
968
|
+
if (latestVersionPart > currentVersionPart) return true;
|
|
969
|
+
if (latestVersionPart < currentVersionPart) return false;
|
|
970
|
+
}
|
|
971
|
+
return false;
|
|
972
|
+
}
|
|
973
|
+
|
|
933
974
|
// src/client.ts
|
|
934
975
|
var XpozClient = class {
|
|
935
976
|
twitter;
|
|
936
977
|
instagram;
|
|
937
978
|
reddit;
|
|
938
979
|
transport;
|
|
980
|
+
versionCheck;
|
|
939
981
|
constructor(options = {}) {
|
|
940
982
|
const apiKey = options.apiKey ?? process.env[ENV_API_KEY];
|
|
941
983
|
if (!apiKey) {
|
|
@@ -943,6 +985,7 @@ var XpozClient = class {
|
|
|
943
985
|
`API key required. Get your token at http://xpoz.ai/get-token?utm_source=ts_sdk&utm_medium=sdk (login \u2192 copy token), then pass it as apiKey or set the ${ENV_API_KEY} environment variable.`
|
|
944
986
|
);
|
|
945
987
|
}
|
|
988
|
+
this.versionCheck = options.versionCheck ?? true;
|
|
946
989
|
const serverUrl = options.serverUrl ?? process.env[ENV_SERVER_URL] ?? DEFAULT_SERVER_URL;
|
|
947
990
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
948
991
|
this.transport = new McpTransport(serverUrl, apiKey);
|
|
@@ -953,6 +996,9 @@ var XpozClient = class {
|
|
|
953
996
|
}
|
|
954
997
|
async connect() {
|
|
955
998
|
await this.transport.connect();
|
|
999
|
+
if (this.versionCheck) {
|
|
1000
|
+
checkForUpdates();
|
|
1001
|
+
}
|
|
956
1002
|
}
|
|
957
1003
|
async close() {
|
|
958
1004
|
await this.transport.close();
|
|
@@ -972,5 +1018,6 @@ var XpozClient = class {
|
|
|
972
1018
|
VERSION,
|
|
973
1019
|
XpozClient,
|
|
974
1020
|
XpozConnectionError,
|
|
975
|
-
XpozError
|
|
1021
|
+
XpozError,
|
|
1022
|
+
checkForUpdates
|
|
976
1023
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -558,10 +558,12 @@ declare class XpozClient {
|
|
|
558
558
|
instagram: InstagramNamespace;
|
|
559
559
|
reddit: RedditNamespace;
|
|
560
560
|
private transport;
|
|
561
|
+
private versionCheck;
|
|
561
562
|
constructor(options?: {
|
|
562
563
|
apiKey?: string;
|
|
563
564
|
serverUrl?: string;
|
|
564
565
|
timeoutMs?: number;
|
|
566
|
+
versionCheck?: boolean;
|
|
565
567
|
});
|
|
566
568
|
connect(): Promise<void>;
|
|
567
569
|
close(): Promise<void>;
|
|
@@ -592,6 +594,8 @@ declare class OperationCancelledError extends XpozError {
|
|
|
592
594
|
constructor(operationId: string);
|
|
593
595
|
}
|
|
594
596
|
|
|
595
|
-
declare const VERSION = "0.2.
|
|
597
|
+
declare const VERSION = "0.2.1";
|
|
596
598
|
|
|
597
|
-
|
|
599
|
+
declare function checkForUpdates(): Promise<void>;
|
|
600
|
+
|
|
601
|
+
export { AuthenticationError, type InstagramComment, type InstagramPost, type InstagramUser, OperationCancelledError, OperationFailedError, OperationTimeoutError, PaginatedResult, type PaginationInfo, type RedditComment, type RedditPost, type RedditPostWithComments, type RedditSubreddit, type RedditUser, ResponseType, type SubredditWithPosts, type TwitterPost, type TwitterUser, VERSION, XpozClient, XpozConnectionError, XpozError, checkForUpdates };
|
package/dist/index.d.ts
CHANGED
|
@@ -558,10 +558,12 @@ declare class XpozClient {
|
|
|
558
558
|
instagram: InstagramNamespace;
|
|
559
559
|
reddit: RedditNamespace;
|
|
560
560
|
private transport;
|
|
561
|
+
private versionCheck;
|
|
561
562
|
constructor(options?: {
|
|
562
563
|
apiKey?: string;
|
|
563
564
|
serverUrl?: string;
|
|
564
565
|
timeoutMs?: number;
|
|
566
|
+
versionCheck?: boolean;
|
|
565
567
|
});
|
|
566
568
|
connect(): Promise<void>;
|
|
567
569
|
close(): Promise<void>;
|
|
@@ -592,6 +594,8 @@ declare class OperationCancelledError extends XpozError {
|
|
|
592
594
|
constructor(operationId: string);
|
|
593
595
|
}
|
|
594
596
|
|
|
595
|
-
declare const VERSION = "0.2.
|
|
597
|
+
declare const VERSION = "0.2.1";
|
|
596
598
|
|
|
597
|
-
|
|
599
|
+
declare function checkForUpdates(): Promise<void>;
|
|
600
|
+
|
|
601
|
+
export { AuthenticationError, type InstagramComment, type InstagramPost, type InstagramUser, OperationCancelledError, OperationFailedError, OperationTimeoutError, PaginatedResult, type PaginationInfo, type RedditComment, type RedditPost, type RedditPostWithComments, type RedditSubreddit, type RedditUser, ResponseType, type SubredditWithPosts, type TwitterPost, type TwitterUser, VERSION, XpozClient, XpozConnectionError, XpozError, checkForUpdates };
|
package/dist/index.js
CHANGED
|
@@ -248,7 +248,7 @@ function coerce(value) {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// src/version.ts
|
|
251
|
-
var VERSION = "0.2.
|
|
251
|
+
var VERSION = "0.2.1";
|
|
252
252
|
|
|
253
253
|
// src/mcp/transport.ts
|
|
254
254
|
var USER_AGENT = `xpoz-ts-sdk/${VERSION}`;
|
|
@@ -895,12 +895,53 @@ var RedditNamespace = class extends BaseNamespace {
|
|
|
895
895
|
}
|
|
896
896
|
};
|
|
897
897
|
|
|
898
|
+
// src/versionCheck.ts
|
|
899
|
+
var NPM_REGISTRY_URL = "https://registry.npmjs.org/@xpoz/xpoz/latest";
|
|
900
|
+
var CHECK_TIMEOUT_MS = 3e3;
|
|
901
|
+
var PACKAGE_NAME = "@xpoz/xpoz";
|
|
902
|
+
var hasWarned = false;
|
|
903
|
+
async function checkForUpdates() {
|
|
904
|
+
if (hasWarned) return;
|
|
905
|
+
try {
|
|
906
|
+
const controller = new AbortController();
|
|
907
|
+
const timeout = setTimeout(() => controller.abort(), CHECK_TIMEOUT_MS);
|
|
908
|
+
const response = await fetch(NPM_REGISTRY_URL, {
|
|
909
|
+
signal: controller.signal,
|
|
910
|
+
headers: { Accept: "application/json" }
|
|
911
|
+
});
|
|
912
|
+
clearTimeout(timeout);
|
|
913
|
+
if (!response.ok) return;
|
|
914
|
+
const data = await response.json();
|
|
915
|
+
const latest = data.version;
|
|
916
|
+
if (!latest || latest === VERSION) return;
|
|
917
|
+
if (isNewerVersion(latest, VERSION)) {
|
|
918
|
+
hasWarned = true;
|
|
919
|
+
console.warn(
|
|
920
|
+
`[xpoz] A newer version of ${PACKAGE_NAME} is available: ${latest} (current: ${VERSION}). Run \`npm install ${PACKAGE_NAME}@latest\` to update.`
|
|
921
|
+
);
|
|
922
|
+
}
|
|
923
|
+
} catch {
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
function isNewerVersion(latestVersion, currentVersion) {
|
|
927
|
+
const latestVersionParts = latestVersion.split(".").map(Number);
|
|
928
|
+
const currentVersionParts = currentVersion.split(".").map(Number);
|
|
929
|
+
for (let i = 0; i < 3; i++) {
|
|
930
|
+
const latestVersionPart = latestVersionParts[i] ?? 0;
|
|
931
|
+
const currentVersionPart = currentVersionParts[i] ?? 0;
|
|
932
|
+
if (latestVersionPart > currentVersionPart) return true;
|
|
933
|
+
if (latestVersionPart < currentVersionPart) return false;
|
|
934
|
+
}
|
|
935
|
+
return false;
|
|
936
|
+
}
|
|
937
|
+
|
|
898
938
|
// src/client.ts
|
|
899
939
|
var XpozClient = class {
|
|
900
940
|
twitter;
|
|
901
941
|
instagram;
|
|
902
942
|
reddit;
|
|
903
943
|
transport;
|
|
944
|
+
versionCheck;
|
|
904
945
|
constructor(options = {}) {
|
|
905
946
|
const apiKey = options.apiKey ?? process.env[ENV_API_KEY];
|
|
906
947
|
if (!apiKey) {
|
|
@@ -908,6 +949,7 @@ var XpozClient = class {
|
|
|
908
949
|
`API key required. Get your token at http://xpoz.ai/get-token?utm_source=ts_sdk&utm_medium=sdk (login \u2192 copy token), then pass it as apiKey or set the ${ENV_API_KEY} environment variable.`
|
|
909
950
|
);
|
|
910
951
|
}
|
|
952
|
+
this.versionCheck = options.versionCheck ?? true;
|
|
911
953
|
const serverUrl = options.serverUrl ?? process.env[ENV_SERVER_URL] ?? DEFAULT_SERVER_URL;
|
|
912
954
|
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
913
955
|
this.transport = new McpTransport(serverUrl, apiKey);
|
|
@@ -918,6 +960,9 @@ var XpozClient = class {
|
|
|
918
960
|
}
|
|
919
961
|
async connect() {
|
|
920
962
|
await this.transport.connect();
|
|
963
|
+
if (this.versionCheck) {
|
|
964
|
+
checkForUpdates();
|
|
965
|
+
}
|
|
921
966
|
}
|
|
922
967
|
async close() {
|
|
923
968
|
await this.transport.close();
|
|
@@ -936,5 +981,6 @@ export {
|
|
|
936
981
|
VERSION,
|
|
937
982
|
XpozClient,
|
|
938
983
|
XpozConnectionError,
|
|
939
|
-
XpozError
|
|
984
|
+
XpozError,
|
|
985
|
+
checkForUpdates
|
|
940
986
|
};
|