Skip to content

Commit

Permalink
feat: pre-generate and commit prisma client
Browse files Browse the repository at this point in the history
  • Loading branch information
okjodom committed Oct 30, 2024
1 parent 5e0f6d5 commit 4a3389a
Show file tree
Hide file tree
Showing 28 changed files with 8,852 additions and 11 deletions.
8 changes: 3 additions & 5 deletions apps/swap/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@ COPY package.json ./
COPY bun.lockb ./
COPY tsconfig.json tsconfig.json
COPY nest-cli.json nest-cli.json
COPY apps/swap/prisma ./prisma
COPY apps/swap/prisma/client ./prisma/client

# FIXME: This hack allows prisma to work with oven/bun
# Ref: https://github.com/oven-sh/bun/issues/5320#issuecomment-1730927088
COPY --from=node:18 /usr/local/bin/node /usr/local/bin/node
COPY --from=node:20 /usr/local/bin/node /usr/local/bin/node

COPY apps/swap apps/swap
COPY libs libs
COPY proto proto

RUN bun install

RUN bun run prisma generate

RUN bun build:swap

FROM oven/bun:latest AS production
Expand All @@ -36,5 +33,6 @@ RUN bun install --production

COPY --from=development /usr/src/app/dist ./dist
COPY --from=development /usr/src/app/proto ./proto
COPY --from=development /usr/src/app/prisma ./prisma

CMD ["sh", "-c", "bun prisma migrate deploy && bun dist/apps/swap/main.js"]
1 change: 1 addition & 0 deletions apps/swap/prisma/client/default.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./index"
1 change: 1 addition & 0 deletions apps/swap/prisma/client/default.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = { ...require('.') }
1 change: 1 addition & 0 deletions apps/swap/prisma/client/edge.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./default"
218 changes: 218 additions & 0 deletions apps/swap/prisma/client/edge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@

Object.defineProperty(exports, "__esModule", { value: true });

const {
PrismaClientKnownRequestError,
PrismaClientUnknownRequestError,
PrismaClientRustPanicError,
PrismaClientInitializationError,
PrismaClientValidationError,
NotFoundError,
getPrismaClient,
sqltag,
empty,
join,
raw,
skip,
Decimal,
Debug,
objectEnumValues,
makeStrictEnum,
Extensions,
warnOnce,
defineDmmfProperty,
Public,
getRuntime
} = require('./runtime/edge.js')


const Prisma = {}

exports.Prisma = Prisma
exports.$Enums = {}

/**
* Prisma Client JS version: 5.21.1
* Query Engine version: bf0e5e8a04cada8225617067eaa03d041e2bba36
*/
Prisma.prismaVersion = {
client: "5.21.1",
engine: "bf0e5e8a04cada8225617067eaa03d041e2bba36"
}

Prisma.PrismaClientKnownRequestError = PrismaClientKnownRequestError;
Prisma.PrismaClientUnknownRequestError = PrismaClientUnknownRequestError
Prisma.PrismaClientRustPanicError = PrismaClientRustPanicError
Prisma.PrismaClientInitializationError = PrismaClientInitializationError
Prisma.PrismaClientValidationError = PrismaClientValidationError
Prisma.NotFoundError = NotFoundError
Prisma.Decimal = Decimal

/**
* Re-export of sql-template-tag
*/
Prisma.sql = sqltag
Prisma.empty = empty
Prisma.join = join
Prisma.raw = raw
Prisma.validator = Public.validator

/**
* Extensions
*/
Prisma.getExtensionContext = Extensions.getExtensionContext
Prisma.defineExtension = Extensions.defineExtension

/**
* Shorthand utilities for JSON filtering
*/
Prisma.DbNull = objectEnumValues.instances.DbNull
Prisma.JsonNull = objectEnumValues.instances.JsonNull
Prisma.AnyNull = objectEnumValues.instances.AnyNull

Prisma.NullTypes = {
DbNull: objectEnumValues.classes.DbNull,
JsonNull: objectEnumValues.classes.JsonNull,
AnyNull: objectEnumValues.classes.AnyNull
}





/**
* Enums
*/
exports.Prisma.TransactionIsolationLevel = makeStrictEnum({
ReadUncommitted: 'ReadUncommitted',
ReadCommitted: 'ReadCommitted',
RepeatableRead: 'RepeatableRead',
Serializable: 'Serializable'
});

exports.Prisma.MpesaOnrampSwapScalarFieldEnum = {
id: 'id',
state: 'state',
userId: 'userId',
mpesaId: 'mpesaId',
lightning: 'lightning',
rate: 'rate',
retryCount: 'retryCount',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
};

exports.Prisma.IntasendMpesaTransactionScalarFieldEnum = {
id: 'id',
state: 'state',
apiRef: 'apiRef',
value: 'value',
charges: 'charges',
netAmount: 'netAmount',
currency: 'currency',
account: 'account',
retryCount: 'retryCount',
createdAt: 'createdAt',
updatedAt: 'updatedAt'
};

exports.Prisma.SortOrder = {
asc: 'asc',
desc: 'desc'
};

exports.Prisma.QueryMode = {
default: 'default',
insensitive: 'insensitive'
};
exports.SwapTransactionState = exports.$Enums.SwapTransactionState = {
PENDING: 'PENDING',
PROCESSING: 'PROCESSING',
FAILED: 'FAILED',
COMPLETE: 'COMPLETE',
RETRY: 'RETRY'
};

exports.Prisma.ModelName = {
MpesaOnrampSwap: 'MpesaOnrampSwap',
IntasendMpesaTransaction: 'IntasendMpesaTransaction'
};
/**
* Create the Client
*/
const config = {
"generator": {
"name": "client",
"provider": {
"fromEnvVar": null,
"value": "prisma-client-js"
},
"output": {
"value": "/usr/src/app/apps/swap/prisma/client",
"fromEnvVar": null
},
"config": {
"engineType": "library"
},
"binaryTargets": [
{
"fromEnvVar": null,
"value": "debian-openssl-1.1.x",
"native": true
},
{
"fromEnvVar": null,
"value": "linux-musl-openssl-3.0.x"
},
{
"fromEnvVar": null,
"value": "debian-openssl-1.1.x"
}
],
"previewFeatures": [],
"sourceFilePath": "/usr/src/app/apps/swap/prisma/schema.prisma",
"isCustomOutput": true
},
"relativeEnvPaths": {
"rootEnvPath": null
},
"relativePath": "..",
"clientVersion": "5.21.1",
"engineVersion": "bf0e5e8a04cada8225617067eaa03d041e2bba36",
"datasourceNames": [
"db"
],
"activeProvider": "postgresql",
"postinstall": false,
"inlineDatasources": {
"db": {
"url": {
"fromEnvVar": "DATABASE_URL",
"value": null
}
}
},
"inlineSchema": "generator client {\n provider = \"prisma-client-js\"\n output = \"./client\"\n binaryTargets = [\"native\", \"linux-musl-openssl-3.0.x\", \"debian-openssl-1.1.x\"]\n}\n\ndatasource db {\n provider = \"postgresql\"\n url = env(\"DATABASE_URL\")\n}\n\nmodel MpesaOnrampSwap {\n /// Unique identifier for the swap\n id String @id @default(uuid())\n /// Tracks progress of the swap\n state SwapTransactionState\n /// References the user who made the transaction.\n userId String\n /// References the onramp Mpesa transaction ID.\n mpesaId String @unique\n /// Lightning invoice to pay.\n lightning String\n /// Fx Rate\n rate String\n /// Retry count tracker\n retryCount Int\n /// Timestamps\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nenum SwapTransactionState {\n PENDING\n PROCESSING\n FAILED\n COMPLETE\n RETRY\n}\n\nmodel IntasendMpesaTransaction {\n id String @id @default(uuid())\n state SwapTransactionState\n apiRef String\n value String\n charges String\n netAmount String\n currency String\n account String\n retryCount Int\n createdAt String\n updatedAt String\n}\n",
"inlineSchemaHash": "5d0a756630ab4cb854d4906bebde4468586658974e57be5cac61985ff3dc9eb2",
"copyEngine": true
}
config.dirname = '/'

config.runtimeDataModel = JSON.parse("{\"models\":{\"MpesaOnrampSwap\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"default\":{\"name\":\"uuid(4)\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Unique identifier for the swap\"},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Tracks progress of the swap\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the user who made the transaction.\"},{\"name\":\"mpesaId\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":true,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"References the onramp Mpesa transaction ID.\"},{\"name\":\"lightning\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Lightning invoice to pay.\"},{\"name\":\"rate\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Fx Rate\"},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Retry count tracker\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"DateTime\",\"default\":{\"name\":\"now\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false,\"documentation\":\"Timestamps\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"DateTime\",\"isGenerated\":false,\"isUpdatedAt\":true}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false},\"IntasendMpesaTransaction\":{\"dbName\":null,\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":true,\"isReadOnly\":false,\"hasDefaultValue\":true,\"type\":\"String\",\"default\":{\"name\":\"uuid(4)\",\"args\":[]},\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"state\",\"kind\":\"enum\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"SwapTransactionState\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"apiRef\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"value\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"charges\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"netAmount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"currency\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"account\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"retryCount\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"Int\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"isList\":false,\"isRequired\":true,\"isUnique\":false,\"isId\":false,\"isReadOnly\":false,\"hasDefaultValue\":false,\"type\":\"String\",\"isGenerated\":false,\"isUpdatedAt\":false}],\"primaryKey\":null,\"uniqueFields\":[],\"uniqueIndexes\":[],\"isGenerated\":false}},\"enums\":{\"SwapTransactionState\":{\"values\":[{\"name\":\"PENDING\",\"dbName\":null},{\"name\":\"PROCESSING\",\"dbName\":null},{\"name\":\"FAILED\",\"dbName\":null},{\"name\":\"COMPLETE\",\"dbName\":null},{\"name\":\"RETRY\",\"dbName\":null}],\"dbName\":null}},\"types\":{}}")
defineDmmfProperty(exports.Prisma, config.runtimeDataModel)
config.engineWasm = undefined

config.injectableEdgeEnv = () => ({
parsed: {
DATABASE_URL: typeof globalThis !== 'undefined' && globalThis['DATABASE_URL'] || typeof process !== 'undefined' && process.env && process.env.DATABASE_URL || undefined
}
})

if (typeof globalThis !== 'undefined' && globalThis['DEBUG'] || typeof process !== 'undefined' && process.env && process.env.DEBUG || undefined) {
Debug.enable(typeof globalThis !== 'undefined' && globalThis['DEBUG'] || typeof process !== 'undefined' && process.env && process.env.DEBUG || undefined)
}

const PrismaClient = getPrismaClient(config)
exports.PrismaClient = PrismaClient
Object.assign(exports, Prisma)

Loading

0 comments on commit 4a3389a

Please sign in to comment.