@hybrd/utils 1.0.10 → 1.1.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/.cache/tsbuildinfo.json +1 -1
- package/.turbo/turbo-build.log +20 -2
- package/dist/index.cjs +261 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +152 -0
- package/dist/index.d.ts +152 -10
- package/dist/index.js +208 -9
- package/dist/index.js.map +1 -0
- package/package.json +7 -5
- package/tsconfig.json +8 -4
- package/tsup.config.ts +14 -0
- package/.turbo/turbo-lint$colon$fix.log +0 -6
- package/.turbo/turbo-lint.log +0 -6
- package/.turbo/turbo-typecheck.log +0 -5
- package/dist/index.d.ts.map +0 -1
- package/dist/lib/array.d.ts +0 -25
- package/dist/lib/array.d.ts.map +0 -1
- package/dist/lib/array.js +0 -32
- package/dist/lib/cloudflare.d.ts +0 -22
- package/dist/lib/cloudflare.d.ts.map +0 -1
- package/dist/lib/cloudflare.js +0 -53
- package/dist/lib/date.d.ts +0 -17
- package/dist/lib/date.d.ts.map +0 -1
- package/dist/lib/date.js +0 -37
- package/dist/lib/markdown.d.ts +0 -7
- package/dist/lib/markdown.d.ts.map +0 -1
- package/dist/lib/markdown.js +0 -11
- package/dist/lib/object.d.ts +0 -15
- package/dist/lib/object.d.ts.map +0 -1
- package/dist/lib/object.js +0 -42
- package/dist/lib/storage.d.ts +0 -24
- package/dist/lib/storage.d.ts.map +0 -1
- package/dist/lib/storage.js +0 -50
- package/dist/lib/string.d.ts +0 -11
- package/dist/lib/string.d.ts.map +0 -1
- package/dist/lib/string.js +0 -12
- package/dist/lib/urls.d.ts +0 -28
- package/dist/lib/urls.d.ts.map +0 -1
- package/dist/lib/urls.js +0 -36
- package/dist/lib/uuid.d.ts +0 -2
- package/dist/lib/uuid.d.ts.map +0 -1
- package/dist/lib/uuid.js +0 -6
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources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gB,oBAAoB,IAAI,cAAc,GAAG,IAAI,CAU5D"}
|
package/dist/lib/storage.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
export class R2StorageAdapter {
|
|
3
|
-
bucket;
|
|
4
|
-
constructor(bucket) {
|
|
5
|
-
this.bucket = bucket;
|
|
6
|
-
}
|
|
7
|
-
async uploadFile(localPath, remotePath) {
|
|
8
|
-
const fileData = await fs.readFile(localPath);
|
|
9
|
-
await this.bucket.put(remotePath, fileData);
|
|
10
|
-
}
|
|
11
|
-
async downloadFile(remotePath, localPath) {
|
|
12
|
-
const object = await this.bucket.get(remotePath);
|
|
13
|
-
if (object) {
|
|
14
|
-
await fs.writeFile(localPath, await object.arrayBuffer());
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
async exists(remotePath) {
|
|
18
|
-
const object = await this.bucket.head(remotePath);
|
|
19
|
-
return object !== null;
|
|
20
|
-
}
|
|
21
|
-
async delete(remotePath) {
|
|
22
|
-
await this.bucket.delete(remotePath);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export class ExternalDatabaseAdapter {
|
|
26
|
-
connectionString;
|
|
27
|
-
constructor(connectionString) {
|
|
28
|
-
this.connectionString = connectionString;
|
|
29
|
-
}
|
|
30
|
-
async uploadFile(localPath, remotePath) {
|
|
31
|
-
throw new Error('External database storage not yet implemented');
|
|
32
|
-
}
|
|
33
|
-
async downloadFile(remotePath, localPath) {
|
|
34
|
-
throw new Error('External database storage not yet implemented');
|
|
35
|
-
}
|
|
36
|
-
async exists(remotePath) {
|
|
37
|
-
return false;
|
|
38
|
-
}
|
|
39
|
-
async delete(remotePath) {
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
export function createStorageAdapter() {
|
|
43
|
-
if (typeof globalThis !== 'undefined' && 'XMTP_STORAGE' in globalThis) {
|
|
44
|
-
return new R2StorageAdapter(globalThis.XMTP_STORAGE);
|
|
45
|
-
}
|
|
46
|
-
if (typeof process !== 'undefined' && process.env?.DATABASE_URL) {
|
|
47
|
-
return new ExternalDatabaseAdapter(process.env.DATABASE_URL);
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
package/dist/lib/string.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Truncates a given string to a specified length, adding an ellipsis if the
|
|
3
|
-
* string is longer than the specified length.
|
|
4
|
-
*
|
|
5
|
-
* @param {string} str - The string to truncate.
|
|
6
|
-
* @param {number} length - The maximum length of the resulting string.
|
|
7
|
-
*
|
|
8
|
-
* @returns {string} The truncated string.
|
|
9
|
-
*/
|
|
10
|
-
export declare function truncate(str: string, length: number): string;
|
|
11
|
-
//# sourceMappingURL=string.d.ts.map
|
package/dist/lib/string.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/lib/string.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,UAEnD"}
|
package/dist/lib/string.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Truncates a given string to a specified length, adding an ellipsis if the
|
|
3
|
-
* string is longer than the specified length.
|
|
4
|
-
*
|
|
5
|
-
* @param {string} str - The string to truncate.
|
|
6
|
-
* @param {number} length - The maximum length of the resulting string.
|
|
7
|
-
*
|
|
8
|
-
* @returns {string} The truncated string.
|
|
9
|
-
*/
|
|
10
|
-
export function truncate(str, length) {
|
|
11
|
-
return str.length > length ? `${str.slice(0, length)}...` : str;
|
|
12
|
-
}
|
package/dist/lib/urls.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the agent application URL for webhooks and callbacks
|
|
3
|
-
*
|
|
4
|
-
* This function constructs the URL for the main agent application, used primarily
|
|
5
|
-
* for QStash webhooks and external callbacks. It supports multiple deployment
|
|
6
|
-
* environments with fallback logic.
|
|
7
|
-
*
|
|
8
|
-
* @param path - Optional path to append to the base URL (leading slashes are normalized)
|
|
9
|
-
* @returns The complete URL for the agent application
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // Get base URL
|
|
14
|
-
* getUrl() // "http://localhost:8454/"
|
|
15
|
-
*
|
|
16
|
-
* // Get URL with path
|
|
17
|
-
* getUrl("/qstash/webhook") // "http://localhost:8454/qstash/webhook"
|
|
18
|
-
* getUrl("api/health") // "http://localhost:8454/api/health"
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @remarks
|
|
22
|
-
* URL resolution priority:
|
|
23
|
-
* 1. `AGENT_URL` environment variable (custom deployment)
|
|
24
|
-
* 2. `RAILWAY_PUBLIC_DOMAIN` environment variable (Railway deployment)
|
|
25
|
-
* 3. `http://localhost:8454/` (default)
|
|
26
|
-
*/
|
|
27
|
-
export declare function getUrl(path?: string): string;
|
|
28
|
-
//# sourceMappingURL=urls.d.ts.map
|
package/dist/lib/urls.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"urls.d.ts","sourceRoot":"","sources":["../../src/lib/urls.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,MAAM,CAAC,IAAI,SAAK,UAY/B"}
|
package/dist/lib/urls.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get the agent application URL for webhooks and callbacks
|
|
3
|
-
*
|
|
4
|
-
* This function constructs the URL for the main agent application, used primarily
|
|
5
|
-
* for QStash webhooks and external callbacks. It supports multiple deployment
|
|
6
|
-
* environments with fallback logic.
|
|
7
|
-
*
|
|
8
|
-
* @param path - Optional path to append to the base URL (leading slashes are normalized)
|
|
9
|
-
* @returns The complete URL for the agent application
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* ```typescript
|
|
13
|
-
* // Get base URL
|
|
14
|
-
* getUrl() // "http://localhost:8454/"
|
|
15
|
-
*
|
|
16
|
-
* // Get URL with path
|
|
17
|
-
* getUrl("/qstash/webhook") // "http://localhost:8454/qstash/webhook"
|
|
18
|
-
* getUrl("api/health") // "http://localhost:8454/api/health"
|
|
19
|
-
* ```
|
|
20
|
-
*
|
|
21
|
-
* @remarks
|
|
22
|
-
* URL resolution priority:
|
|
23
|
-
* 1. `AGENT_URL` environment variable (custom deployment)
|
|
24
|
-
* 2. `RAILWAY_PUBLIC_DOMAIN` environment variable (Railway deployment)
|
|
25
|
-
* 3. `http://localhost:8454/` (default)
|
|
26
|
-
*/
|
|
27
|
-
export function getUrl(path = "") {
|
|
28
|
-
const trimmedPath = path.replace(/^\/+/, "");
|
|
29
|
-
if (process.env.AGENT_URL) {
|
|
30
|
-
return `https://${process.env.AGENT_URL}/${trimmedPath}`;
|
|
31
|
-
}
|
|
32
|
-
if (process.env.RAILWAY_PUBLIC_DOMAIN) {
|
|
33
|
-
return `https://${process.env.RAILWAY_PUBLIC_DOMAIN}/${trimmedPath}`;
|
|
34
|
-
}
|
|
35
|
-
return `https://localhost:8454/${trimmedPath}`;
|
|
36
|
-
}
|
package/dist/lib/uuid.d.ts
DELETED
package/dist/lib/uuid.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../src/lib/uuid.ts"],"names":[],"mappings":"AAIA,wBAAgB,UAAU,IAAI,MAAM,CAEnC"}
|