@eazo/sdk 0.5.1 → 0.7.0
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.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/auth-primitive/EazoAuthClient.d.ts.map +1 -1
- package/dist/internal/auth-primitive/EazoAuthClient.js +2 -2
- package/dist/internal/auth-primitive/EazoAuthClient.js.map +1 -1
- package/dist/internal/capabilities/ai.d.ts +54 -0
- package/dist/internal/capabilities/ai.d.ts.map +1 -0
- package/dist/internal/capabilities/ai.js +55 -0
- package/dist/internal/capabilities/ai.js.map +1 -0
- package/dist/internal/capabilities/storage.d.ts +43 -0
- package/dist/internal/capabilities/storage.d.ts.map +1 -0
- package/dist/internal/capabilities/storage.js +70 -0
- package/dist/internal/capabilities/storage.js.map +1 -0
- package/dist/internal/config.d.ts +5 -0
- package/dist/internal/config.d.ts.map +1 -1
- package/dist/internal/config.js +14 -0
- package/dist/internal/config.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
export { auth } from "./internal/capabilities/auth";
|
|
2
2
|
export { device } from "./internal/capabilities/device";
|
|
3
|
+
export { storage } from "./internal/capabilities/storage";
|
|
4
|
+
export { ai } from "./internal/capabilities/ai";
|
|
3
5
|
export type { LoginOptions } from "./internal/capabilities/auth";
|
|
6
|
+
export type { StorageCredentials, UploadResult } from "./internal/capabilities/storage";
|
|
7
|
+
export type { ChatCompletion, ChatCompletionChunk, ChatCompletionCreateParamsNonStreaming, ChatCompletionCreateParamsStreaming, } from "./internal/capabilities/ai";
|
|
4
8
|
export type { User, DeviceContext, AuthState, EazoState } from "./types";
|
|
5
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,8BAA8B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,gCAAgC,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AAC1D,OAAO,EAAE,EAAE,EAAE,MAAM,4BAA4B,CAAC;AAEhD,YAAY,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AACxF,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.device = exports.auth = void 0;
|
|
3
|
+
exports.ai = exports.storage = exports.device = exports.auth = void 0;
|
|
4
4
|
var auth_1 = require("./internal/capabilities/auth");
|
|
5
5
|
Object.defineProperty(exports, "auth", { enumerable: true, get: function () { return auth_1.auth; } });
|
|
6
6
|
var device_1 = require("./internal/capabilities/device");
|
|
7
7
|
Object.defineProperty(exports, "device", { enumerable: true, get: function () { return device_1.device; } });
|
|
8
|
+
var storage_1 = require("./internal/capabilities/storage");
|
|
9
|
+
Object.defineProperty(exports, "storage", { enumerable: true, get: function () { return storage_1.storage; } });
|
|
10
|
+
var ai_1 = require("./internal/capabilities/ai");
|
|
11
|
+
Object.defineProperty(exports, "ai", { enumerable: true, get: function () { return ai_1.ai; } });
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAA3C,4FAAA,IAAI,OAAA;AACb,yDAAwD;AAA/C,gGAAA,MAAM,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AAA3C,4FAAA,IAAI,OAAA;AACb,yDAAwD;AAA/C,gGAAA,MAAM,OAAA;AACf,2DAA0D;AAAjD,kGAAA,OAAO,OAAA;AAChB,iDAAgD;AAAvC,wFAAA,EAAE,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EazoAuthClient.d.ts","sourceRoot":"","sources":["../../../src/internal/auth-primitive/EazoAuthClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAc,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"EazoAuthClient.d.ts","sourceRoot":"","sources":["../../../src/internal/auth-primitive/EazoAuthClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAc,MAAM,gBAAgB,CAAC;AAGlE,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAKpF;;;;;;;GAOG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IAEjC,OAAO,CAAC,cAAc,CAAqC;gBAE/C,MAAM,EAAE,oBAAoB;IAQxC;;;;OAIG;YACW,gBAAgB;IAkB9B,6EAA6E;IAC7E,eAAe,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAqBhE,4EAA4E;IACtE,sBAAsB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAUpF,qFAAqF;IAC/E,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,YAAY,CAAC;IAU5E,kDAAkD;IAC5C,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD,gBAAgB,IAAI,oBAAoB;IASlC,sBAAsB,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;CAS5D"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EazoAuthClient = void 0;
|
|
4
4
|
const authing_js_sdk_1 = require("authing-js-sdk");
|
|
5
|
+
const config_1 = require("../config");
|
|
5
6
|
const DEFAULT_AUTH_APP_ID = "6972f32040acf5801552404b";
|
|
6
7
|
const DEFAULT_AUTH_APP_DOMAIN = "https://eazo.genauth.ai";
|
|
7
|
-
const DEFAULT_API_BASE = "https://eazo.ai";
|
|
8
8
|
/**
|
|
9
9
|
* Browser-side auth primitive. Wraps GenAuth (Authing) to exchange a JWT for
|
|
10
10
|
* an encrypted SessionToken (same shape produced by Eazo Mobile).
|
|
@@ -21,7 +21,7 @@ class EazoAuthClient {
|
|
|
21
21
|
this.publicKey = config.publicKey;
|
|
22
22
|
this.authAppId = config.authAppId ?? DEFAULT_AUTH_APP_ID;
|
|
23
23
|
this.authAppDomain = config.authAppDomain ?? DEFAULT_AUTH_APP_DOMAIN;
|
|
24
|
-
this.apiBase = config.apiBase
|
|
24
|
+
this.apiBase = (0, config_1.getApiBase)(config.apiBase);
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Exchanges a GenAuth JWT for an encrypted session token.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EazoAuthClient.js","sourceRoot":"","sources":["../../../src/internal/auth-primitive/EazoAuthClient.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;
|
|
1
|
+
{"version":3,"file":"EazoAuthClient.js","sourceRoot":"","sources":["../../../src/internal/auth-primitive/EazoAuthClient.ts"],"names":[],"mappings":";;;AAAA,mDAAkE;AAElE,sCAAuC;AAGvC,MAAM,mBAAmB,GAAO,0BAA0B,CAAC;AAC3D,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAa,cAAc;IAQzB,YAAY,MAA4B;QAFhC,mBAAc,GAAgC,IAAI,CAAC;QAGzD,IAAI,CAAC,MAAM,CAAC,SAAS;YAAE,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QAC3E,IAAI,CAAC,SAAS,GAAO,MAAM,CAAC,SAAS,CAAC;QACtC,IAAI,CAAC,SAAS,GAAO,MAAM,CAAC,SAAS,IAAQ,mBAAmB,CAAC;QACjE,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,uBAAuB,CAAC;QACrE,IAAI,CAAC,OAAO,GAAS,IAAA,mBAAU,EAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACK,KAAK,CAAC,gBAAgB,CAAC,GAAW;QACxC,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,OAAO,6BAA6B,EAAE;YACpE,MAAM,EAAE,MAAM;YACd,OAAO,EAAE;gBACP,cAAc,EAAE,kBAAkB;gBAClC,eAAe,EAAE,UAAU,GAAG,EAAE;aACjC;YACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,CAAC;SACpD,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,CAAC,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CAAC,SAAS,gBAAgB,EAC3E,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAiB,CAC9C,CAAC;QACF,IAAI,CAAC,GAAG,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,0CAA0C,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC;QACrF,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAyD,CAAC;QACrF,OAAO,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC;IACrC,CAAC;CACF;AA1GD,wCA0GC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import OpenAI from "openai";
|
|
2
|
+
export type { ChatCompletion, ChatCompletionChunk } from "openai/resources/chat/completions";
|
|
3
|
+
export type { ChatCompletionCreateParamsNonStreaming, ChatCompletionCreateParamsStreaming, } from "openai/resources/chat/completions";
|
|
4
|
+
/**
|
|
5
|
+
* Send a chat completion request to the built-in AI (AWS Bedrock via bedrock-mantle).
|
|
6
|
+
*
|
|
7
|
+
* Uses the official `openai` package under the hood — all parameter types are
|
|
8
|
+
* identical to the OpenAI SDK. The response is returned as-is in OpenAI standard
|
|
9
|
+
* format, including streaming chunks.
|
|
10
|
+
*
|
|
11
|
+
* @example Non-streaming
|
|
12
|
+
* ```ts
|
|
13
|
+
* const result = await ai.chat({
|
|
14
|
+
* model: 'deepseek.v3.1',
|
|
15
|
+
* messages: [{ role: 'user', content: 'Hello!' }],
|
|
16
|
+
* });
|
|
17
|
+
* console.log(result.choices[0].message.content);
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @example Streaming
|
|
21
|
+
* ```ts
|
|
22
|
+
* const stream = await ai.chat({
|
|
23
|
+
* model: 'deepseek.v3.1',
|
|
24
|
+
* messages: [{ role: 'user', content: 'Tell me a story.' }],
|
|
25
|
+
* stream: true,
|
|
26
|
+
* });
|
|
27
|
+
* for await (const chunk of stream) {
|
|
28
|
+
* process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example Function calling
|
|
33
|
+
* ```ts
|
|
34
|
+
* const result = await ai.chat({
|
|
35
|
+
* model: 'deepseek.v3.1',
|
|
36
|
+
* messages: [{ role: 'user', content: 'What is the weather in Shanghai?' }],
|
|
37
|
+
* tools: [{ type: 'function', function: { name: 'get_weather', description: '...', parameters: {...} } }],
|
|
38
|
+
* tool_choice: 'auto',
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
declare function chat(params: OpenAI.Chat.ChatCompletionCreateParamsNonStreaming): Promise<OpenAI.Chat.ChatCompletion>;
|
|
43
|
+
declare function chat(params: OpenAI.Chat.ChatCompletionCreateParamsStreaming): Promise<AsyncIterable<OpenAI.Chat.ChatCompletionChunk>>;
|
|
44
|
+
export declare const ai: {
|
|
45
|
+
/**
|
|
46
|
+
* Configure the private key for AI requests.
|
|
47
|
+
* Alternative to setting the EAZO_PRIVATE_KEY environment variable.
|
|
48
|
+
*/
|
|
49
|
+
configure(opts: {
|
|
50
|
+
privateKey: string;
|
|
51
|
+
}): void;
|
|
52
|
+
chat: typeof chat;
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=ai.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/ai.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAmC5B,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7F,YAAY,EACV,sCAAsC,EACtC,mCAAmC,GACpC,MAAM,mCAAmC,CAAC;AAM3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,iBAAe,IAAI,CACjB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,sCAAsC,GACzD,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;AACvC,iBAAe,IAAI,CACjB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,mCAAmC,GACtD,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;AAwB3D,eAAO,MAAM,EAAE;IACb;;;OAGG;oBACa;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;;CAK9C,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ai = void 0;
|
|
7
|
+
const openai_1 = __importDefault(require("openai"));
|
|
8
|
+
const config_1 = require("../config");
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
// Private key storage
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
let privateKey = null;
|
|
13
|
+
function setPrivateKey(key) {
|
|
14
|
+
privateKey = key;
|
|
15
|
+
}
|
|
16
|
+
function getPrivateKey() {
|
|
17
|
+
if (privateKey)
|
|
18
|
+
return privateKey;
|
|
19
|
+
if (typeof process !== "undefined" && process.env.EAZO_PRIVATE_KEY) {
|
|
20
|
+
return process.env.EAZO_PRIVATE_KEY;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
function buildClient() {
|
|
25
|
+
const key = getPrivateKey();
|
|
26
|
+
if (!key) {
|
|
27
|
+
throw new Error("@eazo/sdk: missing private key. Set EAZO_PRIVATE_KEY env var or call ai.configure({ privateKey }).");
|
|
28
|
+
}
|
|
29
|
+
return new openai_1.default({
|
|
30
|
+
baseURL: `${(0, config_1.getApiBase)()}/v1`,
|
|
31
|
+
apiKey: key,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
async function chat(params) {
|
|
35
|
+
const client = buildClient();
|
|
36
|
+
if (params.stream) {
|
|
37
|
+
// openai SDK Stream is itself an AsyncIterable<ChatCompletionChunk>
|
|
38
|
+
return client.chat.completions.create(params);
|
|
39
|
+
}
|
|
40
|
+
return client.chat.completions.create(params);
|
|
41
|
+
}
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Public API
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
exports.ai = {
|
|
46
|
+
/**
|
|
47
|
+
* Configure the private key for AI requests.
|
|
48
|
+
* Alternative to setting the EAZO_PRIVATE_KEY environment variable.
|
|
49
|
+
*/
|
|
50
|
+
configure(opts) {
|
|
51
|
+
setPrivateKey(opts.privateKey);
|
|
52
|
+
},
|
|
53
|
+
chat,
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=ai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../../../src/internal/capabilities/ai.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,sCAAuC;AAEvC,8EAA8E;AAC9E,sBAAsB;AACtB,8EAA8E;AAE9E,IAAI,UAAU,GAAkB,IAAI,CAAC;AAErC,SAAS,aAAa,CAAC,GAAW;IAChC,UAAU,GAAG,GAAG,CAAC;AACnB,CAAC;AAED,SAAS,aAAa;IACpB,IAAI,UAAU;QAAE,OAAO,UAAU,CAAC;IAClC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACnE,OAAO,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,WAAW;IAClB,MAAM,GAAG,GAAG,aAAa,EAAE,CAAC;IAC5B,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CACb,oGAAoG,CACrG,CAAC;IACJ,CAAC;IACD,OAAO,IAAI,gBAAM,CAAC;QAChB,OAAO,EAAE,GAAG,IAAA,mBAAU,GAAE,KAAK;QAC7B,MAAM,EAAE,GAAG;KACZ,CAAC,CAAC;AACL,CAAC;AAyDD,KAAK,UAAU,IAAI,CACjB,MAEmD;IAEnD,MAAM,MAAM,GAAG,WAAW,EAAE,CAAC;IAE7B,IAAK,MAA0D,CAAC,MAAM,EAAE,CAAC;QACvE,oEAAoE;QACpE,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CACnC,MAAyD,CACC,CAAC;IAC/D,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CACnC,MAA4D,CAC7D,CAAC;AACJ,CAAC;AAED,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAEjE,QAAA,EAAE,GAAG;IAChB;;;OAGG;IACH,SAAS,CAAC,IAA4B;QACpC,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,IAAI;CACL,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export interface StorageCredentials {
|
|
2
|
+
/** Presigned PUT URL — upload a file directly to S3 with this URL (PUT, no auth header needed) */
|
|
3
|
+
uploadUrl: string;
|
|
4
|
+
/** Publicly accessible CDN URL for the uploaded object (permanent, no expiry) */
|
|
5
|
+
publicUrl: string;
|
|
6
|
+
/** Full S3 object key: app-contents/{md5(ownerId)}/{path} */
|
|
7
|
+
key: string;
|
|
8
|
+
bucket: string;
|
|
9
|
+
region: string;
|
|
10
|
+
/** ISO timestamp when the uploadUrl expires */
|
|
11
|
+
expiration: string;
|
|
12
|
+
}
|
|
13
|
+
export interface UploadResult {
|
|
14
|
+
/** Full S3 object key */
|
|
15
|
+
key: string;
|
|
16
|
+
/** Publicly accessible CDN URL */
|
|
17
|
+
url: string;
|
|
18
|
+
}
|
|
19
|
+
export declare const storage: {
|
|
20
|
+
/**
|
|
21
|
+
* Upload a file to Eazo built-in object storage.
|
|
22
|
+
*
|
|
23
|
+
* Internally this:
|
|
24
|
+
* 1. Requests a presigned PUT URL from portal-agent-server (scoped to your
|
|
25
|
+
* tenant prefix via STS Session Policy).
|
|
26
|
+
* 2. PUTs the file directly to S3 — no platform bandwidth used.
|
|
27
|
+
* 3. Returns the S3 key and a permanent CDN URL.
|
|
28
|
+
*
|
|
29
|
+
* @param path Relative object path, e.g. "todos/123/avatar.png"
|
|
30
|
+
* @param file File or Blob to upload
|
|
31
|
+
* @param options.contentType MIME type (defaults to file.type)
|
|
32
|
+
*/
|
|
33
|
+
upload(path: string, file: File | Blob, options?: {
|
|
34
|
+
contentType?: string;
|
|
35
|
+
}): Promise<UploadResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Low-level: fetch raw storage credentials without uploading.
|
|
38
|
+
* Useful when you need the uploadUrl upfront,
|
|
39
|
+
* or when you want to hand the uploadUrl to a native file picker.
|
|
40
|
+
*/
|
|
41
|
+
getCredentials(path: string): Promise<StorageCredentials>;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../../../src/internal/capabilities/storage.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,kBAAkB;IACjC,kGAAkG;IAClG,SAAS,EAAE,MAAM,CAAC;IAClB,iFAAiF;IACjF,SAAS,EAAE,MAAM,CAAC;IAClB,6DAA6D;IAC7D,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,+CAA+C;IAC/C,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,yBAAyB;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,kCAAkC;IAClC,GAAG,EAAE,MAAM,CAAC;CACb;AAqCD,eAAO,MAAM,OAAO;IAClB;;;;;;;;;;;;OAYG;iBAEK,MAAM,QACN,IAAI,GAAG,IAAI,YACR;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,GAChC,OAAO,CAAC,YAAY,CAAC;IAiBxB;;;;OAIG;yBACkB,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAG1D,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.storage = void 0;
|
|
4
|
+
const config_1 = require("../config");
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Internal helpers
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
async function fetchCredentials(path) {
|
|
9
|
+
const publicKey = (0, config_1.getPublicKey)();
|
|
10
|
+
if (!publicKey) {
|
|
11
|
+
throw new Error("@eazo/sdk: missing public key. Set NEXT_PUBLIC_EAZO_PUBLIC_KEY or call auth.configure({ publicKey }).");
|
|
12
|
+
}
|
|
13
|
+
const res = await fetch(`${(0, config_1.getApiBase)()}/api/open/storage-credentials`, {
|
|
14
|
+
method: "POST",
|
|
15
|
+
headers: { "Content-Type": "application/json" },
|
|
16
|
+
body: JSON.stringify({ publicKey, path }),
|
|
17
|
+
});
|
|
18
|
+
if (!res.ok) {
|
|
19
|
+
let message = `Failed to get storage credentials: ${res.status}`;
|
|
20
|
+
try {
|
|
21
|
+
const body = await res.json();
|
|
22
|
+
if (body?.message)
|
|
23
|
+
message = body.message;
|
|
24
|
+
}
|
|
25
|
+
catch { /* ignore */ }
|
|
26
|
+
throw new Error(message);
|
|
27
|
+
}
|
|
28
|
+
const json = await res.json();
|
|
29
|
+
return json.data;
|
|
30
|
+
}
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
// Public API
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
exports.storage = {
|
|
35
|
+
/**
|
|
36
|
+
* Upload a file to Eazo built-in object storage.
|
|
37
|
+
*
|
|
38
|
+
* Internally this:
|
|
39
|
+
* 1. Requests a presigned PUT URL from portal-agent-server (scoped to your
|
|
40
|
+
* tenant prefix via STS Session Policy).
|
|
41
|
+
* 2. PUTs the file directly to S3 — no platform bandwidth used.
|
|
42
|
+
* 3. Returns the S3 key and a permanent CDN URL.
|
|
43
|
+
*
|
|
44
|
+
* @param path Relative object path, e.g. "todos/123/avatar.png"
|
|
45
|
+
* @param file File or Blob to upload
|
|
46
|
+
* @param options.contentType MIME type (defaults to file.type)
|
|
47
|
+
*/
|
|
48
|
+
async upload(path, file, options = {}) {
|
|
49
|
+
const creds = await fetchCredentials(path);
|
|
50
|
+
const contentType = options.contentType ?? (file instanceof File ? file.type : "application/octet-stream");
|
|
51
|
+
const putRes = await fetch(creds.uploadUrl, {
|
|
52
|
+
method: "PUT",
|
|
53
|
+
body: file,
|
|
54
|
+
headers: { "Content-Type": contentType },
|
|
55
|
+
});
|
|
56
|
+
if (!putRes.ok) {
|
|
57
|
+
throw new Error(`Failed to upload file to storage: ${putRes.status}`);
|
|
58
|
+
}
|
|
59
|
+
return { key: creds.key, url: creds.publicUrl };
|
|
60
|
+
},
|
|
61
|
+
/**
|
|
62
|
+
* Low-level: fetch raw storage credentials without uploading.
|
|
63
|
+
* Useful when you need the uploadUrl upfront,
|
|
64
|
+
* or when you want to hand the uploadUrl to a native file picker.
|
|
65
|
+
*/
|
|
66
|
+
getCredentials(path) {
|
|
67
|
+
return fetchCredentials(path);
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../../src/internal/capabilities/storage.ts"],"names":[],"mappings":";;;AAAA,sCAAqD;AA0BrD,8EAA8E;AAC9E,mBAAmB;AACnB,8EAA8E;AAE9E,KAAK,UAAU,gBAAgB,CAAC,IAAY;IAC1C,MAAM,SAAS,GAAG,IAAA,qBAAY,GAAE,CAAC;IACj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,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE;YAC1C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI;YACV,OAAO,EAAE,EAAE,cAAc,EAAE,WAAW,EAAE;SACzC,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,qCAAqC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QACxE,CAAC;QAED,OAAO,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACH,cAAc,CAAC,IAAY;QACzB,OAAO,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAChC,CAAC;CACF,CAAC"}
|
|
@@ -9,5 +9,10 @@ export declare function setPublicKey(key: string | null): void;
|
|
|
9
9
|
* `auth.configure({ publicKey })`.
|
|
10
10
|
*/
|
|
11
11
|
export declare function getPublicKey(): string | null;
|
|
12
|
+
/**
|
|
13
|
+
* Returns the configured API base URL.
|
|
14
|
+
* Priority: explicit override -> NEXT_PUBLIC_EAZO_API_URL -> default.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getApiBase(override?: string): string;
|
|
12
17
|
export declare function __resetConfig(): void;
|
|
13
18
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAErD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,IAAI,MAAM,GAAG,IAAI,CAM5C;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAMpD;AAED,wBAAgB,aAAa,IAAI,IAAI,CAEpC"}
|
package/dist/internal/config.js
CHANGED
|
@@ -6,8 +6,10 @@
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.setPublicKey = setPublicKey;
|
|
8
8
|
exports.getPublicKey = getPublicKey;
|
|
9
|
+
exports.getApiBase = getApiBase;
|
|
9
10
|
exports.__resetConfig = __resetConfig;
|
|
10
11
|
let publicKey = null;
|
|
12
|
+
const DEFAULT_API_BASE = "https://eazo.ai";
|
|
11
13
|
function setPublicKey(key) {
|
|
12
14
|
publicKey = key;
|
|
13
15
|
}
|
|
@@ -24,6 +26,18 @@ function getPublicKey() {
|
|
|
24
26
|
}
|
|
25
27
|
return null;
|
|
26
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Returns the configured API base URL.
|
|
31
|
+
* Priority: explicit override -> NEXT_PUBLIC_EAZO_API_URL -> default.
|
|
32
|
+
*/
|
|
33
|
+
function getApiBase(override) {
|
|
34
|
+
if (override)
|
|
35
|
+
return override.replace(/\/$/, "");
|
|
36
|
+
if (typeof process !== "undefined" && process.env.NEXT_PUBLIC_EAZO_API_URL) {
|
|
37
|
+
return process.env.NEXT_PUBLIC_EAZO_API_URL.replace(/\/$/, "");
|
|
38
|
+
}
|
|
39
|
+
return DEFAULT_API_BASE;
|
|
40
|
+
}
|
|
27
41
|
function __resetConfig() {
|
|
28
42
|
publicKey = null;
|
|
29
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/internal/config.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,oCAEC;AAOD,oCAMC;AAMD,gCAMC;AAED,sCAEC;AAlCD,IAAI,SAAS,GAAkB,IAAI,CAAC;AACpC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAE3C,SAAgB,YAAY,CAAC,GAAkB;IAC7C,SAAS,GAAG,GAAG,CAAC;AAClB,CAAC;AAED;;;;GAIG;AACH,SAAgB,YAAY;IAC1B,IAAI,SAAS;QAAE,OAAO,SAAS,CAAC;IAChC,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,2BAA2B,EAAE,CAAC;QAC9E,OAAO,OAAO,CAAC,GAAG,CAAC,2BAA2B,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,SAAgB,UAAU,CAAC,QAAiB;IAC1C,IAAI,QAAQ;QAAE,OAAO,QAAQ,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACjD,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAAE,CAAC;QAC3E,OAAO,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,SAAgB,aAAa;IAC3B,SAAS,GAAG,IAAI,CAAC;AACnB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eazo/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Eazo platform SDK — capability-first API for web apps that run on Eazo Mobile and the web browser",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -45,7 +45,8 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@radix-ui/react-dialog": "^1.1.4",
|
|
47
47
|
"authing-js-sdk": "^4.23.55",
|
|
48
|
-
"elliptic": "^6.6.1"
|
|
48
|
+
"elliptic": "^6.6.1",
|
|
49
|
+
"openai": "^6.34.0"
|
|
49
50
|
},
|
|
50
51
|
"peerDependencies": {
|
|
51
52
|
"react": ">=18"
|