Comparing version 1.2.4 to 1.2.5
@@ -1,2 +0,1 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
export {}; |
@@ -11,1 +11,6 @@ import GQLResultInterface, { GQLEdgeInterface, GQLNodeInterface } from "./faces"; | ||
export declare function arGql(endpointUrl?: string): ArGqlInterface; | ||
/** some useful constants */ | ||
export declare const GQLUrls: { | ||
goldsky: string; | ||
arweave: string; | ||
}; |
@@ -1,152 +0,69 @@ | ||
"use strict"; | ||
var __assign = (this && this.__assign) || function () { | ||
__assign = Object.assign || function(t) { | ||
for (var s, i = 1, n = arguments.length; i < n; i++) { | ||
s = arguments[i]; | ||
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) | ||
t[p] = s[p]; | ||
} | ||
return t; | ||
}; | ||
return __assign.apply(this, arguments); | ||
}; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
exports.__esModule = true; | ||
exports.arGql = void 0; | ||
var tx_1 = require("./queries/tx"); | ||
function arGql(endpointUrl) { | ||
var _this = this; | ||
import txQuery from "./queries/tx"; | ||
export function arGql(endpointUrl) { | ||
//sanity check | ||
if (endpointUrl && !endpointUrl.match(/^https?:\/\/.*\/graphql$/)) { | ||
throw new Error("string doesn't appear to be a URL of the form <http(s)://some-domain/graphql>'. You entered \"".concat(endpointUrl, "\"")); | ||
throw new Error(`string doesn't appear to be a URL of the form <http(s)://some-domain/graphql>'. You entered "${endpointUrl}"`); | ||
} | ||
var _endpointUrl = endpointUrl || 'https://arweave.net/graphql'; //default to arweave.net/graphql | ||
var run = function (query, variables) { return __awaiter(_this, void 0, void 0, function () { | ||
var graphql, res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
graphql = JSON.stringify({ | ||
query: query, | ||
variables: variables | ||
}); | ||
return [4 /*yield*/, fetch(_endpointUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json' | ||
}, | ||
body: graphql | ||
})]; | ||
case 1: | ||
res = _a.sent(); | ||
if (!res.ok) { | ||
throw new Error(res.statusText, { cause: res.status }); | ||
} | ||
return [4 /*yield*/, res.json()]; | ||
case 2: return [2 /*return*/, _a.sent()]; | ||
} | ||
const _endpointUrl = endpointUrl || 'https://arweave.net/graphql'; //default to arweave.net/graphql | ||
const run = async (query, variables) => { | ||
const graphql = JSON.stringify({ | ||
query, | ||
variables, | ||
}); | ||
}); }; | ||
var all = function (query, variables, pageCallback) { return __awaiter(_this, void 0, void 0, function () { | ||
var hasNextPage, edges, cursor, pageCallbacks, res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: | ||
hasNextPage = true; | ||
edges = []; | ||
cursor = ""; | ||
pageCallbacks = []; | ||
_a.label = 1; | ||
case 1: | ||
if (!hasNextPage) return [3 /*break*/, 3]; | ||
return [4 /*yield*/, run(query, __assign(__assign({}, variables), { cursor: cursor }))]; | ||
case 2: | ||
res = (_a.sent()).data.transactions; | ||
if (res.edges && res.edges.length) { | ||
if (typeof pageCallback === 'function') { | ||
pageCallbacks.push(pageCallback(res.edges)); | ||
} | ||
else { | ||
edges = edges.concat(res.edges); | ||
} | ||
cursor = res.edges[res.edges.length - 1].cursor; | ||
} | ||
hasNextPage = res.pageInfo.hasNextPage; | ||
return [3 /*break*/, 1]; | ||
case 3: return [4 /*yield*/, Promise.all(pageCallbacks)]; | ||
case 4: | ||
_a.sent(); | ||
return [2 /*return*/, edges]; | ||
} | ||
const res = await fetch(_endpointUrl, { | ||
method: 'POST', | ||
headers: { | ||
'Accept': 'application/json', | ||
'Content-Type': 'application/json', | ||
}, | ||
body: graphql, | ||
}); | ||
}); }; | ||
var tx = function (id) { return __awaiter(_this, void 0, void 0, function () { | ||
var res; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, run(tx_1["default"], { id: id })]; | ||
case 1: | ||
res = _a.sent(); | ||
return [2 /*return*/, res.data.transaction]; | ||
if (!res.ok) { | ||
throw new Error(res.statusText, { cause: res.status }); | ||
} | ||
return await res.json(); | ||
}; | ||
const all = async (query, variables, pageCallback) => { | ||
let hasNextPage = true; | ||
let edges = []; | ||
let cursor = ""; | ||
let pageCallbacks = []; | ||
while (hasNextPage) { | ||
const res = (await run(query, { ...variables, cursor })).data.transactions; | ||
if (res.edges && res.edges.length) { | ||
if (typeof pageCallback === 'function') { | ||
pageCallbacks.push(pageCallback(res.edges)); | ||
} | ||
else { | ||
edges = edges.concat(res.edges); | ||
} | ||
cursor = res.edges[res.edges.length - 1].cursor; | ||
} | ||
}); | ||
}); }; | ||
var fetchTxTag = function (id, name) { return __awaiter(_this, void 0, void 0, function () { | ||
var res, tag; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, tx(id)]; | ||
case 1: | ||
res = _a.sent(); | ||
tag = res.tags.find(function (tag) { return tag.name === name; }); | ||
if (tag) | ||
return [2 /*return*/, tag.value]; | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
hasNextPage = res.pageInfo.hasNextPage; | ||
} | ||
await Promise.all(pageCallbacks); | ||
return edges; | ||
}; | ||
const tx = async (id) => { | ||
const res = await run(txQuery, { id }); | ||
return res.data.transaction; | ||
}; | ||
const fetchTxTag = async (id, name) => { | ||
const res = await tx(id); | ||
const tag = res.tags.find((tag) => tag.name === name); | ||
if (tag) | ||
return tag.value; | ||
}; | ||
return { | ||
run: run, | ||
all: all, | ||
tx: tx, | ||
fetchTxTag: fetchTxTag, | ||
endpointUrl: _endpointUrl | ||
run, | ||
all, | ||
tx, | ||
fetchTxTag, | ||
endpointUrl: _endpointUrl, | ||
}; | ||
} | ||
exports.arGql = arGql; | ||
/** some useful constants */ | ||
export const GQLUrls = { | ||
goldsky: 'https://arweave-search.goldsky.com/graphql', | ||
arweave: 'https://arweave.net/graphql', | ||
}; |
@@ -1,3 +0,39 @@ | ||
"use strict"; | ||
exports.__esModule = true; | ||
exports["default"] = "\nquery($id: ID!) {\n transaction(id: $id) {\n id\n anchor\n signature\n recipient\n owner {\n address\n key\n }\n fee {\n winston\n ar\n }\n quantity {\n winston\n ar\n }\n data {\n size\n type\n }\n tags {\n name\n value\n }\n block {\n id\n timestamp\n height\n previous\n }\n parent {\n id\n }\n }\n}\n"; | ||
export default ` | ||
query($id: ID!) { | ||
transaction(id: $id) { | ||
id | ||
anchor | ||
signature | ||
recipient | ||
owner { | ||
address | ||
key | ||
} | ||
fee { | ||
winston | ||
ar | ||
} | ||
quantity { | ||
winston | ||
ar | ||
} | ||
data { | ||
size | ||
type | ||
} | ||
tags { | ||
name | ||
value | ||
} | ||
block { | ||
id | ||
timestamp | ||
height | ||
previous | ||
} | ||
parent { | ||
id | ||
} | ||
} | ||
} | ||
`; |
{ | ||
"name": "ar-gql", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"main": "dist/index", | ||
@@ -24,3 +24,3 @@ "types": "dist/index", | ||
"node-option": [ | ||
"require=ts-node/register", | ||
"require=tsx/cjs", | ||
"no-warnings" | ||
@@ -35,9 +35,9 @@ ] | ||
"@types/mocha": "^10.0.1", | ||
"chai": "^4.3.7", | ||
"chai": "^5.0.3", | ||
"mocha": "^10.2.0", | ||
"prettier": "^2.2.1", | ||
"rimraf": "^4.1.2", | ||
"ts-node": "latest", | ||
"rimraf": "^5.0.5", | ||
"tsx": "latest", | ||
"typescript": "latest" | ||
} | ||
} |
@@ -6,5 +6,6 @@ { | ||
"declaration": true, | ||
"lib": ["ESNext", "DOM"] | ||
"lib": ["ESNext", "DOM"], | ||
"target": "ES2021" | ||
}, | ||
"include": ["src/**/*"] | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9625
191
2