@takeshape/util 11.45.5 → 11.47.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.
Files changed (242) hide show
  1. package/dist/cjs/common/arrays.js +42 -0
  2. package/dist/cjs/common/assert.js +9 -0
  3. package/dist/cjs/common/async-noop.js +5 -0
  4. package/dist/cjs/common/billing.js +35 -0
  5. package/dist/cjs/common/clone.js +76 -0
  6. package/dist/cjs/common/delay.js +28 -0
  7. package/dist/cjs/common/draftjs-templates.js +131 -0
  8. package/dist/cjs/common/draftjs.js +807 -0
  9. package/dist/cjs/common/get-image-url.js +8 -0
  10. package/dist/cjs/common/highlight-code.js +33 -0
  11. package/dist/cjs/common/http.js +19 -0
  12. package/dist/cjs/common/index.js +50 -0
  13. package/dist/cjs/common/map.js +7 -0
  14. package/dist/cjs/common/memoize.js +13 -0
  15. package/dist/cjs/common/merge.js +64 -0
  16. package/dist/cjs/common/mime.js +68 -0
  17. package/dist/cjs/common/names.js +13 -0
  18. package/dist/cjs/common/naming.js +65 -0
  19. package/dist/cjs/common/path-to-string.js +10 -0
  20. package/dist/cjs/common/persisted-queries.js +4 -0
  21. package/dist/cjs/common/predicate.js +15 -0
  22. package/dist/cjs/common/set-in.js +13 -0
  23. package/dist/cjs/common/sets.js +19 -0
  24. package/dist/cjs/common/sleep.js +9 -0
  25. package/dist/cjs/common/sort-object.js +16 -0
  26. package/dist/cjs/common/strings.js +74 -0
  27. package/dist/cjs/common/templates.js +109 -0
  28. package/dist/cjs/common/timezone.js +606 -0
  29. package/dist/cjs/common/tracing.js +2 -0
  30. package/dist/cjs/common/types.js +63 -0
  31. package/dist/cjs/common/unix-to-iso.js +15 -0
  32. package/dist/cjs/common/urls.js +9 -0
  33. package/dist/cjs/common/validation.js +5 -0
  34. package/dist/cjs/common/value.js +8 -0
  35. package/dist/cjs/common/visit.js +60 -0
  36. package/dist/cjs/node/encryption.js +31 -0
  37. package/dist/cjs/node/gzip.js +10 -0
  38. package/dist/cjs/node/index.js +19 -0
  39. package/dist/cjs/node/search-params.js +23 -0
  40. package/dist/cjs/package.json +1 -0
  41. package/dist/esm/common/arrays.js +33 -0
  42. package/dist/esm/common/assert.js +5 -0
  43. package/dist/esm/common/async-noop.js +2 -0
  44. package/dist/esm/common/billing.js +29 -0
  45. package/dist/esm/common/clone.js +71 -0
  46. package/dist/esm/common/delay.js +22 -0
  47. package/dist/esm/common/draftjs-templates.js +122 -0
  48. package/dist/esm/common/draftjs.js +792 -0
  49. package/{es → dist/esm/common}/get-image-url.js +2 -7
  50. package/dist/esm/common/highlight-code.js +26 -0
  51. package/dist/esm/common/http.js +15 -0
  52. package/dist/esm/common/index.js +34 -0
  53. package/{es → dist/esm/common}/map.js +2 -2
  54. package/dist/esm/common/memoize.js +6 -0
  55. package/dist/esm/common/merge.js +54 -0
  56. package/dist/esm/common/mime.js +60 -0
  57. package/dist/esm/common/names.js +9 -0
  58. package/dist/esm/common/naming.js +54 -0
  59. package/dist/esm/common/path-to-string.js +6 -0
  60. package/{es → dist/esm/common}/persisted-queries.js +1 -1
  61. package/{es → dist/esm/common}/predicate.js +4 -4
  62. package/dist/esm/common/set-in.js +7 -0
  63. package/dist/esm/common/sets.js +14 -0
  64. package/dist/esm/common/sleep.js +5 -0
  65. package/dist/esm/common/sort-object.js +12 -0
  66. package/dist/esm/common/strings.js +60 -0
  67. package/dist/esm/common/templates.js +95 -0
  68. package/dist/esm/common/timezone.js +602 -0
  69. package/dist/esm/common/tracing.js +1 -0
  70. package/dist/esm/common/types.js +50 -0
  71. package/dist/esm/common/unix-to-iso.js +9 -0
  72. package/dist/esm/common/urls.js +5 -0
  73. package/dist/esm/common/validation.js +2 -0
  74. package/dist/esm/common/value.js +4 -0
  75. package/dist/esm/common/visit.js +52 -0
  76. package/dist/esm/node/encryption.js +25 -0
  77. package/dist/esm/node/gzip.js +4 -0
  78. package/dist/esm/node/index.js +3 -0
  79. package/dist/esm/node/search-params.js +17 -0
  80. package/dist/esm/package.json +1 -0
  81. package/dist/tsconfig.types.tsbuildinfo +1 -0
  82. package/dist/{arrays.d.ts → types/common/arrays.d.ts} +0 -1
  83. package/dist/{assert.d.ts → types/common/assert.d.ts} +0 -1
  84. package/dist/{async-noop.d.ts → types/common/async-noop.d.ts} +0 -1
  85. package/dist/types/common/billing.d.ts +365 -0
  86. package/dist/{clone.d.ts → types/common/clone.d.ts} +0 -1
  87. package/dist/{delay.d.ts → types/common/delay.d.ts} +0 -1
  88. package/dist/{draftjs-templates.d.ts → types/common/draftjs-templates.d.ts} +1 -2
  89. package/dist/{draftjs.d.ts → types/common/draftjs.d.ts} +1 -2
  90. package/dist/{get-image-url.d.ts → types/common/get-image-url.d.ts} +0 -1
  91. package/dist/types/common/highlight-code.d.ts +14 -0
  92. package/dist/{http.d.ts → types/common/http.d.ts} +0 -1
  93. package/dist/types/common/index.d.ts +34 -0
  94. package/dist/{map.d.ts → types/common/map.d.ts} +0 -1
  95. package/dist/{memoize.d.ts → types/common/memoize.d.ts} +0 -1
  96. package/dist/{merge.d.ts → types/common/merge.d.ts} +0 -1
  97. package/dist/{mime.d.ts → types/common/mime.d.ts} +0 -1
  98. package/dist/{names.d.ts → types/common/names.d.ts} +0 -1
  99. package/dist/{naming.d.ts → types/common/naming.d.ts} +0 -1
  100. package/dist/{path-to-string.d.ts → types/common/path-to-string.d.ts} +0 -1
  101. package/dist/{persisted-queries.d.ts → types/common/persisted-queries.d.ts} +0 -1
  102. package/dist/{predicate.d.ts → types/common/predicate.d.ts} +0 -1
  103. package/dist/{set-in.d.ts → types/common/set-in.d.ts} +0 -1
  104. package/dist/{sets.d.ts → types/common/sets.d.ts} +0 -1
  105. package/dist/{sleep.d.ts → types/common/sleep.d.ts} +0 -1
  106. package/dist/{sort-object.d.ts → types/common/sort-object.d.ts} +0 -1
  107. package/dist/{strings.d.ts → types/common/strings.d.ts} +1 -2
  108. package/dist/{templates.d.ts → types/common/templates.d.ts} +1 -2
  109. package/dist/{timezone.d.ts → types/common/timezone.d.ts} +0 -1
  110. package/dist/{tracing.d.ts → types/common/tracing.d.ts} +1 -2
  111. package/dist/{types.d.ts → types/common/types.d.ts} +0 -1
  112. package/dist/{unix-to-iso.d.ts → types/common/unix-to-iso.d.ts} +0 -1
  113. package/dist/{urls.d.ts → types/common/urls.d.ts} +0 -1
  114. package/dist/{validation.d.ts → types/common/validation.d.ts} +0 -1
  115. package/dist/{value.d.ts → types/common/value.d.ts} +0 -1
  116. package/dist/{visit.d.ts → types/common/visit.d.ts} +0 -1
  117. package/dist/{encryption.d.ts → types/node/encryption.d.ts} +0 -1
  118. package/dist/{gzip.d.ts → types/node/gzip.d.ts} +1 -2
  119. package/dist/types/node/index.d.ts +3 -0
  120. package/dist/{search-params.d.ts → types/node/search-params.d.ts} +1 -2
  121. package/package.json +33 -21
  122. package/dist/arrays.d.ts.map +0 -1
  123. package/dist/arrays.js +0 -44
  124. package/dist/assert.d.ts.map +0 -1
  125. package/dist/assert.js +0 -11
  126. package/dist/async-noop.d.ts.map +0 -1
  127. package/dist/async-noop.js +0 -8
  128. package/dist/billing.d.ts +0 -366
  129. package/dist/billing.d.ts.map +0 -1
  130. package/dist/billing.js +0 -48
  131. package/dist/browser.d.ts +0 -2
  132. package/dist/browser.d.ts.map +0 -1
  133. package/dist/browser.js +0 -16
  134. package/dist/clone.d.ts.map +0 -1
  135. package/dist/clone.js +0 -101
  136. package/dist/common.d.ts +0 -32
  137. package/dist/common.d.ts.map +0 -1
  138. package/dist/common.js +0 -346
  139. package/dist/delay.d.ts.map +0 -1
  140. package/dist/delay.js +0 -34
  141. package/dist/draftjs-templates.d.ts.map +0 -1
  142. package/dist/draftjs-templates.js +0 -157
  143. package/dist/draftjs.d.ts.map +0 -1
  144. package/dist/draftjs.js +0 -836
  145. package/dist/encryption.d.ts.map +0 -1
  146. package/dist/encryption.js +0 -33
  147. package/dist/get-image-url.d.ts.map +0 -1
  148. package/dist/get-image-url.js +0 -15
  149. package/dist/gzip.d.ts.map +0 -1
  150. package/dist/gzip.js +0 -11
  151. package/dist/highlight-code.d.ts +0 -15
  152. package/dist/highlight-code.d.ts.map +0 -1
  153. package/dist/highlight-code.js +0 -35
  154. package/dist/http.d.ts.map +0 -1
  155. package/dist/http.js +0 -18
  156. package/dist/index.d.ts +0 -6
  157. package/dist/index.d.ts.map +0 -1
  158. package/dist/index.js +0 -60
  159. package/dist/map.d.ts.map +0 -1
  160. package/dist/map.js +0 -9
  161. package/dist/memoize.d.ts.map +0 -1
  162. package/dist/memoize.js +0 -13
  163. package/dist/merge.d.ts.map +0 -1
  164. package/dist/merge.js +0 -67
  165. package/dist/mime.d.ts.map +0 -1
  166. package/dist/mime.js +0 -37
  167. package/dist/names.d.ts.map +0 -1
  168. package/dist/names.js +0 -15
  169. package/dist/naming.d.ts.map +0 -1
  170. package/dist/naming.js +0 -91
  171. package/dist/path-to-string.d.ts.map +0 -1
  172. package/dist/path-to-string.js +0 -13
  173. package/dist/persisted-queries.d.ts.map +0 -1
  174. package/dist/persisted-queries.js +0 -7
  175. package/dist/predicate.d.ts.map +0 -1
  176. package/dist/predicate.js +0 -17
  177. package/dist/search-params.d.ts.map +0 -1
  178. package/dist/search-params.js +0 -25
  179. package/dist/set-in.d.ts.map +0 -1
  180. package/dist/set-in.js +0 -11
  181. package/dist/sets.d.ts.map +0 -1
  182. package/dist/sets.js +0 -21
  183. package/dist/sleep.d.ts.map +0 -1
  184. package/dist/sleep.js +0 -11
  185. package/dist/sort-object.d.ts.map +0 -1
  186. package/dist/sort-object.js +0 -21
  187. package/dist/strings.d.ts.map +0 -1
  188. package/dist/strings.js +0 -87
  189. package/dist/templates.d.ts.map +0 -1
  190. package/dist/templates.js +0 -120
  191. package/dist/timezone.d.ts.map +0 -1
  192. package/dist/timezone.js +0 -17
  193. package/dist/tracing.d.ts.map +0 -1
  194. package/dist/tracing.js +0 -5
  195. package/dist/types.d.ts.map +0 -1
  196. package/dist/types.js +0 -92
  197. package/dist/unix-to-iso.d.ts.map +0 -1
  198. package/dist/unix-to-iso.js +0 -17
  199. package/dist/urls.d.ts.map +0 -1
  200. package/dist/urls.js +0 -11
  201. package/dist/validation.d.ts.map +0 -1
  202. package/dist/validation.js +0 -8
  203. package/dist/value.d.ts.map +0 -1
  204. package/dist/value.js +0 -11
  205. package/dist/visit.d.ts.map +0 -1
  206. package/dist/visit.js +0 -61
  207. package/es/arrays.js +0 -33
  208. package/es/assert.js +0 -5
  209. package/es/async-noop.js +0 -2
  210. package/es/billing.js +0 -40
  211. package/es/browser.js +0 -1
  212. package/es/clone.js +0 -94
  213. package/es/common.js +0 -31
  214. package/es/delay.js +0 -26
  215. package/es/draftjs-templates.js +0 -147
  216. package/es/draftjs.js +0 -819
  217. package/es/encryption.js +0 -26
  218. package/es/gzip.js +0 -4
  219. package/es/highlight-code.js +0 -26
  220. package/es/http.js +0 -11
  221. package/es/index.js +0 -6
  222. package/es/memoize.js +0 -6
  223. package/es/merge.js +0 -58
  224. package/es/mime.js +0 -29
  225. package/es/names.js +0 -9
  226. package/es/naming.js +0 -78
  227. package/es/path-to-string.js +0 -6
  228. package/es/search-params.js +0 -17
  229. package/es/set-in.js +0 -6
  230. package/es/sets.js +0 -14
  231. package/es/sleep.js +0 -5
  232. package/es/sort-object.js +0 -14
  233. package/es/strings.js +0 -72
  234. package/es/templates.js +0 -105
  235. package/es/timezone.js +0 -10
  236. package/es/tracing.js +0 -1
  237. package/es/types.js +0 -80
  238. package/es/unix-to-iso.js +0 -9
  239. package/es/urls.js +0 -5
  240. package/es/validation.js +0 -2
  241. package/es/value.js +0 -4
  242. package/es/visit.js +0 -53
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getImageUrl = void 0;
4
+ const routing_1 = require("@takeshape/routing");
5
+ function getImageUrl(path, defaultImageConfig, imageBaseUrl, config) {
6
+ return (0, routing_1.getImageUrl)(path, { ...defaultImageConfig, ...config }, { baseUrl: imageBaseUrl });
7
+ }
8
+ exports.getImageUrl = getImageUrl;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.highlightCode = void 0;
7
+ /*
8
+ * The intention is to move all this to the client package in the end, but right now it's here
9
+ * to be shared between the draftjs / mdx implementations, which span the client / server differently.
10
+ */
11
+ const prismjs_1 = __importDefault(require("prismjs"));
12
+ require("prismjs/components/prism-javascript.js");
13
+ require("prismjs/components/prism-markup.js");
14
+ require("prismjs/components/prism-markup-templating.js");
15
+ require("prismjs/components/prism-css.js");
16
+ require("prismjs/components/prism-bash.js");
17
+ require("prismjs/components/prism-django.js");
18
+ require("prismjs/components/prism-twig.js");
19
+ require("prismjs/components/prism-yaml.js");
20
+ require("prismjs/components/prism-graphql.js");
21
+ require("prismjs/components/prism-sass.js");
22
+ require("prismjs/components/prism-scss.js");
23
+ require("prismjs/components/prism-markdown.js");
24
+ require("prismjs/components/prism-json.js");
25
+ const escape_js_1 = __importDefault(require("lodash/escape.js"));
26
+ const highlightCode = (code, lang) => {
27
+ if (lang) {
28
+ const syntax = prismjs_1.default.languages[lang];
29
+ return prismjs_1.default.highlight(code, syntax, lang);
30
+ }
31
+ return (0, escape_js_1.default)(code);
32
+ };
33
+ exports.highlightCode = highlightCode;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getBasicAuthString = void 0;
4
+ const browser_or_node_1 = require("browser-or-node");
5
+ const getBasicAuthString = (basicAuth) => {
6
+ let authString = '';
7
+ if (basicAuth.username) {
8
+ authString += basicAuth.username;
9
+ }
10
+ authString += ':';
11
+ if (basicAuth.password) {
12
+ authString += basicAuth.password;
13
+ }
14
+ /**
15
+ * Not ideal, but this is used in service-providers which is imported into both the client and the api.
16
+ */
17
+ return browser_or_node_1.isBrowser ? window.btoa(authString) : Buffer.from(authString).toString('base64');
18
+ };
19
+ exports.getBasicAuthString = getBasicAuthString;
@@ -0,0 +1,50 @@
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("./arrays.js"), exports);
18
+ __exportStar(require("./assert.js"), exports);
19
+ __exportStar(require("./async-noop.js"), exports);
20
+ __exportStar(require("./billing.js"), exports);
21
+ __exportStar(require("./clone.js"), exports);
22
+ __exportStar(require("./delay.js"), exports);
23
+ __exportStar(require("./draftjs-templates.js"), exports);
24
+ __exportStar(require("./draftjs.js"), exports);
25
+ __exportStar(require("./get-image-url.js"), exports);
26
+ __exportStar(require("./highlight-code.js"), exports);
27
+ __exportStar(require("./http.js"), exports);
28
+ __exportStar(require("./map.js"), exports);
29
+ __exportStar(require("./memoize.js"), exports);
30
+ __exportStar(require("./merge.js"), exports);
31
+ __exportStar(require("./mime.js"), exports);
32
+ __exportStar(require("./names.js"), exports);
33
+ __exportStar(require("./naming.js"), exports);
34
+ __exportStar(require("./path-to-string.js"), exports);
35
+ __exportStar(require("./persisted-queries.js"), exports);
36
+ __exportStar(require("./predicate.js"), exports);
37
+ __exportStar(require("./set-in.js"), exports);
38
+ __exportStar(require("./sets.js"), exports);
39
+ __exportStar(require("./sleep.js"), exports);
40
+ __exportStar(require("./sort-object.js"), exports);
41
+ __exportStar(require("./strings.js"), exports);
42
+ __exportStar(require("./templates.js"), exports);
43
+ __exportStar(require("./timezone.js"), exports);
44
+ __exportStar(require("./tracing.js"), exports);
45
+ __exportStar(require("./types.js"), exports);
46
+ __exportStar(require("./unix-to-iso.js"), exports);
47
+ __exportStar(require("./urls.js"), exports);
48
+ __exportStar(require("./validation.js"), exports);
49
+ __exportStar(require("./value.js"), exports);
50
+ __exportStar(require("./visit.js"), exports);
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapKeysToArray = void 0;
4
+ function mapKeysToArray(map) {
5
+ return Array.from(map.keys());
6
+ }
7
+ exports.mapKeysToArray = mapKeysToArray;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.weakMemoize = void 0;
7
+ const memoize_js_1 = __importDefault(require("lodash/memoize.js"));
8
+ function weakMemoize(fn) {
9
+ const memoized = (0, memoize_js_1.default)(fn);
10
+ memoized.cache = new WeakMap();
11
+ return memoized;
12
+ }
13
+ exports.weakMemoize = weakMemoize;
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.rebaseArray = exports.rebaseObject = exports.mergeWithArrayMerge = exports.mergeWithArrayConcat = void 0;
7
+ const difference_js_1 = __importDefault(require("lodash/difference.js"));
8
+ const isArray_js_1 = __importDefault(require("lodash/isArray.js"));
9
+ const isEqual_js_1 = __importDefault(require("lodash/isEqual.js"));
10
+ const isNull_js_1 = __importDefault(require("lodash/isNull.js"));
11
+ const merge_js_1 = __importDefault(require("lodash/merge.js"));
12
+ const mergeWith_js_1 = __importDefault(require("lodash/mergeWith.js"));
13
+ const omit_js_1 = __importDefault(require("lodash/omit.js"));
14
+ const union_js_1 = __importDefault(require("lodash/union.js"));
15
+ /**
16
+ * Lodash `mergeWith` customizer to concat arrays
17
+ */
18
+ const arrayConcatCustomizer = (value, srcValue) => {
19
+ if ((0, isArray_js_1.default)(value)) {
20
+ return value.concat(srcValue);
21
+ }
22
+ };
23
+ /**
24
+ * Lodash `mergeWith` loaded with a customizer that concatenates arrays for a
25
+ * deeper merge.
26
+ */
27
+ function mergeWithArrayConcat(object, source) {
28
+ return (0, mergeWith_js_1.default)(object, source, arrayConcatCustomizer);
29
+ }
30
+ exports.mergeWithArrayConcat = mergeWithArrayConcat;
31
+ /**
32
+ * Lodash `mergeWith` customizer to merge arrays
33
+ */
34
+ const arrayMergeCustomizer = (value, srcValue) => {
35
+ if ((0, isArray_js_1.default)(value) && (0, isArray_js_1.default)(srcValue)) {
36
+ return (0, merge_js_1.default)(value, srcValue).filter((val) => !(0, isNull_js_1.default)(val));
37
+ }
38
+ };
39
+ /**
40
+ * Lodash `mergeWith` loaded with a customizer that merges arrays at the same
41
+ * object path. Array items set to `null` will be removed.
42
+ */
43
+ function mergeWithArrayMerge(object, source) {
44
+ return (0, mergeWith_js_1.default)(object, source, arrayMergeCustomizer);
45
+ }
46
+ exports.mergeWithArrayMerge = mergeWithArrayMerge;
47
+ function rebaseObject(to, base, from) {
48
+ const fromKeys = Object.keys(from);
49
+ const removedKeys = (0, difference_js_1.default)(Object.keys(base), fromKeys);
50
+ const newObj = (0, omit_js_1.default)(to, removedKeys);
51
+ for (const key of fromKeys) {
52
+ if (!(0, isEqual_js_1.default)(base[key], from[key])) {
53
+ newObj[key] = from[key];
54
+ }
55
+ }
56
+ return newObj;
57
+ }
58
+ exports.rebaseObject = rebaseObject;
59
+ function rebaseArray(to, base, from) {
60
+ const removed = (0, difference_js_1.default)(base, from);
61
+ const added = (0, difference_js_1.default)(from, base);
62
+ return (0, union_js_1.default)((0, difference_js_1.default)(to, removed), added);
63
+ }
64
+ exports.rebaseArray = rebaseArray;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.shouldCompress = exports.contentType = void 0;
7
+ const mime_types_1 = __importDefault(require("mime-types"));
8
+ const compressedMimeTypes = new Set([
9
+ 'application/atom+xml',
10
+ 'application/javascript',
11
+ 'application/json',
12
+ 'application/ld+json',
13
+ 'application/manifest+json',
14
+ 'application/rdf+xml',
15
+ 'application/rss+xml',
16
+ 'application/schema+json',
17
+ 'application/vnd.geo+json',
18
+ 'application/vnd.ms-fontobject',
19
+ 'application/x-font-ttf',
20
+ 'application/x-javascript',
21
+ 'application/x-web-app-manifest+json',
22
+ 'application/xhtml+xml',
23
+ 'application/xml',
24
+ 'font/eot',
25
+ 'font/otf',
26
+ 'font/opentype',
27
+ 'image/bmp',
28
+ 'image/svg+xml',
29
+ 'image/vnd.microsoft.icon',
30
+ 'image/x-icon',
31
+ 'text/cache-manifest',
32
+ 'text/css',
33
+ 'text/html',
34
+ 'text/javascript',
35
+ 'text/plain',
36
+ 'text/vcard',
37
+ 'text/vnd.rim.location.xloc',
38
+ 'text/vtt',
39
+ 'text/x-component',
40
+ 'text/x-cross-domain-policy',
41
+ 'text/xml'
42
+ ]);
43
+ // Application/octetstream
44
+ const DEFAULT_TYPE = mime_types_1.default.lookup('bin');
45
+ /**
46
+ * Gets the content type of the file, based on it's extension.
47
+ * @param {String} src Path to file fow which content type should be evaluated.
48
+ * @return {String} Returns string with content type and charset.
49
+ */
50
+ function contentType(src) {
51
+ let type = (mime_types_1.default.lookup(src) || DEFAULT_TYPE).replace('-', '');
52
+ const charset = mime_types_1.default.charset(type);
53
+ if (charset) {
54
+ type += `; charset=${charset}`;
55
+ }
56
+ return type;
57
+ }
58
+ exports.contentType = contentType;
59
+ /**
60
+ * Determines whether we should compress based on file extension
61
+ * @param {String} src Path to file fow which content type should be evaluated.
62
+ * @return {Boolean} Returns true if we should compress
63
+ */
64
+ function shouldCompress(src) {
65
+ const mimeType = mime_types_1.default.lookup(src);
66
+ return Boolean(mimeType && compressedMimeTypes.has(mimeType));
67
+ }
68
+ exports.shouldCompress = shouldCompress;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getUnusedName = void 0;
4
+ function getUnusedName(names, desiredName) {
5
+ let number = 2;
6
+ let candidate = desiredName;
7
+ while (names.has(candidate)) {
8
+ candidate = `${desiredName}${number}`;
9
+ number++;
10
+ }
11
+ return candidate;
12
+ }
13
+ exports.getUnusedName = getUnusedName;
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.keyName = exports.sharedTopicName = exports.sharedBucketName = exports.variantBucketName = exports.sharedResourceName = exports.variantResourceName = exports.dynamoTableName = exports.prefixName = void 0;
7
+ const camelCase_js_1 = __importDefault(require("lodash/camelCase.js"));
8
+ const kebabCase_js_1 = __importDefault(require("lodash/kebabCase.js"));
9
+ function prefixName(config, params, name) {
10
+ const { withVariant, withRegion, separator } = config;
11
+ const { appName, stage: { env, variant }, region } = params;
12
+ const parts = [appName, env];
13
+ if (withVariant && env !== 'prod' && variant) {
14
+ parts.push(variant);
15
+ }
16
+ if (withRegion) {
17
+ if (!region) {
18
+ throw new Error('Cannot provide a region prefix without a region in context');
19
+ }
20
+ parts.push(region);
21
+ }
22
+ if (name === '*') {
23
+ parts.push(name);
24
+ }
25
+ else if (config.case === 'kebabCase') {
26
+ parts.push((0, kebabCase_js_1.default)(name));
27
+ }
28
+ else if (config.case === 'camelCase') {
29
+ parts.push((0, camelCase_js_1.default)(name));
30
+ }
31
+ else {
32
+ parts.push(name);
33
+ }
34
+ return parts.join(separator);
35
+ }
36
+ exports.prefixName = prefixName;
37
+ function dynamoTableName(params, name) {
38
+ return prefixName({ withVariant: true, withRegion: false, separator: '--' }, params, name);
39
+ }
40
+ exports.dynamoTableName = dynamoTableName;
41
+ exports.variantResourceName = prefixName.bind(null, {
42
+ withVariant: true,
43
+ withRegion: false,
44
+ separator: '--',
45
+ case: 'kebabCase'
46
+ });
47
+ exports.sharedResourceName = prefixName.bind(null, {
48
+ withVariant: false,
49
+ withRegion: false,
50
+ separator: '--',
51
+ case: 'kebabCase'
52
+ });
53
+ function variantBucketName(params, name) {
54
+ return prefixName({ withVariant: true, withRegion: true, separator: '--' }, params, name);
55
+ }
56
+ exports.variantBucketName = variantBucketName;
57
+ function sharedBucketName(params, name) {
58
+ return prefixName({ withVariant: false, withRegion: true, separator: '--' }, params, name);
59
+ }
60
+ exports.sharedBucketName = sharedBucketName;
61
+ exports.sharedTopicName = exports.sharedResourceName;
62
+ function keyName(params, name) {
63
+ return prefixName({ withVariant: true, withRegion: false, separator: '--' }, params, name);
64
+ }
65
+ exports.keyName = keyName;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.pathToString = void 0;
4
+ const pathToString = (array) => {
5
+ return array.reduce((string, item) => {
6
+ const prefix = string === '' ? '' : '.';
7
+ return string + (Number.isNaN(Number(item)) ? prefix + item : `[${item}]`);
8
+ }, '');
9
+ };
10
+ exports.pathToString = pathToString;
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PERSISTED_QUERY_NOT_FOUND_CODE = void 0;
4
+ exports.PERSISTED_QUERY_NOT_FOUND_CODE = 'PERSISTED_QUERY_NOT_FOUND';
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.falsy = exports.equals = exports.not = void 0;
4
+ function not(predicate) {
5
+ return (value) => !predicate(value);
6
+ }
7
+ exports.not = not;
8
+ function equals(a) {
9
+ return (b) => a === b;
10
+ }
11
+ exports.equals = equals;
12
+ function falsy(obj) {
13
+ return !obj;
14
+ }
15
+ exports.falsy = falsy;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.setIn = void 0;
7
+ const clone_js_1 = __importDefault(require("lodash/fp/clone.js"));
8
+ const curry_js_1 = __importDefault(require("lodash/fp/curry.js"));
9
+ const setWith_js_1 = __importDefault(require("lodash/fp/setWith.js"));
10
+ /**
11
+ * Same as lodash/set but does not mutate the arguments
12
+ */
13
+ exports.setIn = (0, curry_js_1.default)((obj, path, value) => (0, setWith_js_1.default)(clone_js_1.default, path, value, (0, clone_js_1.default)(obj)));
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mapSet = exports.addAll = void 0;
4
+ function addAll(set, iterable) {
5
+ for (const value of iterable) {
6
+ set.add(value);
7
+ }
8
+ return set;
9
+ }
10
+ exports.addAll = addAll;
11
+ function mapSet(set, fn) {
12
+ const result = new Array(set.size);
13
+ let i = 0;
14
+ for (const value of set) {
15
+ result[i++] = fn(value);
16
+ }
17
+ return result;
18
+ }
19
+ exports.mapSet = mapSet;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sleep = void 0;
4
+ async function sleep(ms) {
5
+ return new Promise((resolve) => {
6
+ setTimeout(resolve, ms);
7
+ });
8
+ }
9
+ exports.sleep = sleep;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sortObject = void 0;
4
+ /**
5
+ * Object key order is not guarenteed. This can be useful
6
+ * but should not be depended upon.
7
+ */
8
+ const sortObject = (obj) => {
9
+ // Convert object to array of key-value pairs
10
+ const arr = Object.entries(obj);
11
+ // Sort array by key
12
+ arr.sort(([key1], [key2]) => key1.localeCompare(key2));
13
+ // Convert array back to object
14
+ return Object.fromEntries(arr);
15
+ };
16
+ exports.sortObject = sortObject;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.base64Decode = exports.base64Encode = exports.encodePropertyName = exports.isIntegerLike = exports.isEmptyString = exports.isUuid = exports.pascalCase = exports.formatShapeName = exports.camelCase = void 0;
7
+ const browser_or_node_1 = require("browser-or-node");
8
+ const camelCase_js_1 = __importDefault(require("lodash/camelCase.js"));
9
+ const isEmpty_js_1 = __importDefault(require("lodash/isEmpty.js"));
10
+ const isString_js_1 = __importDefault(require("lodash/isString.js"));
11
+ const upperFirst_js_1 = __importDefault(require("lodash/upperFirst.js"));
12
+ const arrays_js_1 = require("./arrays.js");
13
+ exports.camelCase = camelCase_js_1.default;
14
+ function formatShapeName(str, options) {
15
+ const strings = (0, arrays_js_1.ensureArray)(str);
16
+ const shapeNameIndex = options?.shapeNameIndex ?? 0;
17
+ const shapeName = strings.at(shapeNameIndex);
18
+ // If the shapeNameIndex is incorrect, behave as normal
19
+ if (!shapeName) {
20
+ throw new Error(`Could not find a ShapeName at index '${shapeNameIndex}'`);
21
+ }
22
+ const prefix = strings.slice(0, Math.max(shapeNameIndex, 0));
23
+ const suffix = strings.slice(shapeNameIndex + 1);
24
+ let arr = [];
25
+ if (prefix) {
26
+ arr = [...arr, pascalCase(prefix)];
27
+ }
28
+ if (shapeName.length > 2 && shapeName.startsWith('TS') && shapeName.charAt(2) === shapeName.charAt(2).toUpperCase()) {
29
+ // Built-in shape, prefixed with `TS`
30
+ arr = [...arr, shapeName];
31
+ }
32
+ else {
33
+ arr = [...arr, pascalCase(shapeName)];
34
+ }
35
+ if (suffix) {
36
+ arr = [...arr, pascalCase(suffix)];
37
+ }
38
+ return arr.join('');
39
+ }
40
+ exports.formatShapeName = formatShapeName;
41
+ /**
42
+ * Optional config triggers a namespace-preserving behavior for built-in shapes starting with `TS`.
43
+ */
44
+ function pascalCase(str) {
45
+ return (0, upperFirst_js_1.default)((0, exports.camelCase)(str));
46
+ }
47
+ exports.pascalCase = pascalCase;
48
+ function isUuid(str) {
49
+ return Boolean(/\w{8,}(-\w{4,}){3,}-\w{12,}/.exec(str));
50
+ }
51
+ exports.isUuid = isUuid;
52
+ function isEmptyString(str) {
53
+ return (0, isString_js_1.default)(str) && (0, isEmpty_js_1.default)(str);
54
+ }
55
+ exports.isEmptyString = isEmptyString;
56
+ function isIntegerLike(value) {
57
+ if (typeof value === 'number') {
58
+ return true;
59
+ }
60
+ return /^\d+$/.test(value);
61
+ }
62
+ exports.isIntegerLike = isIntegerLike;
63
+ function encodePropertyName(value) {
64
+ return value.replace(/[^A-Za-z0-9]/g, (c) => `%${c.charCodeAt(0).toString(16)}`);
65
+ }
66
+ exports.encodePropertyName = encodePropertyName;
67
+ function base64Encode(str) {
68
+ return browser_or_node_1.isBrowser ? window.btoa(str) : Buffer.from(str).toString('base64');
69
+ }
70
+ exports.base64Encode = base64Encode;
71
+ function base64Decode(str) {
72
+ return browser_or_node_1.isBrowser ? window.atob(str) : Buffer.from(str, 'base64').toString();
73
+ }
74
+ exports.base64Decode = base64Decode;
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.jsonTemplate = exports.codeTemplate = exports.oembedTemplateMdx = exports.oembedTemplate = exports.imageTemplateMdx = exports.imageTemplate = exports.attrs = exports.getApplyPrefix = void 0;
7
+ const routing_1 = require("@takeshape/routing");
8
+ /*
9
+ * The intention is to move all this to the client package in the end, but right now it's here
10
+ * to be shared between the draftjs / mdx implementations, which span the client / server differently.
11
+ */
12
+ const classnames_1 = __importDefault(require("classnames"));
13
+ const escape_js_1 = __importDefault(require("lodash/escape.js"));
14
+ const highlight_code_js_1 = require("./highlight-code.js");
15
+ const types_js_1 = require("./types.js");
16
+ function getApplyPrefix(prefix) {
17
+ return (className) => (className ? prefix + className : '');
18
+ }
19
+ exports.getApplyPrefix = getApplyPrefix;
20
+ function attrs(obj) {
21
+ const attrStrings = [];
22
+ const attrNames = Object.keys(obj);
23
+ attrNames.sort();
24
+ for (const attrName of attrNames) {
25
+ const value = obj[attrName];
26
+ if (value) {
27
+ attrStrings.push(`${attrName}="${(0, escape_js_1.default)(value)}"`);
28
+ }
29
+ }
30
+ return attrStrings.length ? ` ${attrStrings.join(' ')}` : '';
31
+ }
32
+ exports.attrs = attrs;
33
+ function imageTemplate(applyPrefix, data) {
34
+ const { caption, credit, alignment, size, asset, imageParams } = data;
35
+ if (!asset) {
36
+ return '';
37
+ }
38
+ const imageUrl = (0, routing_1.getImageUrl)(asset.path, imageParams);
39
+ let figCaption = '';
40
+ if (caption || credit) {
41
+ const htmlCaption = caption ? `<span class="${applyPrefix('caption')}">${caption}</span>` : '';
42
+ const htmlCredit = credit ? `<span class="${applyPrefix('credit')}">${credit}</span>` : '';
43
+ figCaption = `<figcaption>${htmlCaption} ${htmlCredit}</figcaption>`;
44
+ }
45
+ const classes = (0, classnames_1.default)(applyPrefix(alignment), applyPrefix(size));
46
+ const classAttr = classes ? ` class="${classes}"` : '';
47
+ const imgAttrs = attrs({
48
+ alt: asset.description,
49
+ title: asset.title
50
+ });
51
+ let image = `<img${imgAttrs} src="${imageUrl}"/>`;
52
+ if (data.link?.url) {
53
+ const target = data.link.external ? ' target="blank" rel="noopener noreferrer"' : '';
54
+ image = `<a href="${data.link.url}"${target}>${image}</a>`;
55
+ }
56
+ return `<figure${classAttr}>${image}${figCaption}</figure>`;
57
+ }
58
+ exports.imageTemplate = imageTemplate;
59
+ function renderMdx(tag, attributes, data, children) {
60
+ const tagWithAttributes = `${tag} ${attributes.map((attr) => `${attr}="${(0, escape_js_1.default)(data[attr])}"`).join(' ')}`;
61
+ if (children) {
62
+ return `<${tagWithAttributes}>
63
+ ${children.replace(/[\n\r]+$/, '')}
64
+ </${tag}>`;
65
+ }
66
+ return `<${tagWithAttributes}/>`;
67
+ }
68
+ function imageTemplateMdx(applyPrefix, data) {
69
+ return renderMdx(applyPrefix('Image'), ['id', 'caption', 'credit', 'link', 'linkisexternal', 'alignment', 'size', 'src'], data);
70
+ }
71
+ exports.imageTemplateMdx = imageTemplateMdx;
72
+ function oembedTemplate(applyPrefix, data) {
73
+ return `<div class="${applyPrefix('oembed')}">${data.html}</div>`;
74
+ }
75
+ exports.oembedTemplate = oembedTemplate;
76
+ function oembedTemplateMdx(applyPrefix, data) {
77
+ return renderMdx(applyPrefix('Oembed'), ['url', 'author_name', 'author_url', 'width', 'height', 'type', 'cache_age', 'provider_name', 'version'], data, data.html);
78
+ }
79
+ exports.oembedTemplateMdx = oembedTemplateMdx;
80
+ function codeTemplate(applyPrefix, data) {
81
+ const { text, lang } = data;
82
+ const code = (0, highlight_code_js_1.highlightCode)(text, lang);
83
+ const langClass = lang ? ` class="${applyPrefix(`language-${lang}`)}"` : '';
84
+ return `<pre><code${langClass}>${code}</code></pre>`;
85
+ }
86
+ exports.codeTemplate = codeTemplate;
87
+ function jsonTemplate(template, context) {
88
+ const renderTemplate = (template) => {
89
+ return template.replace(/{{(\w+)}}/g, (_, name) => context[name] ?? '');
90
+ };
91
+ const transform = (obj) => {
92
+ if (Array.isArray(obj)) {
93
+ return obj.map(transform);
94
+ }
95
+ if ((0, types_js_1.isRecord)(obj)) {
96
+ const result = {};
97
+ for (const key of Object.keys(obj)) {
98
+ result[renderTemplate(key)] = transform(obj[key]);
99
+ }
100
+ return result;
101
+ }
102
+ if (typeof obj === 'string') {
103
+ return renderTemplate(obj);
104
+ }
105
+ return obj;
106
+ };
107
+ return transform(template);
108
+ }
109
+ exports.jsonTemplate = jsonTemplate;