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';
import { installPackage } from './1678940577209-deepcase.js';
import { containWithin, packageExists, sharePermissions } from './1664940577200-tsx.js';
const debug = Debug('deeplinks:migrations:passport-username-password');
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 up = () => __awaiter(void 0, void 0, void 0, function* () {
    log('up');
    const packageName = '@deep-foundation/passport-username-password';
    if (!(yield packageExists(packageName))) {
        const adminId = yield root.id('deep', 'admin');
        const admin = yield root.login({ linkId: adminId });
        const deep = new DeepClient(Object.assign({ deep: root }, admin));
        yield installPackage(deep, '@deep-foundation/passport-username-password');
        const packageId = yield root.id('@deep-foundation/passport-username-password');
        yield sharePermissions(adminId, packageId);
        yield containWithin(adminId, packageId);
    }
});
export const down = () => __awaiter(void 0, void 0, void 0, function* () {
    log('down');
});
//# sourceMappingURL=1726165830140-passport-username-password.js.map