202 Commits
1.1.0 ... 1.0.1

Author SHA1 Message Date
58f77a06ea A valid package index page 2022-10-15 18:26:55 +01:00
88c8480911 A valid registration page Index 2022-10-15 18:25:40 +01:00
c147eaf54a by Nuget version 2022-09-27 00:39:43 +01:00
e49db8e1a1 re_Vision 2022-09-26 23:34:13 +01:00
9aac183e2c Merge branch 'broken/ef' 2022-09-26 23:30:58 +01:00
037559a0b7 layout 2022-09-26 23:30:54 +01:00
9c4d45b97c + Revsion 2022-09-26 21:54:22 +01:00
9aa3140a11 WIP 2022-09-25 17:07:56 +01:00
7f9344d437 add a vscode task for ef db update 2022-09-25 16:47:31 +01:00
f46ca00de9 REORG 2022-09-25 02:24:21 +01:00
fcea41f8c1 Catalog++ 2022-09-24 12:32:00 +01:00
58f49af5f0 publish 2022-09-23 22:16:12 +01:00
fececb327e WIP reg page 2022-09-23 20:34:51 +01:00
14206ac477 catalog impl 2022-08-20 17:44:33 +01:00
fa9a12ad49 WIP Page leaf 2022-07-29 09:06:59 +01:00
7f9984b059 WIP page leaf 2022-07-10 17:05:16 +01:00
2dcf1a2806 refacts 2022-07-03 14:50:57 +01:00
a84e1d9750 Corrige la suppression de paquets 2022-06-19 21:40:31 +01:00
97eba2390e https redirection 2022-06-19 14:17:49 +01:00
6c9f29bc56 MEF 2022-06-19 14:17:36 +01:00
2d5438c943 presentation 2022-06-18 15:44:06 +01:00
519a4fbd46 Okey 2022-06-16 17:03:38 +01:00
a11bab759e retour sur la MEF du footer 2022-05-25 19:17:31 +01:00
d7f0a5db36 Footer layout 2022-05-25 09:07:36 +01:00
5d59760a77 version bump 2022-04-24 15:13:12 +01:00
3e09afcbfe Errors to Error std output 2022-04-18 20:59:36 +01:00
8fa4c04367 naming 2022-04-18 20:58:14 +01:00
60e4ca8c54 ex to output 2022-04-17 23:30:48 +01:00
da92b9dbec er 2022-04-17 22:33:06 +01:00
6194e185b9 gitversion tool 2022-04-17 22:30:33 +01:00
5c1a49811a Versioning 2022-04-17 20:36:28 +01:00
328f6f166a deploy 2022-04-17 17:59:15 +01:00
4191513eef Compilation warns 2022-04-17 16:22:40 +01:00
217cc49019 Versionning 2022-04-17 14:48:18 +01:00
a4a1c6e271 WIP NuGet API 3.5.0 2022-04-17 14:10:20 +01:00
c06f518836 fixing url's 2022-04-16 03:55:37 +01:00
edc9628b67 testing config 2022-04-16 03:10:12 +01:00
4bb43877c7 Build test host using given app config file 2022-04-16 02:35:20 +01:00
ce8b7bcdb3 Fixes the 500 2022-04-16 01:30:33 +01:00
67ec19184b reposted a pkg 2022-04-15 23:56:15 +01:00
57609e6ed3 Response status code does not indicate success: 500 (Internal Server Error). 2022-04-15 22:54:05 +01:00
b46e786ace warn-- 2022-04-11 20:36:45 +01:00
423f9c15b3 not working by me. 2022-04-11 20:05:35 +01:00
6d21d7370c test 2022-04-11 19:57:30 +01:00
ee07affbbd ... 2022-04-11 01:48:43 +01:00
cba0720150 sources set-default 2022-04-10 18:07:14 +01:00
a2d91e072f ... 2022-04-09 19:53:41 +01:00
1befc2e053 ... 2022-04-09 19:53:26 +01:00
df55836c58 fixes the isn client update 2021-09-13 23:50:20 +01:00
cd3629a5a0 dark theme, logo, tests 2021-09-13 23:28:56 +01:00
51a08dec9a icon 2021-09-12 22:51:28 +01:00
386eec262d dark theme 2021-09-12 20:45:43 +01:00
45d6c22d1e bad config file path 2021-09-12 17:17:36 +01:00
225c8ef588 bad config file name 2021-09-12 17:14:51 +01:00
290a3047b5 echo settings file path 2021-09-12 17:08:14 +01:00
ec70927830 env is Dev 2021-09-12 17:02:21 +01:00
9f338ca09f testing app settings for ci 2021-09-12 17:00:30 +01:00
cfd63fe68d default source apikey 2021-09-12 16:47:26 +01:00
f33ca22255 uhnit testing from vscode 2021-09-08 01:55:00 +01:00
e6f4349621 reorg 2021-09-05 19:33:39 +01:00
903f5157d2 unleash migrates 2021-09-05 19:24:21 +01:00
066c038e4d web ui 2021-09-05 18:55:38 +01:00
95aae91156 Refactorisation of deletion 2021-09-05 17:10:50 +01:00
6dd76ac1a5 REORG+histo 2021-09-05 15:44:47 +01:00
459f8ea422 nodejs ... 2021-09-04 13:55:06 +01:00
5607c53329 Fixes the base resource 2021-09-04 13:41:00 +01:00
71de903f13 bodies 2021-09-03 03:07:58 +01:00
a92bee32e1 CQ 2021-09-02 23:37:28 +01:00
7a835c5c95 Fixes the versionCommit migration 2021-08-29 22:27:12 +01:00
f918d26273 catalog updated at push 2021-08-29 00:51:43 +01:00
25d545e327 isn as net472 assembly 2021-08-29 00:31:19 +01:00
57feb53e82 Fixe l'Url du paquet dans le catalogue 2021-08-29 00:18:16 +01:00
b7dae240cd Catalog packages 2021-08-29 00:08:34 +01:00
d8bfdc293d catalog index 2021-08-28 21:26:39 +01:00
f6fa7a0ec9 unit tests and pkg version commits 2021-08-28 18:41:47 +01:00
55e407d951 commit version 2021-08-27 21:25:33 +01:00
cdb9a26d2c Catalog 2021-08-23 03:21:08 +01:00
504f431937 refact 2021-08-15 19:09:01 +01:00
7da74b0dfb dep & tags 2021-08-15 16:21:34 +01:00
6520d8e4cc dotnet 2021-08-15 14:09:11 +01:00
55b74a584a msbuild 2021-08-15 14:03:53 +01:00
0ec9889e96 msbuild ci tag 2021-08-15 14:02:29 +01:00
b17ee8be75 Settings 2021-08-15 12:59:31 +01:00
f6f3473346 protect 2021-08-15 05:32:08 +01:00
ae114c68db refacts 2021-08-15 01:50:07 +01:00
5f0dfee768 bug on config 2021-08-13 18:55:25 +01:00
9ee058e1c8 bootstrap upgrade 2021-08-12 01:32:20 +01:00
30d81c06df update git ignore list 2021-08-12 01:06:21 +01:00
3845e2c9c4 serve 2021-08-12 01:04:39 +01:00
74427cc15e better Display 2021-08-12 00:38:16 +01:00
5c188b57fc cleaning 2021-08-12 00:02:40 +01:00
74ffc8e83e Prre release buton 2021-08-12 00:01:11 +01:00
7f0518ec82 Put it better 2021-08-11 23:59:08 +01:00
58750587d0 pkg upd by no db 2021-08-11 23:25:15 +01:00
bd1c47e7c6 throw 2021-08-11 20:57:46 +01:00
f7b375ad50 isnapikey 2021-08-11 20:52:50 +01:00
558d5fc8ae . 2021-08-11 20:45:40 +01:00
fff4599ff4 fixes the put 2021-08-10 00:10:26 +01:00
e356636539 Client installation notes 2021-07-12 03:35:03 +01:00
1aef7ce614 upgrade notes 2021-07-12 03:23:11 +01:00
82cec8eece Api Key view 2021-07-12 02:17:26 +01:00
cd7c0be03d Unleash client instance as singleton 2021-07-11 22:13:48 +01:00
a345992351 isn brand fix 2021-07-11 20:15:50 +01:00
5e74b24439 refact & client install notes 2021-07-11 20:04:12 +01:00
451d810ade using async methods 2021-07-11 19:20:56 +01:00
6f82a0a00f Activer le serveur 2021-07-11 19:14:55 +01:00
48ca2df19e async calls 2021-07-11 18:09:02 +01:00
355b2d4c7c Unleash client init 2021-07-11 18:08:49 +01:00
d33a19d35f installation instructions 2021-07-11 18:07:45 +01:00
5a783edac2 Pipline status 2021-07-05 21:46:18 +01:00
32d25733af ci fix due to refact 2021-07-05 21:30:49 +01:00
709e1433bb isntallation steps 2021-07-05 21:24:37 +01:00
476d35ae8a refact 2021-07-05 12:55:52 +01:00
5de53a3cba rebrand 2021-06-27 01:53:00 +01:00
ae6abc104a resources 2021-06-22 23:03:38 +01:00
eba75d0db4 getversions 2021-06-22 01:25:28 +01:00
aaa49788dc autocomplete 2021-06-22 00:10:01 +01:00
b8809deaa1 search 2021-06-21 23:38:05 +01:00
6fcad7c252 MAJ de la description À l'incrément de version 2021-06-21 01:51:57 +01:00
2c31ffb7c4 ignorer une version existante en base mais pas sur le disque 2021-06-21 01:49:19 +01:00
58501329ac removes auto devops 2021-06-21 00:58:44 +01:00
8c25889e88 not only main 2021-06-20 07:07:54 +01:00
90b8913e98 master => main 2021-06-20 07:01:37 +01:00
c88dccd950 reference some env 2021-06-20 06:41:26 +01:00
963ce8579c Update .gitlab-ci.yml 2021-06-20 05:28:47 +00:00
1c1964eb2c renames the 'deploy' job 2021-06-20 05:19:13 +01:00
a5d6e08945 Merge branch 'set-sast-config-1' into 'master'
Set .gitlab-ci.yml to enable or configure SAST

See merge request Paul/nuget-host!1
2021-06-20 04:09:43 +00:00
21b51d4cbd Set .gitlab-ci.yml to enable or configure SAST 2021-06-20 04:07:59 +00:00
27634c3159 api key settings 2021-06-19 00:41:05 +01:00
a11c30e782 re-ignore already present 2021-06-19 00:31:29 +01:00
5cb35f54d5 ci & admin & auth & cli 2021-06-18 23:57:02 +01:00
981f3209e0 ignore code 1 2021-06-18 21:16:38 +01:00
3fa1241ea2 cleaning 2021-06-18 20:44:20 +01:00
c14adcdd80 try++ 2021-06-16 20:19:08 +01:00
25069e5aa2 try++ 2021-06-16 20:14:53 +01:00
b341fdfa4d trying and fix 401 2021-06-16 20:10:33 +01:00
e88763df09 simplified 2021-06-16 19:39:58 +01:00
c456a28282 re push 2021-06-14 19:59:16 +01:00
f7cfeeba8d add source or true 2021-06-14 00:57:06 +01:00
7752620bef deploy src/**/*.nupkg 2021-06-14 00:53:59 +01:00
4fa03c5a1d link warn & deploy to gitlab 2021-06-14 00:46:09 +01:00
61ba3b2bf8 a valid nuget local repo 2021-05-23 20:21:46 +01:00
1266dd54db nugetd 2021-05-23 01:00:57 +01:00
be30ef3c25 gestion des versions :
* dossier des versions = FullString
* Suppressioni de versions
2021-05-22 22:49:57 +01:00
41fbe54638 minor change 2021-05-20 20:35:11 +01:00
d80271dcbf permissions sur le paquet 2021-05-20 20:24:03 +01:00
3a59b8304a [{"PkgName":"nuget-cli.1.0.0.nupkg","Executed":true,"OK":true,"AlreadyPresent":false,"Message":"{\"versionId\":\"nuget-host, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null\",\"files\":[\"nuget-cli-1.0.0.nupkg\"]}","StatusCode":"OK","StackTrace":null}] 2021-05-18 23:17:48 +01:00
f6a27fa919 don't use redirection 2021-05-18 02:58:52 +01:00
e51da7f359 TODO policy on existing zip from fs 2021-05-18 00:39:03 +01:00
e4511a8aaa owner id 2021-05-16 14:07:14 +01:00
9575dd2754 report.OK 2021-05-16 05:33:05 +01:00
54a900c361 Merge branch 'master' of gitlab.pschneider.fr:Paul/nuget-host 2021-05-16 02:51:20 +01:00
efb004ee08 Fixe l'envoi du fichier 2021-05-16 02:41:36 +01:00
e0a3ec0bd5 Ok 2021-05-16 02:13:58 +01:00
d7cabaad8b using web request 2021-05-16 01:31:12 +01:00
9adad9a327 refact 2021-05-15 18:38:11 +01:00
3d3a6cf017 refact 2021-05-15 18:36:42 +01:00
2f4ff1e774 return to canonical usage 2021-05-15 04:45:54 +01:00
9289b3af91 no more nuget 2021-05-14 21:48:01 +01:00
90cfc29492 cli to msbuild 2021-05-14 03:15:34 +01:00
c83ff84370 Don't merge. 2021-05-14 01:41:52 +01:00
d117f26c77 seeing some PUT 2021-05-14 01:41:16 +01:00
c2f38800aa ... 2021-05-13 23:05:19 +01:00
a8c9b7619f TODO cli output 2021-05-11 23:44:43 +01:00
97dec15153 push 2021-05-11 23:01:11 +01:00
512495d10b ci test 2021-05-11 20:52:39 +01:00
5bbcf9cb29 cli helped 2021-05-11 02:38:52 +01:00
b6098c28a6 refact 2021-05-10 23:03:59 +01:00
36e1137e50 sln 2021-05-10 21:36:08 +01:00
3086cc65c4 clean 2021-05-10 21:32:29 +01:00
4cec5d0229 launch 2021-05-09 18:07:48 +01:00
61dc82df5b artifacts 2021-05-09 16:28:20 +01:00
db6f514fb5 .... 2021-05-09 15:49:52 +01:00
cc675844b6 ... 2021-05-09 15:41:05 +01:00
f95765f541 not user-secret 2021-05-09 15:35:05 +01:00
e5d3ba36cc testing? 2021-05-09 15:33:14 +01:00
ffb7cad00a Réussi! - échec : 0, réussite : 2, ignorée(s) : 0, total : 2, durée : 444 ms 2021-05-09 14:56:32 +01:00
6a59f776d5 refact 2021-05-09 13:45:55 +01:00
93394b3e82 api key unprotected 2021-05-09 03:06:23 +01:00
d063f10da5 c'est pas ici! 2021-05-09 02:02:50 +01:00
bb02706773 apikey.creationdate 2021-05-09 01:52:55 +01:00
915736c4e2 migrate database 2021-05-08 23:51:40 +01:00
b550f05c4f typo 2021-05-08 22:01:37 +01:00
dd4dd9321b ci++ 2021-05-08 21:50:59 +01:00
a238bd8cbf arts2 2021-05-08 21:47:24 +01:00
fb822b6aaf yml 2021-05-08 21:43:28 +01:00
ffd1dca16e artfcts 2021-05-08 21:40:03 +01:00
198189ab09 fixes build 2021-05-08 21:27:22 +01:00
ccbdd155f3 ci 2021-05-08 21:18:43 +01:00
445ea24dd2 ngh 2021-05-08 20:44:40 +01:00
48df937b7f Add .gitlab-ci.yml 2021-05-08 15:02:19 +00:00
10b1fd0748 Add LICENSE 2021-05-08 14:59:27 +00:00
15fa91138d version 2021-05-08 15:36:56 +01:00
dd6d83cf06 ApiKey 2021-05-08 15:27:46 +01:00
749eb645d5 refactorisation de la configuration 2021-05-02 15:22:46 +01:00
838de379fd Removes IdentityServer4 usage 2021-05-01 16:43:57 +01:00
dc37c9a9f0 adds aspnet.identity 2021-04-25 12:12:50 +01:00
a2f26f1e8e base namespace to nuget_host 2021-04-17 14:19:00 +01:00
1b2d850522 refact 2021-04-11 22:39:26 +01:00
ec5bd7ca1f builds 2021-04-11 22:22:37 +01:00
cede04a33e more references. 2021-04-10 14:11:09 +01:00
5b6d74d8ee protecting api 2021-04-08 03:08:20 +01:00
156 changed files with 7059 additions and 4014 deletions

2
.build
View File

@ -18,7 +18,7 @@
<target name="build" description="build all"> <target name="build" description="build all">
<exec program="dotnet" commandline="build" /> <exec program="dotnet" commandline="build" />
</target> </target>
<target name="test" description="test all"> <target name="test" description="build all">
<exec program="dotnet" commandline="test" /> <exec program="dotnet" commandline="test" />
</target> </target>
</project> </project>

5
.gitignore vendored
View File

@ -20,7 +20,4 @@ appsettings.Development.json
/test/data/test-isn/bin/ /test/data/test-isn/bin/
/test/data/test-isn/obj /test/data/test-isn/obj
.fake .fake
/artifacts/ artifacts/
/.vs/
/.vscode/

29
.vs/isn/xs/UserPrefs.xml Normal file
View File

@ -0,0 +1,29 @@
<Properties StartupConfiguration="{9D758F00-17FF-433D-B088-F9C2D97C9BD1}|Default">
<MonoDevelop.Ide.Workbench ActiveDocument="src/isnd/isnd.csproj">
<Files>
<File FileName="src/isn/Program.cs" Line="55" Column="48" />
<File FileName="src/isnd/isnd.csproj" Line="15" Column="56" />
</Files>
<Pads>
<Pad Id="ProjectPad">
<State name="__root__">
<Node name="isn" expanded="True">
<Node name="src" expanded="True">
<Node name="isnd" selected="True" />
</Node>
<Node name="test" expanded="True" />
</Node>
</State>
</Pad>
</Pads>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.ItemProperties.src.isnd PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.DebuggingService.PinnedWatches />
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.ItemProperties.test.isnd.tests PreferredExecutionTarget="MonoDevelop.Default" />
<MonoDevelop.Ide.DebuggingService.Breakpoints>
<BreakpointStore />
</MonoDevelop.Ide.DebuggingService.Breakpoints>
<MultiItemStartupConfigurations />
<MonoDevelop.Ide.ItemProperties.src.isn PreferredExecutionTarget="MonoDevelop.Default" />
</Properties>

48
.vscode/launch.json vendored Normal file
View File

@ -0,0 +1,48 @@
{
// Utilisez IntelliSense pour en savoir plus sur les attributs possibles.
// Pointez pour afficher la description des attributs existants.
// Pour plus d'informations, visitez : https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Attach",
"type": "coreclr",
"request": "attach"
},
{
"name": "push",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/isn/bin/Debug/netcoreapp2.1/isn.dll",
"requireExactSource": false,
"args": [
"push", "/home/paul/Nupkgs/Yavsc.Abstract.1.0.8.nupkg"
],
"cwd": "${workspaceFolder}/src/isn",
"stopAtEntry": false,
"console": "internalConsole"
},
{
"name": "web",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/src/isnd/bin/Debug/netcoreapp2.1/isnd.dll",
"args": [],
"cwd": "${workspaceFolder}/src/isnd",
"stopAtEntry": false,
"requireExactSource": false,
"serverReadyAction": {
"action": "openExternally",
"pattern": "\\bNow listening on:\\s+(https?://\\S+)"
},
"env": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"sourceFileMap": {
"/Views": "${workspaceFolder}/Views"
}
}
]
}

52
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,52 @@
{
"omnisharp.msbuild": true,
"dotnet-test-explorer.testProjectPath": "**/*tests.csproj",
"dotnet-test-explorer.runInParallel": false,
"dotnet-test-explorer.showCodeLens": true,
"dotnet-test-explorer.testArguments": "",
"nxunitExplorer.modules": [
"test/i*/bin/Debug/*/*.tests.dll"
],
"nxunitExplorer.skippattern": "",
"dotnetCoreExplorer.runEnvVars": {
"ASPNETCORE_ENVIRONMENT": "Testing"
},
"dotnetCoreExplorer.searchpatterns": "test/**/bin/**/*.tests.{dll,exe}",
"sqltools.connections": [
{
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"driver": "PostgreSQL",
"name": "isndev",
"group": "isn",
"database": "dotnetmvc",
"username": "dotnetmvc",
"password": "RvJa=y#b/tfg"
},
{
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"askForPassword": true,
"driver": "PostgreSQL",
"name": "isnd",
"group": "isn",
"database": "webid",
"username": "webid"
},
{
"previewLimit": 50,
"server": "localhost",
"port": 5432,
"askForPassword": true,
"driver": "PostgreSQL",
"name": "isnddev",
"group": "isn",
"database": "isnd",
"username": "paul"
}
],
"omnisharp.disableMSBuildDiagnosticWarning": true,
"omnisharp.enableRoslynAnalyzers": false
}

View File

@ -0,0 +1,8 @@
using System;
namespace {{namespace}}
{
public class {{name}}
{
}
}

View File

@ -0,0 +1,3 @@
export class {{name}} {
}

View File

@ -0,0 +1,9 @@
Imports System
Namespace {{namespace}}
Public Class {{name}}
End Class
End Namespace

View File

@ -0,0 +1,3 @@
export default {{name}} {
}

View File

@ -0,0 +1,8 @@
using System;
namespace {{namespace}}
{
public enum {{name}}
{
}
}

View File

@ -0,0 +1,8 @@
using System;
namespace {{namespace}}
{
public interface {{name}}
{
}
}

View File

@ -0,0 +1,3 @@
export interface {{name}} {
}

View File

@ -0,0 +1,46 @@
{
"templates": [
{
"name": "Class",
"extension": "cs",
"file": "./class.cs-template",
"parameters": "./template-parameters.js"
},
{
"name": "Interface",
"extension": "cs",
"file": "./interface.cs-template",
"parameters": "./template-parameters.js"
},
{
"name": "Enum",
"extension": "cs",
"file": "./enum.cs-template",
"parameters": "./template-parameters.js"
},
{
"name": "Class",
"extension": "ts",
"file": "./class.ts-template",
"parameters": "./template-parameters.js"
},
{
"name": "Interface",
"extension": "ts",
"file": "./interface.ts-template",
"parameters": "./template-parameters.js"
},
{
"name": "Default",
"extension": "ts",
"file": "./default.ts-template",
"parameters": "./template-parameters.js"
},
{
"name": "Class",
"extension": "vb",
"file": "./class.vb-template",
"parameters": "./template-parameters.js"
}
]
}

View File

@ -0,0 +1,17 @@
var path = require("path");
module.exports = function(filename, projectPath, folderPath) {
var namespace = "Unknown";
if (projectPath) {
namespace = path.basename(projectPath, path.extname(projectPath));
if (folderPath) {
namespace += "." + folderPath.replace(path.dirname(projectPath), "").substring(1).replace(/[\\\/]/g, ".");
}
namespace = namespace.replace(/[\\\-]/g, "_");
}
return {
namespace: namespace,
name: path.basename(filename, path.extname(filename))
}
};

30
.vscode/tasks.json vendored
View File

@ -11,8 +11,7 @@
"/consoleloggerparameters:NoSummary", "/consoleloggerparameters:NoSummary",
"--ignore-failed-sources" "--ignore-failed-sources"
], ],
"problemMatcher": "$msCompile", "problemMatcher": "$msCompile"
"group": "build"
}, },
{ {
"label": "build", "label": "build",
@ -22,10 +21,10 @@
"build", "build",
"/p:Configuration=Debug", "/p:Configuration=Debug",
"/property:GenerateFullPaths=true", "/property:GenerateFullPaths=true",
"/consoleloggerparameters:NoSummary" "/consoleloggerparameters:NoSummary",
"--ignore-failed-sources"
], ],
"problemMatcher": "$msCompile", "problemMatcher": "$msCompile"
"group": "build"
}, },
{ {
"label": "db-upgrade", "label": "db-upgrade",
@ -42,9 +41,9 @@
"env": { "env": {
"ASPNETCORE_ENV": "Development" "ASPNETCORE_ENV": "Development"
} }
}, }
"dependsOn":["build"],
"group": "test"
}, },
{ {
@ -58,8 +57,7 @@
"/consoleloggerparameters:NoSummary", "/consoleloggerparameters:NoSummary",
"/restore" "/restore"
], ],
"problemMatcher": "$msCompile", "problemMatcher": "$msCompile"
"group": "build"
}, },
{ {
"label": "publish", "label": "publish",
@ -76,8 +74,7 @@
"problemMatcher": "$msCompile", "problemMatcher": "$msCompile",
"options": { "options": {
"cwd": "${workspaceFolder}" "cwd": "${workspaceFolder}"
}, }
"group": "none"
}, },
{ {
"label": "monopublish", "label": "monopublish",
@ -94,8 +91,7 @@
"label": "copyTestConfig", "label": "copyTestConfig",
"command": "dotnet", "command": "dotnet",
"type": "process", "type": "process",
"args": [ "build", "/t:CopyTestConfig" ], "args": [ "build", "/t:CopyTestConfig" ]
"group": "test"
}, },
{ {
"label": "test", "label": "test",
@ -112,8 +108,7 @@
"--logger:xunit" "--logger:xunit"
], ],
"problemMatcher": "$msCompile", "problemMatcher": "$msCompile",
"dependsOn": [ "build", "copyTestConfig"], "dependsOn": [ "build", "copyTestConfig"]
"group": "test"
}, },
{ {
"label": "watch", "label": "watch",
@ -129,8 +124,7 @@
"ASPNETCORE_ENVIRONMENT": "Development" "ASPNETCORE_ENVIRONMENT": "Development"
} }
}, },
"problemMatcher": "$msCompile", "problemMatcher": "$msCompile"
"group": "test"
} }
] ]
} }

View File

@ -1,32 +0,0 @@
CONFIGURATION=Debug
TARGETFV=net7.0
all: build-isn build-isnd
build-%: src/%
dotnet build -p:Configuration=$(CONFIGURATION) $^
pack-%: src/%
dotnet pack $^
watch:
dotnet watch --project=src/isnd
test-push:
isn push src/isn/bin/Debug/isn.*.nupkg
clean-%: src/%
rm -rf $^/bin $^/obj
packs: pack-isn pack-isnd pack-isn.abst
clean: clean-isnd clean-isn clean-isn.abst
server-update:
dotnet build -c Release
dotnet publish -c Release -f net7.0 src/isnd
sudo systemctl stop isnd
sudo cp -a src/isnd/bin/Release/net7.0/publish/* /srv/www/isnd
sudo systemctl start isnd

View File

@ -1,6 +1,6 @@
# ISN # ISN
En cours de developement, le détail du paquet n'est toujours pas fourni en API. [![pipeline status](http://gitlab.pschneider.fr/Paul/nuget-host/badges/main/pipeline.svg)](http://gitlab.pschneider.fr/Paul/nuget-host/-/commits/main)
## Usage ## Usage
@ -18,8 +18,6 @@ wget http://localhost:5000/package/index.json?q=your&prerelease=true&semVerLevel
## Installation ## Installation
### Compilation
Depuis le dossier de la solution, compiler la solution : Depuis le dossier de la solution, compiler la solution :
````bash ````bash
@ -27,31 +25,19 @@ dotnet build /restore -c Release
dotnet publish -c Release dotnet publish -c Release
```` ````
### Déploiement du serveur ### Déploiement
Commençont par la livraison initiale, aujourd'hui :
````bash ````bash
sudo mkdir -p /srv/www/isnd sudo mkdir -p /srv/www/isnd
sudo cp -a src/isnd/bin/Release/net7.0/publish/* /srv/www/isnd sudo cp -a src/isnd/bin/Release/netcoreapp2.1/publish/* /srv/www/isnd
sudo cp contrib/isnd.service /etc/systemd/system sudo cp contrib/isnd /etc/init.d/isnd
sudo chmod +x /etc/init.d/isnd
sudo chown -R www-data.www-data /srv/www/isnd
sudo systemctl daemon-reload sudo systemctl daemon-reload
```` ````
Une base de donées Postgresql est requise, avec, pour faire simple, * Créer une base de donées Postgresql,
son utilisateur, et le droit de créer des tables (ce dernier droit pourrait expirer, mais gare aux mises à jour). * ajuster un fichier de configuration `/srv/www/isnd/appsettings.Production.json`
Il faudra éditer la configuration pour indiquer :
* la connextion à une base de donnée Postresgql, sous la forme :
`"Server=<pgserver>;Port=<pgport>;Database=<dbname>;Username=<dbusername>;Password=<dbpass>;"`
* la connection au serveur de messagerie,
* l'URL du ou des sites à propulser,
* Les autres détails.
Pour faire ceci, vous pourrez éditer une copie du fichier `appsettings.json` vers `appsettings.Production.json`,
pour renseigner toutes les valeurs spécifiées.
* Démarrer le serveur : * Démarrer le serveur :
````bash ````bash
@ -64,11 +50,12 @@ sudo systemctl start isnd
sudo systemctl enable isnd sudo systemctl enable isnd
```` ````
### Installation du client ### Installation du client
````bash ````bash
sudo mkdir /usr/local/lib/isn sudo mkdir /usr/local/lib/isn
sudo cp -a src/isn/bin/Release/net6.0/* /usr/local/lib/isn sudo cp -a src/isn/bin/Release/netcoreapp2.1/* /usr/local/lib/isn
sudo chown -R root.root /usr/local/lib/isn sudo chown -R root.root /usr/local/lib/isn
sudo ln -s /usr/local/lib/isn/isn /usr/local/bin/isn sudo ln -s /usr/local/lib/isn/isn /usr/local/bin/isn
```` ````
@ -78,12 +65,61 @@ sudo ln -s /usr/local/lib/isn/isn /usr/local/bin/isn
````bash ````bash
# compiler tout # compiler tout
dotnet build -c Release dotnet build -c Release
dotnet publish -c Release -f net7.0 src/isnd dotnet publish -c Release -f netcoreapp2.1 src/isnd
# MAJ du serveur # MAJ du serveur
sudo systemctl stop isnd sudo systemctl stop isnd
sudo cp -a src/isnd/bin/Release/net7.0/publish/* /srv/www/isnd sudo cp -a src/isnd/bin/Release/netcoreapp2.1/publish/* /srv/www/isnd
sudo systemctl start isnd sudo systemctl start isnd
# MAJ du client # MAJ du client
sudo cp -a src/isn/bin/Release/net7.0/* /usr/local/lib/isn sudo cp -a src/isn/bin/Release/netcoreapp2.1/* /usr/local/lib/isn
sudo chown -R root.root /usr/local/lib/isn sudo chown -R root.root /usr/local/lib/isn
```` ````
## TODO
```json
{
"@id": "https://api.nuget.org/v3/registration5-semver1/",
"@type": "RegistrationsBaseUrl",
"comment": "Base URL of Azure storage where NuGet package registration info is stored"
},
{
"@id": "https://api.nuget.org/v3-flatcontainer/",
"@type": "PackageBaseAddress/3.0.0",
"comment": "Base URL of where NuGet packages are stored, in the format https://api.nuget.org/v3-flatcontainer/{id-lower}/{version-lower}/{id-lower}.{version-lower}.nupkg"
},
{
"@id": "https://api.nuget.org/v3/registration5-semver1/",
"@type": "RegistrationsBaseUrl/3.0.0-rc",
"comment": "Base URL of Azure storage where NuGet package registration info is stored used by RC clients. This base URL does not include SemVer 2.0.0 packages."
},
{
"@id": "https://api.nuget.org/v3/registration5-semver1/",
"@type": "RegistrationsBaseUrl/3.0.0-beta",
"comment": "Base URL of Azure storage where NuGet package registration info is stored used by Beta clients. This base URL does not include SemVer 2.0.0 packages."
},
{
"@id": "https://www.nuget.org/packages/{id}/{version}?_src=template",
"@type": "PackageDetailsUriTemplate/5.1.0",
"comment": "URI template used by NuGet Client to construct details URL for packages"
},
{
"@id": "https://api.nuget.org/v3/registration5-gz-semver2/",
"@type": "RegistrationsBaseUrl/3.6.0",
"comment": "Base URL of Azure storage where NuGet package registration info is stored in GZIP format. This base URL includes SemVer 2.0.0 packages."
},
````

3
contrib/isn Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
/usr/bin/mono /usr/local/lib/isn/isn.exe $*

110
contrib/isnd Normal file
View File

@ -0,0 +1,110 @@
#!/bin/bash
### BEGIN INIT INFO
# Provides: isnd
# Required-Start: $local_fs $network $named $time $syslog $postgresql
# Required-Stop: $local_fs $network $named $time $syslog $postgresql
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: Script to run asp.net 5 application in background
### END INIT INFO
# Author: Ivan Derevianko aka druss <drussilla7@gmail.com>
# Modified by: Paul Schneider <redienhcs.luap@gmail.com>
. /lib/init/vars.sh
. /lib/lsb/init-functions
NAME=isnd
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
TMP_SAVE_runlevel_VAR=$runlevel
unset runlevel
running() {
if [ -f $PIDFILE ]
then
PID=$(cat $PIDFILE)
if kill -0 $PID 2>/dev/null
then
return 0
fi
fi
return 1
}
export WWW_USER=www-data
export ROOT=/srv/www/${NAME}
export DESC="$NAME"
export PIDFILE=/var/run/kestrel-${NAME}.pid
export LOGDIR=/var/log
export DOTNET_CLI_HOME=$ROOT
export ASPDOTNETCORE_ENVIRONMENT=Production
export ASPDOTNETCORE_LOGLEVEL=Information
status() {
if running;
then
echo "Service running $DESC ($NAME; pid: $PID)"
else
echo "Service stopped $DESC ($NAME)"
fi
echo WWW_USER: $WWW_USER ROOT:$ROOT DESC: $DESC NAME: $NAME PIDFILE: $PIDFILE LOGDIR=$LOGDIR
}
start() {
if running; then
echo "Service already running $DESC" "$NAME"
log_end_msg 0
else
cd $ROOT
log_daemon_msg "Starting service $NAME for user $WWW_USER"
if ! start-stop-daemon -SbmCv -u $WWW_USER -p $PIDFILE -d $ROOT -g www-data -x /usr/bin/dotnet isnd.dll run > "${LOGDIR}/kestrel-${NAME}.log"
then
log_daemon_msg "Could not start $NAME : $?, see ${LOGDIR}/kestrel-${NAME}.log"
log_end_msg 2
else
log_daemon_msg "Service $DESC started ($NAME), logs: ${LOGDIR}/kestrel-${NAME}.log"
log_end_msg 0
fi
fi
}
stop() {
if running
then
log_daemon_msg "Stopping service $NAME"
start-stop-daemon -K -p "$PIDFILE"
log_daemon_msg "$DESC stopped"
log_end_msg 0
else
log_daemon_msg "$DESC Service not running"
log_end_msg 1
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status
;;
*)
echo "Usage: $0 {start|stop|restart}"
esac
export runlevel=$TMP_SAVE_runlevel_VAR

View File

@ -1,28 +0,0 @@
[Unit]
Description=isnd - a Nuget package repository daemon
After=syslog.target
After=network.target
Wants=postgresql.service
After=postgresql.service
[Service]
RestartSec=5s
Type=simple
User=isn
Group=isn
WorkingDirectory=/srv/www/isnd/
# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file
# (manually creating /run/gitea doesn't work, because it would not persist across reboots)
#RuntimeDirectory=gitea
ExecStart=/srv/www/isnd/isnd
Restart=always
Environment=HOME=/srv/www/isnd
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_BIND_SERVICE
[Install]
WantedBy=multi-user.target

13
contrib/upgrade-isn-isnd.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
set -e
# compiler tout
dotnet build -c Release
dotnet publish -c Release -f netcoreapp2.1 src/isnd
# MAJ du serveur
sudo systemctl stop isnd
sudo cp -a src/isnd/bin/Release/netcoreapp2.1/publish/* /srv/www/isnd
sudo systemctl start isnd
# MAJ du client
sudo cp -a src/isn/bin/Release/netcoreapp2.1/* /usr/local/lib/isn
sudo chown -R root.root /usr/local/lib/isn

View File

@ -1,12 +0,0 @@
drop table "AspNetRoleClaims" ;
drop table "AspNetUserRoles" ;
drop table "AspNetRoles" ;
drop table "AspNetUserClaims" ;
drop table "AspNetUserTokens" ;
drop table "PackageVersions" ;
drop table "Packages" ;
drop table "Commits" ;
drop table "ApiKeys" ;
drop table "AspNetUserLogins" ;
drop table "AspNetUsers" ;
drop table "__EFMigrationsHistory" ;

View File

@ -1,11 +0,0 @@
using System.Collections.Generic;
namespace isn
{
public class APIKO
{
public string Context { get; set; }
public Dictionary<string, string[]> Errors { get; set; }
}
}

View File

@ -4,17 +4,18 @@ namespace isnd.Entities
{ {
public static class ApiConfig public static class ApiConfig
{ {
public const string Index = "/index.json"; public const string Publish = "put";
public const string Catalog = "/catalog"; public const string Index = "index";
public const string Package = "/package"; public const string IndexDotJson = Index + ".json";
public const string Search = "/search"; public const string Catalog = "catalog";
public const string AutoComplete = "/autocomplete"; public const string CatalogPage = "catalog-page";
public const string Registration = "/registration"; public const string GetPackage = Constants.PaquetFileEstension;
public const string GetVersion = "version";
public const string Nuspec = "/nuspec"; public const string Search = "search";
public const string Content = "/content"; public const string AutoComplete = "autocomplete";
public const string Nuget = "/nuget"; public const string CatalogLeaf = "catalog-leaf";
public const string Delete = "delete";
public const string Find = "/index/FindPackagesById()"; // /FindPackagesById()?id='isn.abst'&semVerLevel=2.0.0 public const string Registration = "registration";
internal const string GetNuspec = Constants.SpecFileEstension;
} }
} }

View File

@ -1,14 +1,9 @@
using isnd.Data.Catalog;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn.Abstract namespace isn.Abstract
{ {
public class ApiIndexViewModel : Permalink public class ApiIndexViewModel
{ {
public ApiIndexViewModel(string id) : base(id, "ApiIndex")
{
}
[JsonProperty("version")] [JsonProperty("version")]
public string Version { get; set; } public string Version { get; set; }

View File

@ -4,6 +4,6 @@ namespace isn.abst
{ {
public const string PaquetFileEstension = "nupkg"; public const string PaquetFileEstension = "nupkg";
public const string SpecFileEstension = "nuspec"; public const string SpecFileEstension = "nuspec";
public const string ApiVersionPrefix = "/v3"; public const string JsonFileEstension = "json";
} }
} }

View File

@ -1,48 +0,0 @@
using Newtonsoft.Json;
namespace isnd.Data.Catalog
{
public abstract class Permalink
{
public Permalink(string id, string type)
{
Type = type;
this.id = id;
}
public Permalink(string id)
{
Type = GetType().Name;
this.id = id;
}
[JsonProperty("@type")]
public virtual string Type { get; set; }
[JsonProperty("@id")]
public string Id { get => GetId(); }
private readonly string id;
public string GetId() { return id; }
public override bool Equals(object obj)
{
if (obj!=null)
{
if (GetType().IsAssignableFrom(obj.GetType()))
{
var rpobj = (Permalink) obj;
return this.id == rpobj.id;
}
}
return base.Equals(obj);
}
public override int GetHashCode()
{
return id.GetHashCode();
}
}
}

View File

@ -1,15 +1,14 @@
using isnd.Data.Catalog;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isn.Abstract namespace isn.Abstract
{ {
public class Resource : Permalink public class Resource
{ {
public Resource(string id, string typename) : base(id) [JsonProperty("@id")]
{ public string Id {get; set; }
Type = typename;
}
[JsonProperty("@type")]
public string Type {get; set; }
[JsonProperty("comment")] [JsonProperty("comment")]
public string Comment {get; set; } public string Comment {get; set; }

View File

@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<PackageVersion>1.0.1</PackageVersion> <PackageVersion>1.0.1</PackageVersion>
<Version>1.0.7</Version> <Version>1.0.5</Version>
<TargetFrameworks>net7.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<NoWarn>NETSDK1138</NoWarn> <NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>1.0.7.0</AssemblyVersion> <AssemblyVersion>1.0.5.0</AssemblyVersion>
<FileVersion>1.0.7.0</FileVersion> <FileVersion>1.0.5.0</FileVersion>
<InformationalVersion>1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327</InformationalVersion> <InformationalVersion>1.0.5+Branch.main.Sha.14206ac477d0f07566d5e8125dc52cbd7f474ca2</InformationalVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="11.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="11.0.1" />

View File

@ -18,7 +18,6 @@ namespace isn
{ {
} }
public string Protect(string data) public string Protect(string data)
{ {
List<Byte> protd = new List<byte>(); List<Byte> protd = new List<byte>();
@ -32,7 +31,7 @@ namespace isn
public string UnProtect(string data) public string UnProtect(string data)
{ {
if (data==null) return null;
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
List<byte> unps = new List<byte>(); List<byte> unps = new List<byte>();

View File

@ -17,18 +17,13 @@ namespace isn
{ {
var json = File.ReadAllText(cfgSettingIf.FullName); var json = File.ReadAllText(cfgSettingIf.FullName);
settings = JsonConvert.DeserializeObject<Settings>(json); settings = JsonConvert.DeserializeObject<Settings>(json);
if (settings.DefaultSourceKey == null) currentSource = settings.DefaultSource;
{
Settings.DefaultSourceKey = settings.Sources.Keys.FirstOrDefault();
}
CurrentSource = settings.DefaultSourceKey;
} }
} }
static readonly OptionSet storeoptions = new OptionSet { static readonly OptionSet storeoptions = new OptionSet {
{ "s|source=", "use source", val => CurrentSource ??= val }, { "s|source=", "use source", val => currentSource = currentSource ?? val },
{ "h|help", "show this message and exit", h => shouldShowPushHelp = h != null }, { "h|help", "show this message and exit", h => shouldShowPushHelp = h != null },
}; };
private static readonly string _configFileName = private static readonly string _configFileName =
Path.Combine( Path.Combine(
Path.Combine(Environment.GetFolderPath( Path.Combine(Environment.GetFolderPath(
@ -39,14 +34,12 @@ namespace isn
public const string push = "push"; public const string push = "push";
static readonly OptionSet options = new OptionSet { static readonly OptionSet options = new OptionSet {
{ "h|help", "show this message and exit", h => shouldShowHelp = h != null }, { "h|help", "show this message and exit", h => shouldShowHelp = h != null },
{ "v|version", "show soft version info and exit", h => shouldShowVersion = h != null }
}; };
static string apiKey;
static readonly OptionSet pushoptions = new OptionSet { static readonly OptionSet pushoptions = new OptionSet {
{ "k|api-key=", "use api key", val => apiKey = apiKey ?? val }, { "k|api-key=", "use api key", val => apiKey = apiKey ?? val },
{ "s|source=", "use source", val => CurrentSource = CurrentSource ?? val }, { "p|store-api-key", "store used api key (=<true|false>)", val => storApiKey = val != null },
{ "s|source=", "use source", val => currentSource = currentSource ?? val },
{ "h|help", "show this message and exit", h => shouldShowPushHelp = h != null }, { "h|help", "show this message and exit", h => shouldShowPushHelp = h != null },
}; };
static readonly OptionSet sourceoptions = new OptionSet { static readonly OptionSet sourceoptions = new OptionSet {
@ -58,12 +51,17 @@ namespace isn
}; };
private static bool shouldShowHelp; private static bool shouldShowHelp;
private static bool shouldShowVersion;
private static bool shouldShowSourceHelp; private static bool shouldShowSourceHelp;
private static bool shouldShowPushHelp; private static bool shouldShowPushHelp;
private static string apiKey = null;
private static string currentSource = null;
private static int pushKO = 0;
private static bool storApiKey = false;
public static IDataProtector Protector { get; set; } = new DefaultDataProtector();
static Settings settings = null; static Settings settings = null;
public static Settings Settings public static Settings Settings
{ {
get get
@ -71,19 +69,15 @@ namespace isn
if (settings == null) if (settings == null)
LoadConfig(); LoadConfig();
if (settings == null) if (settings == null)
{
settings = new Settings settings = new Settings
{ {
DataProtectionTitle = "isn", DataProtectionTitle = "isn",
Sources = new Dictionary<string, SourceSettings>() Sources = new Dictionary<string, SourceSettings>()
}; };
}
return settings; return settings;
} }
} }
public static string CurrentSource { get => Settings.CurrentSourceKey; set => Settings.CurrentSourceKey = value; }
static int Main(string[] args) static int Main(string[] args)
{ {
var commandSet = new CommandSet("isn"); var commandSet = new CommandSet("isn");
@ -156,7 +150,6 @@ namespace isn
{ {
Run = sargs => Add(sargs) Run = sargs => Add(sargs)
}; };
commandSet.Add(add); commandSet.Add(add);
var pushCmd = new Command(push) var pushCmd = new Command(push)
@ -164,7 +157,6 @@ namespace isn
Run = sargs => Run = sargs =>
{ {
var pargs = pushoptions.Parse(sargs); var pargs = pushoptions.Parse(sargs);
if (args.Count()==0) shouldShowPushHelp=true;
if (shouldShowPushHelp) if (shouldShowPushHelp)
{ {
// output the options // output the options
@ -173,19 +165,17 @@ namespace isn
return; return;
} }
List<PushReport> reports = PushPkg(pargs); List<PushReport> reports = PushPkg(pargs);
Console.WriteLine(JsonConvert.SerializeObject(reports));
pushKO = reports.Count(r => !r.OK && !r.AlreadyPresent);
} }
}; };
var setapikey = new Command("set-api-key")
var setapikey = new Command("store-api-key", "Store this API key")
{ {
Run = sargs => StoreApiKey(sargs) Run = sargs => StoreApiKey(sargs)
}; };
setapikey.Options = pushoptions;
commandSet.Add(setapikey);
commandSet.Add(pushCmd); commandSet.Add(pushCmd);
commandSet.Add(setapikey);
commandSet.Add(srcCmd); commandSet.Add(srcCmd);
commandSet.Add(showCommand); commandSet.Add(showCommand);
@ -212,11 +202,8 @@ namespace isn
return 1; return 1;
} }
if (shouldShowVersion) int runCode = commandSet.Run(args);
{ return (runCode == 0 && pushKO > 0) ? 500 : runCode;
Console.WriteLine("isn version " + GitVersionInformation.AssemblySemFileVer);
}
return commandSet.Run(args);
} }
} }

View File

@ -1,82 +1,19 @@
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using Newtonsoft.Json;
namespace isn namespace isn
{ {
public class SourceSettings public class SourceSettings
{ {
/// <summary>
/// Protected API Key
/// </summary>
/// <value></value>
public string ApiKey { get; set; } public string ApiKey { get; set; }
/// <summary>
/// Key alias
/// </summary>
/// <value></value>
public string Alias { get; set; } public string Alias { get; set; }
public string GetClearApiKey()
{
return Protector.UnProtect(ApiKey);
}
public void SetApiKey(string key)
{
ApiKey = Protector.Protect(key);
}
public static IDataProtector Protector { get; set; } = new DefaultDataProtector();
} }
public class Settings public class Settings
{ {
public string DataProtectionTitle { get; set; } public string DataProtectionTitle {get; set; }
public Dictionary<string, SourceSettings> Sources { get; set; } public Dictionary<string, SourceSettings> Sources { get; set; }
public bool AutoUpdateApiKey { get; set; } = false; public bool AutoUpdateApiKey { get; set; } = false;
public string DefaultSource { get; set; }
private string defSourceKey;
/// <summary>
/// Default source by its alias
/// </summary>
/// <value></value>
public string DefaultSourceKey
{
get => defSourceKey;
set
{
if (!Sources.ContainsKey(value))
{
Sources[value]=new SourceSettings
{
Alias = defSourceKey
};
}
defSourceKey = value;
}
}
string currentSourceKey;
[JsonIgnore, NotMapped]
public string CurrentSourceKey
{
get {
return currentSourceKey;
}
set{
if (!Sources.ContainsKey(value))
throw new InvalidOperationException($"source is invalid ({value})");
currentSourceKey = value;
}
}
} }
} }

View File

@ -17,21 +17,8 @@ namespace isn
// var json = await client.GetStringAsync(new System.Uri(url)); // var json = await client.GetStringAsync(new System.Uri(url));
Task.Run(async ()=> { Task.Run(async ()=> {
try {
var response = await client.GetStringAsync(url); var response = await client.GetStringAsync(url);
result = JsonConvert.DeserializeObject<ApiIndexViewModel>(response); result = JsonConvert.DeserializeObject<ApiIndexViewModel>(response);
} catch (HttpRequestException ex)
{
if (ex.StatusCode==HttpStatusCode.NotFound)
{
Console.Error.WriteLine("Not found ... server's down ?");
}
else
{
Console.Error.WriteLine($"{ex.StatusCode} : {ex.Message}");
}
}
}).Wait(); }).Wait();
return result; return result;

View File

@ -4,7 +4,6 @@ using System.IO;
using System.Net; using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json;
namespace isn namespace isn
{ {
@ -25,19 +24,35 @@ namespace isn
using (var multipartFormDataContent = new MultipartFormDataContent()) using (var multipartFormDataContent = new MultipartFormDataContent())
{ {
/* var values = new[]
{
new KeyValuePair<string, string>("Id", Guid.NewGuid().ToString()),
new KeyValuePair<string, string>("Key", "awesome"),
new KeyValuePair<string, string>("From", "khalid@home.com")
//other values
};foreach (var keyValuePair in values)
{
multipartFormDataContent.Add(new StringContent(keyValuePair.Value),
String.Format("\"{0}\"", keyValuePair.Key));
} */
multipartFormDataContent.Add(new ByteArrayContent(File.ReadAllBytes(fi.FullName)), multipartFormDataContent.Add(new ByteArrayContent(File.ReadAllBytes(fi.FullName)),
'"' + "File" + '"', '"' + "File" + '"',
'"' + fi.Name + '"'); '"' + fi.Name + '"');
var result = await client.PutAsync(uri, multipartFormDataContent); var result = await client.PutAsync(uri, multipartFormDataContent);
if (result.IsSuccessStatusCode) return
new PushReport() { if (result.IsSuccessStatusCode)
KO = JsonConvert.DeserializeObject<APIKO>(await result.Content.ReadAsStringAsync()) {
}; string report = await result.Content.ReadAsStringAsync();
Console.WriteLine(report);
}
else else
return new PushReport() { {
OK = true string ereport = await result.Content.ReadAsStringAsync();
}; Console.WriteLine(ereport);
}
return new PushReport();
} }
} }
} }

View File

@ -0,0 +1,195 @@
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
namespace isn
{
public class UploadFilesToServerUsingWebRequest
{
public void UploadFilesToServer(PushReport report, Uri uri, FileInfo fi,
string apikey)
{
// string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
const int TXLEN = 0x1000;
/// the form-data file upload, properly formatted
string fileheaderTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\";\r\nContent-Type: {2}\r\n\r\n";
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
// "X-NuGet-ApiKey
string boundary = "----------" + DateTime.Now.Ticks.ToString("x");
string fileheader = string.Format(fileheaderTemplate, "file", fi.Name, "application/octet-stream");
byte[] fileheaderbytes = Encoding.ASCII.GetBytes(fileheader);
var boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
var endBoundaryBytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--");
HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create(uri);
httpWebRequest.Method = "PUT";
httpWebRequest.ContentType = "multipart/form-data; boundary=" + boundary;
httpWebRequest.AllowAutoRedirect = false;
httpWebRequest.Headers.Add("X-NuGet-Client-Version", Constants.ClientVersion);
httpWebRequest.Headers.Add("X-NuGet-ApiKey", apikey);
httpWebRequest.ContentLength = boundarybytes.Length +
fileheaderbytes.Length + fi.Length + endBoundaryBytes.Length;
httpWebRequest.BeginGetRequestStream(async (result) =>
{
try
{
HttpWebRequest request = (HttpWebRequest)result.AsyncState;
using (Stream requestStream = request.EndGetRequestStream(result))
{
await WriteToStream(requestStream, boundarybytes, boundarybytes.Length);
await WriteToStream(requestStream, fileheaderbytes, fileheaderbytes.Length);
using (var fss = fi.OpenRead())
{
byte[] buffer = new byte[TXLEN];
var form_bytes_read = fss.Read(buffer, 0, TXLEN);
while (form_bytes_read > 0)
{
await WriteToStream(requestStream, buffer, form_bytes_read);
form_bytes_read = fss.Read(buffer, 0, TXLEN);
}
}
requestStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
requestStream.Close();
}
}
catch (Exception rex)
{
report.Executed = false;
report.StackTrace = rex.StackTrace;
report.Message = rex.Message;
Console.Error.WriteLine("Stack trace:");
Console.Error.WriteLine(rex.StackTrace);
WebResponse eresp = httpWebRequest.GetResponse();
if (!CheckResponse(eresp, report))
throw new Exception("Invalid server response type");
}
}, httpWebRequest);
WebResponse resp = httpWebRequest.GetResponse();
if (!CheckResponse(resp, report)) throw new Exception("Invalid server response type");
if (Program.Settings.AutoUpdateApiKey)
Program.EnsureKeyStored();
}
static bool CheckResponse(WebResponse resp, PushReport report)
{
Stream stream = resp.GetResponseStream();
StreamReader re = new StreamReader(stream);
if (resp is HttpWebResponse)
{
if (resp.ContentType == "text/json")
{
String json = re.ReadToEnd();
report.Message = json;
var hrep = resp as HttpWebResponse;
report.StatusCode = hrep.StatusCode.ToString();
report.OK = hrep.StatusCode == HttpStatusCode.Accepted
|| hrep.StatusCode == HttpStatusCode.OK;
return true;
}
}
return false;
}
/// <summary>
/// Creates HTTP POST request &amp; uploads database to server. Author : Farhan Ghumra
/// </summary>
internal async Task UploadFilesToServerAsync(PushReport report, Uri uri, FileInfo fi,
string apikey)
{
// string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
const int TXLEN = 0x1000;
/// the form-data file upload, properly formatted
string fileheaderTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\";\r\nContent-Type: {2}\r\n\r\n";
ServicePointManager.ServerCertificateValidationCallback = delegate { return true; };
// "X-NuGet-ApiKey
string boundary = "----------" + DateTime.Now.Ticks.ToString("x");
string fileheader = string.Format(fileheaderTemplate, "file", fi.Name, "application/octet-stream");
byte[] fileheaderbytes = Encoding.ASCII.GetBytes(fileheader);
var boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n");
var endBoundaryBytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--");
HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(uri);
httpWebRequest.Method = "PUT";
httpWebRequest.ContentType = "multipart/form-data; boundary=" + boundary;
httpWebRequest.AllowAutoRedirect = false;
httpWebRequest.Headers.Add("X-NuGet-Client-Version", Constants.ClientVersion);
httpWebRequest.Headers.Add("X-NuGet-ApiKey", apikey);
httpWebRequest.ContentLength = boundarybytes.Length +
fileheaderbytes.Length + fi.Length + endBoundaryBytes.Length;
httpWebRequest.BeginGetRequestStream(async (result) =>
{
try
{
HttpWebRequest request = (HttpWebRequest)result.AsyncState;
using (Stream requestStream = request.EndGetRequestStream(result))
{
await WriteToStream(requestStream, boundarybytes, boundarybytes.Length);
await WriteToStream(requestStream, fileheaderbytes, fileheaderbytes.Length);
using (var fss = fi.OpenRead())
{
byte[] buffer = new byte[TXLEN];
var form_bytes_read = fss.Read(buffer, 0, TXLEN);
while (form_bytes_read > 0)
{
await WriteToStream(requestStream, buffer, form_bytes_read);
form_bytes_read = fss.Read(buffer, 0, TXLEN);
}
}
requestStream.Write(endBoundaryBytes, 0, endBoundaryBytes.Length);
requestStream.Close();
}
}
catch (Exception rex)
{
report.Message = rex.Message;
Console.Error.WriteLine(rex.Message);
Console.Error.WriteLine("Stack trace:");
Console.Error.WriteLine(rex.StackTrace);
throw;
}
}, httpWebRequest);
WebResponse resp = await httpWebRequest.GetResponseAsync();
Stream stream = resp.GetResponseStream();
StreamReader re = new StreamReader(stream);
if (resp is HttpWebResponse)
{
String json = await re.ReadToEndAsync();
report.Message = json;
var hrep = resp as HttpWebResponse;
report.StatusCode = hrep.StatusCode.ToString();
report.OK = hrep.StatusCode == HttpStatusCode.Accepted
|| hrep.StatusCode == HttpStatusCode.OK;
}
else throw new Exception("Invalid server response type");
}
/// <summary>
/// Writes byte array to stream. Author : Farhan Ghumra
/// </summary>
private static async Task WriteToStream(Stream s, byte[] bytes, int len)
{
await s.WriteAsync(bytes, 0, len);
}
}
}

View File

@ -10,18 +10,12 @@ namespace isn
{ {
public class PushCommand public class PushCommand
{ {
Settings settings; static public PushReport Run(string pkg, string source)
public PushCommand(Settings settings)
{ {
this.settings = settings; if (source == null) source = Program.Settings.DefaultSource;
} if (source == null) throw new InvalidOperationException("source is null");
string apikey = Program.Protector.UnProtect(Program.Settings.Sources[source].ApiKey);
public PushReport Run(string pkg, string source, string apikey)
{
var resources = SourceHelpers.GetServerResources(source); var resources = SourceHelpers.GetServerResources(source);
if (resources == null) return null;
if (resources.Resources == null) if (resources.Resources == null)
throw new InvalidOperationException("source gave no resource"); throw new InvalidOperationException("source gave no resource");
if (!resources.Resources.Any(res => res.Type == "PackagePublish/2.0.0")) if (!resources.Resources.Any(res => res.Type == "PackagePublish/2.0.0"))
@ -33,14 +27,15 @@ namespace isn
var report = new PushReport var report = new PushReport
{ {
PkgName = fi.Name, PkgName = fi.Name,
Message = "Le fichier n'existe pas : " + fi.FullName Message = "Le fichier n'existe pas"
}; };
return report; return report;
} }
using (var client = new HttpClient()) using (var client = new HttpClient())
try try
{ {
return client.UploadFilesToServer(new Uri(pubRes.Id), fi, settings.Sources[source].GetClearApiKey()); Console.WriteLine("Connecting to "+ pubRes.Id);
return client.UploadFilesToServer(new Uri(pubRes.Id), fi, apikey);
} }
catch (HttpRequestException hrex) catch (HttpRequestException hrex)
{ {

View File

@ -12,15 +12,17 @@ namespace isn
public static List<PushReport> PushPkg(IEnumerable<string> pkgs) public static List<PushReport> PushPkg(IEnumerable<string> pkgs)
{ {
List<PushReport> pushReports = new List<PushReport>(); List<PushReport> pushReports = new List<PushReport>();
var cmd = new PushCommand(Settings);
if (CurrentSource == null) throw new InvalidOperationException("source is null");
foreach (string pkg in pkgs) foreach (string pkg in pkgs)
{ {
var report = cmd.Run(pkg, CurrentSource, apiKey); var report = PushCommand.Run(pkg, currentSource);
pushReports.Add(report); pushReports.Add(report);
} }
if (storApiKey)
{
EnsureKeyStored();
}
return pushReports; return pushReports;
} }

View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
namespace isn
{
partial class Program
{
private static void StoreApiKey(IEnumerable<string> storeArgs)
{
var args = storeoptions.Parse(storeArgs);
if (shouldShowPushHelp)
{
// output the options
Console.Error.WriteLine("Push Options:");
storeoptions.WriteOptionDescriptions(Console.Out);
}
else
{
apiKey = args[0];
EnsureKeyStored();
}
}
public static void EnsureKeyStored()
{
if (currentSource == null)
{
if (Settings.DefaultSource == null)
return;
currentSource = Settings.DefaultSource;
}
if (Settings.Sources.ContainsKey(currentSource))
{
if (apiKey == null)
{
// Une suppression
Settings.Sources.Remove(currentSource);
if (Settings.DefaultSource == currentSource) Settings.DefaultSource = null;
}
else
{
// Une mise À jour
string ptd = Protector.Protect(apiKey);
Settings.Sources[currentSource].ApiKey = ptd;
if (Settings.DefaultSource == null) Settings.DefaultSource = currentSource;
}
}
else if (apiKey != null)
{
// une addition
string ptd = Protector.Protect(apiKey);
Settings.Sources.Add(currentSource, new SourceSettings { ApiKey = ptd });
}
SaveConfig();
}
public static void SaveConfig()
{
FileInfo cfgSettingIf = new FileInfo(_configFileName);
if (!cfgSettingIf.Directory.Exists) cfgSettingIf.Directory.Create();
File.WriteAllText(
cfgSettingIf.FullName,
JsonConvert.SerializeObject(
Settings,
Formatting.Indented
));
}
}
}

View File

@ -13,7 +13,7 @@ namespace isn
Settings.Sources[arg] : Settings.Sources[arg] :
Settings.Sources.Values.FirstOrDefault((s)=> s.Alias == arg) ; Settings.Sources.Values.FirstOrDefault((s)=> s.Alias == arg) ;
if (settings==null) throw new InvalidOperationException(arg); if (settings==null) throw new InvalidOperationException(arg);
Settings.DefaultSourceKey = arg; Settings.DefaultSource = arg;
SaveConfig(); SaveConfig();
} }

View File

@ -1,46 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json;
namespace isn
{
partial class Program
{
private static void StoreApiKey(IEnumerable<string> storeArgs)
{
var args = storeoptions.Parse(storeArgs);
if (args.Count != 1)
{
Console.Error.WriteLine("StoreApiKey command takse one and only one argument, the key.");
shouldShowPushHelp=true;
}
if (shouldShowPushHelp)
{
// output the options
Console.Error.WriteLine("StoreApiKey Options:");
storeoptions.WriteOptionDescriptions(Console.Out);
}
else
{
Settings.Sources[Settings.CurrentSourceKey].SetApiKey(args[0]);
SaveConfig();
}
}
public static void SaveConfig()
{
FileInfo cfgSettingIf = new FileInfo(_configFileName);
if (!cfgSettingIf.Directory.Exists) cfgSettingIf.Directory.Create();
File.WriteAllText(
cfgSettingIf.FullName,
JsonConvert.SerializeObject(
Settings,
Formatting.Indented
));
Console.WriteLine("config saved .");
}
}
}

View File

@ -1,25 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFrameworks>net7.0</TargetFrameworks> <TargetFrameworks>netcoreapp2.1</TargetFrameworks>
<RootNamespace>nuget_cli</RootNamespace> <RootNamespace>nuget_cli</RootNamespace>
<UserSecretsId>45b74c62-05bc-4603-95b4-3e80ae2fdf50</UserSecretsId> <UserSecretsId>45b74c62-05bc-4603-95b4-3e80ae2fdf50</UserSecretsId>
<Version>1.0.7</Version> <Version>1.0.5</Version>
<PackageVersion>1.0.1</PackageVersion> <PackageVersion>1.0.1</PackageVersion>
<IsPackable>true</IsPackable> <IsPackable>true</IsPackable>
<PackageLicenseExpression>WTFPL</PackageLicenseExpression> <PackageLicenseExpression>WTFPL</PackageLicenseExpression>
<IsTool>true</IsTool> <IsTool>true</IsTool>
<NoWarn>NETSDK1138</NoWarn> <NoWarn>NETSDK1138</NoWarn>
<AssemblyVersion>1.0.7.0</AssemblyVersion> <AssemblyVersion>1.0.5.0</AssemblyVersion>
<FileVersion>1.0.7.0</FileVersion> <FileVersion>1.0.5.0</FileVersion>
<InformationalVersion>1.0.7+Branch.main.Sha.3695c1742965d93eba0ad851656cfaa3e44ba327</InformationalVersion> <InformationalVersion>1.0.5+Branch.main.Sha.14206ac477d0f07566d5e8125dc52cbd7f474ca2</InformationalVersion>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="System.Security.Cryptography.Pkcs" Version="7.0.1" />
<PackageReference Include="Mono.Options" Version="5.3.0" /> <PackageReference Include="Mono.Options" Version="5.3.0" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" /> <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="unleash.client" Version="1.6.1" /> <PackageReference Include="unleash.client" Version="1.6.1" />
<PackageReference Include="GitVersion.MsBuild" Version="5.6.10*" /> <Reference Include="System.Net.Http" Version="4.0.0" />
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="../isn.abst/isn.abst.csproj" /> <ProjectReference Include="../isn.abst/isn.abst.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,42 +1,15 @@
using System.Threading.Tasks.Dataflow;
using System.Net; using System.Net;
using System.Text;
using Newtonsoft.Json;
namespace isn namespace isn
{ {
public class PushReport public class PushReport
{ {
public PushReport()
{
}
public string PkgName { get; set; } public string PkgName { get; set; }
public bool Executed { get; set; } public bool Executed { get; internal set; }
public bool OK { get; set; } public bool OK { get; internal set; }
public bool AlreadyPresent { get; set; } public bool AlreadyPresent { get; internal set; }
public string Message { get; set; } public string Message { get; internal set; }
public string StatusCode { get; set; } public string StatusCode { get; internal set; }
public string StackTrace { get; set; } public string StackTrace { get; internal set; }
public APIKO KO { get; set; }
public string ToDoc()
{
StringBuilder sb = new StringBuilder($"= push {PkgName}\n\n");
if (Executed) sb.AppendLine("* Executed");
if (OK) sb.AppendLine("* OK");
if (!string.IsNullOrWhiteSpace(Message))
sb.AppendLine("* Message :" + Message);
if (!string.IsNullOrWhiteSpace(StatusCode))
sb.AppendLine($"* Status Code : ");
if (!string.IsNullOrWhiteSpace(StackTrace))
sb.AppendLine($"* StackTrace : " + StackTrace);
if (KO!=null)
sb.AppendLine($"* KO : " + KO.Context);
return sb.ToString();
}
} }
} }

View File

@ -5,4 +5,6 @@ namespace isnd.Authorization
internal class ValidApiKeyRequirement : IAuthorizationRequirement internal class ValidApiKeyRequirement : IAuthorizationRequirement
{ {
} }
} }

View File

@ -65,7 +65,7 @@ namespace isnd.Controllers
return View(); return View();
} }
ApiKey newKey = new ApiKey { UserId = userid, Name = model.Name, ApiKey newKey = new ApiKey { UserId = userid, Name = model.Name,
CreationDate = DateTimeOffset.Now.ToUniversalTime() }; CreationDate = DateTime.Now };
_ = dbContext.ApiKeys.Add(newKey); _ = dbContext.ApiKeys.Add(newKey);
_ = await dbContext.SaveChangesAsync(); _ = await dbContext.SaveChangesAsync();
return View("Details", new DetailModel { Name = newKey.Name, return View("Details", new DetailModel { Name = newKey.Name,

View File

@ -4,25 +4,23 @@ using Microsoft.Extensions.Logging;
using isnd.Data; using isnd.Data;
using System.Linq; using System.Linq;
using isnd.ViewModels; using isnd.ViewModels;
using Unleash;
using System.Reflection; using System.Reflection;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
namespace isnd.Controllers namespace isnd.Controllers
{ {
/// <summary>
/// Home Controller
/// </summary>
public class HomeController : Controller public class HomeController : Controller
{ {
private readonly ApplicationDbContext _dbContext; private readonly ApplicationDbContext _dbContext;
/// <summary> private readonly IUnleash _unleashĈlient;
/// Home controller ctor
/// </summary>
/// <param name="dbContext"></param>
public HomeController( public HomeController(
ApplicationDbContext dbContext) ApplicationDbContext dbContext,
IUnleash unleashĈlient)
{ {
_dbContext = dbContext; _dbContext = dbContext;
_unleashĈlient = unleashĈlient;
} }
public IActionResult Index() public IActionResult Index()
@ -30,7 +28,9 @@ namespace isnd.Controllers
return View(new HomeIndexViewModel{ return View(new HomeIndexViewModel{
PkgCount = _dbContext.Packages PkgCount = _dbContext.Packages
.Where(p => p.Versions.Count > 0) .Where(p => p.Versions.Count > 0)
.Count()}); .Count(),
UnleashClient = _unleashĈlient
});
} }
public IActionResult About() public IActionResult About()

View File

@ -10,7 +10,7 @@ namespace isnd.Controllers
public class NewUpdateController : Controller public class NewUpdateController : Controller
{ {
[Authorize(Policy = IsndConstants.RequireAdminPolicyName)] [Authorize(Policy = IsndConstants.RequireAdminPolicyName)]
public IActionResult NewRelease(NewReleaseInfo release) public IActionResult NewRelease(NewReleaseInfo version)
{ {
throw new NotImplementedException("web hook"); throw new NotImplementedException("web hook");
} }

View File

@ -1,39 +1,31 @@
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using NuGet.Versioning;
using isnd.Data;
using isnd.Entities;
using Unleash;
using isnd.Services; using isnd.Services;
using isnd.ViewModels;
using System.Threading.Tasks;
using isnd.Interfaces;
using isn.Abstract; using isn.Abstract;
using isn.abst; using isn.abst;
using isnd.Interfaces;
using System.Linq;
using isnd.Entities;
namespace isnd.Controllers namespace isnd.Controllers
{ {
/// <summary> public partial class PackagesController : Controller
/// Api Controller
/// </summary>
public class ApiController : Controller
{ {
private readonly IPackageManager packageManager; [HttpGet(_pkgRootPrefix + ApiConfig.IndexDotJson)]
private readonly Resource[] resources;
/// <summary>
/// Api Controller Constructor
/// </summary>
/// <param name="pm"></param>
public ApiController(IPackageManager pm)
{
packageManager = pm;
resources = packageManager.GetResources().ToArray();
}
/// <summary>
/// API index
/// </summary>
/// <returns></returns>
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Index)]
public IActionResult ApiIndex() public IActionResult ApiIndex()
{ {
return Ok(new ApiIndexViewModel(packageManager.CatalogBaseUrl){ Version = PackageManager.BASE_API_LEVEL, Resources = resources }); return Ok(new ApiIndexViewModel{ Version = PackageManager.BASE_API_LEVEL, Resources = resources });
} }
} }

View File

@ -1,15 +1,14 @@
using isnd.Services; using isnd.Services;
using isnd.Entities; using isnd.Entities;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using isn.abst;
namespace isnd.Controllers namespace isnd.Controllers
{ {
public partial class PackagesController public partial class PackagesController
{ {
// GET /autocomplete?id=isn.protocol&prerelease=true // GET /autocomplete?id=isn.protocol&prerelease=true
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.AutoComplete)] [HttpGet(_pkgRootPrefix + ApiConfig.AutoComplete)]
public IActionResult AutoComplete( public IActionResult AutoComplete(
string id, string id,
string semVerLevel, string semVerLevel,

View File

@ -0,0 +1,73 @@
using System.Linq;
using System.Threading.Tasks;
using isnd.Services;
using isnd.Entities;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using NuGet.Versioning;
namespace isnd.Controllers
{
public partial class PackagesController
{
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
[HttpGet(_pkgRootPrefix + ApiConfig.Catalog)]
public IActionResult CatalogIndex()
{
return Ok(PackageManager.CurrentCatalogIndex);
}
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogPage + "-{id}")]
public IActionResult Index(string id)
{
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
return Ok(PackageManager.CurrentCatalogPages[int.Parse(id)]);
}
[HttpGet(_pkgRootPrefix + "{apiVersion}/" + ApiConfig.Registration + "/{id}/{lower}.json")]
public IActionResult CatalogRegistration(string apiVersion, string id, string lower)
{
if (lower.Equals("index", System.StringComparison.OrdinalIgnoreCase))
{
var query = new Data.Catalog.RegistrationPageIndexQuery
{
Query = id,
Prerelease = true
};
var index = packageManager.GetPackageRegistrationIndex(query);
if (index == null) return NotFound();
// query.TotalHits = result.Items.Select(i=>i.Items.Length).Aggregate((a,b)=>a+b);
return Ok(index);
}
var leaf = packageManager.SearchById(id,lower,null);
if (leaf.Count()==0) return NotFound(new { id, lower });
return Ok(leaf.First());
}
[HttpGet(_pkgRootPrefix + ApiConfig.CatalogLeaf + "/{id}/{version}/{lower}/index.json")]
public IActionResult CatalogLeaf(string id, string pversion, string lower)
{
bool askForindex = lower == null;
var pkgvs = this.packageManager.GetCatalogLeaf(id, pversion, lower).ToArray();
if (pkgvs.Count() == 0) return NotFound();
List<string> types = pkgvs.Select(
v => v.Type ?? "Dependency"
).Distinct().ToList();
if (!types.Contains("PackageDelete"))
types.Add("PackageDetails");
var last = pkgvs.Last();
var pub = last.LatestCommit.CommitTimeStamp;
return Ok(new Data.Packages.Catalog.CatalogLeaf
{
CommitId = last.CommitId,
Id = id,
CommitTimeStamp = pub,
Version = last.FullString,
Published = pub,
RefType = types.ToArray()
});
}
}
}

View File

@ -1,11 +1,19 @@
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Linq; using System.Linq;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.DataProtection; using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options; using Microsoft.Extensions.Options;
using NuGet.Versioning;
using isnd.Data; using isnd.Data;
using isnd.Entities; using isnd.Entities;
using Unleash;
using isnd.Services;
using isnd.ViewModels;
using System.Threading.Tasks;
using isnd.Interfaces; using isnd.Interfaces;
using isn.Abstract; using isn.Abstract;
@ -22,11 +30,14 @@ namespace isnd.Controllers
private readonly IsndSettings isndSettings; private readonly IsndSettings isndSettings;
readonly ApplicationDbContext dbContext; readonly ApplicationDbContext dbContext;
private readonly IPackageManager packageManager; private readonly IPackageManager packageManager;
private readonly IUnleash unleashĈlient;
const string _pkgRootPrefix = "~/";
public PackagesController( public PackagesController(
ILoggerFactory loggerFactory, ILoggerFactory loggerFactory,
IDataProtectionProvider provider, IDataProtectionProvider provider,
IOptions<IsndSettings> isndOptions, IOptions<IsndSettings> isndOptions,
IUnleash unleashĈlient,
ApplicationDbContext dbContext, ApplicationDbContext dbContext,
IPackageManager pm) IPackageManager pm)
{ {
@ -35,7 +46,8 @@ namespace isnd.Controllers
protector = provider.CreateProtector(isndSettings.ProtectionTitle); protector = provider.CreateProtector(isndSettings.ProtectionTitle);
this.dbContext = dbContext; this.dbContext = dbContext;
packageManager = pm; packageManager = pm;
resources = packageManager.GetResources().ToArray(); this.unleashĈlient = unleashĈlient;
resources = packageManager.GetResources(unleashĈlient).ToArray();
} }
} }
} }

View File

@ -5,13 +5,12 @@ using isnd.Entities;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using isnd.Attributes; using isnd.Attributes;
using System.Security.Claims; using System.Security.Claims;
using isn.abst;
namespace isnd.Controllers namespace isnd.Controllers
{ {
public partial class PackagesController public partial class PackagesController
{ {
[HttpDelete("~" + Constants.ApiVersionPrefix + ApiConfig.Package + "/{id}/{lower?}/{type?}")] [HttpDelete(_pkgRootPrefix + ApiConfig.Delete + "/{id}/{lower?}/{type?}")]
public async Task<IActionResult> ApiDelete( public async Task<IActionResult> ApiDelete(
[FromRoute][SafeName][Required] string id, [FromRoute][SafeName][Required] string id,
[FromRoute][SafeName][Required] string lower, [FromRoute][SafeName][Required] string lower,

View File

@ -11,9 +11,7 @@ namespace isnd.Controllers
public partial class PackagesController public partial class PackagesController
{ {
// Web get the paquet // Web get the paquet
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Nuget + "/{id}/{lower}/{idf}-{lowerf}." [HttpGet(_pkgRootPrefix + ApiConfig.GetPackage + "/{id}/{lower}/{idf}-{lowerf}."
+ Constants.PaquetFileEstension)]
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Content + "/{id}/{lower}/{idf}-{lowerf}."
+ Constants.PaquetFileEstension)] + Constants.PaquetFileEstension)]
public IActionResult GetPackage( public IActionResult GetPackage(
[FromRoute][SafeName][Required] string id, [FromRoute][SafeName][Required] string id,
@ -34,7 +32,7 @@ namespace isnd.Controllers
} }
// Web get spec // Web get spec
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Nuspec + "/{id}/{lower}/{idf}-{lowerf}." [HttpGet(_pkgRootPrefix + Constants.SpecFileEstension + "/{id}/{lower}/{idf}-{lowerf}."
+ Constants.SpecFileEstension)] + Constants.SpecFileEstension)]
public IActionResult GetNuspec( public IActionResult GetNuspec(
[FromRoute][SafeName][Required] string id, [FromRoute][SafeName][Required] string id,

View File

@ -7,7 +7,7 @@ namespace isnd.Controllers
{ {
public partial class PackagesController public partial class PackagesController
{ {
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Find)] [HttpGet(_pkgRootPrefix + ApiConfig.GetVersion + "/{id}/{lower}/" + ApiConfig.IndexDotJson)]
public IActionResult GetVersions( public IActionResult GetVersions(
string id, string id,
string lower, string lower,

View File

@ -1,48 +0,0 @@
using System.Data.Common;
using System.Linq;
using System.Threading.Tasks;
using isnd.Services;
using isnd.Entities;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using NuGet.Versioning;
using isnd.Data.Packages.Catalog;
using isnd.Data.Catalog;
using isn.abst;
namespace isnd.Controllers
{
public partial class PackagesController
{
// https://docs.microsoft.com/en-us/nuget/api/catalog-resource#versioning
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Catalog)]
public async Task<IActionResult> CatalogIndex()
{
return Ok(await packageManager.GetCatalogIndexAsync());
}
[HttpGet("~" + Constants.ApiVersionPrefix + ApiConfig.Registration + "/{id}/{version}.json")]
public async Task<IActionResult> CatalogRegistration(string id, string version)
{
if ("index" == version)
{
var query = new Data.Catalog.PackageRegistrationQuery
{
Query = id,
Prerelease = true
};
var index = await packageManager.GetPackageRegistrationIndexAsync(query);
if (index == null) return NotFound();
return Ok(index);
}
// return a Package
var leaf = await packageManager.GetCatalogEntryAsync(id, version, null);
if (null == leaf) return NotFound(new { id, version });
return Ok(leaf);
}
}
}

View File

@ -1,5 +1,3 @@
using Microsoft.VisualBasic.CompilerServices;
using System.Linq.Expressions;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -19,15 +17,14 @@ using isnd.Entities;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using isn.abst; using isn.abst;
using isnd.Data.Packages; using isnd.Data.Packages;
using Microsoft.EntityFrameworkCore;
namespace isnd.Controllers namespace isnd.Controllers
{ {
public partial class PackagesController public partial class PackagesController
{ {
// TODO [Authorize(Policy = IsndConstants.RequireValidApiKey)]
[HttpPut("~" + Constants.ApiVersionPrefix + ApiConfig.Package)] [HttpPut(_pkgRootPrefix + ApiConfig.Publish)]
public async Task<IActionResult> Put() public async Task<IActionResult> Put()
{ {
try try
@ -48,8 +45,9 @@ namespace isnd.Controllers
Commit commit = new Commit Commit commit = new Commit
{ {
Action = PackageAction.PublishPackage, Action = PackageAction.PublishPackage,
TimeStamp = DateTimeOffset.Now.ToUniversalTime() TimeStamp = DateTime.Now
}; };
dbContext.Commits.Add(commit);
foreach (IFormFile file in Request.Form.Files) foreach (IFormFile file in Request.Form.Files)
{ {
@ -105,7 +103,7 @@ namespace isnd.Controllers
Id = pkgid, Id = pkgid,
Description = pkgdesc, Description = pkgdesc,
OwnerId = apikey.UserId, OwnerId = apikey.UserId,
LatestCommit = commit LatestVersion = commit,
}; };
dbContext.Packages.Add(pkg); dbContext.Packages.Add(pkg);
} }
@ -116,23 +114,22 @@ namespace isnd.Controllers
var destdir = new DirectoryInfo(dest.DirectoryName); var destdir = new DirectoryInfo(dest.DirectoryName);
if (dest.Exists) if (dest.Exists)
{ {
logger.LogWarning($"Existant package on disk : '{dest.FullName}'");
// La version existe sur le disque, // La version existe sur le disque,
// mais si elle ne l'est pas en base de donnéés, // mais si elle ne l'est pas en base de donnéés,
// on remplace la version sur disque. // on remplace la version sur disque.
string exFullString = version.ToFullString(); var pkgv = dbContext.PackageVersions.Where(
var pkgv = dbContext.PackageVersions. v => v.PackageId == pkg.Id
Include(v=>v.LatestCommit)
.SingleOrDefault(
v => v.PackageId == pkg.Id && v.FullString == exFullString
); );
if (pkgv!=null && ! pkgv.IsDeleted)
if (pkgv !=null && pkgv.Count()==0)
{ {
string msg = $"existant : {pkg.Id}-{exFullString}"; dest.Delete();
logger.LogWarning("400 : {msg}", msg); }
ModelState.AddModelError("pkgversion", msg); else {
return BadRequest(this.CreateAPIKO("existant")); logger.LogWarning("400 : pkgversion:existant");
} else dest.Delete(); ModelState.AddModelError("pkgversion", "existant" );
return BadRequest(ModelState);
}
} }
{ {
if (!destdir.Exists) destdir.Create(); if (!destdir.Exists) destdir.Create();
@ -179,9 +176,8 @@ namespace isnd.Controllers
dbContext.PackageVersions.Add(pkgver); dbContext.PackageVersions.Add(pkgver);
} }
dbContext.Commits.Add(commit);
await dbContext.SaveChangesAsync(); await dbContext.SaveChangesAsync();
await packageManager.ÛpdateCatalogForAsync(commit); packageManager.ÛpdateCatalogFor(commit);
logger.LogInformation($"new paquet : {spec.Name}"); logger.LogInformation($"new paquet : {spec.Name}");
} }
@ -202,23 +198,23 @@ namespace isnd.Controllers
} }
} }
string nuspecfullpath = Path.Combine(pkgpath, pkgid + "." + Constants.SpecFileEstension); string nuspecfullpath = Path.Combine(pkgpath, pkgid + "." + Constants.SpecFileEstension);
FileInfo nfpi = new(nuspecfullpath); FileInfo nfpi = new FileInfo(nuspecfullpath);
if (nfpi.Exists) if (nfpi.Exists)
nfpi.Delete(); nfpi.Delete();
spec.ExtractToFile(nuspecfullpath); spec.ExtractToFile(nuspecfullpath);
} }
} }
return Ok(); return Ok(ViewData);
} }
catch (Exception ex) catch (Exception ex)
{ {
logger.LogError("PUT exception : " + ex.Message); logger.LogError(ex.Message);
logger.LogError("Stack Trace : " + ex.StackTrace); logger.LogError("Stack Trace: " + ex.StackTrace);
return new ObjectResult(new { ViewData, ex.Message }) return new ObjectResult(new { ViewData, ex.Message })
{ StatusCode = 500 }; { StatusCode = 500 };
} }
} }
} }
} }

View File

@ -0,0 +1,10 @@
using isnd.Data.Catalog;
namespace isnd
{
public class RegistrationPageIndexQueryAndResult
{
public RegistrationPageIndexQuery Query { get; set; }
public RegistrationPageIndex Result { get; set; }
}
}

View File

@ -0,0 +1,27 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using isnd.Entities;
namespace isnd.Controllers
{
public partial class PackagesController
{
// GET {@id}?q={QUERY}&skip={SKIP}&take={TAKE}&prerelease={PRERELEASE}&semVerLevel={SEMVERLEVEL}&packageType={PACKAGETYPE}
[HttpGet(_pkgRootPrefix + ApiConfig.Search)]
public IActionResult Search(
string q,
int skip = 0,
int take = 25,
bool prerelease = false,
string semVerLevel = null,
string packageType = null
)
{
throw new NotImplementedException();
}
}
}

View File

@ -1,7 +1,6 @@
using System;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using isn.abst;
using isnd.Data; using isnd.Data;
using isnd.Data.Catalog; using isnd.Data.Catalog;
using isnd.Helpers; using isnd.Helpers;
@ -16,51 +15,51 @@ namespace isnd.Controllers
public partial class PackagesController public partial class PackagesController
{ {
// Web search // Web search
public async Task<IActionResult> Index(PackageRegistrationQuery model) public async Task<IActionResult> Index(RegistrationPageIndexQuery model)
{ {
var pkgs = await packageManager.SearchPackageAsync(model); return View(new RegistrationPageIndexQueryAndResult{Query = model,
Result = packageManager.GetPackageRegistrationIndex(model)});
return View(new RegistrationPageIndexQueryAndResult
{
Query = model,
Result = pkgs.ToArray()
});
} }
public async Task<IActionResult> Details(PackageDetailViewModel model) public async Task<IActionResult> Details(string pkgid)
{ {
if (model.pkgid == null) if (pkgid == null)
{ {
return NotFound(); return NotFound();
} }
var packageVersion = dbContext.PackageVersions var packageVersion = dbContext.PackageVersions
.Include(p=>p.LatestCommit)
.Include(p => p.Package) .Include(p => p.Package)
.Where(m => m.PackageId == model.pkgid) .Where(m => m.PackageId == pkgid)
.OrderByDescending(p => p) .OrderByDescending(p => p)
; ;
if (packageVersion.Count() == 0) if (packageVersion == null)
{ {
return NotFound(); return NotFound();
} }
bool results = await packageVersion.AnyAsync(); bool results = await packageVersion.AnyAsync();
model.latest = await packageVersion.FirstAsync(); var latest = await packageVersion.FirstAsync();
model.totalHits = packageVersion.Count();
model.data = packageVersion.Take(MAX_PKG_VERSION_LIST).ToArray(); return View("Details", new PackageDetailViewModel
{
latest = latest,
pkgid = pkgid,
totalHits = packageVersion.Count(),
data = packageVersion.Take(MAX_PKG_VERSION_LIST).ToArray()
});
return View("Details", model);
} }
const int MAX_PKG_VERSION_LIST = 50; const int MAX_PKG_VERSION_LIST = 50;
[Authorize, HttpGet] [Authorize]
public async Task<IActionResult> Delete(string pkgid, string version, string pkgtype) public async Task<IActionResult> Delete(string pkgid, string version, string pkgtype)
{ {
if (pkgid == null || version == null) if (pkgid == null || version == null)
{ {
return NotFound(); return NotFound();
} }
// var report = await packageManager.DeletePackageAsync(id, lower, type);
var packageVersion = await dbContext.PackageVersions.Include(p => p.Package) var packageVersion = await dbContext.PackageVersions.Include(p => p.Package)
.FirstOrDefaultAsync(m => m.PackageId == pkgid .FirstOrDefaultAsync(m => m.PackageId == pkgid
@ -72,7 +71,7 @@ namespace isnd.Controllers
} }
// POST: PackageVersion/Delete/5 // POST: PackageVersion/Delete/5
[HttpPost] [HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken] [ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(string PackageId, string FullString, public async Task<IActionResult> DeleteConfirmed(string PackageId, string FullString,
string Type) string Type)

View File

@ -18,7 +18,7 @@ namespace isnd.Data.ApiKeys
public int ValidityPeriodInDays{ get; set; } public int ValidityPeriodInDays{ get; set; }
public DateTimeOffset CreationDate { get; set; } public DateTime CreationDate { get; set; }
public bool IsValid => CreationDate.AddDays(ValidityPeriodInDays) > DateTime.Now; public bool IsValid => CreationDate.AddDays(ValidityPeriodInDays) > DateTime.Now;
} }

View File

@ -1,54 +1,23 @@
using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Identity.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using isnd.Data;
using isnd.Data.ApiKeys; using isnd.Data.ApiKeys;
using isnd.Data.Packages; using isnd.Data.Packages;
namespace isnd.Data namespace isnd.Data
{ {
/// <summary>
/// Application Db Context
/// </summary>
public class ApplicationDbContext : IdentityDbContext<ApplicationUser> public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{ {
/// <summary>
/// db context ctor
/// </summary>
/// <param name="options"></param>
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options)
: base(options) { } : base(options) { }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
_ = builder.Entity<PackageVersion>()
.HasKey( v => new { v.PackageId, v.FullString } );
_ = builder.Entity<PackageVersion>()
.HasOne(v => v.Package).WithMany(p => p.Versions).HasForeignKey(x => x.PackageId);
}
/// <summary>
/// User API keys
/// </summary>
/// <value></value>
public DbSet<ApiKey> ApiKeys { get; set; } public DbSet<ApiKey> ApiKeys { get; set; }
/// <summary>
/// Packages
/// </summary>
/// <value></value>
public DbSet<Package> Packages { get; set; } public DbSet<Package> Packages { get; set; }
/// <summary>
/// Package Versions
/// </summary>
/// <value></value>
public DbSet<PackageVersion> PackageVersions { get; set; } public DbSet<PackageVersion> PackageVersions { get; set; }
/// <summary>
/// Commits
/// </summary>
/// <value></value>
public DbSet<Commit> Commits { get; set; } public DbSet<Commit> Commits { get; set; }
} }
} }

View File

@ -1,62 +1,30 @@
using System.ComponentModel;
using System.Net.Sockets;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json; using Newtonsoft.Json;
using isnd.Data.Packages;
using NuGet.Versioning;
using System.Collections.Generic;
using System;
using isnd.Interfaces;
using NuGet.Protocol.Core.Types;
using NuGet.Protocol;
using NuGet.Packaging;
using NuGet.Packaging.Core;
using System.Threading.Tasks;
namespace isnd.Data.Catalog namespace isnd.Data.Catalog
{ {
public class PackageDetails : Permalink, IObject, IPackageSearchMetadata public class CatalogEntry
{ {
/// <summary> /// <summary>
/// Creates a catalog entry /// The URL to the document used to produce this object
/// </summary> /// </summary>
/// <param name="pkg">package id</param> /// <value></value>
/// <param name="apiBase">api Base</param> [Key][Required,JsonRequired]
/// <param name="uri">package permalink</param> [StringLength(1024)]
/// <returns></returns> [JsonProperty("@id")]
public PackageDetails(PackageVersion pkg, string apiBase, string uri): base(uri) public string Id { get; set; }
{
PackageId = pkg.Package.Id;
Version = pkg.FullString;
Authors = $"{pkg.Package.Owner.FullName} <${pkg.Package.Owner.Email}>";
packageContent = apiBase + pkg.NugetLink;
CommitId = pkg.CommitId;
CommitTimeStamp = pkg.LatestCommit.CommitTimeStamp;
IsListed = !pkg.IsDeleted && pkg.Package.Public;
// TODO Licence Project Urls, Summary, Title, etc ...
}
[JsonProperty("@type")]
public string[] RefType { get; protected set; } = new string[] { "PackageDetails" };
[JsonProperty("commitId")]
public string CommitId { get; set; }
[JsonProperty("commitTimeStamp")]
public DateTimeOffset CommitTimeStamp { get; set; }
/// <summary> /// <summary>
/// Authors /// Authors
/// </summary> /// </summary>
/// <value>string or array of strings</value> /// <value>string or array of strings</value>
[JsonProperty("authors")] public string authors { get; set; }
public string Authors { get; set; }
/// <summary> /// <summary>
/// The dependencies of the package, grouped by target framework /// The dependencies of the package, grouped by target framework
/// </summary> /// </summary>
/// <value>array of objects</value> /// <value>array of objects</value>
public DependencyGroup[] dependencyGroups { get; set; } = Array.Empty<DependencyGroup>(); public DependencyGroup[] dependencyGroups { get; set; }
/// <summary> /// <summary>
/// The deprecation associated with the package /// The deprecation associated with the package
@ -66,97 +34,49 @@ namespace isnd.Data.Catalog
[JsonProperty("description")] [JsonProperty("description")]
public string Description { get; set; } public string Description { get; set; }
public string iconUrl { get; set; }
[JsonProperty("iconUrl")]
public Uri IconUrl { get; set; }
public string language { get; set; }
[JsonProperty("licenseUrl")]
public Uri LicenseUrl { get; set; }
/// <summary>
/// The ID of the package
/// </summary>
/// <value></value>
public string idp { get; set; }
public string licenseUrl { get; set; }
public string licenseExpression { get; set; } public string licenseExpression { get; set; }
/// <summary>
/// Should be considered as listed if absent
/// </summary>
/// <value></value>
public bool listed { get; set; }
public string minClientVersion { get; set; } public string minClientVersion { get; set; }
public string projectUrl { get; set; }
[JsonProperty("projectUrl")] /// <summary>
public Uri ProjectUrl { get; set; } /// A string containing a ISO 8601 timestamp of when the package was published
/// </summary>
/// <value></value>
[JsonProperty("requireLicenseAcceptance")] public string published { get; set; }
public bool RequireLicenseAcceptance { get; set; } public bool requireLicenseAcceptance { get; set; }
public string summary { get; set; }
[JsonProperty("summary")]
public string Summary { get; set; }
/// <summary> /// <summary>
/// The tags /// The tags
/// </summary> /// </summary>
/// <value></value> /// <value></value>
[JsonProperty("tags")] public string tags { get; set; }
public string Tags { get; set; } public string title { get; set; }
[JsonProperty("title")]
public string Title { get; set; }
/// <summary>
/// The security vulnerabilities of the package
/// </summary>
/// <value></value>
public IEnumerable<PackageVulnerabilityMetadata> Vulnerabilities { get; }
public string packageContent { get; set; }
/// <summary>
/// A string containing a ISO 8601 timestamp of when the package was published
/// </summary>
/// <value></value>
[JsonProperty("published")]
public DateTimeOffset? Published { get; set; }
/// <summary> /// <summary>
/// The full version string after normalization /// The full version string after normalization
/// </summary> /// </summary>
/// <value></value> /// <value></value>
[Required,JsonRequired] [Required,JsonRequired]
[JsonProperty("version")] public string version { get; set; } // string yes
public string Version { get; set; } /// <summary>
/// The security vulnerabilities of the package
/// </summary>
/// <value></value>
public Vulnerabilitie[] vulnerabilities { get; set; }
[Required,JsonRequired]
[JsonProperty("id")]
public string PackageId { get; set; }
public IEnumerable<PackageDependencyGroup> DependencySets { get; set; }
= Array.Empty<PackageDependencyGroup>();
public long? DownloadCount { get; set; }
public PackageIdentity Identity{ get; set; }
public Uri ReadmeUrl { get; set; }
public Uri ReportAbuseUrl { get; set; }
public Uri PackageDetailsUrl { get; set; }
public string Owners { get; set; }
[JsonProperty("isListed")]
public bool IsListed { get; set; }
public bool PrefixReserved { get; set; }
public LicenseMetadata LicenseMetadata { get; set; }
public Task<PackageDeprecationMetadata> GetDeprecationMetadataAsync()
{
throw new NotImplementedException();
}
public Task<IEnumerable<VersionInfo>> GetVersionsAsync()
{
throw new NotImplementedException();
}
} }
} }

View File

@ -1,99 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using isnd.Data.Packages;
using Newtonsoft.Json;
using NuGet.Versioning;
namespace isnd.Data.Catalog
{
public class CatalogPage : Permalink
{
private readonly string pkgid;
private readonly List<Package> items;
private readonly string apiBase;
public CatalogPage (string pkgid, string apiBase) : base(apiBase + $"/registration/{pkgid}/index.json")
{
Parent = apiBase + $"/registration/{pkgid}/index.json";
this.items = new List<Package>();
this.pkgid = pkgid;
this.apiBase = apiBase;
}
public CatalogPage(string bid, string pkgid, string apiBase, List<PackageVersion> versions) : this(pkgid, apiBase)
{
AddVersionRange(versions);
}
public string GetPackageId()
{
return pkgid;
}
/// <summary>
/// The array of registration leaves and their associate metadata
/// </summary>
/// <value></value>
[JsonProperty("items")]
public Package[] Items { get => items.ToArray(); }
public void AddVersionRange(IEnumerable<PackageVersion> vitems)
{
if (vitems.Count() == 0) return;
NuGetVersion upper = null;
NuGetVersion lower = null;
PackageVersion latest = null;
if (Lower!=null) lower = new NuGetVersion(Lower);
if (Upper!=null) upper = new NuGetVersion(Upper);
// Assert.True(items.All(p=>p.Id == id));
long commitMax = 0;
foreach (var p in vitems)
{
var pkg = p.ToPackage(apiBase);
if (items.Contains(pkg)) continue;
if (upper == null) upper = p.NugetVersion;
else if ( upper < p.NugetVersion) upper = p.NugetVersion;
if (lower == null) lower = p.NugetVersion;
else if (lower > p.NugetVersion) lower = p.NugetVersion;
if (p.CommitNId > commitMax)
{
latest = p;
}
items.Add(pkg);
}
Upper = upper.ToFullString();
Lower = lower.ToFullString();
}
/// <summary>
/// The highest SemVer 2.0.0 version in the page (inclusive)
/// </summary>
/// <value></value>
[JsonProperty("upper"), JsonRequired]
public string Upper { get; private set; }
/// <summary>
/// The lowest SemVer 2.0.0 version in the page (inclusive)
/// </summary>
/// <value></value>
[JsonProperty("lower"), JsonRequired]
public string Lower { get; private set; }
/// <summary>
/// The URL to the registration index
/// </summary>
/// <value></value>
[JsonProperty("parent")]
public string Parent { get; set; }
[JsonProperty("count")]
public int Count { get => items.Count; }
}
}

View File

@ -1,32 +0,0 @@
using isnd.Data.Packages;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
namespace isnd.Data.Catalog
{
public class PackageRegistration : Permalink
{
public PackageRegistration(string url) : base(url)
{
Items = new List<CatalogPage>();
}
public PackageRegistration(string bid, string apiBase, Packages.Package pkg) : base(bid + $"/{pkg.Id}/index.json")
{
Items = new List<CatalogPage>
{
new CatalogPage(bid, pkg.Id, apiBase, pkg.Versions)
};
}
[JsonProperty("count")]
public int Count { get => Items.Count; }
[JsonProperty("items")]
public List<CatalogPage> Items { get; set; }
}
}

View File

@ -1,7 +1,5 @@
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using isnd.Entities;
using Newtonsoft.Json; using Newtonsoft.Json;
using isn.abst;
namespace isnd.Data.Catalog namespace isnd.Data.Catalog
{ {
@ -9,30 +7,20 @@ namespace isnd.Data.Catalog
/// Hosts a catalog entry, /// Hosts a catalog entry,
/// the atomic content reference /// the atomic content reference
/// </summary> /// </summary>
public class Package public class RegistrationLeaf
{ {
public Package(string apiBase, string pkgId, string fullVersionString, PackageDetails entry)
{
this.registration = apiBase + ApiConfig.Registration + "/" + pkgId + "/" + fullVersionString + ".json";
Id = registration;
this.PackageContent = apiBase + ApiConfig.Nuget + "/" + pkgId + "/" + fullVersionString
+ "/" + pkgId + "-" + fullVersionString + "." + Constants.PaquetFileEstension;
Entry = entry;
}
/* /*
@id string yes @id string yes
catalogEntry object yes catalogEntry object yes
packageContent string yes packageContent string yes
*/ */
[JsonProperty("@id")]
[Key][Required]
[StringLength(1024)]
/// <summary> /// <summary>
/// The URL to the registration leaf /// The URL to the registration leaf
/// </summary> /// </summary>
/// <value></value> /// <value></value>
[JsonProperty("@id")]
[Key][Required]
[StringLength(1024)]
public string Id { get; set; } public string Id { get; set; }
/// <summary> /// <summary>
@ -40,7 +28,7 @@ namespace isnd.Data.Catalog
/// </summary> /// </summary>
/// <value></value> /// <value></value>
[JsonProperty("catalogEntry")] [JsonProperty("catalogEntry")]
public PackageDetails Entry { get; set; } public CatalogEntry Entry { get; set; }
/// <summary> /// <summary>
/// The URL to the package content (.nupkg) /// The URL to the package content (.nupkg)
@ -48,7 +36,5 @@ namespace isnd.Data.Catalog
/// <value></value> /// <value></value>
[JsonProperty("packageContent")] [JsonProperty("packageContent")]
public string PackageContent { get; set; } public string PackageContent { get; set; }
public string registration { get; set; }
} }
} }

View File

@ -0,0 +1,101 @@
using System;
using System.Collections.Generic;
using System.Linq;
using isnd.Data.Packages;
using Newtonsoft.Json;
using NuGet.Versioning;
namespace isnd.Data.Catalog
{
public class RegistrationPage
{
[JsonProperty("@id")]
[JsonRequired]
public string Id { get; protected set;}
private List<PackageVersion> items;
protected string Bid { get ; private set; }
public string DlBase { get; }
public RegistrationPage (string bid, string dlBase)
{
Bid = bid;
DlBase = dlBase;
this.items = new List<PackageVersion>();
}
public RegistrationPage (string bid, string pkgid, string dlBase, IEnumerable<PackageVersion> items)
{
Bid = bid;
Parent = Bid + "/index.json";
DlBase = dlBase;
this.items = new List<PackageVersion>(items);
SetPackageId(pkgid);
UpdateCompact();
}
protected void SetPackageId(string pkgid)
{
this.Id = Bid + "/" + pkgid + "/index.json";
}
private void UpdateCompact()
{
NuGetVersion upper = new NuGetVersion(0,0,0);
// Assert.True(items.All(p=>p.Id == id));
foreach (var p in items)
{
if (upper < p.NugetVersion) upper = p.NugetVersion;
}
Upper = upper.ToFullString();
NuGetVersion lower = upper;
foreach (var p in items)
{
if (lower > p.NugetVersion) lower = p.NugetVersion;
}
Lower = lower.ToFullString();
}
/// <summary>
/// no The array of registration leaves and their associate metadata
/// </summary>
/// <value></value>
[JsonProperty("items")]
public RegistrationLeaf[] Items { get => items.Select((p) => p.ToLeave(Bid, DlBase)).ToArray(); }
public void AddVersionRange(IEnumerable<PackageVersion> vitems)
{
if (vitems.Count() == 0) return;
items.AddRange(vitems);
UpdateCompact();
}
/// <summary>
/// The highest SemVer 2.0.0 version in the page (inclusive)
/// </summary>
/// <value></value>
[JsonProperty("upper"), JsonRequired]
public string Upper { get; private set; }
/// <summary>
/// The lowest SemVer 2.0.0 version in the page (inclusive)
/// </summary>
/// <value></value>
[JsonProperty("lower"), JsonRequired]
public string Lower { get; private set; }
/// <summary>
/// The URL to the registration index
/// </summary>
/// <value></value>
[JsonProperty("parent")]
public string Parent { get; set; }
[JsonProperty("count")]
public int Count { get; internal set; }
public string CommitId { get; internal set; }
public DateTime CommitTimeStamp { get; internal set; }
}
}

View File

@ -0,0 +1,43 @@
using isnd.Data.Packages;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
namespace isnd.Data.Catalog
{
public class RegistrationPageIndex
{
/// <summary>
/// Page Url
/// </summary>
/// <value></value>
[JsonProperty("@id")]
public string Id { get; protected set; }
public RegistrationPageIndex(string bid, string id)
{
Id = bid + "/" + id + "/index.json";
Items = new List<RegistrationPage>();
}
public RegistrationPageIndex(string bid, string id, string dlBase, IEnumerable<Package> pkgs) : this(bid, id)
{
// leaves;
this.Items = new List<RegistrationPage>
(pkgs.GroupBy(l => l.Id)
.Select(lg => new RegistrationPage
(bid, lg.Key, dlBase, lg.ToArray()
.Select(p => p.Versions).Aggregate
((l, m) => { l.AddRange(m); return l.ToList(); })
)));
}
[JsonProperty("count")]
public int Count { get => Items?.Count ?? 0; }
[JsonProperty("items")]
public List<RegistrationPage> Items { get; set; }
public string CommitId { get; set; }
}
}

View File

@ -4,9 +4,10 @@ using Newtonsoft.Json;
namespace isnd.Data.Catalog namespace isnd.Data.Catalog
{ {
public class PackageRegistrationQuery public class RegistrationPageIndexQuery
{ {
public PackageRegistrationQuery()
public RegistrationPageIndexQuery()
{ {
} }
@ -21,5 +22,7 @@ namespace isnd.Data.Catalog
[JsonProperty("take")] [JsonProperty("take")]
public int Take { get; set; } = 25; public int Take { get; set; } = 25;
[JsonProperty("totalHits")]
public int TotalHits { get; set; }
} }
} }

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using isnd.Interfaces;
using Newtonsoft.Json;
namespace isnd.Data.Packages.Catalog
{
public class CatalogLeaf : IObject
{
[JsonProperty("@type")]
public string[] RefType { get; set; }
[JsonProperty("commitId")]
public string CommitId { get; set; }
[JsonProperty("commitTimeStamp")]
public DateTime CommitTimeStamp { get; set; }
[JsonProperty("published")]
public DateTime Published { get; set; }
[JsonProperty("id")]
public string Id { get; set; }
[JsonProperty("version")]
public string Version { get; set; }
}
}

View File

@ -4,15 +4,11 @@ using Newtonsoft.Json;
namespace isnd.Interfaces namespace isnd.Interfaces
{ {
public interface IObject public interface IObject
{ {
[JsonProperty("@type")]
public string Type { get => GetType().Name; }
[JsonProperty("commitId")] [JsonProperty("commitId")]
string CommitId { get; } string CommitId { get; }
[JsonProperty("commitTimeStamp")] [JsonProperty("commitTimeStamp")]
DateTimeOffset CommitTimeStamp { get; } DateTime CommitTimeStamp { get; }
} }
} }

View File

@ -0,0 +1,7 @@
namespace isnd.Data.Packages.Catalog
{
public class PackageDetail : CatalogLeaf
{
}
}

View File

@ -1,12 +0,0 @@
using System;
using isnd.Interfaces;
namespace isnd.Data.Packages.Catalog
{
public class PackageEntry : IObject
{
public string CommitId => throw new NotImplementedException();
public DateTimeOffset CommitTimeStamp => throw new NotImplementedException();
}
}

View File

@ -10,9 +10,10 @@ namespace isnd.Data.Packages.Catalog
/// for availability, or deletion, /// for availability, or deletion,
/// ///
/// </summary> /// </summary>
public class PackageDetails : IObject public class PackageRef : IObject
{ {
[JsonProperty("@id")] [JsonProperty("@id")]
public string RefId { get; set; } public string RefId { get; set; }
@ -46,7 +47,6 @@ namespace isnd.Data.Packages.Catalog
public virtual Commit LastCommit { get; set; } public virtual Commit LastCommit { get; set; }
[JsonProperty("commitTimeStamp")] [JsonProperty("commitTimeStamp")]
public DateTimeOffset CommitTimeStamp { get; set; } public DateTime CommitTimeStamp { get; set; }
} }
} }

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using isnd.Interfaces;
using Newtonsoft.Json;
namespace isnd.Data.Packages.Catalog
{
public class Page : IObject
{
[JsonProperty("@id")]
public string Id { get; set; }
[JsonProperty("parent")]
public string Parent { get; set; }
[JsonProperty("items")]
public virtual List<PackageRef> Items { get; set; }
public string CommitId { get; set; }
public DateTime CommitTimeStamp { get; set; }
}
}

View File

@ -21,7 +21,7 @@ namespace isnd.Data.Packages
public long Id { get; set; } public long Id { get; set; }
[Required][JsonIgnore] [Required][JsonIgnore]
public DateTimeOffset TimeStamp{ get; set; } public DateTime TimeStamp{ get; set; }
[Required] [Required]
public PackageAction Action { get; set; } public PackageAction Action { get; set; }
@ -30,7 +30,7 @@ namespace isnd.Data.Packages
public string CommitId { get => Id.ToString(); } public string CommitId { get => Id.ToString(); }
[NotMapped] [NotMapped]
public DateTimeOffset CommitTimeStamp { get => TimeStamp; } public DateTime CommitTimeStamp { get => TimeStamp; }
[ForeignKey("CommitNId")] [ForeignKey("CommitNId")]

View File

@ -2,29 +2,16 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using isnd.Data.Catalog;
using isnd.Interfaces; using isnd.Interfaces;
using Newtonsoft.Json; using Newtonsoft.Json;
namespace isnd.Data.Packages namespace isnd.Data.Packages
{ {
public interface IPackage public class Package : IObject
{ {
string Id { get; set; } [Key][Required]
string OwnerId { get; set; }
string Description { get; set; }
bool Public { get; set; }
ApplicationUser Owner { get; set; }
List<PackageVersion> Versions { get; set; }
long CommitNId { get; set; }
string CommitId { get; }
Commit LatestCommit { get; set; }
DateTimeOffset CommitTimeStamp { get; set; }
}
public class Package
{
[Key]
[Required]
[StringLength(1024)] [StringLength(1024)]
public string Id { get; set; } public string Id { get; set; }
@ -35,7 +22,7 @@ namespace isnd.Data.Packages
[StringLength(1024)] [StringLength(1024)]
public string Description { get; set; } public string Description { get; set; }
public bool Public { get; set; } public bool Public { get ; set;}
[JsonIgnore] [JsonIgnore]
virtual public ApplicationUser Owner { get; set; } virtual public ApplicationUser Owner { get; set; }
@ -49,17 +36,38 @@ namespace isnd.Data.Packages
/// or even deletion when no more active version. /// or even deletion when no more active version.
/// </summary> /// </summary>
/// <value></value> /// <value></value>
[Required] [Required][JsonIgnore]
[JsonIgnore] public long CommitNId { get; set ; }
[ForeignKey("LatestCommit")]
public long CommitNId { get; set; }
[NotMapped] [NotMapped]
public string CommitId { get => CommitNId.ToString(); } public string CommitId { get => CommitNId.ToString(); }
public virtual Commit LatestCommit { get; set; } [ForeignKey("CommitNId")]
public virtual Commit LatestVersion{ get; set; }
public DateTime CommitTimeStamp { get; set; }
/// <summary>
/// Returns the leaf
/// </summary>
/// <param name="bid">base url tu use for building the id property</param>
/// <returns></returns>
public RegistrationLeaf ToLeave(string bid)
{
if (Versions.Count == 0) throw new Exception("NO VERSION");
var v = Versions.OrderBy(w => w.NugetVersion).First();
RegistrationLeaf leave = new RegistrationLeaf
{
Id = bid + Id + "/" + v.FullString + ".json",
PackageContent = v.NugetLink,
Entry = new CatalogEntry
{
Id = bid + Id + ".json",
idp = Id,
version = v.FullString,
authors = $"{Owner.FullName} <${Owner.Email}>"
}
};
return leave;
}
} }
} }

View File

@ -1,4 +1,3 @@
using System.Security.Principal;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
@ -6,14 +5,11 @@ using isn.abst;
using isnd.Data.Catalog; using isnd.Data.Catalog;
using isnd.Data.Packages; using isnd.Data.Packages;
using isnd.Data.Packages.Catalog; using isnd.Data.Packages.Catalog;
using isnd.Entities;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json; using Newtonsoft.Json;
using NuGet.Versioning; using NuGet.Versioning;
namespace isnd.Data namespace isnd.Data
{ {
[PrimaryKey("PackageId", "FullString")]
public class PackageVersion public class PackageVersion
{ {
[Required] [Required]
@ -24,10 +20,10 @@ namespace isnd.Data
[Required] [Required]
public int Major { get; set; } public int Major { get; set; }
[Required] [Required]
public int Minor { get; set; } public int Minor { get; set; }
[Required] [Required]
public int Patch { get; set; } public int Patch { get; set; }
@ -39,7 +35,7 @@ namespace isnd.Data
/// </summary> /// </summary>
/// <value></value> /// <value></value>
[StringLength(256)] [StringLength(256)]
[Required] [Required][Key]
public string FullString { get; set; } public string FullString { get; set; }
public bool IsPrerelease { get; set; } public bool IsPrerelease { get; set; }
@ -47,10 +43,9 @@ namespace isnd.Data
public string Type { get; set; } public string Type { get; set; }
[JsonIgnore] [JsonIgnore]
public virtual Packages.Package Package { get; set; } public virtual Package Package { get; set; }
[Required] [Required][JsonIgnore]
[JsonIgnore]
[ForeignKey("LatestCommit")] [ForeignKey("LatestCommit")]
public long CommitNId { get; set; } public long CommitNId { get; set; }
@ -58,20 +53,31 @@ namespace isnd.Data
public string CommitId { get => CommitNId.ToString(); } public string CommitId { get => CommitNId.ToString(); }
public virtual Commit LatestCommit { get; set; } public virtual Commit LatestCommit {get; set; }
public string NugetLink => $"{ApiConfig.Nuget}/{PackageId}/{FullString}/{PackageId}-{FullString}." public string NugetLink => $"{Constants.PaquetFileEstension}/{PackageId}/{FullString}/{PackageId}-{FullString}."
+ Constants.PaquetFileEstension; + Constants.PaquetFileEstension;
public string NuspecLink => $"{ApiConfig.Nuspec}/{PackageId}/{FullString}/{PackageId}-{FullString}." public string NuspecLink => $"{Constants.SpecFileEstension}/{PackageId}/{FullString}/{PackageId}-{FullString}."
+ Constants.SpecFileEstension; + Constants.SpecFileEstension;
public string SementicVersionString { get => $"{Major}.{Minor}.{Patch}"; } public string SementicVersionString { get => $"{Major}.{Minor}.{Patch}"; }
public NuGetVersion NugetVersion { get => new NuGetVersion(FullString); } public NuGetVersion NugetVersion { get => new NuGetVersion(FullString); }
public Catalog.Package ToPackage(string apiBase) public RegistrationLeaf ToLeave(string bid, string dlbase)
{ {
return new Catalog.Package(apiBase, this.PackageId , FullString, string leaveid = bid + "/" + this.PackageId + "/" + FullString + ".json";
new Catalog.PackageDetails(this, apiBase, apiBase + ApiConfig.Registration + "/" + this.PackageId + "/" + FullString + ".json")); return new RegistrationLeaf
{
Id = leaveid,
PackageContent = dlbase + NugetLink,
Entry = new CatalogEntry
{
Id = leaveid,
idp = PackageId,
version = FullString,
authors = $"{this.Package.Owner.FullName} <${Package.Owner.Email}>"
}
};
} }
public bool IsDeleted => LatestCommit.Action == PackageAction.DeletePackage;
} }
} }

View File

@ -0,0 +1,8 @@
namespace isnd.Entities
{
public class UnleashClientSettings
{
public string ClientApiKey { get; set; }
public string ApiUrl { get; set; }
}
}

View File

@ -1,23 +0,0 @@
using System.Collections.Generic;
using System.Linq;
using isn;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ModelBinding;
namespace isnd.Helpers
{
public static class ApiHelpers
{
static public APIKO CreateAPIKO(this Controller controller, string context)
{
Dictionary<string,string[]> errors = new();
foreach (var elt in controller.ModelState)
{
errors[elt.Key] = elt.Value.Errors.Select( e => e.ErrorMessage).ToArray();
}
return new APIKO{ Context = context, Errors = errors };
}
}
}

View File

@ -1,17 +1,32 @@
namespace isnd.Helpers namespace isnd.Helpers
{ {
/// <summary>
/// Package Id Helpers
/// </summary>
public static class PackageIdHelpers public static class PackageIdHelpers
{ {
internal static bool SeparatedByMinusMatch(string id, string q) internal static bool SeparatedByMinusMatch(string id, string q)
{ {
foreach (var part in id.Split('-')) foreach (var part in id.Split('-'))
{ {
if (part.Equals(q, System.StringComparison.InvariantCultureIgnoreCase)) return true; if (part.Equals(q, System.StringComparison.OrdinalIgnoreCase)) return true;
} }
return false; return false;
} }
internal static bool CamelCaseMatch(string id, string query)
{
// Assert.False (q==null);
if (string.IsNullOrEmpty(query)) return true;
while (id.Length > 0)
{
int i = 0;
while (id.Length > i && char.IsLower(id[i])) i++;
if (i == 0) break;
id = id.Substring(i);
if (id.Equals(query, System.StringComparison.OrdinalIgnoreCase)) return true;
}
return false;
}
} }
} }

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using isnd.Entities;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
using Unleash;
using Unleash.ClientFactory;
namespace isnd.Helpers
{
public static class UnleashHelpers
{
public static IUnleash CreateUnleahClient(this IHostingEnvironment env,
UnleashClientSettings unleashClientSettings)
{
var unleashSettings = new UnleashSettings
{
UnleashApi = new Uri(unleashClientSettings.ApiUrl),
AppName = "isnd",
Environment = env.EnvironmentName,
CustomHttpHeaders = new Dictionary<string, string>
{
{ "Authorization", unleashClientSettings.ClientApiKey }
}
};
UnleashClientFactory unleashClientFactory = new UnleashClientFactory();
return unleashClientFactory.CreateClient(unleashSettings);
}
}
}

View File

@ -1,12 +1,15 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using isn.Abstract; using isn.Abstract;
using isnd.Controllers;
using isnd.Data; using isnd.Data;
using isnd.Data.Catalog; using isnd.Data.Catalog;
using isnd.Data.Packages; using isnd.Data.Packages;
using isnd.Data.Packages.Catalog;
using isnd.Services; using isnd.Services;
using isnd.ViewModels; using isnd.ViewModels;
using NuGet.Versioning; using NuGet.Versioning;
using Unleash;
namespace isnd.Interfaces namespace isnd.Interfaces
{ {
@ -16,18 +19,16 @@ namespace isnd.Interfaces
AutoCompleteResult AutoComplete(string pkgid, int skip, int take, bool prerelease = false, string packageType = null); AutoCompleteResult AutoComplete(string pkgid, int skip, int take, bool prerelease = false, string packageType = null);
string[] GetVersions(string pkgid, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25); string[] GetVersions(string pkgid, NuGetVersion parsedVersion, bool prerelease = false, string packageType = null, int skip = 0, int take = 25);
IEnumerable<Resource> GetResources(); IEnumerable<Resource> GetResources(IUnleash unleashĈlient);
Task<PackageRegistration> ÛpdateCatalogForAsync(Commit commit); void ÛpdateCatalogFor(Commit commit);
Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type); Task<PackageDeletionReport> DeletePackageAsync(string pkgid, string version, string type);
Task<PackageDeletionReport> UserAskForPackageDeletionAsync(string userid, string pkgId, string lower, string type); Task<PackageDeletionReport> UserAskForPackageDeletionAsync(string userid, string pkgId, string lower, string type);
Task<PackageVersion> GetPackageAsync(string pkgid, string version, string type); Task<PackageVersion> GetPackageAsync(string pkgid, string version, string type);
Task<Data.Catalog.Package> GetCatalogEntryAsync(string pkgId, string version, string pkgType); IEnumerable<PackageVersion> GetCatalogLeaf(string pkgId, string semver, string pkgType);
IEnumerable<Data.Catalog.Package> SearchCatalogEntriesById(string pkgId, string semver, string pkgType, bool preRelease); IEnumerable<RegistrationLeaf> SearchById(string pkgId, string semver, string pkgType);
Task<PackageRegistration> GetCatalogIndexAsync(); RegistrationPageIndex GetCatalogIndex();
Task<PackageRegistration> GetPackageRegistrationIndexAsync(PackageRegistrationQuery query); RegistrationPageIndex GetPackageRegistrationIndex(RegistrationPageIndexQuery query);
Task<IEnumerable<PackageRegistration>> SearchPackageAsync(PackageRegistrationQuery query);
} }
} }

View File

@ -0,0 +1,230 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isnd.Data;
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210424155323_init")]
partial class init
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,219 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace isndhost.Migrations
{
public partial class init : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AspNetRoles",
columns: table => new
{
Id = table.Column<string>(nullable: false),
Name = table.Column<string>(maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(maxLength: 256, nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetUsers",
columns: table => new
{
Id = table.Column<string>(nullable: false),
UserName = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false),
PasswordHash = table.Column<string>(nullable: true),
SecurityStamp = table.Column<string>(nullable: true),
ConcurrencyStamp = table.Column<string>(nullable: true),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false),
TwoFactorEnabled = table.Column<bool>(nullable: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
LockoutEnabled = table.Column<bool>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false),
FullName = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "AspNetRoleClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
RoleId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetRoleClaims_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserClaims",
columns: table => new
{
Id = table.Column<int>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
UserId = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_AspNetUserClaims_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserLogins",
columns: table => new
{
LoginProvider = table.Column<string>(nullable: false),
ProviderKey = table.Column<string>(nullable: false),
ProviderDisplayName = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserLogins", x => new { x.LoginProvider, x.ProviderKey });
table.ForeignKey(
name: "FK_AspNetUserLogins_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserRoles",
columns: table => new
{
UserId = table.Column<string>(nullable: false),
RoleId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserRoles", x => new { x.UserId, x.RoleId });
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetRoles_RoleId",
column: x => x.RoleId,
principalTable: "AspNetRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_AspNetUserRoles_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "AspNetUserTokens",
columns: table => new
{
UserId = table.Column<string>(nullable: false),
LoginProvider = table.Column<string>(nullable: false),
Name = table.Column<string>(nullable: false),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_AspNetUserTokens", x => new { x.UserId, x.LoginProvider, x.Name });
table.ForeignKey(
name: "FK_AspNetUserTokens_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AspNetRoleClaims_RoleId",
table: "AspNetRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "AspNetRoles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_AspNetUserClaims_UserId",
table: "AspNetUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserLogins_UserId",
table: "AspNetUserLogins",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_AspNetUserRoles_RoleId",
table: "AspNetUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "AspNetUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "AspNetUsers",
column: "NormalizedUserName",
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AspNetRoleClaims");
migrationBuilder.DropTable(
name: "AspNetUserClaims");
migrationBuilder.DropTable(
name: "AspNetUserLogins");
migrationBuilder.DropTable(
name: "AspNetUserRoles");
migrationBuilder.DropTable(
name: "AspNetUserTokens");
migrationBuilder.DropTable(
name: "AspNetRoles");
migrationBuilder.DropTable(
name: "AspNetUsers");
}
}
}

View File

@ -0,0 +1,253 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isnd.Data;
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210502153508_api-keys")]
partial class apikeys
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("isn.Data.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ApiKeys");
});
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.ApiKey", b =>
{
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,39 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace isndhost.Migrations
{
public partial class apikeys : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "ApiKeys",
columns: table => new
{
Id = table.Column<string>(nullable: false),
UserId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ApiKeys", x => x.Id);
table.ForeignKey(
name: "FK_ApiKeys_AspNetUsers_UserId",
column: x => x.UserId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_ApiKeys_UserId",
table: "ApiKeys",
column: "UserId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "ApiKeys");
}
}
}

View File

@ -0,0 +1,259 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isnd.Data;
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210508012908_ApkiKey.CreationDate")]
partial class ApkiKeyCreationDate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreationDate");
b.Property<string>("Name");
b.Property<string>("UserId")
.IsRequired();
b.Property<int>("ValidityPeriodInDays");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ApiKeys");
});
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,43 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace isndhost.Migrations
{
public partial class ApkiKeyCreationDate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<DateTime>(
name: "CreationDate",
table: "ApiKeys",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<string>(
name: "Name",
table: "ApiKeys",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ValidityPeriodInDays",
table: "ApiKeys",
nullable: false,
defaultValue: 0);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "CreationDate",
table: "ApiKeys");
migrationBuilder.DropColumn(
name: "Name",
table: "ApiKeys");
migrationBuilder.DropColumn(
name: "ValidityPeriodInDays",
table: "ApiKeys");
}
}
}

View File

@ -0,0 +1,316 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isnd.Data;
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210516060430_packages")]
partial class packages
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreationDate");
b.Property<string>("Name");
b.Property<string>("UserId")
.IsRequired();
b.Property<int>("ValidityPeriodInDays");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ApiKeys");
});
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("isn.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Description");
b.Property<string>("OwnerId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("Packages");
});
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.Property<string>("FullString")
.ValueGeneratedOnAdd()
.HasMaxLength(32);
b.Property<bool>("IsPrerelease");
b.Property<int>("Major");
b.Property<int>("Minor");
b.Property<string>("PackageId")
.IsRequired();
b.Property<int>("Patch");
b.HasKey("FullString");
b.HasIndex("PackageId");
b.ToTable("PackageVersions");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.Package", b =>
{
b.HasOne("isn.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.HasOne("isn.Data.Package", "Package")
.WithMany()
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,70 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace isndhost.Migrations
{
public partial class packages : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Packages",
columns: table => new
{
Id = table.Column<string>(nullable: false),
OwnerId = table.Column<string>(nullable: false),
Description = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Packages", x => x.Id);
table.ForeignKey(
name: "FK_Packages_AspNetUsers_OwnerId",
column: x => x.OwnerId,
principalTable: "AspNetUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "PackageVersions",
columns: table => new
{
FullString = table.Column<string>(maxLength: 32, nullable: false),
PackageId = table.Column<string>(nullable: false),
Major = table.Column<int>(nullable: false),
Minor = table.Column<int>(nullable: false),
Patch = table.Column<int>(nullable: false),
IsPrerelease = table.Column<bool>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_PackageVersions", x => x.FullString);
table.ForeignKey(
name: "FK_PackageVersions_Packages_PackageId",
column: x => x.PackageId,
principalTable: "Packages",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Packages_OwnerId",
table: "Packages",
column: "OwnerId");
migrationBuilder.CreateIndex(
name: "IX_PackageVersions_PackageId",
table: "PackageVersions",
column: "PackageId");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "PackageVersions");
migrationBuilder.DropTable(
name: "Packages");
}
}
}

View File

@ -0,0 +1,312 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isnd.Data;
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210522194803_packageVersionKey")]
partial class packageVersionKey
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreationDate");
b.Property<string>("Name");
b.Property<string>("UserId")
.IsRequired();
b.Property<int>("ValidityPeriodInDays");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ApiKeys");
});
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("isn.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Description");
b.Property<string>("OwnerId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("Packages");
});
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.Property<string>("PackageId");
b.Property<string>("FullString")
.HasMaxLength(256);
b.Property<bool>("IsPrerelease");
b.Property<int>("Major");
b.Property<int>("Minor");
b.Property<int>("Patch");
b.HasKey("PackageId", "FullString");
b.ToTable("PackageVersions");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.Package", b =>
{
b.HasOne("isn.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.HasOne("isn.Data.Package", "Package")
.WithMany()
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -1,14 +1,9 @@
using System; using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable namespace isndhost.Migrations
namespace isnd.Migrations
{ {
/// <inheritdoc /> public partial class packageVersionKey : Migration
public partial class pkgversions : Migration
{ {
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropPrimaryKey( migrationBuilder.DropPrimaryKey(
@ -19,9 +14,13 @@ namespace isnd.Migrations
name: "IX_PackageVersions_PackageId", name: "IX_PackageVersions_PackageId",
table: "PackageVersions"); table: "PackageVersions");
migrationBuilder.DropColumn( migrationBuilder.AlterColumn<string>(
name: "CommitTimeStamp", name: "FullString",
table: "Packages"); table: "PackageVersions",
maxLength: 256,
nullable: false,
oldClrType: typeof(string),
oldMaxLength: 32);
migrationBuilder.AddPrimaryKey( migrationBuilder.AddPrimaryKey(
name: "PK_PackageVersions", name: "PK_PackageVersions",
@ -29,19 +28,19 @@ namespace isnd.Migrations
columns: new[] { "PackageId", "FullString" }); columns: new[] { "PackageId", "FullString" });
} }
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder) protected override void Down(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.DropPrimaryKey( migrationBuilder.DropPrimaryKey(
name: "PK_PackageVersions", name: "PK_PackageVersions",
table: "PackageVersions"); table: "PackageVersions");
migrationBuilder.AddColumn<DateTimeOffset>( migrationBuilder.AlterColumn<string>(
name: "CommitTimeStamp", name: "FullString",
table: "Packages", table: "PackageVersions",
type: "timestamp with time zone", maxLength: 32,
nullable: false, nullable: false,
defaultValue: new DateTimeOffset(new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified), new TimeSpan(0, 0, 0, 0, 0))); oldClrType: typeof(string),
oldMaxLength: 256);
migrationBuilder.AddPrimaryKey( migrationBuilder.AddPrimaryKey(
name: "PK_PackageVersions", name: "PK_PackageVersions",

View File

@ -0,0 +1,316 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isnd.Data;
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210621214109_version-types")]
partial class versiontypes
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreationDate");
b.Property<string>("Name");
b.Property<string>("UserId")
.IsRequired();
b.Property<int>("ValidityPeriodInDays");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ApiKeys");
});
modelBuilder.Entity("isn.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("isn.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("Description")
.HasMaxLength(1024);
b.Property<string>("OwnerId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("OwnerId");
b.ToTable("Packages");
});
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.Property<string>("PackageId");
b.Property<string>("FullString")
.HasMaxLength(256);
b.Property<string>("Type")
.HasMaxLength(256);
b.Property<bool>("IsPrerelease");
b.Property<int>("Major");
b.Property<int>("Minor");
b.Property<int>("Patch");
b.HasKey("PackageId", "FullString", "Type");
b.ToTable("PackageVersions");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("isn.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("isn.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.Package", b =>
{
b.HasOne("isn.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isn.Data.PackageVersion", b =>
{
b.HasOne("isn.Data.Package", "Package")
.WithMany("Versions")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,58 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace isndhost.Migrations
{
public partial class versiontypes : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_PackageVersions",
table: "PackageVersions");
migrationBuilder.AddColumn<string>(
name: "Type",
table: "PackageVersions",
maxLength: 256,
nullable: false,
defaultValue: "");
migrationBuilder.AlterColumn<string>(
name: "Description",
table: "Packages",
maxLength: 1024,
nullable: true,
oldClrType: typeof(string),
oldNullable: true);
migrationBuilder.AddPrimaryKey(
name: "PK_PackageVersions",
table: "PackageVersions",
columns: new[] { "PackageId", "FullString", "Type" });
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropPrimaryKey(
name: "PK_PackageVersions",
table: "PackageVersions");
migrationBuilder.DropColumn(
name: "Type",
table: "PackageVersions");
migrationBuilder.AlterColumn<string>(
name: "Description",
table: "Packages",
nullable: true,
oldClrType: typeof(string),
oldMaxLength: 1024,
oldNullable: true);
migrationBuilder.AddPrimaryKey(
name: "PK_PackageVersions",
table: "PackageVersions",
columns: new[] { "PackageId", "FullString" });
}
}
}

View File

@ -0,0 +1,346 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isnd.Data;
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210828142245_versionCommit")]
partial class versionCommit
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreationDate");
b.Property<string>("Name");
b.Property<string>("UserId")
.IsRequired();
b.Property<int>("ValidityPeriodInDays");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ApiKeys");
});
modelBuilder.Entity("isnd.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("isnd.Data.Catalog.Commit", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Action");
b.Property<string>("PackageVersionId")
.IsRequired();
b.Property<DateTime>("TimeStamp");
b.HasKey("Id");
b.ToTable("Commits");
});
modelBuilder.Entity("isnd.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<long>("CommitNId");
b.Property<DateTime>("CommitTimeStamp");
b.Property<string>("Description")
.HasMaxLength(1024);
b.Property<string>("OwnerId")
.IsRequired();
b.Property<bool>("Public");
b.HasKey("Id");
b.HasIndex("CommitNId");
b.HasIndex("OwnerId");
b.ToTable("Packages");
});
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
{
b.Property<string>("PackageId");
b.Property<string>("FullString")
.HasMaxLength(256);
b.Property<string>("Type")
.HasMaxLength(256);
b.Property<bool>("IsPrerelease");
b.Property<int>("Major");
b.Property<int>("Minor");
b.Property<int>("Patch");
b.HasKey("PackageId", "FullString", "Type");
b.ToTable("PackageVersions");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("isnd.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.Package", b =>
{
b.HasOne("isnd.Data.Catalog.Commit", "LatestCommit")
.WithMany()
.HasForeignKey("CommitNId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
{
b.HasOne("isnd.Data.Package", "Package")
.WithMany("Versions")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,92 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace isndhost.Migrations
{
public partial class versionCommit : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "CommitNId",
table: "Packages",
nullable: false,
defaultValue: 0L);
migrationBuilder.AddColumn<DateTime>(
name: "CommitTimeStamp",
table: "Packages",
nullable: false,
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
migrationBuilder.AddColumn<bool>(
name: "Public",
table: "Packages",
nullable: false,
defaultValue: false);
migrationBuilder.CreateTable(
name: "Commits",
columns: table => new
{
Id = table.Column<long>(nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn),
TimeStamp = table.Column<DateTime>(nullable: false),
Action = table.Column<int>(nullable: false),
PackageVersionId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Commits", x => x.Id);
});
migrationBuilder.Sql(
@"delete from ""PackageVersions"""
);
migrationBuilder.Sql(
@"delete from ""Packages"";"
);
migrationBuilder.CreateIndex(
name: "IX_Packages_CommitNId",
table: "Packages",
column: "CommitNId");
migrationBuilder.AddForeignKey(
name: "FK_Packages_Commits_CommitNId",
table: "Packages",
column: "CommitNId",
principalTable: "Commits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Packages_Commits_CommitNId",
table: "Packages");
migrationBuilder.DropTable(
name: "Commits");
migrationBuilder.DropIndex(
name: "IX_Packages_CommitNId",
table: "Packages");
migrationBuilder.DropColumn(
name: "CommitNId",
table: "Packages");
migrationBuilder.DropColumn(
name: "CommitTimeStamp",
table: "Packages");
migrationBuilder.DropColumn(
name: "Public",
table: "Packages");
}
}
}

View File

@ -0,0 +1,355 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isnd.Data;
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210828150712_pkgVersionCommit")]
partial class pkgVersionCommit
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreationDate");
b.Property<string>("Name");
b.Property<string>("UserId")
.IsRequired();
b.Property<int>("ValidityPeriodInDays");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ApiKeys");
});
modelBuilder.Entity("isnd.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("isnd.Data.Catalog.Commit", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Action");
b.Property<string>("PackageVersionId")
.IsRequired();
b.Property<DateTime>("TimeStamp");
b.HasKey("Id");
b.ToTable("Commits");
});
modelBuilder.Entity("isnd.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<long>("CommitNId");
b.Property<DateTime>("CommitTimeStamp");
b.Property<string>("Description")
.HasMaxLength(1024);
b.Property<string>("OwnerId")
.IsRequired();
b.Property<bool>("Public");
b.HasKey("Id");
b.HasIndex("CommitNId");
b.HasIndex("OwnerId");
b.ToTable("Packages");
});
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
{
b.Property<string>("PackageId");
b.Property<string>("FullString")
.HasMaxLength(256);
b.Property<string>("Type")
.HasMaxLength(256);
b.Property<long>("CommitNId");
b.Property<bool>("IsPrerelease");
b.Property<int>("Major");
b.Property<int>("Minor");
b.Property<int>("Patch");
b.HasKey("PackageId", "FullString", "Type");
b.HasIndex("CommitNId");
b.ToTable("PackageVersions");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("isnd.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.Package", b =>
{
b.HasOne("isnd.Data.Catalog.Commit", "LatestVersion")
.WithMany()
.HasForeignKey("CommitNId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
{
b.HasOne("isnd.Data.Catalog.Commit", "LatestCommit")
.WithMany()
.HasForeignKey("CommitNId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.Package", "Package")
.WithMany("Versions")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,44 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace isndhost.Migrations
{
public partial class pkgVersionCommit : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<long>(
name: "CommitNId",
table: "PackageVersions",
nullable: false,
defaultValue: 0L);
migrationBuilder.CreateIndex(
name: "IX_PackageVersions_CommitNId",
table: "PackageVersions",
column: "CommitNId");
migrationBuilder.AddForeignKey(
name: "FK_PackageVersions_Commits_CommitNId",
table: "PackageVersions",
column: "CommitNId",
principalTable: "Commits",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PackageVersions_Commits_CommitNId",
table: "PackageVersions");
migrationBuilder.DropIndex(
name: "IX_PackageVersions_CommitNId",
table: "PackageVersions");
migrationBuilder.DropColumn(
name: "CommitNId",
table: "PackageVersions");
}
}
}

View File

@ -0,0 +1,352 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isnd.Data;
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210828220901_CommitNoPack")]
partial class CommitNoPack
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreationDate");
b.Property<string>("Name");
b.Property<string>("UserId")
.IsRequired();
b.Property<int>("ValidityPeriodInDays");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ApiKeys");
});
modelBuilder.Entity("isnd.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("isnd.Data.Catalog.Commit", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Action");
b.Property<DateTime>("TimeStamp");
b.HasKey("Id");
b.ToTable("Commits");
});
modelBuilder.Entity("isnd.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<long>("CommitNId");
b.Property<DateTime>("CommitTimeStamp");
b.Property<string>("Description")
.HasMaxLength(1024);
b.Property<string>("OwnerId")
.IsRequired();
b.Property<bool>("Public");
b.HasKey("Id");
b.HasIndex("CommitNId");
b.HasIndex("OwnerId");
b.ToTable("Packages");
});
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
{
b.Property<string>("PackageId");
b.Property<string>("FullString")
.HasMaxLength(256);
b.Property<string>("Type")
.HasMaxLength(256);
b.Property<long>("CommitNId");
b.Property<bool>("IsPrerelease");
b.Property<int>("Major");
b.Property<int>("Minor");
b.Property<int>("Patch");
b.HasKey("PackageId", "FullString", "Type");
b.HasIndex("CommitNId");
b.ToTable("PackageVersions");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("isnd.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.Package", b =>
{
b.HasOne("isnd.Data.Catalog.Commit", "LatestVersion")
.WithMany()
.HasForeignKey("CommitNId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
{
b.HasOne("isnd.Data.Catalog.Commit", "LatestCommit")
.WithMany("Versions")
.HasForeignKey("CommitNId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.Package", "Package")
.WithMany("Versions")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,23 @@
using Microsoft.EntityFrameworkCore.Migrations;
namespace isndhost.Migrations
{
public partial class CommitNoPack : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "PackageVersionId",
table: "Commits");
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "PackageVersionId",
table: "Commits",
nullable: false,
defaultValue: "");
}
}
}

View File

@ -0,0 +1,392 @@
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using isnd.Data;
namespace isndhost.Migrations
{
[DbContext(typeof(ApplicationDbContext))]
[Migration("20210905144343_pkgVerCom")]
partial class pkgVerCom
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.HasAnnotation("ProductVersion", "2.2.6-servicing-10079")
.HasAnnotation("Relational:MaxIdentifierLength", 63);
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("AspNetRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("AspNetRoleClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("AspNetUserClaims");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.Property<string>("LoginProvider");
b.Property<string>("ProviderKey");
b.Property<string>("ProviderDisplayName");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("LoginProvider", "ProviderKey");
b.HasIndex("UserId");
b.ToTable("AspNetUserLogins");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("RoleId");
b.HasKey("UserId", "RoleId");
b.HasIndex("RoleId");
b.ToTable("AspNetUserRoles");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.Property<string>("UserId");
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("Value");
b.HasKey("UserId", "LoginProvider", "Name");
b.ToTable("AspNetUserTokens");
});
modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<DateTime>("CreationDate");
b.Property<string>("Name");
b.Property<string>("UserId")
.IsRequired();
b.Property<int>("ValidityPeriodInDays");
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("ApiKeys");
});
modelBuilder.Entity("isnd.Data.ApplicationUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<string>("FullName");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("AspNetUsers");
});
modelBuilder.Entity("isnd.Data.Catalog.Commit", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("Action");
b.Property<DateTime>("TimeStamp");
b.HasKey("Id");
b.ToTable("Commits");
});
modelBuilder.Entity("isnd.Data.Historic.PackageVersionCommit", b =>
{
b.Property<long>("CommitId");
b.Property<string>("PackageId")
.HasMaxLength(1024);
b.Property<string>("FullString")
.HasMaxLength(256);
b.Property<string>("PackageType")
.HasMaxLength(256);
b.HasKey("CommitId", "PackageId", "FullString", "PackageType");
b.HasIndex("PackageId", "FullString", "PackageType");
b.ToTable("PackageVersionCommmit");
});
modelBuilder.Entity("isnd.Data.Package", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd()
.HasMaxLength(1024);
b.Property<long>("CommitNId");
b.Property<DateTime>("CommitTimeStamp");
b.Property<string>("Description")
.HasMaxLength(1024);
b.Property<string>("OwnerId")
.IsRequired();
b.Property<bool>("Public");
b.HasKey("Id");
b.HasIndex("CommitNId");
b.HasIndex("OwnerId");
b.ToTable("Packages");
});
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
{
b.Property<string>("PackageId")
.HasMaxLength(1024);
b.Property<string>("FullString")
.HasMaxLength(256);
b.Property<string>("Type")
.HasMaxLength(256);
b.Property<long>("CommitNId");
b.Property<bool>("IsPrerelease");
b.Property<int>("Major");
b.Property<int>("Minor");
b.Property<int>("Patch");
b.HasKey("PackageId", "FullString", "Type");
b.HasIndex("CommitNId");
b.ToTable("PackageVersions");
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole<string>", b =>
{
b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken<string>", b =>
{
b.HasOne("isnd.Data.ApplicationUser")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.ApiKeys.ApiKey", b =>
{
b.HasOne("isnd.Data.ApplicationUser", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.Historic.PackageVersionCommit", b =>
{
b.HasOne("isnd.Data.Catalog.Commit", "Commit")
.WithMany()
.HasForeignKey("CommitId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.Package", "Package")
.WithMany()
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.PackageVersion", "PackageVersion")
.WithMany()
.HasForeignKey("PackageId", "FullString", "PackageType")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.Package", b =>
{
b.HasOne("isnd.Data.Catalog.Commit", "LatestVersion")
.WithMany()
.HasForeignKey("CommitNId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.ApplicationUser", "Owner")
.WithMany()
.HasForeignKey("OwnerId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("isnd.Data.PackageVersion", b =>
{
b.HasOne("isnd.Data.Catalog.Commit", "LatestCommit")
.WithMany("Versions")
.HasForeignKey("CommitNId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("isnd.Data.Package", "Package")
.WithMany("Versions")
.HasForeignKey("PackageId")
.OnDelete(DeleteBehavior.Cascade);
});
#pragma warning restore 612, 618
}
}
}

Some files were not shown because too many files have changed in this diff Show More