README
store-name-analyser
JavaScript-based store name validator and availability checker.
Owner | @Shopify/launch-fed |
Help | #launch |
Installation
You can easily install this package with Yarn:
$ yarn add @shopify/store-name-analyser
Usage
Note: For a store to be created, its name need to satisfy some basic requirements. First, it has to conform with the character length constraints, then it also must not contain substrings of disallowed words in it. The BasicRequirementError
enum exposes these requirements as MinLength
, MaxLength
and Disallowed
.
This module exports a couple of utility functions.
validateStoreName
Accepts a store name, and returns a BasicRequirementError
which describes the nature of the error if any or true
if the store name passes all the basic requirements.
Set the optional isSubdomain
parameter to true
when validating a store subdomain in markets with non-latin languages (Japan, Korea, Thailand, China) to skip the max length check.
Parameters:
(storeName: string, isSubdomain = false)
Return value:
BasicRequirementError | true
basicRequirementsPass
Accepts a validation result from validateStoreName
, and determines if the result indicates that the store name in question successfully meets the basic requirements.
Parameters:
(result: true | BasicRequirementError)
Return value:
true | false
checkStoreNameAvailability
Accepts a mandatory store name value and runs that through the store name availability endpoint in core to determine if a store name has already been chosen.
It can also accept an email and a timeout, which by default is set to one minute because the availability of a store name is not critical enough to block store creation as core has a strategy in place to append incrementing numbers from 1
to store names that already exist.
Parameters:
(storeName: string, email = '', timeout = ONE_MINUTE)
Return value:
StoreAvailabilityResponse
interface StoreAvailabilityResponse {
host?: string;
message?: string;
status: StoreAvailabilityStatus;
}
Development Guide
This project is written in TypeScript, and uses Rollup to generate an optimized JavaScript bundle. The structure and standards should be pretty obvious, but if you're going to be adding a new feature, please write tests for that. The following are the available dev
commands.
dev up
generates a bundle and declaration files from the TS sourcedev [server|watch]
does the same asdev up
, but listens for changes in the source files and re-bundlesdev test
runs Jest in watch mode
✨