@ambasada/sdk 0.2.0 → 0.3.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/client.d.ts +18 -6
- package/dist/index.js +26 -2
- package/dist/types.d.ts +25 -0
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type IncomingRequest } from "./receipt.js";
|
|
2
|
-
import type { AgentConfigInput, BuyOptions, BuyResult, ChatRequest, ChatResponse, CheckoutInput, CheckoutReceiptClaims, CheckoutSession, FileOptions, ImageRequest, ImageResult, Jwk, LedgerPage, Listing, ListingInput, MarketOffering, PaidCall, PaymentLink, PaymentLinkInput, ToolListing, ToolResult, TranscriptEntry, TransferOptions, Wallet, WebhookDelivery, WebhookEvent } from "./types.js";
|
|
2
|
+
import type { AgentConfigInput, BuyOptions, BuyResult, ChatRequest, ChatResponse, CheckoutInput, CheckoutReceiptClaims, CheckoutSession, FileOptions, StoredFile, StoreList, StoreWrite, ImageRequest, ImageResult, Jwk, LedgerPage, Listing, ListingInput, MarketOffering, PaidCall, PaymentLink, PaymentLinkInput, ToolListing, ToolResult, TranscriptEntry, TransferOptions, Wallet, WebhookDelivery, WebhookEvent } from "./types.js";
|
|
3
3
|
export declare const DEFAULT_API_URL = "https://hackaton.ambasada.id";
|
|
4
4
|
export declare const DEFAULT_MODEL = "deepseek-v4.1-flash";
|
|
5
5
|
export interface VillageOptions {
|
|
@@ -128,12 +128,24 @@ export declare class Village {
|
|
|
128
128
|
};
|
|
129
129
|
readonly files: {
|
|
130
130
|
/**
|
|
131
|
-
* Stores bytes, a Blob, or a URL to copy, for the event
|
|
132
|
-
*
|
|
131
|
+
* Stores bytes, a Blob, or a URL to copy, for the event (`POST /v1/files`, 0.1 TON). Returns a
|
|
132
|
+
* public URL other products can fetch.
|
|
133
133
|
*/
|
|
134
|
-
put: (data: Uint8Array | ArrayBuffer | Blob | string, options?: FileOptions) => Promise<
|
|
135
|
-
|
|
136
|
-
|
|
134
|
+
put: (data: Uint8Array | ArrayBuffer | Blob | string, options?: FileOptions) => Promise<StoredFile>;
|
|
135
|
+
};
|
|
136
|
+
/**
|
|
137
|
+
* Your company's JSON key-value store (`/v1/store`): 1 MB per company (keys + values), free. State for
|
|
138
|
+
* a hosted product that needs no database.
|
|
139
|
+
*/
|
|
140
|
+
readonly store: {
|
|
141
|
+
/** The value, or null when the key is not set. */
|
|
142
|
+
get: <T = unknown>(key: string) => Promise<T | null>;
|
|
143
|
+
/** Saves any JSON value (fails with INVALID_REQUEST when the store would pass 1 MB). */
|
|
144
|
+
set: (key: string, value: unknown) => Promise<StoreWrite>;
|
|
145
|
+
/** True when the key existed. */
|
|
146
|
+
delete: (key: string) => Promise<boolean>;
|
|
147
|
+
/** Keys (up to 1000, optionally under a prefix) and how much of the 1 MB is used. */
|
|
148
|
+
list: (prefix?: string) => Promise<StoreList>;
|
|
137
149
|
};
|
|
138
150
|
readonly listings: {
|
|
139
151
|
/** Creates or updates an offering (price changes are versioned). */
|
package/dist/index.js
CHANGED
|
@@ -693,8 +693,8 @@ var Village = class {
|
|
|
693
693
|
};
|
|
694
694
|
files = {
|
|
695
695
|
/**
|
|
696
|
-
* Stores bytes, a Blob, or a URL to copy, for the event
|
|
697
|
-
*
|
|
696
|
+
* Stores bytes, a Blob, or a URL to copy, for the event (`POST /v1/files`, 0.1 TON). Returns a
|
|
697
|
+
* public URL other products can fetch.
|
|
698
698
|
*/
|
|
699
699
|
put: (data, options = {}) => {
|
|
700
700
|
const query = { ttl_seconds: options.ttlSeconds };
|
|
@@ -703,6 +703,30 @@ var Village = class {
|
|
|
703
703
|
return this.call("POST", "/v1/files", { raw: data, headers: { "content-type": contentType }, query });
|
|
704
704
|
}
|
|
705
705
|
};
|
|
706
|
+
/**
|
|
707
|
+
* Your company's JSON key-value store (`/v1/store`): 1 MB per company (keys + values), free. State for
|
|
708
|
+
* a hosted product that needs no database.
|
|
709
|
+
*/
|
|
710
|
+
store = {
|
|
711
|
+
/** The value, or null when the key is not set. */
|
|
712
|
+
get: async (key) => {
|
|
713
|
+
try {
|
|
714
|
+
return (await this.call("GET", `/v1/store/${encodeURIComponent(key)}`)).value;
|
|
715
|
+
} catch (error) {
|
|
716
|
+
if (error instanceof VillageError && error.status === 404) return null;
|
|
717
|
+
throw error;
|
|
718
|
+
}
|
|
719
|
+
},
|
|
720
|
+
/** Saves any JSON value (fails with INVALID_REQUEST when the store would pass 1 MB). */
|
|
721
|
+
set: (key, value) => {
|
|
722
|
+
if (value === void 0) throw new VillageError("INVALID_REQUEST", "store.set needs a JSON value (use store.delete to remove a key)");
|
|
723
|
+
return this.call("PUT", `/v1/store/${encodeURIComponent(key)}`, { body: value });
|
|
724
|
+
},
|
|
725
|
+
/** True when the key existed. */
|
|
726
|
+
delete: async (key) => (await this.call("DELETE", `/v1/store/${encodeURIComponent(key)}`)).deleted,
|
|
727
|
+
/** Keys (up to 1000, optionally under a prefix) and how much of the 1 MB is used. */
|
|
728
|
+
list: (prefix) => this.call("GET", "/v1/store", { query: { prefix } })
|
|
729
|
+
};
|
|
706
730
|
// ── listings, wallet, ledger ──────────────────────────────────────────────
|
|
707
731
|
listings = {
|
|
708
732
|
/** Creates or updates an offering (price changes are versioned). */
|
package/dist/types.d.ts
CHANGED
|
@@ -218,6 +218,31 @@ export interface FileOptions {
|
|
|
218
218
|
contentType?: string;
|
|
219
219
|
ttlSeconds?: number;
|
|
220
220
|
}
|
|
221
|
+
/** `POST /v1/files` (0.1 TON a file). */
|
|
222
|
+
export interface StoredFile {
|
|
223
|
+
id: string;
|
|
224
|
+
url: string;
|
|
225
|
+
size?: number;
|
|
226
|
+
content_type?: string;
|
|
227
|
+
cost?: number;
|
|
228
|
+
call_id?: string;
|
|
229
|
+
}
|
|
230
|
+
export interface StoreKey {
|
|
231
|
+
key: string;
|
|
232
|
+
size: number;
|
|
233
|
+
updated_at: string;
|
|
234
|
+
}
|
|
235
|
+
export interface StoreList {
|
|
236
|
+
keys: StoreKey[];
|
|
237
|
+
used_bytes: number;
|
|
238
|
+
limit_bytes: number;
|
|
239
|
+
}
|
|
240
|
+
export interface StoreWrite {
|
|
241
|
+
key: string;
|
|
242
|
+
size: number;
|
|
243
|
+
used_bytes: number;
|
|
244
|
+
limit_bytes: number;
|
|
245
|
+
}
|
|
221
246
|
/** Offering field schema shorthand: `{ text: "string", to: "string", tone: "string?" }`. */
|
|
222
247
|
export type FieldSchema = Record<string, string>;
|
|
223
248
|
export interface ListingInput {
|
package/package.json
CHANGED