ag-common 0.0.393 → 0.0.395

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.
@@ -45,8 +45,8 @@ const stripPKs = (record, keepPk = true) => {
45
45
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
46
46
  return null;
47
47
  }
48
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
49
48
  // @ts-ignore
49
+ // eslint-disable-next-line
50
50
  const { PK, PK1, PK2, PK3, PK4, PK5, L1, L2, L3, L4, L5, L6, type } = record, rest = __rest(record, ["PK", "PK1", "PK2", "PK3", "PK4", "PK5", "L1", "L2", "L3", "L4", "L5", "L6", "type"]);
51
51
  if (keepPk) {
52
52
  //@ts-ignore
@@ -32,7 +32,7 @@ const HeadersRaw = ({ title, image, SiteShort, FullSiteUrl, siteDesc, }) => {
32
32
  react_1.default.createElement("meta", { key: "14", itemProp: "url", content: FullSiteUrl }),
33
33
  react_1.default.createElement("meta", { key: "15", name: "twitter:url", content: FullSiteUrl }),
34
34
  react_1.default.createElement("meta", { key: "16", property: "og:type", content: "website" }),
35
- react_1.default.createElement("meta", { key: "17", name: "twitter:card", content: "summary" }),
35
+ react_1.default.createElement("meta", { key: "17", name: "twitter:card", content: "summary_large_image" }),
36
36
  react_1.default.createElement("meta", { key: "18", name: "robots", content: "index, follow" }),
37
37
  ...imagearr,
38
38
  ];
@@ -1,7 +1,3 @@
1
- export declare function getCookieRaw({ name, cookieDocument, }: {
2
- name: string;
3
- cookieDocument?: string;
4
- }): string | undefined;
5
1
  /**
6
2
  * read chunks. json parse+unb64
7
3
  * parse defaults to JSON.parse. must change if want if type is not an object!
@@ -1,24 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCookieString = exports.getCookieRawWrapper = exports.getCookieRaw = void 0;
3
+ exports.getCookieString = exports.getCookieRawWrapper = void 0;
4
4
  const log_1 = require("../../../common/helpers/log");
5
5
  const string_1 = require("../../../common/helpers/string");
6
- const set_1 = require("./set");
7
- function getCookieRaw({ name, cookieDocument, }) {
8
- const nameeq = `${name}=`;
9
- const ca1 = cookieDocument || (typeof window !== 'undefined' && document.cookie);
10
- if (!ca1 || !(ca1 === null || ca1 === void 0 ? void 0 : ca1.trim())) {
11
- return undefined;
12
- }
13
- const ca = ca1.split(';').map((t) => t.trim());
14
- const c = ca.find((c2) => c2.startsWith(nameeq));
15
- if (c) {
16
- const raw = c.substr(nameeq.length, c.length);
17
- return raw;
18
- }
19
- return undefined;
20
- }
21
- exports.getCookieRaw = getCookieRaw;
6
+ const raw_1 = require("./raw");
22
7
  /**
23
8
  * read chunks. json parse+unb64
24
9
  * parse defaults to JSON.parse. must change if want if type is not an object!
@@ -39,7 +24,7 @@ function getCookieRawWrapper({ name, cookieDocument, defaultValue, parse: parseR
39
24
  let currentCount = 0;
40
25
  // eslint-disable-next-line no-constant-condition
41
26
  while (true) {
42
- const newv = getCookieRaw({
27
+ const newv = (0, raw_1.getCookie)({
43
28
  name: name + currentCount,
44
29
  cookieDocument,
45
30
  });
@@ -54,7 +39,7 @@ function getCookieRawWrapper({ name, cookieDocument, defaultValue, parse: parseR
54
39
  }
55
40
  catch (e) {
56
41
  (0, log_1.warn)('cookie error:', e);
57
- (0, set_1.wipeCookies)(name);
42
+ (0, raw_1.wipeCookies)(name);
58
43
  return defaultValue;
59
44
  }
60
45
  }
@@ -1,4 +1,5 @@
1
1
  export * from './const';
2
2
  export * from './get';
3
+ export * from './raw';
3
4
  export * from './set';
4
5
  export * from './use';
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./const"), exports);
18
18
  __exportStar(require("./get"), exports);
19
+ __exportStar(require("./raw"), exports);
19
20
  __exportStar(require("./set"), exports);
20
21
  __exportStar(require("./use"), exports);
@@ -0,0 +1,26 @@
1
+ /**
2
+ * parse cookie string into key values
3
+ * @param cookieString
4
+ * @returns
5
+ */
6
+ export declare const getAllCookies: (cookieString?: string) => Record<string, string>;
7
+ /** get a cookie by name*/
8
+ export declare const getCookie: ({ name, cookieDocument, }: {
9
+ name: string;
10
+ cookieDocument?: string | undefined;
11
+ }) => string;
12
+ /**
13
+ * expiryDays <0 will delete
14
+ * @param param0
15
+ * @returns
16
+ */
17
+ export declare function setCookie({ name, value, expiryDays, }: {
18
+ name: string;
19
+ value: string;
20
+ /**
21
+ * defaults to 1
22
+ */
23
+ expiryDays?: number;
24
+ }): void;
25
+ /** delete all non httponly cookies */
26
+ export declare function wipeCookies(name: string): void;
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wipeCookies = exports.setCookie = exports.getCookie = exports.getAllCookies = void 0;
4
+ const log_1 = require("../../../common/helpers/log");
5
+ const const_1 = require("./const");
6
+ /**
7
+ * parse cookie string into key values
8
+ * @param cookieString
9
+ * @returns
10
+ */
11
+ const getAllCookies = (cookieString) => {
12
+ const cookieKeyValuePairs = {};
13
+ if (!cookieString) {
14
+ return cookieKeyValuePairs;
15
+ }
16
+ // Split the cookie string into an array of strings
17
+ const cookieArr = cookieString.split(';');
18
+ // Loop through the array of strings
19
+ for (let i = 0; i < cookieArr.length; i++) {
20
+ // Split each string into an array of key and value
21
+ const cookieKeyValue = cookieArr[i].split('=');
22
+ // Add the key value pair to the object
23
+ cookieKeyValuePairs[cookieKeyValue[0].trim()] = cookieKeyValue[1].trim();
24
+ }
25
+ return cookieKeyValuePairs;
26
+ };
27
+ exports.getAllCookies = getAllCookies;
28
+ /** get a cookie by name*/
29
+ const getCookie = ({ name, cookieDocument, }) => { var _a; return (_a = (0, exports.getAllCookies)(cookieDocument)) === null || _a === void 0 ? void 0 : _a[name]; };
30
+ exports.getCookie = getCookie;
31
+ /**
32
+ * expiryDays <0 will delete
33
+ * @param param0
34
+ * @returns
35
+ */
36
+ function setCookie({ name, value, expiryDays = 1, }) {
37
+ if (typeof window === undefined) {
38
+ return;
39
+ }
40
+ const d = new Date();
41
+ d.setTime(d.getTime() + expiryDays * 24 * 60 * 60 * 1000);
42
+ const expires = `expires=${!value || expiryDays < 0 ? const_1.expireDate : d.toUTCString()}`;
43
+ document.cookie = `${name}=${!value ? '' : value};${expires};path=/; SameSite=Strict; Secure`;
44
+ }
45
+ exports.setCookie = setCookie;
46
+ /** delete all non httponly cookies */
47
+ function wipeCookies(name) {
48
+ if (typeof window === 'undefined') {
49
+ (0, log_1.warn)('cant wipe cookies on server');
50
+ return;
51
+ }
52
+ let currentCount = 0;
53
+ // eslint-disable-next-line no-constant-condition
54
+ while (true) {
55
+ if ((0, exports.getCookie)({
56
+ name: name + currentCount,
57
+ cookieDocument: '',
58
+ })) {
59
+ setCookie({ name: name + currentCount, value: '', expiryDays: -1 });
60
+ currentCount += 1;
61
+ }
62
+ else {
63
+ return;
64
+ }
65
+ }
66
+ }
67
+ exports.wipeCookies = wipeCookies;
@@ -1,4 +1,3 @@
1
- export declare function wipeCookies(name: string): void;
2
1
  /**
3
2
  * json+b64 incoming. chunk. write chunks
4
3
  * @param p
@@ -1,45 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.setCookieString = exports.setCookieRawWrapper = exports.wipeCookies = void 0;
4
- const log_1 = require("../../../common/helpers/log");
3
+ exports.setCookieString = exports.setCookieRawWrapper = void 0;
5
4
  const string_1 = require("../../../common/helpers/string");
6
5
  const const_1 = require("./const");
7
- const get_1 = require("./get");
8
- /**
9
- * expiryDays <0 will delete
10
- * @param param0
11
- * @returns
12
- */
13
- function setCookieRaw({ name, value, expiryDays = 1, }) {
14
- if (typeof window === undefined) {
15
- return;
16
- }
17
- const d = new Date();
18
- d.setTime(d.getTime() + expiryDays * 24 * 60 * 60 * 1000);
19
- const expires = `expires=${!value || expiryDays < 0 ? const_1.expireDate : d.toUTCString()}`;
20
- document.cookie = `${name}=${!value ? '' : value};${expires};path=/; SameSite=Strict; Secure`;
21
- }
22
- function wipeCookies(name) {
23
- if (typeof window === 'undefined') {
24
- (0, log_1.warn)('cant wipe cookies on server');
25
- return;
26
- }
27
- let currentCount = 0;
28
- // eslint-disable-next-line no-constant-condition
29
- while (true) {
30
- if ((0, get_1.getCookieRaw)({
31
- name: name + currentCount,
32
- cookieDocument: '',
33
- })) {
34
- setCookieRaw({ name: name + currentCount, value: '', expiryDays: -1 });
35
- currentCount += 1;
36
- }
37
- else {
38
- return;
39
- }
40
- }
41
- }
42
- exports.wipeCookies = wipeCookies;
6
+ const raw_1 = require("./raw");
43
7
  /**
44
8
  * json+b64 incoming. chunk. write chunks
45
9
  * @param p
@@ -52,7 +16,7 @@ function setCookieRawWrapper(p) {
52
16
  }
53
17
  return JSON.stringify(s);
54
18
  };
55
- wipeCookies(p.name);
19
+ (0, raw_1.wipeCookies)(p.name);
56
20
  if (!p.value) {
57
21
  return;
58
22
  }
@@ -60,7 +24,7 @@ function setCookieRawWrapper(p) {
60
24
  const chunks = (0, string_1.chunkString)(str, const_1.maxCookieLen);
61
25
  for (const index1 in chunks) {
62
26
  const chunk = chunks[index1];
63
- setCookieRaw(Object.assign(Object.assign({}, p), { name: p.name + index1, value: chunk }));
27
+ (0, raw_1.setCookie)(Object.assign(Object.assign({}, p), { name: p.name + index1, value: chunk }));
64
28
  }
65
29
  }
66
30
  exports.setCookieRawWrapper = setCookieRawWrapper;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ag-common",
3
- "version": "0.0.393",
3
+ "version": "0.0.395",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "author": "Andrei Gec <@andreigec> (https://gec.dev/)",
@@ -34,15 +34,15 @@
34
34
  "@emotion/styled": ">11"
35
35
  },
36
36
  "devDependencies": {
37
- "@babel/core": "7.20.5",
38
- "@storybook/addon-actions": "6.5.14",
39
- "@storybook/addon-docs": "6.5.14",
40
- "@storybook/addon-essentials": "6.5.14",
41
- "@storybook/addon-interactions": "6.5.14",
42
- "@storybook/addon-links": "6.5.14",
43
- "@storybook/addons": "6.5.14",
44
- "@storybook/react": "6.5.14",
45
- "@storybook/theming": "6.5.14",
37
+ "@babel/core": "7.20.7",
38
+ "@storybook/addon-actions": "6.5.15",
39
+ "@storybook/addon-docs": "6.5.15",
40
+ "@storybook/addon-essentials": "6.5.15",
41
+ "@storybook/addon-interactions": "6.5.15",
42
+ "@storybook/addon-links": "6.5.15",
43
+ "@storybook/addons": "6.5.15",
44
+ "@storybook/react": "6.5.15",
45
+ "@storybook/theming": "6.5.15",
46
46
  "@types/jsonwebtoken": "8.5.9",
47
47
  "@types/node": "18.11.17",
48
48
  "@types/react": "18.0.26",