New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@ainft-team/ainft-js

Package Overview
Dependencies
Maintainers
0
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ainft-team/ainft-js - npm Package Compare versions

Comparing version

to
2.1.0-beta.28

6

dist/ai/ai.d.ts

@@ -13,3 +13,3 @@ import FactoryBase from '../factoryBase';

* @param {string} serviceName - The name of Ainize service.
* @returns {Promise<AiConfigurationTransactionResult>} Returns a promise that resolves with both the transaction result and the configuration info.
* @returns {Promise<AiConfigurationTransactionResult>} A promise that resolves with both the transaction result and the configuration info.
*/

@@ -20,3 +20,3 @@ configure(objectId: string, serviceName: string): Promise<AiConfigurationTransactionResult>;

* @param {string} serviceName - The name of Ainize service.
* @returns {Promise<number|null>} Returns a promise that resolves with the credit balance.
* @returns {Promise<number|null>} A promise that resolves with the credit balance.
*/

@@ -29,3 +29,3 @@ getCredit(serviceName: string): Promise<number>;

* @param {number} amount - The amount of credits to deposit.
* @returns {Promise<CreditTransactionResult>} Returns a promise that resolves with the deposit transaction info.
* @returns {Promise<CreditTransactionResult>} A promise that resolves with the deposit transaction info.
*/

@@ -32,0 +32,0 @@ getUserTokensByStatus(objectId: string, address: string, status?: string, { limit, offset, order }?: QueryParams): Promise<{

@@ -36,3 +36,3 @@ "use strict";

* @param {string} serviceName - The name of Ainize service.
* @returns {Promise<AiConfigurationTransactionResult>} Returns a promise that resolves with both the transaction result and the configuration info.
* @returns {Promise<AiConfigurationTransactionResult>} A promise that resolves with both the transaction result and the configuration info.
*/

@@ -53,3 +53,3 @@ configure(objectId, serviceName) {

* @param {string} serviceName - The name of Ainize service.
* @returns {Promise<number|null>} Returns a promise that resolves with the credit balance.
* @returns {Promise<number|null>} A promise that resolves with the credit balance.
*/

@@ -83,3 +83,3 @@ getCredit(serviceName) {

* @param {number} amount - The amount of credits to deposit.
* @returns {Promise<CreditTransactionResult>} Returns a promise that resolves with the deposit transaction info.
* @returns {Promise<CreditTransactionResult>} A promise that resolves with the deposit transaction info.
*/

@@ -86,0 +86,0 @@ /*

@@ -14,3 +14,3 @@ import FactoryBase from '../factoryBase';

* @param {AssistantCreateOptions} AssistantCreateOptions - The creation options.
* @returns Returns a promise that resolves with both the transaction result and the created assistant.
* @returns A promise that resolves with both the transaction result and the created assistant.
*/

@@ -24,3 +24,3 @@ create(objectId: string, tokenId: string, { model, name, instructions, description, metadata }: AssistantCreateParams, options?: AssistantCreateOptions): Promise<AssistantTransactionResult>;

* @param {AssistantUpdateParams} AssistantUpdateParams - The parameters to update assistant.
* @returns Returns a promise that resolves with both the transaction result and the updated assistant.
* @returns A promise that resolves with both the transaction result and the updated assistant.
*/

@@ -33,3 +33,3 @@ update(objectId: string, tokenId: string, assistantId: string, { model, name, instructions, description, metadata }: AssistantUpdateParams): Promise<AssistantTransactionResult>;

* @param {string} assistantId - The ID of assistant.
* @returns Returns a promise that resolves with both the transaction result and the deleted assistant.
* @returns A promise that resolves with both the transaction result and the deleted assistant.
*/

@@ -42,3 +42,3 @@ delete(objectId: string, tokenId: string, assistantId: string): Promise<AssistantDeleteTransactionResult>;

* @param {string} assistantId - The ID of assistant.
* @returns Returns a promise that resolves with the assistant.
* @returns A promise that resolves with the assistant.
*/

@@ -49,7 +49,7 @@ get(objectId: string, tokenId: string, assistantId: string): Promise<Assistant>;

* @param {string} objectId - The ID of AINFT object.
* @param {string} address - The checksum address of account.
* @param {QueryParams} QueryParams - The parameters for querying items.
* @returns Returns a promise that resolves with the list of assistants.
* @param {string} [address] - (Optional) The checksum address of account.
* @param {QueryParams} [queryParams={}] - The parameters for querying items.
* @returns A promise that resolves with the list of assistants.
*/
list(objectId: string, address: string, { limit, offset, order }?: QueryParams): Promise<{
list(objectId: string, address?: string | null, { limit, offset, order }?: QueryParams): Promise<{
total: number;

@@ -62,6 +62,7 @@ items: Assistant[];

private buildTxBodyForDeleteAssistant;
private getTokensByAddress;
private getTokens;
private getAssistantsFromTokens;
private toAssistant;
private sortAssistants;
private countThreads;
}

@@ -42,3 +42,3 @@ "use strict";

* @param {AssistantCreateOptions} AssistantCreateOptions - The creation options.
* @returns Returns a promise that resolves with both the transaction result and the created assistant.
* @returns A promise that resolves with both the transaction result and the created assistant.
*/

@@ -88,3 +88,3 @@ create(objectId, tokenId, { model, name, instructions, description, metadata }, options = {}) {

* @param {AssistantUpdateParams} AssistantUpdateParams - The parameters to update assistant.
* @returns Returns a promise that resolves with both the transaction result and the updated assistant.
* @returns A promise that resolves with both the transaction result and the updated assistant.
*/

@@ -131,3 +131,3 @@ update(objectId, tokenId, assistantId, { model, name, instructions, description, metadata }) {

* @param {string} assistantId - The ID of assistant.
* @returns Returns a promise that resolves with both the transaction result and the deleted assistant.
* @returns A promise that resolves with both the transaction result and the deleted assistant.
*/

@@ -170,3 +170,3 @@ delete(objectId, tokenId, assistantId) {

* @param {string} assistantId - The ID of assistant.
* @returns Returns a promise that resolves with the assistant.
* @returns A promise that resolves with the assistant.
*/

@@ -197,5 +197,5 @@ get(objectId, tokenId, assistantId) {

* @param {string} objectId - The ID of AINFT object.
* @param {string} address - The checksum address of account.
* @param {QueryParams} QueryParams - The parameters for querying items.
* @returns Returns a promise that resolves with the list of assistants.
* @param {string} [address] - (Optional) The checksum address of account.
* @param {QueryParams} [queryParams={}] - The parameters for querying items.
* @returns A promise that resolves with the list of assistants.
*/

@@ -205,3 +205,3 @@ list(objectId, address, { limit = 20, offset = 0, order = 'desc' } = {}) {

yield (0, validator_1.validateObject)(this.ain, objectId);
const tokens = yield this.getTokensByAddress(objectId, address);
const tokens = yield this.getTokens(objectId, address);
const assistants = this.getAssistantsFromTokens(tokens);

@@ -299,3 +299,3 @@ const sorted = this.sortAssistants(assistants, order);

}
getTokensByAddress(objectId, address) {
getTokens(objectId, address) {
return __awaiter(this, void 0, void 0, function* () {

@@ -306,3 +306,3 @@ const appId = ainft721Object_1.default.getAppId(objectId);

return Object.entries(tokens).reduce((acc, [id, token]) => {
if (token.owner === address) {
if (!address || token.owner === address) {
acc.push(Object.assign({ tokenId: id }, token));

@@ -317,3 +317,3 @@ }

if (token.ai) {
acc.push(this.toAssistant(token));
acc.push(this.toAssistant(token, this.countThreads(token.ai.history)));
}

@@ -323,3 +323,3 @@ return acc;

}
toAssistant(data) {
toAssistant(data, numThreads) {
return {

@@ -335,2 +335,3 @@ id: data.ai.id,

created_at: data.ai.createdAt,
metric: { numThreads },
};

@@ -347,4 +348,15 @@ }

}
countThreads(items) {
if (typeof items !== 'object' || !items) {
return 0;
}
return Object.values(items).reduce((sum, item) => {
const count = item.threads && typeof item.threads === 'object'
? Object.keys(item.threads).length
: 0;
return sum + count;
}, 0);
}
}
exports.Assistants = Assistants;
//# sourceMappingURL=assistant.js.map

@@ -14,3 +14,3 @@ import FactoryBase from '../factoryBase';

* @param {MessageCreateParams} MessageCreateParams - The parameters to create message.
* @returns Returns a promise that resolves with both the transaction result and a list including the new message.
* @returns A promise that resolves with both the transaction result and a list including the new message.
*/

@@ -25,3 +25,3 @@ create(objectId: string, tokenId: string, threadId: string, body: MessageCreateParams): Promise<MessagesTransactionResult>;

* @param {MessageUpdateParams} MessageUpdateParams - The parameters to update message.
* @returns Returns a promise that resolves with both the transaction result and the updated message.
* @returns A promise that resolves with both the transaction result and the updated message.
*/

@@ -36,3 +36,3 @@ update(objectId: string, tokenId: string, threadId: string, messageId: string, { metadata }: MessageUpdateParams): Promise<MessageTransactionResult>;

* @param {string} address - The checksum address of account.
* @returns Returns a promise that resolves with the message.
* @returns A promise that resolves with the message.
*/

@@ -46,3 +46,3 @@ get(objectId: string, tokenId: string, threadId: string, messageId: string, address: string): Promise<Message>;

* @param {string} address - The checksum address of account.
* @returns Returns a promise that resolves with the list of messages.
* @returns A promise that resolves with the list of messages.
*/

@@ -49,0 +49,0 @@ list(objectId: string, tokenId: string, threadId: string, address: string): Promise<MessageMap>;

@@ -51,3 +51,3 @@ "use strict";

* @param {MessageCreateParams} MessageCreateParams - The parameters to create message.
* @returns Returns a promise that resolves with both the transaction result and a list including the new message.
* @returns A promise that resolves with both the transaction result and a list including the new message.
*/

@@ -79,3 +79,3 @@ create(objectId, tokenId, threadId, body) {

* @param {MessageUpdateParams} MessageUpdateParams - The parameters to update message.
* @returns Returns a promise that resolves with both the transaction result and the updated message.
* @returns A promise that resolves with both the transaction result and the updated message.
*/

@@ -112,3 +112,3 @@ update(objectId, tokenId, threadId, messageId, { metadata }) {

* @param {string} address - The checksum address of account.
* @returns Returns a promise that resolves with the message.
* @returns A promise that resolves with the message.
*/

@@ -140,3 +140,3 @@ get(objectId, tokenId, threadId, messageId, address) {

* @param {string} address - The checksum address of account.
* @returns Returns a promise that resolves with the list of messages.
* @returns A promise that resolves with the list of messages.
*/

@@ -143,0 +143,0 @@ list(objectId, tokenId, threadId, address) {

@@ -13,3 +13,3 @@ import FactoryBase from '../factoryBase';

* @param {ThreadCreateParams} ThreadCreateParams - The parameters to create thread.
* @returns Returns a promise that resolves with both the transaction result and the created thread.
* @returns A promise that resolves with both the transaction result and the created thread.
*/

@@ -23,3 +23,3 @@ create(objectId: string, tokenId: string, { metadata }: ThreadCreateParams): Promise<ThreadTransactionResult>;

* @param {ThreadUpdateParams} ThreadUpdateParams - The parameters to update thread.
* @returns Returns a promise that resolves with both the transaction result and the updated thread.
* @returns A promise that resolves with both the transaction result and the updated thread.
*/

@@ -32,3 +32,3 @@ update(objectId: string, tokenId: string, threadId: string, { metadata }: ThreadUpdateParams): Promise<ThreadTransactionResult>;

* @param {string} threadId - The ID of thread.
* @returns Returns a promise that resolves with both the transaction result and the deleted thread.
* @returns A promise that resolves with both the transaction result and the deleted thread.
*/

@@ -42,3 +42,3 @@ delete(objectId: string, tokenId: string, threadId: string): Promise<ThreadDeleteTransactionResult>;

* @param {string} address - The checksum address of account.
* @returns Returns a promise that resolves with the thread.
* @returns A promise that resolves with the thread.
*/

@@ -52,3 +52,3 @@ get(objectId: string, tokenId: string, threadId: string, address: string): Promise<Thread>;

* @param {QueryParams} QueryParams - The parameters for querying items.
* @returns Returns a promise that resolves with the list of threads.
* @returns A promise that resolves with the list of threads.
*/

@@ -55,0 +55,0 @@ list(objectId: string, tokenId?: string | null, address?: string | null, { limit, offset, order }?: QueryParams): Promise<{

@@ -34,3 +34,3 @@ "use strict";

* @param {ThreadCreateParams} ThreadCreateParams - The parameters to create thread.
* @returns Returns a promise that resolves with both the transaction result and the created thread.
* @returns A promise that resolves with both the transaction result and the created thread.
*/

@@ -75,3 +75,3 @@ create(objectId, tokenId, { metadata }) {

* @param {ThreadUpdateParams} ThreadUpdateParams - The parameters to update thread.
* @returns Returns a promise that resolves with both the transaction result and the updated thread.
* @returns A promise that resolves with both the transaction result and the updated thread.
*/

@@ -104,3 +104,3 @@ update(objectId, tokenId, threadId, { metadata }) {

* @param {string} threadId - The ID of thread.
* @returns Returns a promise that resolves with both the transaction result and the deleted thread.
* @returns A promise that resolves with both the transaction result and the deleted thread.
*/

@@ -134,3 +134,3 @@ delete(objectId, tokenId, threadId) {

* @param {string} address - The checksum address of account.
* @returns Returns a promise that resolves with the thread.
* @returns A promise that resolves with the thread.
*/

@@ -165,3 +165,3 @@ get(objectId, tokenId, threadId, address) {

* @param {QueryParams} QueryParams - The parameters for querying items.
* @returns Returns a promise that resolves with the list of threads.
* @returns A promise that resolves with the list of threads.
*/

@@ -168,0 +168,0 @@ list(objectId, tokenId, address, { limit = 20, offset = 0, order = 'desc' } = {}) {

@@ -1,4 +0,5 @@

import { AinftToken } from "./ainftToken";
import FactoryBase from "./factoryBase";
import Ain from "@ainblockchain/ain-js";
import { AinftToken } from './ainftToken';
import FactoryBase from './factoryBase';
import { Metadata } from './types';
import Ain from '@ainblockchain/ain-js';
/**

@@ -18,2 +19,4 @@ * The class of AINFT 721 object.

readonly appId: string;
/** The metadata of AINFT object. */
readonly metadata?: Metadata;
/**

@@ -26,3 +29,4 @@ * Constructor of Ainft721Object.

* @param objectInfo.symbol The symbol of AINFT object.
* @param objectInfo.owner Owner of AINFT object.
* @param objectInfo.owner The owner of AINFT object.
* @param objectInfo.metadata The metadata of AINFT object.
* @param ain Ain instance to sign and send transaction to AIN blockchain.

@@ -36,2 +40,3 @@ * @param baseUrl The base url to request api to AINFT factory server.

owner: string;
metadata?: Metadata;
}, ain: Ain, baseUrl: string);

@@ -38,0 +43,0 @@ /**

@@ -29,3 +29,4 @@ "use strict";

* @param objectInfo.symbol The symbol of AINFT object.
* @param objectInfo.owner Owner of AINFT object.
* @param objectInfo.owner The owner of AINFT object.
* @param objectInfo.metadata The metadata of AINFT object.
* @param ain Ain instance to sign and send transaction to AIN blockchain.

@@ -41,2 +42,3 @@ * @param baseUrl The base url to request api to AINFT factory server.

this.appId = Ainft721Object.getAppId(objectInfo.id);
this.metadata = objectInfo.metadata || {};
}

@@ -64,3 +66,8 @@ /**

const token = nfts[0];
return new ainftToken_1.AinftToken({ ainftObjectId: this.id, tokenId, tokenURI: token.tokenURI, metadata: token.metadata }, this.ain, this.baseUrl);
return new ainftToken_1.AinftToken({
ainftObjectId: this.id,
tokenId,
tokenURI: token.tokenURI,
metadata: token.metadata,
}, this.ain, this.baseUrl);
});

@@ -67,0 +74,0 @@ }

import FactoryBase from './factoryBase';
import { DeleteAssetParams, NftSearchParams, UploadAssetFromBufferParams, UploadAssetFromDataUrlParams, AinftTokenSearchResponse, AinftObjectSearchResponse } from './types';
import { DeleteAssetParams, NftSearchParams, UploadAssetFromBufferParams, UploadAssetFromDataUrlParams, AinftTokenSearchResponse, AinftObjectSearchResponse, AinftObjectCreateParams } from './types';
import Ainft721Object from './ainft721Object';

@@ -30,3 +30,3 @@ /**

*/
create(name: string, symbol: string): Promise<{
create({ name, symbol, metadata }: AinftObjectCreateParams): Promise<{
txHash: string;

@@ -33,0 +33,0 @@ ainftObject: Ainft721Object;

@@ -15,2 +15,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
const lodash_1 = __importDefault(require("lodash"));
const factoryBase_1 = __importDefault(require("./factoryBase"));

@@ -47,6 +48,8 @@ const types_1 = require("./types");

*/
create(name, symbol) {
create({ name, symbol, metadata }) {
return __awaiter(this, void 0, void 0, function* () {
const address = yield this.ain.signer.getAddress();
const body = { address, name, symbol };
const body = Object.assign({ address,
name,
symbol }, (metadata && !lodash_1.default.isEmpty(metadata) && { metadata }));
const trailingUrl = 'native';

@@ -53,0 +56,0 @@ const { ainftObjectId, txBody } = yield this.sendRequest(types_1.HttpMethod.POST, trailingUrl, body);

@@ -997,3 +997,3 @@ /// <reference types="node" />

}
export interface AinftObjectSearchResponse extends SearchReponse {
export interface AinftObjectSearchResponse extends SearchResponse {
ainftObjects: {

@@ -1006,3 +1006,3 @@ id: string;

}
export interface AinftTokenSearchResponse extends SearchReponse {
export interface AinftTokenSearchResponse extends SearchResponse {
nfts: {

@@ -1016,6 +1016,17 @@ tokenId: string;

}
export interface SearchReponse {
export interface SearchResponse {
isFinal: boolean;
cursor?: string;
}
export interface Metadata {
[key: string]: any;
}
export interface AinftObjectCreateParams {
/** The name of the AINFT object. */
name: string;
/** The symbol of the AINFT object. */
symbol: string;
/** The metadata of the AINFT object. */
metadata?: Metadata;
}
export declare enum ServiceType {

@@ -1115,2 +1126,6 @@ CHAT = "chat"

metadata: object | null;
/** The metric of the assistant. */
metric?: {
[key: string]: number;
} | null;
/** The UNIX timestamp in seconds. */

@@ -1117,0 +1132,0 @@ created_at: number;

@@ -5,3 +5,3 @@ {

"types": "dist/ainft.d.ts",
"version": "2.1.0-beta.27",
"version": "2.1.0-beta.28",
"engines": {

@@ -8,0 +8,0 @@ "node": ">=16"

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet