@appsemble/utils 0.20.27 → 0.20.29
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 +4 -4
- package/api/components/schemas/AppDefinition.js +1 -0
- package/api/components/schemas/LoopPageActionsDefinition.d.ts +2 -0
- package/api/components/schemas/LoopPageActionsDefinition.js +24 -0
- package/api/components/schemas/LoopPageDefinition.d.ts +1 -0
- package/api/components/schemas/LoopPageDefinition.js +38 -0
- package/api/components/schemas/ObjectRemapperDefinition.js +4 -0
- package/api/components/schemas/index.d.ts +2 -0
- package/api/components/schemas/index.js +2 -0
- package/appMessages.js +4 -1
- package/iterApp.js +3 -0
- package/package.json +2 -2
- package/remap.d.ts +3 -0
- package/remap.js +3 -0
- package/validation.js +7 -7
- package/validation.test.js +1 -1
- package/api/components/index.js.map +0 -1
- package/api/components/index.ts +0 -15
- package/api/components/parameters/$filter.js.map +0 -1
- package/api/components/parameters/$filter.ts +0 -12
- package/api/components/parameters/$orderby.js.map +0 -1
- package/api/components/parameters/$orderby.ts +0 -12
- package/api/components/parameters/$select.js.map +0 -1
- package/api/components/parameters/$select.ts +0 -15
- package/api/components/parameters/$team.js.map +0 -1
- package/api/components/parameters/$team.ts +0 -11
- package/api/components/parameters/$top.js.map +0 -1
- package/api/components/parameters/$top.ts +0 -9
- package/api/components/parameters/appId.js.map +0 -1
- package/api/components/parameters/appId.ts +0 -9
- package/api/components/parameters/appOAuth2SecretId.js.map +0 -1
- package/api/components/parameters/appOAuth2SecretId.ts +0 -9
- package/api/components/parameters/appSamlSecretId.js.map +0 -1
- package/api/components/parameters/appSamlSecretId.ts +0 -12
- package/api/components/parameters/assetId.js.map +0 -1
- package/api/components/parameters/assetId.ts +0 -9
- package/api/components/parameters/blockId.js.map +0 -1
- package/api/components/parameters/blockId.ts +0 -15
- package/api/components/parameters/blockVersion.js.map +0 -1
- package/api/components/parameters/blockVersion.ts +0 -9
- package/api/components/parameters/endpoint.js.map +0 -1
- package/api/components/parameters/endpoint.ts +0 -9
- package/api/components/parameters/index.js.map +0 -1
- package/api/components/parameters/index.ts +0 -18
- package/api/components/parameters/language.js.map +0 -1
- package/api/components/parameters/language.ts +0 -9
- package/api/components/parameters/organizationId.js.map +0 -1
- package/api/components/parameters/organizationId.ts +0 -9
- package/api/components/parameters/resourceId.js.map +0 -1
- package/api/components/parameters/resourceId.ts +0 -9
- package/api/components/parameters/resourceType.js.map +0 -1
- package/api/components/parameters/resourceType.ts +0 -11
- package/api/components/parameters/screenshotId.js.map +0 -1
- package/api/components/parameters/screenshotId.ts +0 -9
- package/api/components/parameters/view.js.map +0 -1
- package/api/components/parameters/view.ts +0 -8
- package/api/components/requestBodies/index.js.map +0 -1
- package/api/components/requestBodies/index.ts +0 -3
- package/api/components/requestBodies/oauth2Consent.js.map +0 -1
- package/api/components/requestBodies/oauth2Consent.ts +0 -31
- package/api/components/requestBodies/resource.js.map +0 -1
- package/api/components/requestBodies/resource.ts +0 -31
- package/api/components/requestBodies/user.js.map +0 -1
- package/api/components/requestBodies/user.ts +0 -12
- package/api/components/responses/app.js.map +0 -1
- package/api/components/responses/app.ts +0 -12
- package/api/components/responses/blockVersion.js.map +0 -1
- package/api/components/responses/blockVersion.ts +0 -12
- package/api/components/responses/default.js.map +0 -1
- package/api/components/responses/default.ts +0 -10
- package/api/components/responses/index.js.map +0 -1
- package/api/components/responses/index.ts +0 -8
- package/api/components/responses/invite.js.map +0 -1
- package/api/components/responses/invite.ts +0 -12
- package/api/components/responses/oauth2AuthorizationCode.js.map +0 -1
- package/api/components/responses/oauth2AuthorizationCode.ts +0 -12
- package/api/components/responses/organization.js.map +0 -1
- package/api/components/responses/organization.ts +0 -12
- package/api/components/responses/resource.js.map +0 -1
- package/api/components/responses/resource.ts +0 -17
- package/api/components/responses/subscriptions.js.map +0 -1
- package/api/components/responses/subscriptions.ts +0 -16
- package/api/components/schemas/ActionDefinition.js.map +0 -1
- package/api/components/schemas/ActionDefinition.ts +0 -82
- package/api/components/schemas/AnalyticsActionDefinition.js.map +0 -1
- package/api/components/schemas/AnalyticsActionDefinition.ts +0 -25
- package/api/components/schemas/App.js.map +0 -1
- package/api/components/schemas/App.ts +0 -107
- package/api/components/schemas/AppAccount.js.map +0 -1
- package/api/components/schemas/AppAccount.ts +0 -39
- package/api/components/schemas/AppDefinition.js.map +0 -1
- package/api/components/schemas/AppDefinition.ts +0 -112
- package/api/components/schemas/AppLayoutDefinition.js.map +0 -1
- package/api/components/schemas/AppLayoutDefinition.ts +0 -39
- package/api/components/schemas/AppMessages.js.map +0 -1
- package/api/components/schemas/AppMessages.ts +0 -17
- package/api/components/schemas/AppOAuth2Secret.js.map +0 -1
- package/api/components/schemas/AppOAuth2Secret.ts +0 -65
- package/api/components/schemas/AppsembleMessages.js.map +0 -1
- package/api/components/schemas/AppsembleMessages.ts +0 -41
- package/api/components/schemas/Asset.js.map +0 -1
- package/api/components/schemas/Asset.ts +0 -33
- package/api/components/schemas/BaseActionDefinition.js.map +0 -1
- package/api/components/schemas/BaseActionDefinition.ts +0 -11
- package/api/components/schemas/BaseJSONSchema.js.map +0 -1
- package/api/components/schemas/BaseJSONSchema.ts +0 -25
- package/api/components/schemas/BasePageDefinition.js.map +0 -1
- package/api/components/schemas/BasePageDefinition.ts +0 -89
- package/api/components/schemas/BlockDefinition.js.map +0 -1
- package/api/components/schemas/BlockDefinition.ts +0 -86
- package/api/components/schemas/BlockVersion.js.map +0 -1
- package/api/components/schemas/BlockVersion.ts +0 -162
- package/api/components/schemas/ConditionActionDefinition.js.map +0 -1
- package/api/components/schemas/ConditionActionDefinition.ts +0 -30
- package/api/components/schemas/CronDefinition.js.map +0 -1
- package/api/components/schemas/CronDefinition.ts +0 -21
- package/api/components/schemas/CustomFontDefinition.js.map +0 -1
- package/api/components/schemas/CustomFontDefinition.ts +0 -21
- package/api/components/schemas/DialogActionDefinition.js.map +0 -1
- package/api/components/schemas/DialogActionDefinition.ts +0 -42
- package/api/components/schemas/DialogErrorActionDefinition.js.map +0 -1
- package/api/components/schemas/DialogErrorActionDefinition.ts +0 -17
- package/api/components/schemas/DialogOkActionDefinition.js.map +0 -1
- package/api/components/schemas/DialogOkActionDefinition.ts +0 -17
- package/api/components/schemas/DownloadActionDefinition.js.map +0 -1
- package/api/components/schemas/DownloadActionDefinition.ts +0 -19
- package/api/components/schemas/EachActionDefinition.js.map +0 -1
- package/api/components/schemas/EachActionDefinition.ts +0 -22
- package/api/components/schemas/EmailActionDefinition.js.map +0 -1
- package/api/components/schemas/EmailActionDefinition.ts +0 -58
- package/api/components/schemas/Error.js.map +0 -1
- package/api/components/schemas/Error.ts +0 -25
- package/api/components/schemas/EventActionDefinition.js.map +0 -1
- package/api/components/schemas/EventActionDefinition.ts +0 -28
- package/api/components/schemas/EventsDefinition.js.map +0 -1
- package/api/components/schemas/EventsDefinition.ts +0 -30
- package/api/components/schemas/FlowBackActionDefinition.js.map +0 -1
- package/api/components/schemas/FlowBackActionDefinition.ts +0 -16
- package/api/components/schemas/FlowFinishActionDefinition.js.map +0 -1
- package/api/components/schemas/FlowFinishActionDefinition.ts +0 -16
- package/api/components/schemas/FlowNextActionDefinition.js.map +0 -1
- package/api/components/schemas/FlowNextActionDefinition.ts +0 -17
- package/api/components/schemas/FlowPageActionsDefinition.js.map +0 -1
- package/api/components/schemas/FlowPageActionsDefinition.ts +0 -20
- package/api/components/schemas/FlowPageDefinition.js.map +0 -1
- package/api/components/schemas/FlowPageDefinition.ts +0 -37
- package/api/components/schemas/FlowToActionDefinition.js.map +0 -1
- package/api/components/schemas/FlowToActionDefinition.ts +0 -21
- package/api/components/schemas/GoogleFontDefinition.js.map +0 -1
- package/api/components/schemas/GoogleFontDefinition.ts +0 -24
- package/api/components/schemas/Health.js.map +0 -1
- package/api/components/schemas/Health.ts +0 -14
- package/api/components/schemas/JSONPointer.js.map +0 -1
- package/api/components/schemas/JSONPointer.ts +0 -20
- package/api/components/schemas/JSONSchema.js.map +0 -1
- package/api/components/schemas/JSONSchema.ts +0 -21
- package/api/components/schemas/JSONSchemaAnyOf.js.map +0 -1
- package/api/components/schemas/JSONSchemaAnyOf.ts +0 -27
- package/api/components/schemas/JSONSchemaArray.js.map +0 -1
- package/api/components/schemas/JSONSchemaArray.ts +0 -47
- package/api/components/schemas/JSONSchemaBoolean.js.map +0 -1
- package/api/components/schemas/JSONSchemaBoolean.ts +0 -37
- package/api/components/schemas/JSONSchemaConst.js.map +0 -1
- package/api/components/schemas/JSONSchemaConst.ts +0 -16
- package/api/components/schemas/JSONSchemaEnum.js.map +0 -1
- package/api/components/schemas/JSONSchemaEnum.ts +0 -36
- package/api/components/schemas/JSONSchemaInteger.js.map +0 -1
- package/api/components/schemas/JSONSchemaInteger.ts +0 -55
- package/api/components/schemas/JSONSchemaMultiType.js.map +0 -1
- package/api/components/schemas/JSONSchemaMultiType.ts +0 -48
- package/api/components/schemas/JSONSchemaNot.js.map +0 -1
- package/api/components/schemas/JSONSchemaNot.ts +0 -23
- package/api/components/schemas/JSONSchemaNull.js.map +0 -1
- package/api/components/schemas/JSONSchemaNull.ts +0 -16
- package/api/components/schemas/JSONSchemaNumber.js.map +0 -1
- package/api/components/schemas/JSONSchemaNumber.ts +0 -66
- package/api/components/schemas/JSONSchemaObject.js.map +0 -1
- package/api/components/schemas/JSONSchemaObject.ts +0 -74
- package/api/components/schemas/JSONSchemaOneOf.js.map +0 -1
- package/api/components/schemas/JSONSchemaOneOf.ts +0 -25
- package/api/components/schemas/JSONSchemaRemapper.js.map +0 -1
- package/api/components/schemas/JSONSchemaRemapper.ts +0 -19
- package/api/components/schemas/JSONSchemaRoot.js.map +0 -1
- package/api/components/schemas/JSONSchemaRoot.ts +0 -23
- package/api/components/schemas/JSONSchemaString.js.map +0 -1
- package/api/components/schemas/JSONSchemaString.ts +0 -116
- package/api/components/schemas/LinkActionDefinition.js.map +0 -1
- package/api/components/schemas/LinkActionDefinition.ts +0 -28
- package/api/components/schemas/LinkBackActionDefinition.js.map +0 -1
- package/api/components/schemas/LinkBackActionDefinition.ts +0 -14
- package/api/components/schemas/LinkNextActionDefinition.js.map +0 -1
- package/api/components/schemas/LinkNextActionDefinition.ts +0 -14
- package/api/components/schemas/LogActionDefinition.js.map +0 -1
- package/api/components/schemas/LogActionDefinition.ts +0 -22
- package/api/components/schemas/Member.js.map +0 -1
- package/api/components/schemas/Member.ts +0 -31
- package/api/components/schemas/MessageActionDefinition.js.map +0 -1
- package/api/components/schemas/MessageActionDefinition.ts +0 -36
- package/api/components/schemas/NoopActionDefinition.js.map +0 -1
- package/api/components/schemas/NoopActionDefinition.ts +0 -17
- package/api/components/schemas/NotificationHookDataDefinition.js.map +0 -1
- package/api/components/schemas/NotificationHookDataDefinition.ts +0 -25
- package/api/components/schemas/NotificationHookDefinition.js.map +0 -1
- package/api/components/schemas/NotificationHookDefinition.ts +0 -33
- package/api/components/schemas/OAuth2AuthorizationCode.js.map +0 -1
- package/api/components/schemas/OAuth2AuthorizationCode.ts +0 -15
- package/api/components/schemas/OAuth2ClientCredentials.js.map +0 -1
- package/api/components/schemas/OAuth2ClientCredentials.ts +0 -39
- package/api/components/schemas/ObjectRemapperDefinition.js.map +0 -1
- package/api/components/schemas/ObjectRemapperDefinition.ts +0 -453
- package/api/components/schemas/Organization.js.map +0 -1
- package/api/components/schemas/Organization.ts +0 -40
- package/api/components/schemas/PageDefinition.js.map +0 -1
- package/api/components/schemas/PageDefinition.ts +0 -23
- package/api/components/schemas/Rating.js.map +0 -1
- package/api/components/schemas/Rating.ts +0 -25
- package/api/components/schemas/RemapperDefinition.js.map +0 -1
- package/api/components/schemas/RemapperDefinition.ts +0 -35
- package/api/components/schemas/RequestActionDefinition.js.map +0 -1
- package/api/components/schemas/RequestActionDefinition.ts +0 -60
- package/api/components/schemas/Resource.js.map +0 -1
- package/api/components/schemas/Resource.ts +0 -20
- package/api/components/schemas/ResourceCountActionDefinition.js.map +0 -1
- package/api/components/schemas/ResourceCountActionDefinition.ts +0 -23
- package/api/components/schemas/ResourceCreateActionDefinition.js.map +0 -1
- package/api/components/schemas/ResourceCreateActionDefinition.ts +0 -22
- package/api/components/schemas/ResourceDefinition.js.map +0 -1
- package/api/components/schemas/ResourceDefinition.ts +0 -229
- package/api/components/schemas/ResourceDeleteActionDefinition.js.map +0 -1
- package/api/components/schemas/ResourceDeleteActionDefinition.ts +0 -22
- package/api/components/schemas/ResourceGetActionDefinition.js.map +0 -1
- package/api/components/schemas/ResourceGetActionDefinition.ts +0 -26
- package/api/components/schemas/ResourceHistoryDefinition.js.map +0 -1
- package/api/components/schemas/ResourceHistoryDefinition.ts +0 -15
- package/api/components/schemas/ResourceHooksDefinition.js.map +0 -1
- package/api/components/schemas/ResourceHooksDefinition.ts +0 -11
- package/api/components/schemas/ResourceQueryActionDefinition.js.map +0 -1
- package/api/components/schemas/ResourceQueryActionDefinition.ts +0 -26
- package/api/components/schemas/ResourceSubscription.js.map +0 -1
- package/api/components/schemas/ResourceSubscription.ts +0 -42
- package/api/components/schemas/ResourceSubscriptionStatusActionDefinition.js.map +0 -1
- package/api/components/schemas/ResourceSubscriptionStatusActionDefinition.ts +0 -23
- package/api/components/schemas/ResourceSubscriptionSubscribeActionDefinition.js.map +0 -1
- package/api/components/schemas/ResourceSubscriptionSubscribeActionDefinition.ts +0 -25
- package/api/components/schemas/ResourceSubscriptionToggleActionDefinition.js.map +0 -1
- package/api/components/schemas/ResourceSubscriptionToggleActionDefinition.ts +0 -22
- package/api/components/schemas/ResourceSubscriptionUnsubscribeActionDefinition.js.map +0 -1
- package/api/components/schemas/ResourceSubscriptionUnsubscribeActionDefinition.ts +0 -25
- package/api/components/schemas/ResourceUpdateActionDefinition.js.map +0 -1
- package/api/components/schemas/ResourceUpdateActionDefinition.ts +0 -22
- package/api/components/schemas/ResourceViewDefinition.js.map +0 -1
- package/api/components/schemas/ResourceViewDefinition.ts +0 -26
- package/api/components/schemas/SSLSecret.js.map +0 -1
- package/api/components/schemas/SSLSecret.ts +0 -17
- package/api/components/schemas/SSOConfiguration.js.map +0 -1
- package/api/components/schemas/SSOConfiguration.ts +0 -22
- package/api/components/schemas/SecurityDefaultDefinition.js.map +0 -1
- package/api/components/schemas/SecurityDefaultDefinition.ts +0 -29
- package/api/components/schemas/SecurityDefinition.js.map +0 -1
- package/api/components/schemas/SecurityDefinition.ts +0 -21
- package/api/components/schemas/SecurityRoleDefinition.js.map +0 -1
- package/api/components/schemas/SecurityRoleDefinition.ts +0 -29
- package/api/components/schemas/ShareActionDefinition.js.map +0 -1
- package/api/components/schemas/ShareActionDefinition.ts +0 -30
- package/api/components/schemas/StaticActionDefinition.js.map +0 -1
- package/api/components/schemas/StaticActionDefinition.ts +0 -20
- package/api/components/schemas/StorageAppendActionDefinition.js.map +0 -1
- package/api/components/schemas/StorageAppendActionDefinition.ts +0 -43
- package/api/components/schemas/StorageDeleteActionDefinition.js.map +0 -1
- package/api/components/schemas/StorageDeleteActionDefinition.ts +0 -31
- package/api/components/schemas/StorageReadActionDefinition.js.map +0 -1
- package/api/components/schemas/StorageReadActionDefinition.ts +0 -32
- package/api/components/schemas/StorageSubtractActionDefinition.js.map +0 -1
- package/api/components/schemas/StorageSubtractActionDefinition.ts +0 -35
- package/api/components/schemas/StorageUpdateActionDefinition.js.map +0 -1
- package/api/components/schemas/StorageUpdateActionDefinition.ts +0 -46
- package/api/components/schemas/StorageWriteActionDefinition.js.map +0 -1
- package/api/components/schemas/StorageWriteActionDefinition.ts +0 -42
- package/api/components/schemas/SubPage.js.map +0 -1
- package/api/components/schemas/SubPage.ts +0 -24
- package/api/components/schemas/TabsPageDefinition.js.map +0 -1
- package/api/components/schemas/TabsPageDefinition.ts +0 -22
- package/api/components/schemas/TeamInviteActionDefinition.js.map +0 -1
- package/api/components/schemas/TeamInviteActionDefinition.ts +0 -27
- package/api/components/schemas/TeamJoinActionDefinition.js.map +0 -1
- package/api/components/schemas/TeamJoinActionDefinition.ts +0 -14
- package/api/components/schemas/TeamListActionDefinition.js.map +0 -1
- package/api/components/schemas/TeamListActionDefinition.ts +0 -14
- package/api/components/schemas/TeamsDefinition.js.map +0 -1
- package/api/components/schemas/TeamsDefinition.ts +0 -30
- package/api/components/schemas/Theme.js.map +0 -1
- package/api/components/schemas/Theme.ts +0 -82
- package/api/components/schemas/ThrowActionDefinition.js.map +0 -1
- package/api/components/schemas/ThrowActionDefinition.ts +0 -17
- package/api/components/schemas/User.js.map +0 -1
- package/api/components/schemas/User.ts +0 -30
- package/api/components/schemas/UserEmail.js.map +0 -1
- package/api/components/schemas/UserEmail.ts +0 -24
- package/api/components/schemas/UserLoginActionDefinition.js.map +0 -1
- package/api/components/schemas/UserLoginActionDefinition.ts +0 -22
- package/api/components/schemas/UserRegisterActionDefinition.js.map +0 -1
- package/api/components/schemas/UserRegisterActionDefinition.ts +0 -33
- package/api/components/schemas/UserUpdateActionDefinition.js.map +0 -1
- package/api/components/schemas/UserUpdateActionDefinition.ts +0 -33
- package/api/components/schemas/index.js.map +0 -1
- package/api/components/schemas/index.ts +0 -108
- package/api/components/schemas/utils.js.map +0 -1
- package/api/components/schemas/utils.ts +0 -43
- package/api/components/securitySchemes/app.js.map +0 -1
- package/api/components/securitySchemes/app.ts +0 -33
- package/api/components/securitySchemes/basic.js.map +0 -1
- package/api/components/securitySchemes/basic.ts +0 -7
- package/api/components/securitySchemes/cli.js.map +0 -1
- package/api/components/securitySchemes/cli.test.js.map +0 -1
- package/api/components/securitySchemes/cli.test.ts +0 -6
- package/api/components/securitySchemes/cli.ts +0 -25
- package/api/components/securitySchemes/index.js.map +0 -1
- package/api/components/securitySchemes/index.ts +0 -4
- package/api/components/securitySchemes/studio.js.map +0 -1
- package/api/components/securitySchemes/studio.ts +0 -8
- package/api/index.js.map +0 -1
- package/api/index.test.js.map +0 -1
- package/api/index.test.ts +0 -196
- package/api/index.ts +0 -44
- package/api/paths/action.js.map +0 -1
- package/api/paths/action.ts +0 -55
- package/api/paths/appMessages.js.map +0 -1
- package/api/paths/appMessages.ts +0 -104
- package/api/paths/appOAuth2Secrets.js.map +0 -1
- package/api/paths/appOAuth2Secrets.ts +0 -152
- package/api/paths/appSSLSecrets.js.map +0 -1
- package/api/paths/appSSLSecrets.ts +0 -40
- package/api/paths/appSamlSecrets.js.map +0 -1
- package/api/paths/appSamlSecrets.ts +0 -85
- package/api/paths/apps.js.map +0 -1
- package/api/paths/apps.ts +0 -1394
- package/api/paths/appsembleMessages.js.map +0 -1
- package/api/paths/appsembleMessages.ts +0 -49
- package/api/paths/assets.js.map +0 -1
- package/api/paths/assets.ts +0 -139
- package/api/paths/blocks.js.map +0 -1
- package/api/paths/blocks.ts +0 -184
- package/api/paths/emails.js.map +0 -1
- package/api/paths/emails.ts +0 -164
- package/api/paths/health.js.map +0 -1
- package/api/paths/health.ts +0 -75
- package/api/paths/index.js.map +0 -1
- package/api/paths/index.ts +0 -45
- package/api/paths/invite.js.map +0 -1
- package/api/paths/invite.ts +0 -26
- package/api/paths/oauth2ClientCredentials.js.map +0 -1
- package/api/paths/oauth2ClientCredentials.ts +0 -79
- package/api/paths/oauth2Login.js.map +0 -1
- package/api/paths/oauth2Login.ts +0 -120
- package/api/paths/oauth2Provider.js.map +0 -1
- package/api/paths/oauth2Provider.ts +0 -73
- package/api/paths/organizations.js.map +0 -1
- package/api/paths/organizations.ts +0 -471
- package/api/paths/resourceHistory.js.map +0 -1
- package/api/paths/resourceHistory.ts +0 -32
- package/api/paths/resources.js.map +0 -1
- package/api/paths/resources.ts +0 -305
- package/api/paths/saml.js.map +0 -1
- package/api/paths/saml.ts +0 -127
- package/api/paths/templates.js.map +0 -1
- package/api/paths/templates.ts +0 -85
- package/api/paths/user.js.map +0 -1
- package/api/paths/user.ts +0 -481
- package/api/schema-tests/AppDefinition/invalid/additional-property.yaml +0 -11
- package/api/schema-tests/AppDefinition/invalid/empty-pages.yaml +0 -4
- package/api/schema-tests/AppDefinition/invalid/missing-default-page.yaml +0 -7
- package/api/schema-tests/AppDefinition/invalid/missing-name.yaml +0 -7
- package/api/schema-tests/AppDefinition/invalid/missing-pages.yaml +0 -2
- package/api/schema-tests/AppDefinition/valid/all-properties.yaml +0 -114
- package/api/schema-tests/AppDefinition/valid/minimal.yaml +0 -9
- package/api/schema-tests/FlowPageDefinition/invalid/missing-subPages.yaml +0 -2
- package/api/schema-tests/FlowPageDefinition/valid/flow.yaml +0 -15
- package/api/schema-tests/PageDefinition/invalid/additional-properties.yaml +0 -5
- package/api/schema-tests/PageDefinition/invalid/missing-blocks.yaml +0 -1
- package/api/schema-tests/PageDefinition/invalid/missing-name.yaml +0 -3
- package/api/schema-tests/PageDefinition/valid/all-properties.yaml +0 -15
- package/api/schema-tests/PageDefinition/valid/minimal.yaml +0 -5
- package/api/schema-tests/TabsPageDefinition/invalid/missing-subPages.yaml +0 -2
- package/api/schema-tests/TabsPageDefinition/valid/tabs.yaml +0 -7
- package/api/tags/app.js.map +0 -1
- package/api/tags/app.ts +0 -6
- package/api/tags/appMember.js.map +0 -1
- package/api/tags/appMember.ts +0 -6
- package/api/tags/asset.js.map +0 -1
- package/api/tags/asset.ts +0 -6
- package/api/tags/auth.js.map +0 -1
- package/api/tags/auth.ts +0 -6
- package/api/tags/index.js.map +0 -1
- package/api/tags/index.ts +0 -9
- package/api/tags/language.js.map +0 -1
- package/api/tags/language.ts +0 -6
- package/api/tags/organization.js.map +0 -1
- package/api/tags/organization.ts +0 -6
- package/api/tags/resource.js.map +0 -1
- package/api/tags/resource.ts +0 -6
- package/api/tags/template.js.map +0 -1
- package/api/tags/template.ts +0 -6
- package/api/tags/user.js.map +0 -1
- package/api/tags/user.ts +0 -6
- package/appMessages.js.map +0 -1
- package/appMessages.test.js.map +0 -1
- package/appMessages.test.ts +0 -432
- package/appMessages.ts +0 -145
- package/appSecurity.js.map +0 -1
- package/appSecurity.test.js.map +0 -1
- package/appSecurity.test.ts +0 -141
- package/appSecurity.ts +0 -48
- package/blockUtils.js.map +0 -1
- package/blockUtils.test.js.map +0 -1
- package/blockUtils.test.ts +0 -94
- package/blockUtils.ts +0 -76
- package/changed/added/.gitkeep +0 -0
- package/changed/changed/.gitkeep +0 -0
- package/changed/deprecated/.gitkeep +0 -0
- package/changed/fixed/.gitkeep +0 -0
- package/changed/removed/.gitkeep +0 -0
- package/changed/security/.gitkeep +0 -0
- package/checkAppRole.js.map +0 -1
- package/checkAppRole.ts +0 -49
- package/compare.js.map +0 -1
- package/compare.ts +0 -10
- package/constants/Permission.js.map +0 -1
- package/constants/Permission.ts +0 -95
- package/constants/asciiLogo.js.map +0 -1
- package/constants/asciiLogo.ts +0 -8
- package/constants/baseTheme.js.map +0 -1
- package/constants/baseTheme.ts +0 -17
- package/constants/date.js.map +0 -1
- package/constants/date.ts +0 -20
- package/constants/fonts.js.map +0 -1
- package/constants/fonts.ts +0 -1291
- package/constants/index.js.map +0 -1
- package/constants/index.ts +0 -9
- package/constants/locale.js.map +0 -1
- package/constants/locale.ts +0 -4
- package/constants/patterns.js.map +0 -1
- package/constants/patterns.test.js.map +0 -1
- package/constants/patterns.test.ts +0 -100
- package/constants/patterns.ts +0 -48
- package/constants/roles.js.map +0 -1
- package/constants/roles.ts +0 -49
- package/constants/scopes.js.map +0 -1
- package/constants/scopes.ts +0 -13
- package/convertToCsv.js.map +0 -1
- package/convertToCsv.test.js.map +0 -1
- package/convertToCsv.test.ts +0 -73
- package/convertToCsv.ts +0 -65
- package/formatRequestAction.js.map +0 -1
- package/formatRequestAction.ts +0 -16
- package/has.js.map +0 -1
- package/has.test.js.map +0 -1
- package/has.test.ts +0 -19
- package/has.ts +0 -10
- package/i18n.js.map +0 -1
- package/i18n.test.js.map +0 -1
- package/i18n.test.ts +0 -81
- package/i18n.ts +0 -55
- package/ics.js.map +0 -1
- package/ics.ts +0 -44
- package/index.js.map +0 -1
- package/index.ts +0 -29
- package/intl-messageformat.js.map +0 -1
- package/intl-messageformat.ts +0 -6
- package/iterApp.js.map +0 -1
- package/iterApp.test.js.map +0 -1
- package/iterApp.test.ts +0 -512
- package/iterApp.ts +0 -174
- package/jest.config.js +0 -3
- package/jsonschema.js.map +0 -1
- package/jsonschema.test.js.map +0 -1
- package/jsonschema.test.ts +0 -320
- package/jsonschema.ts +0 -222
- package/langmap.js.map +0 -1
- package/langmap.ts +0 -23
- package/mapValues.js.map +0 -1
- package/mapValues.test.js.map +0 -1
- package/mapValues.test.ts +0 -15
- package/mapValues.ts +0 -10
- package/miscellaneous.js.map +0 -1
- package/miscellaneous.test.js.map +0 -1
- package/miscellaneous.test.ts +0 -82
- package/miscellaneous.ts +0 -71
- package/noop.js.map +0 -1
- package/noop.ts +0 -5
- package/normalize.js.map +0 -1
- package/normalize.test.js.map +0 -1
- package/normalize.test.ts +0 -24
- package/normalize.ts +0 -23
- package/objectCache.js.map +0 -1
- package/objectCache.test.js.map +0 -1
- package/objectCache.test.ts +0 -19
- package/objectCache.ts +0 -22
- package/pem.js.map +0 -1
- package/pem.ts +0 -11
- package/prefix.js.map +0 -1
- package/prefix.test.js.map +0 -1
- package/prefix.test.ts +0 -11
- package/prefix.ts +0 -10
- package/remap.js.map +0 -1
- package/remap.test.js.map +0 -1
- package/remap.test.ts +0 -1039
- package/remap.ts +0 -455
- package/string.js.map +0 -1
- package/string.test.js.map +0 -1
- package/string.test.ts +0 -29
- package/string.ts +0 -31
- package/theme.js.map +0 -1
- package/theme.test.js.map +0 -1
- package/theme.test.ts +0 -99
- package/theme.ts +0 -38
- package/tsconfig.json +0 -6
- package/types.js.map +0 -1
- package/types.ts +0 -6
- package/validateStyle.js.map +0 -1
- package/validateStyle.test.js.map +0 -1
- package/validateStyle.test.ts +0 -14
- package/validateStyle.ts +0 -19
- package/validation.js.map +0 -1
- package/validation.test.js.map +0 -1
- package/validation.test.ts +0 -1915
- package/validation.ts +0 -767
package/remap.test.ts
DELETED
|
@@ -1,1039 +0,0 @@
|
|
|
1
|
-
import { AppMessages, Remapper, UserInfo } from '@appsemble/types';
|
|
2
|
-
|
|
3
|
-
import { IntlMessageFormat } from './intl-messageformat.js';
|
|
4
|
-
import { remap } from './remap.js';
|
|
5
|
-
|
|
6
|
-
interface TestCase {
|
|
7
|
-
input: any;
|
|
8
|
-
mappers: Remapper;
|
|
9
|
-
expected: any;
|
|
10
|
-
messages?: AppMessages['messages'];
|
|
11
|
-
userInfo?: UserInfo;
|
|
12
|
-
context?: Record<string, any>;
|
|
13
|
-
history?: unknown[];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
function runTests(tests: Record<string, TestCase>): void {
|
|
17
|
-
it.each(Object.entries(tests))(
|
|
18
|
-
'should %s',
|
|
19
|
-
(name, { context, expected, history, input, mappers, messages, userInfo }) => {
|
|
20
|
-
const result = remap(mappers, input, {
|
|
21
|
-
getMessage: ({ defaultMessage, id }) =>
|
|
22
|
-
new IntlMessageFormat(messages?.messageIds?.[id] ?? defaultMessage),
|
|
23
|
-
url: 'https://example.com/en/example',
|
|
24
|
-
appUrl: 'https://example.com',
|
|
25
|
-
userInfo,
|
|
26
|
-
context,
|
|
27
|
-
history,
|
|
28
|
-
appId: 6789,
|
|
29
|
-
locale: 'en',
|
|
30
|
-
pageData: { hello: 'Page data' },
|
|
31
|
-
});
|
|
32
|
-
expect(result).toStrictEqual(expected);
|
|
33
|
-
},
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
describe('Primitive values', () => {
|
|
38
|
-
runTests({
|
|
39
|
-
'return a literal string': {
|
|
40
|
-
input: 'a string',
|
|
41
|
-
mappers: 'raw string',
|
|
42
|
-
expected: 'raw string',
|
|
43
|
-
},
|
|
44
|
-
'return a literal number': {
|
|
45
|
-
input: 'a string',
|
|
46
|
-
mappers: 42,
|
|
47
|
-
expected: 42,
|
|
48
|
-
},
|
|
49
|
-
'return a literal boolean': {
|
|
50
|
-
input: 'a string',
|
|
51
|
-
mappers: false,
|
|
52
|
-
expected: false,
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('app', () => {
|
|
58
|
-
runTests({
|
|
59
|
-
'return the app id': {
|
|
60
|
-
input: {},
|
|
61
|
-
mappers: { app: 'id' },
|
|
62
|
-
expected: 6789,
|
|
63
|
-
},
|
|
64
|
-
'return the curent url': {
|
|
65
|
-
input: {},
|
|
66
|
-
mappers: { app: 'url' },
|
|
67
|
-
expected: 'https://example.com',
|
|
68
|
-
},
|
|
69
|
-
'return the current locale': {
|
|
70
|
-
input: {},
|
|
71
|
-
mappers: { app: 'locale' },
|
|
72
|
-
expected: 'en',
|
|
73
|
-
},
|
|
74
|
-
});
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
describe('page', () => {
|
|
78
|
-
runTests({
|
|
79
|
-
'return the page url': {
|
|
80
|
-
input: {},
|
|
81
|
-
mappers: { page: 'url' },
|
|
82
|
-
expected: 'https://example.com/en/example',
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
runTests({
|
|
87
|
-
'return page data': {
|
|
88
|
-
input: {},
|
|
89
|
-
mappers: { page: 'data' },
|
|
90
|
-
expected: { hello: 'Page data' },
|
|
91
|
-
},
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
describe('context', () => {
|
|
96
|
-
runTests({
|
|
97
|
-
'get a simple property from context': {
|
|
98
|
-
input: {},
|
|
99
|
-
mappers: { context: 'name' },
|
|
100
|
-
expected: 'Spongebob',
|
|
101
|
-
context: { name: 'Spongebob' },
|
|
102
|
-
},
|
|
103
|
-
'get a nested property': {
|
|
104
|
-
input: {},
|
|
105
|
-
context: { address: { town: 'Bikini Bottom' } },
|
|
106
|
-
mappers: { context: 'address.town' },
|
|
107
|
-
expected: 'Bikini Bottom',
|
|
108
|
-
},
|
|
109
|
-
'handle null': {
|
|
110
|
-
input: {},
|
|
111
|
-
context: { name: 'Spongebob' },
|
|
112
|
-
mappers: { context: null },
|
|
113
|
-
expected: null,
|
|
114
|
-
},
|
|
115
|
-
'handle properties named null': {
|
|
116
|
-
input: {},
|
|
117
|
-
context: { null: 'Spongebob' },
|
|
118
|
-
mappers: { context: null },
|
|
119
|
-
expected: 'Spongebob',
|
|
120
|
-
},
|
|
121
|
-
'handle null values': {
|
|
122
|
-
input: {},
|
|
123
|
-
mappers: { context: 'foo.bar' },
|
|
124
|
-
expected: null,
|
|
125
|
-
},
|
|
126
|
-
'return null if context is not available': {
|
|
127
|
-
input: {},
|
|
128
|
-
mappers: { context: 'test' },
|
|
129
|
-
expected: null,
|
|
130
|
-
},
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
describe('date.now', () => {
|
|
135
|
-
beforeEach(() => {
|
|
136
|
-
import.meta.jest.useFakeTimers({ now: 0 });
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
runTests({
|
|
140
|
-
'return the current date': {
|
|
141
|
-
input: 'whatever',
|
|
142
|
-
mappers: { 'date.now': {} },
|
|
143
|
-
expected: new Date(0),
|
|
144
|
-
},
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
describe('date.add', () => {
|
|
149
|
-
beforeEach(() => {
|
|
150
|
-
import.meta.jest.useFakeTimers({ now: 0 });
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
runTests({
|
|
154
|
-
'add 3 days to the given date': {
|
|
155
|
-
input: 'whatever',
|
|
156
|
-
mappers: [{ 'date.now': {} }, { 'date.add': '3d' }],
|
|
157
|
-
expected: new Date(3 * 24 * 60 * 60 * 1e3),
|
|
158
|
-
},
|
|
159
|
-
'add 3 days to the given date as number': {
|
|
160
|
-
input: 20e3,
|
|
161
|
-
mappers: [{ 'date.add': '3d' }],
|
|
162
|
-
expected: new Date(3 * 24 * 60 * 60 * 1e3 + 20e3),
|
|
163
|
-
},
|
|
164
|
-
'subtract 1 day from the given date': {
|
|
165
|
-
input: 'whatever',
|
|
166
|
-
mappers: [{ 'date.now': {} }, { 'date.add': '-1d' }],
|
|
167
|
-
expected: new Date(-(24 * 60 * 60 * 1e3)),
|
|
168
|
-
},
|
|
169
|
-
'return input when input is nothing': {
|
|
170
|
-
input: undefined,
|
|
171
|
-
mappers: [{ 'date.add': '3d' }],
|
|
172
|
-
expected: undefined,
|
|
173
|
-
},
|
|
174
|
-
'return input when input is not a date': {
|
|
175
|
-
input: 'whatever',
|
|
176
|
-
mappers: [{ 'date.add': '3d' }],
|
|
177
|
-
expected: 'whatever',
|
|
178
|
-
},
|
|
179
|
-
'return input date when duration is invalid': {
|
|
180
|
-
input: new Date(1000),
|
|
181
|
-
mappers: [{ 'date.add': '3dd' }],
|
|
182
|
-
expected: new Date(1000),
|
|
183
|
-
},
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
describe('le', () => {
|
|
188
|
-
runTests({
|
|
189
|
-
'return true if the left value is less than the right value': {
|
|
190
|
-
input: { left: 42, right: 420 },
|
|
191
|
-
mappers: { lt: [{ prop: 'left' }, { prop: 'right' }] },
|
|
192
|
-
expected: true,
|
|
193
|
-
},
|
|
194
|
-
'work with dates': {
|
|
195
|
-
input: { left: new Date(200_000), right: new Date(0) },
|
|
196
|
-
mappers: { gt: [{ prop: 'left' }, { prop: 'right' }] },
|
|
197
|
-
expected: true,
|
|
198
|
-
},
|
|
199
|
-
'work with strings': {
|
|
200
|
-
input: { left: 'aa', right: 'a' },
|
|
201
|
-
mappers: { gt: [{ prop: 'left' }, { prop: 'right' }] },
|
|
202
|
-
expected: true,
|
|
203
|
-
},
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
describe('ge', () => {
|
|
208
|
-
runTests({
|
|
209
|
-
'return true if the left value is greater than the right value': {
|
|
210
|
-
input: { left: 420, right: 42 },
|
|
211
|
-
mappers: { gt: [{ prop: 'left' }, { prop: 'right' }] },
|
|
212
|
-
expected: true,
|
|
213
|
-
},
|
|
214
|
-
'work with dates': {
|
|
215
|
-
input: { left: new Date(200_000), right: new Date(0) },
|
|
216
|
-
mappers: { gt: [{ prop: 'left' }, { prop: 'right' }] },
|
|
217
|
-
expected: true,
|
|
218
|
-
},
|
|
219
|
-
'work with strings': {
|
|
220
|
-
input: { left: 'aa', right: 'a' },
|
|
221
|
-
mappers: { gt: [{ prop: 'left' }, { prop: 'right' }] },
|
|
222
|
-
expected: true,
|
|
223
|
-
},
|
|
224
|
-
});
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
describe('equals', () => {
|
|
228
|
-
runTests({
|
|
229
|
-
'return true if all values are equal': {
|
|
230
|
-
input: [1, 1, 1],
|
|
231
|
-
mappers: { equals: [{ prop: '0' }, { prop: '1' }, { prop: '2' }] },
|
|
232
|
-
expected: true,
|
|
233
|
-
},
|
|
234
|
-
'use deep equality': {
|
|
235
|
-
input: [{ foo: { bar: 3 } }, { foo: { bar: 3 } }],
|
|
236
|
-
mappers: { equals: [{ prop: '0' }, { prop: '1' }] },
|
|
237
|
-
expected: true,
|
|
238
|
-
},
|
|
239
|
-
'return false if not all values are equal': {
|
|
240
|
-
input: [{ foo: { bar: 3 } }, { foo: { bar: 2 } }],
|
|
241
|
-
mappers: { equals: [{ prop: '0' }, { prop: '1' }] },
|
|
242
|
-
expected: false,
|
|
243
|
-
},
|
|
244
|
-
'return true on empty arrays': {
|
|
245
|
-
input: { empty: [] },
|
|
246
|
-
mappers: { equals: [] },
|
|
247
|
-
expected: true,
|
|
248
|
-
},
|
|
249
|
-
'return true on arrays with 1 entry': {
|
|
250
|
-
input: { empty: [] },
|
|
251
|
-
mappers: { equals: [{ prop: 'empty' }] },
|
|
252
|
-
expected: true,
|
|
253
|
-
},
|
|
254
|
-
});
|
|
255
|
-
});
|
|
256
|
-
|
|
257
|
-
describe('ics', () => {
|
|
258
|
-
runTests({
|
|
259
|
-
'support string date': {
|
|
260
|
-
input: {
|
|
261
|
-
date: '2023-01-01T00:00:00Z',
|
|
262
|
-
title: 'Happy new year!',
|
|
263
|
-
description: 'Best wishes for 2023 🍾',
|
|
264
|
-
url: 'https://example.com',
|
|
265
|
-
location: 'Earth',
|
|
266
|
-
latlng: [0, 0],
|
|
267
|
-
},
|
|
268
|
-
mappers: [
|
|
269
|
-
{
|
|
270
|
-
ics: {
|
|
271
|
-
start: { prop: 'date' },
|
|
272
|
-
title: { prop: 'title' },
|
|
273
|
-
description: { prop: 'description' },
|
|
274
|
-
duration: '24h',
|
|
275
|
-
url: { prop: 'url' },
|
|
276
|
-
location: { prop: 'location' },
|
|
277
|
-
coordinates: { prop: 'latlng' },
|
|
278
|
-
},
|
|
279
|
-
},
|
|
280
|
-
{ 'string.replace': { 'UID:[\\w-]+': 'UID:UID_STUB' } },
|
|
281
|
-
{ 'string.replace': { 'DTSTAMP:\\w+': 'DTSTAMP:DTSTAMP_STUB' } },
|
|
282
|
-
],
|
|
283
|
-
expected: `BEGIN:VCALENDAR\r
|
|
284
|
-
VERSION:2.0\r
|
|
285
|
-
CALSCALE:GREGORIAN\r
|
|
286
|
-
PRODID:https://example.com\r
|
|
287
|
-
METHOD:PUBLISH\r
|
|
288
|
-
X-PUBLISHED-TTL:PT1H\r
|
|
289
|
-
BEGIN:VEVENT\r
|
|
290
|
-
UID:UID_STUB\r
|
|
291
|
-
SUMMARY:Happy new year!\r
|
|
292
|
-
DTSTAMP:DTSTAMP_STUB\r
|
|
293
|
-
DTSTART:20230101T000000Z\r
|
|
294
|
-
DESCRIPTION:Best wishes for 2023 🍾\r
|
|
295
|
-
URL:https://example.com\r
|
|
296
|
-
GEO:0;0\r
|
|
297
|
-
LOCATION:Earth\r
|
|
298
|
-
DURATION:P1DT\r
|
|
299
|
-
END:VEVENT\r
|
|
300
|
-
END:VCALENDAR\r
|
|
301
|
-
`,
|
|
302
|
-
},
|
|
303
|
-
'support JavaScript date': {
|
|
304
|
-
input: {
|
|
305
|
-
date: new Date('2023-01-01T00:00:00Z'),
|
|
306
|
-
title: 'Happy new year!',
|
|
307
|
-
description: 'Best wishes for 2023 🍾',
|
|
308
|
-
url: 'https://example.com',
|
|
309
|
-
location: 'Earth',
|
|
310
|
-
latlng: [0, 0],
|
|
311
|
-
},
|
|
312
|
-
mappers: [
|
|
313
|
-
{
|
|
314
|
-
ics: {
|
|
315
|
-
start: { prop: 'date' },
|
|
316
|
-
title: { prop: 'title' },
|
|
317
|
-
description: { prop: 'description' },
|
|
318
|
-
duration: '24h',
|
|
319
|
-
url: { prop: 'url' },
|
|
320
|
-
location: { prop: 'location' },
|
|
321
|
-
coordinates: { prop: 'latlng' },
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
{ 'string.replace': { 'UID:[\\w-]+': 'UID:UID_STUB' } },
|
|
325
|
-
{ 'string.replace': { 'DTSTAMP:\\w+': 'DTSTAMP:DTSTAMP_STUB' } },
|
|
326
|
-
],
|
|
327
|
-
expected: `BEGIN:VCALENDAR\r
|
|
328
|
-
VERSION:2.0\r
|
|
329
|
-
CALSCALE:GREGORIAN\r
|
|
330
|
-
PRODID:https://example.com\r
|
|
331
|
-
METHOD:PUBLISH\r
|
|
332
|
-
X-PUBLISHED-TTL:PT1H\r
|
|
333
|
-
BEGIN:VEVENT\r
|
|
334
|
-
UID:UID_STUB\r
|
|
335
|
-
SUMMARY:Happy new year!\r
|
|
336
|
-
DTSTAMP:DTSTAMP_STUB\r
|
|
337
|
-
DTSTART:20230101T000000Z\r
|
|
338
|
-
DESCRIPTION:Best wishes for 2023 🍾\r
|
|
339
|
-
URL:https://example.com\r
|
|
340
|
-
GEO:0;0\r
|
|
341
|
-
LOCATION:Earth\r
|
|
342
|
-
DURATION:P1DT\r
|
|
343
|
-
END:VEVENT\r
|
|
344
|
-
END:VCALENDAR\r
|
|
345
|
-
`,
|
|
346
|
-
},
|
|
347
|
-
|
|
348
|
-
'support end string date': {
|
|
349
|
-
input: {
|
|
350
|
-
date: '2023-01-01T00:00:00Z',
|
|
351
|
-
endDate: '2023-01-02T00:00:00Z',
|
|
352
|
-
title: 'Happy new year!',
|
|
353
|
-
description: 'Best wishes for 2023 🍾',
|
|
354
|
-
url: 'https://example.com',
|
|
355
|
-
location: 'Earth',
|
|
356
|
-
latlng: [0, 0],
|
|
357
|
-
},
|
|
358
|
-
mappers: [
|
|
359
|
-
{
|
|
360
|
-
ics: {
|
|
361
|
-
start: { prop: 'date' },
|
|
362
|
-
title: { prop: 'title' },
|
|
363
|
-
description: { prop: 'description' },
|
|
364
|
-
end: { prop: 'endDate' },
|
|
365
|
-
url: { prop: 'url' },
|
|
366
|
-
location: { prop: 'location' },
|
|
367
|
-
coordinates: { prop: 'latlng' },
|
|
368
|
-
},
|
|
369
|
-
},
|
|
370
|
-
{ 'string.replace': { 'UID:[\\w-]+': 'UID:UID_STUB' } },
|
|
371
|
-
{ 'string.replace': { 'DTSTAMP:\\w+': 'DTSTAMP:DTSTAMP_STUB' } },
|
|
372
|
-
],
|
|
373
|
-
expected: `BEGIN:VCALENDAR\r
|
|
374
|
-
VERSION:2.0\r
|
|
375
|
-
CALSCALE:GREGORIAN\r
|
|
376
|
-
PRODID:https://example.com\r
|
|
377
|
-
METHOD:PUBLISH\r
|
|
378
|
-
X-PUBLISHED-TTL:PT1H\r
|
|
379
|
-
BEGIN:VEVENT\r
|
|
380
|
-
UID:UID_STUB\r
|
|
381
|
-
SUMMARY:Happy new year!\r
|
|
382
|
-
DTSTAMP:DTSTAMP_STUB\r
|
|
383
|
-
DTSTART:20230101T000000Z\r
|
|
384
|
-
DTEND:20230102T000000Z\r
|
|
385
|
-
DESCRIPTION:Best wishes for 2023 🍾\r
|
|
386
|
-
URL:https://example.com\r
|
|
387
|
-
GEO:0;0\r
|
|
388
|
-
LOCATION:Earth\r
|
|
389
|
-
END:VEVENT\r
|
|
390
|
-
END:VCALENDAR\r
|
|
391
|
-
`,
|
|
392
|
-
},
|
|
393
|
-
'support end JavaScript date': {
|
|
394
|
-
input: {
|
|
395
|
-
date: new Date('2023-01-01T00:00:00Z'),
|
|
396
|
-
endDate: new Date('2023-01-02T00:00:00Z'),
|
|
397
|
-
title: 'Happy new year!',
|
|
398
|
-
description: 'Best wishes for 2023 🍾',
|
|
399
|
-
url: 'https://example.com',
|
|
400
|
-
location: 'Earth',
|
|
401
|
-
latlng: [0, 0],
|
|
402
|
-
},
|
|
403
|
-
mappers: [
|
|
404
|
-
{
|
|
405
|
-
ics: {
|
|
406
|
-
start: { prop: 'date' },
|
|
407
|
-
title: { prop: 'title' },
|
|
408
|
-
description: { prop: 'description' },
|
|
409
|
-
end: { prop: 'endDate' },
|
|
410
|
-
url: { prop: 'url' },
|
|
411
|
-
location: { prop: 'location' },
|
|
412
|
-
coordinates: { prop: 'latlng' },
|
|
413
|
-
},
|
|
414
|
-
},
|
|
415
|
-
{ 'string.replace': { 'UID:[\\w-]+': 'UID:UID_STUB' } },
|
|
416
|
-
{ 'string.replace': { 'DTSTAMP:\\w+': 'DTSTAMP:DTSTAMP_STUB' } },
|
|
417
|
-
],
|
|
418
|
-
expected: `BEGIN:VCALENDAR\r
|
|
419
|
-
VERSION:2.0\r
|
|
420
|
-
CALSCALE:GREGORIAN\r
|
|
421
|
-
PRODID:https://example.com\r
|
|
422
|
-
METHOD:PUBLISH\r
|
|
423
|
-
X-PUBLISHED-TTL:PT1H\r
|
|
424
|
-
BEGIN:VEVENT\r
|
|
425
|
-
UID:UID_STUB\r
|
|
426
|
-
SUMMARY:Happy new year!\r
|
|
427
|
-
DTSTAMP:DTSTAMP_STUB\r
|
|
428
|
-
DTSTART:20230101T000000Z\r
|
|
429
|
-
DTEND:20230102T000000Z\r
|
|
430
|
-
DESCRIPTION:Best wishes for 2023 🍾\r
|
|
431
|
-
URL:https://example.com\r
|
|
432
|
-
GEO:0;0\r
|
|
433
|
-
LOCATION:Earth\r
|
|
434
|
-
END:VEVENT\r
|
|
435
|
-
END:VCALENDAR\r
|
|
436
|
-
`,
|
|
437
|
-
},
|
|
438
|
-
});
|
|
439
|
-
});
|
|
440
|
-
|
|
441
|
-
describe('if', () => {
|
|
442
|
-
runTests({
|
|
443
|
-
'return the value of then if condition is truthy': {
|
|
444
|
-
input: { really: true },
|
|
445
|
-
mappers: { if: { condition: { prop: 'really' }, else: 'no really', then: 'yes really' } },
|
|
446
|
-
expected: 'yes really',
|
|
447
|
-
},
|
|
448
|
-
'return the value of else if condition is falsy': {
|
|
449
|
-
input: { really: false },
|
|
450
|
-
mappers: { if: { condition: { prop: 'really' }, else: 'no really', then: 'yes really' } },
|
|
451
|
-
expected: 'no really',
|
|
452
|
-
},
|
|
453
|
-
'return the value of then if condition is empty': {
|
|
454
|
-
input: { really: false },
|
|
455
|
-
mappers: { if: { condition: [], else: 'no really', then: 'yes really' } },
|
|
456
|
-
expected: 'yes really',
|
|
457
|
-
},
|
|
458
|
-
'return input if else is empty': {
|
|
459
|
-
input: { really: false },
|
|
460
|
-
mappers: { if: { condition: { prop: 'really' }, else: [], then: 'yes really' } },
|
|
461
|
-
expected: { really: false },
|
|
462
|
-
},
|
|
463
|
-
'return input if then is empty': {
|
|
464
|
-
input: { really: true },
|
|
465
|
-
mappers: { if: { condition: { prop: 'really' }, else: 'no really', then: [] } },
|
|
466
|
-
expected: { really: true },
|
|
467
|
-
},
|
|
468
|
-
});
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
describe('object.from', () => {
|
|
472
|
-
runTests({
|
|
473
|
-
'create a new object from remappers': {
|
|
474
|
-
input: { givenName: 'Patrick', familyName: 'Star', species: 'Starfish' },
|
|
475
|
-
mappers: {
|
|
476
|
-
'object.from': { firstName: { prop: 'givenName' }, lastName: { prop: 'familyName' } },
|
|
477
|
-
},
|
|
478
|
-
|
|
479
|
-
expected: { firstName: 'Patrick', lastName: 'Star' },
|
|
480
|
-
},
|
|
481
|
-
});
|
|
482
|
-
});
|
|
483
|
-
|
|
484
|
-
describe('object.omit', () => {
|
|
485
|
-
runTests({
|
|
486
|
-
'omit properties from existing object': {
|
|
487
|
-
input: { foo: 'foo', bar: 'bar', baz: 'baz' },
|
|
488
|
-
mappers: {
|
|
489
|
-
'object.omit': ['bar'],
|
|
490
|
-
},
|
|
491
|
-
expected: { foo: 'foo', baz: 'baz' },
|
|
492
|
-
},
|
|
493
|
-
'delete nested properties': {
|
|
494
|
-
input: { foo: 1, bar: 'bar', baz: { test: 'foo', test2: 10 } },
|
|
495
|
-
mappers: {
|
|
496
|
-
'object.omit': ['bar', ['baz', 'test']],
|
|
497
|
-
},
|
|
498
|
-
expected: { foo: 1, baz: { test2: 10 } },
|
|
499
|
-
},
|
|
500
|
-
'handle non existing properties': {
|
|
501
|
-
input: { foo: 1, bar: 'bar', baz: { test: 'foo', test2: 10 } },
|
|
502
|
-
mappers: {
|
|
503
|
-
'object.omit': ['bar', ['baz', '5']],
|
|
504
|
-
},
|
|
505
|
-
expected: { foo: 1, baz: { test: 'foo', test2: 10 } },
|
|
506
|
-
},
|
|
507
|
-
});
|
|
508
|
-
});
|
|
509
|
-
|
|
510
|
-
describe('object.assign', () => {
|
|
511
|
-
runTests({
|
|
512
|
-
'assign to an object from remappers': {
|
|
513
|
-
input: { givenName: 'Patrick', familyName: 'Star' },
|
|
514
|
-
mappers: {
|
|
515
|
-
'object.assign': {
|
|
516
|
-
familyName: [{ prop: 'familyName' }, { 'string.case': 'lower' }],
|
|
517
|
-
species: 'Starfish',
|
|
518
|
-
},
|
|
519
|
-
},
|
|
520
|
-
|
|
521
|
-
expected: { givenName: 'Patrick', familyName: 'star', species: 'Starfish' },
|
|
522
|
-
},
|
|
523
|
-
});
|
|
524
|
-
});
|
|
525
|
-
|
|
526
|
-
describe('array.map', () => {
|
|
527
|
-
runTests({
|
|
528
|
-
'apply remappers to each array item': {
|
|
529
|
-
input: [
|
|
530
|
-
{ firstName: 'John', lastName: 'Doe' },
|
|
531
|
-
{ firstName: 'Jane', lastName: 'Smith' },
|
|
532
|
-
],
|
|
533
|
-
mappers: {
|
|
534
|
-
'array.map': [
|
|
535
|
-
{
|
|
536
|
-
'string.format': {
|
|
537
|
-
template: '{firstName} {lastName}',
|
|
538
|
-
values: {
|
|
539
|
-
firstName: { prop: 'firstName' },
|
|
540
|
-
lastName: { prop: 'lastName' },
|
|
541
|
-
},
|
|
542
|
-
},
|
|
543
|
-
},
|
|
544
|
-
{ 'string.case': 'lower' },
|
|
545
|
-
],
|
|
546
|
-
},
|
|
547
|
-
|
|
548
|
-
expected: ['john doe', 'jane smith'],
|
|
549
|
-
},
|
|
550
|
-
});
|
|
551
|
-
});
|
|
552
|
-
|
|
553
|
-
describe('array.unique', () => {
|
|
554
|
-
runTests({
|
|
555
|
-
'return the input if the input is not an array': {
|
|
556
|
-
input: { a: 1, b: 2, c: 3 },
|
|
557
|
-
mappers: [{ 'array.unique': null }],
|
|
558
|
-
expected: { a: 1, b: 2, c: 3 },
|
|
559
|
-
},
|
|
560
|
-
'filter out duplicate values using primitive values without a remapper': {
|
|
561
|
-
input: [1, 2, 2, 3],
|
|
562
|
-
mappers: [{ 'array.unique': null }],
|
|
563
|
-
expected: [1, 2, 3],
|
|
564
|
-
},
|
|
565
|
-
'filter out duplicate values using complex values without a remapper': {
|
|
566
|
-
input: [
|
|
567
|
-
{ id: 1, value: 'one' },
|
|
568
|
-
{ id: 1, value: 'one' },
|
|
569
|
-
{ id: 1, value: 'one' },
|
|
570
|
-
{ id: 2, value: 'two' },
|
|
571
|
-
],
|
|
572
|
-
mappers: [{ 'array.unique': null }],
|
|
573
|
-
expected: [
|
|
574
|
-
{ id: 1, value: 'one' },
|
|
575
|
-
{ id: 2, value: 'two' },
|
|
576
|
-
],
|
|
577
|
-
},
|
|
578
|
-
'filter out duplicate values using complex values with a remapper': {
|
|
579
|
-
input: [
|
|
580
|
-
{ id: 1, value: 'one' },
|
|
581
|
-
{ id: 1, value: 'one' },
|
|
582
|
-
{ id: 1, value: 'ONE' },
|
|
583
|
-
{ id: 2, value: 'two' },
|
|
584
|
-
],
|
|
585
|
-
mappers: [{ 'array.unique': { prop: 'value' } }],
|
|
586
|
-
expected: [
|
|
587
|
-
{ id: 1, value: 'one' },
|
|
588
|
-
{ id: 1, value: 'ONE' },
|
|
589
|
-
{ id: 2, value: 'two' },
|
|
590
|
-
],
|
|
591
|
-
},
|
|
592
|
-
});
|
|
593
|
-
});
|
|
594
|
-
|
|
595
|
-
describe('array', () => {
|
|
596
|
-
runTests({
|
|
597
|
-
'return undefined if not in the context of array.map': {
|
|
598
|
-
input: {},
|
|
599
|
-
mappers: [
|
|
600
|
-
{
|
|
601
|
-
'object.from': {
|
|
602
|
-
index: [{ array: 'index' }],
|
|
603
|
-
length: [{ array: 'length' }],
|
|
604
|
-
},
|
|
605
|
-
},
|
|
606
|
-
],
|
|
607
|
-
expected: { index: undefined, length: undefined },
|
|
608
|
-
},
|
|
609
|
-
'return the index and length if in the context of array.map': {
|
|
610
|
-
input: { array: [{ value: 'a' }, { value: 'b' }, { value: 'c' }] },
|
|
611
|
-
mappers: [
|
|
612
|
-
{ prop: 'array' },
|
|
613
|
-
{
|
|
614
|
-
'array.map': [
|
|
615
|
-
{
|
|
616
|
-
'object.from': {
|
|
617
|
-
value: [{ prop: 'value' }],
|
|
618
|
-
index: [{ array: 'index' }],
|
|
619
|
-
length: [{ array: 'length' }],
|
|
620
|
-
},
|
|
621
|
-
},
|
|
622
|
-
],
|
|
623
|
-
},
|
|
624
|
-
],
|
|
625
|
-
expected: [
|
|
626
|
-
{ value: 'a', index: 0, length: 3 },
|
|
627
|
-
{ value: 'b', index: 1, length: 3 },
|
|
628
|
-
{ value: 'c', index: 2, length: 3 },
|
|
629
|
-
],
|
|
630
|
-
},
|
|
631
|
-
});
|
|
632
|
-
});
|
|
633
|
-
|
|
634
|
-
describe('array.from', () => {
|
|
635
|
-
runTests({
|
|
636
|
-
'create new array with remapped values': {
|
|
637
|
-
input: { foo: 'bar' },
|
|
638
|
-
mappers: [{ 'array.from': [{ 'object.from': { foo: { prop: 'foo' } } }, 'baz'] }],
|
|
639
|
-
expected: [{ foo: 'bar' }, 'baz'],
|
|
640
|
-
},
|
|
641
|
-
'create empty array': {
|
|
642
|
-
input: { foo: 'bar' },
|
|
643
|
-
mappers: [{ 'array.from': [] }],
|
|
644
|
-
expected: [],
|
|
645
|
-
},
|
|
646
|
-
});
|
|
647
|
-
});
|
|
648
|
-
|
|
649
|
-
describe('array.append', () => {
|
|
650
|
-
runTests({
|
|
651
|
-
'append remapped value to array': {
|
|
652
|
-
input: ['baz'],
|
|
653
|
-
mappers: [{ 'array.append': [{ 'object.from': { foo: 'bar' } }] }],
|
|
654
|
-
expected: ['baz', { foo: 'bar' }],
|
|
655
|
-
},
|
|
656
|
-
'create empty array': {
|
|
657
|
-
input: { foo: 'bar' },
|
|
658
|
-
mappers: [{ 'array.append': [] }],
|
|
659
|
-
expected: [],
|
|
660
|
-
},
|
|
661
|
-
});
|
|
662
|
-
});
|
|
663
|
-
|
|
664
|
-
describe('array.omit', () => {
|
|
665
|
-
runTests({
|
|
666
|
-
'omit objects at given remapped indices': {
|
|
667
|
-
input: [{ foo: '...' }, { bar: '...' }, { baz: '...' }],
|
|
668
|
-
mappers: [{ 'array.omit': [0, { context: 'index' }] }],
|
|
669
|
-
expected: [{ bar: '...' }],
|
|
670
|
-
context: { index: 2 },
|
|
671
|
-
},
|
|
672
|
-
'omit nothing': {
|
|
673
|
-
input: [{ foo: '...' }, { bar: '...' }, { baz: '...' }],
|
|
674
|
-
mappers: [{ 'array.omit': [{ static: 'index' }] }],
|
|
675
|
-
expected: [{ foo: '...' }, { bar: '...' }, { baz: '...' }],
|
|
676
|
-
},
|
|
677
|
-
'create empty array': {
|
|
678
|
-
input: { foo: 'bar' },
|
|
679
|
-
mappers: [{ 'array.omit': [] }],
|
|
680
|
-
expected: [],
|
|
681
|
-
},
|
|
682
|
-
});
|
|
683
|
-
});
|
|
684
|
-
|
|
685
|
-
describe('null.strip', () => {
|
|
686
|
-
runTests({
|
|
687
|
-
'strip null values': {
|
|
688
|
-
input: { foo: null, bar: { baz: undefined }, fooz: [null, , undefined] },
|
|
689
|
-
mappers: [{ 'null.strip': null }],
|
|
690
|
-
expected: { bar: {}, fooz: [] },
|
|
691
|
-
},
|
|
692
|
-
'support depth': {
|
|
693
|
-
input: { foo: null, bar: { baz: undefined }, fooz: [null, , undefined] },
|
|
694
|
-
mappers: [{ 'null.strip': { depth: 1 } }],
|
|
695
|
-
expected: { bar: { baz: undefined }, fooz: [null, , undefined] },
|
|
696
|
-
},
|
|
697
|
-
});
|
|
698
|
-
});
|
|
699
|
-
|
|
700
|
-
describe('prop', () => {
|
|
701
|
-
runTests({
|
|
702
|
-
'get a simple property': {
|
|
703
|
-
input: { name: 'Spongebob' },
|
|
704
|
-
mappers: { prop: 'name' },
|
|
705
|
-
expected: 'Spongebob',
|
|
706
|
-
},
|
|
707
|
-
'get a nested property': {
|
|
708
|
-
input: { address: { town: 'Bikini Bottom' } },
|
|
709
|
-
mappers: { prop: ['address', 'town'] },
|
|
710
|
-
expected: 'Bikini Bottom',
|
|
711
|
-
},
|
|
712
|
-
'get a property with a . in the key': {
|
|
713
|
-
input: { 'address.town': 'Bikini Bottom' },
|
|
714
|
-
mappers: { prop: 'address.town' },
|
|
715
|
-
expected: 'Bikini Bottom',
|
|
716
|
-
},
|
|
717
|
-
'handle numbers': {
|
|
718
|
-
input: { names: ['foo', 'bar'] },
|
|
719
|
-
mappers: [{ prop: 'names' }, { prop: 0 }],
|
|
720
|
-
expected: 'foo',
|
|
721
|
-
},
|
|
722
|
-
'handle null': {
|
|
723
|
-
input: { name: 'Spongebob' },
|
|
724
|
-
mappers: { prop: null },
|
|
725
|
-
expected: undefined,
|
|
726
|
-
},
|
|
727
|
-
'handle properties named null': {
|
|
728
|
-
input: { null: 'Spongebob' },
|
|
729
|
-
mappers: { prop: null },
|
|
730
|
-
expected: 'Spongebob',
|
|
731
|
-
},
|
|
732
|
-
'handle undefined values': {
|
|
733
|
-
input: {},
|
|
734
|
-
mappers: { prop: 'foo' },
|
|
735
|
-
expected: undefined,
|
|
736
|
-
},
|
|
737
|
-
'handle null values': {
|
|
738
|
-
input: { foo: null },
|
|
739
|
-
mappers: { prop: 'foo' },
|
|
740
|
-
expected: null,
|
|
741
|
-
},
|
|
742
|
-
});
|
|
743
|
-
});
|
|
744
|
-
|
|
745
|
-
describe('random.choice', () => {
|
|
746
|
-
it('should return random entries from a list', () => {
|
|
747
|
-
const input = [1, 2, 3, 4];
|
|
748
|
-
const result = remap({ 'random.choice': null }, input, null);
|
|
749
|
-
expect(input).toContain(result);
|
|
750
|
-
});
|
|
751
|
-
|
|
752
|
-
runTests({
|
|
753
|
-
'return the input if the input is not an array': {
|
|
754
|
-
input: { input: [1, 2, 3, 4] },
|
|
755
|
-
mappers: [{ 'random.choice': null }],
|
|
756
|
-
expected: { input: [1, 2, 3, 4] },
|
|
757
|
-
},
|
|
758
|
-
});
|
|
759
|
-
});
|
|
760
|
-
|
|
761
|
-
describe('random.integer', () => {
|
|
762
|
-
beforeEach(() => {
|
|
763
|
-
import.meta.jest.spyOn(Math, 'random').mockReturnValue(0.5);
|
|
764
|
-
});
|
|
765
|
-
|
|
766
|
-
runTests({
|
|
767
|
-
'return the input if the input is not an array': {
|
|
768
|
-
input: { input: undefined },
|
|
769
|
-
mappers: [{ 'random.integer': [5, 10] }],
|
|
770
|
-
expected: 7,
|
|
771
|
-
},
|
|
772
|
-
});
|
|
773
|
-
});
|
|
774
|
-
|
|
775
|
-
describe('random.float', () => {
|
|
776
|
-
beforeEach(() => {
|
|
777
|
-
import.meta.jest.spyOn(Math, 'random').mockReturnValue(0.5);
|
|
778
|
-
});
|
|
779
|
-
|
|
780
|
-
runTests({
|
|
781
|
-
'return the input if the input is not an array': {
|
|
782
|
-
input: { input: undefined },
|
|
783
|
-
mappers: [{ 'random.float': [5, 10] }],
|
|
784
|
-
expected: 7.5,
|
|
785
|
-
},
|
|
786
|
-
});
|
|
787
|
-
});
|
|
788
|
-
|
|
789
|
-
describe('random.string', () => {
|
|
790
|
-
beforeEach(() => {
|
|
791
|
-
import.meta.jest
|
|
792
|
-
.spyOn(Math, 'random')
|
|
793
|
-
.mockReturnValueOnce(0)
|
|
794
|
-
.mockReturnValueOnce(0.4)
|
|
795
|
-
.mockReturnValueOnce(0.5)
|
|
796
|
-
.mockReturnValueOnce(0.6)
|
|
797
|
-
.mockReturnValueOnce(0.7)
|
|
798
|
-
.mockReturnValueOnce(0.8)
|
|
799
|
-
.mockReturnValueOnce(0.2)
|
|
800
|
-
.mockReturnValueOnce(0.3)
|
|
801
|
-
.mockReturnValueOnce(0.4)
|
|
802
|
-
.mockReturnValueOnce(0.5)
|
|
803
|
-
.mockReturnValueOnce(0.7)
|
|
804
|
-
.mockReturnValueOnce(0.9)
|
|
805
|
-
.mockReturnValueOnce(0.6);
|
|
806
|
-
});
|
|
807
|
-
|
|
808
|
-
runTests({
|
|
809
|
-
'return the input if the input is not an array': {
|
|
810
|
-
input: { input: undefined },
|
|
811
|
-
mappers: [{ 'random.string': { choice: 'abcdefghijklmnopqrstuvwzyx', length: 12 } }],
|
|
812
|
-
expected: 'aknpsufhknszp',
|
|
813
|
-
},
|
|
814
|
-
});
|
|
815
|
-
});
|
|
816
|
-
|
|
817
|
-
describe('root', () => {
|
|
818
|
-
runTests({
|
|
819
|
-
'return the root input data': {
|
|
820
|
-
input: { input: 'data' },
|
|
821
|
-
mappers: [{ prop: 'input' }, { root: null }],
|
|
822
|
-
expected: { input: 'data' },
|
|
823
|
-
},
|
|
824
|
-
'not overwrite the root in the context': {
|
|
825
|
-
input: { input: 'data' },
|
|
826
|
-
mappers: [{ prop: 'input' }, { 'object.from': { key: { root: null } } }],
|
|
827
|
-
expected: { key: { input: 'data' } },
|
|
828
|
-
},
|
|
829
|
-
});
|
|
830
|
-
});
|
|
831
|
-
|
|
832
|
-
describe('history', () => {
|
|
833
|
-
runTests({
|
|
834
|
-
'return the first history item': {
|
|
835
|
-
input: { input: 'data' },
|
|
836
|
-
history: [{ old: 'monke' }, { latest: 'monke' }],
|
|
837
|
-
mappers: [{ prop: 'input' }, { history: 0 }],
|
|
838
|
-
expected: { old: 'monke' },
|
|
839
|
-
},
|
|
840
|
-
});
|
|
841
|
-
});
|
|
842
|
-
|
|
843
|
-
describe('from.history', () => {
|
|
844
|
-
runTests({
|
|
845
|
-
'create new object with props from the second history item': {
|
|
846
|
-
input: { input: 'data' },
|
|
847
|
-
history: [{ old: 'monke' }, { rescue: 'monke', sadge: 'monke' }],
|
|
848
|
-
mappers: [{ 'from.history': { index: 1, props: { happy: { prop: 'rescue' } } } }],
|
|
849
|
-
expected: { happy: 'monke' },
|
|
850
|
-
},
|
|
851
|
-
});
|
|
852
|
-
});
|
|
853
|
-
|
|
854
|
-
describe('assign.history', () => {
|
|
855
|
-
runTests({
|
|
856
|
-
'assign the second history item props defined in prop remappers to the output': {
|
|
857
|
-
input: { input: 'data' },
|
|
858
|
-
history: [{ old: 'monke' }, { rescue: 'monke', sadge: 'monke' }],
|
|
859
|
-
mappers: [{ 'assign.history': { index: 1, props: { happy: { prop: 'rescue' } } } }],
|
|
860
|
-
expected: { input: 'data', happy: 'monke' },
|
|
861
|
-
},
|
|
862
|
-
});
|
|
863
|
-
});
|
|
864
|
-
|
|
865
|
-
describe('omit.history', () => {
|
|
866
|
-
runTests({
|
|
867
|
-
'assign the second history item props to the output except omitted props': {
|
|
868
|
-
input: { input: 'data' },
|
|
869
|
-
history: [{ old: 'monke' }, { rescue: 'monke', sadge: 'monke' }],
|
|
870
|
-
mappers: [{ 'omit.history': { index: 1, keys: ['sadge'] } }],
|
|
871
|
-
expected: { input: 'data', rescue: 'monke' },
|
|
872
|
-
},
|
|
873
|
-
'not assign nested omitted props': {
|
|
874
|
-
input: { input: 'data' },
|
|
875
|
-
history: [{ rescue: 'monke', nested: { sadge: 'monke', safe: 'monke' } }],
|
|
876
|
-
mappers: [{ 'omit.history': { index: 0, keys: [['nested', 'sadge']] } }],
|
|
877
|
-
expected: { input: 'data', rescue: 'monke', nested: { safe: 'monke' } },
|
|
878
|
-
},
|
|
879
|
-
'handle non existing properties': {
|
|
880
|
-
input: { input: 'data' },
|
|
881
|
-
history: [{ rescue: 'monke', nested: { happy: 'monke', safe: 'monke' } }],
|
|
882
|
-
mappers: [{ 'omit.history': { index: 0, keys: [['nested', 'nonexistent']] } }],
|
|
883
|
-
expected: { input: 'data', rescue: 'monke', nested: { happy: 'monke', safe: 'monke' } },
|
|
884
|
-
},
|
|
885
|
-
});
|
|
886
|
-
});
|
|
887
|
-
|
|
888
|
-
describe('string.case', () => {
|
|
889
|
-
runTests({
|
|
890
|
-
'convert a string to upper case': {
|
|
891
|
-
input: 'I’m a Goofy Goober',
|
|
892
|
-
mappers: { 'string.case': 'upper' },
|
|
893
|
-
expected: 'I’M A GOOFY GOOBER',
|
|
894
|
-
},
|
|
895
|
-
'convert a string to lower case': {
|
|
896
|
-
input: 'We’re all Goofy Goobers',
|
|
897
|
-
mappers: { 'string.case': 'lower' },
|
|
898
|
-
expected: 'we’re all goofy goobers',
|
|
899
|
-
},
|
|
900
|
-
});
|
|
901
|
-
});
|
|
902
|
-
|
|
903
|
-
describe('string.format', () => {
|
|
904
|
-
runTests({
|
|
905
|
-
'format a template string': {
|
|
906
|
-
input: { name: 'Krusty Krab', food: 'krabby patties' },
|
|
907
|
-
mappers: {
|
|
908
|
-
'string.format': {
|
|
909
|
-
template: 'The {restaurant} serves {highlight}',
|
|
910
|
-
values: { restaurant: { prop: 'name' }, highlight: { prop: 'food' } },
|
|
911
|
-
},
|
|
912
|
-
},
|
|
913
|
-
|
|
914
|
-
expected: 'The Krusty Krab serves krabby patties',
|
|
915
|
-
},
|
|
916
|
-
'escape formatting double curly brackets': {
|
|
917
|
-
input: { food: 'krabby patty' },
|
|
918
|
-
mappers: {
|
|
919
|
-
'string.format': {
|
|
920
|
-
template: "A {burger} can be ressembled in ascii using: '{{I}}'",
|
|
921
|
-
values: { burger: { prop: 'food' } },
|
|
922
|
-
},
|
|
923
|
-
},
|
|
924
|
-
expected: 'A krabby patty can be ressembled in ascii using: {{I}}',
|
|
925
|
-
},
|
|
926
|
-
'format unknown values to empty strings': {
|
|
927
|
-
input: {},
|
|
928
|
-
mappers: { 'string.format': { template: '‘{value}’ is unknown', values: {} } },
|
|
929
|
-
expected:
|
|
930
|
-
'The intl string context variable "value" was not provided to the string "‘{value}’ is unknown"',
|
|
931
|
-
},
|
|
932
|
-
'format dates it parsed': {
|
|
933
|
-
input: { date: '1970-01-01T00:00:00.000Z' },
|
|
934
|
-
mappers: {
|
|
935
|
-
'string.format': {
|
|
936
|
-
template: 'Date’s year: {year, date, :: yyyy}',
|
|
937
|
-
values: { year: [{ prop: 'date' }, { 'date.parse': '' }] },
|
|
938
|
-
},
|
|
939
|
-
},
|
|
940
|
-
expected: 'Date’s year: 1970',
|
|
941
|
-
},
|
|
942
|
-
'format multilingual messages': {
|
|
943
|
-
input: null,
|
|
944
|
-
mappers: {
|
|
945
|
-
'string.format': {
|
|
946
|
-
messageId: 'patty',
|
|
947
|
-
values: { type: 'Krabby' },
|
|
948
|
-
},
|
|
949
|
-
},
|
|
950
|
-
expected: 'Krabby Patty',
|
|
951
|
-
messages: {
|
|
952
|
-
core: {},
|
|
953
|
-
app: {},
|
|
954
|
-
blocks: {},
|
|
955
|
-
messageIds: {
|
|
956
|
-
patty: '{type} Patty',
|
|
957
|
-
},
|
|
958
|
-
},
|
|
959
|
-
},
|
|
960
|
-
});
|
|
961
|
-
});
|
|
962
|
-
|
|
963
|
-
describe('static', () => {
|
|
964
|
-
runTests({
|
|
965
|
-
'return a static value': {
|
|
966
|
-
input: null,
|
|
967
|
-
mappers: { static: 'Hello world' },
|
|
968
|
-
expected: 'Hello world',
|
|
969
|
-
},
|
|
970
|
-
'return an object': {
|
|
971
|
-
input: null,
|
|
972
|
-
mappers: { static: { foo: { bar: 123 } } },
|
|
973
|
-
expected: { foo: { bar: 123 } },
|
|
974
|
-
},
|
|
975
|
-
'return an array': {
|
|
976
|
-
input: null,
|
|
977
|
-
mappers: { static: [{ foo: 123 }, 321, [1, 2, 3]] },
|
|
978
|
-
expected: [{ foo: 123 }, 321, [1, 2, 3]],
|
|
979
|
-
},
|
|
980
|
-
'apply regex replacements': {
|
|
981
|
-
input: null,
|
|
982
|
-
mappers: [{ static: '1234 AA' }, { 'string.replace': { '\\s+': '' } }],
|
|
983
|
-
expected: '1234AA',
|
|
984
|
-
},
|
|
985
|
-
});
|
|
986
|
-
});
|
|
987
|
-
|
|
988
|
-
describe('translate', () => {
|
|
989
|
-
runTests({
|
|
990
|
-
'format multilingual messages': {
|
|
991
|
-
input: null,
|
|
992
|
-
mappers: {
|
|
993
|
-
translate: 'patty',
|
|
994
|
-
},
|
|
995
|
-
expected: 'Patty',
|
|
996
|
-
messages: {
|
|
997
|
-
core: {},
|
|
998
|
-
app: {},
|
|
999
|
-
blocks: {},
|
|
1000
|
-
messageIds: {
|
|
1001
|
-
patty: 'Patty',
|
|
1002
|
-
},
|
|
1003
|
-
},
|
|
1004
|
-
},
|
|
1005
|
-
'handle untranslated multilingual messages': {
|
|
1006
|
-
input: null,
|
|
1007
|
-
mappers: {
|
|
1008
|
-
translate: 'patty',
|
|
1009
|
-
},
|
|
1010
|
-
expected: '{patty}',
|
|
1011
|
-
messages: {
|
|
1012
|
-
core: {},
|
|
1013
|
-
app: {},
|
|
1014
|
-
blocks: {},
|
|
1015
|
-
messageIds: {
|
|
1016
|
-
patty: '',
|
|
1017
|
-
},
|
|
1018
|
-
},
|
|
1019
|
-
},
|
|
1020
|
-
});
|
|
1021
|
-
});
|
|
1022
|
-
|
|
1023
|
-
describe('user', () => {
|
|
1024
|
-
runTests({
|
|
1025
|
-
'insert user info': {
|
|
1026
|
-
input: null,
|
|
1027
|
-
mappers: { user: 'name' },
|
|
1028
|
-
expected: 'Me',
|
|
1029
|
-
userInfo: {
|
|
1030
|
-
sub: '1',
|
|
1031
|
-
name: 'Me',
|
|
1032
|
-
email: 'me@example.com',
|
|
1033
|
-
email_verified: true,
|
|
1034
|
-
picture: '',
|
|
1035
|
-
profile: '',
|
|
1036
|
-
},
|
|
1037
|
-
},
|
|
1038
|
-
});
|
|
1039
|
-
});
|