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

@tableland/sdk

Package Overview
Dependencies
Maintainers
5
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tableland/sdk - npm Package Compare versions

Comparing version 4.4.3-dev1.0 to 4.5.0

./dist/cjs/index.js

12

dist/cjs/helpers/config.d.ts

@@ -1,3 +0,3 @@

import { type ethers } from "ethers";
import { type WaitableTransactionReceipt } from "../registry/utils.js";
import { type FetchConfig } from "../validator/client/index.js";
import { type ChainName } from "./chains.js";

@@ -8,13 +8,6 @@ import { type Signer, type ExternalProvider } from "./ethers.js";

aliases?: AliasesNameMap;
apiKey?: string;
}
export interface SignAndSendOverride {
signer: Signer;
contractAddress: string;
functionSignature: string;
functionArgs: any[];
overrides?: any;
}
export interface SignerConfig {
signer: Signer;
signAndSendOverride?: (options: SignAndSendOverride) => Promise<ethers.providers.TransactionResponse>;
}

@@ -35,2 +28,3 @@ export interface AutoWaitConfig {

export declare function jsonFileAliases(filepath: string): AliasesNameMap;
export declare function prepReadConfig(config: Partial<ReadConfig>): FetchConfig;
//# sourceMappingURL=config.d.ts.map
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.jsonFileAliases = exports.extractChainId = exports.extractSigner = exports.extractBaseUrl = exports.checkWait = void 0;
exports.prepReadConfig = exports.jsonFileAliases = exports.extractChainId = exports.extractSigner = exports.extractBaseUrl = exports.checkWait = void 0;
const node_fs_1 = __importDefault(require("node:fs"));
const chains_js_1 = require("./chains.js");

@@ -68,31 +49,16 @@ const ethers_js_1 = require("./ethers.js");

exports.extractChainId = extractChainId;
const findOrCreateFile = async function (filepath) {
const fs = await getFsModule();
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (!fs.existsSync(filepath)) {
fs.writeFileSync(filepath, JSON.stringify({}));
const findOrCreateFile = function (filepath) {
if (!node_fs_1.default.existsSync(filepath)) {
node_fs_1.default.writeFileSync(filepath, JSON.stringify({}));
}
return fs.readFileSync(filepath);
return node_fs_1.default.readFileSync(filepath);
};
// TODO: next major we should remove the jsonFileAliases helper and expose it
// in a different package since it doesn't work in the browser.
const getFsModule = (function () {
let fs;
return async function () {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (fs)
return fs;
fs = await Promise.resolve().then(() => __importStar(require(/* webpackIgnore: true */ "fs")));
return fs;
};
})();
function jsonFileAliases(filepath) {
return {
read: async function () {
const jsonBuf = await findOrCreateFile(filepath);
const jsonBuf = findOrCreateFile(filepath);
return JSON.parse(jsonBuf.toString());
},
write: async function (nameMap) {
const fs = await getFsModule();
fs.writeFileSync(filepath, JSON.stringify(nameMap));
node_fs_1.default.writeFileSync(filepath, JSON.stringify(nameMap));
},

@@ -102,2 +68,14 @@ };

exports.jsonFileAliases = jsonFileAliases;
function prepReadConfig(config) {
const conf = {};
if (config.apiKey) {
conf.init = {
headers: {
"Api-Key": config.apiKey,
},
};
}
return { ...config, ...conf };
}
exports.prepReadConfig = prepReadConfig;
//# sourceMappingURL=config.js.map
export { type Signal, type Wait, type SignalAndInterval, type Interval, } from "./await.js";
export { type ChainName, type ChainInfo, supportedChains, getBaseUrl, getChainId, getChainInfo, getContractAddress, isTestnet, overrideDefaults, } from "./chains.js";
export { type ReadConfig, type SignerConfig, type Config, type AutoWaitConfig, type AliasesNameMap, type NameMapping, checkWait, extractBaseUrl, extractChainId, extractSigner, jsonFileAliases, } from "./config.js";
export { type ReadConfig, type SignerConfig, type Config, type AutoWaitConfig, type AliasesNameMap, type NameMapping, checkWait, extractBaseUrl, extractChainId, extractSigner, jsonFileAliases, prepReadConfig, } from "./config.js";
export { type Signer, type ExternalProvider, getDefaultProvider, type ContractTransaction, type ContractReceipt, type RegistryReceipt, type MultiEventTransactionReceipt, getSigner, getContractReceipt, } from "./ethers.js";

@@ -5,0 +5,0 @@ export { normalize, validateTableName, type NormalizedStatement, type StatementType, } from "./parser.js";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TableEventBus = exports.validateTableName = exports.normalize = exports.getContractReceipt = exports.getSigner = exports.getDefaultProvider = exports.jsonFileAliases = exports.extractSigner = exports.extractChainId = exports.extractBaseUrl = exports.checkWait = exports.overrideDefaults = exports.isTestnet = exports.getContractAddress = exports.getChainInfo = exports.getChainId = exports.getBaseUrl = exports.supportedChains = void 0;
exports.TableEventBus = exports.validateTableName = exports.normalize = exports.getContractReceipt = exports.getSigner = exports.getDefaultProvider = exports.prepReadConfig = exports.jsonFileAliases = exports.extractSigner = exports.extractChainId = exports.extractBaseUrl = exports.checkWait = exports.overrideDefaults = exports.isTestnet = exports.getContractAddress = exports.getChainInfo = exports.getChainId = exports.getBaseUrl = exports.supportedChains = void 0;
var chains_js_1 = require("./chains.js");

@@ -18,2 +18,3 @@ Object.defineProperty(exports, "supportedChains", { enumerable: true, get: function () { return chains_js_1.supportedChains; } });

Object.defineProperty(exports, "jsonFileAliases", { enumerable: true, get: function () { return config_js_1.jsonFileAliases; } });
Object.defineProperty(exports, "prepReadConfig", { enumerable: true, get: function () { return config_js_1.prepReadConfig; } });
var ethers_js_1 = require("./ethers.js");

@@ -20,0 +21,0 @@ Object.defineProperty(exports, "getDefaultProvider", { enumerable: true, get: function () { return ethers_js_1.getDefaultProvider; } });

@@ -49,7 +49,3 @@ "use strict";

const baseUrl = await (0, index_js_1.extractBaseUrl)(config, chainId);
const _config = {
baseUrl,
signer,
signAndSendOverride: config.signAndSendOverride,
};
const _config = { baseUrl, signer };
const _params = { chainId, first, statement: sql };

@@ -104,7 +100,3 @@ switch (type) {

const baseUrl = await (0, index_js_1.extractBaseUrl)(config, chainId);
const _config = {
baseUrl,
signer,
signAndSendOverride: config.signAndSendOverride,
};
const _config = { baseUrl, signer };
const params = { runnables, chainId };

@@ -133,7 +125,3 @@ if (typeof config.aliases?.read === "function") {

const baseUrl = await (0, index_js_1.extractBaseUrl)(config, chainId);
const _config = {
baseUrl,
signer,
signAndSendOverride: config.signAndSendOverride,
};
const _config = { baseUrl, signer };
const params = {

@@ -140,0 +128,0 @@ statements: await Promise.all(statements.map(async function (statement) {

@@ -42,28 +42,10 @@ "use strict";

exports.create = create;
async function _createOne({ signer, signAndSendOverride }, { statement, chainId }) {
async function _createOne({ signer }, { statement, chainId }) {
const owner = await signer.getAddress();
const { contract, overrides } = await (0, contract_js_1.getContractAndOverrides)(signer, chainId);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "create(address,string)",
functionArgs: [owner, statement],
overrides,
});
}
return await contract["create(address,string)"](owner, statement, overrides);
}
async function _createMany({ signer, signAndSendOverride }, { statements, chainId }) {
async function _createMany({ signer }, { statements, chainId }) {
const owner = await signer.getAddress();
const { contract, overrides } = await (0, contract_js_1.getContractAndOverrides)(signer, chainId);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "create(address,string[])",
functionArgs: [owner, statements],
overrides,
});
}
return await contract["create(address,string[])"](owner, statements, overrides);

@@ -70,0 +52,0 @@ }

@@ -19,28 +19,10 @@ "use strict";

exports.mutate = mutate;
async function _mutateOne({ signer, signAndSendOverride }, { statement, tableId, chainId }) {
async function _mutateOne({ signer }, { statement, tableId, chainId }) {
const caller = await signer.getAddress();
const { contract, overrides } = await (0, contract_js_1.getContractAndOverrides)(signer, chainId);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "mutate(address,uint256,string)",
functionArgs: [caller, tableId, statement],
overrides,
});
}
return await contract["mutate(address,uint256,string)"](caller, tableId, statement, overrides);
}
async function _mutateMany({ signer, signAndSendOverride }, { runnables, chainId }) {
async function _mutateMany({ signer }, { runnables, chainId }) {
const caller = await signer.getAddress();
const { contract, overrides } = await (0, contract_js_1.getContractAndOverrides)(signer, chainId);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "mutate(address,(uint256,string)[])",
functionArgs: [caller, runnables],
overrides,
});
}
return await contract["mutate(address,(uint256,string)[])"](caller, runnables, overrides);

@@ -47,0 +29,0 @@ }

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

const baseUrl = await (0, config_js_1.extractBaseUrl)(conn, chainId);
return { baseUrl };
return { baseUrl, apiKey: conn.apiKey };
}

@@ -36,0 +36,0 @@ exports.extractReadonly = extractReadonly;

@@ -8,5 +8,6 @@ "use strict";

Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return types_js_1.ApiError; } });
const index_js_1 = require("../../helpers/index.js");
function getFetcher(config) {
const fetcher = fetcher_js_1.Fetcher.for();
fetcher.configure(config);
fetcher.configure((0, index_js_1.prepReadConfig)(config));
return fetcher;

@@ -13,0 +14,0 @@ }

@@ -1,2 +0,2 @@

import { type Signal } from "../helpers/await.js";
import { type Signal } from "../helpers/index.js";
import { type FetchConfig, type Paths } from "./client/index.js";

@@ -3,0 +3,0 @@ /**

@@ -1,3 +0,3 @@

import { type ethers } from "ethers";
import { type WaitableTransactionReceipt } from "../registry/utils.js";
import { type FetchConfig } from "../validator/client/index.js";
import { type ChainName } from "./chains.js";

@@ -8,13 +8,6 @@ import { type Signer, type ExternalProvider } from "./ethers.js";

aliases?: AliasesNameMap;
apiKey?: string;
}
export interface SignAndSendOverride {
signer: Signer;
contractAddress: string;
functionSignature: string;
functionArgs: any[];
overrides?: any;
}
export interface SignerConfig {
signer: Signer;
signAndSendOverride?: (options: SignAndSendOverride) => Promise<ethers.providers.TransactionResponse>;
}

@@ -35,2 +28,3 @@ export interface AutoWaitConfig {

export declare function jsonFileAliases(filepath: string): AliasesNameMap;
export declare function prepReadConfig(config: Partial<ReadConfig>): FetchConfig;
//# sourceMappingURL=config.d.ts.map

@@ -0,1 +1,2 @@

import fs from "node:fs";
import { getBaseUrl } from "./chains.js";

@@ -38,5 +39,3 @@ import { getSigner } from "./ethers.js";

}
const findOrCreateFile = async function (filepath) {
const fs = await getFsModule();
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const findOrCreateFile = function (filepath) {
if (!fs.existsSync(filepath)) {

@@ -47,22 +46,9 @@ fs.writeFileSync(filepath, JSON.stringify({}));

};
// TODO: next major we should remove the jsonFileAliases helper and expose it
// in a different package since it doesn't work in the browser.
const getFsModule = (function () {
let fs;
return async function () {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (fs)
return fs;
fs = await import(/* webpackIgnore: true */ "fs");
return fs;
};
})();
export function jsonFileAliases(filepath) {
return {
read: async function () {
const jsonBuf = await findOrCreateFile(filepath);
const jsonBuf = findOrCreateFile(filepath);
return JSON.parse(jsonBuf.toString());
},
write: async function (nameMap) {
const fs = await getFsModule();
fs.writeFileSync(filepath, JSON.stringify(nameMap));

@@ -72,2 +58,13 @@ },

}
export function prepReadConfig(config) {
const conf = {};
if (config.apiKey) {
conf.init = {
headers: {
"Api-Key": config.apiKey,
},
};
}
return { ...config, ...conf };
}
//# sourceMappingURL=config.js.map
export { type Signal, type Wait, type SignalAndInterval, type Interval, } from "./await.js";
export { type ChainName, type ChainInfo, supportedChains, getBaseUrl, getChainId, getChainInfo, getContractAddress, isTestnet, overrideDefaults, } from "./chains.js";
export { type ReadConfig, type SignerConfig, type Config, type AutoWaitConfig, type AliasesNameMap, type NameMapping, checkWait, extractBaseUrl, extractChainId, extractSigner, jsonFileAliases, } from "./config.js";
export { type ReadConfig, type SignerConfig, type Config, type AutoWaitConfig, type AliasesNameMap, type NameMapping, checkWait, extractBaseUrl, extractChainId, extractSigner, jsonFileAliases, prepReadConfig, } from "./config.js";
export { type Signer, type ExternalProvider, getDefaultProvider, type ContractTransaction, type ContractReceipt, type RegistryReceipt, type MultiEventTransactionReceipt, getSigner, getContractReceipt, } from "./ethers.js";

@@ -5,0 +5,0 @@ export { normalize, validateTableName, type NormalizedStatement, type StatementType, } from "./parser.js";

export { supportedChains, getBaseUrl, getChainId, getChainInfo, getContractAddress, isTestnet, overrideDefaults, } from "./chains.js";
export { checkWait, extractBaseUrl, extractChainId, extractSigner, jsonFileAliases, } from "./config.js";
export { checkWait, extractBaseUrl, extractChainId, extractSigner, jsonFileAliases, prepReadConfig, } from "./config.js";
export { getDefaultProvider, getSigner, getContractReceipt, } from "./ethers.js";

@@ -4,0 +4,0 @@ export { normalize, validateTableName, } from "./parser.js";

@@ -46,7 +46,3 @@ import { extractBaseUrl, extractSigner, normalize, } from "./helpers/index.js";

const baseUrl = await extractBaseUrl(config, chainId);
const _config = {
baseUrl,
signer,
signAndSendOverride: config.signAndSendOverride,
};
const _config = { baseUrl, signer };
const _params = { chainId, first, statement: sql };

@@ -100,7 +96,3 @@ switch (type) {

const baseUrl = await extractBaseUrl(config, chainId);
const _config = {
baseUrl,
signer,
signAndSendOverride: config.signAndSendOverride,
};
const _config = { baseUrl, signer };
const params = { runnables, chainId };

@@ -128,7 +120,3 @@ if (typeof config.aliases?.read === "function") {

const baseUrl = await extractBaseUrl(config, chainId);
const _config = {
baseUrl,
signer,
signAndSendOverride: config.signAndSendOverride,
};
const _config = { baseUrl, signer };
const params = {

@@ -135,0 +123,0 @@ statements: await Promise.all(statements.map(async function (statement) {

@@ -36,28 +36,10 @@ import { normalize } from "../helpers/index.js";

}
async function _createOne({ signer, signAndSendOverride }, { statement, chainId }) {
async function _createOne({ signer }, { statement, chainId }) {
const owner = await signer.getAddress();
const { contract, overrides } = await getContractAndOverrides(signer, chainId);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "create(address,string)",
functionArgs: [owner, statement],
overrides,
});
}
return await contract["create(address,string)"](owner, statement, overrides);
}
async function _createMany({ signer, signAndSendOverride }, { statements, chainId }) {
async function _createMany({ signer }, { statements, chainId }) {
const owner = await signer.getAddress();
const { contract, overrides } = await getContractAndOverrides(signer, chainId);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "create(address,string[])",
functionArgs: [owner, statements],
overrides,
});
}
return await contract["create(address,string[])"](owner, statements, overrides);

@@ -64,0 +46,0 @@ }

@@ -14,28 +14,10 @@ import { validateTableName } from "../helpers/parser.js";

}
async function _mutateOne({ signer, signAndSendOverride }, { statement, tableId, chainId }) {
async function _mutateOne({ signer }, { statement, tableId, chainId }) {
const caller = await signer.getAddress();
const { contract, overrides } = await getContractAndOverrides(signer, chainId);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "mutate(address,uint256,string)",
functionArgs: [caller, tableId, statement],
overrides,
});
}
return await contract["mutate(address,uint256,string)"](caller, tableId, statement, overrides);
}
async function _mutateMany({ signer, signAndSendOverride }, { runnables, chainId }) {
async function _mutateMany({ signer }, { runnables, chainId }) {
const caller = await signer.getAddress();
const { contract, overrides } = await getContractAndOverrides(signer, chainId);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "mutate(address,(uint256,string)[])",
functionArgs: [caller, runnables],
overrides,
});
}
return await contract["mutate(address,(uint256,string)[])"](caller, runnables, overrides);

@@ -42,0 +24,0 @@ }

@@ -29,3 +29,3 @@ import { pollTransactionReceipt, } from "../validator/receipt.js";

const baseUrl = await extractBaseUrl(conn, chainId);
return { baseUrl };
return { baseUrl, apiKey: conn.apiKey };
}

@@ -32,0 +32,0 @@ /**

import { Fetcher } from "./fetcher.js";
import { ApiError } from "./types.js";
import { prepReadConfig } from "../../helpers/index.js";
export { Fetcher, ApiError };
export function getFetcher(config) {
const fetcher = Fetcher.for();
fetcher.configure(config);
fetcher.configure(prepReadConfig(config));
return fetcher;
}
//# sourceMappingURL=index.js.map

@@ -1,2 +0,2 @@

import { type Signal } from "../helpers/await.js";
import { type Signal } from "../helpers/index.js";
import { type FetchConfig, type Paths } from "./client/index.js";

@@ -3,0 +3,0 @@ /**

{
"name": "@tableland/sdk",
"version": "4.4.3-dev1.0",
"version": "4.5.0",
"description": "A database client and helpers for the Tableland network",

@@ -55,14 +55,16 @@ "publishConfig": {

],
"nx": {
"implicitDependencies": [
"!@tableland/local"
]
},
"scripts": {
"lint": "eslint '**/*.{js,ts}'",
"lint:fix": "npm run lint -- --fix",
"prettier": "prettier '**/*.{ts,json,sol,md}' --check",
"prettier:fix": "npm run prettier -- --write",
"format": "npm run prettier:fix && npm run lint:fix",
"prepublishOnly": "npm run build",
"test": "mocha",
"test:browser": "PW_TS_ESM_ON=true playwright test",
"test": "npm run test:browser && npm run test:mocha",
"test:mocha": "mocha --exit",
"test:browser": "npx playwright install --with-deps && PW_TS_ESM_ON=true playwright test",
"test:browser-show-report": "npx playwright show-report",
"test:ci": "npm run coverage",
"test-server": "cd test/browser/server && npm install && npm run dev",
"coverage": "c8 --exclude src/validator/client/fetcher.ts --exclude test mocha --exit",
"coverage": "c8 --exclude src/validator/client/fetcher.ts --exclude test --exclude dist mocha --exit",
"docs": "typedoc --entryPoints src/index.ts",

@@ -87,24 +89,5 @@ "clean": "rm -rf dist coverage docs",

"@playwright/test": "^1.30.0",
"@tableland/local": "^2.0.1",
"@types/assert": "^1.5.6",
"@types/mocha": "^10.0.1",
"@types/node": "^20.1.4",
"@typescript-eslint/eslint-plugin": "^5.62.0",
"@typescript-eslint/parser": "^5.62.0",
"assert": "^2.0.0",
"c8": "^8.0.0",
"d1-orm": "^0.7.1",
"eslint": "^8.31.0",
"eslint-config-prettier": "^8.6.0",
"eslint-config-standard": "^17.0.0",
"eslint-config-standard-with-typescript": "^35.0.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-n": "^15.6.0",
"eslint-plugin-promise": "^6.1.1",
"mocha": "^10.2.0",
"openapi-typescript": "^6.1.0",
"prettier": "^2.8.2",
"ts-node": "^10.9.1",
"typedoc": "^0.24.6",
"typescript": "^5.0.4"
"openapi-typescript": "6.2.4",
"typedoc": "^0.24.6"
},

@@ -116,3 +99,4 @@ "dependencies": {

"ethers": "^5.7.2"
}
}
},
"gitHead": "6aee2455f2a1b2bf491e622f8bb67b358b8b36ed"
}

@@ -48,3 +48,3 @@ # @tableland/sdk

Full library documentation is [generated on GitHub](https://tablelandnetwork.github.io/js-tableland/), and
general docs, examples, and more are [available on our docs site](https://docs.tableland.xyz/sdk/).
general docs, examples, and more are [available on our docs site](https://docs.tableland.xyz/sdk/core/).

@@ -51,0 +51,0 @@ ### Database

@@ -1,3 +0,4 @@

import { type ethers } from "ethers";
import fs from "node:fs";
import { type WaitableTransactionReceipt } from "../registry/utils.js";
import { type FetchConfig } from "../validator/client/index.js";
import { type ChainName, getBaseUrl } from "./chains.js";

@@ -9,17 +10,7 @@ import { type Signer, type ExternalProvider, getSigner } from "./ethers.js";

aliases?: AliasesNameMap;
apiKey?: string;
}
export interface SignAndSendOverride {
signer: Signer;
contractAddress: string;
functionSignature: string;
functionArgs: any[];
overrides?: any;
}
export interface SignerConfig {
signer: Signer;
signAndSendOverride?: (
options: SignAndSendOverride
) => Promise<ethers.providers.TransactionResponse>;
}

@@ -94,5 +85,3 @@

const findOrCreateFile = async function (filepath: string): Promise<Buffer> {
const fs = await getFsModule();
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
const findOrCreateFile = function (filepath: string): Buffer {
if (!fs.existsSync(filepath)) {

@@ -105,23 +94,9 @@ fs.writeFileSync(filepath, JSON.stringify({}));

// TODO: next major we should remove the jsonFileAliases helper and expose it
// in a different package since it doesn't work in the browser.
const getFsModule = (function () {
let fs: any;
return async function () {
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
if (fs) return fs;
fs = await import(/* webpackIgnore: true */ "fs");
return fs;
};
})();
export function jsonFileAliases(filepath: string): AliasesNameMap {
return {
read: async function (): Promise<NameMapping> {
const jsonBuf = await findOrCreateFile(filepath);
const jsonBuf = findOrCreateFile(filepath);
return JSON.parse(jsonBuf.toString());
},
write: async function (nameMap: NameMapping) {
const fs = await getFsModule();
fs.writeFileSync(filepath, JSON.stringify(nameMap));

@@ -131,1 +106,14 @@ },

}
export function prepReadConfig(config: Partial<ReadConfig>): FetchConfig {
const conf: FetchConfig = {};
if (config.apiKey) {
conf.init = {
headers: {
"Api-Key": config.apiKey,
},
};
}
return { ...config, ...conf };
}

@@ -30,2 +30,3 @@ export {

jsonFileAliases,
prepReadConfig,
} from "./config.js";

@@ -32,0 +33,0 @@ export {

@@ -84,7 +84,3 @@ import {

const baseUrl = await extractBaseUrl(config, chainId);
const _config = {
baseUrl,
signer,
signAndSendOverride: config.signAndSendOverride,
};
const _config = { baseUrl, signer };
const _params = { chainId, first, statement: sql };

@@ -148,7 +144,3 @@ switch (type) {

const baseUrl = await extractBaseUrl(config, chainId);
const _config = {
baseUrl,
signer,
signAndSendOverride: config.signAndSendOverride,
};
const _config = { baseUrl, signer };
const params: MutateManyParams = { runnables, chainId };

@@ -191,7 +183,3 @@

const baseUrl = await extractBaseUrl(config, chainId);
const _config = {
baseUrl,
signer,
signAndSendOverride: config.signAndSendOverride,
};
const _config = { baseUrl, signer };
const params: CreateManyParams = {

@@ -198,0 +186,0 @@ statements: await Promise.all(

@@ -102,3 +102,3 @@ import { normalize } from "../helpers/index.js";

async function _createOne(
{ signer, signAndSendOverride }: SignerConfig,
{ signer }: SignerConfig,
{ statement, chainId }: CreateOneParams

@@ -111,13 +111,2 @@ ): Promise<ContractTransaction> {

);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "create(address,string)",
functionArgs: [owner, statement],
overrides,
});
}
return await contract["create(address,string)"](owner, statement, overrides);

@@ -127,3 +116,3 @@ }

async function _createMany(
{ signer, signAndSendOverride }: SignerConfig,
{ signer }: SignerConfig,
{ statements, chainId }: CreateManyParams

@@ -136,13 +125,2 @@ ): Promise<ContractTransaction> {

);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "create(address,string[])",
functionArgs: [owner, statements],
overrides,
});
}
return await contract["create(address,string[])"](

@@ -149,0 +127,0 @@ owner,

@@ -90,3 +90,3 @@ import { type SignerConfig } from "../helpers/config.js";

async function _mutateOne(
{ signer, signAndSendOverride }: SignerConfig,
{ signer }: SignerConfig,
{ statement, tableId, chainId }: MutateOneParams

@@ -99,13 +99,2 @@ ): Promise<ContractTransaction> {

);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "mutate(address,uint256,string)",
functionArgs: [caller, tableId, statement],
overrides,
});
}
return await contract["mutate(address,uint256,string)"](

@@ -120,3 +109,3 @@ caller,

async function _mutateMany(
{ signer, signAndSendOverride }: SignerConfig,
{ signer }: SignerConfig,
{ runnables, chainId }: MutateManyParams

@@ -129,13 +118,2 @@ ): Promise<ContractTransaction> {

);
if (signAndSendOverride !== undefined) {
return await signAndSendOverride({
signer,
contractAddress: contract.address,
functionSignature: "mutate(address,(uint256,string)[])",
functionArgs: [caller, runnables],
overrides,
});
}
return await contract["mutate(address,(uint256,string)[])"](

@@ -142,0 +120,0 @@ caller,

@@ -151,3 +151,3 @@ import {

const baseUrl = await extractBaseUrl(conn, chainId);
return { baseUrl };
return { baseUrl, apiKey: conn.apiKey };
}

@@ -154,0 +154,0 @@

import { Fetcher } from "./fetcher.js";
import { ApiResponse, ApiError, FetchConfig } from "./types.js";
import type { paths as Paths, components as Components } from "./validator.js";
import { prepReadConfig } from "../../helpers/index.js";

@@ -12,4 +13,4 @@ export { ApiResponse, Fetcher, ApiError, FetchConfig };

const fetcher = Fetcher.for<Paths>();
fetcher.configure(config);
fetcher.configure(prepReadConfig(config));
return fetcher;
}

@@ -1,2 +0,2 @@

import { type Signal } from "../helpers/await.js";
import { type Signal } from "../helpers/index.js";
import { type FetchConfig, type Paths, getFetcher } from "./client/index.js";

@@ -3,0 +3,0 @@ import { hoistApiError } from "./errors.js";

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

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

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc