@flarehr/superhero-basic-profile 0.1.2217 → 0.1.2223

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/assets/delete.dcc7b157.svg +5 -0
  2. package/dist/assets/dialog-warning.cc77f3ba.svg +5 -0
  3. package/dist/assets/pencil.05fe6be6.svg +5 -0
  4. package/dist/index.html +20 -0
  5. package/dist/superhero-basic-profile.js +50 -0
  6. package/package.json +1 -1
  7. package/dist/App.jsx +0 -4
  8. package/dist/Basic.Profile.Domain/AnalyticsEvent.jsx +0 -102
  9. package/dist/Basic.Profile.Domain/Audit.jsx +0 -149
  10. package/dist/Basic.Profile.Domain/Commands.jsx +0 -68
  11. package/dist/Basic.Profile.Domain/CommonTypes.jsx +0 -194
  12. package/dist/Basic.Profile.Domain/Config/Api/Admin/Read.jsx +0 -58
  13. package/dist/Basic.Profile.Domain/Config/Api/Admin/Write.jsx +0 -23
  14. package/dist/Basic.Profile.Domain/Config/Api/FlareAdminShell/Read.jsx +0 -35
  15. package/dist/Basic.Profile.Domain/Config/Commands.jsx +0 -72
  16. package/dist/Basic.Profile.Domain/Config/ConfigCommandHandler.jsx +0 -197
  17. package/dist/Basic.Profile.Domain/Config/Dto.jsx +0 -181
  18. package/dist/Basic.Profile.Domain/Config/Types.jsx +0 -152
  19. package/dist/Basic.Profile.Domain/DateTimeProvider.jsx +0 -23
  20. package/dist/Basic.Profile.Domain/DomainAggregates.jsx +0 -801
  21. package/dist/Basic.Profile.Domain/DomainPrimitives.jsx +0 -426
  22. package/dist/Basic.Profile.Domain/Dto/Aggregates.jsx +0 -564
  23. package/dist/Basic.Profile.Domain/Dto/AnalyticsEvent.jsx +0 -157
  24. package/dist/Basic.Profile.Domain/Dto/Api/Backend/Common.jsx +0 -102
  25. package/dist/Basic.Profile.Domain/Dto/Api/Backend/Read.jsx +0 -85
  26. package/dist/Basic.Profile.Domain/Dto/Api/Backend/Write.jsx +0 -16
  27. package/dist/Basic.Profile.Domain/Dto/Api/Common.jsx +0 -427
  28. package/dist/Basic.Profile.Domain/Dto/Api/External/Read.jsx +0 -118
  29. package/dist/Basic.Profile.Domain/Dto/Api/External/ReadV2.jsx +0 -6
  30. package/dist/Basic.Profile.Domain/Dto/Api/External/Write.jsx +0 -184
  31. package/dist/Basic.Profile.Domain/Dto/Api/External/WriteV2.jsx +0 -439
  32. package/dist/Basic.Profile.Domain/Dto/Api/FlareAdminShell/Read.jsx +0 -38
  33. package/dist/Basic.Profile.Domain/Dto/Api/FlareAdminShell/Write.jsx +0 -199
  34. package/dist/Basic.Profile.Domain/Dto/Api/Internal/Read.jsx +0 -125
  35. package/dist/Basic.Profile.Domain/Dto/Audit.jsx +0 -121
  36. package/dist/Basic.Profile.Domain/Dto/Commands.jsx +0 -256
  37. package/dist/Basic.Profile.Domain/Dto/Common.jsx +0 -84
  38. package/dist/Basic.Profile.Domain/Dto/Events.jsx +0 -220
  39. package/dist/Basic.Profile.Domain/Dto/Primitives.jsx +0 -580
  40. package/dist/Basic.Profile.Domain/Dto/ProfileCreationModels.jsx +0 -324
  41. package/dist/Basic.Profile.Domain/Dto/Validation.jsx +0 -229
  42. package/dist/Basic.Profile.Domain/Events.jsx +0 -64
  43. package/dist/Basic.Profile.Domain/Import/Api/InternalApi/Read.jsx +0 -140
  44. package/dist/Basic.Profile.Domain/Import/Api/InternalApi/Validation.jsx +0 -499
  45. package/dist/Basic.Profile.Domain/Import/Api/InternalApi/Write.jsx +0 -51
  46. package/dist/Basic.Profile.Domain/Import/Api/Read.jsx +0 -154
  47. package/dist/Basic.Profile.Domain/Import/CommonTypes.jsx +0 -187
  48. package/dist/Basic.Profile.Domain/Import/Dto.jsx +0 -475
  49. package/dist/Basic.Profile.Domain/Import/ImportCommandHandler.jsx +0 -531
  50. package/dist/Basic.Profile.Domain/Import/Types.jsx +0 -405
  51. package/dist/Basic.Profile.Domain/JwtPayload.jsx +0 -44
  52. package/dist/Basic.Profile.Domain/Metadata.jsx +0 -257
  53. package/dist/Basic.Profile.Domain/ProfileCommandHandler.jsx +0 -261
  54. package/dist/Basic.Profile.Domain/ProfileModels.jsx +0 -59
  55. package/dist/Basic.Profile.Domain/Utils.jsx +0 -372
  56. package/dist/Common/PreactCustomElement.jsx +0 -8
  57. package/dist/Common/Resources.jsx +0 -20
  58. package/dist/Common/Tailwind.jsx +0 -8
  59. package/dist/Common/Utils.jsx +0 -18
  60. package/dist/Directory/App.jsx +0 -192
  61. package/dist/Directory/BackendServices/Common.jsx +0 -115
  62. package/dist/Directory/BackendServices/ConfigService.jsx +0 -168
  63. package/dist/Directory/BackendServices/ImportService.jsx +0 -137
  64. package/dist/Directory/Common.jsx +0 -93
  65. package/dist/Directory/Config/Components.jsx +0 -173
  66. package/dist/Directory/Config/Types.jsx +0 -187
  67. package/dist/Directory/PastImports/PastImports.jsx +0 -81
  68. package/dist/Directory/ProfileImport/ProfileImport.jsx +0 -284
  69. package/dist/Directory/ProfileImport/Types.jsx +0 -91
  70. package/dist/Directory/TabNav.jsx +0 -24
  71. package/dist/Directory/Types.jsx +0 -101
  72. package/dist/Directory/User.jsx +0 -117
  73. package/dist/HeadlessUI/Dialog.jsx +0 -66
  74. package/dist/HeadlessUI/ModalDialog.jsx +0 -74
  75. package/dist/HeadlessUI/Switch.jsx +0 -66
  76. package/dist/HeadlessUI/Transition.jsx +0 -66
@@ -1,8 +0,0 @@
1
- import preact_custom_element from "preact-custom-element";
2
-
3
- export function register(reactComponent, tagName) {
4
- preact_custom_element(reactComponent, tagName, undefined, {
5
- shadow: true,
6
- });
7
- }
8
-
@@ -1,20 +0,0 @@
1
- import { reactApi } from "../fable_modules/Feliz.2.8.0/Interop.fs.js";
2
- import { createObj } from "../fable_modules/fable-library-js.4.20.0/Util.js";
3
- import { ReactComponent } from "../../src/assets/dialog-warning.svg";
4
- import { ReactComponent as ReactComponent_1 } from "../../src/assets/pencil.svg";
5
- import { ReactComponent as ReactComponent_2 } from "../../src/assets/delete.svg";
6
-
7
- function ImportedSvg_importSvg(svg, props) {
8
- return reactApi.createElement(svg, createObj(props));
9
- }
10
-
11
- export function dialogWarning(props) {
12
- return ImportedSvg_importSvg(ReactComponent, props);
13
- }
14
-
15
- export const dialogWarningDefault = dialogWarning([["className", "h-6 w-6 text-red-500"]]);
16
-
17
- export const pencilDefault = ImportedSvg_importSvg(ReactComponent_1, []);
18
-
19
- export const deleteDefault = ImportedSvg_importSvg(ReactComponent_2, []);
20
-
@@ -1,8 +0,0 @@
1
- import index from "../../index.css";
2
- import { toString } from "../fable_modules/fable-library-js.4.20.0/Types.js";
3
-
4
- export const css = (() => {
5
- const value = index;
6
- return toString(value);
7
- })();
8
-
@@ -1,18 +0,0 @@
1
- import { Union } from "../fable_modules/fable-library-js.4.20.0/Types.js";
2
- import { union_type } from "../fable_modules/fable-library-js.4.20.0/Reflection.js";
3
-
4
- export class AsyncOperationStatus$2 extends Union {
5
- constructor(tag, fields) {
6
- super();
7
- this.tag = tag;
8
- this.fields = fields;
9
- }
10
- cases() {
11
- return ["Started", "Finished"];
12
- }
13
- }
14
-
15
- export function AsyncOperationStatus$2_$reflection(gen0, gen1) {
16
- return union_type("Basic.Profile.UI.Superhero.Common.Utils.AsyncOperationStatus`2", [gen0, gen1], AsyncOperationStatus$2, () => [[["Item", gen0]], [["Item", gen1]]]);
17
- }
18
-
@@ -1,192 +0,0 @@
1
- import { UserModule_create, AccessRoleModule_canEditConfig, AccessRoleModule_$007CAccessConfig$007C_$007C, AccessRoleModule_$007CEditConfig$007C_$007C, AccessRoleModule_$007CImport$007C_$007C } from "./User.jsx";
2
- import { Msg, StateModule_update, StateModule_init, Tab, ImportTabs } from "./Types.jsx";
3
- import { singleton, ofArray } from "../fable_modules/fable-library-js.4.20.0/List.js";
4
- import { createElement } from "react";
5
- import React from "react";
6
- import { Props, ConfigComponent } from "./Config/Components.jsx";
7
- import { ConfigService_$ctor_Z384F8060 } from "./BackendServices/ConfigService.jsx";
8
- import { css } from "../Common/Tailwind.jsx";
9
- import { Component as Component_1 } from "./TabNav.jsx";
10
- import { createObj } from "../fable_modules/fable-library-js.4.20.0/Util.js";
11
- import { reactApi } from "../fable_modules/Feliz.2.8.0/Interop.fs.js";
12
- import { ImportService__GetImport_Z524259A4, ImportService__GetImports, ImportService_$ctor_30230F9B } from "./BackendServices/ImportService.jsx";
13
- import { React_useElmish_Z6C327F2E } from "../fable_modules/Feliz.UseElmish.2.5.0/UseElmish.fs.js";
14
- import { ProgramModule_mkProgram } from "../fable_modules/Fable.Elmish.4.0.0/program.fs.js";
15
- import { singleton as singleton_1, delay, toList } from "../fable_modules/fable-library-js.4.20.0/Seq.js";
16
- import { ErrorText } from "./Common.jsx";
17
- import { Component as Component_2 } from "./PastImports/PastImports.jsx";
18
- import { Component as Component_3 } from "./ProfileImport/ProfileImport.jsx";
19
- import { AsyncOperationStatus$2 } from "../Common/Utils.jsx";
20
- import { register } from "../Common/PreactCustomElement.jsx";
21
-
22
- export function buildTabs(roles) {
23
- const tabs = [];
24
- if (AccessRoleModule_$007CImport$007C_$007C(roles) != null) {
25
- void (tabs.push(new Tab(0, [new ImportTabs(0, [])])));
26
- void (tabs.push(new Tab(0, [new ImportTabs(1, [])])));
27
- }
28
- let matchResult;
29
- if (AccessRoleModule_$007CEditConfig$007C_$007C(roles) != null) {
30
- matchResult = 0;
31
- }
32
- else if (AccessRoleModule_$007CAccessConfig$007C_$007C(roles) != null) {
33
- matchResult = 0;
34
- }
35
- else {
36
- matchResult = 1;
37
- }
38
- switch (matchResult) {
39
- case 0: {
40
- void (tabs.push(new Tab(1, [])));
41
- break;
42
- }
43
- }
44
- return ofArray(tabs.slice());
45
- }
46
-
47
- export function renderConfigComponent(props, user) {
48
- return createElement(ConfigComponent, new Props(props.partnerId, props.accountId, ConfigService_$ctor_Z384F8060(props.backendUrl, props.accessToken), AccessRoleModule_canEditConfig(user.Roles)));
49
- }
50
-
51
- export function Component(props) {
52
- let elems, elems_1;
53
- const user = UserModule_create(props.accessToken);
54
- const matchValue = props.accountId;
55
- const matchValue_1 = user.Roles;
56
- let matchResult;
57
- if (matchValue == null) {
58
- if (AccessRoleModule_$007CAccessConfig$007C_$007C(matchValue_1) != null) {
59
- matchResult = 0;
60
- }
61
- else if (AccessRoleModule_$007CEditConfig$007C_$007C(matchValue_1) != null) {
62
- matchResult = 0;
63
- }
64
- else {
65
- matchResult = 1;
66
- }
67
- }
68
- else {
69
- matchResult = 1;
70
- }
71
- switch (matchResult) {
72
- case 0: {
73
- const children = ofArray([createElement("style", {
74
- children: [css],
75
- }), createElement(Component_1, {
76
- tabs: singleton(new Tab(1, [])),
77
- currentTab: new Tab(1, []),
78
- setCurrentTab: (value_1) => {
79
- },
80
- }), createElement("div", createObj(ofArray([["className", "mt-4"], (elems = [renderConfigComponent(props, user)], ["children", reactApi.Children.toArray(Array.from(elems))])])))]);
81
- return createElement("div", {
82
- children: reactApi.Children.toArray(Array.from(children)),
83
- });
84
- }
85
- default: {
86
- let matchResult_1, accountId;
87
- if (matchValue != null) {
88
- if (AccessRoleModule_$007CImport$007C_$007C(matchValue_1) != null) {
89
- matchResult_1 = 0;
90
- accountId = matchValue;
91
- }
92
- else {
93
- matchResult_1 = 1;
94
- }
95
- }
96
- else {
97
- matchResult_1 = 1;
98
- }
99
- switch (matchResult_1) {
100
- case 0: {
101
- const backendService = ImportService_$ctor_30230F9B(props.backendUrl, accountId, props.accessToken);
102
- const patternInput = React_useElmish_Z6C327F2E(() => ProgramModule_mkProgram(StateModule_init, (msg, state) => StateModule_update(() => ImportService__GetImports(backendService), msg, state), (_arg, _arg_1) => {
103
- }), undefined, undefined);
104
- const state_1 = patternInput[0];
105
- const dispatch = patternInput[1];
106
- const tabs = buildTabs(user.Roles);
107
- const children_2 = ofArray([createElement("style", {
108
- children: [css],
109
- }), createElement(Component_1, {
110
- tabs: tabs,
111
- currentTab: state_1.CurrentTab,
112
- setCurrentTab: (arg) => {
113
- dispatch(new Msg(0, [arg]));
114
- },
115
- }), createElement("div", createObj(ofArray([["className", "mt-4"], (elems_1 = toList(delay(() => {
116
- const matchValue_3 = state_1.CurrentTab;
117
- if (matchValue_3.tag === 0) {
118
- const matchValue_4 = state_1.AccountImports;
119
- let matchResult_2, ex, e, accountImports;
120
- switch (matchValue_4.tag) {
121
- case 3: {
122
- matchResult_2 = 1;
123
- ex = matchValue_4.fields[0];
124
- break;
125
- }
126
- case 2: {
127
- if (matchValue_4.fields[0].tag === 0) {
128
- matchResult_2 = 3;
129
- accountImports = matchValue_4.fields[0].fields[0];
130
- }
131
- else {
132
- matchResult_2 = 2;
133
- e = matchValue_4.fields[0].fields[0];
134
- }
135
- break;
136
- }
137
- default:
138
- matchResult_2 = 0;
139
- }
140
- switch (matchResult_2) {
141
- case 0:
142
- return singleton_1(createElement("div", {
143
- children: ["Please wait..."],
144
- }));
145
- case 1:
146
- return singleton_1(ErrorText(ex.message));
147
- case 2:
148
- return singleton_1(ErrorText(e));
149
- default:
150
- return (matchValue_3.fields[0].tag === 1) ? singleton_1(createElement(Component_2, {
151
- accountImports: accountImports,
152
- fetchImport: (importId) => ImportService__GetImport_Z524259A4(backendService, importId),
153
- })) : singleton_1(createElement(Component_3, {
154
- accountId: accountId,
155
- accountImports: accountImports,
156
- dispatchFetchImports: () => {
157
- dispatch(new Msg(1, [new AsyncOperationStatus$2(0, [undefined])]));
158
- },
159
- importService: backendService,
160
- onDone: () => {
161
- dispatch(new Msg(0, [new Tab(0, [new ImportTabs(1, [])])]));
162
- },
163
- }));
164
- }
165
- }
166
- else {
167
- return singleton_1(renderConfigComponent(props, user));
168
- }
169
- })), ["children", reactApi.Children.toArray(Array.from(elems_1))])])))]);
170
- return createElement("div", {
171
- children: reactApi.Children.toArray(Array.from(children_2)),
172
- });
173
- }
174
- default: {
175
- const children_4 = ofArray([createElement("style", {
176
- children: [css],
177
- }), createElement("div", {
178
- children: "You do not have the appropriate permissions to view or do the imports.",
179
- })]);
180
- return createElement("div", {
181
- children: reactApi.Children.toArray(Array.from(children_4)),
182
- });
183
- }
184
- }
185
- }
186
- }
187
- }
188
-
189
- export function registerCustomElement() {
190
- register((props) => createElement(Component, props), "superhero-profile-directory-app");
191
- }
192
-
@@ -1,115 +0,0 @@
1
- import { Union } from "../../fable_modules/fable-library-js.4.20.0/Types.js";
2
- import { class_type, union_type, string_type } from "../../fable_modules/fable-library-js.4.20.0/Reflection.js";
3
- import { singleton } from "../../fable_modules/fable-library-js.4.20.0/AsyncBuilder.js";
4
- import { Headers_contentType, Http_content, Headers_authorization, Http_header, Http_request, Http_method, Http_send } from "../../fable_modules/Fable.SimpleHttp.3.6.0/Http.fs.js";
5
- import { BodyContent, HttpMethod } from "../../fable_modules/Fable.SimpleHttp.3.6.0/Types.fs.js";
6
- import { FSharpResult$2 } from "../../fable_modules/fable-library-js.4.20.0/Result.js";
7
-
8
- export class ResponseError extends Union {
9
- constructor(tag, fields) {
10
- super();
11
- this.tag = tag;
12
- this.fields = fields;
13
- }
14
- cases() {
15
- return ["AccessDenied", "Serialization", "Others"];
16
- }
17
- }
18
-
19
- export function ResponseError_$reflection() {
20
- return union_type("Basic.Profile.UI.Superhero.Directory.BackendServices.ResponseError", [], ResponseError, () => [[], [["Item", string_type]], []]);
21
- }
22
-
23
- export class HttpClient {
24
- constructor(accessToken) {
25
- this.accessToken = accessToken;
26
- }
27
- }
28
-
29
- export function HttpClient_$reflection() {
30
- return class_type("Basic.Profile.UI.Superhero.Directory.BackendServices.HttpClient", undefined, HttpClient);
31
- }
32
-
33
- export function HttpClient_$ctor_Z721C83C5(accessToken) {
34
- return new HttpClient(accessToken);
35
- }
36
-
37
- export function HttpClient__Get_Z721C83C5(_, url) {
38
- return singleton.Delay(() => {
39
- let req_1;
40
- let asyncResult_2;
41
- const input = Http_send((req_1 = Http_method(new HttpMethod(0, []), Http_request(url)), Http_header(Headers_authorization(`Bearer ${_.accessToken}`), req_1)));
42
- asyncResult_2 = singleton.Bind(input, (x$0027) => singleton.Return(new FSharpResult$2(0, [x$0027])));
43
- return singleton.Bind(asyncResult_2, (input_1_1) => {
44
- const input_4 = input_1_1;
45
- if (input_4.tag === 1) {
46
- return singleton.Return(new FSharpResult$2(1, [input_4.fields[0]]));
47
- }
48
- else {
49
- const response = input_4.fields[0];
50
- const matchValue = response.statusCode | 0;
51
- switch (matchValue) {
52
- case 200:
53
- return singleton.Return(new FSharpResult$2(0, [response.responseText]));
54
- case 403:
55
- return singleton.Return(new FSharpResult$2(1, [new ResponseError(0, [])]));
56
- default:
57
- return singleton.Return(new FSharpResult$2(1, [new ResponseError(2, [])]));
58
- }
59
- }
60
- });
61
- });
62
- }
63
-
64
- export function HttpClient__Put(_, url, bodyContent) {
65
- return singleton.Delay(() => {
66
- let req_2, req_1;
67
- let asyncResult_2;
68
- const input = Http_send(Http_content(new BodyContent(1, [bodyContent]), (req_2 = ((req_1 = Http_method(new HttpMethod(2, []), Http_request(url)), Http_header(Headers_authorization(`Bearer ${_.accessToken}`), req_1))), Http_header(Headers_contentType("application/json"), req_2))));
69
- asyncResult_2 = singleton.Bind(input, (x$0027) => singleton.Return(new FSharpResult$2(0, [x$0027])));
70
- return singleton.Bind(asyncResult_2, (input_1_1) => {
71
- const input_4 = input_1_1;
72
- if (input_4.tag === 1) {
73
- return singleton.Return(new FSharpResult$2(1, [input_4.fields[0]]));
74
- }
75
- else {
76
- const matchValue = input_4.fields[0].statusCode | 0;
77
- switch (matchValue) {
78
- case 200:
79
- return singleton.Return(new FSharpResult$2(0, [undefined]));
80
- case 403:
81
- return singleton.Return(new FSharpResult$2(1, [new ResponseError(0, [])]));
82
- default:
83
- return singleton.Return(new FSharpResult$2(1, [new ResponseError(2, [])]));
84
- }
85
- }
86
- });
87
- });
88
- }
89
-
90
- export function HttpClient__Delete_Z721C83C5(_, url) {
91
- return singleton.Delay(() => {
92
- let req_2, req_1;
93
- let asyncResult_2;
94
- const input = Http_send((req_2 = ((req_1 = Http_method(new HttpMethod(4, []), Http_request(url)), Http_header(Headers_authorization(`Bearer ${_.accessToken}`), req_1))), Http_header(Headers_contentType("application/json"), req_2)));
95
- asyncResult_2 = singleton.Bind(input, (x$0027) => singleton.Return(new FSharpResult$2(0, [x$0027])));
96
- return singleton.Bind(asyncResult_2, (input_1_1) => {
97
- const input_4 = input_1_1;
98
- if (input_4.tag === 1) {
99
- return singleton.Return(new FSharpResult$2(1, [input_4.fields[0]]));
100
- }
101
- else {
102
- const matchValue = input_4.fields[0].statusCode | 0;
103
- switch (matchValue) {
104
- case 200:
105
- return singleton.Return(new FSharpResult$2(0, [undefined]));
106
- case 403:
107
- return singleton.Return(new FSharpResult$2(1, [new ResponseError(0, [])]));
108
- default:
109
- return singleton.Return(new FSharpResult$2(1, [new ResponseError(2, [])]));
110
- }
111
- }
112
- });
113
- });
114
- }
115
-
@@ -1,168 +0,0 @@
1
- import { HttpClient__Delete_Z721C83C5, HttpClient__Put, ResponseError, HttpClient__Get_Z721C83C5, HttpClient_$ctor_Z721C83C5 } from "./Common.jsx";
2
- import { class_type } from "../../fable_modules/fable-library-js.4.20.0/Reflection.js";
3
- import { singleton } from "../../fable_modules/fable-library-js.4.20.0/AsyncBuilder.js";
4
- import { FSharpResult$2 } from "../../fable_modules/fable-library-js.4.20.0/Result.js";
5
- import { Auto_generateBoxedDecoder_Z6670B51, fromString } from "../../fable_modules/Thoth.Json.10.2.0/Decode.fs.js";
6
- import { uncurry2 } from "../../fable_modules/fable-library-js.4.20.0/Util.js";
7
- import { ConfigDto_$reflection } from "../../Basic.Profile.Domain/Config/Api/Admin/Read.jsx";
8
- import { CaseStrategy } from "../../fable_modules/Thoth.Json.10.2.0/Types.fs.js";
9
- import { Auto_generateBoxedEncoder_437914C6, toString } from "../../fable_modules/Thoth.Json.10.2.0/Encode.fs.js";
10
- import { ConfigPutDto_$reflection } from "../../Basic.Profile.Domain/Config/Api/Admin/Write.jsx";
11
-
12
- export class ConfigService {
13
- constructor(backendUrl, accessToken) {
14
- this.backendUrl = backendUrl;
15
- this.httpClient = HttpClient_$ctor_Z721C83C5(accessToken);
16
- }
17
- }
18
-
19
- export function ConfigService_$reflection() {
20
- return class_type("Basic.Profile.UI.Superhero.Directory.BackendServices.ConfigService", undefined, ConfigService);
21
- }
22
-
23
- export function ConfigService_$ctor_Z384F8060(backendUrl, accessToken) {
24
- return new ConfigService(backendUrl, accessToken);
25
- }
26
-
27
- export function ConfigService__GetPartnerConfig_Z721C83C5(_, partnerId) {
28
- let input_6;
29
- const input_2 = HttpClient__Get_Z721C83C5(_.httpClient, ConfigService__getPartnerBaseUrl_1505(_, partnerId));
30
- input_6 = singleton.Bind(input_2, (input_1_1) => {
31
- const input_4 = input_1_1;
32
- if (input_4.tag === 1) {
33
- return singleton.Return(new FSharpResult$2(1, [input_4.fields[0]]));
34
- }
35
- else {
36
- return singleton.Delay(() => {
37
- let value_1;
38
- const input_1 = fromString(uncurry2(Auto_generateBoxedDecoder_Z6670B51(ConfigDto_$reflection(), new CaseStrategy(1, []), undefined)), input_4.fields[0]);
39
- value_1 = ((input_1.tag === 1) ? (new FSharpResult$2(1, [new ResponseError(1, [input_1.fields[0]])])) : (new FSharpResult$2(0, [input_1.fields[0]])));
40
- return singleton.Return(value_1);
41
- });
42
- }
43
- });
44
- return singleton.Bind(input_6, (x$0027) => {
45
- let value_4;
46
- const input_8 = x$0027;
47
- value_4 = ((input_8.tag === 1) ? (new FSharpResult$2(1, [ConfigService__mapResponseError(_, "Failed to fetch partner\'s config", input_8.fields[0])])) : (new FSharpResult$2(0, [input_8.fields[0]])));
48
- return singleton.Return(value_4);
49
- });
50
- }
51
-
52
- export function ConfigService__UpdatePartnerConfig(_, partnerId, config) {
53
- return singleton.Delay(() => {
54
- const bodyContent = toString(0, Auto_generateBoxedEncoder_437914C6(ConfigPutDto_$reflection(), new CaseStrategy(1, []), undefined, undefined)(config));
55
- const input = HttpClient__Put(_.httpClient, ConfigService__getPartnerBaseUrl_1505(_, partnerId), bodyContent);
56
- return singleton.Bind(input, (x$0027) => {
57
- let value_2;
58
- const input_2 = x$0027;
59
- value_2 = ((input_2.tag === 1) ? (new FSharpResult$2(1, [ConfigService__mapResponseError(_, "Failed to update partner\'s config", input_2.fields[0])])) : (new FSharpResult$2(0, [input_2.fields[0]])));
60
- return singleton.Return(value_2);
61
- });
62
- });
63
- }
64
-
65
- export function ConfigService__DeletePartnerConfig_Z721C83C5(_, partnerId) {
66
- const input = HttpClient__Delete_Z721C83C5(_.httpClient, ConfigService__getPartnerBaseUrl_1505(_, partnerId));
67
- return singleton.Bind(input, (x$0027) => {
68
- let value;
69
- const input_2 = x$0027;
70
- value = ((input_2.tag === 1) ? (new FSharpResult$2(1, [ConfigService__mapResponseError(_, "Failed to delete partner\'s config", input_2.fields[0])])) : (new FSharpResult$2(0, [input_2.fields[0]])));
71
- return singleton.Return(value);
72
- });
73
- }
74
-
75
- export function ConfigService__GetAccountConfig(_, partnerId, accountId) {
76
- let input_6;
77
- const input_2 = HttpClient__Get_Z721C83C5(_.httpClient, ConfigService__getAccountBaseUrl(_, partnerId, accountId));
78
- input_6 = singleton.Bind(input_2, (input_1_1) => {
79
- const input_4 = input_1_1;
80
- if (input_4.tag === 1) {
81
- return singleton.Return(new FSharpResult$2(1, [input_4.fields[0]]));
82
- }
83
- else {
84
- return singleton.Delay(() => {
85
- let value_1;
86
- const input_1 = fromString(uncurry2(Auto_generateBoxedDecoder_Z6670B51(ConfigDto_$reflection(), new CaseStrategy(1, []), undefined)), input_4.fields[0]);
87
- value_1 = ((input_1.tag === 1) ? (new FSharpResult$2(1, [new ResponseError(1, [input_1.fields[0]])])) : (new FSharpResult$2(0, [input_1.fields[0]])));
88
- return singleton.Return(value_1);
89
- });
90
- }
91
- });
92
- return singleton.Bind(input_6, (x$0027) => {
93
- let value_4;
94
- const input_8 = x$0027;
95
- value_4 = ((input_8.tag === 1) ? (new FSharpResult$2(1, [ConfigService__mapResponseError(_, "Failed to fetch account\'s config", input_8.fields[0])])) : (new FSharpResult$2(0, [input_8.fields[0]])));
96
- return singleton.Return(value_4);
97
- });
98
- }
99
-
100
- export function ConfigService__UpdateAccountConfig(_, partnerId, accountId, config) {
101
- return singleton.Delay(() => {
102
- const bodyContent = toString(0, Auto_generateBoxedEncoder_437914C6(ConfigPutDto_$reflection(), new CaseStrategy(1, []), undefined, undefined)(config));
103
- const input = HttpClient__Put(_.httpClient, ConfigService__getAccountBaseUrl(_, partnerId, accountId), bodyContent);
104
- return singleton.Bind(input, (x$0027) => {
105
- let value_2;
106
- const input_2 = x$0027;
107
- value_2 = ((input_2.tag === 1) ? (new FSharpResult$2(1, [ConfigService__mapResponseError(_, "Failed to update account\'s config", input_2.fields[0])])) : (new FSharpResult$2(0, [input_2.fields[0]])));
108
- return singleton.Return(value_2);
109
- });
110
- });
111
- }
112
-
113
- export function ConfigService__DeleteAccountConfig(_, partnerId, accountId) {
114
- const input = HttpClient__Delete_Z721C83C5(_.httpClient, ConfigService__getAccountBaseUrl(_, partnerId, accountId));
115
- return singleton.Bind(input, (x$0027) => {
116
- let value;
117
- const input_2 = x$0027;
118
- value = ((input_2.tag === 1) ? (new FSharpResult$2(1, [ConfigService__mapResponseError(_, "Failed to delete account\'s config", input_2.fields[0])])) : (new FSharpResult$2(0, [input_2.fields[0]])));
119
- return singleton.Return(value);
120
- });
121
- }
122
-
123
- export function ConfigService__GetConfig(this$, partnerId, accountId) {
124
- if (accountId == null) {
125
- return ConfigService__GetPartnerConfig_Z721C83C5(this$, partnerId);
126
- }
127
- else {
128
- return ConfigService__GetAccountConfig(this$, partnerId, accountId);
129
- }
130
- }
131
-
132
- export function ConfigService__UpdateConfig(this$, partnerId, accountId, config) {
133
- if (accountId == null) {
134
- return ConfigService__UpdatePartnerConfig(this$, partnerId, config);
135
- }
136
- else {
137
- return ConfigService__UpdateAccountConfig(this$, partnerId, accountId, config);
138
- }
139
- }
140
-
141
- export function ConfigService__DeleteConfig(this$, partnerId, accountId) {
142
- if (accountId == null) {
143
- return ConfigService__DeletePartnerConfig_Z721C83C5(this$, partnerId);
144
- }
145
- else {
146
- return ConfigService__DeleteAccountConfig(this$, partnerId, accountId);
147
- }
148
- }
149
-
150
- export function ConfigService__getPartnerBaseUrl_1505(this$, partnerId) {
151
- return `${this$.backendUrl}/profiles/admin/partners/${partnerId}/config`;
152
- }
153
-
154
- export function ConfigService__getAccountBaseUrl(this$, partnerId, accountId) {
155
- return `${this$.backendUrl}/profiles/admin/partners/${partnerId}/accounts/${accountId}/config`;
156
- }
157
-
158
- export function ConfigService__mapResponseError(this$, defaultErrorMsg, r) {
159
- switch (r.tag) {
160
- case 1:
161
- return r.fields[0];
162
- case 2:
163
- return defaultErrorMsg;
164
- default:
165
- return "Access is denied";
166
- }
167
- }
168
-
@@ -1,137 +0,0 @@
1
- import { Union } from "../../fable_modules/fable-library-js.4.20.0/Types.js";
2
- import { ImportDto_$reflection, PostImportError_$reflection, AccountImportsDto_$reflection } from "../../Basic.Profile.Domain/Import/Api/Read.jsx";
3
- import { class_type, union_type } from "../../fable_modules/fable-library-js.4.20.0/Reflection.js";
4
- import { singleton } from "../../fable_modules/fable-library-js.4.20.0/AsyncBuilder.js";
5
- import { Http_content, Headers_authorization, Http_header, Http_request, Http_method, Http_send } from "../../fable_modules/Fable.SimpleHttp.3.6.0/Http.fs.js";
6
- import { BodyContent, HttpMethod } from "../../fable_modules/Fable.SimpleHttp.3.6.0/Types.fs.js";
7
- import { printf, toText } from "../../fable_modules/fable-library-js.4.20.0/String.js";
8
- import { FSharpResult$2 } from "../../fable_modules/fable-library-js.4.20.0/Result.js";
9
- import { Auto_generateBoxedDecoder_Z6670B51, fromString } from "../../fable_modules/Thoth.Json.10.2.0/Decode.fs.js";
10
- import { uncurry2 } from "../../fable_modules/fable-library-js.4.20.0/Util.js";
11
- import { CaseStrategy } from "../../fable_modules/Thoth.Json.10.2.0/Types.fs.js";
12
-
13
- export class ImportServiceModule_Types_CreateImportResult extends Union {
14
- constructor(tag, fields) {
15
- super();
16
- this.tag = tag;
17
- this.fields = fields;
18
- }
19
- cases() {
20
- return ["Success", "ImportError"];
21
- }
22
- }
23
-
24
- export function ImportServiceModule_Types_CreateImportResult_$reflection() {
25
- return union_type("Basic.Profile.UI.Superhero.Directory.BackendServices.ImportServiceModule.Types.CreateImportResult", [], ImportServiceModule_Types_CreateImportResult, () => [[["Item", AccountImportsDto_$reflection()]], [["Item", PostImportError_$reflection()]]]);
26
- }
27
-
28
- export class ImportService {
29
- constructor(backendUrl, accountId, accessToken) {
30
- this.accessToken = accessToken;
31
- this.baseUrl = (`${backendUrl}/profiles/admin/accounts/${accountId}/imports`);
32
- }
33
- }
34
-
35
- export function ImportService_$reflection() {
36
- return class_type("Basic.Profile.UI.Superhero.Directory.BackendServices.ImportService", undefined, ImportService);
37
- }
38
-
39
- export function ImportService_$ctor_30230F9B(backendUrl, accountId, accessToken) {
40
- return new ImportService(backendUrl, accountId, accessToken);
41
- }
42
-
43
- export function ImportService__GetImport_Z524259A4(_, importId) {
44
- return singleton.Delay(() => {
45
- let req_1;
46
- let asyncResult_2;
47
- const input = Http_send((req_1 = Http_method(new HttpMethod(0, []), Http_request(`${_.baseUrl}/${importId}`)), Http_header(Headers_authorization(toText(printf("Bearer %s"))(_.accessToken)), req_1)));
48
- asyncResult_2 = singleton.Bind(input, (x$0027) => singleton.Return(new FSharpResult$2(0, [x$0027])));
49
- return singleton.Bind(asyncResult_2, (input_1_1) => {
50
- const input_4 = input_1_1;
51
- if (input_4.tag === 1) {
52
- return singleton.Return(new FSharpResult$2(1, [input_4.fields[0]]));
53
- }
54
- else {
55
- const response = input_4.fields[0];
56
- if (response.statusCode === 200) {
57
- const value_1_2 = fromString(uncurry2(Auto_generateBoxedDecoder_Z6670B51(ImportDto_$reflection(), new CaseStrategy(1, []), undefined)), response.responseText);
58
- return singleton.Return(value_1_2);
59
- }
60
- else {
61
- return singleton.Return(new FSharpResult$2(1, ["Failed to fetch import"]));
62
- }
63
- }
64
- });
65
- });
66
- }
67
-
68
- export function ImportService__GetImports(_) {
69
- return singleton.Delay(() => {
70
- let req_1;
71
- let asyncResult_2;
72
- const input = Http_send((req_1 = Http_method(new HttpMethod(0, []), Http_request(_.baseUrl)), Http_header(Headers_authorization(toText(printf("Bearer %s"))(_.accessToken)), req_1)));
73
- asyncResult_2 = singleton.Bind(input, (x$0027) => singleton.Return(new FSharpResult$2(0, [x$0027])));
74
- return singleton.Bind(asyncResult_2, (input_1_1) => {
75
- const input_4 = input_1_1;
76
- if (input_4.tag === 1) {
77
- return singleton.Return(new FSharpResult$2(1, [input_4.fields[0]]));
78
- }
79
- else {
80
- const response = input_4.fields[0];
81
- if (response.statusCode === 200) {
82
- const value_1_2 = fromString(uncurry2(Auto_generateBoxedDecoder_Z6670B51(AccountImportsDto_$reflection(), new CaseStrategy(1, []), undefined)), response.responseText);
83
- return singleton.Return(value_1_2);
84
- }
85
- else {
86
- return singleton.Return(new FSharpResult$2(1, ["Failed to fetch account imports"]));
87
- }
88
- }
89
- });
90
- });
91
- }
92
-
93
- export function ImportService__CreateImport_D0E9224(_, formData) {
94
- return singleton.Delay(() => {
95
- let req_2;
96
- let asyncResult_1;
97
- const input = Http_send((req_2 = Http_content(new BodyContent(3, [formData]), Http_method(new HttpMethod(1, []), Http_request(_.baseUrl))), Http_header(Headers_authorization(toText(printf("Bearer %s"))(_.accessToken)), req_2)));
98
- asyncResult_1 = singleton.Bind(input, (x$0027) => singleton.Return(new FSharpResult$2(0, [x$0027])));
99
- return singleton.Bind(asyncResult_1, (input_1_3) => {
100
- const input_12 = input_1_3;
101
- if (input_12.tag === 1) {
102
- return singleton.Return(new FSharpResult$2(1, [input_12.fields[0]]));
103
- }
104
- else {
105
- const response = input_12.fields[0];
106
- const matchValue = response.statusCode | 0;
107
- switch (matchValue) {
108
- case 200: {
109
- let x;
110
- const value_1_2 = fromString(uncurry2(Auto_generateBoxedDecoder_Z6670B51(AccountImportsDto_$reflection(), new CaseStrategy(1, []), undefined)), response.responseText);
111
- x = singleton.Return(value_1_2);
112
- return singleton.Bind(x, (x$0027_1) => {
113
- let value_3;
114
- const input_4 = x$0027_1;
115
- value_3 = ((input_4.tag === 1) ? (new FSharpResult$2(1, [input_4.fields[0]])) : (new FSharpResult$2(0, [new ImportServiceModule_Types_CreateImportResult(0, [input_4.fields[0]])])));
116
- return singleton.Return(value_3);
117
- });
118
- }
119
- case 400: {
120
- let x_2;
121
- const value_1_4 = fromString(uncurry2(Auto_generateBoxedDecoder_Z6670B51(PostImportError_$reflection(), new CaseStrategy(1, []), undefined)), response.responseText);
122
- x_2 = singleton.Return(value_1_4);
123
- return singleton.Bind(x_2, (x$0027_2) => {
124
- let value_6;
125
- const input_8 = x$0027_2;
126
- value_6 = ((input_8.tag === 1) ? (new FSharpResult$2(1, [input_8.fields[0]])) : (new FSharpResult$2(0, [new ImportServiceModule_Types_CreateImportResult(1, [input_8.fields[0]])])));
127
- return singleton.Return(value_6);
128
- });
129
- }
130
- default:
131
- return singleton.Return(new FSharpResult$2(1, ["Failed to create account import"]));
132
- }
133
- }
134
- });
135
- });
136
- }
137
-