fixies
This commit is contained in:
parent
668a5bbac5
commit
136a9ad231
11 changed files with 39 additions and 78 deletions
|
|
@ -17,6 +17,7 @@ import { TrackedProvider } from "./build/src/services/storage/entity/TrackedProv
|
||||||
import { InviteToken } from "./build/src/services/storage/entity/InviteToken.js"
|
import { InviteToken } from "./build/src/services/storage/entity/InviteToken.js"
|
||||||
import { DebitAccess } from "./build/src/services/storage/entity/DebitAccess.js"
|
import { DebitAccess } from "./build/src/services/storage/entity/DebitAccess.js"
|
||||||
import { UserOffer } from "./build/src/services/storage/entity/UserOffer.js"
|
import { UserOffer } from "./build/src/services/storage/entity/UserOffer.js"
|
||||||
|
import { ManagementGrant } from "./build/src/services/storage/entity/ManagementGrant.js"
|
||||||
|
|
||||||
import { Initial1703170309875 } from './build/src/services/storage/migrations/1703170309875-initial.js'
|
import { Initial1703170309875 } from './build/src/services/storage/migrations/1703170309875-initial.js'
|
||||||
import { LspOrder1718387847693 } from './build/src/services/storage/migrations/1718387847693-lsp_order.js'
|
import { LspOrder1718387847693 } from './build/src/services/storage/migrations/1718387847693-lsp_order.js'
|
||||||
|
|
@ -35,7 +36,7 @@ export default new DataSource({
|
||||||
// logging: true,
|
// logging: true,
|
||||||
migrations: [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264, DebitToPub1727105758354, UserCbUrl1727112281043, UserOffer1733502626042],
|
migrations: [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264, DebitToPub1727105758354, UserCbUrl1727112281043, UserOffer1733502626042],
|
||||||
entities: [User, UserReceivingInvoice, UserReceivingAddress, AddressReceivingTransaction, UserInvoicePayment, UserTransactionPayment,
|
entities: [User, UserReceivingInvoice, UserReceivingAddress, AddressReceivingTransaction, UserInvoicePayment, UserTransactionPayment,
|
||||||
UserBasicAuth, UserEphemeralKey, Product, UserToUserPayment, Application, ApplicationUser, UserToUserPayment, LspOrder, LndNodeInfo, TrackedProvider, InviteToken, DebitAccess, UserOffer],
|
UserBasicAuth, UserEphemeralKey, Product, UserToUserPayment, Application, ApplicationUser, UserToUserPayment, LspOrder, LndNodeInfo, TrackedProvider, InviteToken, DebitAccess, UserOffer, ManagementGrant],
|
||||||
// synchronize: true,
|
// synchronize: true,
|
||||||
})
|
})
|
||||||
//npx typeorm migration:generate ./src/services/storage/migrations/ops_time -d ./datasource.js
|
//npx typeorm migration:generate ./src/services/storage/migrations/management_grant -d ./datasource.js
|
||||||
8
package-lock.json
generated
8
package-lock.json
generated
|
|
@ -13,7 +13,7 @@
|
||||||
"@protobuf-ts/grpc-transport": "^2.9.4",
|
"@protobuf-ts/grpc-transport": "^2.9.4",
|
||||||
"@protobuf-ts/plugin": "^2.5.0",
|
"@protobuf-ts/plugin": "^2.5.0",
|
||||||
"@protobuf-ts/runtime": "^2.5.0",
|
"@protobuf-ts/runtime": "^2.5.0",
|
||||||
"@shocknet/clink-sdk": "^1.1.2",
|
"@shocknet/clink-sdk": "^1.1.4",
|
||||||
"@stablelib/xchacha20": "^1.0.1",
|
"@stablelib/xchacha20": "^1.0.1",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.31",
|
||||||
|
|
@ -591,9 +591,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@shocknet/clink-sdk": {
|
"node_modules/@shocknet/clink-sdk": {
|
||||||
"version": "1.1.2",
|
"version": "1.1.4",
|
||||||
"resolved": "https://registry.npmjs.org/@shocknet/clink-sdk/-/clink-sdk-1.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/@shocknet/clink-sdk/-/clink-sdk-1.1.4.tgz",
|
||||||
"integrity": "sha512-nICsXlLZRIs6E+wy3PfQccIidmQ/D7uSHfHfqrJzNJFOUH2+XGDkApB9TQU1eTrNgD/BHxm9tSZkEmG0it7I3w==",
|
"integrity": "sha512-b0YVsisIkTxOAwxrb1a9DGDxwWkHm7kJ2BpqOzkEbtJ6flkJxo2ggmRH3fxsVIiJOeVWwgSPATab68JU8DSLOA==",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@noble/hashes": "^1.8.0",
|
"@noble/hashes": "^1.8.0",
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
"@protobuf-ts/grpc-transport": "^2.9.4",
|
"@protobuf-ts/grpc-transport": "^2.9.4",
|
||||||
"@protobuf-ts/plugin": "^2.5.0",
|
"@protobuf-ts/plugin": "^2.5.0",
|
||||||
"@protobuf-ts/runtime": "^2.5.0",
|
"@protobuf-ts/runtime": "^2.5.0",
|
||||||
"@shocknet/clink-sdk": "^1.1.2",
|
"@shocknet/clink-sdk": "^1.1.4",
|
||||||
"@stablelib/xchacha20": "^1.0.1",
|
"@stablelib/xchacha20": "^1.0.1",
|
||||||
"@types/express": "^4.17.21",
|
"@types/express": "^4.17.21",
|
||||||
"@types/node": "^17.0.31",
|
"@types/node": "^17.0.31",
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,7 @@ import { NostrEvent, NostrSend, NostrSettings } from "./services/nostr/handler.j
|
||||||
import * as Types from '../proto/autogenerated/ts/types.js'
|
import * as Types from '../proto/autogenerated/ts/types.js'
|
||||||
import NewNostrTransport, { NostrRequest } from '../proto/autogenerated/ts/nostr_transport.js';
|
import NewNostrTransport, { NostrRequest } from '../proto/autogenerated/ts/nostr_transport.js';
|
||||||
import { ERROR, getLogger } from "./services/helpers/logger.js";
|
import { ERROR, getLogger } from "./services/helpers/logger.js";
|
||||||
import { NdebitData, NofferData } from "@shocknet/clink-sdk";
|
import { NdebitData, NofferData, NmanageRequest } from "@shocknet/clink-sdk";
|
||||||
import { NmanageRequest } from "./services/main/managementManager.js";
|
|
||||||
|
|
||||||
export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSettings: NostrSettings, onClientEvent: (e: { requestId: string }, fromPub: string) => void): { Stop: () => void, Send: NostrSend, Ping: () => Promise<void> } => {
|
export default (serverMethods: Types.ServerMethods, mainHandler: Main, nostrSettings: NostrSettings, onClientEvent: (e: { requestId: string }, fromPub: string) => void): { Stop: () => void, Send: NostrSend, Ping: () => Promise<void> } => {
|
||||||
const log = getLogger({})
|
const log = getLogger({})
|
||||||
|
|
|
||||||
|
|
@ -77,8 +77,8 @@ export default class {
|
||||||
this.applicationManager = new ApplicationManager(this.storage, this.settings, this.paymentManager)
|
this.applicationManager = new ApplicationManager(this.storage, this.settings, this.paymentManager)
|
||||||
this.appUserManager = new AppUserManager(this.storage, this.settings, this.applicationManager)
|
this.appUserManager = new AppUserManager(this.storage, this.settings, this.applicationManager)
|
||||||
this.debitManager = new DebitManager(this.storage, this.lnd, this.applicationManager)
|
this.debitManager = new DebitManager(this.storage, this.lnd, this.applicationManager)
|
||||||
this.offerManager = new OfferManager(this.storage, this.lnd, this.applicationManager, this.productManager, this.liquidityManager)
|
this.offerManager = new OfferManager(this.storage, this.settings, this.lnd, this.applicationManager, this.productManager, this.liquidityManager)
|
||||||
this.managementManager = new ManagementManager(this.storage, this.offerManager)
|
this.managementManager = new ManagementManager(this.storage, this.settings)
|
||||||
//this.webRTC = new webRTC(this.storage, this.utils)
|
//this.webRTC = new webRTC(this.storage, this.utils)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@ import { InviteToken } from "../entity/InviteToken.js"
|
||||||
import { DebitAccess } from "../entity/DebitAccess.js"
|
import { DebitAccess } from "../entity/DebitAccess.js"
|
||||||
import { RootOperation } from "../entity/RootOperation.js"
|
import { RootOperation } from "../entity/RootOperation.js"
|
||||||
import { UserOffer } from "../entity/UserOffer.js"
|
import { UserOffer } from "../entity/UserOffer.js"
|
||||||
|
import { ManagementGrant } from "../entity/ManagementGrant.js"
|
||||||
|
|
||||||
|
|
||||||
export type DbSettings = {
|
export type DbSettings = {
|
||||||
|
|
@ -65,7 +66,8 @@ export const MainDbEntities = {
|
||||||
'InviteToken': InviteToken,
|
'InviteToken': InviteToken,
|
||||||
'DebitAccess': DebitAccess,
|
'DebitAccess': DebitAccess,
|
||||||
'UserOffer': UserOffer,
|
'UserOffer': UserOffer,
|
||||||
'Product': Product
|
'Product': Product,
|
||||||
|
'ManagementGrant': ManagementGrant
|
||||||
}
|
}
|
||||||
export type MainDbNames = keyof typeof MainDbEntities
|
export type MainDbNames = keyof typeof MainDbEntities
|
||||||
export const MainDbEntitiesNames = Object.keys(MainDbEntities)
|
export const MainDbEntitiesNames = Object.keys(MainDbEntities)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn, UpdateDateColumn } from "typeorm";
|
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, ManyToOne, JoinColumn, UpdateDateColumn } from "typeorm";
|
||||||
import { User } from "./User";
|
import { User } from "./User";
|
||||||
|
|
||||||
@Entity("management_grants")
|
@Entity()
|
||||||
export class ManagementGrant {
|
export class ManagementGrant {
|
||||||
@PrimaryGeneratedColumn()
|
@PrimaryGeneratedColumn()
|
||||||
serial_id: number
|
serial_id: number
|
||||||
|
|
|
||||||
|
|
@ -1,14 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner } from "typeorm"
|
|
||||||
|
|
||||||
export class AddOfferManagingAppPubKey1749933500426 implements MigrationInterface {
|
|
||||||
name = 'AddOfferManagingAppPubKey1749933500426'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "user_offer" ADD "managing_app_pubkey" character varying`);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.query(`ALTER TABLE "user_offer" DROP COLUMN "managing_app_pubkey"`);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
||||||
import { MigrationInterface, QueryRunner, Table, TableForeignKey } from "typeorm"
|
|
||||||
|
|
||||||
export class CreateManagementGrant1749934345873 implements MigrationInterface {
|
|
||||||
name = 'CreateManagementGrant1749934345873'
|
|
||||||
|
|
||||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.createTable(new Table({
|
|
||||||
name: "management_grants",
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
name: "id",
|
|
||||||
type: "varchar",
|
|
||||||
isPrimary: true,
|
|
||||||
isGenerated: true,
|
|
||||||
generationStrategy: "uuid"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "user_id",
|
|
||||||
type: "varchar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "app_pubkey",
|
|
||||||
type: "varchar"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "created_at",
|
|
||||||
type: "timestamp",
|
|
||||||
default: "CURRENT_TIMESTAMP"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "expires_at",
|
|
||||||
type: "timestamp",
|
|
||||||
isNullable: true
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}));
|
|
||||||
|
|
||||||
await queryRunner.createForeignKey("management_grants", new TableForeignKey({
|
|
||||||
columnNames: ["user_id"],
|
|
||||||
referencedColumnNames: ["user_id"],
|
|
||||||
referencedTableName: "user",
|
|
||||||
onDelete: "CASCADE"
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
|
||||||
await queryRunner.dropTable("management_grants");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class ManagementGrant1751307732346 implements MigrationInterface {
|
||||||
|
name = 'ManagementGrant1751307732346'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`CREATE TABLE "management_grant" ("serial_id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "app_user_id" varchar NOT NULL, "app_pubkey" varchar NOT NULL, "expires_at_unix" integer NOT NULL, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')))`);
|
||||||
|
await queryRunner.query(`CREATE TABLE "temporary_user_offer" ("serial_id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "app_user_id" varchar NOT NULL, "offer_id" varchar NOT NULL, "label" varchar NOT NULL, "price_sats" integer NOT NULL DEFAULT (0), "callback_url" varchar NOT NULL DEFAULT (''), "expected_data" text, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')), "management_pubkey" varchar NOT NULL DEFAULT (''), CONSTRAINT "UQ_478f72095abd8a516d3a309a5c5" UNIQUE ("offer_id"))`);
|
||||||
|
await queryRunner.query(`INSERT INTO "temporary_user_offer"("serial_id", "app_user_id", "offer_id", "label", "price_sats", "callback_url", "expected_data", "created_at", "updated_at") SELECT "serial_id", "app_user_id", "offer_id", "label", "price_sats", "callback_url", "expected_data", "created_at", "updated_at" FROM "user_offer"`);
|
||||||
|
await queryRunner.query(`DROP TABLE "user_offer"`);
|
||||||
|
await queryRunner.query(`ALTER TABLE "temporary_user_offer" RENAME TO "user_offer"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE "user_offer" RENAME TO "temporary_user_offer"`);
|
||||||
|
await queryRunner.query(`CREATE TABLE "user_offer" ("serial_id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "app_user_id" varchar NOT NULL, "offer_id" varchar NOT NULL, "label" varchar NOT NULL, "price_sats" integer NOT NULL DEFAULT (0), "callback_url" varchar NOT NULL DEFAULT (''), "expected_data" text, "created_at" datetime NOT NULL DEFAULT (datetime('now')), "updated_at" datetime NOT NULL DEFAULT (datetime('now')), CONSTRAINT "UQ_478f72095abd8a516d3a309a5c5" UNIQUE ("offer_id"))`);
|
||||||
|
await queryRunner.query(`INSERT INTO "user_offer"("serial_id", "app_user_id", "offer_id", "label", "price_sats", "callback_url", "expected_data", "created_at", "updated_at") SELECT "serial_id", "app_user_id", "offer_id", "label", "price_sats", "callback_url", "expected_data", "created_at", "updated_at" FROM "temporary_user_offer"`);
|
||||||
|
await queryRunner.query(`DROP TABLE "temporary_user_offer"`);
|
||||||
|
await queryRunner.query(`DROP TABLE "management_grant"`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -16,7 +16,8 @@ import { UserCbUrl1727112281043 } from './1727112281043-user_cb_url.js'
|
||||||
import { RootOps1732566440447 } from './1732566440447-root_ops.js'
|
import { RootOps1732566440447 } from './1732566440447-root_ops.js'
|
||||||
import { UserOffer1733502626042 } from './1733502626042-user_offer.js'
|
import { UserOffer1733502626042 } from './1733502626042-user_offer.js'
|
||||||
import { RootOpsTime1745428134124 } from './1745428134124-root_ops_time.js'
|
import { RootOpsTime1745428134124 } from './1745428134124-root_ops_time.js'
|
||||||
export const allMigrations = [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189, TrackedProvider1720814323679, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264, DebitToPub1727105758354, UserCbUrl1727112281043, UserOffer1733502626042]
|
import { ManagementGrant1751307732346 } from './1751307732346-management_grant.js'
|
||||||
|
export const allMigrations = [Initial1703170309875, LspOrder1718387847693, LiquidityProvider1719335699480, LndNodeInfo1720187506189, TrackedProvider1720814323679, CreateInviteTokenTable1721751414878, PaymentIndex1721760297610, DebitAccess1726496225078, DebitAccessFixes1726685229264, DebitToPub1727105758354, UserCbUrl1727112281043, UserOffer1733502626042, ManagementGrant1751307732346]
|
||||||
export const allMetricsMigrations = [LndMetrics1703170330183, ChannelRouting1709316653538, HtlcCount1724266887195, BalanceEvents1724860966825, RootOps1732566440447, RootOpsTime1745428134124]
|
export const allMetricsMigrations = [LndMetrics1703170330183, ChannelRouting1709316653538, HtlcCount1724266887195, BalanceEvents1724860966825, RootOps1732566440447, RootOpsTime1745428134124]
|
||||||
/* export const TypeOrmMigrationRunner = async (log: PubLogger, storageManager: Storage, settings: DbSettings, arg: string | undefined): Promise<boolean> => {
|
/* export const TypeOrmMigrationRunner = async (log: PubLogger, storageManager: Storage, settings: DbSettings, arg: string | undefined): Promise<boolean> => {
|
||||||
await connectAndMigrate(log, storageManager, allMigrations, allMetricsMigrations)
|
await connectAndMigrate(log, storageManager, allMigrations, allMetricsMigrations)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue