@deep-foundation/deeplinks
Version:
[](https://www.npmjs.com/package/@deep-foundation/deeplinks) [](https://gitpod.io/#https://github.com/deep-fo
56 lines • 2.63 kB
JavaScript
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());
});
};
import { generateApolloClient } from '@deep-foundation/hasura/client.js';
import Debug from 'debug';
import { DeepClient } from '../imports/client.js';
const debug = Debug('deeplinks:migrations:deepcase');
const log = debug.extend('log');
const error = debug.extend('error');
const rootClient = generateApolloClient({
path: `${process.env.MIGRATIONS_HASURA_PATH}/v1/graphql`,
ssl: !!+(process.env.MIGRATIONS_HASURA_SSL || 0),
secret: process.env.MIGRATIONS_HASURA_SECRET,
});
const root = new DeepClient({
apolloClient: rootClient,
});
export const installPackage = (deep, packageName) => __awaiter(void 0, void 0, void 0, function* () {
const adminId = yield deep.id('deep', 'admin');
const promiseTree = deep.idLocal('@deep-foundation/core', 'promiseTree');
log('adminId', adminId);
const packageQueryTypeId = deep.idLocal('@deep-foundation/core', 'PackageQuery');
log('packageQueryTypeId', packageQueryTypeId);
const installTypeId = yield deep.id('@deep-foundation/npm-packager', 'Install');
log('installTypeId', installTypeId);
const { data: [{ id: installId = undefined } = {}] = [] } = {} = yield deep.insert({
from_id: adminId,
type_id: installTypeId,
to: {
data: {
type_id: packageQueryTypeId,
string: { data: { value: packageName } }
}
}
});
yield deep.await(installId);
console.log(JSON.stringify((yield deep.select({
up: { tree_id: promiseTree, parent_id: installId },
})).data, null, 2));
const packageId = yield deep.id(packageName);
log(`${packageName} package is installed as ${packageId} link.`);
return packageId;
});
export const up = () => __awaiter(void 0, void 0, void 0, function* () {
log('up');
});
export const down = () => __awaiter(void 0, void 0, void 0, function* () {
log('down');
});
//# sourceMappingURL=1678940577209-deepcase.js.map