repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
oisy-wallet
github_2023
dfinity
typescript
execPromise
function execPromise({ command }: { command: string; }): Promise<{ stdout: string; stderr: string }> { return execAsync(command).catch((err: ExecException & { stdout: string; stderr: string }) => { // Mimic the original error handling: reject with new Error(stderr) throw new Error(err.stderr); }); }
// 1) Wrap 'exec' in a promise using promisify
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/e2e/utils/commands/runner.ts#L16-L25
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
HomepageLoggedOut.waitForReady
async waitForReady(): Promise<void> { await this.waitForHomepageReady(); await this.waitForLoadState(); }
/** * @override */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/e2e/utils/pages/homepage.page.ts#L377-L380
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
HomepageLoggedIn.waitForReady
async waitForReady(): Promise<void> { await this.waitForAuthentication(); await this.waitForLoaderModal(); await this.waitForLoaderModal({ state: 'hidden', timeout: 60000 }); await this.waitForContentReady(); }
/** * @override */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/e2e/utils/pages/homepage.page.ts#L452-L460
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
filterCommittedSns
const filterCommittedSns = ({ swap_state: { swap: { lifecycle } } }: ResponseData) => lifecycle === 3;
// 3 === Committed
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/scripts/build.tokens.sns.ts#L152-L156
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
initBtcPendingSentTransactionsStore
const initBtcPendingSentTransactionsStore = (): BtcPendingSentTransactionsStore => { const { update, set, subscribe } = writable<BtcPendingSentTransactionsStoreData>({}); return { subscribe, setPendingTransactions({ address, pendingTransactions: pendingTransactions }: { address: Address; pendingTra...
/** * Bitcoin transations take time to confirm. * After a user sends a transaction, while a transaction is pending, * its utxos cannot be used, but they might still be available. * Instead of trying ot be smart, for now we'll disable transactions until they are confirmed. * * This store is used to keep track of p...
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/btc/stores/btc-pending-sent-transactions.store.ts#L30-L63
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
AlchemyErc20Provider.constructor
constructor(private readonly providerUrl: string) { this.provider = new JsonRpcProvider(`${this.providerUrl}/${ALCHEMY_API_KEY}`); }
// AlchemyProvider of ether.js does not support Sepolia
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/eth/providers/alchemy-erc20.providers.ts#L25-L27
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
filterListener
const filterListener = async ( _from: string, _address: string, _value: BigNumber, transaction: Erc20Transaction ) => { const { transactionHash: hash, args } = transaction; const [_from_, _to_, value] = args; await listener({ hash, value }); };
// eslint-disable-next-line local-rules/prefer-object-params -- This function needs to have listed arguments to match the Listener type passed to ethers.js providers
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/eth/providers/alchemy-erc20.providers.ts#L41-L50
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
InfuraErc20IcpProvider.populateTransaction
populateTransaction = ({ contract: { address: contractAddress }, to, amount }: PopulateTransactionParams & { amount: BigNumber }): Promise<PopulatedTransaction> => { const erc20Contract = new ethers.Contract(contractAddress, ERC20_ICP_ABI, this.provider); return erc20Contract.populateTransaction.burnToAccoun...
/** * @override */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/eth/providers/infura-erc20-icp.providers.ts
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
InfuraErc20Provider.populateTransaction
populateTransaction = ({ contract: { address: contractAddress }, to, amount }: { contract: Erc20ContractAddress; to: EthAddress; amount: BigNumber; }): Promise<PopulatedTransaction> => { const erc20Contract = new ethers.Contract(contractAddress, ERC20_ABI, this.provider); return erc20Contract.populate...
// Transaction send: https://ethereum.stackexchange.com/a/131944
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/eth/providers/infura-erc20.providers.ts
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
loadDefaultErc20Tokens
const loadDefaultErc20Tokens = async (): Promise<ResultSuccess> => { try { type ContractData = Erc20Contract & Erc20Metadata & { network: EthereumNetwork } & Pick<Erc20Token, 'category'> & Partial<Pick<Erc20Token, 'id'>>; const loadKnownContracts = (): Promise<ContractData>[] => ERC20_CONTRACTS.map( ...
// TODO(GIX-2740): use environment static metadata
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/eth/services/erc20.services.ts#L33-L63
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
ckErc20HelperContractPrepareTransaction
const ckErc20HelperContractPrepareTransaction = async ({ contract, to, amount, networkId, token, ...rest }: TransferParams & NetworkChainId & { nonce: number; gas: bigint; contract: Erc20ContractAddress; networkId: NetworkId; } & Pick<SendParams, 'token'>): Promise<EthSignTransactionRequest> => { const...
/** * {@link https://github.com/dfinity/ic/blob/master/rs/ethereum/cketh/docs/ckerc20.adoc#deposit-erc20-to-ckerc20} */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/eth/services/send.services.ts#L139-L172
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
erc20ContractAllowance
const erc20ContractAllowance = async ({ token, owner, spender, networkId }: { networkId: NetworkId; owner: EthAddress; spender: EthAddress; } & Pick<SendParams, 'token'>): Promise<BigNumber> => { const { allowance } = infuraErc20Providers(networkId); return await allowance({ contract: token as Erc20Token, ...
/** * Get the current allowance of an Erc20 contract. */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/eth/services/send.services.ts#L177-L194
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
erc20ContractPrepareApprove
const erc20ContractPrepareApprove = async ({ amount, token, spender, networkId, ...rest }: Omit<TransferParams, 'to' | 'from'> & NetworkChainId & { nonce: number; gas: bigint; networkId: NetworkId; spender: EthAddress; } & Pick<SendParams, 'token'>): Promise<EthSignTransactionRequest> => { const { popul...
/** * Prepare an Erc20 contract to approve a transaction from another contract (address). * i.e. tell an Erc20 contract to approve a transaction from the ckErc20 helper. * * {@link https://github.com/dfinity/ic/blob/master/rs/ethereum/cketh/docs/ckerc20.adoc#deposit-erc20-to-ckerc20} */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/eth/services/send.services.ts#L202-L231
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
IcWalletBalanceScheduler.syncWallet
protected syncWallet = async ({ identity, ...data }: SchedulerJobData<PostMessageDataRequest>) => { await queryAndUpdate<bigint>({ request: ({ identity: _, certified }) => this.getBalance({ ...data, identity, certified }), onLoad: ({ certified, ...rest }) => this.syncBalance({ certified, ...rest }), onC...
/** * @override */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/icp/schedulers/ic-wallet-balance.scheduler.ts
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
IcWalletTransactionsScheduler.syncWallet
protected syncWallet = async ({ identity, ...data }: SchedulerJobData<PostMessageDataRequest>) => { await queryAndUpdate<GetTransactions & { transactions: TWithId[] }>({ request: ({ identity: _, certified }) => this.getTransactions({ ...data, identity, certified }), onLoad: ({ certified, ...rest }) => ...
/** * @override */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/icp/schedulers/ic-wallet-transactions.scheduler.ts
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
IcWalletTransactionsScheduler.cleanTransactions
private cleanTransactions({ certified }: { certified: boolean }) { if (!certified) { return; } const [certifiedTransactions, notCertifiedTransactions] = Object.entries( this.store.transactions ).reduce( ( [certified, notCertified]: [IndexedTransactions<T>, IndexedTransactions<T>], [key, data] ...
/** * For security reason, everytime we get an update results we check if there are remaining transactions not certified in memory. * If we find some, we prune those. Given that we are fetching transactions every X seconds, there should not be any query in memory when update calls have been resolved. */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/icp/schedulers/ic-wallet-transactions.scheduler.ts#L175-L212
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
waitCkBtcMinterInfoLoaded
const waitCkBtcMinterInfoLoaded = (): Promise<void> => new Promise<void>((resolve, reject) => { const isDisabled = (): boolean => { const $ckBtcMinterInfoStore = get(ckBtcMinterInfoStore); return isNullish($ckBtcMinterInfoStore?.[tokenId]); }; waitWalletReady(isDisabled).then((status) => (status ===...
// ckBTC minter info are loaded when accessing the ckBTC transactions page with a worker
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/icp/services/ckbtc.services.ts#L117-L125
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
loadIcrcCustomTokens
const loadIcrcCustomTokens = async (params: { identity: OptionIdentity; certified: boolean; }): Promise<IcrcCustomTokenWithoutId[]> => { const tokens = await listCustomTokens({ ...params, nullishIdentityErrorMessage: get(i18n).auth.error.no_internet_identity }); // We filter the custom tokens that are Icrc (t...
/** * @todo Add missing document and test for this function. */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/icp/services/icrc.services.ts#L109-L125
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
requestIcrcCustomTokenMetadata
const requestIcrcCustomTokenMetadata = async ( custom_token: CustomToken, index: number ): Promise<IcrcCustomTokenWithoutId | undefined> => { const { enabled, version: v, token } = custom_token; if (!('Icrc' in token)) { throw new Error('Token is not Icrc'); } const { Icrc: { ledger_id, index_id } ...
// eslint-disable-next-line local-rules/prefer-object-params -- This is a mapping function, so the parameters will be provided not as an object but as separate arguments.
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/icp/services/icrc.services.ts#L139-L185
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
idbAddressesStore
const idbAddressesStore = (key: string): UseStore => browser ? createStore(`oisy-${key}-addresses`, `${key}-addresses`) : ({} as unknown as UseStore);
// There is no IndexedDB in SSG. Since this initialization occurs at the module's root, SvelteKit would encounter an error during the dapp bundling process, specifically a "ReferenceError [Error]: indexedDB is not defined". Therefore, the object for bundling on NodeJS side.
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/api/idb.api.ts#L22-L23
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
BackendCanister.btcGetPendingTransaction
btcGetPendingTransaction = async ({ network, address }: BtcGetPendingTransactionParams): Promise<PendingTransaction[]> => { const { btc_get_pending_transactions } = this.caller({ certified: true }); const response = await btc_get_pending_transactions({ network, address }); if ('Ok' in response) { ...
// TODO: rename to plural
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/canisters/backend.canister.ts
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
clearTestnetsOption
const clearTestnetsOption = async () => { testnetsStore.reset({ key: 'testnets' }); };
// eslint-disable-next-line require-await
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/services/auth.services.ts#L120-L122
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
clearSessionStorage
const clearSessionStorage = async () => { sessionStorage.clear(); };
// eslint-disable-next-line require-await
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/services/auth.services.ts#L125-L127
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
appendMsgToUrl
const appendMsgToUrl = (msg: ToastMsg) => { const { text, level } = msg; const url: URL = new URL(window.location.href); url.searchParams.append(PARAM_MSG, encodeURI(text)); url.searchParams.append(PARAM_LEVEL, level); replaceHistory(url); };
/** * If a message was provided to the logout process - e.g. a message informing the logout happened because the session timed-out - append the information to the url as query params */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/services/auth.services.ts#L177-L186
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
_toastError
const _toastError = (value: PostMessageDataResponseExchangeError | undefined) => { const text = 'An error occurred while attempting to retrieve the USD exchange rates.' as const; const msg = value?.err; if (isNullish(msg)) { toastsError({ msg: { text } }); return; } const now = Da...
// If Coingecko throws an error, for instance, if too many requests are queried within the same minute, it is possible that the window may receive the same error twice because we start and stop the worker based on certain store changes.
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/services/worker.exchange.services.ts#L32-L73
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
escapeRegExp
const escapeRegExp = (regExpText: string): string => regExpText.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#escaping
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/utils/i18n.utils.ts
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
bytesToHexString
const bytesToHexString = (bytes: number[]): string => bytes.reduce((str, byte) => `${str}${byte.toString(16).padStart(2, '0')}`, '');
// Convert a byte array to a hex string
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/utils/json.utils.ts#L9-L10
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
supportsHistory
const supportsHistory = (): boolean => window.history !== undefined && 'pushState' in window.history && typeof window.history.pushState !== 'undefined';
/** * Test if the History API is supported by the devices. On old phones it might not be the case. * Source: https://stackoverflow.com/a/6825002/5404186 */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/utils/route.utils.ts#L17-L20
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
startIdleTimer
const startIdleTimer = () => (timer = setInterval(async () => await onIdleSignOut(), AUTH_TIMER_INTERVAL));
/** * The timer is executed only if user has signed in */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/workers/auth.worker.ts#L28-L29
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
checkAuthentication
const checkAuthentication = async (): Promise<boolean> => { const authClient: AuthClient = await createAuthClient(); return authClient.isAuthenticated(); };
/** * If user is not authenticated - i.e. no identity or anonymous and there is no valid delegation chain, then identity is not valid * * @returns true if authenticated */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/workers/auth.worker.ts#L57-L60
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
checkDelegationChain
const checkDelegationChain = async (): Promise<{ valid: boolean; delegation: DelegationChain | null; }> => { const idbStorage: IdbStorage = new IdbStorage(); const delegationChain: string | null = await idbStorage.get(KEY_STORAGE_DELEGATION); const delegation = delegationChain !== null ? DelegationChain.fromJSON(...
/** * If there is no delegation or if not valid, then delegation is not valid * * @returns true if delegation is valid */
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/workers/auth.worker.ts#L67-L80
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
logout
const logout = () => { // Clear timer to not emit sign-out multiple times stopIdleTimer(); postMessage({ msg: 'signOutIdleTimer' }); };
// We do the logout on the client side because we reload the window to reload stores afterwards
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/lib/workers/auth.worker.ts#L83-L88
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
SolWalletScheduler.loadTransactions
private loadTransactions = async ({ address, solanaNetwork, tokenAddress }: LoadSolWalletParams): Promise<SolCertifiedTransaction[]> => { const transactions = await getSolTransactions({ network: solanaNetwork, address, tokenAddress }); const transactionsUi = transactions.map((transaction) => ({ ...
// TODO add unit tests for spl txns
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/sol/schedulers/sol-wallet.scheduler.ts
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
saveCachedUserTokensToBackend
const saveCachedUserTokensToBackend = async ({ identity, savedTokens }: { identity: Identity; savedTokens: CustomToken[]; }): Promise<SplTokenAddress[]> => { const savedTokenAddresses = savedTokens.reduce<SplTokenAddress[]>( (acc, { token }) => [ ...acc, ...('SplMainnet' in token ? [token.SplMainnet.token_...
// This function is a temporary solution: save the user tokens that we were caching in the browser into the backend.
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/sol/services/spl.services.ts#L79-L131
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
oisy-wallet
github_2023
dfinity
typescript
callback
const callback = async () => { done(); };
// eslint-disable-next-line require-await
https://github.com/dfinity/oisy-wallet/blob/4e02d674d47e70be19097c8b6fedcaa2f8f8e19f/src/frontend/src/tests/lib/services/token.services.spec.ts#L39-L41
4e02d674d47e70be19097c8b6fedcaa2f8f8e19f
deck.gl-layers
github_2023
geoarrow
typescript
fetchData
const fetchData = async () => { const data = await fetch(GEOARROW_POINT_DATA); const buffer = await data.arrayBuffer(); const table = arrow.tableFromIPC(buffer); setTable(table); };
// declare the data fetching function
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/examples/linestring/app.tsx#L38-L43
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
fetchData
const fetchData = async () => { const data = await fetch(GEOARROW_MULTILINESTRING_DATA); const buffer = await data.arrayBuffer(); const table = arrow.tableFromIPC(buffer); console.log(table); setTable(table); };
// declare the data fetching function
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/examples/multilinestring/app.tsx#L45-L51
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
fetchData
const fetchData = async () => { const data = await fetch(GEOARROW_MULTIPOINT_DATA); const buffer = await data.arrayBuffer(); const table = arrow.tableFromIPC(buffer); console.log(table); setTable(table); };
// declare the data fetching function
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/examples/multipoint/app.tsx#L41-L47
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
fetchData
const fetchData = async () => { const data = await fetch(GEOARROW_POLYGON_DATA); const buffer = await data.arrayBuffer(); const table = arrow.tableFromIPC(buffer); setTable(table); };
// declare the data fetching function
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/examples/multipolygon/app.tsx#L38-L43
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
fetchData
const fetchData = async () => { const data = await fetch(GEOARROW_POINT_DATA); const buffer = await data.arrayBuffer(); const table = arrow.tableFromIPC(buffer); setTable(table); };
// declare the data fetching function
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/examples/point/app.tsx#L38-L43
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
fetchData
const fetchData = async () => { const data = await fetch(GEOARROW_POLYGON_DATA); const buffer = await data.arrayBuffer(); const table = arrow.tableFromIPC(buffer); const table2 = new arrow.Table(table.batches.slice(0, 10)); window.table = table2; setTable(table2); };
// declare the data fetching function
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/examples/polygon/app.tsx#L40-L47
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
fetchData
const fetchData = async () => { const data = await fetch(GEOARROW_POLYGON_DATA); const buffer = await data.arrayBuffer(); const table = arrow.tableFromIPC(buffer); setTable(table); };
// declare the data fetching function
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/examples/text/app.tsx#L37-L42
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
fetchData
const fetchData = async () => { const data = await fetch(GEOARROW_POINT_DATA); const buffer = await data.arrayBuffer(); const table = arrow.tableFromIPC(buffer); setTable(table); };
// declare the data fetching function
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/examples/trips/app.tsx#L55-L60
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
GeoArrowPolygonLayer._renderLayers
_renderLayers( geometryColumn: ga.vector.PolygonVector | ga.vector.MultiPolygonVector, ): Layer<{}> | LayersList | null { const { data: table } = this.props; let getPath: ga.vector.MultiLineStringVector; if (ga.vector.isPolygonVector(geometryColumn)) { getPath = getPolygonExterior(geometryColum...
// support multi-* and single- geometries.
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/src/layers/polygon-layer.ts#L233-L375
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
GeoArrowSolidPolygonLayer.initEarcutPool
async initEarcutPool(): Promise<Pool<FunctionThread> | null> { if (this.state.earcutWorkerPool) return this.state.earcutWorkerPool; const workerText = await this.state.earcutWorkerRequest; if (!workerText) { return null; } // Some environments are not able to execute `importScripts` // E...
// sure we never construct two pools?
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/src/layers/solid-polygon-layer.ts#L154-L185
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
convertStructToFixedSizeList
function convertStructToFixedSizeList( coords: | arrow.Data<arrow.FixedSizeList<arrow.Float64>> | arrow.Data<arrow.Struct<{ x: arrow.Float64; y: arrow.Float64 }>>, ): arrow.Data<arrow.FixedSizeList<arrow.Float64>> { if (isDataInterleavedCoords(coords)) { return coords; } else if (isDataSeparatedCoords...
/** * Convert geoarrow Struct coordinates to FixedSizeList coords * * The GeoArrow spec allows for either separated or interleaved coords, but at * this time deck.gl only supports interleaved. */
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/src/utils/utils.ts#L66-L104
598a62cdae112129e12d43067d4f724f3742c9ed
deck.gl-layers
github_2023
geoarrow
typescript
wrapAccessorFunction
function wrapAccessorFunction<In, Out>( objectInfo: _InternalAccessorContext<In>, userAccessorFunction: AccessorFunction<In, Out>, ): Out { const { index, data } = objectInfo; let newIndex = index; if (data.invertedGeomOffsets !== undefined) { newIndex = data.invertedGeomOffsets[index]; } const newObj...
/** * A wrapper around a user-provided accessor function * * For layers like Scatterplot, Path, and Polygon, we automatically handle * "exploding" the table when multi-geometry input are provided. This means that * the upstream `index` value passed to the user will be the correct row index * _only_ for non-explod...
https://github.com/geoarrow/deck.gl-layers/blob/598a62cdae112129e12d43067d4f724f3742c9ed/src/utils/utils.ts#L130-L150
598a62cdae112129e12d43067d4f724f3742c9ed
langgraph
github_2023
langchain-ai
typescript
callModel
const callModel = async ( state: typeof StateAnnotation.State, _config: RunnableConfig, ): Promise<typeof StateAnnotation.Update> => { /** * Do some work... (e.g. call an LLM) * For example, with LangChain you could do something like: * * ```bash * $ npm i @langchain/anthropic * ``` * * ``...
/** * Define a node, these do the work of the graph and should have most of the logic. * Must return a subset of the properties set in StateAnnotation. * @param state The current state of the graph. * @param config Extra parameters passed into the state graph. * @returns Some subset of parameters of the graph stat...
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/cli/js-examples/src/agent/graph.ts#L17-L68
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
CronsClient.createForThread
async createForThread( threadId: string, assistantId: string, payload?: CronsCreatePayload, ): Promise<CronCreateForThreadResponse> { const json: Record<string, any> = { schedule: payload?.schedule, input: payload?.input, config: payload?.config, metadata: payload?.metadata, ...
/** * * @param threadId The ID of the thread. * @param assistantId Assistant ID to use for this cron job. * @param payload Payload for creating a cron job. * @returns The created background run. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L186-L210
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
CronsClient.create
async create( assistantId: string, payload?: CronsCreatePayload, ): Promise<CronCreateResponse> { const json: Record<string, any> = { schedule: payload?.schedule, input: payload?.input, config: payload?.config, metadata: payload?.metadata, assistant_id: assistantId, int...
/** * * @param assistantId Assistant ID to use for this cron job. * @param payload Payload for creating a cron job. * @returns */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L218-L238
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
CronsClient.delete
async delete(cronId: string): Promise<void> { await this.fetch<void>(`/runs/crons/${cronId}`, { method: "DELETE", }); }
/** * * @param cronId Cron ID of Cron job to delete. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L244-L248
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
CronsClient.search
async search(query?: { assistantId?: string; threadId?: string; limit?: number; offset?: number; }): Promise<Cron[]> { return this.fetch<Cron[]>("/runs/crons/search", { method: "POST", json: { assistant_id: query?.assistantId ?? undefined, thread_id: query?.threadId ?? ...
/** * * @param query Query options. * @returns List of crons. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L255-L270
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AssistantsClient.get
async get(assistantId: string): Promise<Assistant> { return this.fetch<Assistant>(`/assistants/${assistantId}`); }
/** * Get an assistant by ID. * * @param assistantId The ID of the assistant. * @returns Assistant */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L280-L282
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AssistantsClient.getGraph
async getGraph( assistantId: string, options?: { xray?: boolean | number }, ): Promise<AssistantGraph> { return this.fetch<AssistantGraph>(`/assistants/${assistantId}/graph`, { params: { xray: options?.xray }, }); }
/** * Get the JSON representation of the graph assigned to a runnable * @param assistantId The ID of the assistant. * @param options.xray Whether to include subgraphs in the serialized graph representation. If an integer value is provided, only subgraphs with a depth less than or equal to the value will be inc...
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L290-L297
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AssistantsClient.getSchemas
async getSchemas(assistantId: string): Promise<GraphSchema> { return this.fetch<GraphSchema>(`/assistants/${assistantId}/schemas`); }
/** * Get the state and config schema of the graph assigned to a runnable * @param assistantId The ID of the assistant. * @returns Graph schema */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L304-L306
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AssistantsClient.getSubgraphs
async getSubgraphs( assistantId: string, options?: { namespace?: string; recurse?: boolean; }, ): Promise<Subgraphs> { if (options?.namespace) { return this.fetch<Subgraphs>( `/assistants/${assistantId}/subgraphs/${options.namespace}`, { params: { recurse: options?.re...
/** * Get the schemas of an assistant by ID. * * @param assistantId The ID of the assistant to get the schema of. * @param options Additional options for getting subgraphs, such as namespace or recursion extraction. * @returns The subgraphs of the assistant. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L315-L331
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AssistantsClient.create
async create(payload: { graphId: string; config?: Config; metadata?: Metadata; assistantId?: string; ifExists?: OnConflictBehavior; name?: string; }): Promise<Assistant> { return this.fetch<Assistant>("/assistants", { method: "POST", json: { graph_id: payload.graphId, ...
/** * Create a new assistant. * @param payload Payload for creating an assistant. * @returns The created assistant. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L338-L357
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AssistantsClient.update
async update( assistantId: string, payload: { graphId?: string; config?: Config; metadata?: Metadata; name?: string; }, ): Promise<Assistant> { return this.fetch<Assistant>(`/assistants/${assistantId}`, { method: "PATCH", json: { graph_id: payload.graphId, ...
/** * Update an assistant. * @param assistantId ID of the assistant. * @param payload Payload for updating the assistant. * @returns The updated assistant. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L365-L383
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AssistantsClient.delete
async delete(assistantId: string): Promise<void> { return this.fetch<void>(`/assistants/${assistantId}`, { method: "DELETE", }); }
/** * Delete an assistant. * * @param assistantId ID of the assistant. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L390-L394
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AssistantsClient.search
async search(query?: { graphId?: string; metadata?: Metadata; limit?: number; offset?: number; }): Promise<Assistant[]> { return this.fetch<Assistant[]>("/assistants/search", { method: "POST", json: { graph_id: query?.graphId ?? undefined, metadata: query?.metadata ?? u...
/** * List assistants. * @param query Query options. * @returns List of assistants. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L401-L416
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AssistantsClient.getVersions
async getVersions( assistantId: string, payload?: { metadata?: Metadata; limit?: number; offset?: number; }, ): Promise<AssistantVersion[]> { return this.fetch<AssistantVersion[]>( `/assistants/${assistantId}/versions`, { method: "POST", json: { ...
/** * List all versions of an assistant. * * @param assistantId ID of the assistant. * @returns List of assistant versions. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L424-L443
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AssistantsClient.setLatest
async setLatest(assistantId: string, version: number): Promise<Assistant> { return this.fetch<Assistant>(`/assistants/${assistantId}/latest`, { method: "POST", json: { version }, }); }
/** * Change the version of an assistant. * * @param assistantId ID of the assistant. * @param version The version to change to. * @returns The updated assistant. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L452-L457
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
ThreadsClient.get
async get(threadId: string): Promise<Thread> { return this.fetch<Thread>(`/threads/${threadId}`); }
/** * Get a thread by ID. * * @param threadId ID of the thread. * @returns The thread. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L467-L469
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
ThreadsClient.create
async create(payload?: { /** * Metadata for the thread. */ metadata?: Metadata; threadId?: string; ifExists?: OnConflictBehavior; }): Promise<Thread> { return this.fetch<Thread>(`/threads`, { method: "POST", json: { metadata: payload?.metadata, thread_id: payl...
/** * Create a new thread. * * @param payload Payload for creating a thread. * @returns The created thread. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L477-L493
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
ThreadsClient.copy
async copy(threadId: string): Promise<Thread> { return this.fetch<Thread>(`/threads/${threadId}/copy`, { method: "POST", }); }
/** * Copy an existing thread * @param threadId ID of the thread to be copied * @returns Newly copied thread */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L500-L504
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
ThreadsClient.update
async update( threadId: string, payload?: { /** * Metadata for the thread. */ metadata?: Metadata; }, ): Promise<Thread> { return this.fetch<Thread>(`/threads/${threadId}`, { method: "PATCH", json: { metadata: payload?.metadata }, }); }
/** * Update a thread. * * @param threadId ID of the thread. * @param payload Payload for updating the thread. * @returns The updated thread. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L513-L526
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
ThreadsClient.delete
async delete(threadId: string): Promise<void> { return this.fetch<void>(`/threads/${threadId}`, { method: "DELETE", }); }
/** * Delete a thread. * * @param threadId ID of the thread. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L533-L537
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
ThreadsClient.search
async search(query?: { /** * Metadata to filter threads by. */ metadata?: Metadata; /** * Maximum number of threads to return. * Defaults to 10 */ limit?: number; /** * Offset to start from. */ offset?: number; /** * Thread status to filter on. * ...
/** * List threads * * @param query Query options * @returns List of threads */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L545-L574
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
ThreadsClient.getState
async getState<ValuesType = DefaultValues>( threadId: string, checkpoint?: Checkpoint | string, options?: { subgraphs?: boolean }, ): Promise<ThreadState<ValuesType>> { if (checkpoint != null) { if (typeof checkpoint !== "string") { return this.fetch<ThreadState<ValuesType>>( `...
/** * Get state for a thread. * * @param threadId ID of the thread. * @returns Thread state. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L582-L608
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
ThreadsClient.updateState
async updateState<ValuesType = DefaultValues>( threadId: string, options: { values: ValuesType; checkpoint?: Checkpoint; checkpointId?: string; asNode?: string; }, ): Promise<Pick<Config, "configurable">> { return this.fetch<Pick<Config, "configurable">>( `/threads/${thre...
/** * Add state to a thread. * * @param threadId The ID of the thread. * @returns */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L616-L637
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
ThreadsClient.patchState
async patchState( threadIdOrConfig: string | Config, metadata: Metadata, ): Promise<void> { let threadId: string; if (typeof threadIdOrConfig !== "string") { if (typeof threadIdOrConfig.configurable.thread_id !== "string") { throw new Error( "Thread ID is required when updatin...
/** * Patch the metadata of a thread. * * @param threadIdOrConfig Thread ID or config to patch the state of. * @param metadata Metadata to patch the state with. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L645-L666
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
ThreadsClient.getHistory
async getHistory<ValuesType = DefaultValues>( threadId: string, options?: { limit?: number; before?: Config; checkpoint?: Partial<Omit<Checkpoint, "thread_id">>; metadata?: Metadata; }, ): Promise<ThreadState<ValuesType>[]> { return this.fetch<ThreadState<ValuesType>[]>( ...
/** * Get all past states for a thread. * * @param threadId ID of the thread. * @param options Additional options. * @returns List of thread states. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L675-L696
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
RunsClient.stream
async *stream( threadId: string | null, assistantId: string, payload?: RunsStreamPayload, ): AsyncGenerator<{ event: StreamEvent; data: any; }> { const json: Record<string, any> = { input: payload?.input, command: payload?.command, config: payload?.config, metadata: p...
/** * Create a run and stream the results. * * @param threadId The ID of the thread. * @param assistantId Assistant ID to use for this run. * @param payload Payload for creating a run. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L725-L807
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
RunsClient.create
async create( threadId: string, assistantId: string, payload?: RunsCreatePayload, ): Promise<Run> { const json: Record<string, any> = { input: payload?.input, command: payload?.command, config: payload?.config, metadata: payload?.metadata, stream_mode: payload?.streamMode...
/** * Create a run. * * @param threadId The ID of the thread. * @param assistantId Assistant ID to use for this run. * @param payload Payload for creating a run. * @returns The created run. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L817-L844
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
RunsClient.createBatch
async createBatch( payloads: (RunsCreatePayload & { assistantId: string })[], ): Promise<Run[]> { const filteredPayloads = payloads .map((payload) => ({ ...payload, assistant_id: payload.assistantId })) .map((payload) => { return Object.fromEntries( Object.entries(payload).filter...
/** * Create a batch of stateless background runs. * * @param payloads An array of payloads for creating runs. * @returns An array of created runs. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L852-L867
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
RunsClient.wait
async wait( threadId: string | null, assistantId: string, payload?: RunsWaitPayload, ): Promise<ThreadState["values"]> { const json: Record<string, any> = { input: payload?.input, command: payload?.command, config: payload?.config, metadata: payload?.metadata, assistant_i...
/** * Create a run and wait for it to complete. * * @param threadId The ID of the thread. * @param assistantId Assistant ID to use for this run. * @param payload Payload for creating a run. * @returns The last values chunk of the thread. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L889-L934
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
RunsClient.list
async list( threadId: string, options?: { /** * Maximum number of runs to return. * Defaults to 10 */ limit?: number; /** * Offset to start from. * Defaults to 0. */ offset?: number; /** * Status of the run to filter by. */ ...
/** * List all runs for a thread. * * @param threadId The ID of the thread. * @param options Filtering and pagination options. * @returns List of runs. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L943-L971
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
RunsClient.get
async get(threadId: string, runId: string): Promise<Run> { return this.fetch<Run>(`/threads/${threadId}/runs/${runId}`); }
/** * Get a run by ID. * * @param threadId The ID of the thread. * @param runId The ID of the run. * @returns The run. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L980-L982
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
RunsClient.cancel
async cancel( threadId: string, runId: string, wait: boolean = false, action: CancelAction = "interrupt", ): Promise<void> { return this.fetch<void>(`/threads/${threadId}/runs/${runId}/cancel`, { method: "POST", params: { wait: wait ? "1" : "0", action: action, },...
/** * Cancel a run. * * @param threadId The ID of the thread. * @param runId The ID of the run. * @param wait Whether to block when canceling * @param action Action to take when cancelling the run. Possible values are `interrupt` or `rollback`. Default is `interrupt`. * @returns */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L993-L1006
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
RunsClient.join
async join( threadId: string, runId: string, options?: { signal?: AbortSignal }, ): Promise<void> { return this.fetch<void>(`/threads/${threadId}/runs/${runId}/join`, { timeoutMs: null, signal: options?.signal, }); }
/** * Block until a run is done. * * @param threadId The ID of the thread. * @param runId The ID of the run. * @returns */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L1015-L1024
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
RunsClient.joinStream
async *joinStream( threadId: string, runId: string, options?: | { signal?: AbortSignal; cancelOnDisconnect?: boolean } | AbortSignal, ): AsyncGenerator<{ event: StreamEvent; data: any }> { const opts = typeof options === "object" && options != null && options instanceof A...
/** * Stream output from a run in real-time, until the run is done. * Output is not buffered, so any output produced before this call will * not be received here. * * @param threadId The ID of the thread. * @param runId The ID of the run. * @returns An async generator yielding stream parts. */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L1035-L1100
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
RunsClient.delete
async delete(threadId: string, runId: string): Promise<void> { return this.fetch<void>(`/threads/${threadId}/runs/${runId}`, { method: "DELETE", }); }
/** * Delete a run. * * @param threadId The ID of the thread. * @param runId The ID of the run. * @returns */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L1109-L1113
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
StoreClient.putItem
async putItem( namespace: string[], key: string, value: Record<string, any>, ): Promise<void> { namespace.forEach((label) => { if (label.includes(".")) { throw new Error( `Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`, ); } ...
/** * Store or update an item. * * @param namespace A list of strings representing the namespace path. * @param key The unique identifier for the item within the namespace. * @param value A dictionary containing the item's data. * @returns Promise<void> */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L1136-L1159
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
StoreClient.getItem
async getItem(namespace: string[], key: string): Promise<Item | null> { namespace.forEach((label) => { if (label.includes(".")) { throw new Error( `Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`, ); } }); const response = await this....
/** * Retrieve a single item. * * @param namespace A list of strings representing the namespace path. * @param key The unique identifier for the item. * @returns Promise<Item> */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L1168-L1188
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
StoreClient.deleteItem
async deleteItem(namespace: string[], key: string): Promise<void> { namespace.forEach((label) => { if (label.includes(".")) { throw new Error( `Invalid namespace label '${label}'. Namespace labels cannot contain periods ('.')`, ); } }); return this.fetch<void>("/store/...
/** * Delete an item. * * @param namespace A list of strings representing the namespace path. * @param key The unique identifier for the item. * @returns Promise<void> */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L1197-L1210
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
StoreClient.searchItems
async searchItems( namespacePrefix: string[], options?: { filter?: Record<string, any>; limit?: number; offset?: number; query?: string; }, ): Promise<SearchItemsResponse> { const payload = { namespace_prefix: namespacePrefix, filter: options?.filter, limit: o...
/** * Search for items within a namespace prefix. * * @param namespacePrefix List of strings representing the namespace prefix. * @param options.filter Optional dictionary of key-value pairs to filter results. * @param options.limit Maximum number of items to return (default is 10). * @param options.o...
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L1222-L1253
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
StoreClient.listNamespaces
async listNamespaces(options?: { prefix?: string[]; suffix?: string[]; maxDepth?: number; limit?: number; offset?: number; }): Promise<ListNamespaceResponse> { const payload = { prefix: options?.prefix, suffix: options?.suffix, max_depth: options?.maxDepth, limit: optio...
/** * List namespaces with optional match conditions. * * @param options.prefix Optional list of strings representing the prefix to filter namespaces. * @param options.suffix Optional list of strings representing the suffix to filter namespaces. * @param options.maxDepth Optional integer specifying the m...
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/client.ts#L1265-L1284
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
DEFAULT_FETCH_IMPLEMENTATION
const DEFAULT_FETCH_IMPLEMENTATION = (...args: any[]) => fetch(...args);
// Wrap the default fetch call due to issues with illegal invocations
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/singletons/fetch.ts#L5-L5
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
isResponse
function isResponse(x: unknown): x is Response { if (x == null || typeof x !== "object") return false; return "status" in x && "statusText" in x && "text" in x; }
/** * Do not rely on globalThis.Response, rather just * do duck typing */
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/utils/async_caller.ts#L52-L55
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AsyncCaller.call
call<A extends any[], T extends (...args: A) => Promise<any>>( callable: T, ...args: Parameters<T> ): Promise<Awaited<ReturnType<T>>> { const onFailedResponseHook = this.onFailedResponseHook; return this.queue.add( () => pRetry( () => callable(...(args as Parameters...
// eslint-disable-next-line @typescript-eslint/no-explicit-any
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/utils/async_caller.ts#L135-L189
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
AsyncCaller.callWithOptions
callWithOptions<A extends any[], T extends (...args: A) => Promise<any>>( options: AsyncCallerCallOptions, callable: T, ...args: Parameters<T> ): Promise<Awaited<ReturnType<T>>> { // Note this doesn't cancel the underlying request, // when available prefer to use the signal option of the underlyin...
// eslint-disable-next-line @typescript-eslint/no-explicit-any
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/utils/async_caller.ts#L192-L210
e81979827f8311cbcd21c743485329949746a3e3
langgraph
github_2023
langchain-ai
typescript
IterableReadableStream.throw
async throw(e: any): Promise<IteratorResult<T>> { this.ensureReader(); if (this.locked) { const cancelPromise = this.reader.cancel(); // cancel first, but don't await yet this.reader.releaseLock(); // release lock first await cancelPromise; // now await it } throw e; }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
https://github.com/langchain-ai/langgraph/blob/e81979827f8311cbcd21c743485329949746a3e3/libs/sdk-js/src/utils/stream.ts#L54-L62
e81979827f8311cbcd21c743485329949746a3e3
copilot
github_2023
openchatai
typescript
parseNestedJSON
const parseNestedJSON = (obj: Record<string, any>) => { Object.keys(obj).forEach((key) => { const value = obj[key]; if (typeof value === "string") { if ( (value.startsWith("{") && value.endsWith("}")) || (value.startsWith("[") && value.endsWith("]")) ...
// Recursively parse nested JSON strings or arrays
https://github.com/openchatai/copilot/blob/7373cf7a7ba21b58e1213faa18202ef9ee7ec253/copilot-widget/lib/contexts/messageHandler.tsx#L18-L36
7373cf7a7ba21b58e1213faa18202ef9ee7ec253
copilot
github_2023
openchatai
typescript
ChatController.appendToCurrentBotMessage
appendToCurrentBotMessage = (message: string) => { const currentUserMessage = this.state.currentUserMessage; if (!currentUserMessage) { return; } // Append the message content to the existing botmessage.type=TEXT or create a new one const botMessage = this.select("messages").find( (msg...
// Called for every character recived from the bot
https://github.com/openchatai/copilot/blob/7373cf7a7ba21b58e1213faa18202ef9ee7ec253/copilot-widget/lib/contexts/messageHandler.tsx
7373cf7a7ba21b58e1213faa18202ef9ee7ec253
copilot
github_2023
openchatai
typescript
Field
function Field< TFieldValues extends FieldValues = FieldValues, TName extends FieldPath<TFieldValues> = FieldPath<TFieldValues> >({ required, label, description, name, control, render, className, }: { name: TName; required?: boolean; label?: string; description?: string; // eslint-disable-ne...
// use this
https://github.com/openchatai/copilot/blob/7373cf7a7ba21b58e1213faa18202ef9ee7ec253/dashboard/components/ui/form.tsx#L173-L212
7373cf7a7ba21b58e1213faa18202ef9ee7ec253
copilot
github_2023
openchatai
typescript
isModifiedEvent
function isModifiedEvent(event: React.MouseEvent): boolean { const eventTarget = event.currentTarget as HTMLAnchorElement | SVGAElement; const target = eventTarget.getAttribute("target"); return ( (target && target !== "_self") || event.metaKey || event.ctrlKey || event.shiftKey || event.altKe...
// https://github.com/vercel/next.js/blob/400ccf7b1c802c94127d8d8e0d5e9bdf9aab270c/packages/next/src/client/link.tsx#L169
https://github.com/openchatai/copilot/blob/7373cf7a7ba21b58e1213faa18202ef9ee7ec253/dashboard/lib/router-events/patch-router/should-trigger-start-event.ts#L9-L20
7373cf7a7ba21b58e1213faa18202ef9ee7ec253
biomes-game
github_2023
ill-inc
typescript
createBiomes
function createBiomes() { return [ // Asset Server biomesIngress({ name: "asset", }), biomesDisruptionBudget("asset"), ...biomesDeployment({ ...SERVICE_DEFAULTS, name: "asset", entryPoint: "web", replicas: 1, http: true, args: [...BASE_CONFIG_ARGS, "-a", "...
// Define the Biomes service layout.
https://github.com/ill-inc/biomes-game/blob/14252b95bf9e68495655af40c72750e8e3c44a42/deploy/k8/biomes.ts#L57-L333
14252b95bf9e68495655af40c72750e8e3c44a42
biomes-game
github_2023
ill-inc
typescript
writeYamlFile
async function writeYamlFile(filePath: string) { await writeFile( filePath, "# Generated by biomes.ts - DO NOT MANUALLY EDIT!\n\n" + createBiomes() .map((x) => k8s.dumpYaml(x)) .join("---\n"), { encoding: "utf-8" } ); }
// Write to file deploy/k8/biomes.yaml
https://github.com/ill-inc/biomes-game/blob/14252b95bf9e68495655af40c72750e8e3c44a42/deploy/k8/biomes.ts#L1055-L1064
14252b95bf9e68495655af40c72750e8e3c44a42
biomes-game
github_2023
ill-inc
typescript
backfillDb
async function backfillDb() { await scriptInit(); const storage = await createStorageBackend("firestore"); const db = createBdb(storage); const allFeedPosts = ( await db.backing.collection("feed-posts" as StoragePath).get() ).docs; await Promise.all( allFeedPosts.map(async (post) => { try { ...
// This script backfills creation timestamps for posts, likes, etc. and rebuilds counts
https://github.com/ill-inc/biomes-game/blob/14252b95bf9e68495655af40c72750e8e3c44a42/scripts/node/backfill_db.ts#L11-L217
14252b95bf9e68495655af40c72750e8e3c44a42
biomes-game
github_2023
ill-inc
typescript
backupEntityHistogram
async function backupEntityHistogram( backupFile: string, filter: (e: ReadonlyEntity) => boolean ) { const histogram = new DefaultMap<string, number>(() => 0); for await (const [_, entity] of iterBackupEntitiesFromFile(backupFile)) { if (filter(entity)) { const key = componentsKey(entity); const ...
// Returns a histogram of number of entities with each different component
https://github.com/ill-inc/biomes-game/blob/14252b95bf9e68495655af40c72750e8e3c44a42/scripts/node/backup_entity_histograms.ts#L7-L21
14252b95bf9e68495655af40c72750e8e3c44a42