ag-common 0.0.762 → 0.0.764

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 (64) hide show
  1. package/dist/api/helpers/apigw.d.ts +1 -1
  2. package/dist/api/helpers/apigw.js +6 -8
  3. package/dist/api/helpers/index.d.ts +0 -2
  4. package/dist/api/helpers/index.js +0 -2
  5. package/dist/api/types/index.d.ts +0 -32
  6. package/dist/ui/components/index.d.ts +0 -1
  7. package/dist/ui/components/index.js +0 -1
  8. package/dist/ui/helpers/dom.js +2 -0
  9. package/dist/ui/helpers/index.d.ts +0 -2
  10. package/dist/ui/helpers/index.js +0 -2
  11. package/dist/ui/helpers/jwt.d.ts +0 -12
  12. package/dist/ui/helpers/routes.d.ts +0 -18
  13. package/dist/ui/helpers/useContextMenu.js +3 -0
  14. package/dist/ui/helpers/useIsInViewport.js +1 -0
  15. package/dist/ui/helpers/useOnScroll.js +2 -3
  16. package/package.json +24 -32
  17. package/dist/api/helpers/openApiHelpers.d.ts +0 -43
  18. package/dist/api/helpers/openApiHelpers.js +0 -163
  19. package/dist/api/helpers/validateOpenApi.d.ts +0 -25
  20. package/dist/api/helpers/validateOpenApi.js +0 -127
  21. package/dist/api/openapi-postfix.d.ts +0 -1
  22. package/dist/api/openapi-postfix.js +0 -42
  23. package/dist/api/openapi-prefix.d.ts +0 -1
  24. package/dist/api/openapi-prefix.js +0 -88
  25. package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.d.ts +0 -3
  26. package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.js +0 -69
  27. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.d.ts +0 -6
  28. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.js +0 -30
  29. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.d.ts +0 -2
  30. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.js +0 -31
  31. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.d.ts +0 -11
  32. package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +0 -28
  33. package/dist/ui/components/OpenApiCodeBlock/curl/index.d.ts +0 -6
  34. package/dist/ui/components/OpenApiCodeBlock/curl/index.js +0 -35
  35. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.d.ts +0 -3
  36. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.js +0 -23
  37. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/getFetchLines.d.ts +0 -2
  38. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/getFetchLines.js +0 -19
  39. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.d.ts +0 -3
  40. package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +0 -78
  41. package/dist/ui/components/OpenApiCodeBlock/fetch/index.d.ts +0 -6
  42. package/dist/ui/components/OpenApiCodeBlock/fetch/index.js +0 -24
  43. package/dist/ui/components/OpenApiCodeBlock/helpers/common.d.ts +0 -20
  44. package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +0 -89
  45. package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.d.ts +0 -4
  46. package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +0 -25
  47. package/dist/ui/components/OpenApiCodeBlock/index.d.ts +0 -2
  48. package/dist/ui/components/OpenApiCodeBlock/index.js +0 -17
  49. package/dist/ui/components/OpenApiCodeBlock/types.d.ts +0 -60
  50. package/dist/ui/components/OpenApiCodeBlock/types.js +0 -2
  51. package/dist/ui/helpers/axiosHelper.d.ts +0 -17
  52. package/dist/ui/helpers/axiosHelper.js +0 -92
  53. package/dist/ui/helpers/callOpenApi/cached.d.ts +0 -34
  54. package/dist/ui/helpers/callOpenApi/cached.js +0 -92
  55. package/dist/ui/helpers/callOpenApi/direct.d.ts +0 -9
  56. package/dist/ui/helpers/callOpenApi/direct.js +0 -137
  57. package/dist/ui/helpers/callOpenApi/helpers.d.ts +0 -9
  58. package/dist/ui/helpers/callOpenApi/helpers.js +0 -60
  59. package/dist/ui/helpers/callOpenApi/hook.d.ts +0 -27
  60. package/dist/ui/helpers/callOpenApi/hook.js +0 -82
  61. package/dist/ui/helpers/callOpenApi/index.d.ts +0 -5
  62. package/dist/ui/helpers/callOpenApi/index.js +0 -20
  63. package/dist/ui/helpers/callOpenApi/types.d.ts +0 -19
  64. package/dist/ui/helpers/callOpenApi/types.js +0 -2
@@ -1,60 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.apiResponseToAxiosResponse = void 0;
13
- const array_1 = require("../../../common/helpers/array");
14
- const stream_1 = require("../../../common/helpers/stream");
15
- /**
16
- * shim to convert raw response to an axios style response.
17
- * must convert all DefaultClass requests to the Raw equivalent
18
- * @param p
19
- * @returns
20
- */
21
- const apiResponseToAxiosResponse = (p) => __awaiter(void 0, void 0, void 0, function* () {
22
- try {
23
- const r = yield p();
24
- const r1 = {
25
- status: r.raw.status,
26
- statusText: r.raw.statusText,
27
- data: yield r.value(),
28
- headers: (0, array_1.arrayToObject)(Object.entries(r.raw.headers), (s) => s[0], (s) => s[1]),
29
- config: {},
30
- };
31
- return r1;
32
- }
33
- catch (e) {
34
- const er = e;
35
- //try and get body
36
- let statusText = er.statusText || e.stack || '';
37
- if (er.body) {
38
- try {
39
- const st = yield (0, stream_1.getStringFromStream)(er.body);
40
- statusText = st;
41
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
42
- }
43
- catch (e) {
44
- //
45
- }
46
- }
47
- const ret = {
48
- data: undefined,
49
- status: er.status,
50
- statusText,
51
- headers:
52
- // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
53
- er.headers &&
54
- (0, array_1.arrayToObject)(Object.entries(er.headers), (s) => s[0], (s) => s[1]),
55
- config: {},
56
- };
57
- return ret;
58
- }
59
- });
60
- exports.apiResponseToAxiosResponse = apiResponseToAxiosResponse;
@@ -1,27 +0,0 @@
1
- import type { AxiosWrapper } from '../jwt';
2
- import type { CacheItems } from '../routes';
3
- import type { ICallOpenApi } from './types';
4
- export type TUseCallOpenApi<T> = AxiosWrapper<T> & {
5
- loaded: boolean;
6
- loadcount: number;
7
- /** internally mutate state, but do not refetch. will automatically bump datetime */
8
- setData: React.Dispatch<React.SetStateAction<T>>;
9
- };
10
- type TUseCallOpenApiInt<T, TDefaultApi> = ICallOpenApi<T, TDefaultApi> & {
11
- cacheKey: string;
12
- /**
13
- * will shortcut and return the appropriate axioswrapper data if cachekey is found
14
- */
15
- ssrCacheItems?: CacheItems;
16
- /**
17
- * default ttl in seconds for cache - default 120s
18
- */
19
- cacheTtl?: number;
20
- };
21
- /**
22
- * hooks+cached call to callOpenApi
23
- * @param p
24
- * @returns
25
- */
26
- export declare const useCallOpenApi: <T, TDefaultApi>(inConfig: TUseCallOpenApiInt<T, TDefaultApi>) => TUseCallOpenApi<T>;
27
- export {};
@@ -1,82 +0,0 @@
1
- "use strict";
2
- 'use client';
3
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
- return new (P || (P = Promise))(function (resolve, reject) {
6
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
- step((generator = generator.apply(thisArg, _arguments || [])).next());
10
- });
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.useCallOpenApi = void 0;
14
- const react_1 = require("react");
15
- const useGranularHook_1 = require("../useGranularHook");
16
- const cached_1 = require("./cached");
17
- const direct_1 = require("./direct");
18
- const defaultState = (p,
19
- /**
20
- * default false
21
- */
22
- noSsr = false) => {
23
- var _a;
24
- const cachedData = noSsr
25
- ? undefined
26
- : (_a = (0, cached_1.callOpenApiCachedRaw)(Object.assign(Object.assign({}, p), { onlyCached: true }))) === null || _a === void 0 ? void 0 : _a.data;
27
- return Object.assign(Object.assign({ data: undefined, datetime: 0, loadcount: 0, loading: false }, (cachedData && { data: cachedData })), { loaded: !!cachedData });
28
- };
29
- /**
30
- * hooks+cached call to callOpenApi
31
- * @param p
32
- * @returns
33
- */
34
- const useCallOpenApi = (inConfig) => {
35
- /** response from hook */
36
- const [resp, setResp] = (0, react_1.useState)(defaultState(inConfig));
37
- /** config about hook*/
38
- const [config, setConfig] = (0, react_1.useState)(inConfig);
39
- (0, useGranularHook_1.useGranularEffect)(() => {
40
- if (JSON.stringify(Object.assign(Object.assign({}, config), { headers: undefined, ssrCacheItems: undefined, overrideAuth: undefined })) !==
41
- JSON.stringify(Object.assign(Object.assign({}, inConfig), { headers: undefined, ssrCacheItems: undefined, overrideAuth: undefined }))) {
42
- setConfig(inConfig);
43
- setResp(Object.assign(Object.assign({}, defaultState(inConfig, true)), { loading: true }));
44
- void (0, direct_1.callOpenApi)(inConfig).then((r) => setResp((r2) => (Object.assign(Object.assign(Object.assign({}, r2), r), { loading: false }))));
45
- }
46
- }, [inConfig], [resp, setResp, config, setConfig]);
47
- const reFetch = (0, react_1.useCallback)(() => __awaiter(void 0, void 0, void 0, function* () {
48
- const newdate = new Date().getTime();
49
- const newresp = yield (0, direct_1.callOpenApi)(config);
50
- setResp((d) => {
51
- let newState = Object.assign(Object.assign({}, d), { loaded: true, loading: false });
52
- if (newdate > d.datetime) {
53
- newState = Object.assign(Object.assign({}, newresp), { loaded: true, loading: false, loadcount: d.loadcount + 1, datetime: newdate });
54
- }
55
- if (JSON.stringify(d) !== JSON.stringify(newState)) {
56
- return newState;
57
- }
58
- else {
59
- return d;
60
- }
61
- });
62
- }), [config]);
63
- (0, react_1.useEffect)(() => {
64
- const { error, loaded, loading, loadcount } = resp;
65
- const ng = config.disabled || loaded || loading || (error && loadcount > 2);
66
- if (ng) {
67
- return;
68
- }
69
- setResp((d) => (Object.assign(Object.assign({}, d), { loading: true })));
70
- void reFetch();
71
- }, [config.disabled, reFetch, resp]);
72
- const ret = Object.assign(Object.assign({}, resp), { reFetch, setData: (p) => __awaiter(void 0, void 0, void 0, function* () {
73
- //wipe cache, or might revert
74
- yield (0, cached_1.setOpenApiCacheRaw)(config, undefined);
75
- //ensure datetime is changed, or might get overwritten
76
- setResp((x) => (Object.assign(Object.assign({}, x), { datetime: new Date().getTime(), data: typeof p === 'function'
77
- ? p(x.data)
78
- : p })));
79
- }) });
80
- return ret;
81
- };
82
- exports.useCallOpenApi = useCallOpenApi;
@@ -1,5 +0,0 @@
1
- export * from './cached';
2
- export * from './direct';
3
- export * from './helpers';
4
- export * from './hook';
5
- export type * from './types';
@@ -1,20 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./cached"), exports);
18
- __exportStar(require("./direct"), exports);
19
- __exportStar(require("./helpers"), exports);
20
- __exportStar(require("./hook"), exports);
@@ -1,19 +0,0 @@
1
- import type { AxiosResponse } from 'axios';
2
- import type { User } from '../jwt';
3
- export interface OverrideAuth {
4
- id_token?: string;
5
- }
6
- export interface ICallOpenApi<T, TDefaultApi> {
7
- func: (f: TDefaultApi) => Promise<AxiosResponse<T>>;
8
- apiUrl: string;
9
- overrideAuth?: OverrideAuth;
10
- logout: () => void;
11
- refreshToken: () => Promise<User | undefined>;
12
- newDefaultApi: (config: any) => TDefaultApi;
13
- disabled?: boolean;
14
- headers?: Record<string, string | number>;
15
- }
16
- export interface ApiResponse<T> {
17
- raw: Response;
18
- value(): Promise<T>;
19
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });