Skip to content

Commit

Permalink
Use @build5/database in functions
Browse files Browse the repository at this point in the history
Fixes

Fixes

Fixes

Fixes
  • Loading branch information
Boldizsar Mezei committed Oct 22, 2023
1 parent 9ac60fc commit ecfa78d
Show file tree
Hide file tree
Showing 406 changed files with 396 additions and 1,077 deletions.
39 changes: 2 additions & 37 deletions .github/workflows/functions_emulated-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -220,49 +220,14 @@ jobs:
npm run test:ci -- --forceExit --findRelatedTests ./test/cron/nft-stake.cron.spec.ts &&
npm run test:ci -- --forceExit --findRelatedTests ./test/cron/proposal.cron.spec.ts &&
npm run test:ci -- --forceExit --findRelatedTests ./test/db.roll.spec.ts &&
npm run test:ci -- --forceExit --findRelatedTests ./test/dbRoll/total.guardians.roll.spec.ts &&
npm run test:ci -- --forceExit --findRelatedTests ./test/stake/delete.stake.reward.spec.ts &&
npm run test:ci -- --forceExit --findRelatedTests ./test/stake/stake.reward.cron.spec.ts
" --project dev --only functions,firestore,storage,ui,auth --export-on-exit=./firestore-data
- name: Archive firestore data
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: firestore-data-test-chunk_4
path: ./packages/functions/firestore-data/
retention-days: 1
chunk_5:
needs: npm-install
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16.x
- uses: actions/cache@v3
with:
path: |
node_modules
packages/functions/node_modules
packages/interfaces/node_modules
key: ${{ runner.os }}-modules-${{ hashFiles('**/package.json') }}
- name: Init
run: |
npm run build:functions
npm install -g firebase-tools
- name: Test
working-directory: packages/functions
run: |
export GOOGLE_APPLICATION_CREDENTIALS="./test-service-account-key.json"
npm run milestone-sync &
firebase emulators:exec "
npm run test:ci -- --forceExit --findRelatedTests ./test/stake/stake.reward.cron.spec.ts &&
npm run test:ci -- --forceExit --findRelatedTests ./test/storage/resize.img.spec.ts
" --project dev --only functions,firestore,storage,ui,auth --export-on-exit=./firestore-data
- name: Archive firestore data
uses: actions/upload-artifact@v3
if: ${{ failure() }}
with:
name: firestore-data-test-chunk_5
name: firestore-data-test-chunk_4
path: ./packages/functions/firestore-data/
retention-days: 1
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
"packages/functions"
],
"scripts": {
"build:functions": "npm run build:interfaces && npm i --workspace=packages/functions && npm run build --workspace=packages/functions",
"build:functions": "npm run build:database && npm i --workspace=packages/functions && npm run build --workspace=packages/functions",
"build:interfaces": "npm i --workspace=packages/interfaces && npm run build --workspace=packages/interfaces",
"build:lib": "npm run build:interfaces && npm i --workspace=packages/lib && npm run build --workspace=packages/lib",
"build:indexes": "npm i --workspace=packages/indexes && npm run build --workspace=packages/indexes",
"build:database": "npm run build:interfaces && npm i --workspace=packages/database && npm run build --workspace=packages/database",
"build:api": "npm run build:interfaces && npm run build:database && npm i --workspace=packages/api && npm run build --workspace=packages/api",
"build:api": "npm run build:database && npm i --workspace=packages/api && npm run build --workspace=packages/api",
"build": "npm i --workspaces && npm run build --workspaces",
"clean:api": "rm -rf packages/api/lib; rm -rf packages/api/node_modules",
"clean:database": "rm -rf packages/database/lib; rm -rf packages/database/node_modules",
Expand Down
1 change: 1 addition & 0 deletions packages/functions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
},
"dependencies": {
"@build-5/interfaces": "*",
"@build-5/database": "*",
"@ffmpeg-installer/ffmpeg": "1.1.0",
"@ffprobe-installer/ffprobe": "2.0.0",
"@iota/sdk": "1.1.1",
Expand Down
41 changes: 0 additions & 41 deletions packages/functions/scripts/db.upgrade.ts

This file was deleted.

55 changes: 0 additions & 55 deletions packages/functions/scripts/dbUpgrades/1.0/totalGuardiansRoll.ts

This file was deleted.

2 changes: 1 addition & 1 deletion packages/functions/src/controls/address/address.control.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Network,
WenError,
} from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { build5Db } from '@build-5/database';
import { createAddressValidationOrder } from '../../services/payment/tangle-service/address/address-validation.service';
import { invalidArgument } from '../../utils/error.utils';
import { Context } from '../common';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { build5Db } from '@build-5/database';
import {
ApiError,
AwardApproveParticipantRequest,
AwardApproveParticipantResponse,
Transaction,
} from '@build-5/interfaces';
import { get } from 'lodash';
import { build5Db } from '../../firebase/firestore/build5Db';
import { approveAwardParticipant } from '../../services/payment/tangle-service/award/award.approve.participant.service';
import { Context } from '../common';

Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/award/award.cancel.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { build5Db } from '@build-5/database';
import { Award, AwardCancelRequest, COL, WenError } from '@build-5/interfaces';
import dayjs from 'dayjs';
import { build5Db } from '../../firebase/firestore/build5Db';
import { invalidArgument } from '../../utils/error.utils';
import { assertIsGuardian } from '../../utils/token.utils';
import { Context } from '../common';
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/award/award.create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { build5Db } from '@build-5/database';
import { Award, AwardCreateRequest, COL, SUB_COL } from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { createAward } from '../../services/payment/tangle-service/award/award.create.service';
import { Context } from '../common';

Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/award/award.fund.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { build5Db } from '@build-5/database';
import { AwardFundRequest, COL, Transaction } from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import {
createAwardFundOrder,
getAwardForFunding,
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/award/award.owner.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { build5Db } from '@build-5/database';
import {
Award,
AwardAddOwnerRequest,
Expand All @@ -7,7 +8,6 @@ import {
WenError,
} from '@build-5/interfaces';
import dayjs from 'dayjs';
import { build5Db } from '../../firebase/firestore/build5Db';
import { dateToTimestamp } from '../../utils/dateTime.utils';
import { invalidArgument } from '../../utils/error.utils';
import { Context } from '../common';
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/award/award.participate.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { build5Db } from '@build-5/database';
import {
Award,
AwardParticipant,
Expand All @@ -7,7 +8,6 @@ import {
WenError,
} from '@build-5/interfaces';
import dayjs from 'dayjs';
import { build5Db } from '../../firebase/firestore/build5Db';
import { dateToTimestamp } from '../../utils/dateTime.utils';
import { invalidArgument } from '../../utils/error.utils';
import { Context } from '../common';
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/award/award.reject.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { build5Db } from '@build-5/database';
import { Award, AwardRejectRequest, COL, WenError } from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { invalidArgument } from '../../utils/error.utils';
import { assertIsGuardian } from '../../utils/token.utils';
import { Context } from '../common';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { build5Db, getSnapshot } from '@build-5/database';
import {
COL,
Collection,
Expand All @@ -19,7 +20,6 @@ import {
import { Ed25519Address } from '@iota/sdk';
import dayjs from 'dayjs';
import { last } from 'lodash';
import { build5Db, getSnapshot } from '../../firebase/firestore/build5Db';
import { Wallet } from '../../services/wallet/wallet';
import { AddressDetails, WalletService } from '../../services/wallet/wallet.service';
import { assertMemberHasValidAddress, assertSpaceHasValidAddress } from '../../utils/address.utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { build5Db } from '@build-5/database';
import { ApproveCollectionRequest, COL, Collection, WenError } from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { invalidArgument } from '../../utils/error.utils';
import { assertIsGuardian } from '../../utils/token.utils';
import { Context } from '../common';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { build5Db } from '@build-5/database';
import {
COL,
Collection,
Expand All @@ -12,7 +13,6 @@ import {
SUB_COL,
WenError,
} from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { hasStakedSoonTokens } from '../../services/stake.service';
import { assertSpaceHasValidAddress } from '../../utils/address.utils';
import { dateToTimestamp, serverTime } from '../../utils/dateTime.utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { build5Db } from '@build-5/database';
import { COL, Collection, RejectCollectionRequest, WenError } from '@build-5/interfaces';
import dayjs from 'dayjs';
import { build5Db } from '../../firebase/firestore/build5Db';
import { invalidArgument } from '../../utils/error.utils';
import { assertIsGuardian } from '../../utils/token.utils';
import { Context } from '../common';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { build5Db, getSnapshot } from '@build-5/database';
import {
COL,
Collection,
Expand All @@ -11,7 +12,6 @@ import {
} from '@build-5/interfaces';
import dayjs from 'dayjs';
import { isEmpty, last, set } from 'lodash';
import { build5Db, getSnapshot } from '../../firebase/firestore/build5Db';
import { dateToTimestamp } from '../../utils/dateTime.utils';
import { invalidArgument } from '../../utils/error.utils';
import { assertValidationAsync } from '../../utils/schema.utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { build5Db } from '@build-5/database';
import {
COL,
CreditUnrefundableRequest,
Expand All @@ -11,7 +12,6 @@ import {
WenError,
} from '@build-5/interfaces';
import dayjs from 'dayjs';
import { build5Db } from '../../firebase/firestore/build5Db';
import { WalletService } from '../../services/wallet/wallet.service';
import { dateToTimestamp } from '../../utils/dateTime.utils';
import { invalidArgument } from '../../utils/error.utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import fs from 'fs';
import mime from 'mime-types';
import os from 'os';
import path from 'path';
import { build5Storage } from '../../firebase/storage/build5Storage';
import { build5Storage } from '@build-5/database';
import { getBucket } from '../../utils/config.utils';
import { invalidArgument } from '../../utils/error.utils';
import { assertValidationAsync } from '../../utils/schema.utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/member/member.create.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { build5Db } from '@build-5/database';
import { COL, Member } from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { getRandomNonce } from '../../utils/wallet.utils';
import { Context } from '../common';

Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/member/member.update.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { build5Db } from '@build-5/database';
import {
COL,
Member,
Expand All @@ -7,7 +8,6 @@ import {
NftStatus,
WenError,
} from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { invalidArgument } from '../../utils/error.utils';
import { cleanupParams } from '../../utils/schema.utils';
import { Context } from '../common';
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/nft/nft.bid.control.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { build5Db } from '@build-5/database';
import { COL, NftBidRequest, Transaction, WenError } from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { createNftBidOrder } from '../../services/payment/tangle-service/nft/nft-bid.service';
import { invalidArgument } from '../../utils/error.utils';
import { Context } from '../common';
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/nft/nft.create.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { build5Db } from '@build-5/database';
import {
COL,
Collection,
Expand All @@ -11,7 +12,6 @@ import {
} from '@build-5/interfaces';
import dayjs from 'dayjs';
import { isEmpty } from 'lodash';
import { build5Db } from '../../firebase/firestore/build5Db';
import { dateToTimestamp } from '../../utils/dateTime.utils';
import { invalidArgument } from '../../utils/error.utils';
import { getRandomEthAddress } from '../../utils/wallet.utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/nft/nft.deposit.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { build5Db } from '@build-5/database';
import {
COL,
Network,
Expand All @@ -9,7 +10,6 @@ import {
TransactionValidationType,
} from '@build-5/interfaces';
import dayjs from 'dayjs';
import { build5Db } from '../../firebase/firestore/build5Db';
import { WalletService } from '../../services/wallet/wallet.service';
import { dateToTimestamp } from '../../utils/dateTime.utils';
import { getRandomEthAddress } from '../../utils/wallet.utils';
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/nft/nft.puchase.control.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { build5Db } from '@build-5/database';
import { COL, NftPurchaseRequest, Transaction } from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { createNftPuchaseOrder } from '../../services/payment/tangle-service/nft/nft-purchase.service';
import { Context } from '../common';

Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/nft/nft.set.for.sale.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { build5Db } from '@build-5/database';
import { COL, Member, Nft, NftSetForSaleRequest, WenError } from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { getNftSetForSaleParams } from '../../services/payment/tangle-service/nft/nft-set-for-sale.service';
import { invalidArgument } from '../../utils/error.utils';
import { Context } from '../common';
Expand Down
2 changes: 1 addition & 1 deletion packages/functions/src/controls/nft/nft.stake.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { build5Db } from '@build-5/database';
import { COL, Network, NftStakeRequest, StakeType, Transaction } from '@build-5/interfaces';
import { build5Db } from '../../firebase/firestore/build5Db';
import { createNftStakeOrder } from '../../services/payment/nft/nft-stake-service';
import { Context } from '../common';

Expand Down
Loading

0 comments on commit ecfa78d

Please sign in to comment.