octopian-configuration-apis 1.0.0

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 (49) hide show
  1. package/README.md +104 -0
  2. package/package.json +18 -0
  3. package/src/CoreServices/configurationServices.js +1501 -0
  4. package/src/CoreServices/darAlBerServices.js +239 -0
  5. package/src/config.js +22 -0
  6. package/src/index.d.ts +908 -0
  7. package/src/index.js +101 -0
  8. package/src/modals/input-modals/CreateNewCorrespondenceInput.ts +7 -0
  9. package/src/modals/input-modals/GetAssetBlazorViewInput.ts +4 -0
  10. package/src/modals/input-modals/GetAssetListInput.ts +8 -0
  11. package/src/modals/input-modals/GetAttributeTypesInput.ts +6 -0
  12. package/src/modals/input-modals/GetDABAssetsInput.ts +4 -0
  13. package/src/modals/input-modals/GetDocumentTypesInput.ts +6 -0
  14. package/src/modals/input-modals/GetInteractorListInput.ts +5 -0
  15. package/src/modals/input-modals/GetItemListInput.ts +8 -0
  16. package/src/modals/input-modals/GetPositionsInput.ts +6 -0
  17. package/src/modals/input-modals/GetRoleListByPermissionInput.ts +13 -0
  18. package/src/modals/input-modals/GetServiceAttributeListInput.ts +8 -0
  19. package/src/modals/input-modals/GetServiceCategoryInput.ts +6 -0
  20. package/src/modals/input-modals/GetServiceListInput.ts +10 -0
  21. package/src/modals/input-modals/GetServiceStepListInput.ts +8 -0
  22. package/src/modals/input-modals/GetServiceSubCategoryInput.ts +7 -0
  23. package/src/modals/input-modals/GetStepTypesInput.ts +7 -0
  24. package/src/modals/input-modals/LoginUserInput.ts +8 -0
  25. package/src/modals/input-modals/MaintainAttributeListInput.ts +6 -0
  26. package/src/modals/input-modals/MaintainAttributeTypeInput.ts +142 -0
  27. package/src/modals/input-modals/MaintainSubCategoryInput.ts +6 -0
  28. package/src/modals/output-modals/BaseResponse.ts +13 -0
  29. package/src/modals/output-modals/GetAssetBlazorViewOutput.ts +11 -0
  30. package/src/modals/output-modals/GetAssetListOutput.ts +92 -0
  31. package/src/modals/output-modals/GetAttributeTypesOutput.ts +37 -0
  32. package/src/modals/output-modals/GetDefaultConfigurationOutput.ts +273 -0
  33. package/src/modals/output-modals/GetDocumentTypesOutput.ts +23 -0
  34. package/src/modals/output-modals/GetInteractorListOutput.ts +81 -0
  35. package/src/modals/output-modals/GetInteractorTypeListOutput.ts +59 -0
  36. package/src/modals/output-modals/GetItemListOutput.ts +92 -0
  37. package/src/modals/output-modals/GetPositionsOutput.ts +10 -0
  38. package/src/modals/output-modals/GetRoleListByPermissionOutput.ts +18 -0
  39. package/src/modals/output-modals/GetServiceAttributeListOutput.ts +95 -0
  40. package/src/modals/output-modals/GetServiceCategoryOutput.ts +62 -0
  41. package/src/modals/output-modals/GetServiceListOutput.ts +183 -0
  42. package/src/modals/output-modals/GetServiceStepListOutput.ts +163 -0
  43. package/src/modals/output-modals/GetServiceSubCategoryOuput.ts +71 -0
  44. package/src/modals/output-modals/GetStepTypesOutput.ts +7 -0
  45. package/src/modals/output-modals/GetUnitListOutput.ts +27 -0
  46. package/src/modals/output-modals/LoginUserOutput.ts +8 -0
  47. package/src/sdkUtilities.js +22 -0
  48. package/src/web-services/apiConstants.js +99 -0
  49. package/src/web-services/apiHandler.js +154 -0
@@ -0,0 +1,154 @@
1
+ import axios from "axios";
2
+ import { GetConfig } from "../sdkUtilities";
3
+
4
+ export async function PostMethod(
5
+ uri,
6
+ inputDTO,
7
+ token = null,
8
+ timeout = 30000,
9
+ headerValue = null
10
+ ) {
11
+ let apiKey = GetConfig("APIKey");
12
+ let DomainName = GetConfig("DomainName");
13
+ let SavedToken = GetConfig("Token");
14
+ try {
15
+ // console.log("post request to",DomainName + uri);
16
+ let requestBody = inputDTO != null ? JSON.stringify(inputDTO) : "{}";
17
+ const config = {
18
+ headers: {
19
+ Accept: "application/json",
20
+ "Content-Type": "application/json",
21
+ Authorization: token
22
+ ? `Bearer ${token}`
23
+ : SavedToken
24
+ ? `Bearer ${SavedToken}`
25
+ : "",
26
+ "Ocp-Apim-Subscription-Key": apiKey,
27
+ },
28
+ timeout: timeout,
29
+ };
30
+ // console.log("request input", requestBody);
31
+
32
+ let response = await axios.post(DomainName + uri, requestBody, config);
33
+ if (headerValue) {
34
+ response.data["HeaderValue"] = response.headers.get(headerValue);
35
+ }
36
+ // console.log("request output", response.data);
37
+ return response.data;
38
+ } catch (error) {
39
+ // console.log("error response", error);
40
+
41
+ if (error.code === "ECONNABORTED") {
42
+ return {
43
+ Message: "Error",
44
+ StatusCode: -1,
45
+ Result:
46
+ "Request timeout, please check your connection and try again later!",
47
+ };
48
+ } else {
49
+ return {
50
+ Message: "Error",
51
+ StatusCode: error.response ? error.response.status : 500,
52
+ Result: error.message || "An unexpected error occurred.",
53
+ };
54
+ }
55
+ }
56
+ }
57
+
58
+ export async function GetMethod(uri, token, timeout = 30000) {
59
+ try {
60
+ let apiKey = GetConfig("APIKey");
61
+ let DomainName = GetConfig("DomainName");
62
+ let SavedToken = GetConfig("Token");
63
+
64
+ const config = {
65
+ headers: {
66
+ Accept: "application/json",
67
+ "Content-Type": "application/json",
68
+ Authorization: token
69
+ ? `Bearer ${token}`
70
+ : SavedToken
71
+ ? `Bearer ${SavedToken}`
72
+ : "",
73
+ "Ocp-Apim-Subscription-Key": apiKey,
74
+ },
75
+ timeout: timeout,
76
+ };
77
+ let response = await axios.get(DomainName + uri, config);
78
+
79
+ return response.data;
80
+ } catch (error) {
81
+ // console.log("error response", error);
82
+ if (error.code === "ECONNABORTED") {
83
+ return {
84
+ Message: "Error",
85
+ StatusCode: -1,
86
+ Result:
87
+ "Request timeout, please check your connection and try again later!",
88
+ };
89
+ } else {
90
+ return {
91
+ Message: "Error",
92
+ StatusCode: error.response ? error.response.status : 500,
93
+ Result: error.message || "An unexpected error occurred.",
94
+ };
95
+ }
96
+ }
97
+ }
98
+
99
+ export async function UploadBlob(writeSAS, file, fileName) {
100
+ try {
101
+ const sasContainerUri = writeSAS.split("?")[0];
102
+
103
+ const sasToken = writeSAS.split("?")[1]; // you may need to play with other html verbs in this string e.g., `sp`, `ss` e.t.c.
104
+
105
+ // const localUri =
106
+ // Platform.OS === "ios" ? file.uri.replace("file://", "/") : file.uri;
107
+ const Name = guidGenerator();
108
+ const customBlobName = `${Name}.${file.uri.split(".").pop()}`;
109
+ const assetPath = `${sasContainerUri}/${fileName}/${customBlobName}`;
110
+ await axios.put(`${assetPath}?${sasToken}`, file, {
111
+ headers: {
112
+ "x-ms-blob-type": "BlockBlob", // Specify blob type
113
+ "content-type": "application/octet-stream",
114
+ "x-ms-blob-content-type": file.type,
115
+ },
116
+ }); //.then(function (response) {
117
+ return `${fileName}/${customBlobName}`;
118
+ //});;
119
+ // await RNFetchBlob.fetch(
120
+ // "PUT",
121
+ // `${assetPath}?${sasToken}`,
122
+ // {
123
+ // "x-ms-blob-type": "BlockBlob",
124
+ // "content-type": "application/octet-stream",
125
+ // "x-ms-blob-content-type": file.type,
126
+ // },
127
+ // RNFetchBlob.wrap(localUri)
128
+ // );
129
+ } catch (error) {
130
+ // Alert.alert("Failed","error")
131
+ // console.log(error);
132
+ return null;
133
+ }
134
+ }
135
+
136
+ function guidGenerator() {
137
+ const S4 = function () {
138
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
139
+ };
140
+ return (
141
+ S4() +
142
+ S4() +
143
+ "-" +
144
+ S4() +
145
+ "-" +
146
+ S4() +
147
+ "-" +
148
+ S4() +
149
+ "-" +
150
+ S4() +
151
+ S4() +
152
+ S4()
153
+ );
154
+ }