@appsemble/utils 0.30.14-test.6 → 0.32.1-test.14

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 (171) hide show
  1. package/README.md +3 -3
  2. package/allActions.js +5 -3
  3. package/api/components/parameters/$orderby.js +2 -2
  4. package/api/components/parameters/index.d.ts +2 -1
  5. package/api/components/parameters/index.js +2 -1
  6. package/api/components/parameters/webhookName.d.ts +2 -0
  7. package/api/components/parameters/webhookName.js +10 -0
  8. package/api/components/parameters/webhookSecretId.d.ts +2 -0
  9. package/api/components/parameters/webhookSecretId.js +8 -0
  10. package/api/components/schemas/ActionDefinition.js +3 -0
  11. package/api/components/schemas/App.js +8 -0
  12. package/api/components/schemas/AppDefinition.js +6 -0
  13. package/api/components/schemas/AppLayoutDefinition.js +8 -0
  14. package/api/components/schemas/AppServiceSecret.js +5 -0
  15. package/api/components/schemas/AppWebhookSecret.d.ts +2 -0
  16. package/api/components/schemas/AppWebhookSecret.js +25 -0
  17. package/api/components/schemas/DialogOkActionDefinition.js +1 -1
  18. package/api/components/schemas/FilterParametersDefinition.d.ts +2 -0
  19. package/api/components/schemas/FilterParametersDefinition.js +15 -0
  20. package/api/components/schemas/FlowCancelActionDefinition.js +1 -1
  21. package/api/components/schemas/FlowFinishActionDefinition.js +1 -1
  22. package/api/components/schemas/GroupMemberDeleteActionDefinition.js +1 -1
  23. package/api/components/schemas/ResourceDefinition.js +5 -0
  24. package/api/components/schemas/ResourceDeleteAllActionDefinition.d.ts +1 -0
  25. package/api/components/schemas/ResourceDeleteAllActionDefinition.js +21 -0
  26. package/api/components/schemas/ResourceDeleteBulkActionDefinition.d.ts +1 -0
  27. package/api/components/schemas/ResourceDeleteBulkActionDefinition.js +18 -0
  28. package/api/components/schemas/ResourceGetActionDefinition.js +3 -0
  29. package/api/components/schemas/ResourcePatchActionDefinition.js +3 -0
  30. package/api/components/schemas/ResourceSubscriptionStatusActionDefinition.js +1 -0
  31. package/api/components/schemas/ResourceSubscriptionSubscribeActionDefinition.js +1 -0
  32. package/api/components/schemas/ResourceSubscriptionToggleActionDefinition.js +1 -0
  33. package/api/components/schemas/ResourceSubscriptionUnsubscribeActionDefinition.js +1 -0
  34. package/api/components/schemas/ResourceUpdatePositionsActionDefinition.d.ts +1 -0
  35. package/api/components/schemas/ResourceUpdatePositionsActionDefinition.js +21 -0
  36. package/api/components/schemas/SecurityCronDefinition.d.ts +2 -0
  37. package/api/components/schemas/SecurityCronDefinition.js +26 -0
  38. package/api/components/schemas/SecurityDefinition.js +1 -0
  39. package/api/components/schemas/StorageSubtractActionDefinition.js +2 -2
  40. package/api/components/schemas/Training.js +2 -25
  41. package/api/components/schemas/TrainingCompleted.d.ts +2 -0
  42. package/api/components/schemas/TrainingCompleted.js +17 -0
  43. package/api/components/schemas/WebhookDefinition.d.ts +2 -0
  44. package/api/components/schemas/WebhookDefinition.js +17 -0
  45. package/api/components/schemas/index.d.ts +8 -1
  46. package/api/components/schemas/index.js +8 -1
  47. package/api/components/schemas/utils.js +1 -1
  48. package/api/components/securitySchemes/index.d.ts +1 -0
  49. package/api/components/securitySchemes/index.js +1 -0
  50. package/api/components/securitySchemes/webhook.d.ts +2 -0
  51. package/api/components/securitySchemes/webhook.js +6 -0
  52. package/api/paths/apps/appId/resources/resourceType/resourceId/positions.js +54 -0
  53. package/api/paths/apps/appId/secrets/webhook/secretId.js +61 -0
  54. package/api/paths/apps/appId/secrets/webhook.js +44 -0
  55. package/api/paths/apps/appId/webhooks/webhookName.js +35 -0
  56. package/api/paths/apps/appId.js +6 -0
  57. package/api/paths/auth/email/patchPassword.js +30 -0
  58. package/api/paths/index.d.ts +7 -5
  59. package/api/paths/index.js +16 -12
  60. package/api/paths/trainings/completeTraining.js +18 -0
  61. package/api/paths/trainings/completedTrainings.d.ts +2 -0
  62. package/api/paths/trainings/completedTrainings.js +21 -0
  63. package/api/paths/trainings/trainingIds.d.ts +2 -0
  64. package/api/paths/trainings/trainingIds.js +20 -0
  65. package/api/tags/index.js +4 -4
  66. package/appMessages.js +1 -1
  67. package/assets.js +1 -1
  68. package/authorization.d.ts +1 -1
  69. package/authorization.js +1 -1
  70. package/blockUtils.d.ts +1 -1
  71. package/blockUtils.js +1 -0
  72. package/convertToCsv.js +2 -0
  73. package/examples.js +214 -4
  74. package/formatRequestAction.js +2 -2
  75. package/has.d.ts +1 -1
  76. package/has.js +1 -1
  77. package/i18n.js +6 -8
  78. package/ics.js +1 -1
  79. package/iterApp.js +3 -3
  80. package/jsonschema.js +16 -3
  81. package/package.json +15 -11
  82. package/reference-schemas/actions/appMember.d.ts +2 -0
  83. package/reference-schemas/actions/appMember.js +21 -0
  84. package/reference-schemas/actions/flow.d.ts +2 -0
  85. package/reference-schemas/actions/flow.js +13 -0
  86. package/reference-schemas/actions/group.d.ts +2 -0
  87. package/reference-schemas/actions/group.js +13 -0
  88. package/reference-schemas/actions/index.d.ts +7 -0
  89. package/reference-schemas/actions/index.js +8 -0
  90. package/reference-schemas/actions/link.d.ts +2 -0
  91. package/reference-schemas/actions/link.js +9 -0
  92. package/reference-schemas/actions/miscellaneous.d.ts +2 -0
  93. package/reference-schemas/actions/miscellaneous.js +41 -0
  94. package/reference-schemas/actions/resources.d.ts +2 -0
  95. package/reference-schemas/actions/resources.js +19 -0
  96. package/reference-schemas/actions/storage.d.ts +2 -0
  97. package/reference-schemas/actions/storage.js +15 -0
  98. package/reference-schemas/remappers/conditionals.js +39 -0
  99. package/reference-schemas/remappers/data.js +26 -2
  100. package/reference-schemas/remappers/index.d.ts +1 -0
  101. package/reference-schemas/remappers/index.js +1 -0
  102. package/reference-schemas/remappers/objects.js +32 -0
  103. package/reference-schemas/remappers/odata.d.ts +2 -0
  104. package/reference-schemas/remappers/odata.js +95 -0
  105. package/reference-schemas/remappers/strings.js +33 -0
  106. package/reference-schemas/remappers/unsorted.js +9 -0
  107. package/remap.d.ts +2 -0
  108. package/remap.js +192 -15
  109. package/serializeResource.d.ts +7 -0
  110. package/serializeResource.js +7 -0
  111. package/serverActions.d.ts +1 -1
  112. package/serverActions.js +2 -0
  113. package/theme.js +5 -1
  114. package/validateStyle.js +2 -0
  115. package/validation.js +52 -16
  116. package/api/components/parameters/trainingBlockId.d.ts +0 -2
  117. package/api/components/parameters/trainingBlockId.js +0 -8
  118. package/api/components/schemas/TrainingBlock.d.ts +0 -2
  119. package/api/components/schemas/TrainingBlock.js +0 -38
  120. package/api/components/securitySchemes/cli.test.d.ts +0 -1
  121. package/api/components/securitySchemes/cli.test.js +0 -7
  122. package/api/index.test.d.ts +0 -1
  123. package/api/index.test.js +0 -180
  124. package/api/paths/trainingBlocks/trainingBlockId.js +0 -41
  125. package/api/paths/trainings/trainingId/blocks.js +0 -51
  126. package/api/paths/trainings/trainingId/users/current.js +0 -62
  127. package/api/paths/trainings/trainingId/users.js +0 -25
  128. package/api/paths/trainings/trainingId.js +0 -85
  129. package/api/paths/trainings.js +0 -44
  130. package/appMessages.test.d.ts +0 -1
  131. package/appMessages.test.js +0 -409
  132. package/blockUtils.test.d.ts +0 -1
  133. package/blockUtils.test.js +0 -77
  134. package/constants/patterns.test.d.ts +0 -1
  135. package/constants/patterns.test.js +0 -83
  136. package/convertToCsv.test.d.ts +0 -1
  137. package/convertToCsv.test.js +0 -55
  138. package/has.test.d.ts +0 -1
  139. package/has.test.js +0 -17
  140. package/i18n.test.d.ts +0 -1
  141. package/i18n.test.js +0 -76
  142. package/iterApp.test.d.ts +0 -1
  143. package/iterApp.test.js +0 -439
  144. package/jsonschema.test.d.ts +0 -1
  145. package/jsonschema.test.js +0 -256
  146. package/mapValues.test.d.ts +0 -1
  147. package/mapValues.test.js +0 -16
  148. package/miscellaneous.test.d.ts +0 -1
  149. package/miscellaneous.test.js +0 -87
  150. package/normalize.test.d.ts +0 -1
  151. package/normalize.test.js +0 -23
  152. package/objectCache.test.d.ts +0 -1
  153. package/objectCache.test.js +0 -20
  154. package/prefix.test.d.ts +0 -1
  155. package/prefix.test.js +0 -11
  156. package/remap.test.d.ts +0 -1
  157. package/remap.test.js +0 -1387
  158. package/string.test.d.ts +0 -1
  159. package/string.test.js +0 -27
  160. package/theme.test.d.ts +0 -1
  161. package/theme.test.js +0 -91
  162. package/validateStyle.test.d.ts +0 -1
  163. package/validateStyle.test.js +0 -13
  164. package/validation.test.d.ts +0 -1
  165. package/validation.test.js +0 -3121
  166. /package/api/paths/{trainingBlocks/trainingBlockId.d.ts → apps/appId/resources/resourceType/resourceId/positions.d.ts} +0 -0
  167. /package/api/paths/{trainings/trainingId.d.ts → apps/appId/secrets/webhook/secretId.d.ts} +0 -0
  168. /package/api/paths/{trainings.d.ts → apps/appId/secrets/webhook.d.ts} +0 -0
  169. /package/api/paths/{trainings/trainingId/blocks.d.ts → apps/appId/webhooks/webhookName.d.ts} +0 -0
  170. /package/api/paths/{trainings/trainingId/users.d.ts → auth/email/patchPassword.d.ts} +0 -0
  171. /package/api/paths/trainings/{trainingId/users/current.d.ts → completeTraining.d.ts} +0 -0
@@ -1,256 +0,0 @@
1
- import { describe, expect, it, vi } from 'vitest';
2
- import { combineSchemas, generateDataFromSchema, iterJSONSchema } from './jsonschema.js';
3
- describe('generateDataFromSchema', () => {
4
- it('should not crash if no schema is defined', () => {
5
- const result = generateDataFromSchema();
6
- expect(result).toBeUndefined();
7
- });
8
- it('should return the default value', () => {
9
- const result = generateDataFromSchema({ type: 'string', default: 'pear' });
10
- expect(result).toBe('pear');
11
- });
12
- describe('array', () => {
13
- it('should return an empty array', () => {
14
- const result = generateDataFromSchema({ type: 'array' });
15
- expect(result).toStrictEqual([]);
16
- });
17
- it('should fill the array up to minItems', () => {
18
- const result = generateDataFromSchema({
19
- type: 'array',
20
- minItems: 3,
21
- items: { type: 'string' },
22
- });
23
- expect(result).toStrictEqual(['', '', '']);
24
- });
25
- it('should use indexed array items if it’s an array', () => {
26
- const result = generateDataFromSchema({
27
- type: 'array',
28
- minItems: 3,
29
- items: [{ type: 'boolean' }, { type: 'number' }, { type: 'string' }],
30
- });
31
- expect(result).toStrictEqual([false, 0, '']);
32
- });
33
- it('should use use additionalItems if the array length', () => {
34
- const result = generateDataFromSchema({
35
- type: 'array',
36
- minItems: 3,
37
- items: [{ type: 'boolean' }],
38
- additionalItems: { type: 'string' },
39
- });
40
- expect(result).toStrictEqual([false, '', '']);
41
- });
42
- });
43
- describe('boolean', () => {
44
- it('should return false', () => {
45
- const result = generateDataFromSchema({ type: 'boolean' });
46
- expect(result).toBe(false);
47
- });
48
- });
49
- describe('integer / number', () => {
50
- it('should return 0', () => {
51
- const result = generateDataFromSchema({ type: 'number' });
52
- expect(result).toBe(0);
53
- });
54
- it('should respect the minimum value', () => {
55
- const result = generateDataFromSchema({ type: 'number', minimum: 5 });
56
- expect(result).toBe(5);
57
- });
58
- it('should respect the maximum value', () => {
59
- const result = generateDataFromSchema({ type: 'number', maximum: -5 });
60
- expect(result).toBe(-5);
61
- });
62
- it('should respect the combination of multipleOf and minimum', () => {
63
- const result = generateDataFromSchema({ type: 'number', minimum: 5, multipleOf: 3 });
64
- expect(result).toBe(6);
65
- });
66
- it('should respect the combination of multipleOf and maximum', () => {
67
- const result = generateDataFromSchema({ type: 'number', maximum: -5, multipleOf: 3 });
68
- expect(result).toBe(-6);
69
- });
70
- });
71
- describe('null', () => {
72
- it('should return null', () => {
73
- const result = generateDataFromSchema({ type: 'null' });
74
- expect(result).toBeNull();
75
- });
76
- });
77
- describe('string', () => {
78
- it('should return an empty string', () => {
79
- const result = generateDataFromSchema({ type: 'string' });
80
- expect(result).toBe('');
81
- });
82
- });
83
- describe('object', () => {
84
- it('should recursively create an object', () => {
85
- const result = generateDataFromSchema({
86
- type: 'object',
87
- properties: { bool: { type: 'boolean' }, num: { type: 'number' }, str: { type: 'string' } },
88
- });
89
- expect(result).toStrictEqual({ bool: false, num: 0, str: '' });
90
- });
91
- });
92
- });
93
- describe('combineSchemas', () => {
94
- it('should use the first type found', () => {
95
- const result = combineSchemas({ type: 'number' }, { type: 'string' });
96
- expect(result).toStrictEqual({ type: 'number' });
97
- });
98
- it('should use the first format found', () => {
99
- const result = combineSchemas({ format: 'email' }, { format: 'uuid' });
100
- expect(result).toStrictEqual({ format: 'email' });
101
- });
102
- it('should determine the minimum', () => {
103
- const result = combineSchemas({}, { minimum: 3 }, { minimum: 1 }, { minimum: 2 }, {});
104
- expect(result).toStrictEqual({ minimum: 3 });
105
- });
106
- it('should determine the min length', () => {
107
- const result = combineSchemas({}, { minLength: 3 }, { minLength: 1 }, { minLength: 2 }, {});
108
- expect(result).toStrictEqual({ minLength: 3 });
109
- });
110
- it('should determine the maximum', () => {
111
- const result = combineSchemas({}, { maximum: 3 }, { maximum: 1 }, { maximum: 2 }, {});
112
- expect(result).toStrictEqual({ maximum: 1 });
113
- });
114
- it('should determine the max length', () => {
115
- const result = combineSchemas({}, { maxLength: 3 }, { maxLength: 1 }, { maxLength: 2 }, {});
116
- expect(result).toStrictEqual({ maxLength: 1 });
117
- });
118
- it('should use the least common multiple for multipleOf', () => {
119
- const result = combineSchemas({}, { multipleOf: 0 }, { multipleOf: 6 }, { multipleOf: 8 }, {});
120
- expect(result).toStrictEqual({ multipleOf: 24 });
121
- });
122
- it('should assign the first non-nullish default', () => {
123
- const result = combineSchemas({}, { default: null }, { default: 'a' }, { default: 'b' }, {});
124
- expect(result).toStrictEqual({ default: 'a' });
125
- });
126
- it('should use the first truthy description', () => {
127
- const result = combineSchemas({}, { description: '' }, { description: 'Hi' }, { description: 'Bye' }, {});
128
- expect(result).toStrictEqual({ description: 'Hi' });
129
- });
130
- it('should use the first truthy title', () => {
131
- const result = combineSchemas({}, { title: '' }, { title: 'Hi' }, { title: 'Bye' }, {});
132
- expect(result).toStrictEqual({ title: 'Hi' });
133
- });
134
- it('should set uniqueItems to true if any schema requires this', () => {
135
- const result = combineSchemas({}, { uniqueItems: false }, { uniqueItems: true }, {});
136
- expect(result).toStrictEqual({ uniqueItems: true });
137
- });
138
- it('should merge required arrays', () => {
139
- const result = combineSchemas({}, { required: ['foo'] }, { required: ['bar'] }, {});
140
- expect(result).toStrictEqual({ required: ['foo', 'bar'] });
141
- });
142
- it('should assign required if it’s true', () => {
143
- const result = combineSchemas({}, { required: true }, { required: false }, {});
144
- expect(result).toStrictEqual({ required: true });
145
- });
146
- it('should merge properties', () => {
147
- const result = combineSchemas({}, { properties: { foo: { type: 'string' } } }, { properties: { bar: { type: 'number' } } }, { properties: { foo: { title: 'Foo' }, bar: { title: 'Bar' } } }, { required: ['foo', 'bar'] }, {});
148
- expect(result).toStrictEqual({
149
- required: ['foo', 'bar'],
150
- properties: {
151
- foo: {
152
- title: 'Foo',
153
- type: 'string',
154
- },
155
- bar: {
156
- title: 'Bar',
157
- type: 'number',
158
- },
159
- },
160
- });
161
- });
162
- });
163
- describe('iterJSONSchema', () => {
164
- it('should handle properties', () => {
165
- const onSchema = vi.fn();
166
- const schema = {
167
- type: 'object',
168
- properties: {
169
- foo: { description: 'foo' },
170
- },
171
- };
172
- iterJSONSchema(schema, onSchema);
173
- expect(onSchema).toHaveBeenCalledTimes(2);
174
- expect(onSchema).toHaveBeenCalledWith(schema);
175
- expect(onSchema).toHaveBeenCalledWith(schema.properties.foo);
176
- });
177
- it('should handle additionalProperties', () => {
178
- const onSchema = vi.fn();
179
- const schema = {
180
- type: 'object',
181
- additionalProperties: { description: 'foo' },
182
- };
183
- iterJSONSchema(schema, onSchema);
184
- expect(onSchema).toHaveBeenCalledTimes(2);
185
- expect(onSchema).toHaveBeenCalledWith(schema);
186
- expect(onSchema).toHaveBeenCalledWith(schema.additionalProperties);
187
- });
188
- it('should handle an items object', () => {
189
- const onSchema = vi.fn();
190
- const schema = {
191
- type: 'array',
192
- items: { description: 'foo' },
193
- };
194
- iterJSONSchema(schema, onSchema);
195
- expect(onSchema).toHaveBeenCalledTimes(2);
196
- expect(onSchema).toHaveBeenCalledWith(schema);
197
- expect(onSchema).toHaveBeenCalledWith(schema.items);
198
- });
199
- it('should handle an items array', () => {
200
- const onSchema = vi.fn();
201
- const schema = {
202
- type: 'array',
203
- items: [{ description: 'foo' }, { description: 'bar' }],
204
- };
205
- iterJSONSchema(schema, onSchema);
206
- expect(onSchema).toHaveBeenCalledTimes(3);
207
- expect(onSchema).toHaveBeenCalledWith(schema);
208
- expect(onSchema).toHaveBeenCalledWith(schema.items[0]);
209
- expect(onSchema).toHaveBeenCalledWith(schema.items[1]);
210
- });
211
- it('should handle additionalItems', () => {
212
- const onSchema = vi.fn();
213
- const schema = {
214
- type: 'array',
215
- additionalItems: { description: 'foo' },
216
- };
217
- iterJSONSchema(schema, onSchema);
218
- expect(onSchema).toHaveBeenCalledTimes(2);
219
- expect(onSchema).toHaveBeenCalledWith(schema);
220
- expect(onSchema).toHaveBeenCalledWith(schema.additionalItems);
221
- });
222
- it('should handle anyOf', () => {
223
- const onSchema = vi.fn();
224
- const schema = {
225
- type: 'array',
226
- anyOf: [{ description: 'foo' }],
227
- };
228
- iterJSONSchema(schema, onSchema);
229
- expect(onSchema).toHaveBeenCalledTimes(2);
230
- expect(onSchema).toHaveBeenCalledWith(schema);
231
- expect(onSchema).toHaveBeenCalledWith(schema.anyOf[0]);
232
- });
233
- it('should handle oneOf', () => {
234
- const onSchema = vi.fn();
235
- const schema = {
236
- type: 'array',
237
- oneOf: [{ description: 'foo' }],
238
- };
239
- iterJSONSchema(schema, onSchema);
240
- expect(onSchema).toHaveBeenCalledTimes(2);
241
- expect(onSchema).toHaveBeenCalledWith(schema);
242
- expect(onSchema).toHaveBeenCalledWith(schema.oneOf[0]);
243
- });
244
- it('should handle allOf', () => {
245
- const onSchema = vi.fn();
246
- const schema = {
247
- type: 'array',
248
- allOf: [{ description: 'foo' }],
249
- };
250
- iterJSONSchema(schema, onSchema);
251
- expect(onSchema).toHaveBeenCalledTimes(2);
252
- expect(onSchema).toHaveBeenCalledWith(schema);
253
- expect(onSchema).toHaveBeenCalledWith(schema.allOf[0]);
254
- });
255
- });
256
- //# sourceMappingURL=jsonschema.test.js.map
@@ -1 +0,0 @@
1
- export {};
package/mapValues.test.js DELETED
@@ -1,16 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { mapValues } from './mapValues.js';
3
- describe('mapValues', () => {
4
- it('should call the iteratee over each own property', () => {
5
- const proto = {
6
- nope: 'Discard me',
7
- };
8
- const data = Object.create(proto);
9
- data.yep = 'Overwrite me.';
10
- const result = mapValues(data, (value) => `${value} Done.`);
11
- expect(result).toStrictEqual({
12
- yep: 'Overwrite me. Done.',
13
- });
14
- });
15
- });
16
- //# sourceMappingURL=mapValues.test.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,87 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { identity, rethrow, stripNullValues } from './miscellaneous.js';
3
- /**
4
- * Return the input data.
5
- *
6
- * @param data The data to return.
7
- * @returns The input data.
8
- */
9
- describe('identity', () => {
10
- it('should return the input data', () => {
11
- const input = {};
12
- expect(identity(input)).toBe(input);
13
- });
14
- });
15
- /**
16
- * Throw the input data.
17
- *
18
- * @param data The data to throw.
19
- * @throws The input data.
20
- */
21
- describe('rethrow', () => {
22
- it('should throw the input data', () => {
23
- expect(() => rethrow('Test')).toThrow('Test');
24
- });
25
- });
26
- describe('stripNullValues', () => {
27
- it('should convert null to undefined', () => {
28
- const input = null;
29
- expect(stripNullValues(input)).toBeUndefined();
30
- });
31
- it('should return raw primitives', () => {
32
- const input = 42;
33
- expect(stripNullValues(input)).toBe(42);
34
- });
35
- it('should remove empty, undefined, and null from arrays', () => {
36
- const input = [, undefined, null];
37
- expect(stripNullValues(input)).toStrictEqual([]);
38
- });
39
- it('should not remove Blob values', () => {
40
- const blob = new Blob([], { type: 'image/jpeg' });
41
- const input = {
42
- foo: null,
43
- bar: blob,
44
- baz: 'hello',
45
- };
46
- expect(stripNullValues(input)).toStrictEqual({
47
- bar: blob,
48
- baz: 'hello',
49
- });
50
- });
51
- it('should remove undefined, and null values from objects', () => {
52
- const input = {
53
- foo: null,
54
- bar: undefined,
55
- baz: 42,
56
- };
57
- expect(stripNullValues(input)).toStrictEqual({ baz: 42 });
58
- });
59
- it('should remove empty, undefined, and null values recursively', () => {
60
- const input = {
61
- foo: {
62
- bar: {
63
- fooz: null,
64
- baz: [, undefined, null],
65
- },
66
- },
67
- };
68
- expect(stripNullValues(input)).toStrictEqual({ foo: { bar: { baz: [] } } });
69
- });
70
- it('should respect depth for objects', () => {
71
- const input = {
72
- foo: {
73
- bar: {
74
- asd: null,
75
- },
76
- baz: null,
77
- },
78
- fooz: null,
79
- };
80
- expect(stripNullValues(input, { depth: 2 })).toStrictEqual({ foo: { bar: { asd: null } } });
81
- });
82
- it('should respect depth for arrays', () => {
83
- const input = [null, [null, [null]]];
84
- expect(stripNullValues(input, { depth: 2 })).toStrictEqual([[[null]]]);
85
- });
86
- });
87
- //# sourceMappingURL=miscellaneous.test.js.map
@@ -1 +0,0 @@
1
- export {};
package/normalize.test.js DELETED
@@ -1,23 +0,0 @@
1
- import { expect, it } from 'vitest';
2
- import { normalize } from './normalize.js';
3
- const fixtures = [
4
- ['Foo', 'foo'],
5
- ['A somewhat long sentence.', 'a-somewhat-long-sentence'],
6
- ['Ĺòt’s øf wəìŕð ćĥâṙąçṫœ®ş', 'lot-s-f-w-ir-charact-s'],
7
- ['I___contain_underscores', 'i-contain-underscores'],
8
- ['many----hyphens', 'many-hyphens'],
9
- ['includes.dot', 'includes-dot'],
10
- ['trailing-hyphen-', 'trailing-hyphen'],
11
- ['0123456789 digits', '0123456789-digits'],
12
- ['-leading-hyphen', 'leading-hyphen'],
13
- ['*-multiple-leading-non-word-characters', 'multiple-leading-non-word-characters'],
14
- ];
15
- it.each(fixtures)('should turn “%s” into “%s”', (actual, expected) => {
16
- const result = normalize(actual);
17
- expect(result).toBe(expected);
18
- });
19
- it('should have an option to not support a trailing hyphen', () => {
20
- const result = normalize('trailing-hyphen-', false);
21
- expect(result).toBe('trailing-hyphen-');
22
- });
23
- //# sourceMappingURL=normalize.test.js.map
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { objectCache } from './objectCache.js';
3
- describe('objectCache', () => {
4
- it('should cache results', () => {
5
- let count = 0;
6
- const cache = objectCache((id) => {
7
- count += 1;
8
- return { id, count };
9
- });
10
- const a = cache('a');
11
- expect(a).toStrictEqual({ id: 'a', count: 1 });
12
- const b = cache('b');
13
- expect(b).toStrictEqual({ id: 'b', count: 2 });
14
- expect(b).not.toBe(a);
15
- const c = cache('a');
16
- expect(c).toStrictEqual({ id: 'a', count: 1 });
17
- expect(c).toBe(a);
18
- });
19
- });
20
- //# sourceMappingURL=objectCache.test.js.map
package/prefix.test.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/prefix.test.js DELETED
@@ -1,11 +0,0 @@
1
- import { expect, it } from 'vitest';
2
- import { prefix } from './prefix.js';
3
- it('should prefix a string if the prefix is truthy', () => {
4
- const result = prefix('bar', 'foo');
5
- expect(result).toBe('foobar');
6
- });
7
- it('should not prefix a string if the prefix is falsy', () => {
8
- const result = prefix('bar', null);
9
- expect(result).toBe('bar');
10
- });
11
- //# sourceMappingURL=prefix.test.js.map
package/remap.test.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};