Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cf4bf5ed42 |
@@ -16,7 +16,6 @@ enum RecordType {
|
|||||||
StackRecord = 'StackRecord',
|
StackRecord = 'StackRecord',
|
||||||
SubgraphRecord = 'SubgraphRecord',
|
SubgraphRecord = 'SubgraphRecord',
|
||||||
WatcherRecord = 'WatcherRecord',
|
WatcherRecord = 'WatcherRecord',
|
||||||
DockerImageRecord = 'DockerImageRecord'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const recordTypeToRecordField = new Map<string, string>([
|
const recordTypeToRecordField = new Map<string, string>([
|
||||||
@@ -189,46 +188,6 @@ async function publishRecord (userKey: string, bondId: string, fee: StdFee, reco
|
|||||||
record.repository = repoRecordId;
|
record.repository = repoRecordId;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For stack records, check for attributes
|
|
||||||
if (record.type === RecordType.StackRecord) {
|
|
||||||
const watcherName = record.meta?.watcher;
|
|
||||||
const dockerImages = record.docker_images;
|
|
||||||
|
|
||||||
// If .docker_images present, check for image records
|
|
||||||
if (Array.isArray(dockerImages) && dockerImages.length > 0) {
|
|
||||||
const dockerImageRecordsIdPromises = dockerImages.map(async (dockerImage) => {
|
|
||||||
// Find the required docker image record
|
|
||||||
const queryResult = await registry.queryRecords({ type: RecordType.DockerImageRecord, name: dockerImage }, true);
|
|
||||||
if (queryResult.length === 0) {
|
|
||||||
throw new Error(`Record not found, type: ${RecordType.DockerImageRecord}, name: ${dockerImage}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assume the first query result
|
|
||||||
const dockerImageRecordId = queryResult[0].id;
|
|
||||||
|
|
||||||
// Replace watcher name with the watcher record id
|
|
||||||
return dockerImageRecordId;
|
|
||||||
});
|
|
||||||
|
|
||||||
record.docker_images = await Promise.all(dockerImageRecordsIdPromises);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If .meta.watcher present, check for watcher record
|
|
||||||
if (watcherName) {
|
|
||||||
// Find the required watcher record
|
|
||||||
const queryResult = await registry.queryRecords({ type: RecordType.WatcherRecord, name: watcherName }, true);
|
|
||||||
if (queryResult.length === 0) {
|
|
||||||
throw new Error(`Record not found, type: ${RecordType.WatcherRecord}, name: ${watcherName}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assume the first query result
|
|
||||||
const watcherRecordId = queryResult[0].id;
|
|
||||||
|
|
||||||
// Replace watcher name with the watcher record id
|
|
||||||
record.meta.watcher = watcherRecordId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return registry.setRecord({ privateKey: userKey, record, bondId }, userKey, fee);
|
return registry.setRecord({ privateKey: userKey, record, bondId }, userKey, fee);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@cerc-io/laconic-registry-cli",
|
"name": "@cerc-io/laconic-registry-cli",
|
||||||
"version": "0.2.6",
|
"version": "0.2.7",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
|
"repository": "git@github.com:cerc-io/laconic-registry-cli.git",
|
||||||
"author": "",
|
"author": "",
|
||||||
@@ -29,7 +29,7 @@
|
|||||||
"typescript": "^4.6.3"
|
"typescript": "^4.6.3"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cerc-io/registry-sdk": "^0.2.6",
|
"@cerc-io/registry-sdk": "^0.2.8",
|
||||||
"fs-extra": "^10.1.0",
|
"fs-extra": "^10.1.0",
|
||||||
"js-yaml": "^3.14.1",
|
"js-yaml": "^3.14.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
|
|||||||
@@ -23,8 +23,15 @@ export const handler = async (argv: Arguments) => {
|
|||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
|
|
||||||
|
let result: any;
|
||||||
|
|
||||||
const { owner } = argv;
|
const { owner } = argv;
|
||||||
const result = await registry.queryBonds({ owner });
|
if (owner) {
|
||||||
|
const [bondsByOwnerResult] = await registry.queryBondsByOwner([String(owner)]);
|
||||||
|
result = bondsByOwnerResult.bonds;
|
||||||
|
} else {
|
||||||
|
result = await registry.queryBonds();
|
||||||
|
}
|
||||||
|
|
||||||
queryOutput(result, argv.output);
|
queryOutput(result, argv.output);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,13 +24,23 @@ export const builder = {
|
|||||||
all: {
|
all: {
|
||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
refs: {
|
||||||
|
type: 'boolean',
|
||||||
|
default: false
|
||||||
|
},
|
||||||
|
limit: {
|
||||||
|
type: 'number'
|
||||||
|
},
|
||||||
|
offset: {
|
||||||
|
type: 'number'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const handler = async (argv: Arguments) => {
|
export const handler = async (argv: Arguments) => {
|
||||||
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
const { services: { registry: registryConfig } } = getConfig(argv.config as string);
|
||||||
const { rpcEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
const { rpcEndpoint, gqlEndpoint, chainId } = getConnectionInfo(argv, registryConfig);
|
||||||
const { type, name, bondId, owner, all } = argv;
|
const { type, name, bondId, owner, all, refs, limit, offset } = argv;
|
||||||
const filters: any = {};
|
const filters: any = {};
|
||||||
|
|
||||||
const filterArgs = argv._.slice(3);
|
const filterArgs = argv._.slice(3);
|
||||||
@@ -44,7 +54,7 @@ export const handler = async (argv: Arguments) => {
|
|||||||
|
|
||||||
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
const registry = new Registry(gqlEndpoint, rpcEndpoint, chainId);
|
||||||
|
|
||||||
let result = await registry.queryRecords({ ...filters, type, name }, all as boolean);
|
let result = await registry.queryRecords({ ...filters, type, name }, all as boolean, refs as boolean, limit as number, offset as number);
|
||||||
|
|
||||||
// Apply ex post filters.
|
// Apply ex post filters.
|
||||||
if (bondId) {
|
if (bondId) {
|
||||||
|
|||||||
@@ -302,10 +302,10 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||||
|
|
||||||
"@cerc-io/registry-sdk@^0.2.6":
|
"@cerc-io/registry-sdk@^0.2.8":
|
||||||
version "0.2.6"
|
version "0.2.8"
|
||||||
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.6/registry-sdk-0.2.6.tgz#af8a5844bdb742a01d322a9d93ace90d35aad37e"
|
resolved "https://git.vdb.to/api/packages/cerc-io/npm/%40cerc-io%2Fregistry-sdk/-/0.2.8/registry-sdk-0.2.8.tgz#d71837f735d998987055068457fdf8b2e94ca69c"
|
||||||
integrity sha512-Z2rneeoPLTJk9aBTqMrR9WPKfPQZhNWShI4IYOb7kzoIorp3eD8mEals0I5bVjzStjapw/5RKf8lVnDCX9I4iA==
|
integrity sha512-utK3Rq5qZrEoRs/eOsOkowcsD740nlnBs6C3KKFRHgKIiR0XedD6t33KukUPLKbGp4mYZOYXRTA7/A04x58lKw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@cosmjs/amino" "^0.28.1"
|
"@cosmjs/amino" "^0.28.1"
|
||||||
"@cosmjs/crypto" "^0.28.1"
|
"@cosmjs/crypto" "^0.28.1"
|
||||||
|
|||||||
Reference in New Issue
Block a user