@appsemble/utils 0.33.5 → 0.33.7
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/api/components/schemas/App.js +5 -1
- package/api/components/schemas/BlockVersion.js +6 -1
- package/api/components/schemas/index.d.ts +0 -118
- package/api/components/schemas/index.js +0 -118
- package/api/paths/appTemplates.js +12 -3
- package/appMessages.d.ts +2 -2
- package/appMessages.js +1 -1
- package/authorization.d.ts +1 -11
- package/authorization.js +1 -163
- package/constants/index.d.ts +0 -2
- package/constants/index.js +0 -2
- package/formatRequestAction.d.ts +1 -1
- package/index.d.ts +2 -14
- package/index.js +2 -14
- package/miscellaneous.d.ts +5 -13
- package/miscellaneous.js +6 -33
- package/package.json +3 -2
- package/theme.d.ts +1 -1
- package/theme.js +1 -1
- package/types.d.ts +1 -1
- package/validateAppMessages.d.ts +2 -1
- package/validateAppMessages.js +2 -2
- package/allActions.d.ts +0 -3
- package/allActions.js +0 -11
- package/api/components/schemas/ActionDefinition.d.ts +0 -2
- package/api/components/schemas/ActionDefinition.js +0 -95
- package/api/components/schemas/AnalyticsActionDefinition.d.ts +0 -1
- package/api/components/schemas/AnalyticsActionDefinition.js +0 -25
- package/api/components/schemas/AppDefinition.d.ts +0 -2
- package/api/components/schemas/AppDefinition.js +0 -126
- package/api/components/schemas/AppLayoutDefinition.d.ts +0 -2
- package/api/components/schemas/AppLayoutDefinition.js +0 -46
- package/api/components/schemas/AppMemberCurrentPatchActionDefinition.d.ts +0 -1
- package/api/components/schemas/AppMemberCurrentPatchActionDefinition.js +0 -30
- package/api/components/schemas/AppMemberDeleteActionDefinition.d.ts +0 -1
- package/api/components/schemas/AppMemberDeleteActionDefinition.js +0 -20
- package/api/components/schemas/AppMemberInviteActionDefinition.d.ts +0 -1
- package/api/components/schemas/AppMemberInviteActionDefinition.js +0 -24
- package/api/components/schemas/AppMemberLoginActionDefinition.d.ts +0 -1
- package/api/components/schemas/AppMemberLoginActionDefinition.js +0 -24
- package/api/components/schemas/AppMemberLogoutActionDefinition.d.ts +0 -1
- package/api/components/schemas/AppMemberLogoutActionDefinition.js +0 -14
- package/api/components/schemas/AppMemberPropertiesPatchActionDefinition.d.ts +0 -1
- package/api/components/schemas/AppMemberPropertiesPatchActionDefinition.js +0 -26
- package/api/components/schemas/AppMemberPropertyDefinition.d.ts +0 -2
- package/api/components/schemas/AppMemberPropertyDefinition.js +0 -49
- package/api/components/schemas/AppMemberQueryActionDefinition.d.ts +0 -1
- package/api/components/schemas/AppMemberQueryActionDefinition.js +0 -24
- package/api/components/schemas/AppMemberRegisterActionDefinition.d.ts +0 -1
- package/api/components/schemas/AppMemberRegisterActionDefinition.js +0 -43
- package/api/components/schemas/AppMemberRoleUpdateActionDefinition.d.ts +0 -1
- package/api/components/schemas/AppMemberRoleUpdateActionDefinition.js +0 -27
- package/api/components/schemas/AppMembersDefinition.d.ts +0 -2
- package/api/components/schemas/AppMembersDefinition.js +0 -17
- package/api/components/schemas/ArrayRemapperDefinition.d.ts +0 -2
- package/api/components/schemas/ArrayRemapperDefinition.js +0 -22
- package/api/components/schemas/BaseActionDefinition.d.ts +0 -2
- package/api/components/schemas/BaseActionDefinition.js +0 -10
- package/api/components/schemas/BaseJSONSchema.d.ts +0 -2
- package/api/components/schemas/BaseJSONSchema.js +0 -24
- package/api/components/schemas/BasePageDefinition.d.ts +0 -2
- package/api/components/schemas/BasePageDefinition.js +0 -92
- package/api/components/schemas/BlockDefinition.d.ts +0 -2
- package/api/components/schemas/BlockDefinition.js +0 -94
- package/api/components/schemas/ConditionActionDefinition.d.ts +0 -1
- package/api/components/schemas/ConditionActionDefinition.js +0 -30
- package/api/components/schemas/ContainerDefinition.d.ts +0 -2
- package/api/components/schemas/ContainerDefinition.js +0 -52
- package/api/components/schemas/ContainerPageDefinition.d.ts +0 -1
- package/api/components/schemas/ContainerPageDefinition.js +0 -56
- package/api/components/schemas/ControllerActionDefinition.d.ts +0 -1
- package/api/components/schemas/ControllerActionDefinition.js +0 -18
- package/api/components/schemas/ControllerDefinition.d.ts +0 -2
- package/api/components/schemas/ControllerDefinition.js +0 -17
- package/api/components/schemas/CronDefinition.d.ts +0 -2
- package/api/components/schemas/CronDefinition.js +0 -20
- package/api/components/schemas/CsvParseActionDefinition.d.ts +0 -1
- package/api/components/schemas/CsvParseActionDefinition.js +0 -22
- package/api/components/schemas/CustomFontDefinition.d.ts +0 -2
- package/api/components/schemas/CustomFontDefinition.js +0 -20
- package/api/components/schemas/DialogActionDefinition.d.ts +0 -1
- package/api/components/schemas/DialogActionDefinition.js +0 -40
- package/api/components/schemas/DialogErrorActionDefinition.d.ts +0 -1
- package/api/components/schemas/DialogErrorActionDefinition.js +0 -17
- package/api/components/schemas/DialogOkActionDefinition.d.ts +0 -1
- package/api/components/schemas/DialogOkActionDefinition.js +0 -17
- package/api/components/schemas/DownloadActionDefinition.d.ts +0 -1
- package/api/components/schemas/DownloadActionDefinition.js +0 -19
- package/api/components/schemas/EachActionDefinition.d.ts +0 -1
- package/api/components/schemas/EachActionDefinition.js +0 -26
- package/api/components/schemas/EmailActionDefinition.d.ts +0 -1
- package/api/components/schemas/EmailActionDefinition.js +0 -54
- package/api/components/schemas/EventActionDefinition.d.ts +0 -1
- package/api/components/schemas/EventActionDefinition.js +0 -27
- package/api/components/schemas/EventsDefinition.d.ts +0 -2
- package/api/components/schemas/EventsDefinition.js +0 -29
- package/api/components/schemas/FilterParametersDefinition.d.ts +0 -2
- package/api/components/schemas/FilterParametersDefinition.js +0 -15
- package/api/components/schemas/FlowBackActionDefinition.d.ts +0 -1
- package/api/components/schemas/FlowBackActionDefinition.js +0 -16
- package/api/components/schemas/FlowCancelActionDefinition.d.ts +0 -1
- package/api/components/schemas/FlowCancelActionDefinition.js +0 -14
- package/api/components/schemas/FlowFinishActionDefinition.d.ts +0 -1
- package/api/components/schemas/FlowFinishActionDefinition.js +0 -16
- package/api/components/schemas/FlowNextActionDefinition.d.ts +0 -1
- package/api/components/schemas/FlowNextActionDefinition.js +0 -17
- package/api/components/schemas/FlowPageActionsDefinition.d.ts +0 -2
- package/api/components/schemas/FlowPageActionsDefinition.js +0 -23
- package/api/components/schemas/FlowPageDefinition.d.ts +0 -1
- package/api/components/schemas/FlowPageDefinition.js +0 -37
- package/api/components/schemas/FlowToActionDefinition.d.ts +0 -1
- package/api/components/schemas/FlowToActionDefinition.js +0 -21
- package/api/components/schemas/GoogleFontDefinition.d.ts +0 -2
- package/api/components/schemas/GoogleFontDefinition.js +0 -22
- package/api/components/schemas/GroupMemberDeleteActionDefinition.d.ts +0 -1
- package/api/components/schemas/GroupMemberDeleteActionDefinition.js +0 -18
- package/api/components/schemas/GroupMemberInviteActionDefinition.d.ts +0 -1
- package/api/components/schemas/GroupMemberInviteActionDefinition.js +0 -26
- package/api/components/schemas/GroupMemberQueryActionDefinition.d.ts +0 -1
- package/api/components/schemas/GroupMemberQueryActionDefinition.js +0 -18
- package/api/components/schemas/GroupMemberRoleUpdateActionDefinition.d.ts +0 -1
- package/api/components/schemas/GroupMemberRoleUpdateActionDefinition.js +0 -22
- package/api/components/schemas/GroupQueryActionDefinition.d.ts +0 -1
- package/api/components/schemas/GroupQueryActionDefinition.js +0 -14
- package/api/components/schemas/JSONPointer.d.ts +0 -1
- package/api/components/schemas/JSONPointer.js +0 -20
- package/api/components/schemas/JSONSchema.d.ts +0 -2
- package/api/components/schemas/JSONSchema.js +0 -20
- package/api/components/schemas/JSONSchemaAnyOf.d.ts +0 -1
- package/api/components/schemas/JSONSchemaAnyOf.js +0 -26
- package/api/components/schemas/JSONSchemaArray.d.ts +0 -1
- package/api/components/schemas/JSONSchemaArray.js +0 -47
- package/api/components/schemas/JSONSchemaBoolean.d.ts +0 -1
- package/api/components/schemas/JSONSchemaBoolean.js +0 -37
- package/api/components/schemas/JSONSchemaConst.d.ts +0 -1
- package/api/components/schemas/JSONSchemaConst.js +0 -16
- package/api/components/schemas/JSONSchemaEnum.d.ts +0 -1
- package/api/components/schemas/JSONSchemaEnum.js +0 -36
- package/api/components/schemas/JSONSchemaInteger.d.ts +0 -1
- package/api/components/schemas/JSONSchemaInteger.js +0 -55
- package/api/components/schemas/JSONSchemaMultiType.d.ts +0 -1
- package/api/components/schemas/JSONSchemaMultiType.js +0 -48
- package/api/components/schemas/JSONSchemaNot.d.ts +0 -1
- package/api/components/schemas/JSONSchemaNot.js +0 -23
- package/api/components/schemas/JSONSchemaNull.d.ts +0 -1
- package/api/components/schemas/JSONSchemaNull.js +0 -16
- package/api/components/schemas/JSONSchemaNumber.d.ts +0 -1
- package/api/components/schemas/JSONSchemaNumber.js +0 -63
- package/api/components/schemas/JSONSchemaObject.d.ts +0 -1
- package/api/components/schemas/JSONSchemaObject.js +0 -74
- package/api/components/schemas/JSONSchemaOneOf.d.ts +0 -1
- package/api/components/schemas/JSONSchemaOneOf.js +0 -24
- package/api/components/schemas/JSONSchemaRemapper.d.ts +0 -1
- package/api/components/schemas/JSONSchemaRemapper.js +0 -19
- package/api/components/schemas/JSONSchemaRoot.d.ts +0 -1
- package/api/components/schemas/JSONSchemaRoot.js +0 -21
- package/api/components/schemas/JSONSchemaString.d.ts +0 -1
- package/api/components/schemas/JSONSchemaString.js +0 -107
- package/api/components/schemas/LinkActionDefinition.d.ts +0 -1
- package/api/components/schemas/LinkActionDefinition.js +0 -29
- package/api/components/schemas/LinkBackActionDefinition.d.ts +0 -1
- package/api/components/schemas/LinkBackActionDefinition.js +0 -14
- package/api/components/schemas/LinkNextActionDefinition.d.ts +0 -1
- package/api/components/schemas/LinkNextActionDefinition.js +0 -14
- package/api/components/schemas/LogActionDefinition.d.ts +0 -1
- package/api/components/schemas/LogActionDefinition.js +0 -22
- package/api/components/schemas/LoopPageActionsDefinition.d.ts +0 -2
- package/api/components/schemas/LoopPageActionsDefinition.js +0 -24
- package/api/components/schemas/LoopPageDefinition.d.ts +0 -1
- package/api/components/schemas/LoopPageDefinition.js +0 -32
- package/api/components/schemas/MatchActionDefinition.d.ts +0 -1
- package/api/components/schemas/MatchActionDefinition.js +0 -35
- package/api/components/schemas/MessageActionDefinition.d.ts +0 -1
- package/api/components/schemas/MessageActionDefinition.js +0 -40
- package/api/components/schemas/NoopActionDefinition.d.ts +0 -1
- package/api/components/schemas/NoopActionDefinition.js +0 -17
- package/api/components/schemas/NotificationHookDataDefinition.d.ts +0 -2
- package/api/components/schemas/NotificationHookDataDefinition.js +0 -24
- package/api/components/schemas/NotificationHookDefinition.d.ts +0 -2
- package/api/components/schemas/NotificationHookDefinition.js +0 -32
- package/api/components/schemas/NotifyActionDefinition.d.ts +0 -1
- package/api/components/schemas/NotifyActionDefinition.js +0 -32
- package/api/components/schemas/ObjectRemapperDefinition.d.ts +0 -2
- package/api/components/schemas/ObjectRemapperDefinition.js +0 -17
- package/api/components/schemas/PageActionsDefinition.d.ts +0 -2
- package/api/components/schemas/PageActionsDefinition.js +0 -12
- package/api/components/schemas/PageDefinition.d.ts +0 -1
- package/api/components/schemas/PageDefinition.js +0 -26
- package/api/components/schemas/RemapperDefinition.d.ts +0 -2
- package/api/components/schemas/RemapperDefinition.js +0 -27
- package/api/components/schemas/RequestActionDefinition.d.ts +0 -1
- package/api/components/schemas/RequestActionDefinition.js +0 -75
- package/api/components/schemas/ResourceCountActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceCountActionDefinition.js +0 -22
- package/api/components/schemas/ResourceCreateActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceCreateActionDefinition.js +0 -18
- package/api/components/schemas/ResourceDefinition.d.ts +0 -2
- package/api/components/schemas/ResourceDefinition.js +0 -263
- package/api/components/schemas/ResourceDeleteActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceDeleteActionDefinition.js +0 -18
- package/api/components/schemas/ResourceDeleteAllActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceDeleteAllActionDefinition.js +0 -21
- package/api/components/schemas/ResourceDeleteBulkActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceDeleteBulkActionDefinition.js +0 -18
- package/api/components/schemas/ResourceGetActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceGetActionDefinition.js +0 -25
- package/api/components/schemas/ResourceHistoryDefinition.d.ts +0 -2
- package/api/components/schemas/ResourceHistoryDefinition.js +0 -14
- package/api/components/schemas/ResourceHistoryGetActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceHistoryGetActionDefinition.js +0 -18
- package/api/components/schemas/ResourceHooksDefinition.d.ts +0 -2
- package/api/components/schemas/ResourceHooksDefinition.js +0 -10
- package/api/components/schemas/ResourcePatchActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourcePatchActionDefinition.js +0 -21
- package/api/components/schemas/ResourceQueryActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceQueryActionDefinition.js +0 -26
- package/api/components/schemas/ResourceSubscriptionStatusActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceSubscriptionStatusActionDefinition.js +0 -23
- package/api/components/schemas/ResourceSubscriptionSubscribeActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceSubscriptionSubscribeActionDefinition.js +0 -23
- package/api/components/schemas/ResourceSubscriptionToggleActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceSubscriptionToggleActionDefinition.js +0 -23
- package/api/components/schemas/ResourceSubscriptionUnsubscribeActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceSubscriptionUnsubscribeActionDefinition.js +0 -23
- package/api/components/schemas/ResourceUpdateActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceUpdateActionDefinition.js +0 -18
- package/api/components/schemas/ResourceUpdatePositionsActionDefinition.d.ts +0 -1
- package/api/components/schemas/ResourceUpdatePositionsActionDefinition.js +0 -21
- package/api/components/schemas/ResourceViewDefinition.d.ts +0 -2
- package/api/components/schemas/ResourceViewDefinition.js +0 -24
- package/api/components/schemas/SecurityCronDefinition.d.ts +0 -2
- package/api/components/schemas/SecurityCronDefinition.js +0 -26
- package/api/components/schemas/SecurityDefaultDefinition.d.ts +0 -2
- package/api/components/schemas/SecurityDefaultDefinition.js +0 -34
- package/api/components/schemas/SecurityDefinition.d.ts +0 -2
- package/api/components/schemas/SecurityDefinition.js +0 -17
- package/api/components/schemas/SecurityGuestDefinition.d.ts +0 -2
- package/api/components/schemas/SecurityGuestDefinition.js +0 -26
- package/api/components/schemas/SecurityRoleDefinition.d.ts +0 -2
- package/api/components/schemas/SecurityRoleDefinition.js +0 -35
- package/api/components/schemas/ShareActionDefinition.d.ts +0 -1
- package/api/components/schemas/ShareActionDefinition.js +0 -30
- package/api/components/schemas/StaticActionDefinition.d.ts +0 -1
- package/api/components/schemas/StaticActionDefinition.js +0 -20
- package/api/components/schemas/StorageAppendActionDefinition.d.ts +0 -1
- package/api/components/schemas/StorageAppendActionDefinition.js +0 -43
- package/api/components/schemas/StorageDeleteActionDefinition.d.ts +0 -1
- package/api/components/schemas/StorageDeleteActionDefinition.js +0 -31
- package/api/components/schemas/StorageReadActionDefinition.d.ts +0 -1
- package/api/components/schemas/StorageReadActionDefinition.js +0 -32
- package/api/components/schemas/StorageSubtractActionDefinition.d.ts +0 -1
- package/api/components/schemas/StorageSubtractActionDefinition.js +0 -35
- package/api/components/schemas/StorageUpdateActionDefinition.d.ts +0 -1
- package/api/components/schemas/StorageUpdateActionDefinition.js +0 -46
- package/api/components/schemas/StorageWriteActionDefinition.d.ts +0 -1
- package/api/components/schemas/StorageWriteActionDefinition.js +0 -46
- package/api/components/schemas/SubPage.d.ts +0 -2
- package/api/components/schemas/SubPage.js +0 -36
- package/api/components/schemas/TabsPageDefinition.d.ts +0 -1
- package/api/components/schemas/TabsPageDefinition.js +0 -46
- package/api/components/schemas/Theme.d.ts +0 -2
- package/api/components/schemas/Theme.js +0 -80
- package/api/components/schemas/ThrowActionDefinition.d.ts +0 -1
- package/api/components/schemas/ThrowActionDefinition.js +0 -17
- package/api/components/schemas/WebhookDefinition.d.ts +0 -2
- package/api/components/schemas/WebhookDefinition.js +0 -17
- package/api/components/schemas/utils.d.ts +0 -13
- package/api/components/schemas/utils.js +0 -34
- package/appMembers.d.ts +0 -1
- package/appMembers.js +0 -9
- package/blockUtils.d.ts +0 -31
- package/blockUtils.js +0 -65
- package/constants/baseTheme.d.ts +0 -2
- package/constants/baseTheme.js +0 -16
- package/constants/fonts.d.ts +0 -6
- package/constants/fonts.js +0 -1607
- package/examples.d.ts +0 -23
- package/examples.js +0 -975
- package/findPageByName.d.ts +0 -2
- package/findPageByName.js +0 -15
- package/has.d.ts +0 -8
- package/has.js +0 -11
- package/ics.d.ts +0 -3
- package/ics.js +0 -41
- package/iterApp.d.ts +0 -64
- package/iterApp.js +0 -150
- package/jsonschema.d.ts +0 -54
- package/jsonschema.js +0 -185
- package/reference-schemas/actions/appMember.d.ts +0 -2
- package/reference-schemas/actions/appMember.js +0 -21
- package/reference-schemas/actions/flow.d.ts +0 -2
- package/reference-schemas/actions/flow.js +0 -13
- package/reference-schemas/actions/group.d.ts +0 -2
- package/reference-schemas/actions/group.js +0 -13
- package/reference-schemas/actions/index.d.ts +0 -7
- package/reference-schemas/actions/index.js +0 -8
- package/reference-schemas/actions/link.d.ts +0 -2
- package/reference-schemas/actions/link.js +0 -9
- package/reference-schemas/actions/miscellaneous.d.ts +0 -2
- package/reference-schemas/actions/miscellaneous.js +0 -43
- package/reference-schemas/actions/resources.d.ts +0 -2
- package/reference-schemas/actions/resources.js +0 -19
- package/reference-schemas/actions/storage.d.ts +0 -2
- package/reference-schemas/actions/storage.js +0 -15
- package/reference-schemas/remappers/arrays.d.ts +0 -2
- package/reference-schemas/remappers/arrays.js +0 -297
- package/reference-schemas/remappers/conditionals.d.ts +0 -2
- package/reference-schemas/remappers/conditionals.js +0 -167
- package/reference-schemas/remappers/config.d.ts +0 -2
- package/reference-schemas/remappers/config.js +0 -13
- package/reference-schemas/remappers/data.d.ts +0 -2
- package/reference-schemas/remappers/data.js +0 -394
- package/reference-schemas/remappers/dates.d.ts +0 -2
- package/reference-schemas/remappers/dates.js +0 -94
- package/reference-schemas/remappers/history.d.ts +0 -2
- package/reference-schemas/remappers/history.js +0 -246
- package/reference-schemas/remappers/index.d.ts +0 -12
- package/reference-schemas/remappers/index.js +0 -13
- package/reference-schemas/remappers/numbers.d.ts +0 -2
- package/reference-schemas/remappers/numbers.js +0 -30
- package/reference-schemas/remappers/objects.d.ts +0 -2
- package/reference-schemas/remappers/objects.js +0 -127
- package/reference-schemas/remappers/odata.d.ts +0 -2
- package/reference-schemas/remappers/odata.js +0 -95
- package/reference-schemas/remappers/randoms.d.ts +0 -2
- package/reference-schemas/remappers/randoms.js +0 -82
- package/reference-schemas/remappers/strings.d.ts +0 -2
- package/reference-schemas/remappers/strings.js +0 -93
- package/reference-schemas/remappers/unsorted.d.ts +0 -2
- package/reference-schemas/remappers/unsorted.js +0 -276
- package/remap.d.ts +0 -74
- package/remap.js +0 -692
- package/serverActions.d.ts +0 -2
- package/serverActions.js +0 -21
- package/string.d.ts +0 -23
- package/string.js +0 -30
- package/validation.d.ts +0 -25
- package/validation.js +0 -1231
package/remap.js
DELETED
|
@@ -1,692 +0,0 @@
|
|
|
1
|
-
import { filter, literalValues, param } from '@odata/parser';
|
|
2
|
-
import { addMilliseconds, format, parse, parseISO } from 'date-fns';
|
|
3
|
-
import equal from 'fast-deep-equal';
|
|
4
|
-
import { XMLParser } from 'fast-xml-parser';
|
|
5
|
-
import { createEvent } from 'ics';
|
|
6
|
-
import parseDuration from 'parse-duration';
|
|
7
|
-
import { has } from './has.js';
|
|
8
|
-
import { getDuration, processLocation } from './ics.js';
|
|
9
|
-
import { mapValues } from './mapValues.js';
|
|
10
|
-
import { stripNullValues } from './miscellaneous.js';
|
|
11
|
-
class RemapperError extends TypeError {
|
|
12
|
-
constructor(message, remapper) {
|
|
13
|
-
super(message);
|
|
14
|
-
this.name = 'RemapperError';
|
|
15
|
-
this.remapper = remapper;
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
function isPlainObject(value) {
|
|
19
|
-
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
20
|
-
}
|
|
21
|
-
function isEqualArray(a, b) {
|
|
22
|
-
if (a.length !== b.length) {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
return a.every((val, i) => val === b[i]);
|
|
26
|
-
}
|
|
27
|
-
function isEqualObject(a, b) {
|
|
28
|
-
const aKeys = Object.keys(a);
|
|
29
|
-
const bKeys = Object.keys(b);
|
|
30
|
-
if (aKeys.length !== bKeys.length) {
|
|
31
|
-
return false;
|
|
32
|
-
}
|
|
33
|
-
return aKeys.every((key) => bKeys.includes(key) && equal(a[key], b[key]));
|
|
34
|
-
}
|
|
35
|
-
function isNumber(a) {
|
|
36
|
-
return a !== undefined && a != null && a !== '' && !Number.isNaN(Number(a));
|
|
37
|
-
}
|
|
38
|
-
export function remap(remapper, input, context) {
|
|
39
|
-
if (typeof remapper === 'string' ||
|
|
40
|
-
typeof remapper === 'number' ||
|
|
41
|
-
typeof remapper === 'boolean' ||
|
|
42
|
-
remapper == null) {
|
|
43
|
-
return remapper;
|
|
44
|
-
}
|
|
45
|
-
let result = input;
|
|
46
|
-
// Workaround for ts(2589) Type instantiation is excessively deep and possibly infinite
|
|
47
|
-
const remappers = Array.isArray(remapper)
|
|
48
|
-
? remapper.flat(Number.POSITIVE_INFINITY)
|
|
49
|
-
: [remapper];
|
|
50
|
-
for (const mapper of remappers) {
|
|
51
|
-
const entries = Object.entries(mapper);
|
|
52
|
-
if (entries.length !== 1) {
|
|
53
|
-
console.error(mapper);
|
|
54
|
-
throw new RemapperError(`Remapper has multiple keys: ${Object.keys(mapper)
|
|
55
|
-
.map((key) => JSON.stringify(key))
|
|
56
|
-
.join(', ')}`, mapper);
|
|
57
|
-
}
|
|
58
|
-
const [[name, args]] = entries;
|
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
60
|
-
if (!has(mapperImplementations, name)) {
|
|
61
|
-
console.error(mapper);
|
|
62
|
-
throw new RemapperError(`Remapper name does not exist: ${JSON.stringify(name)}`, mapper);
|
|
63
|
-
}
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
65
|
-
const implementation = mapperImplementations[name];
|
|
66
|
-
result = implementation(args, result, { root: input, ...context });
|
|
67
|
-
}
|
|
68
|
-
return result;
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Implementations of all remappers.
|
|
72
|
-
*
|
|
73
|
-
* All arguments are deferred from remappers.
|
|
74
|
-
*
|
|
75
|
-
* @see Remappers
|
|
76
|
-
*/
|
|
77
|
-
const mapperImplementations = {
|
|
78
|
-
app(prop, input, context) {
|
|
79
|
-
if (prop === 'id') {
|
|
80
|
-
return context.appId;
|
|
81
|
-
}
|
|
82
|
-
if (prop === 'locale') {
|
|
83
|
-
return context.locale;
|
|
84
|
-
}
|
|
85
|
-
if (prop === 'url') {
|
|
86
|
-
return context.appUrl;
|
|
87
|
-
}
|
|
88
|
-
throw new Error(`Unknown app property: ${prop}`);
|
|
89
|
-
},
|
|
90
|
-
page(prop, input, context) {
|
|
91
|
-
if (prop === 'data') {
|
|
92
|
-
return context.pageData;
|
|
93
|
-
}
|
|
94
|
-
if (prop === 'url') {
|
|
95
|
-
return context.url;
|
|
96
|
-
}
|
|
97
|
-
throw new Error(`Unknown page property: ${prop}`);
|
|
98
|
-
},
|
|
99
|
-
context(prop, input, context) {
|
|
100
|
-
let result = context.context;
|
|
101
|
-
for (const p of String(prop).split('.')) {
|
|
102
|
-
if (result == null) {
|
|
103
|
-
return null;
|
|
104
|
-
}
|
|
105
|
-
result = result[p];
|
|
106
|
-
}
|
|
107
|
-
return result ?? null;
|
|
108
|
-
},
|
|
109
|
-
variable(name, input, context) {
|
|
110
|
-
if (context.getVariable) {
|
|
111
|
-
return context.getVariable(name);
|
|
112
|
-
}
|
|
113
|
-
return { variable: name };
|
|
114
|
-
},
|
|
115
|
-
equals(mappers, input, context) {
|
|
116
|
-
if (mappers.length <= 1) {
|
|
117
|
-
return true;
|
|
118
|
-
}
|
|
119
|
-
const values = mappers.map((mapper) => remap(mapper, input, context));
|
|
120
|
-
return values.every((value) => equal(values[0], value));
|
|
121
|
-
},
|
|
122
|
-
not(mappers, input, context) {
|
|
123
|
-
if (mappers.length <= 1) {
|
|
124
|
-
return !remap(mappers[0], input, context);
|
|
125
|
-
}
|
|
126
|
-
const [firstValue, ...otherValues] = mappers.map((mapper) => remap(mapper, input, context));
|
|
127
|
-
return !otherValues.some((value) => equal(firstValue, value));
|
|
128
|
-
},
|
|
129
|
-
or(mappers, input, context) {
|
|
130
|
-
const values = mappers.map((mapper) => Boolean(remap(mapper, input, context)));
|
|
131
|
-
return values.length > 0 ? values.includes(true) : true;
|
|
132
|
-
},
|
|
133
|
-
and(mappers, input, context) {
|
|
134
|
-
const values = mappers.map((mapper) => remap(mapper, input, context));
|
|
135
|
-
return values.every(Boolean);
|
|
136
|
-
},
|
|
137
|
-
step(mapper, input, context) {
|
|
138
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
139
|
-
// @ts-ignore 18048 variable is possibly undefined (strictNullChecks)
|
|
140
|
-
return context.stepRef.current[mapper];
|
|
141
|
-
},
|
|
142
|
-
'tab.name'(mapper, input, context) {
|
|
143
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
144
|
-
// @ts-ignore 18048 variable is possibly undefined (strictNullChecks)
|
|
145
|
-
return context.tabRef.current.name;
|
|
146
|
-
},
|
|
147
|
-
gt: ([left, right], input, context) =>
|
|
148
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
149
|
-
// @ts-ignore Messed up - 2571 Object is of type 'unknown'.
|
|
150
|
-
remap(left, input, context) > remap(right, input, context),
|
|
151
|
-
lt: ([left, right], input, context) =>
|
|
152
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
153
|
-
// @ts-ignore Messed up - 2571 Object is of type 'unknown'.
|
|
154
|
-
remap(left, input, context) < remap(right, input, context),
|
|
155
|
-
ics(mappers, input, context) {
|
|
156
|
-
let event;
|
|
157
|
-
const mappedStart = remap(mappers.start, input, context);
|
|
158
|
-
const start = mappedStart instanceof Date ? mappedStart : parseISO(mappedStart);
|
|
159
|
-
const sharedAttributes = {
|
|
160
|
-
start: [
|
|
161
|
-
start.getUTCFullYear(),
|
|
162
|
-
start.getUTCMonth() + 1,
|
|
163
|
-
start.getUTCDate(),
|
|
164
|
-
start.getUTCHours(),
|
|
165
|
-
start.getUTCMinutes(),
|
|
166
|
-
],
|
|
167
|
-
startInputType: 'utc',
|
|
168
|
-
startOutputType: 'utc',
|
|
169
|
-
title: remap(mappers.title, input, context),
|
|
170
|
-
description: remap(mappers.description ?? null, input, context),
|
|
171
|
-
url: remap(mappers.url ?? null, input, context),
|
|
172
|
-
location: remap(mappers.location ?? null, input, context),
|
|
173
|
-
geo: processLocation(remap(mappers.coordinates ?? null, input, context)),
|
|
174
|
-
productId: context.appUrl,
|
|
175
|
-
};
|
|
176
|
-
if ('end' in mappers) {
|
|
177
|
-
const mappedEnd = remap(mappers.end, input, context);
|
|
178
|
-
const end = mappedEnd instanceof Date ? mappedEnd : parseISO(mappedEnd);
|
|
179
|
-
event = {
|
|
180
|
-
...sharedAttributes,
|
|
181
|
-
endInputType: 'utc',
|
|
182
|
-
endOutputType: 'utc',
|
|
183
|
-
end: [
|
|
184
|
-
end.getUTCFullYear(),
|
|
185
|
-
end.getUTCMonth() + 1,
|
|
186
|
-
end.getUTCDate(),
|
|
187
|
-
end.getUTCHours(),
|
|
188
|
-
end.getUTCMinutes(),
|
|
189
|
-
],
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
event = {
|
|
194
|
-
...sharedAttributes,
|
|
195
|
-
duration: getDuration(remap(mappers.duration, input, context)),
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
|
-
const { error, value } = createEvent(event);
|
|
199
|
-
if (error) {
|
|
200
|
-
throw error;
|
|
201
|
-
}
|
|
202
|
-
return value;
|
|
203
|
-
},
|
|
204
|
-
if(mappers, input, context) {
|
|
205
|
-
const condition = remap(mappers.condition, input, context);
|
|
206
|
-
return remap(condition ? mappers.then : mappers.else, input, context);
|
|
207
|
-
},
|
|
208
|
-
match(mappers, input, context) {
|
|
209
|
-
return (remap(mappers.find((mapper) => remap(mapper.case, input, context))?.value ?? null, input, context) ?? null);
|
|
210
|
-
},
|
|
211
|
-
'object.from': (mappers, input, context) => mapValues(mappers, (mapper) => remap(mapper, input, context)),
|
|
212
|
-
'object.assign': (mappers, input, context) => ({
|
|
213
|
-
...input,
|
|
214
|
-
...mapValues(mappers, (mapper) => remap(mapper, input, context)),
|
|
215
|
-
}),
|
|
216
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
217
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
218
|
-
'object.omit'(keys, input) {
|
|
219
|
-
const result = { ...input };
|
|
220
|
-
for (const key of keys) {
|
|
221
|
-
if (Array.isArray(key)) {
|
|
222
|
-
let acc = result;
|
|
223
|
-
for (const [index, k] of key.entries()) {
|
|
224
|
-
if (index === key.length - 1) {
|
|
225
|
-
delete acc[k];
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
acc = acc?.[k];
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
else {
|
|
233
|
-
delete result[key];
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
return result;
|
|
237
|
-
},
|
|
238
|
-
'object.compare'([remapper1, remapper2], input, context) {
|
|
239
|
-
const remapped1 = remap(remapper1, input, context);
|
|
240
|
-
const remapped2 = remap(remapper2, input, context);
|
|
241
|
-
function deepDiff(object1, object2) {
|
|
242
|
-
const stack = [{ obj1: object1, obj2: object2, path: [] }];
|
|
243
|
-
const diffs = [];
|
|
244
|
-
while (stack.length !== 0) {
|
|
245
|
-
const { obj1, obj2, path } = stack.pop();
|
|
246
|
-
const keys = new Set([...Object.keys(obj1 || {}), ...Object.keys(obj2 || {})]);
|
|
247
|
-
for (const key of keys) {
|
|
248
|
-
const val1 = obj1?.[key];
|
|
249
|
-
const val2 = obj2?.[key];
|
|
250
|
-
const currentPath = [...path, key];
|
|
251
|
-
if (isPlainObject(val1) && isPlainObject(val2)) {
|
|
252
|
-
stack.push({ obj1: val1, obj2: val2, path: currentPath });
|
|
253
|
-
}
|
|
254
|
-
else if (Array.isArray(val1) && Array.isArray(val2) && !isEqualArray(val1, val2)) {
|
|
255
|
-
diffs.push({ path: currentPath, type: 'changed', from: val1, to: val2 });
|
|
256
|
-
}
|
|
257
|
-
else if (!(key in obj1)) {
|
|
258
|
-
diffs.push({ path: currentPath, type: 'added', value: val2 });
|
|
259
|
-
}
|
|
260
|
-
else if (!(key in obj2)) {
|
|
261
|
-
diffs.push({ path: currentPath, type: 'removed', value: val1 });
|
|
262
|
-
}
|
|
263
|
-
else if (val1 !== val2) {
|
|
264
|
-
diffs.push({ path: currentPath, type: 'changed', from: val1, to: val2 });
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
}
|
|
268
|
-
return diffs;
|
|
269
|
-
}
|
|
270
|
-
if (!isPlainObject(remapped1) || !isPlainObject(remapped2)) {
|
|
271
|
-
return [];
|
|
272
|
-
}
|
|
273
|
-
return deepDiff(remapped1, remapped2);
|
|
274
|
-
},
|
|
275
|
-
'object.explode'(property, input) {
|
|
276
|
-
if (!isPlainObject(input)) {
|
|
277
|
-
return [];
|
|
278
|
-
}
|
|
279
|
-
const { [property]: arrayValue, ...rest } = input;
|
|
280
|
-
if (!Array.isArray(arrayValue)) {
|
|
281
|
-
return [];
|
|
282
|
-
}
|
|
283
|
-
return arrayValue.map((item) => ({
|
|
284
|
-
...rest,
|
|
285
|
-
...item,
|
|
286
|
-
}));
|
|
287
|
-
},
|
|
288
|
-
type(args, input) {
|
|
289
|
-
// eslint-disable-next-line eqeqeq
|
|
290
|
-
if (input === null) {
|
|
291
|
-
return null;
|
|
292
|
-
}
|
|
293
|
-
if (Array.isArray(input)) {
|
|
294
|
-
return 'array';
|
|
295
|
-
}
|
|
296
|
-
return typeof input;
|
|
297
|
-
},
|
|
298
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
299
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
300
|
-
'array.map': (mapper, input, context) => input?.map((item, index) => remap(mapper, item, {
|
|
301
|
-
...context,
|
|
302
|
-
array: {
|
|
303
|
-
index,
|
|
304
|
-
length: input.length,
|
|
305
|
-
item,
|
|
306
|
-
prevItem: input[index - 1],
|
|
307
|
-
nextItem: input[index + 1],
|
|
308
|
-
},
|
|
309
|
-
})) ?? [],
|
|
310
|
-
'array.contains'(mapper, input, context) {
|
|
311
|
-
if (!Array.isArray(input)) {
|
|
312
|
-
return false;
|
|
313
|
-
}
|
|
314
|
-
const remapped = remap(mapper, input, context);
|
|
315
|
-
if (isPlainObject(remapped)) {
|
|
316
|
-
return input.some((item) => isEqualObject(item, remapped ?? {}));
|
|
317
|
-
}
|
|
318
|
-
if (Array.isArray(remapped)) {
|
|
319
|
-
return input.some((item) => isEqualArray(item, remapped));
|
|
320
|
-
}
|
|
321
|
-
return input.includes(remapped);
|
|
322
|
-
},
|
|
323
|
-
'array.unique'(mapper, input, context) {
|
|
324
|
-
if (!Array.isArray(input)) {
|
|
325
|
-
return input;
|
|
326
|
-
}
|
|
327
|
-
const remapped = input.map((item, index) => mapper == null
|
|
328
|
-
? item
|
|
329
|
-
: remap(mapper, item, {
|
|
330
|
-
...context,
|
|
331
|
-
array: {
|
|
332
|
-
index,
|
|
333
|
-
length: input.length,
|
|
334
|
-
item,
|
|
335
|
-
prevItem: input[index - 1],
|
|
336
|
-
nextItem: input[index + 1],
|
|
337
|
-
},
|
|
338
|
-
}));
|
|
339
|
-
return input.filter((value, index) => {
|
|
340
|
-
for (let i = 0; i < index; i += 1) {
|
|
341
|
-
if (equal(remapped[index], remapped[i])) {
|
|
342
|
-
return false;
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
return true;
|
|
346
|
-
});
|
|
347
|
-
},
|
|
348
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
349
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
350
|
-
array: (prop, input, context) => context.array?.[prop],
|
|
351
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
352
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
353
|
-
'array.filter'(mapper, input, context) {
|
|
354
|
-
if (!Array.isArray(input)) {
|
|
355
|
-
console.error(`${input} is not an array!`);
|
|
356
|
-
return null;
|
|
357
|
-
}
|
|
358
|
-
return input?.filter((item, index) => {
|
|
359
|
-
const remapped = remap(mapper, item, {
|
|
360
|
-
...context,
|
|
361
|
-
array: {
|
|
362
|
-
index,
|
|
363
|
-
length: input.length,
|
|
364
|
-
item,
|
|
365
|
-
prevItem: input[index - 1],
|
|
366
|
-
nextItem: input[index + 1],
|
|
367
|
-
},
|
|
368
|
-
});
|
|
369
|
-
return remapped;
|
|
370
|
-
});
|
|
371
|
-
},
|
|
372
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
373
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
374
|
-
'array.find'(mapper, input, context) {
|
|
375
|
-
if (!Array.isArray(input)) {
|
|
376
|
-
console.error(`${input} is not an array!`);
|
|
377
|
-
return null;
|
|
378
|
-
}
|
|
379
|
-
return (input?.find((item) => {
|
|
380
|
-
const remapped = remap(mapper, item, context);
|
|
381
|
-
switch (typeof remapped) {
|
|
382
|
-
case 'boolean':
|
|
383
|
-
return remap(mapper, item, context) ? item : null;
|
|
384
|
-
default:
|
|
385
|
-
return equal(remapped, item) ? item : null;
|
|
386
|
-
}
|
|
387
|
-
}) ?? null);
|
|
388
|
-
},
|
|
389
|
-
'array.from': (mappers, input, context) => mappers.map((mapper) => remap(mapper, input, context)),
|
|
390
|
-
'array.append': (mappers, input, context) => Array.isArray(input)
|
|
391
|
-
? input.concat(mappers.map((mapper) => remap(mapper, input, context)))
|
|
392
|
-
: [],
|
|
393
|
-
'array.omit'(mappers, input, context) {
|
|
394
|
-
const indices = new Set(mappers.map((mapper) => {
|
|
395
|
-
const remapped = remap(mapper, input, context);
|
|
396
|
-
if (typeof remapped === 'number') {
|
|
397
|
-
return remapped;
|
|
398
|
-
}
|
|
399
|
-
}));
|
|
400
|
-
return Array.isArray(input) ? input.filter((value, i) => !indices.has(i)) : [];
|
|
401
|
-
},
|
|
402
|
-
'array.flatten'(mapper, input, context) {
|
|
403
|
-
if (!Array.isArray(input)) {
|
|
404
|
-
return input;
|
|
405
|
-
}
|
|
406
|
-
const depth = remap(mapper, input, context);
|
|
407
|
-
return input.flat(depth || Number.POSITIVE_INFINITY);
|
|
408
|
-
},
|
|
409
|
-
static: (input) => input,
|
|
410
|
-
prop(prop, obj, context) {
|
|
411
|
-
let result = obj;
|
|
412
|
-
if (result == null) {
|
|
413
|
-
return result;
|
|
414
|
-
}
|
|
415
|
-
if (Array.isArray(prop)) {
|
|
416
|
-
if (prop.every((item) => typeof item === 'number' || typeof item === 'string')) {
|
|
417
|
-
// This runs if the provided value is an array of property names or indexes
|
|
418
|
-
for (const p of [prop].flat()) {
|
|
419
|
-
result = result[p];
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
else if (prop.every((item) => typeof item === 'object' && !Array.isArray(item))) {
|
|
423
|
-
// This runs if the provided value is an array of remappers
|
|
424
|
-
const remapped = remap(prop, obj, context);
|
|
425
|
-
if (typeof remapped === 'number' || typeof remapped === 'string') {
|
|
426
|
-
result = result[remapped];
|
|
427
|
-
}
|
|
428
|
-
else {
|
|
429
|
-
console.error(`Invalid remapper ${JSON.stringify(prop)}`);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
else if (typeof prop === 'object') {
|
|
434
|
-
if (prop == null) {
|
|
435
|
-
result = result.null;
|
|
436
|
-
return result;
|
|
437
|
-
}
|
|
438
|
-
// This runs if the provided value is a remapper
|
|
439
|
-
const remapped = remap(prop, result, context);
|
|
440
|
-
if (typeof remapped === 'number' || typeof remapped === 'string') {
|
|
441
|
-
result = result[remapped];
|
|
442
|
-
}
|
|
443
|
-
else {
|
|
444
|
-
console.error(`Invalid remapper ${JSON.stringify(prop)}`);
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
else if (typeof prop === 'number' || typeof prop === 'string') {
|
|
448
|
-
result =
|
|
449
|
-
Array.isArray(result) && typeof prop === 'number' && prop < 0
|
|
450
|
-
? result[result.length + prop]
|
|
451
|
-
: result[prop];
|
|
452
|
-
}
|
|
453
|
-
return result;
|
|
454
|
-
},
|
|
455
|
-
'number.parse'(remapper, input, context) {
|
|
456
|
-
if (!remapper) {
|
|
457
|
-
const inputConverted = Number(input);
|
|
458
|
-
if (!Number.isNaN(inputConverted)) {
|
|
459
|
-
return inputConverted;
|
|
460
|
-
}
|
|
461
|
-
return input;
|
|
462
|
-
}
|
|
463
|
-
const remapped = remap(remapper, input, context);
|
|
464
|
-
const remappedConverted = Number(remapped);
|
|
465
|
-
if (!Number.isNaN(remappedConverted)) {
|
|
466
|
-
return remappedConverted;
|
|
467
|
-
}
|
|
468
|
-
return remapped;
|
|
469
|
-
},
|
|
470
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
471
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
472
|
-
'date.parse': (fmt, input) => (fmt ? parse(input, fmt, new Date()) : parseISO(input)),
|
|
473
|
-
'date.now': () => new Date(),
|
|
474
|
-
'date.add'(time, input) {
|
|
475
|
-
const expireDuration = parseDuration(time);
|
|
476
|
-
if (!expireDuration || !input || (!Number.isFinite(input) && !(input instanceof Date))) {
|
|
477
|
-
return input;
|
|
478
|
-
}
|
|
479
|
-
return addMilliseconds(input, expireDuration);
|
|
480
|
-
},
|
|
481
|
-
'date.format'(args, input) {
|
|
482
|
-
const date = input instanceof Date
|
|
483
|
-
? input
|
|
484
|
-
: typeof input === 'number'
|
|
485
|
-
? new Date(input)
|
|
486
|
-
: parseISO(String(input));
|
|
487
|
-
return args ? format(date, args) : date.toJSON();
|
|
488
|
-
},
|
|
489
|
-
'null.strip': (args, input) => stripNullValues(input, args || {}),
|
|
490
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
491
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
492
|
-
'random.choice': (args, input) => Array.isArray(input) ? input[Math.floor(Math.random() * input.length)] : input,
|
|
493
|
-
'random.integer'(args) {
|
|
494
|
-
const min = Math.min(...args);
|
|
495
|
-
const max = Math.max(...args);
|
|
496
|
-
return Math.floor(Math.random() * (max - min) + min);
|
|
497
|
-
},
|
|
498
|
-
'random.float'(args) {
|
|
499
|
-
const min = Math.min(...args);
|
|
500
|
-
const max = Math.max(...args);
|
|
501
|
-
return Math.random() * (max - min) + min;
|
|
502
|
-
},
|
|
503
|
-
'random.string'(args) {
|
|
504
|
-
const result = [];
|
|
505
|
-
const characters = [...new Set(args.choice.split(''))];
|
|
506
|
-
for (let i = 0; i <= args.length; i += 1) {
|
|
507
|
-
result.push(characters[Math.floor(Math.random() * characters.length)]);
|
|
508
|
-
}
|
|
509
|
-
return result.join('');
|
|
510
|
-
},
|
|
511
|
-
root: (args, input, context) => context.root,
|
|
512
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
513
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
514
|
-
len: (args, input) => input?.length,
|
|
515
|
-
history: (index, input, context) => context.history?.[index],
|
|
516
|
-
'from.history': ({ index, props }, input, context) => mapValues(props, (mapper) => remap(mapper, context.history?.[index], context)),
|
|
517
|
-
'assign.history': ({ index, props }, input, context) => ({
|
|
518
|
-
...input,
|
|
519
|
-
...mapValues(props, (mapper) => remap(mapper, context.history?.[index], context)),
|
|
520
|
-
}),
|
|
521
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
522
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
523
|
-
'omit.history'({ index, keys }, input, context) {
|
|
524
|
-
const result = { ...context.history?.[index] };
|
|
525
|
-
for (const key of keys) {
|
|
526
|
-
if (Array.isArray(key)) {
|
|
527
|
-
let acc = result;
|
|
528
|
-
for (const [i, k] of key.entries()) {
|
|
529
|
-
if (i === key.length - 1) {
|
|
530
|
-
delete acc[k];
|
|
531
|
-
}
|
|
532
|
-
else {
|
|
533
|
-
acc = acc?.[k];
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
}
|
|
537
|
-
else {
|
|
538
|
-
delete result[key];
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
return { ...input, ...result };
|
|
542
|
-
},
|
|
543
|
-
'string.case'(stringCase, input) {
|
|
544
|
-
if (stringCase === 'lower') {
|
|
545
|
-
return String(input).toLowerCase();
|
|
546
|
-
}
|
|
547
|
-
if (stringCase === 'upper') {
|
|
548
|
-
return String(input).toUpperCase();
|
|
549
|
-
}
|
|
550
|
-
return input;
|
|
551
|
-
},
|
|
552
|
-
'string.contains'(stringToCheck, input) {
|
|
553
|
-
if (!(typeof input === 'string')) {
|
|
554
|
-
return false;
|
|
555
|
-
}
|
|
556
|
-
return input.includes(stringToCheck);
|
|
557
|
-
},
|
|
558
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
559
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
560
|
-
'string.startsWith'(substring, input) {
|
|
561
|
-
if (typeof substring === 'string') {
|
|
562
|
-
return input.startsWith(substring);
|
|
563
|
-
}
|
|
564
|
-
if (substring.strict || substring.strict === undefined) {
|
|
565
|
-
return input.startsWith(substring.substring);
|
|
566
|
-
}
|
|
567
|
-
return input.toLowerCase().startsWith(substring.substring.toLowerCase());
|
|
568
|
-
},
|
|
569
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
570
|
-
// @ts-ignore 2322 ... is not assignable to type (strictNullChecks)
|
|
571
|
-
'string.endsWith'(substring, input) {
|
|
572
|
-
if (typeof substring === 'string') {
|
|
573
|
-
return input.endsWith(substring);
|
|
574
|
-
}
|
|
575
|
-
if (substring.strict || substring.strict === undefined) {
|
|
576
|
-
return input.endsWith(substring.substring);
|
|
577
|
-
}
|
|
578
|
-
return input.toLowerCase().endsWith(substring.substring.toLowerCase());
|
|
579
|
-
},
|
|
580
|
-
// eslint-disable-next-line @typescript-eslint/prefer-ts-expect-error
|
|
581
|
-
// @ts-ignore 2322 null is not assignable to type (strictNullChecks)
|
|
582
|
-
slice(sliceIndex, input) {
|
|
583
|
-
try {
|
|
584
|
-
return Array.isArray(sliceIndex) ? input.slice(...sliceIndex) : input.slice(sliceIndex);
|
|
585
|
-
}
|
|
586
|
-
catch {
|
|
587
|
-
return null;
|
|
588
|
-
}
|
|
589
|
-
},
|
|
590
|
-
log(level, input, context) {
|
|
591
|
-
console[level ?? 'info'](JSON.stringify({ input, context }, null, 2));
|
|
592
|
-
return input;
|
|
593
|
-
},
|
|
594
|
-
'string.format'({ messageId, template, values }, input, context) {
|
|
595
|
-
try {
|
|
596
|
-
const remappedMessageId = remap(messageId ?? null, input, context);
|
|
597
|
-
const message = context.getMessage({ id: remappedMessageId, defaultMessage: template });
|
|
598
|
-
return message.format(values ? mapValues(values, (val) => remap(val, input, context)) : undefined);
|
|
599
|
-
}
|
|
600
|
-
catch (error) {
|
|
601
|
-
if (messageId) {
|
|
602
|
-
return `{${messageId}}`;
|
|
603
|
-
}
|
|
604
|
-
return error.message;
|
|
605
|
-
}
|
|
606
|
-
},
|
|
607
|
-
'string.replace'(values, input) {
|
|
608
|
-
const [[regex, replacer]] = Object.entries(values);
|
|
609
|
-
return String(input).replaceAll(new RegExp(regex, 'gm'), replacer);
|
|
610
|
-
},
|
|
611
|
-
translate(messageId, input, context) {
|
|
612
|
-
const remappedId = remap(messageId, input, context);
|
|
613
|
-
if (typeof remappedId !== 'string') {
|
|
614
|
-
return null;
|
|
615
|
-
}
|
|
616
|
-
const message = context.getMessage({ id: remappedId });
|
|
617
|
-
return message.format() || `{${remappedId}}`;
|
|
618
|
-
},
|
|
619
|
-
'app.member': (property, input, context) => context.appMemberInfo?.[property],
|
|
620
|
-
container(property, input, context) {
|
|
621
|
-
// This value is replaced when the request is made
|
|
622
|
-
// By using the value of the release name
|
|
623
|
-
const namespace = 'companion-containers-appsemble';
|
|
624
|
-
const appName = context.appUrl.split('.')[0].replace(/^https?:\/\//, '');
|
|
625
|
-
const endpoint = property.split('/').slice(1).join('/');
|
|
626
|
-
const containerName = `${property.split('/')[0]}-${appName}-${context.appId}`
|
|
627
|
-
.replaceAll(' ', '-')
|
|
628
|
-
.toLowerCase();
|
|
629
|
-
const url = `http://${containerName}.${namespace}.svc.cluster.local/${endpoint}`;
|
|
630
|
-
return url;
|
|
631
|
-
},
|
|
632
|
-
'filter.from'(values, input, context) {
|
|
633
|
-
let result = filter();
|
|
634
|
-
for (const [field, { comparator, type, value }] of Object.entries(values)) {
|
|
635
|
-
const remapped = remap(value, input, context);
|
|
636
|
-
const remappedDefined = remapped === undefined ? null : remapped;
|
|
637
|
-
const literal = type === 'String' && remapped != null
|
|
638
|
-
? literalValues[type](String(remappedDefined).replaceAll("'", "''").replaceAll('\\', '\\\\'))
|
|
639
|
-
: literalValues[type === 'Number' ? 'Decimal' : type](remappedDefined);
|
|
640
|
-
result = result.field(field)[comparator](literal);
|
|
641
|
-
}
|
|
642
|
-
return String(param().filter(result)).replace(/^\$filter=/, '');
|
|
643
|
-
},
|
|
644
|
-
'order.from'(values) {
|
|
645
|
-
return String(param().orderby(Object.entries(values).map(([key, order]) => ({ field: key, order })))).replace('$orderby=', '');
|
|
646
|
-
},
|
|
647
|
-
'xml.parse'(value, input, context) {
|
|
648
|
-
const parser = new XMLParser({
|
|
649
|
-
ignoreAttributes: false,
|
|
650
|
-
attributeNamePrefix: '',
|
|
651
|
-
});
|
|
652
|
-
try {
|
|
653
|
-
return parser.parse(remap(value, input, context) || '');
|
|
654
|
-
}
|
|
655
|
-
catch (error) {
|
|
656
|
-
console.error(error);
|
|
657
|
-
return {};
|
|
658
|
-
}
|
|
659
|
-
},
|
|
660
|
-
defined(value, input, context) {
|
|
661
|
-
const remapped = remap(value, input, context);
|
|
662
|
-
return remapped !== undefined && remapped != null;
|
|
663
|
-
},
|
|
664
|
-
maths(value, input, context) {
|
|
665
|
-
const { a, b, operation } = value;
|
|
666
|
-
const aRemapped = remap(a, input, context);
|
|
667
|
-
const bRemapped = remap(b, input, context);
|
|
668
|
-
if (!isNumber(aRemapped) || !isNumber(bRemapped)) {
|
|
669
|
-
return -1;
|
|
670
|
-
}
|
|
671
|
-
const na = Number(aRemapped);
|
|
672
|
-
const nb = Number(bRemapped);
|
|
673
|
-
switch (operation) {
|
|
674
|
-
case 'add':
|
|
675
|
-
return na + nb;
|
|
676
|
-
case 'subtract':
|
|
677
|
-
return na - nb;
|
|
678
|
-
case 'multiply':
|
|
679
|
-
return na * nb;
|
|
680
|
-
case 'divide':
|
|
681
|
-
if (nb === 0) {
|
|
682
|
-
return -1;
|
|
683
|
-
}
|
|
684
|
-
return na / nb;
|
|
685
|
-
case 'mod':
|
|
686
|
-
return na % nb;
|
|
687
|
-
default:
|
|
688
|
-
return -1;
|
|
689
|
-
}
|
|
690
|
-
},
|
|
691
|
-
};
|
|
692
|
-
//# sourceMappingURL=remap.js.map
|
package/serverActions.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
export declare const serverActions: Set<"log" | "app.member.query" | "condition" | "each" | "email" | "noop" | "notify" | "static" | "throw" | "request" | "resource.create" | "resource.delete" | "resource.delete.all" | "resource.delete.bulk" | "resource.get" | "resource.patch" | "resource.query" | "resource.update">;
|
|
2
|
-
export type ServerActionName = typeof serverActions extends Set<infer T> ? T : never;
|