ag-common 0.0.691 → 0.0.693

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 (33) hide show
  1. package/dist/api/helpers/api.d.ts +7 -7
  2. package/dist/api/helpers/dynamo.d.ts +1 -1
  3. package/dist/api/helpers/enforceDynamoProvisionCap.d.ts +3 -3
  4. package/dist/api/helpers/s3.d.ts +2 -3
  5. package/dist/api/helpers/ssmInfra/dynamo.d.ts +1 -1
  6. package/dist/common/helpers/binary.d.ts +2 -0
  7. package/dist/common/helpers/binary.js +13 -3
  8. package/dist/common/helpers/secondsInNearest.d.ts +1 -1
  9. package/dist/ui/components/BarChart/Base.d.ts +2 -2
  10. package/dist/ui/components/BarChart/Item.d.ts +3 -3
  11. package/dist/ui/components/BarChart/TooltipContent.d.ts +1 -1
  12. package/dist/ui/components/BarChart/getLegendItems.d.ts +1 -1
  13. package/dist/ui/components/HorizontalScrollBar/index.d.ts +1 -1
  14. package/dist/ui/components/Modal/Dialog.d.ts +4 -1
  15. package/dist/ui/components/Modal/Dialog.js +17 -8
  16. package/dist/ui/components/PulseRing/index.d.ts +9 -9
  17. package/dist/ui/components/TextEdit/ListboxEdit.d.ts +2 -2
  18. package/dist/ui/components/Toast/base.d.ts +1 -1
  19. package/dist/ui/helpers/axiosHelper.d.ts +4 -4
  20. package/dist/ui/helpers/cookie/raw.d.ts +1 -1
  21. package/dist/ui/helpers/routes.d.ts +3 -3
  22. package/dist/ui/helpers/useOverloadPageSearch.d.ts +1 -1
  23. package/dist/ui/helpers/useQueryString.d.ts +3 -3
  24. package/dist/ui/icons/Checkmark.d.ts +3 -3
  25. package/dist/ui/icons/Circle.d.ts +4 -4
  26. package/dist/ui/icons/CircleDot.d.ts +1 -1
  27. package/dist/ui/icons/Computer.d.ts +3 -3
  28. package/dist/ui/icons/CrossIcon.d.ts +2 -2
  29. package/dist/ui/icons/Hamburger.d.ts +1 -1
  30. package/dist/ui/icons/Magnify.d.ts +3 -3
  31. package/dist/ui/icons/Moon.d.ts +3 -3
  32. package/dist/ui/icons/Warning.d.ts +4 -4
  33. package/package.json +3 -3
@@ -1,7 +1,7 @@
1
1
  import type { APIGatewayProxyResult, DYNAMOKEYS } from '../types';
2
2
  export declare const returnCode: <T>(statusCode: number, body?: T, extraHeaders?: {
3
3
  [a: string]: string;
4
- } | undefined, fullSiteUrl?: string) => APIGatewayProxyResult;
4
+ }, fullSiteUrl?: string) => APIGatewayProxyResult;
5
5
  /**
6
6
  * strip all dynamo generated keys. can optionally keep PK
7
7
  * @param record
@@ -22,10 +22,10 @@ export declare const stripPKs: <T>(record: T, keepPk?: boolean) => T;
22
22
  export declare const generateDynamoPKS: ({ type, L1, L2, L3, L4, L5, L6, additionalPKValues, }: {
23
23
  type: string;
24
24
  L1: string;
25
- L2?: string | undefined;
26
- L3?: string | undefined;
27
- L4?: string | undefined;
28
- L5?: string | undefined;
29
- L6?: string | undefined;
30
- additionalPKValues?: string[] | undefined;
25
+ L2?: string;
26
+ L3?: string;
27
+ L4?: string;
28
+ L5?: string;
29
+ L6?: string;
30
+ additionalPKValues?: string[];
31
31
  }) => DYNAMOKEYS;
@@ -56,7 +56,7 @@ export declare const getItemDynamo: <T>({ tableName, pkName, pkValue, }: {
56
56
  }>;
57
57
  export declare const queryDynamo: <T>({ tableName, pkName, pkValue, pkOperator, skName, skValue, skOperator, indexName, limit, startKey, filterName, filterValue, filterOperator, sortAscending, }: IQueryDynamo) => Promise<{
58
58
  data: T[];
59
- startKey?: Key | undefined;
59
+ startKey?: Key;
60
60
  } | {
61
61
  error: string;
62
62
  }>;
@@ -4,13 +4,13 @@ export declare const enforceDynamoProvisionCap: ({ tables, readsMax, writesMax,
4
4
  /**
5
5
  * default 25
6
6
  */
7
- readsMax?: number | undefined;
7
+ readsMax?: number;
8
8
  /**
9
9
  * default 25
10
10
  */
11
- writesMax?: number | undefined;
11
+ writesMax?: number;
12
12
  /**
13
13
  * default false. if true, will throw if cap isnt met. will still throw if exceeds.
14
14
  */
15
- mustEqual?: boolean | undefined;
15
+ mustEqual?: boolean;
16
16
  }) => void;
@@ -2,7 +2,6 @@
2
2
  import { S3Client } from '@aws-sdk/client-s3';
3
3
  import type { StreamingBlobPayloadOutputTypes } from '@smithy/types';
4
4
  import type { Buffer } from 'buffer';
5
- import { error } from '../../common/helpers/log';
6
5
  export declare const setS3: (region: string) => S3Client;
7
6
  export declare const s3: S3Client;
8
7
  export declare const getS3Object: ({ fileurl: { Bucket, Key }, }: {
@@ -32,7 +31,7 @@ export declare function getS3Objects({ bucket, keys, }: {
32
31
  error?: undefined;
33
32
  }, void, unknown>;
34
33
  export declare const putS3Object: ({ Body, Bucket, Key, ContentType, }: {
35
- ContentType?: string | undefined;
34
+ ContentType?: string;
36
35
  Body: string | Blob | Buffer;
37
36
  Bucket: string;
38
37
  Key: string;
@@ -56,7 +55,7 @@ export declare const copyFile: ({ Bucket, fromKey, toKey, deleteSource, }: {
56
55
  fromKey: string;
57
56
  toKey: string;
58
57
  /** if true, will delete original after copy. default false */
59
- deleteSource?: boolean | undefined;
58
+ deleteSource?: boolean;
60
59
  }) => Promise<{
61
60
  error?: string;
62
61
  }>;
@@ -10,5 +10,5 @@ export declare const generateDynamoSSMParams: ({ stack, table, baseKey, gsi, }:
10
10
  stack: Stack;
11
11
  table: dynamodb.ITable;
12
12
  baseKey: string;
13
- gsi?: string[] | undefined;
13
+ gsi?: string[];
14
14
  }) => void;
@@ -1,6 +1,8 @@
1
1
  /// <reference types="node" />
2
2
  import { Buffer } from 'buffer';
3
3
  export declare const toBuffer: (ab: ArrayBuffer) => Buffer;
4
+ export declare function bufferToArrayBuffer(buffer: Buffer): ArrayBuffer;
5
+ export declare function b64ToArrayBuffer(base64: string): ArrayBufferLike;
4
6
  /**
5
7
  * convert an ArrayBuffer (usually from file.arrayBuffer) to base64. Usually on client side before server send
6
8
  * @param buffer
@@ -1,11 +1,20 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.base64ToBinary = exports.arrayBufferToBase64 = exports.toBuffer = void 0;
3
+ exports.base64ToBinary = exports.arrayBufferToBase64 = exports.b64ToArrayBuffer = exports.bufferToArrayBuffer = exports.toBuffer = void 0;
4
4
  const buffer_1 = require("buffer");
5
5
  const base64_1 = require("./string/base64");
6
6
  const toBuffer = (ab) => buffer_1.Buffer.from(ab);
7
7
  exports.toBuffer = toBuffer;
8
- function toArrayBuffer(base64) {
8
+ function bufferToArrayBuffer(buffer) {
9
+ const arrayBuffer = new ArrayBuffer(buffer.length);
10
+ const view = new Uint8Array(arrayBuffer);
11
+ for (let i = 0; i < buffer.length; ++i) {
12
+ view[i] = buffer[i];
13
+ }
14
+ return arrayBuffer;
15
+ }
16
+ exports.bufferToArrayBuffer = bufferToArrayBuffer;
17
+ function b64ToArrayBuffer(base64) {
9
18
  const binary_string = (0, base64_1.fromBase64)(base64);
10
19
  const len = binary_string.length;
11
20
  const bytes = new Uint8Array(len);
@@ -14,6 +23,7 @@ function toArrayBuffer(base64) {
14
23
  }
15
24
  return bytes.buffer;
16
25
  }
26
+ exports.b64ToArrayBuffer = b64ToArrayBuffer;
17
27
  /**
18
28
  * convert an ArrayBuffer (usually from file.arrayBuffer) to base64. Usually on client side before server send
19
29
  * @param buffer
@@ -34,5 +44,5 @@ exports.arrayBufferToBase64 = arrayBufferToBase64;
34
44
  * @param raw
35
45
  * @returns
36
46
  */
37
- const base64ToBinary = (raw) => (0, exports.toBuffer)(toArrayBuffer(raw));
47
+ const base64ToBinary = (raw) => (0, exports.toBuffer)(b64ToArrayBuffer(raw));
38
48
  exports.base64ToBinary = base64ToBinary;
@@ -4,5 +4,5 @@
4
4
  */
5
5
  export declare const secondsInNearest: ({ seconds, precision, }: {
6
6
  seconds: number;
7
- precision?: number | undefined;
7
+ precision?: number;
8
8
  }) => string;
@@ -3,6 +3,6 @@ import { type IVarStyles } from '../../styles/common';
3
3
  import type { IBarChartData } from './types';
4
4
  export declare const BarChart: ({ data: dataRaw, style: sRaw, className, }: {
5
5
  data: IBarChartData[];
6
- style?: Partial<IVarStyles> | undefined;
7
- className?: string | undefined;
6
+ style?: Partial<IVarStyles>;
7
+ className?: string;
8
8
  }) => React.JSX.Element;
@@ -4,9 +4,9 @@ import type { IVarStyles } from '../../styles';
4
4
  import type { IBarChartData } from './types';
5
5
  export declare const Item: ({ data, className, onMouseMove, onMouseLeave, maxWidth, style, }: {
6
6
  data: IBarChartData;
7
- className?: string | undefined;
8
- onMouseMove?: MouseEventHandler<HTMLDivElement> | undefined;
9
- onMouseLeave?: MouseEventHandler<HTMLDivElement> | undefined;
7
+ className?: string;
8
+ onMouseMove?: MouseEventHandler<HTMLDivElement>;
9
+ onMouseLeave?: MouseEventHandler<HTMLDivElement>;
10
10
  maxWidth: number;
11
11
  style: IVarStyles;
12
12
  }) => React.JSX.Element;
@@ -3,6 +3,6 @@ import type { IVarStyles } from '../../styles/common';
3
3
  import type { IBarChartData } from './types';
4
4
  export declare const TooltipContent: ({ data, selectedKey, style, }: {
5
5
  data: IBarChartData;
6
- selectedKey?: string | undefined;
6
+ selectedKey?: string;
7
7
  style: IVarStyles;
8
8
  }) => React.JSX.Element;
@@ -1,7 +1,7 @@
1
1
  import type { IBarChartData } from './types';
2
2
  export declare const getLegendItems: ({ data, selectedKey, }: {
3
3
  data: IBarChartData;
4
- selectedKey?: string | undefined;
4
+ selectedKey?: string;
5
5
  }) => {
6
6
  part: {
7
7
  name: string;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  export declare const HorizontalScrollBar: ({ children, className, }: {
3
3
  children: React.ReactNode;
4
- className?: string | undefined;
4
+ className?: string;
5
5
  }) => React.JSX.Element;
@@ -1,5 +1,8 @@
1
1
  import type { CSSProperties } from 'react';
2
- export declare const ModalDialog: (content: JSX.Element, opt?: {
2
+ import React from 'react';
3
+ export declare const ModalDialog: (content: React.ReactNode | ((p: {
4
+ close: () => void;
5
+ }) => React.ReactNode), opt?: {
3
6
  style?: CSSProperties;
4
7
  portalId?: string;
5
8
  }) => Promise<string | undefined>;
@@ -20,18 +20,27 @@ const ModalDialog = (content, opt) => __awaiter(void 0, void 0, void 0, function
20
20
  return new Promise((res) => {
21
21
  const wrapper = document.body.appendChild(document.createElement('div'));
22
22
  const root = (0, client_1.createRoot)(wrapper);
23
+ const onClose = () => {
24
+ try {
25
+ root.unmount();
26
+ wrapper.remove();
27
+ }
28
+ catch (e) {
29
+ //
30
+ }
31
+ };
23
32
  root.render(react_1.default.createElement(Modal_1.Modal, { open: true, setOpen: (o) => {
24
33
  if (!o) {
25
- try {
26
- root.unmount();
27
- wrapper.remove();
28
- }
29
- catch (e) {
30
- //
31
- }
34
+ onClose();
32
35
  }
33
36
  res('ok');
34
- }, topPosition: "center", position: "center", style: opt === null || opt === void 0 ? void 0 : opt.style }, content));
37
+ }, topPosition: "center", position: "center", style: opt === null || opt === void 0 ? void 0 : opt.style }, typeof content !== 'function'
38
+ ? content
39
+ : content({
40
+ close: () => {
41
+ onClose();
42
+ },
43
+ })));
35
44
  });
36
45
  });
37
46
  exports.ModalDialog = ModalDialog;
@@ -2,18 +2,18 @@ import type { CSSProperties } from 'react';
2
2
  import React from 'react';
3
3
  export declare const PulseRing: ({ style, className, text, title, }: {
4
4
  /** tooltip text */
5
- title?: string | undefined;
5
+ title?: string;
6
6
  /** bubble text */
7
- text?: string | undefined;
8
- className?: string | undefined;
9
- style?: (CSSProperties & {
7
+ text?: string;
8
+ className?: string;
9
+ style?: CSSProperties & {
10
10
  /** default 2.5rem */
11
- width?: string | undefined;
11
+ width?: string;
12
12
  /** default 2.5rem */
13
- height?: string | undefined;
13
+ height?: string;
14
14
  /** colour of pulse. default #01a4e9 */
15
- backgroundColor?: string | undefined;
15
+ backgroundColor?: string;
16
16
  /** colour of tex. default #000 */
17
- color?: string | undefined;
18
- }) | undefined;
17
+ color?: string;
18
+ };
19
19
  }) => React.JSX.Element;
@@ -6,9 +6,9 @@ export declare const ListboxEdit: <T>({ defaultValue, onSubmit, values, canEdit,
6
6
  /**
7
7
  * if true can revert or explicit save. default true
8
8
  */
9
- canEdit?: boolean | undefined;
9
+ canEdit?: boolean;
10
10
  /**
11
11
  * can overload the render of the label. defaults to toString
12
12
  */
13
- renderLabel?: ((a: T) => string) | undefined;
13
+ renderLabel?: (a: T) => string;
14
14
  }) => React.JSX.Element;
@@ -12,5 +12,5 @@ export declare const Toast: ({ toast, close, style, }: {
12
12
  }) => React.JSX.Element;
13
13
  export declare const ToastProvider: ({ children, providerOptions, }: {
14
14
  children: React.ReactNode;
15
- providerOptions?: IToastProviderOptions | undefined;
15
+ providerOptions?: IToastProviderOptions;
16
16
  }) => React.JSX.Element;
@@ -7,11 +7,11 @@ import type { AxiosResponse } from 'axios';
7
7
  export declare const axiosHelper: <TOut>({ verb, url, body, headers, timeout, retryMax, onStaleAuth, }: {
8
8
  headers?: {
9
9
  [a: string]: string;
10
- } | undefined;
10
+ };
11
11
  verb: 'put' | 'post' | 'get' | 'patch' | 'delete';
12
12
  url: string;
13
13
  body?: unknown;
14
- timeout?: number | undefined;
15
- retryMax?: number | undefined;
16
- onStaleAuth?: (() => void) | undefined;
14
+ timeout?: number;
15
+ retryMax?: number;
16
+ onStaleAuth?: () => void;
17
17
  }) => Promise<AxiosResponse<TOut>>;
@@ -7,7 +7,7 @@ export declare const getAllCookies: (cookieString?: string) => Partial<Record<st
7
7
  /** get a cookie by name*/
8
8
  export declare const getCookie: ({ name, cookieDocument, }: {
9
9
  name: string;
10
- cookieDocument?: string | undefined;
10
+ cookieDocument?: string;
11
11
  }) => string | undefined;
12
12
  /**
13
13
  * expiryDays <0 will delete
@@ -45,10 +45,10 @@ export declare const getClientReqHref: () => IRequestCommon;
45
45
  * @returns
46
46
  */
47
47
  export declare const getClientOrServerReqHref: ({ url, query, userAgent, }: {
48
- url?: URLLite | undefined;
49
- query?: Record<string, string> | undefined;
48
+ url?: URLLite;
49
+ query?: Record<string, string>;
50
50
  /** will use navigator if possible */
51
- userAgent?: string | undefined;
51
+ userAgent?: string;
52
52
  }) => IRequestCommon;
53
53
  /**
54
54
  * get server side parsed url
@@ -2,6 +2,6 @@ export declare const useOverloadPageSearch: ({ disabled, onTrigger, }: {
2
2
  /**
3
3
  * default false
4
4
  */
5
- disabled?: boolean | undefined;
5
+ disabled?: boolean;
6
6
  onTrigger: () => void;
7
7
  }) => void;
@@ -6,7 +6,7 @@ export declare const isServer: boolean;
6
6
  */
7
7
  export declare const useQueryStringRaw: <T>({ name, queryValues, defaultValue, stringify, parse, }: {
8
8
  name: string;
9
- queryValues?: Record<string, string> | undefined;
9
+ queryValues?: Record<string, string>;
10
10
  defaultValue: T;
11
11
  stringify: (v: T) => string | undefined;
12
12
  parse: (v: string | undefined) => T;
@@ -18,7 +18,7 @@ export declare const useQueryStringRaw: <T>({ name, queryValues, defaultValue, s
18
18
  */
19
19
  export declare const useQueryStringArray: ({ name, queryValues, defaultValue, }: {
20
20
  name: string;
21
- queryValues?: Record<string, string> | undefined;
21
+ queryValues?: Record<string, string>;
22
22
  defaultValue: string[];
23
23
  }) => [string[], (v: string[]) => void];
24
24
  /**
@@ -28,7 +28,7 @@ export declare const useQueryStringArray: ({ name, queryValues, defaultValue, }:
28
28
  */
29
29
  export declare const useQueryStringSingle: ({ name, queryValues, defaultValue, }: {
30
30
  name: string;
31
- queryValues?: Record<string, string> | undefined;
31
+ queryValues?: Record<string, string>;
32
32
  /**
33
33
  * default value. default undefined
34
34
  */
@@ -1,8 +1,8 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  import React from 'react';
3
3
  export declare const Checkmark: ({ style, }: {
4
- style?: ({
4
+ style?: {
5
5
  /** change the colour of the tick. default black */
6
- fill?: string | undefined;
7
- } & CSSProperties) | undefined;
6
+ fill?: string;
7
+ } & CSSProperties;
8
8
  }) => React.JSX.Element;
@@ -1,9 +1,9 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  import React from 'react';
3
3
  export declare const Circle: ({ style, dotted, }: {
4
- style?: ({
4
+ style?: {
5
5
  /** change the colour of the circle. default black */
6
- fill?: string | undefined;
7
- } & CSSProperties) | undefined;
8
- dotted?: boolean | undefined;
6
+ fill?: string;
7
+ } & CSSProperties;
8
+ dotted?: boolean;
9
9
  }) => React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  import React from 'react';
3
3
  export declare const CircleDot: ({ style }: {
4
- style?: CSSProperties | undefined;
4
+ style?: CSSProperties;
5
5
  }) => React.JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  import React from 'react';
3
3
  export declare const Computer: ({ style, }: {
4
- style?: ({
4
+ style?: {
5
5
  /** change the colour of the icon. default black */
6
- fill?: string | undefined;
7
- } & CSSProperties) | undefined;
6
+ fill?: string;
7
+ } & CSSProperties;
8
8
  }) => React.JSX.Element;
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  export declare const CrossIcon: ({ className, onClick, }: {
3
- className?: string | undefined;
4
- onClick?: (() => void) | undefined;
3
+ className?: string;
4
+ onClick?: () => void;
5
5
  }) => React.JSX.Element;
@@ -1,4 +1,4 @@
1
1
  import React from 'react';
2
2
  export declare const Hamburger: ({ className }: {
3
- className?: string | undefined;
3
+ className?: string;
4
4
  }) => React.JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  import React from 'react';
3
3
  export declare const Magnify: ({ style, }: {
4
- style?: ({
4
+ style?: {
5
5
  /** change the colour of the icon. default black */
6
- fill?: string | undefined;
7
- } & CSSProperties) | undefined;
6
+ fill?: string;
7
+ } & CSSProperties;
8
8
  }) => React.JSX.Element;
@@ -1,8 +1,8 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  import React from 'react';
3
3
  export declare const Moon: ({ style, }: {
4
- style?: ({
4
+ style?: {
5
5
  /** change the colour of the icon. default black */
6
- fill?: string | undefined;
7
- } & CSSProperties) | undefined;
6
+ fill?: string;
7
+ } & CSSProperties;
8
8
  }) => React.JSX.Element;
@@ -1,9 +1,9 @@
1
1
  import type { CSSProperties } from 'react';
2
2
  import React from 'react';
3
3
  export declare const Warning: ({ style, className, }: {
4
- className?: string | undefined;
5
- style?: ({
4
+ className?: string;
5
+ style?: {
6
6
  /** change the colour of the icon. default #ffc515 */
7
- fill?: string | undefined;
8
- } & CSSProperties) | undefined;
7
+ fill?: string;
8
+ } & CSSProperties;
9
9
  }) => React.JSX.Element;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.0.691",
2
+ "version": "0.0.693",
3
3
  "name": "ag-common",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
@@ -8,9 +8,9 @@
8
8
  "license": "ISC",
9
9
  "scripts": {
10
10
  "preinstall": "npx only-allow pnpm",
11
- "format": "eslint --ext .ts,.tsx src --fix",
11
+ "format": "eslint src --fix",
12
12
  "lint:tsc": "tsc --noEmit",
13
- "lint:eslint": "eslint --ext .ts,.tsx src",
13
+ "lint:eslint": "eslint src",
14
14
  "lint": "pnpm run /^lint:/",
15
15
  "build": "rimraf dist && tsc -p tsconfig.build.json",
16
16
  "start": "cross-env BROWSER=none cross-env storybook dev -p 6006",