@appsemble/utils 0.30.14-test.5 → 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.
- package/README.md +3 -3
- package/allActions.js +5 -3
- package/api/components/parameters/$orderby.js +2 -2
- package/api/components/parameters/index.d.ts +2 -1
- package/api/components/parameters/index.js +2 -1
- package/api/components/parameters/webhookName.d.ts +2 -0
- package/api/components/parameters/webhookName.js +10 -0
- package/api/components/parameters/webhookSecretId.d.ts +2 -0
- package/api/components/parameters/webhookSecretId.js +8 -0
- package/api/components/schemas/ActionDefinition.js +3 -0
- package/api/components/schemas/App.js +8 -0
- package/api/components/schemas/AppDefinition.js +6 -0
- package/api/components/schemas/AppLayoutDefinition.js +8 -0
- package/api/components/schemas/AppServiceSecret.js +5 -0
- package/api/components/schemas/AppWebhookSecret.d.ts +2 -0
- package/api/components/schemas/AppWebhookSecret.js +25 -0
- package/api/components/schemas/DialogOkActionDefinition.js +1 -1
- package/api/components/schemas/FilterParametersDefinition.d.ts +2 -0
- package/api/components/schemas/FilterParametersDefinition.js +15 -0
- package/api/components/schemas/FlowCancelActionDefinition.js +1 -1
- package/api/components/schemas/FlowFinishActionDefinition.js +1 -1
- package/api/components/schemas/GroupMemberDeleteActionDefinition.js +1 -1
- package/api/components/schemas/ResourceDefinition.js +5 -0
- package/api/components/schemas/ResourceDeleteAllActionDefinition.d.ts +1 -0
- package/api/components/schemas/ResourceDeleteAllActionDefinition.js +21 -0
- package/api/components/schemas/ResourceDeleteBulkActionDefinition.d.ts +1 -0
- package/api/components/schemas/ResourceDeleteBulkActionDefinition.js +18 -0
- package/api/components/schemas/ResourceGetActionDefinition.js +3 -0
- package/api/components/schemas/ResourcePatchActionDefinition.js +3 -0
- package/api/components/schemas/ResourceSubscriptionStatusActionDefinition.js +1 -0
- package/api/components/schemas/ResourceSubscriptionSubscribeActionDefinition.js +1 -0
- package/api/components/schemas/ResourceSubscriptionToggleActionDefinition.js +1 -0
- package/api/components/schemas/ResourceSubscriptionUnsubscribeActionDefinition.js +1 -0
- package/api/components/schemas/ResourceUpdatePositionsActionDefinition.d.ts +1 -0
- package/api/components/schemas/ResourceUpdatePositionsActionDefinition.js +21 -0
- package/api/components/schemas/SecurityCronDefinition.d.ts +2 -0
- package/api/components/schemas/SecurityCronDefinition.js +26 -0
- package/api/components/schemas/SecurityDefinition.js +1 -0
- package/api/components/schemas/StorageSubtractActionDefinition.js +2 -2
- package/api/components/schemas/StorageWriteActionDefinition.js +4 -0
- package/api/components/schemas/Training.js +2 -25
- package/api/components/schemas/TrainingCompleted.d.ts +2 -0
- package/api/components/schemas/TrainingCompleted.js +17 -0
- package/api/components/schemas/WebhookDefinition.d.ts +2 -0
- package/api/components/schemas/WebhookDefinition.js +17 -0
- package/api/components/schemas/index.d.ts +8 -1
- package/api/components/schemas/index.js +8 -1
- package/api/components/schemas/utils.js +1 -1
- package/api/components/securitySchemes/index.d.ts +1 -0
- package/api/components/securitySchemes/index.js +1 -0
- package/api/components/securitySchemes/webhook.d.ts +2 -0
- package/api/components/securitySchemes/webhook.js +6 -0
- package/api/paths/apps/appId/resources/resourceType/resourceId/positions.js +54 -0
- package/api/paths/apps/appId/secrets/webhook/secretId.js +61 -0
- package/api/paths/apps/appId/secrets/webhook.js +44 -0
- package/api/paths/apps/appId/webhooks/webhookName.js +35 -0
- package/api/paths/apps/appId.js +6 -0
- package/api/paths/auth/email/patchPassword.js +30 -0
- package/api/paths/index.d.ts +7 -5
- package/api/paths/index.js +16 -12
- package/api/paths/trainings/completeTraining.js +18 -0
- package/api/paths/trainings/completedTrainings.d.ts +2 -0
- package/api/paths/trainings/completedTrainings.js +21 -0
- package/api/paths/trainings/trainingIds.d.ts +2 -0
- package/api/paths/trainings/trainingIds.js +20 -0
- package/api/tags/index.js +4 -4
- package/appMessages.js +1 -1
- package/assets.js +1 -1
- package/authorization.d.ts +1 -1
- package/authorization.js +1 -1
- package/blockUtils.d.ts +1 -1
- package/blockUtils.js +1 -0
- package/convertToCsv.js +2 -0
- package/examples.js +214 -4
- package/formatRequestAction.js +2 -2
- package/has.d.ts +1 -1
- package/has.js +1 -1
- package/i18n.js +6 -8
- package/ics.js +1 -1
- package/iterApp.js +3 -3
- package/jsonschema.js +16 -3
- package/package.json +15 -11
- package/reference-schemas/actions/appMember.d.ts +2 -0
- package/reference-schemas/actions/appMember.js +21 -0
- package/reference-schemas/actions/flow.d.ts +2 -0
- package/reference-schemas/actions/flow.js +13 -0
- package/reference-schemas/actions/group.d.ts +2 -0
- package/reference-schemas/actions/group.js +13 -0
- package/reference-schemas/actions/index.d.ts +7 -0
- package/reference-schemas/actions/index.js +8 -0
- package/reference-schemas/actions/link.d.ts +2 -0
- package/reference-schemas/actions/link.js +9 -0
- package/reference-schemas/actions/miscellaneous.d.ts +2 -0
- package/reference-schemas/actions/miscellaneous.js +41 -0
- package/reference-schemas/actions/resources.d.ts +2 -0
- package/reference-schemas/actions/resources.js +19 -0
- package/reference-schemas/actions/storage.d.ts +2 -0
- package/reference-schemas/actions/storage.js +15 -0
- package/reference-schemas/remappers/conditionals.js +39 -0
- package/reference-schemas/remappers/data.js +26 -2
- package/reference-schemas/remappers/index.d.ts +1 -0
- package/reference-schemas/remappers/index.js +1 -0
- package/reference-schemas/remappers/objects.js +32 -0
- package/reference-schemas/remappers/odata.d.ts +2 -0
- package/reference-schemas/remappers/odata.js +95 -0
- package/reference-schemas/remappers/strings.js +33 -0
- package/reference-schemas/remappers/unsorted.js +9 -0
- package/remap.d.ts +2 -0
- package/remap.js +192 -15
- package/serializeResource.d.ts +7 -0
- package/serializeResource.js +7 -0
- package/serverActions.d.ts +1 -1
- package/serverActions.js +2 -0
- package/theme.js +5 -1
- package/validateStyle.js +2 -0
- package/validation.js +52 -16
- package/api/components/parameters/trainingBlockId.d.ts +0 -2
- package/api/components/parameters/trainingBlockId.js +0 -8
- package/api/components/schemas/TrainingBlock.d.ts +0 -2
- package/api/components/schemas/TrainingBlock.js +0 -38
- package/api/components/securitySchemes/cli.test.d.ts +0 -1
- package/api/components/securitySchemes/cli.test.js +0 -7
- package/api/index.test.d.ts +0 -1
- package/api/index.test.js +0 -180
- package/api/paths/trainingBlocks/trainingBlockId.js +0 -41
- package/api/paths/trainings/trainingId/blocks.js +0 -51
- package/api/paths/trainings/trainingId/users/current.js +0 -62
- package/api/paths/trainings/trainingId/users.js +0 -25
- package/api/paths/trainings/trainingId.js +0 -85
- package/api/paths/trainings.js +0 -44
- package/appMessages.test.d.ts +0 -1
- package/appMessages.test.js +0 -409
- package/blockUtils.test.d.ts +0 -1
- package/blockUtils.test.js +0 -77
- package/constants/patterns.test.d.ts +0 -1
- package/constants/patterns.test.js +0 -83
- package/convertToCsv.test.d.ts +0 -1
- package/convertToCsv.test.js +0 -55
- package/has.test.d.ts +0 -1
- package/has.test.js +0 -17
- package/i18n.test.d.ts +0 -1
- package/i18n.test.js +0 -76
- package/iterApp.test.d.ts +0 -1
- package/iterApp.test.js +0 -439
- package/jsonschema.test.d.ts +0 -1
- package/jsonschema.test.js +0 -256
- package/mapValues.test.d.ts +0 -1
- package/mapValues.test.js +0 -16
- package/miscellaneous.test.d.ts +0 -1
- package/miscellaneous.test.js +0 -87
- package/normalize.test.d.ts +0 -1
- package/normalize.test.js +0 -23
- package/objectCache.test.d.ts +0 -1
- package/objectCache.test.js +0 -20
- package/prefix.test.d.ts +0 -1
- package/prefix.test.js +0 -11
- package/remap.test.d.ts +0 -1
- package/remap.test.js +0 -1387
- package/string.test.d.ts +0 -1
- package/string.test.js +0 -27
- package/theme.test.d.ts +0 -1
- package/theme.test.js +0 -91
- package/validateStyle.test.d.ts +0 -1
- package/validateStyle.test.js +0 -13
- package/validation.test.d.ts +0 -1
- package/validation.test.js +0 -3121
- /package/api/paths/{trainingBlocks/trainingBlockId.d.ts → apps/appId/resources/resourceType/resourceId/positions.d.ts} +0 -0
- /package/api/paths/{trainings/trainingId.d.ts → apps/appId/secrets/webhook/secretId.d.ts} +0 -0
- /package/api/paths/{trainings.d.ts → apps/appId/secrets/webhook.d.ts} +0 -0
- /package/api/paths/{trainings/trainingId/blocks.d.ts → apps/appId/webhooks/webhookName.d.ts} +0 -0
- /package/api/paths/{trainings/trainingId/users.d.ts → auth/email/patchPassword.d.ts} +0 -0
- /package/api/paths/trainings/{trainingId/users/current.d.ts → completeTraining.d.ts} +0 -0
package/appMessages.test.js
DELETED
|
@@ -1,409 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { extractAppMessages, findMessageIds } from './appMessages.js';
|
|
3
|
-
describe('findMessageIds', () => {
|
|
4
|
-
it('should ignore null', () => {
|
|
5
|
-
const result = findMessageIds(null);
|
|
6
|
-
expect(result).toStrictEqual({});
|
|
7
|
-
});
|
|
8
|
-
it('should ignore non-object values', () => {
|
|
9
|
-
const result = findMessageIds('A string');
|
|
10
|
-
expect(result).toStrictEqual({});
|
|
11
|
-
});
|
|
12
|
-
it('should find message ids from a string.format remapper', () => {
|
|
13
|
-
const result = findMessageIds({ 'string.format': { messageId: 'foo' } });
|
|
14
|
-
expect(result).toStrictEqual({ foo: '' });
|
|
15
|
-
});
|
|
16
|
-
it('should return the message template', () => {
|
|
17
|
-
const result = findMessageIds({ 'string.format': { messageId: 'foo', template: 'bar' } });
|
|
18
|
-
expect(result).toStrictEqual({ foo: 'bar' });
|
|
19
|
-
});
|
|
20
|
-
it('should ignore non-string message ids', () => {
|
|
21
|
-
const result = findMessageIds({ 'string.format': { messageId: 12 } });
|
|
22
|
-
expect(result).toStrictEqual({});
|
|
23
|
-
});
|
|
24
|
-
it('should missing message ids', () => {
|
|
25
|
-
const result = findMessageIds({ 'string.format': {} });
|
|
26
|
-
expect(result).toStrictEqual({});
|
|
27
|
-
});
|
|
28
|
-
it('should recurse into arrays', () => {
|
|
29
|
-
const result = findMessageIds([
|
|
30
|
-
{ 'string.format': { messageId: 'foo' } },
|
|
31
|
-
{ 'string.format': { messageId: 'bar' } },
|
|
32
|
-
]);
|
|
33
|
-
expect(result).toStrictEqual({ foo: '', bar: '' });
|
|
34
|
-
});
|
|
35
|
-
it('should recurse into objects', () => {
|
|
36
|
-
const result = findMessageIds({
|
|
37
|
-
foo: { 'string.format': { messageId: 'fooz' } },
|
|
38
|
-
bar: { 'string.format': { messageId: 'baz' } },
|
|
39
|
-
});
|
|
40
|
-
expect(result).toStrictEqual({ fooz: '', baz: '' });
|
|
41
|
-
});
|
|
42
|
-
it('should extract string.format remapper values', () => {
|
|
43
|
-
const result = findMessageIds({
|
|
44
|
-
'string.format': { messageId: 'foo', values: { translate: 'bar' } },
|
|
45
|
-
});
|
|
46
|
-
expect(result).toStrictEqual({ foo: '', bar: '' });
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
describe('extractAppMessages', () => {
|
|
50
|
-
it('should extract page prefixes', () => {
|
|
51
|
-
const result = extractAppMessages({
|
|
52
|
-
defaultPage: '',
|
|
53
|
-
pages: [
|
|
54
|
-
{ name: 'First Page', blocks: [] },
|
|
55
|
-
{ name: 'Second Page', blocks: [] },
|
|
56
|
-
],
|
|
57
|
-
});
|
|
58
|
-
expect(result).toMatchObject({
|
|
59
|
-
app: { 'pages.first-page': 'First Page', 'pages.second-page': 'Second Page' },
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
it('should extract block header remappers', () => {
|
|
63
|
-
const result = extractAppMessages({
|
|
64
|
-
defaultPage: '',
|
|
65
|
-
pages: [
|
|
66
|
-
{
|
|
67
|
-
name: 'Page',
|
|
68
|
-
blocks: [
|
|
69
|
-
{ type: 'test', version: '1.2.3', header: { 'string.format': { messageId: 'foo' } } },
|
|
70
|
-
],
|
|
71
|
-
},
|
|
72
|
-
],
|
|
73
|
-
});
|
|
74
|
-
expect(result).toMatchObject({ messageIds: { foo: '' }, app: { 'pages.page': 'Page' } });
|
|
75
|
-
});
|
|
76
|
-
it('should extract remappers from block parameters', () => {
|
|
77
|
-
const result = extractAppMessages({
|
|
78
|
-
defaultPage: '',
|
|
79
|
-
pages: [
|
|
80
|
-
{
|
|
81
|
-
name: 'Page',
|
|
82
|
-
blocks: [
|
|
83
|
-
{
|
|
84
|
-
type: 'test',
|
|
85
|
-
version: '1.2.3',
|
|
86
|
-
parameters: { foo: { 'string.format': { messageId: 'foo' } } },
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
],
|
|
91
|
-
});
|
|
92
|
-
expect(result).toMatchObject({ messageIds: { foo: '' }, app: { 'pages.page': 'Page' } });
|
|
93
|
-
});
|
|
94
|
-
it('should extract action remap', () => {
|
|
95
|
-
const result = extractAppMessages({
|
|
96
|
-
defaultPage: '',
|
|
97
|
-
pages: [
|
|
98
|
-
{
|
|
99
|
-
name: 'Page',
|
|
100
|
-
blocks: [
|
|
101
|
-
{
|
|
102
|
-
type: 'test',
|
|
103
|
-
version: '1.2.3',
|
|
104
|
-
actions: {
|
|
105
|
-
onClick: {
|
|
106
|
-
type: 'noop',
|
|
107
|
-
remap: { 'string.format': { messageId: 'onClickMessageId' } },
|
|
108
|
-
onError: {
|
|
109
|
-
type: 'noop',
|
|
110
|
-
remap: { 'string.format': { messageId: 'onErrorMessageId' } },
|
|
111
|
-
},
|
|
112
|
-
onSuccess: {
|
|
113
|
-
type: 'noop',
|
|
114
|
-
remap: { 'string.format': { messageId: 'onSuccessMessageId' } },
|
|
115
|
-
},
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
],
|
|
122
|
-
});
|
|
123
|
-
expect(result).toMatchObject({
|
|
124
|
-
messageIds: { onClickMessageId: '', onErrorMessageId: '', onSuccessMessageId: '' },
|
|
125
|
-
app: { 'pages.page': 'Page' },
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
it('should extract condition action if', () => {
|
|
129
|
-
const result = extractAppMessages({
|
|
130
|
-
defaultPage: '',
|
|
131
|
-
pages: [
|
|
132
|
-
{
|
|
133
|
-
name: 'Page',
|
|
134
|
-
blocks: [
|
|
135
|
-
{
|
|
136
|
-
type: 'test',
|
|
137
|
-
version: '1.2.3',
|
|
138
|
-
actions: {
|
|
139
|
-
onClick: {
|
|
140
|
-
type: 'condition',
|
|
141
|
-
if: { translate: 'ifCondition' },
|
|
142
|
-
then: { type: 'noop' },
|
|
143
|
-
else: { type: 'noop' },
|
|
144
|
-
},
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
],
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
});
|
|
151
|
-
expect(result).toMatchObject({
|
|
152
|
-
messageIds: { ifCondition: '' },
|
|
153
|
-
app: { 'pages.page': 'Page' },
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
it('should extract dialog action title', () => {
|
|
157
|
-
const result = extractAppMessages({
|
|
158
|
-
defaultPage: '',
|
|
159
|
-
pages: [
|
|
160
|
-
{
|
|
161
|
-
name: 'Page',
|
|
162
|
-
blocks: [
|
|
163
|
-
{
|
|
164
|
-
type: 'test',
|
|
165
|
-
version: '1.2.3',
|
|
166
|
-
actions: {
|
|
167
|
-
onClick: {
|
|
168
|
-
type: 'dialog',
|
|
169
|
-
title: { translate: 'dialogTitle' },
|
|
170
|
-
blocks: [],
|
|
171
|
-
},
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
],
|
|
175
|
-
},
|
|
176
|
-
],
|
|
177
|
-
});
|
|
178
|
-
expect(result).toMatchObject({
|
|
179
|
-
messageIds: { dialogTitle: '' },
|
|
180
|
-
app: { 'pages.page': 'Page' },
|
|
181
|
-
});
|
|
182
|
-
});
|
|
183
|
-
it('should extract email action remappers', () => {
|
|
184
|
-
const result = extractAppMessages({
|
|
185
|
-
defaultPage: '',
|
|
186
|
-
pages: [
|
|
187
|
-
{
|
|
188
|
-
name: 'Page',
|
|
189
|
-
blocks: [
|
|
190
|
-
{
|
|
191
|
-
type: 'test',
|
|
192
|
-
version: '1.2.3',
|
|
193
|
-
actions: {
|
|
194
|
-
onClick: {
|
|
195
|
-
type: 'email',
|
|
196
|
-
attachments: { translate: 'attachments' },
|
|
197
|
-
bcc: { translate: 'bcc' },
|
|
198
|
-
body: { translate: 'body' },
|
|
199
|
-
cc: { translate: 'cc' },
|
|
200
|
-
subject: { translate: 'subject' },
|
|
201
|
-
to: { translate: 'to' },
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
},
|
|
205
|
-
],
|
|
206
|
-
},
|
|
207
|
-
],
|
|
208
|
-
});
|
|
209
|
-
expect(result).toMatchObject({
|
|
210
|
-
messageIds: { attachments: '', bcc: '', body: '', cc: '', subject: '', to: '' },
|
|
211
|
-
app: { 'pages.page': 'Page' },
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
it('should extract flow.to action step', () => {
|
|
215
|
-
const result = extractAppMessages({
|
|
216
|
-
defaultPage: '',
|
|
217
|
-
pages: [
|
|
218
|
-
{
|
|
219
|
-
name: 'Page',
|
|
220
|
-
blocks: [
|
|
221
|
-
{
|
|
222
|
-
type: 'test',
|
|
223
|
-
version: '1.2.3',
|
|
224
|
-
actions: {
|
|
225
|
-
onClick: {
|
|
226
|
-
type: 'flow.to',
|
|
227
|
-
step: { translate: 'toPage' },
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
},
|
|
231
|
-
],
|
|
232
|
-
},
|
|
233
|
-
],
|
|
234
|
-
});
|
|
235
|
-
expect(result).toMatchObject({
|
|
236
|
-
messageIds: { toPage: '' },
|
|
237
|
-
app: { 'pages.page': 'Page' },
|
|
238
|
-
});
|
|
239
|
-
});
|
|
240
|
-
it('should extract message action body', () => {
|
|
241
|
-
const result = extractAppMessages({
|
|
242
|
-
defaultPage: '',
|
|
243
|
-
pages: [
|
|
244
|
-
{
|
|
245
|
-
name: 'Page',
|
|
246
|
-
blocks: [
|
|
247
|
-
{
|
|
248
|
-
type: 'test',
|
|
249
|
-
version: '1.2.3',
|
|
250
|
-
actions: {
|
|
251
|
-
onClick: {
|
|
252
|
-
type: 'message',
|
|
253
|
-
body: { translate: 'messageBody' },
|
|
254
|
-
},
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
],
|
|
258
|
-
},
|
|
259
|
-
],
|
|
260
|
-
});
|
|
261
|
-
expect(result).toMatchObject({
|
|
262
|
-
messageIds: { messageBody: '' },
|
|
263
|
-
app: { 'pages.page': 'Page' },
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
it('should extract request action remappers', () => {
|
|
267
|
-
const result = extractAppMessages({
|
|
268
|
-
defaultPage: '',
|
|
269
|
-
pages: [
|
|
270
|
-
{
|
|
271
|
-
name: 'Page',
|
|
272
|
-
blocks: [
|
|
273
|
-
{
|
|
274
|
-
type: 'test',
|
|
275
|
-
version: '1.2.3',
|
|
276
|
-
actions: {
|
|
277
|
-
onRequest: {
|
|
278
|
-
type: 'request',
|
|
279
|
-
body: { translate: 'requestBody' },
|
|
280
|
-
query: { translate: 'requestQuery' },
|
|
281
|
-
url: { translate: 'requestUrl' },
|
|
282
|
-
},
|
|
283
|
-
onResourceCount: {
|
|
284
|
-
type: 'resource.count',
|
|
285
|
-
resource: 'test',
|
|
286
|
-
body: { translate: 'resourceCountBody' },
|
|
287
|
-
query: { translate: 'resourceCountQuery' },
|
|
288
|
-
url: { translate: 'resourceCountUrl' },
|
|
289
|
-
},
|
|
290
|
-
onResourceCreate: {
|
|
291
|
-
type: 'resource.create',
|
|
292
|
-
resource: 'test',
|
|
293
|
-
body: { translate: 'resourceCreateBody' },
|
|
294
|
-
query: { translate: 'resourceCreateQuery' },
|
|
295
|
-
url: { translate: 'resourceCreateUrl' },
|
|
296
|
-
},
|
|
297
|
-
onResourceDelete: {
|
|
298
|
-
type: 'resource.delete',
|
|
299
|
-
resource: 'test',
|
|
300
|
-
body: { translate: 'resourceDeleteBody' },
|
|
301
|
-
query: { translate: 'resourceDeleteQuery' },
|
|
302
|
-
url: { translate: 'resourceDeleteUrl' },
|
|
303
|
-
},
|
|
304
|
-
onResourceGet: {
|
|
305
|
-
type: 'resource.get',
|
|
306
|
-
resource: 'test',
|
|
307
|
-
body: { translate: 'resourceGetBody' },
|
|
308
|
-
query: { translate: 'resourceGetQuery' },
|
|
309
|
-
url: { translate: 'resourceGetUrl' },
|
|
310
|
-
},
|
|
311
|
-
onResourceQuery: {
|
|
312
|
-
type: 'resource.query',
|
|
313
|
-
resource: 'test',
|
|
314
|
-
body: { translate: 'resourceQueryBody' },
|
|
315
|
-
query: { translate: 'resourceQueryQuery' },
|
|
316
|
-
url: { translate: 'resourceQueryUrl' },
|
|
317
|
-
},
|
|
318
|
-
onResourceUpdate: {
|
|
319
|
-
type: 'resource.update',
|
|
320
|
-
resource: 'test',
|
|
321
|
-
body: { translate: 'resourceUpdateBody' },
|
|
322
|
-
query: { translate: 'resourceUpdateQuery' },
|
|
323
|
-
url: { translate: 'resourceUpdateUrl' },
|
|
324
|
-
},
|
|
325
|
-
},
|
|
326
|
-
},
|
|
327
|
-
],
|
|
328
|
-
},
|
|
329
|
-
],
|
|
330
|
-
});
|
|
331
|
-
expect(result).toMatchObject({
|
|
332
|
-
messageIds: {
|
|
333
|
-
requestBody: '',
|
|
334
|
-
requestQuery: '',
|
|
335
|
-
requestUrl: '',
|
|
336
|
-
resourceCountBody: '',
|
|
337
|
-
resourceCountQuery: '',
|
|
338
|
-
resourceCountUrl: '',
|
|
339
|
-
resourceCreateBody: '',
|
|
340
|
-
resourceCreateQuery: '',
|
|
341
|
-
resourceCreateUrl: '',
|
|
342
|
-
resourceDeleteBody: '',
|
|
343
|
-
resourceDeleteQuery: '',
|
|
344
|
-
resourceDeleteUrl: '',
|
|
345
|
-
resourceGetBody: '',
|
|
346
|
-
resourceGetQuery: '',
|
|
347
|
-
resourceGetUrl: '',
|
|
348
|
-
resourceQueryBody: '',
|
|
349
|
-
resourceQueryQuery: '',
|
|
350
|
-
resourceQueryUrl: '',
|
|
351
|
-
resourceUpdateBody: '',
|
|
352
|
-
resourceUpdateQuery: '',
|
|
353
|
-
resourceUpdateUrl: '',
|
|
354
|
-
},
|
|
355
|
-
app: { 'pages.page': 'Page' },
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
it('should extract share action remappers', () => {
|
|
359
|
-
const result = extractAppMessages({
|
|
360
|
-
defaultPage: '',
|
|
361
|
-
pages: [
|
|
362
|
-
{
|
|
363
|
-
name: 'Page',
|
|
364
|
-
blocks: [
|
|
365
|
-
{
|
|
366
|
-
type: 'test',
|
|
367
|
-
version: '1.2.3',
|
|
368
|
-
actions: {
|
|
369
|
-
onClick: {
|
|
370
|
-
type: 'share',
|
|
371
|
-
text: { translate: 'shareText' },
|
|
372
|
-
title: { translate: 'shareTitle' },
|
|
373
|
-
url: { translate: 'shareUrl' },
|
|
374
|
-
},
|
|
375
|
-
},
|
|
376
|
-
},
|
|
377
|
-
],
|
|
378
|
-
},
|
|
379
|
-
],
|
|
380
|
-
});
|
|
381
|
-
expect(result).toMatchObject({
|
|
382
|
-
messageIds: { shareText: '', shareTitle: '', shareUrl: '' },
|
|
383
|
-
app: { 'pages.page': 'Page' },
|
|
384
|
-
});
|
|
385
|
-
});
|
|
386
|
-
it('should extract names from tabs pages', () => {
|
|
387
|
-
const result = extractAppMessages({
|
|
388
|
-
defaultPage: '',
|
|
389
|
-
pages: [
|
|
390
|
-
{
|
|
391
|
-
name: 'Tabs',
|
|
392
|
-
type: 'tabs',
|
|
393
|
-
tabs: [{ name: 'Tab', blocks: [] }],
|
|
394
|
-
},
|
|
395
|
-
],
|
|
396
|
-
});
|
|
397
|
-
expect(result).toMatchObject({ app: { 'pages.tabs': 'Tabs', 'pages.tabs.tabs.0': 'Tab' } });
|
|
398
|
-
});
|
|
399
|
-
it('should append any messages returned by onBlock', () => {
|
|
400
|
-
const onBlock = vi.fn().mockReturnValue({ foo: 'bar' });
|
|
401
|
-
const result = extractAppMessages({
|
|
402
|
-
defaultPage: '',
|
|
403
|
-
pages: [{ name: 'Page', blocks: [{ type: '', version: '' }] }],
|
|
404
|
-
}, onBlock);
|
|
405
|
-
expect(onBlock).toHaveBeenCalledWith({ type: '', version: '' }, ['pages', 'page', 'blocks', 0]);
|
|
406
|
-
expect(result).toMatchObject({ app: { 'pages.page': 'Page' } });
|
|
407
|
-
});
|
|
408
|
-
});
|
|
409
|
-
//# sourceMappingURL=appMessages.test.js.map
|
package/blockUtils.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/blockUtils.test.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { getAppBlocks, normalizeBlockName, parseBlockName, prefixBlockURL, stripBlockName, } from './blockUtils.js';
|
|
3
|
-
describe('normalizeBlockName', () => {
|
|
4
|
-
it('should prepend @appsemble if no organization is prepended', () => {
|
|
5
|
-
const blockName = 'form';
|
|
6
|
-
const result = normalizeBlockName(blockName);
|
|
7
|
-
expect(result).toBe(`@appsemble/${blockName}`);
|
|
8
|
-
});
|
|
9
|
-
it('should leave block name intact if organization is prepended', () => {
|
|
10
|
-
const blockName = '@example/test';
|
|
11
|
-
const result = normalizeBlockName(blockName);
|
|
12
|
-
expect(result).toBe(blockName);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
15
|
-
describe('stripBlockName', () => {
|
|
16
|
-
it('should strip the @appsemble prefix from official blocks', () => {
|
|
17
|
-
const result = stripBlockName('@appsemble/table');
|
|
18
|
-
expect(result).toBe('table');
|
|
19
|
-
});
|
|
20
|
-
it('should keep other organization prefixes', () => {
|
|
21
|
-
const result = stripBlockName('@other/table');
|
|
22
|
-
expect(result).toBe('@other/table');
|
|
23
|
-
});
|
|
24
|
-
it('should support unprefixed block names', () => {
|
|
25
|
-
const result = stripBlockName('table');
|
|
26
|
-
expect(result).toBe('table');
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
describe('parseBlockName', () => {
|
|
30
|
-
it('should return a tuple of organization id and block id', () => {
|
|
31
|
-
const result = parseBlockName('@example/test');
|
|
32
|
-
expect(result).toStrictEqual(['example', 'test']);
|
|
33
|
-
});
|
|
34
|
-
it('should support numeric values', () => {
|
|
35
|
-
const result = parseBlockName('@123-foo/456-bar');
|
|
36
|
-
expect(result).toStrictEqual(['123-foo', '456-bar']);
|
|
37
|
-
});
|
|
38
|
-
it('should support official appsemble blocks', () => {
|
|
39
|
-
const result = parseBlockName('detail-viewer');
|
|
40
|
-
expect(result).toStrictEqual(['appsemble', 'detail-viewer']);
|
|
41
|
-
});
|
|
42
|
-
it('should return undefined for invalid values', () => {
|
|
43
|
-
const result = parseBlockName('FooBar');
|
|
44
|
-
expect(result).toBeUndefined();
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
describe('getAppBlocks', () => {
|
|
48
|
-
it('should find unique block types inside an app', () => {
|
|
49
|
-
const result = getAppBlocks({
|
|
50
|
-
name: '',
|
|
51
|
-
defaultPage: '',
|
|
52
|
-
pages: [
|
|
53
|
-
{
|
|
54
|
-
name: '',
|
|
55
|
-
blocks: [
|
|
56
|
-
{ type: 'foo', version: '0.0.0' },
|
|
57
|
-
{ type: '@appsemble/foo', version: '0.0.0' },
|
|
58
|
-
{ type: 'foo', version: '0.0.1' },
|
|
59
|
-
{ type: 'bar', version: '0.0.1' },
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
});
|
|
64
|
-
expect(result).toStrictEqual([
|
|
65
|
-
{ type: '@appsemble/foo', version: '0.0.0' },
|
|
66
|
-
{ type: '@appsemble/foo', version: '0.0.1' },
|
|
67
|
-
{ type: '@appsemble/bar', version: '0.0.1' },
|
|
68
|
-
]);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe('prefixBlockURL', () => {
|
|
72
|
-
it('should populate the API url with block properties', () => {
|
|
73
|
-
const result = prefixBlockURL({ type: '@appsemble/test', version: '1.0.0' }, 'test.css');
|
|
74
|
-
expect(result).toBe('/api/blocks/@appsemble/test/versions/1.0.0/test.css');
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
//# sourceMappingURL=blockUtils.test.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { domainPattern, googleAnalyticsIDPattern, normalized, partialNormalized, } from './patterns.js';
|
|
3
|
-
describe('partialNormalized', () => {
|
|
4
|
-
it.each([
|
|
5
|
-
['Ffoo', 'foo'],
|
|
6
|
-
['barB', 'bar'],
|
|
7
|
-
['I am victorous', 'am'],
|
|
8
|
-
])('should match %j as %j', (input, expected) => {
|
|
9
|
-
const match = input.match(partialNormalized);
|
|
10
|
-
expect(match).not.toBeNull();
|
|
11
|
-
expect(match).toHaveLength(2);
|
|
12
|
-
expect([...match]).toStrictEqual([expected, expected]);
|
|
13
|
-
});
|
|
14
|
-
it('should be reusable to compose a new regular expression', () => {
|
|
15
|
-
const composed = new RegExp(`^@${partialNormalized.source}/${partialNormalized.source}$`);
|
|
16
|
-
const match = '@foo/bar'.match(composed);
|
|
17
|
-
expect(match).not.toBeNull();
|
|
18
|
-
expect(match).toHaveLength(3);
|
|
19
|
-
expect([...match]).toStrictEqual(['@foo/bar', 'foo', 'bar']);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
describe('normalized', () => {
|
|
23
|
-
it.each([
|
|
24
|
-
'foo',
|
|
25
|
-
'bar',
|
|
26
|
-
'a',
|
|
27
|
-
'ab',
|
|
28
|
-
'hyphenated-string',
|
|
29
|
-
'multi-hyphenated-string',
|
|
30
|
-
'1',
|
|
31
|
-
'10-second-move',
|
|
32
|
-
'13-37',
|
|
33
|
-
])('should match %j', (string) => {
|
|
34
|
-
expect(string).toMatch(normalized);
|
|
35
|
-
});
|
|
36
|
-
it.each([
|
|
37
|
-
'-',
|
|
38
|
-
'Uppercase',
|
|
39
|
-
'uppercasE',
|
|
40
|
-
'camelCase',
|
|
41
|
-
'double--hyphen',
|
|
42
|
-
'trouble--double--hyphen',
|
|
43
|
-
'triple---hyphen',
|
|
44
|
-
'under_score',
|
|
45
|
-
'aććëņtèd',
|
|
46
|
-
'🐱',
|
|
47
|
-
])('should not match %j', (string) => {
|
|
48
|
-
expect(string).not.toMatch(normalized);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
describe('domainPattern', () => {
|
|
52
|
-
it.each([
|
|
53
|
-
'example.com',
|
|
54
|
-
'valid.com',
|
|
55
|
-
'definitely.valid.org',
|
|
56
|
-
'a.nl',
|
|
57
|
-
'very.deeply.nested.domain.name.example',
|
|
58
|
-
])('should match %j', (string) => {
|
|
59
|
-
expect(string).toMatch(domainPattern);
|
|
60
|
-
});
|
|
61
|
-
it.each([
|
|
62
|
-
'a',
|
|
63
|
-
'a.a',
|
|
64
|
-
'.com',
|
|
65
|
-
'-.de',
|
|
66
|
-
'valid.ínválíd.com',
|
|
67
|
-
'example.COM',
|
|
68
|
-
'EXAMPLE.com',
|
|
69
|
-
'EXAMPLE.COM',
|
|
70
|
-
'This is a random string',
|
|
71
|
-
])('should not match %j', (string) => {
|
|
72
|
-
expect(string).not.toMatch(domainPattern);
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe('googleAnalyticsIDPattern', () => {
|
|
76
|
-
it.each(['', 'UA-12345678-9', 'G-0123456789ABC', 'UA-211654446-1'])('should match %j', (string) => {
|
|
77
|
-
expect(string).toMatch(googleAnalyticsIDPattern);
|
|
78
|
-
});
|
|
79
|
-
it.each([' ', 'AU-123456789-0', 'UA-123-123', 'UA-1234-12345', 'G-012345678abc'])('should match %j', (string) => {
|
|
80
|
-
expect(string).not.toMatch(googleAnalyticsIDPattern);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
//# sourceMappingURL=patterns.test.js.map
|
package/convertToCsv.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/convertToCsv.test.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { convertToCsv } from './convertToCsv.js';
|
|
3
|
-
describe('convertToCsv', () => {
|
|
4
|
-
it('should throw an error if input is null', () => {
|
|
5
|
-
const input = null;
|
|
6
|
-
expect(() => convertToCsv(input)).toThrow(new Error('No data'));
|
|
7
|
-
});
|
|
8
|
-
it('should return an error if the input has no keys', () => {
|
|
9
|
-
const input = {};
|
|
10
|
-
expect(() => convertToCsv(input)).toThrow(new Error('No headers could be found'));
|
|
11
|
-
});
|
|
12
|
-
it('should return an error if the input is a primitive', () => {
|
|
13
|
-
const input = 'foo';
|
|
14
|
-
expect(() => convertToCsv(input)).toThrow(new TypeError('Data is of an invalid type'));
|
|
15
|
-
});
|
|
16
|
-
it('should correctly combines all headers', () => {
|
|
17
|
-
const input = [
|
|
18
|
-
{ foo: 123, baz: 1 },
|
|
19
|
-
{ foo: 123, bar: 'bar' },
|
|
20
|
-
];
|
|
21
|
-
const output = 'bar,baz,foo\r\n,1,123\r\nbar,,123\r\n';
|
|
22
|
-
expect(convertToCsv(input)).toStrictEqual(output);
|
|
23
|
-
});
|
|
24
|
-
it('should support an arrays of objects', () => {
|
|
25
|
-
const input = [{ foo: 123 }, { foo: 321 }];
|
|
26
|
-
const output = 'foo\r\n123\r\n321\r\n';
|
|
27
|
-
expect(convertToCsv(input)).toStrictEqual(output);
|
|
28
|
-
});
|
|
29
|
-
it('should escape strings containing commas', () => {
|
|
30
|
-
const input = [{ 'foo,bar': 'foo,bar' }];
|
|
31
|
-
const output = '"foo,bar"\r\n"foo,bar"\r\n';
|
|
32
|
-
expect(convertToCsv(input)).toStrictEqual(output);
|
|
33
|
-
});
|
|
34
|
-
it('should escape strings containing newlines', () => {
|
|
35
|
-
const input = { 'foo\r\nline2': 'foo\r\nbar' };
|
|
36
|
-
const output = '"foo\r\nline2"\r\n"foo\r\nbar"\r\n';
|
|
37
|
-
expect(convertToCsv(input)).toStrictEqual(output);
|
|
38
|
-
});
|
|
39
|
-
it('should escape quotes', () => {
|
|
40
|
-
const input = { 'foo "example" bar': 'Lots of "str"ings"' };
|
|
41
|
-
const output = '"foo ""example"" bar"\r\n"Lots of ""str""ings"""\r\n';
|
|
42
|
-
expect(convertToCsv(input)).toStrictEqual(output);
|
|
43
|
-
});
|
|
44
|
-
it('should convert date objects', () => {
|
|
45
|
-
const input = { foo: new Date(0) };
|
|
46
|
-
const output = 'foo\r\n1970-01-01T00:00:00.000Z\r\n';
|
|
47
|
-
expect(convertToCsv(input)).toStrictEqual(output);
|
|
48
|
-
});
|
|
49
|
-
it('should return null on empty results', () => {
|
|
50
|
-
const input = [];
|
|
51
|
-
const output = null;
|
|
52
|
-
expect(convertToCsv(input)).toStrictEqual(output);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
//# sourceMappingURL=convertToCsv.test.js.map
|
package/has.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/has.test.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { has } from './has.js';
|
|
3
|
-
describe('has', () => {
|
|
4
|
-
it('should return false for null targets', () => {
|
|
5
|
-
expect(has(null, 'toString')).toBe(false);
|
|
6
|
-
});
|
|
7
|
-
it('should return false for undefined targets', () => {
|
|
8
|
-
expect(has(undefined, 'toString')).toBe(false);
|
|
9
|
-
});
|
|
10
|
-
it('should return false for attributes inferred from the prototype chain', () => {
|
|
11
|
-
expect(has({}, 'toString')).toBe(false);
|
|
12
|
-
});
|
|
13
|
-
it('should return true for own properties', () => {
|
|
14
|
-
expect(has({ toString: null }, 'toString')).toBe(true);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
//# sourceMappingURL=has.test.js.map
|
package/i18n.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|