notte-sdk 0.0.7 → 0.0.9
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 +122 -2
- package/dist/index.d.ts +122 -2
- package/dist/index.js +117 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +115 -3
- package/dist/index.mjs.map +1 -1
- package/dist/proxy/core.js +2 -0
- package/dist/proxy/core.js.map +1 -1
- package/dist/proxy/core.mjs +2 -0
- package/dist/proxy/core.mjs.map +1 -1
- package/dist/proxy/next.js +2 -0
- package/dist/proxy/next.js.map +1 -1
- package/dist/proxy/next.mjs +2 -0
- package/dist/proxy/next.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -5,6 +5,104 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
5
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
+
// src/version.ts
|
|
9
|
+
var SDK_VERSION = true ? "0.0.9" : "dev";
|
|
10
|
+
var SDK_PACKAGE_NAME = true ? "notte-sdk" : "notte-sdk";
|
|
11
|
+
|
|
12
|
+
// src/version-check.ts
|
|
13
|
+
var DISABLE_ENV = "NOTTE_SDK_DISABLE_VERSION_CHECK";
|
|
14
|
+
var VERSION_CHECK_TIMEOUT_MS = 1500;
|
|
15
|
+
var hasStartedVersionCheck = false;
|
|
16
|
+
function startVersionCheck() {
|
|
17
|
+
if (hasStartedVersionCheck || !shouldCheckVersion()) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
hasStartedVersionCheck = true;
|
|
21
|
+
const timer = setTimeout(() => {
|
|
22
|
+
void checkForLatestVersion().catch(() => void 0);
|
|
23
|
+
}, 0);
|
|
24
|
+
timer.unref?.();
|
|
25
|
+
}
|
|
26
|
+
async function checkForLatestVersion(options = {}) {
|
|
27
|
+
const currentVersion = options.currentVersion ?? SDK_VERSION;
|
|
28
|
+
const packageName = options.packageName ?? SDK_PACKAGE_NAME;
|
|
29
|
+
const fetchFn = options.fetchFn ?? globalThis.fetch;
|
|
30
|
+
const warnFn = options.warnFn ?? console.warn;
|
|
31
|
+
const env = options.env ?? getEnv();
|
|
32
|
+
if (!shouldCheckVersion(currentVersion, fetchFn, env)) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
const latestVersion = await fetchLatestVersion(packageName, fetchFn);
|
|
36
|
+
if (!latestVersion || !isVersionGreater(latestVersion, currentVersion)) {
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
warnFn(
|
|
40
|
+
`[${packageName}] A newer version is available: ${currentVersion} -> ${latestVersion}. Update with: npm install ${packageName}@latest`
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
function shouldCheckVersion(currentVersion = SDK_VERSION, fetchFn = globalThis.fetch, env = getEnv()) {
|
|
44
|
+
if (!fetchFn || !env || env[DISABLE_ENV] || env.NODE_ENV === "test" || env.VITEST || env.CI) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return isPublishedVersion(currentVersion);
|
|
48
|
+
}
|
|
49
|
+
async function fetchLatestVersion(packageName, fetchFn) {
|
|
50
|
+
const controller = typeof AbortController !== "undefined" ? new AbortController() : void 0;
|
|
51
|
+
const timeout = controller ? setTimeout(() => controller.abort(), VERSION_CHECK_TIMEOUT_MS) : void 0;
|
|
52
|
+
timeout?.unref?.();
|
|
53
|
+
try {
|
|
54
|
+
const response = await fetchFn(`https://registry.npmjs.org/${encodeURIComponent(packageName)}/latest`, {
|
|
55
|
+
headers: {
|
|
56
|
+
accept: "application/json"
|
|
57
|
+
},
|
|
58
|
+
signal: controller?.signal
|
|
59
|
+
});
|
|
60
|
+
if (!response.ok) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
const payload = await response.json();
|
|
64
|
+
return typeof payload.version === "string" ? payload.version : void 0;
|
|
65
|
+
} catch {
|
|
66
|
+
return void 0;
|
|
67
|
+
} finally {
|
|
68
|
+
if (timeout) {
|
|
69
|
+
clearTimeout(timeout);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function isPublishedVersion(version) {
|
|
74
|
+
return /^\d+\.\d+\.\d+/.test(version) && !version.includes("dev");
|
|
75
|
+
}
|
|
76
|
+
function isVersionGreater(candidate, current) {
|
|
77
|
+
const candidateVersion = parseSemver(candidate);
|
|
78
|
+
const currentVersion = parseSemver(current);
|
|
79
|
+
if (!candidateVersion || !currentVersion) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
for (let index = 0; index < 3; index += 1) {
|
|
83
|
+
if (candidateVersion.parts[index] > currentVersion.parts[index]) {
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
if (candidateVersion.parts[index] < currentVersion.parts[index]) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return currentVersion.prerelease.length > 0 && candidateVersion.prerelease.length === 0;
|
|
91
|
+
}
|
|
92
|
+
function parseSemver(version) {
|
|
93
|
+
const match = version.match(/^(\d+)\.(\d+)\.(\d+)(?:-([^+]+))?/);
|
|
94
|
+
if (!match) {
|
|
95
|
+
return void 0;
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
parts: [Number(match[1]), Number(match[2]), Number(match[3])],
|
|
99
|
+
prerelease: match[4] ?? ""
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
function getEnv() {
|
|
103
|
+
return typeof process !== "undefined" ? process.env : void 0;
|
|
104
|
+
}
|
|
105
|
+
|
|
8
106
|
// src/lib/client/core/bodySerializer.gen.ts
|
|
9
107
|
var serializeFormDataPair = (data, key, value) => {
|
|
10
108
|
if (typeof value === "string" || value instanceof Blob) {
|
|
@@ -1140,6 +1238,20 @@ var profileGet = (options) => (options.client ?? client).get({
|
|
|
1140
1238
|
url: "/profiles/{profile_id}",
|
|
1141
1239
|
...options
|
|
1142
1240
|
});
|
|
1241
|
+
var profileCookiesGet = (options) => (options.client ?? client).get({
|
|
1242
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1243
|
+
url: "/profiles/{profile_id}/cookies",
|
|
1244
|
+
...options
|
|
1245
|
+
});
|
|
1246
|
+
var profileCookiesSet = (options) => (options.client ?? client).post({
|
|
1247
|
+
security: [{ scheme: "bearer", type: "http" }],
|
|
1248
|
+
url: "/profiles/{profile_id}/cookies",
|
|
1249
|
+
...options,
|
|
1250
|
+
headers: {
|
|
1251
|
+
"Content-Type": "application/json",
|
|
1252
|
+
...options.headers
|
|
1253
|
+
}
|
|
1254
|
+
});
|
|
1143
1255
|
var profileList = (options) => (options?.client ?? client).get({
|
|
1144
1256
|
security: [{ scheme: "bearer", type: "http" }],
|
|
1145
1257
|
url: "/profiles",
|
|
@@ -2574,9 +2686,6 @@ var NottePersona = class {
|
|
|
2574
2686
|
}
|
|
2575
2687
|
};
|
|
2576
2688
|
|
|
2577
|
-
// src/version.ts
|
|
2578
|
-
var SDK_VERSION = true ? "0.0.7" : "dev";
|
|
2579
|
-
|
|
2580
2689
|
// src/functions.ts
|
|
2581
2690
|
var NotteFunction = class {
|
|
2582
2691
|
constructor(client2, options) {
|
|
@@ -2807,6 +2916,7 @@ var NotteProxyAuthError = class extends Error {
|
|
|
2807
2916
|
};
|
|
2808
2917
|
|
|
2809
2918
|
// src/index.ts
|
|
2919
|
+
startVersionCheck();
|
|
2810
2920
|
var createClient2 = (config) => {
|
|
2811
2921
|
if (config?.baseUrl) {
|
|
2812
2922
|
client.setConfig({ baseUrl: config.baseUrl });
|
|
@@ -2875,6 +2985,8 @@ export {
|
|
|
2875
2985
|
personaEmailsList,
|
|
2876
2986
|
personaGet,
|
|
2877
2987
|
personaSmsList,
|
|
2988
|
+
profileCookiesGet,
|
|
2989
|
+
profileCookiesSet,
|
|
2878
2990
|
profileCreate,
|
|
2879
2991
|
profileDelete,
|
|
2880
2992
|
profileGet,
|