@airporting/integrations-app 0.1.0 → 0.1.1

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.
@@ -0,0 +1 @@
1
+ export declare function useStatsQuery(): import("@tanstack/react-query").UseQueryResult<import("../../gen/IntegrationsApi").ConnectorsStatsResponse, Error>;
@@ -0,0 +1,2 @@
1
+ import { IntegrationsApi } from '@/src/gen/IntegrationsApi';
2
+ export declare function useApi(): IntegrationsApi<unknown>;
@@ -0,0 +1 @@
1
+ export declare function ConnectorsApp(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,158 @@
1
+ export interface ConnectorsStatsResponse {
2
+ ill: number;
3
+ maintenance: number;
4
+ ok: number;
5
+ }
6
+ export declare namespace Connectors {
7
+ /**
8
+ * No description
9
+ * @tags Connectors
10
+ * @name GetStatsConnectorsV1
11
+ * @request GET:/v1/connectors/stats
12
+ * @response `200` `ConnectorsStatsResponse`
13
+ */
14
+ namespace GetStatsConnectorsV1 {
15
+ type RequestParams = {};
16
+ type RequestQuery = {};
17
+ type RequestBody = never;
18
+ type RequestHeaders = {};
19
+ type ResponseBody = ConnectorsStatsResponse;
20
+ }
21
+ /**
22
+ * No description
23
+ * @tags Connectors
24
+ * @name GetConnectorsV1
25
+ * @request GET:/v1/connectors
26
+ * @response `200` `object`
27
+ */
28
+ namespace GetConnectorsV1 {
29
+ type RequestParams = {};
30
+ type RequestQuery = {};
31
+ type RequestBody = never;
32
+ type RequestHeaders = {};
33
+ type ResponseBody = object;
34
+ }
35
+ /**
36
+ * No description
37
+ * @tags Connectors
38
+ * @name GetIllConnectorsV1
39
+ * @request GET:/v1/connectors/ill
40
+ * @response `200` `object`
41
+ */
42
+ namespace GetIllConnectorsV1 {
43
+ type RequestParams = {};
44
+ type RequestQuery = {};
45
+ type RequestBody = never;
46
+ type RequestHeaders = {};
47
+ type ResponseBody = object;
48
+ }
49
+ }
50
+ export type QueryParamsType = Record<string | number, any>;
51
+ export type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>;
52
+ export interface FullRequestParams extends Omit<RequestInit, 'body'> {
53
+ /** set parameter to `true` for call `securityWorker` for this request */
54
+ secure?: boolean;
55
+ /** request path */
56
+ path: string;
57
+ /** content type of request body */
58
+ type?: ContentType;
59
+ /** query params */
60
+ query?: QueryParamsType;
61
+ /** format of response (i.e. response.json() -> format: "json") */
62
+ format?: ResponseFormat;
63
+ /** request body */
64
+ body?: unknown;
65
+ /** base url */
66
+ baseUrl?: string;
67
+ /** request cancellation token */
68
+ cancelToken?: CancelToken;
69
+ }
70
+ export type RequestParams = Omit<FullRequestParams, 'body' | 'method' | 'query' | 'path'>;
71
+ export interface ApiConfig<SecurityDataType = unknown> {
72
+ baseUrl?: string;
73
+ baseApiParams?: Omit<RequestParams, 'baseUrl' | 'cancelToken' | 'signal'>;
74
+ securityWorker?: (securityData: SecurityDataType | null) => Promise<RequestParams | void> | RequestParams | void;
75
+ customFetch?: typeof fetch;
76
+ }
77
+ export interface HttpResponse<D extends unknown, E extends unknown = unknown> extends Response {
78
+ data: D;
79
+ error: E;
80
+ }
81
+ type CancelToken = Symbol | string | number;
82
+ export declare enum ContentType {
83
+ Json = "application/json",
84
+ JsonApi = "application/vnd.api+json",
85
+ FormData = "multipart/form-data",
86
+ UrlEncoded = "application/x-www-form-urlencoded",
87
+ Text = "text/plain"
88
+ }
89
+ export declare class HttpClient<SecurityDataType = unknown> {
90
+ baseUrl: string;
91
+ private securityData;
92
+ private securityWorker?;
93
+ private abortControllers;
94
+ private customFetch;
95
+ private baseApiParams;
96
+ constructor(apiConfig?: ApiConfig<SecurityDataType>);
97
+ setSecurityData: (data: SecurityDataType | null) => void;
98
+ protected encodeQueryParam(key: string, value: any): string;
99
+ protected addQueryParam(query: QueryParamsType, key: string): string;
100
+ protected addArrayQueryParam(query: QueryParamsType, key: string): any;
101
+ protected toQueryString(rawQuery?: QueryParamsType): string;
102
+ protected addQueryParams(rawQuery?: QueryParamsType): string;
103
+ private contentFormatters;
104
+ protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams;
105
+ protected createAbortSignal: (cancelToken: CancelToken) => AbortSignal | undefined;
106
+ abortRequest: (cancelToken: CancelToken) => void;
107
+ request: <T = any, E = any>({ body, secure, path, type, query, format, baseUrl, cancelToken, ...params }: FullRequestParams) => Promise<HttpResponse<T, E>>;
108
+ }
109
+ /**
110
+ * @title My Cool API
111
+ * @version 1.0
112
+ * @contact
113
+ *
114
+ * Change this info in src/main.ts
115
+ */
116
+ export declare class IntegrationsApi<SecurityDataType extends unknown> {
117
+ http: HttpClient<SecurityDataType>;
118
+ constructor(http: HttpClient<SecurityDataType>);
119
+ /**
120
+ * No description
121
+ *
122
+ * @tags App
123
+ * @name Status
124
+ * @request GET:/status
125
+ * @response `200` `void`
126
+ */
127
+ status: (params?: RequestParams) => Promise<HttpResponse<void, any>>;
128
+ connectors: {
129
+ /**
130
+ * No description
131
+ *
132
+ * @tags Connectors
133
+ * @name GetStatsConnectorsV1
134
+ * @request GET:/v1/connectors/stats
135
+ * @response `200` `ConnectorsStatsResponse`
136
+ */
137
+ getStatsConnectorsV1: (params?: RequestParams) => Promise<HttpResponse<ConnectorsStatsResponse, any>>;
138
+ /**
139
+ * No description
140
+ *
141
+ * @tags Connectors
142
+ * @name GetConnectorsV1
143
+ * @request GET:/v1/connectors
144
+ * @response `200` `object`
145
+ */
146
+ getConnectorsV1: (params?: RequestParams) => Promise<HttpResponse<object, any>>;
147
+ /**
148
+ * No description
149
+ *
150
+ * @tags Connectors
151
+ * @name GetIllConnectorsV1
152
+ * @request GET:/v1/connectors/ill
153
+ * @response `200` `object`
154
+ */
155
+ getIllConnectorsV1: (params?: RequestParams) => Promise<HttpResponse<object, any>>;
156
+ };
157
+ }
158
+ export {};
Binary file
@@ -7,4 +7,4 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element"),REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");function jsxProd(type,config,maybeKey){var key=null;void 0!==maybeKey&&(key=""+maybeKey);void 0!==config.key&&(key=""+config.key);if("key"in config){maybeKey={};for(var propName in config)"key"!==propName&&(maybeKey[propName]=config[propName])}else maybeKey=config;config=maybeKey.ref;return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:key,ref:void 0!==config?config:null,props:maybeKey}}exports.Fragment=REACT_FRAGMENT_TYPE;exports.jsx=jsxProd;exports.jsxs=jsxProd},5893:function(module,__unused_webpack_exports,__webpack_require__){module.exports=__webpack_require__(631)},8504:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Connectors});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(9063);var index_mjs_=__webpack_require__(3215);function App(){return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)("h1",{children:"Hello"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:2,children:"Nos connecteurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{order:3,children:"Synchronisez vos comptes bancaires et outils comptables facilement."}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{data:["Connecteurs actifs","Connecteurs \xe0 configurer","Connecteurs en maintenance","Tous les connecteurs"]})]})}var dist_index_js_=__webpack_require__(7483);var esm_index_mjs_=__webpack_require__(3519);var notifications_esm_index_mjs_=__webpack_require__(225);var modern_index_js_=__webpack_require__(2760);var dist_esm_index_mjs_=__webpack_require__(3040);const AppConfigCtx=/*#__PURE__*/(0,index_js_.createContext)(null);const AppConfigProvider=AppConfigCtx.Provider;const theme=(0,index_mjs_.createTheme)((0,dist_esm_index_mjs_.assign)(dist_index_js_.theme,{components:{}}));const cssVarResolver=x=>(0,dist_esm_index_mjs_.assign)(dist_index_js_.cssVarResolver(x),{dark:{},light:{},variables:{}});function Providers(props){const{children,config,mantine,tanstack}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(AppConfigProvider,{value:config,children:/*#__PURE__*/(0,jsx_runtime.jsx)(modern_index_js_.QueryClientProvider,{client:tanstack?.queryClient??new modern_index_js_.QueryClient,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MantineProvider,{theme:theme,cssVariablesResolver:cssVarResolver,defaultColorScheme:mantine?.defaultColorScheme,forceColorScheme:mantine?.forceColorScheme,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(esm_index_mjs_.ModalsProvider,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(notifications_esm_index_mjs_.Notifications,{}),children]})})})})}function Connectors(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Providers,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(App,{})})})}}}]);
10
+ */var REACT_ELEMENT_TYPE=Symbol.for("react.transitional.element"),REACT_FRAGMENT_TYPE=Symbol.for("react.fragment");function jsxProd(type,config,maybeKey){var key=null;void 0!==maybeKey&&(key=""+maybeKey);void 0!==config.key&&(key=""+config.key);if("key"in config){maybeKey={};for(var propName in config)"key"!==propName&&(maybeKey[propName]=config[propName])}else maybeKey=config;config=maybeKey.ref;return{$$typeof:REACT_ELEMENT_TYPE,type:type,key:key,ref:void 0!==config?config:null,props:maybeKey}}exports.Fragment=REACT_FRAGMENT_TYPE;exports.jsx=jsxProd;exports.jsxs=jsxProd},5893:function(module,__unused_webpack_exports,__webpack_require__){module.exports=__webpack_require__(631)},5080:function(__unused_webpack_module,__webpack_exports__,__webpack_require__){__webpack_require__.r(__webpack_exports__);__webpack_require__.d(__webpack_exports__,{default:()=>Connectors});var jsx_runtime=__webpack_require__(5893);var index_js_=__webpack_require__(9063);var index_mjs_=__webpack_require__(3215);var modern_index_js_=__webpack_require__(2760);class HttpClient{baseUrl="";securityData=null;securityWorker;abortControllers=new Map;customFetch=(...fetchParams)=>fetch(...fetchParams);baseApiParams={credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"};constructor(apiConfig={}){Object.assign(this,apiConfig)}setSecurityData=data=>{this.securityData=data};encodeQueryParam(key,value){const encodedKey=encodeURIComponent(key);return`${encodedKey}=${encodeURIComponent("number"==typeof value?value:`${value}`)}`}addQueryParam(query,key){return this.encodeQueryParam(key,query[key])}addArrayQueryParam(query,key){const value=query[key];return value.map(v=>this.encodeQueryParam(key,v)).join("&")}toQueryString(rawQuery){const query=rawQuery||{};const keys=Object.keys(query).filter(key=>void 0!==query[key]);return keys.map(key=>Array.isArray(query[key])?this.addArrayQueryParam(query,key):this.addQueryParam(query,key)).join("&")}addQueryParams(rawQuery){const queryString=this.toQueryString(rawQuery);return queryString?`?${queryString}`:""}contentFormatters={["application/json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["application/vnd.api+json"]:input=>null!==input&&("object"==typeof input||"string"==typeof input)?JSON.stringify(input):input,["text/plain"]:input=>null!==input&&"string"!=typeof input?JSON.stringify(input):input,["multipart/form-data"]:input=>{if(input instanceof FormData)return input;return Object.keys(input||{}).reduce((formData,key)=>{const property=input[key];formData.append(key,property instanceof Blob?property:"object"==typeof property&&null!==property?JSON.stringify(property):`${property}`);return formData},new FormData)},["application/x-www-form-urlencoded"]:input=>this.toQueryString(input)};mergeRequestParams(params1,params2){return{...this.baseApiParams,...params1,...params2||{},headers:{...this.baseApiParams.headers||{},...params1.headers||{},...params2&&params2.headers||{}}}}createAbortSignal=cancelToken=>{if(this.abortControllers.has(cancelToken)){const abortController=this.abortControllers.get(cancelToken);if(abortController)return abortController.signal;return}const abortController=new AbortController;this.abortControllers.set(cancelToken,abortController);return abortController.signal};abortRequest=cancelToken=>{const abortController=this.abortControllers.get(cancelToken);if(abortController){abortController.abort();this.abortControllers.delete(cancelToken)}};request=async({body,secure,path,type,query,format,baseUrl,cancelToken,...params})=>{const secureParams=("boolean"==typeof secure?secure:this.baseApiParams.secure)&&this.securityWorker&&await this.securityWorker(this.securityData)||{};const requestParams=this.mergeRequestParams(params,secureParams);const queryString=query&&this.toQueryString(query);const payloadFormatter=this.contentFormatters[type||"application/json"];const responseFormat=format||requestParams.format;return this.customFetch(`${baseUrl||this.baseUrl||""}${path}${queryString?`?${queryString}`:""}`,{...requestParams,headers:{...requestParams.headers||{},...type&&"multipart/form-data"!==type?{"Content-Type":type}:{}},signal:(cancelToken?this.createAbortSignal(cancelToken):requestParams.signal)||null,body:null==body?null:payloadFormatter(body)}).then(async response=>{const r=response;r.data=null;r.error=null;const data=responseFormat?await response[responseFormat]().then(data=>{if(r.ok)r.data=data;else r.error=data;return r}).catch(e=>{r.error=e;return r}):r;if(cancelToken)this.abortControllers.delete(cancelToken);if(!response.ok)throw data;return data})}}class IntegrationsApi{http;constructor(http){this.http=http}status=(params={})=>this.http.request({path:"/status",method:"GET",...params});connectors={getStatsConnectorsV1:(params={})=>this.http.request({path:"/v1/connectors/stats",method:"GET",format:"json",...params}),getConnectorsV1:(params={})=>this.http.request({path:"/v1/connectors",method:"GET",format:"json",...params}),getIllConnectorsV1:(params={})=>this.http.request({path:"/v1/connectors/ill",method:"GET",format:"json",...params})}}const AppConfigCtx=/*#__PURE__*/(0,index_js_.createContext)(null);const AppConfigProvider=AppConfigCtx.Provider;function useAppConfig(){const config=(0,index_js_.useContext)(AppConfigCtx);if(!config)throw new Error("Called `useAppConfig` outside a `<AppConfigProvider />`");return config}function useApi(){const config=useAppConfig();const client=new HttpClient({baseUrl:config.api.replace(/\/$/,""),baseApiParams:{headers:{Authorization:config.token?`Bearer ${config.token}`:"",From:config.owner}}});return new IntegrationsApi(client)}function useStatsQuery(){const api=useApi();const query=(0,modern_index_js_.useQuery)({queryKey:["connectors","stats"],queryFn:async()=>await api.connectors.getStatsConnectorsV1().then(x=>x.data),refetchIntervalInBackground:false,refetchOnWindowFocus:true,refetchOnReconnect:true});return query}function ConnectorsApp(){const statsResultRes=useStatsQuery();const statsResult=statsResultRes.data;console.log(statsResult);return/*#__PURE__*/(0,jsx_runtime.jsxs)(jsx_runtime.Fragment,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{py:16,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(index_mjs_.Stack,{gap:0,children:[/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Title,{w:"fit-content",mb:0,order:1,children:"Nos connecteurs"}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Text,{w:"fit-content",mb:0,c:"dimmed",fz:"h5",children:"Synchronisez vos comptes bancaires et outils comptables facilement."})]})}),/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.Group,{py:16,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.SegmentedControl,{radius:"md",size:"xl",data:[`Connecteurs actifs${statsResult?.ok?` (${statsResult.ok})`:""}`,`Connecteurs \xe0 configurer${statsResult?.ill?` (${statsResult.ill})`:""}`,`Connecteurs en maintenance${statsResult?.maintenance?` (${statsResult.maintenance})`:""}`,"Tous les connecteurs"]})})]})}var dist_index_js_=__webpack_require__(7483);var esm_index_mjs_=__webpack_require__(3519);var notifications_esm_index_mjs_=__webpack_require__(225);var dist_esm_index_mjs_=__webpack_require__(3040);const theme=(0,index_mjs_.createTheme)((0,dist_esm_index_mjs_.assign)(dist_index_js_.theme,{components:{}}));const cssVarResolver=x=>(0,dist_esm_index_mjs_.assign)(dist_index_js_.cssVarResolver(x),{dark:{},light:{},variables:{}});function Providers(props){const{children,config,mantine,tanstack}=props;return/*#__PURE__*/(0,jsx_runtime.jsx)(AppConfigProvider,{value:config,children:/*#__PURE__*/(0,jsx_runtime.jsx)(modern_index_js_.QueryClientProvider,{client:tanstack?.queryClient??new modern_index_js_.QueryClient,children:/*#__PURE__*/(0,jsx_runtime.jsx)(index_mjs_.MantineProvider,{theme:theme,cssVariablesResolver:cssVarResolver,defaultColorScheme:mantine?.defaultColorScheme,forceColorScheme:mantine?.forceColorScheme,children:/*#__PURE__*/(0,jsx_runtime.jsxs)(esm_index_mjs_.ModalsProvider,{children:[/*#__PURE__*/(0,jsx_runtime.jsx)(notifications_esm_index_mjs_.Notifications,{}),children]})})})})}function Connectors(props){return/*#__PURE__*/(0,jsx_runtime.jsx)(index_js_.StrictMode,{children:/*#__PURE__*/(0,jsx_runtime.jsx)(Providers,{...props,children:/*#__PURE__*/(0,jsx_runtime.jsx)(ConnectorsApp,{})})})}}}]);