mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-10 17:53:36 +02:00
feat: generated db types
This commit is contained in:
parent
dfe068ee33
commit
9f545bea1c
@ -32,6 +32,7 @@
|
||||
"start:dev": "NODE_ENV=development tsc-watch --onSuccess \"node dist/server-dev.js\"",
|
||||
"copy-templates": "copyfiles -u 1 src/mailtemplates/**/*.mustache dist/",
|
||||
"db-migrate": "db-migrate --migrations-dir ./src/migrations",
|
||||
"db-generate-types": "pg-to-ts generate --config src/lib/db/db-type-generate-config.json",
|
||||
"lint": "eslint ./src",
|
||||
"local:package": "del-cli --force build && mkdir build && cp -r dist docs CHANGELOG.md LICENSE README.md package.json build",
|
||||
"prebuild:watch": "yarn run clean",
|
||||
@ -180,6 +181,7 @@
|
||||
"lint-staged": "13.1.2",
|
||||
"nock": "13.3.0",
|
||||
"openapi-enforcer": "1.22.2",
|
||||
"pg-to-ts": "4.1.0",
|
||||
"prettier": "2.8.1",
|
||||
"proxyquire": "2.1.3",
|
||||
"source-map-support": "0.5.21",
|
||||
|
98
src/lib/db/db-extend-knex-types.ts
Normal file
98
src/lib/db/db-extend-knex-types.ts
Normal file
@ -0,0 +1,98 @@
|
||||
import {
|
||||
Addons,
|
||||
ApiTokenProject,
|
||||
ApiTokens,
|
||||
ChangeRequestApprovals,
|
||||
ChangeRequestComments,
|
||||
ChangeRequestEvents,
|
||||
ChangeRequestSettings,
|
||||
ChangeRequests,
|
||||
ClientApplications,
|
||||
ClientInstances,
|
||||
ClientMetricsEnv,
|
||||
ContextFields,
|
||||
Environments,
|
||||
Events,
|
||||
FavoriteFeatures,
|
||||
FavoriteProjects,
|
||||
FeatureEnvironments,
|
||||
FeatureStrategies,
|
||||
FeatureStrategySegment,
|
||||
FeatureTag,
|
||||
FeatureTypes,
|
||||
Features,
|
||||
GroupRole,
|
||||
GroupUser,
|
||||
Groups,
|
||||
Permissions,
|
||||
PersonalAccessTokens,
|
||||
ProjectEnvironments,
|
||||
ProjectStats,
|
||||
Projects,
|
||||
PublicSignupTokens,
|
||||
PublicSignupTokensUser,
|
||||
ResetTokens,
|
||||
RolePermission,
|
||||
RoleUser,
|
||||
Roles,
|
||||
Segments,
|
||||
Settings,
|
||||
Strategies,
|
||||
TagTypes,
|
||||
Tags,
|
||||
UnleashSession,
|
||||
UserFeedback,
|
||||
UserSplash,
|
||||
Users,
|
||||
} from './db-types';
|
||||
|
||||
declare module 'knex/types/tables' {
|
||||
interface Tables {
|
||||
// This is same as specifying `knex<User>('users')`
|
||||
addons: Addons;
|
||||
api_token_project: ApiTokenProject;
|
||||
api_tokens: ApiTokens;
|
||||
change_request_approvals: ChangeRequestApprovals;
|
||||
change_request_comments: ChangeRequestComments;
|
||||
change_request_events: ChangeRequestEvents;
|
||||
change_request_settings: ChangeRequestSettings;
|
||||
change_requests: ChangeRequests;
|
||||
client_applications: ClientApplications;
|
||||
client_instances: ClientInstances;
|
||||
client_metrics_env: ClientMetricsEnv;
|
||||
context_fields: ContextFields;
|
||||
environments: Environments;
|
||||
events: Events;
|
||||
favorite_features: FavoriteFeatures;
|
||||
favorite_projects: FavoriteProjects;
|
||||
feature_environments: FeatureEnvironments;
|
||||
feature_strategies: FeatureStrategies;
|
||||
feature_strategy_segment: FeatureStrategySegment;
|
||||
feature_tag: FeatureTag;
|
||||
feature_types: FeatureTypes;
|
||||
features: Features;
|
||||
group_role: GroupRole;
|
||||
group_user: GroupUser;
|
||||
groups: Groups;
|
||||
permissions: Permissions;
|
||||
personal_access_tokens: PersonalAccessTokens;
|
||||
project_environments: ProjectEnvironments;
|
||||
project_stats: ProjectStats;
|
||||
projects: Projects;
|
||||
public_signup_tokens: PublicSignupTokens;
|
||||
public_signup_tokens_user: PublicSignupTokensUser;
|
||||
reset_tokens: ResetTokens;
|
||||
role_permissions: RolePermission;
|
||||
role_user: RoleUser;
|
||||
roles: Roles;
|
||||
segments: Segments;
|
||||
settings: Settings;
|
||||
strategies: Strategies;
|
||||
tag_types: TagTypes;
|
||||
tag: Tags;
|
||||
unleash_session: UnleashSession;
|
||||
user_feedback: UserFeedback;
|
||||
user_splash: UserSplash;
|
||||
users: Users;
|
||||
}
|
||||
}
|
4
src/lib/db/db-type-generate-config.json
Normal file
4
src/lib/db/db-type-generate-config.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"conn": "postgres://unleash_user:passord@localhost:5432/unleash",
|
||||
"output": "./src/lib/db/db-types.ts"
|
||||
}
|
1663
src/lib/db/db-types.ts
Normal file
1663
src/lib/db/db-types.ts
Normal file
File diff suppressed because it is too large
Load Diff
90
yarn.lock
90
yarn.lock
@ -1643,6 +1643,11 @@ asn1@^0.2.4, asn1@~0.2.3:
|
||||
dependencies:
|
||||
safer-buffer "~2.1.0"
|
||||
|
||||
assert-options@0.8.0:
|
||||
version "0.8.0"
|
||||
resolved "https://registry.yarnpkg.com/assert-options/-/assert-options-0.8.0.tgz#cf71882534d23d3027945bc7462e20d3d3682380"
|
||||
integrity sha512-qSELrEaEz4sGwTs4Qh+swQkjiHAysC4rot21+jzXU86dJzNG+FDqBzyS3ohSoTRf4ZLA3FSwxQdiuNl5NXUtvA==
|
||||
|
||||
assert-plus@1.0.0, assert-plus@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/assert-plus/-/assert-plus-1.0.0.tgz#f12e0f3c5d77b0b1cdd9146942e4e96c1e4dd525"
|
||||
@ -2098,6 +2103,11 @@ combined-stream@^1.0.6, combined-stream@^1.0.8, combined-stream@~1.0.6:
|
||||
dependencies:
|
||||
delayed-stream "~1.0.0"
|
||||
|
||||
commander@^2.19.0:
|
||||
version "2.20.3"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
|
||||
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
|
||||
|
||||
commander@^6.1.0:
|
||||
version "6.2.1"
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-6.2.1.tgz#0792eb682dfbc325999bb2b84fddddba110ac73c"
|
||||
@ -2113,6 +2123,11 @@ commander@^9.4.1:
|
||||
resolved "https://registry.yarnpkg.com/commander/-/commander-9.4.1.tgz#d1dd8f2ce6faf93147295c0df13c7c21141cfbdd"
|
||||
integrity sha512-5EEkTNyHNGFPD2H+c/dXXfQZYa/scCKasxWcXJaWnNJ99pnQN9Vnmqow+p+PlFPE63Q6mThaZws1T+HxfpgtPw==
|
||||
|
||||
commandpost@^1.0.0:
|
||||
version "1.4.0"
|
||||
resolved "https://registry.yarnpkg.com/commandpost/-/commandpost-1.4.0.tgz#89218012089dfc9b67a337ba162f15c88e0f1048"
|
||||
integrity sha512-aE2Y4MTFJ870NuB/+2z1cXBhSBBzRydVVjzhFC4gtenEhpnj15yu0qptWGJsO9YGrcPZ3ezX8AWb1VA391MKpQ==
|
||||
|
||||
component-emitter@^1.3.0:
|
||||
version "1.3.0"
|
||||
resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0"
|
||||
@ -2567,6 +2582,16 @@ ecc-jsbn@~0.1.1:
|
||||
jsbn "~0.1.0"
|
||||
safer-buffer "^2.1.0"
|
||||
|
||||
editorconfig@^0.15.0:
|
||||
version "0.15.3"
|
||||
resolved "https://registry.yarnpkg.com/editorconfig/-/editorconfig-0.15.3.tgz#bef84c4e75fb8dcb0ce5cee8efd51c15999befc5"
|
||||
integrity sha512-M9wIMFx96vq0R4F+gRpY3o2exzb8hEj/n9S8unZtHSvYjibBp/iMufSzvmOcV/laG0ZtuTVGtiJggPOSW2r93g==
|
||||
dependencies:
|
||||
commander "^2.19.0"
|
||||
lru-cache "^4.1.5"
|
||||
semver "^5.6.0"
|
||||
sigmund "^1.0.1"
|
||||
|
||||
ee-first@1.1.1:
|
||||
version "1.1.1"
|
||||
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
|
||||
@ -4812,6 +4837,14 @@ log4js@^6.0.0:
|
||||
rfdc "^1.3.0"
|
||||
streamroller "^3.1.3"
|
||||
|
||||
lru-cache@^4.1.5:
|
||||
version "4.1.5"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.5.tgz#8bbe50ea85bed59bc9e33dcab8235ee9bcf443cd"
|
||||
integrity sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==
|
||||
dependencies:
|
||||
pseudomap "^1.0.2"
|
||||
yallist "^2.1.2"
|
||||
|
||||
lru-cache@^5.1.1:
|
||||
version "5.1.1"
|
||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920"
|
||||
@ -5566,16 +5599,41 @@ pg-int8@1.0.1:
|
||||
resolved "https://registry.yarnpkg.com/pg-int8/-/pg-int8-1.0.1.tgz#943bd463bf5b71b4170115f80f8efc9a0c0eb78c"
|
||||
integrity sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==
|
||||
|
||||
pg-minify@1.6.2:
|
||||
version "1.6.2"
|
||||
resolved "https://registry.yarnpkg.com/pg-minify/-/pg-minify-1.6.2.tgz#055acfe862cfca3ca0a529020846b0f308d68e70"
|
||||
integrity sha512-1KdmFGGTP6jplJoI8MfvRlfvMiyBivMRP7/ffh4a11RUFJ7kC2J0ZHlipoKiH/1hz+DVgceon9U2qbaHpPeyPg==
|
||||
|
||||
pg-pool@^3.5.2:
|
||||
version "3.5.2"
|
||||
resolved "https://registry.yarnpkg.com/pg-pool/-/pg-pool-3.5.2.tgz#ed1bed1fb8d79f1c6fd5fb1c99e990fbf9ddf178"
|
||||
integrity sha512-His3Fh17Z4eg7oANLob6ZvH8xIVen3phEZh2QuyrIl4dQSDVEabNducv6ysROKpDNPSD+12tONZVWfSgMvDD9w==
|
||||
|
||||
pg-promise@^10.11.1:
|
||||
version "10.15.4"
|
||||
resolved "https://registry.yarnpkg.com/pg-promise/-/pg-promise-10.15.4.tgz#b8b5055489f375a43e5d3edbff1d41ddb3817b2f"
|
||||
integrity sha512-BKlHCMCdNUmF6gagVbehRWSEiVcZzPVltEx14OJExR9Iz9/1R6KETDWLLGv2l6yRqYFnEZZy1VDjRhArzeIGrw==
|
||||
dependencies:
|
||||
assert-options "0.8.0"
|
||||
pg "8.8.0"
|
||||
pg-minify "1.6.2"
|
||||
spex "3.2.0"
|
||||
|
||||
pg-protocol@^1.5.0:
|
||||
version "1.5.0"
|
||||
resolved "https://registry.yarnpkg.com/pg-protocol/-/pg-protocol-1.5.0.tgz#b5dd452257314565e2d54ab3c132adc46565a6a0"
|
||||
integrity sha512-muRttij7H8TqRNu/DxrAJQITO4Ac7RmX3Klyr/9mJEOBeIpgnF8f9jAfRz5d3XwQZl5qBjF9gLsUtMPJE0vezQ==
|
||||
|
||||
pg-to-ts@4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/pg-to-ts/-/pg-to-ts-4.1.0.tgz#54007aff65f920bb127e0e4c39fa530d97e9820f"
|
||||
integrity sha512-MLetxJXYT7dwof8F52U2/Twd5hx7FHzoWqWTnBxENDcSb4flixWbA8vjU2/RaQ1E3rsVQVjx7FOIqukpnfJeAw==
|
||||
dependencies:
|
||||
lodash "^4.17.21"
|
||||
pg-promise "^10.11.1"
|
||||
typescript-formatter "^7.0.1"
|
||||
yargs "^17.3.1"
|
||||
|
||||
pg-types@^2.1.0:
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/pg-types/-/pg-types-2.2.0.tgz#2d0250d636454f7cfa3b6ae0382fdfa8063254a3"
|
||||
@ -5587,7 +5645,7 @@ pg-types@^2.1.0:
|
||||
postgres-date "~1.0.4"
|
||||
postgres-interval "^1.1.0"
|
||||
|
||||
pg@^8.0.3, pg@^8.7.3:
|
||||
pg@8.8.0, pg@^8.0.3, pg@^8.7.3:
|
||||
version "8.8.0"
|
||||
resolved "https://registry.yarnpkg.com/pg/-/pg-8.8.0.tgz#a77f41f9d9ede7009abfca54667c775a240da686"
|
||||
integrity sha512-UXYN0ziKj+AeNNP7VDMwrehpACThH7LUl/p8TDFpEUuSejCUIwGSfxpHsPvtM6/WXFy6SU4E5RG4IJV/TZAGjw==
|
||||
@ -5769,6 +5827,11 @@ ps-tree@^1.2.0:
|
||||
dependencies:
|
||||
event-stream "=3.3.4"
|
||||
|
||||
pseudomap@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"
|
||||
integrity sha512-b/YwNhb8lk1Zz2+bXXpS/LK9OisiZZ1SNsSLxN1x2OXVEhW2Ckr/7mWE5vrC1ZTiJlD9g19jWszTmJsB+oEpFQ==
|
||||
|
||||
psl@^1.1.28:
|
||||
version "1.9.0"
|
||||
resolved "https://registry.yarnpkg.com/psl/-/psl-1.9.0.tgz#d0df2a137f00794565fcaf3b2c00cd09f8d5a5a7"
|
||||
@ -6113,7 +6176,7 @@ safe-regex-test@^1.0.0:
|
||||
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
|
||||
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==
|
||||
|
||||
semver@^5.0.3, semver@^5.3.0:
|
||||
semver@^5.0.3, semver@^5.3.0, semver@^5.6.0:
|
||||
version "5.7.1"
|
||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
|
||||
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
|
||||
@ -6219,6 +6282,11 @@ side-channel@^1.0.4:
|
||||
get-intrinsic "^1.0.2"
|
||||
object-inspect "^1.9.0"
|
||||
|
||||
sigmund@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/sigmund/-/sigmund-1.0.1.tgz#3ff21f198cad2175f9f3b781853fd94d0d19b590"
|
||||
integrity sha512-fCvEXfh6NWpm+YSuY2bpXb/VIihqWA6hLsgboC+0nl71Q7N7o2eaCW8mJa/NLvQhs6jpd3VZV4UiUQlV6+lc8g==
|
||||
|
||||
signal-exit@^3.0.2, signal-exit@^3.0.3, signal-exit@^3.0.7:
|
||||
version "3.0.7"
|
||||
resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.7.tgz#a9a1767f8af84155114eaabd73f99273c8f59ad9"
|
||||
@ -6334,6 +6402,11 @@ spdx-license-ids@^3.0.0:
|
||||
resolved "https://registry.yarnpkg.com/spdx-license-ids/-/spdx-license-ids-3.0.12.tgz#69077835abe2710b65f03969898b6637b505a779"
|
||||
integrity sha512-rr+VVSXtRhO4OHbXUiAF7xW3Bo9DuuF6C5jH+q/x15j2jniycgKbxU09Hr0WqlSLUs4i4ltHGXqTe7VHclYWyA==
|
||||
|
||||
spex@3.2.0:
|
||||
version "3.2.0"
|
||||
resolved "https://registry.yarnpkg.com/spex/-/spex-3.2.0.tgz#fa4a21922407e112624977b445a6d634578a1127"
|
||||
integrity sha512-9srjJM7NaymrpwMHvSmpDeIK5GoRMX/Tq0E8aOlDPS54dDnDUIp30DrP9SphMPEETDLzEM9+4qo+KipmbtPecg==
|
||||
|
||||
split2@^4.1.0:
|
||||
version "4.1.0"
|
||||
resolved "https://registry.yarnpkg.com/split2/-/split2-4.1.0.tgz#101907a24370f85bb782f08adaabe4e281ecf809"
|
||||
@ -6884,6 +6957,14 @@ typedarray@^0.0.6:
|
||||
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
||||
integrity sha512-/aCDEGatGvZ2BIk+HmLf4ifCJFwvKFNb9/JeZPMulfgFracn9QFcAf5GO8B/mweUjSoblS5In0cWhqpfs/5PQA==
|
||||
|
||||
typescript-formatter@^7.0.1:
|
||||
version "7.2.2"
|
||||
resolved "https://registry.yarnpkg.com/typescript-formatter/-/typescript-formatter-7.2.2.tgz#a147181839b7bb09c2377b072f20f6336547c00a"
|
||||
integrity sha512-V7vfI9XArVhriOTYHPzMU2WUnm5IMdu9X/CPxs8mIMGxmTBFpDABlbkBka64PZJ9/xgQeRpK8KzzAG4MPzxBDQ==
|
||||
dependencies:
|
||||
commandpost "^1.0.0"
|
||||
editorconfig "^0.15.0"
|
||||
|
||||
typescript@4.8.4:
|
||||
version "4.8.4"
|
||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
|
||||
@ -7155,6 +7236,11 @@ y18n@^5.0.5:
|
||||
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
|
||||
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
|
||||
|
||||
yallist@^2.1.2:
|
||||
version "2.1.2"
|
||||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-2.1.2.tgz#1c11f9218f076089a47dd512f93c6699a6a81d52"
|
||||
integrity sha512-ncTzHV7NvsQZkYe1DW7cbDLm0YpzHmZF5r/iyP3ZnQtMiJ+pjzisCiMNI+Sj+xQF5pXhSHxSB3uDbsBTzY/c2A==
|
||||
|
||||
yallist@^3.0.2:
|
||||
version "3.1.1"
|
||||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd"
|
||||
|
Loading…
Reference in New Issue
Block a user