@takeshape/util 11.72.0 → 11.74.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 (71) hide show
  1. package/package.json +3 -3
  2. package/dist/common/__tests__/arrays.test.d.ts +0 -1
  3. package/dist/common/__tests__/arrays.test.js +0 -43
  4. package/dist/common/__tests__/billing.test.d.ts +0 -1
  5. package/dist/common/__tests__/billing.test.js +0 -27
  6. package/dist/common/__tests__/clone.test.d.ts +0 -1
  7. package/dist/common/__tests__/clone.test.js +0 -128
  8. package/dist/common/__tests__/data/advanced-draftjs-data-from-app.d.ts +0 -114
  9. package/dist/common/__tests__/data/advanced-draftjs-data-from-app.js +0 -316
  10. package/dist/common/__tests__/data/advanced-draftjs-from-markdown-data.d.ts +0 -160
  11. package/dist/common/__tests__/data/advanced-draftjs-from-markdown-data.js +0 -326
  12. package/dist/common/__tests__/data/advanced-draftjs-from-mdx-data.d.ts +0 -215
  13. package/dist/common/__tests__/data/advanced-draftjs-from-mdx-data.js +0 -407
  14. package/dist/common/__tests__/data/advanced-markdown-2nd-pass.d.ts +0 -1
  15. package/dist/common/__tests__/data/advanced-markdown-2nd-pass.js +0 -39
  16. package/dist/common/__tests__/data/advanced-markdown-data.d.ts +0 -1
  17. package/dist/common/__tests__/data/advanced-markdown-data.js +0 -39
  18. package/dist/common/__tests__/data/advanced-mdx-2nd-pass.d.ts +0 -1
  19. package/dist/common/__tests__/data/advanced-mdx-2nd-pass.js +0 -40
  20. package/dist/common/__tests__/data/advanced-mdx-data.d.ts +0 -1
  21. package/dist/common/__tests__/data/advanced-mdx-data.js +0 -40
  22. package/dist/common/__tests__/delay.test.d.ts +0 -1
  23. package/dist/common/__tests__/delay.test.js +0 -22
  24. package/dist/common/__tests__/draftjs.test.d.ts +0 -1
  25. package/dist/common/__tests__/draftjs.test.js +0 -373
  26. package/dist/common/__tests__/empty.test.d.ts +0 -1
  27. package/dist/common/__tests__/empty.test.js +0 -65
  28. package/dist/common/__tests__/http.test.d.ts +0 -1
  29. package/dist/common/__tests__/http.test.js +0 -13
  30. package/dist/common/__tests__/merge.test.d.ts +0 -1
  31. package/dist/common/__tests__/merge.test.js +0 -36
  32. package/dist/common/__tests__/mime.test.d.ts +0 -1
  33. package/dist/common/__tests__/mime.test.js +0 -17
  34. package/dist/common/__tests__/names.test.d.ts +0 -1
  35. package/dist/common/__tests__/names.test.js +0 -22
  36. package/dist/common/__tests__/naming.test.d.ts +0 -1
  37. package/dist/common/__tests__/naming.test.js +0 -98
  38. package/dist/common/__tests__/path-to-string.test.d.ts +0 -1
  39. package/dist/common/__tests__/path-to-string.test.js +0 -7
  40. package/dist/common/__tests__/predicate.test.d.ts +0 -1
  41. package/dist/common/__tests__/predicate.test.js +0 -18
  42. package/dist/common/__tests__/search-params.test.d.ts +0 -1
  43. package/dist/common/__tests__/search-params.test.js +0 -8
  44. package/dist/common/__tests__/sets.test.d.ts +0 -1
  45. package/dist/common/__tests__/sets.test.js +0 -13
  46. package/dist/common/__tests__/sort-object.test.d.ts +0 -1
  47. package/dist/common/__tests__/sort-object.test.js +0 -12
  48. package/dist/common/__tests__/strings.test.d.ts +0 -1
  49. package/dist/common/__tests__/strings.test.js +0 -78
  50. package/dist/common/__tests__/takeshape-id.test.d.ts +0 -1
  51. package/dist/common/__tests__/takeshape-id.test.js +0 -26
  52. package/dist/common/__tests__/templates.test.d.ts +0 -1
  53. package/dist/common/__tests__/templates.test.js +0 -220
  54. package/dist/common/__tests__/timezone.test.d.ts +0 -1
  55. package/dist/common/__tests__/timezone.test.js +0 -8
  56. package/dist/common/__tests__/types.test.d.ts +0 -1
  57. package/dist/common/__tests__/types.test.js +0 -46
  58. package/dist/common/__tests__/unix-to-iso.test.d.ts +0 -1
  59. package/dist/common/__tests__/unix-to-iso.test.js +0 -6
  60. package/dist/common/__tests__/urls.test.d.ts +0 -1
  61. package/dist/common/__tests__/urls.test.js +0 -19
  62. package/dist/common/__tests__/value.test.d.ts +0 -1
  63. package/dist/common/__tests__/value.test.js +0 -6
  64. package/dist/common/__tests__/visit.test.d.ts +0 -1
  65. package/dist/common/__tests__/visit.test.js +0 -112
  66. package/dist/node/__tests__/buffer.test.d.ts +0 -1
  67. package/dist/node/__tests__/buffer.test.js +0 -41
  68. package/dist/node/__tests__/encryption.test.d.ts +0 -1
  69. package/dist/node/__tests__/encryption.test.js +0 -14
  70. package/dist/node/__tests__/gzip.test.d.ts +0 -1
  71. package/dist/node/__tests__/gzip.test.js +0 -59
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@takeshape/util",
3
- "version": "11.72.0",
3
+ "version": "11.74.1",
4
4
  "description": "Shared utilities",
5
5
  "homepage": "https://www.takeshape.io",
6
6
  "repository": {
@@ -46,7 +46,7 @@
46
46
  "tiny-invariant": "^1.2.0",
47
47
  "uint8array-extras": "^1.4.0",
48
48
  "url-parse": "^1.5.3",
49
- "@takeshape/routing": "11.72.0"
49
+ "@takeshape/routing": "11.74.1"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/classnames": "^2.2.9",
@@ -64,7 +64,7 @@
64
64
  "node": ">=20"
65
65
  },
66
66
  "scripts": {
67
- "build": "tsc --build tsconfig.build.json",
67
+ "build": "tsc --project tsconfig.build.json",
68
68
  "prebuild:ci": "pnpm clean",
69
69
  "build:ci": "pnpm build --noCheck",
70
70
  "clean": "del-cli dist coverage *.tsbuildinfo",
@@ -1 +0,0 @@
1
- export {};
@@ -1,43 +0,0 @@
1
- import { expect, test } from 'vitest';
2
- import { arrayContainsAll, isDefined, setIsEqual, toArray } from "../arrays.js";
3
- test('arrayContainsAll - true', () => {
4
- const a = ['a', 'b', 'c'];
5
- const b = ['b', 'c', 'a'];
6
- expect(arrayContainsAll(a, b)).toEqual(true);
7
- });
8
- test('arrayContainsAll - true, different lengths', () => {
9
- const a = ['a', 'b', 'c'];
10
- const b = ['a', 'b', 'c', 'd', 'e'];
11
- expect(arrayContainsAll(a, b)).toEqual(true);
12
- });
13
- test('arrayContainsAll - false', () => {
14
- const a = ['a', 'b', 'c'];
15
- const b = ['b', 'c', 'd'];
16
- expect(arrayContainsAll(a, b)).toEqual(false);
17
- });
18
- test('setIsEqual - true', () => {
19
- const a = ['a', 'b', 'c'];
20
- const b = ['c', 'b', 'a'];
21
- expect(setIsEqual(a, b)).toEqual(true);
22
- });
23
- test('setIsEqual - false, different values', () => {
24
- const a = ['a', 'b', 'c'];
25
- const b = ['d', 'b', 'a'];
26
- expect(setIsEqual(a, b)).toEqual(false);
27
- });
28
- test('setIsEqual - false, different lengths', () => {
29
- const a = ['a', 'b', 'c'];
30
- const b = ['a', 'b', 'c', 'd', 'e'];
31
- expect(setIsEqual(a, b)).toEqual(false);
32
- });
33
- test('isDefined', () => {
34
- expect(isDefined({ foo: 'bar' })).toEqual(true);
35
- expect(isDefined('')).toEqual(true);
36
- expect(isDefined(undefined)).toEqual(false);
37
- expect(isDefined(null)).toEqual(false);
38
- });
39
- test('toArray', () => {
40
- expect(toArray({ foo: 'bar' })).toEqual([{ foo: 'bar' }]);
41
- // @ts-expect-error
42
- expect(toArray()).toEqual([]);
43
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,27 +0,0 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { getStripeProductObject, isStripeProductObject } from "../billing.js";
3
- const mockProductObject = {
4
- object: 'product'
5
- };
6
- describe('isStripeProductObject', () => {
7
- test('null', () => {
8
- expect(isStripeProductObject(null)).toEqual(false);
9
- });
10
- test('string', () => {
11
- expect(isStripeProductObject('string')).toEqual(false);
12
- });
13
- test('product', () => {
14
- expect(isStripeProductObject(mockProductObject)).toEqual(true);
15
- });
16
- });
17
- describe('getStripeProductObject', () => {
18
- test('null', () => {
19
- expect(() => getStripeProductObject(null)).toThrowError('product is not a Stripe product object');
20
- });
21
- test('string', () => {
22
- expect(() => getStripeProductObject('string')).toThrowError('product is not a Stripe product object');
23
- });
24
- test('product', () => {
25
- expect(getStripeProductObject(mockProductObject)).toEqual(mockProductObject);
26
- });
27
- });
@@ -1 +0,0 @@
1
- export {};
@@ -1,128 +0,0 @@
1
- import { describe, expect, it, vi } from 'vitest';
2
- import { deepClone, deepCloneWith, REMOVE } from "../clone.js";
3
- import { value } from "../value.js";
4
- describe('deepClone', () => {
5
- it('clones deeply', () => {
6
- const deepObject = {
7
- foo: {
8
- bar: 'baz'
9
- }
10
- };
11
- const clonedObject = deepClone(deepObject);
12
- expect(clonedObject).toEqual(deepObject);
13
- clonedObject.foo.bar = 'poo';
14
- expect(clonedObject).not.toEqual(deepObject);
15
- expect(deepObject).toEqual(deepObject);
16
- });
17
- it('does not clone prototype', () => {
18
- const map = new Map([
19
- ['a', 1],
20
- ['b', 2],
21
- ['c', 3]
22
- ]);
23
- expect(deepClone(map)).toEqual({});
24
- });
25
- it('removes undefined object properties', () => {
26
- const obj = {
27
- foo: undefined
28
- };
29
- const cloned = deepClone(obj);
30
- expect('foo' in cloned).toBe(false);
31
- });
32
- it('circular objects throw error', () => {
33
- const a = {};
34
- const b = { a };
35
- a.b = b;
36
- // No circular detection is a performance tradeoff
37
- // Our previous implementation using JSON.parse(JSON.stringify(obj)) throws as well
38
- expect(() => deepClone(a)).toThrowErrorMatchingInlineSnapshot('[RangeError: Maximum call stack size exceeded]');
39
- });
40
- });
41
- describe('deepCloneWith', () => {
42
- it('clones deeply when customizer returns undefined', () => {
43
- const deepObject = {
44
- foo: {
45
- bar: 'baz'
46
- }
47
- };
48
- const clonedObject = deepCloneWith(deepObject, value(undefined));
49
- expect(clonedObject).toEqual(deepObject);
50
- clonedObject.foo.bar = 'poo';
51
- expect(clonedObject).not.toEqual(deepObject);
52
- expect(deepObject).toEqual(deepObject);
53
- });
54
- it('does not clone prototype', () => {
55
- const map = new Map([
56
- ['a', 1],
57
- ['b', 2],
58
- ['c', 3]
59
- ]);
60
- expect(deepCloneWith(map, value(undefined))).toEqual({});
61
- });
62
- it('removes undefined object properties', () => {
63
- const obj = {
64
- foo: undefined
65
- };
66
- const cloned = deepCloneWith(obj, value(undefined));
67
- expect('foo' in cloned).toBe(false);
68
- });
69
- it('calls callback', () => {
70
- const complex = [
71
- {
72
- objects: {
73
- a: [
74
- 'foo',
75
- {
76
- bar: true
77
- }
78
- ],
79
- b: {
80
- c: {
81
- d: {
82
- e: [{ value: 'lol' }]
83
- }
84
- }
85
- }
86
- }
87
- }
88
- ];
89
- const callback = vi.fn((value, key, parent, clone) => {
90
- if (value === 'foo') {
91
- return REMOVE;
92
- }
93
- if (key === 'b') {
94
- return {
95
- ...clone(value),
96
- updated: true
97
- };
98
- }
99
- if (value === 'lol') {
100
- return 'haha';
101
- }
102
- });
103
- const result = deepCloneWith(complex, callback);
104
- expect(result).toEqual([
105
- {
106
- objects: {
107
- a: [
108
- {
109
- bar: true
110
- }
111
- ],
112
- b: {
113
- c: {
114
- d: {
115
- e: [
116
- {
117
- value: 'haha'
118
- }
119
- ]
120
- }
121
- },
122
- updated: true
123
- }
124
- }
125
- }
126
- ]);
127
- });
128
- });
@@ -1,114 +0,0 @@
1
- export declare const data: {
2
- blocks: ({
3
- key: string;
4
- text: string;
5
- type: string;
6
- depth: number;
7
- inlineStyleRanges: never[];
8
- entityRanges: never[];
9
- data: {
10
- lang: string;
11
- };
12
- } | {
13
- key: string;
14
- text: string;
15
- type: string;
16
- depth: number;
17
- inlineStyleRanges: {
18
- offset: number;
19
- length: number;
20
- style: string;
21
- }[];
22
- entityRanges: {
23
- offset: number;
24
- length: number;
25
- key: number;
26
- }[];
27
- data: {
28
- lang?: undefined;
29
- };
30
- })[];
31
- entityMap: {
32
- '0': {
33
- type: string;
34
- mutability: string;
35
- data: {
36
- id: string;
37
- caption: {
38
- blocks: {
39
- key: string;
40
- text: string;
41
- type: string;
42
- depth: number;
43
- inlineStyleRanges: never[];
44
- entityRanges: never[];
45
- data: {};
46
- }[];
47
- entityMap: {};
48
- };
49
- credit: {
50
- blocks: {
51
- key: string;
52
- text: string;
53
- type: string;
54
- depth: number;
55
- inlineStyleRanges: never[];
56
- entityRanges: never[];
57
- data: {};
58
- }[];
59
- entityMap: {};
60
- };
61
- link: {
62
- url: string;
63
- external: boolean;
64
- };
65
- alignment: string;
66
- size: string;
67
- contentTypeId: string;
68
- };
69
- };
70
- '1': {
71
- type: string;
72
- mutability: string;
73
- data: {
74
- id: string;
75
- caption: string;
76
- credit: string;
77
- };
78
- };
79
- '2': {
80
- type: string;
81
- mutability: string;
82
- data: {
83
- id: string;
84
- caption: string;
85
- credit: string;
86
- };
87
- };
88
- '3': {
89
- type: string;
90
- mutability: string;
91
- data: {
92
- url: string;
93
- author_name: string;
94
- author_url: string;
95
- html: string;
96
- width: number;
97
- height: null;
98
- type: string;
99
- cache_age: string;
100
- provider_name: string;
101
- provider_url: string;
102
- version: string;
103
- };
104
- };
105
- '4': {
106
- type: string;
107
- mutability: string;
108
- data: {
109
- url: string;
110
- target: string;
111
- };
112
- };
113
- };
114
- };
@@ -1,316 +0,0 @@
1
- export const data = {
2
- blocks: [
3
- {
4
- key: '3fado',
5
- text: 'Draftjs / Markdown Test Document',
6
- type: 'header-one',
7
- depth: 0,
8
- inlineStyleRanges: [],
9
- entityRanges: [],
10
- data: {}
11
- },
12
- {
13
- key: 'cjtrq',
14
- text: 'Fancy Stuff',
15
- type: 'header-two',
16
- depth: 0,
17
- inlineStyleRanges: [],
18
- entityRanges: [],
19
- data: {}
20
- },
21
- {
22
- key: 'b02nl',
23
- text: 'Image',
24
- type: 'header-three',
25
- depth: 0,
26
- inlineStyleRanges: [],
27
- entityRanges: [],
28
- data: {}
29
- },
30
- {
31
- key: '9fsh4',
32
- text: ' ',
33
- type: 'atomic',
34
- depth: 0,
35
- inlineStyleRanges: [],
36
- entityRanges: [
37
- {
38
- offset: 0,
39
- length: 1,
40
- key: 0
41
- }
42
- ],
43
- data: {}
44
- },
45
- {
46
- key: 'c3uvu',
47
- text: 'Image without caption or credit',
48
- type: 'header-three',
49
- depth: 0,
50
- inlineStyleRanges: [],
51
- entityRanges: [],
52
- data: {}
53
- },
54
- {
55
- key: '33gbo',
56
- text: ' ',
57
- type: 'atomic',
58
- depth: 0,
59
- inlineStyleRanges: [],
60
- entityRanges: [
61
- {
62
- offset: 0,
63
- length: 1,
64
- key: 1
65
- }
66
- ],
67
- data: {}
68
- },
69
- {
70
- key: 'erfe7',
71
- text: 'Image with caption and credit in asset, not in draftjs',
72
- type: 'header-three',
73
- depth: 0,
74
- inlineStyleRanges: [],
75
- entityRanges: [],
76
- data: {}
77
- },
78
- {
79
- key: '1o0s4',
80
- text: ' ',
81
- type: 'atomic',
82
- depth: 0,
83
- inlineStyleRanges: [],
84
- entityRanges: [
85
- {
86
- offset: 0,
87
- length: 1,
88
- key: 2
89
- }
90
- ],
91
- data: {}
92
- },
93
- {
94
- key: 'bs9r3',
95
- text: '',
96
- type: 'unstyled',
97
- depth: 0,
98
- inlineStyleRanges: [],
99
- entityRanges: [],
100
- data: {}
101
- },
102
- {
103
- key: 'dnqh2',
104
- text: 'Media URL',
105
- type: 'header-three',
106
- depth: 0,
107
- inlineStyleRanges: [],
108
- entityRanges: [],
109
- data: {}
110
- },
111
- {
112
- key: '8fa9m',
113
- text: ' ',
114
- type: 'atomic',
115
- depth: 0,
116
- inlineStyleRanges: [],
117
- entityRanges: [
118
- {
119
- offset: 0,
120
- length: 1,
121
- key: 3
122
- }
123
- ],
124
- data: {}
125
- },
126
- {
127
- key: '7hpad',
128
- text: 'Code Block',
129
- type: 'header-three',
130
- depth: 0,
131
- inlineStyleRanges: [],
132
- entityRanges: [],
133
- data: {}
134
- },
135
- {
136
- key: 'cs8lc',
137
- text: "if (true + true > 1) {\n console.log('true');\n}",
138
- type: 'code-block',
139
- depth: 0,
140
- inlineStyleRanges: [],
141
- entityRanges: [],
142
- data: {
143
- lang: 'javascript'
144
- }
145
- },
146
- {
147
- key: '60eo',
148
- text: ' ',
149
- type: 'section-break',
150
- depth: 0,
151
- inlineStyleRanges: [],
152
- entityRanges: [],
153
- data: {}
154
- },
155
- {
156
- key: '9ac0a',
157
- text: 'Basic Markdown',
158
- type: 'header-two',
159
- depth: 0,
160
- inlineStyleRanges: [],
161
- entityRanges: [],
162
- data: {}
163
- },
164
- {
165
- key: '2pij',
166
- text: 'Normal Super Sub Pre link bold italic underline',
167
- type: 'unstyled',
168
- depth: 0,
169
- inlineStyleRanges: [
170
- {
171
- offset: 7,
172
- length: 5,
173
- style: 'SUP'
174
- },
175
- {
176
- offset: 13,
177
- length: 3,
178
- style: 'SUB'
179
- },
180
- {
181
- offset: 17,
182
- length: 3,
183
- style: 'CODE'
184
- },
185
- {
186
- offset: 26,
187
- length: 4,
188
- style: 'BOLD'
189
- },
190
- {
191
- offset: 31,
192
- length: 6,
193
- style: 'ITALIC'
194
- },
195
- {
196
- offset: 38,
197
- length: 9,
198
- style: 'UNDERLINE'
199
- }
200
- ],
201
- entityRanges: [
202
- {
203
- offset: 21,
204
- length: 4,
205
- key: 4
206
- }
207
- ],
208
- data: {}
209
- },
210
- {
211
- key: 'b09mb',
212
- text: 'Block Quote',
213
- type: 'blockquote',
214
- depth: 0,
215
- inlineStyleRanges: [],
216
- entityRanges: [],
217
- data: {}
218
- },
219
- {
220
- key: 'ahpuf',
221
- text: 'Pull Quote',
222
- type: 'pullquote',
223
- depth: 0,
224
- inlineStyleRanges: [],
225
- entityRanges: [],
226
- data: {}
227
- }
228
- ],
229
- entityMap: {
230
- '0': {
231
- type: 'image',
232
- mutability: 'IMMUTABLE',
233
- data: {
234
- id: '92d98a89-52c1-4761-a4f5-1cc3463f3c0f',
235
- caption: {
236
- blocks: [
237
- {
238
- key: '77jqj',
239
- text: 'Image Caption',
240
- type: 'unstyled',
241
- depth: 0,
242
- inlineStyleRanges: [],
243
- entityRanges: [],
244
- data: {}
245
- }
246
- ],
247
- entityMap: {}
248
- },
249
- credit: {
250
- blocks: [
251
- {
252
- key: '77jqj',
253
- text: 'Image Credit',
254
- type: 'unstyled',
255
- depth: 0,
256
- inlineStyleRanges: [],
257
- entityRanges: [],
258
- data: {}
259
- }
260
- ],
261
- entityMap: {}
262
- },
263
- link: {
264
- url: 'https://takeshape.io',
265
- external: true
266
- },
267
- alignment: 'right',
268
- size: 'medium',
269
- contentTypeId: 'ASSET'
270
- }
271
- },
272
- '1': {
273
- type: 'image',
274
- mutability: 'IMMUTABLE',
275
- data: {
276
- id: '885f34b5-8dea-483a-8909-c50b9932862c',
277
- caption: '',
278
- credit: ''
279
- }
280
- },
281
- '2': {
282
- type: 'image',
283
- mutability: 'IMMUTABLE',
284
- data: {
285
- id: 'a251340c-e8c0-4df7-b38b-51dc7a9d6a44',
286
- caption: '',
287
- credit: ''
288
- }
289
- },
290
- '3': {
291
- type: 'oembed',
292
- mutability: 'IMMUTABLE',
293
- data: {
294
- url: 'https://twitter.com/dog_feelings/status/1430266037182767105',
295
- author_name: 'Thoughts of Dog®',
296
- author_url: 'https://twitter.com/dog_feelings',
297
- html: '<blockquote class="twitter-tweet"><p lang="en" dir="ltr">the FDA. has also fully approved. giving my forehead. a little smooch</p>&mdash; Thoughts of Dog® (@dog_feelings) <a href="https://twitter.com/dog_feelings/status/1430266037182767105?ref_src=twsrc%5Etfw">August 24, 2021</a></blockquote>\n<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>\n',
298
- width: 550,
299
- height: null,
300
- type: 'rich',
301
- cache_age: '3153600000',
302
- provider_name: 'Twitter',
303
- provider_url: 'https://twitter.com',
304
- version: '1.0'
305
- }
306
- },
307
- '4': {
308
- type: 'LINK',
309
- mutability: 'MUTABLE',
310
- data: {
311
- url: 'https://google.com',
312
- target: '_blank'
313
- }
314
- }
315
- }
316
- };