diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 68635e04dd..fce55c76c0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,10 +15,12 @@ on: - 'release/*' - 'CBG*' - 'ci-*' + - 'feature*' pull_request: branches: - 'master' - 'release/*' + - 'feature*' jobs: build: @@ -40,7 +42,7 @@ jobs: go-version: 1.20.3 - run: go install github.com/google/addlicense@latest - uses: actions/checkout@v3 - - run: addlicense -check -f licenses/addlicense.tmpl . + - run: addlicense -check -f licenses/addlicense.tmpl -ignore 'js/underscore*.js' . golangci: name: lint @@ -86,6 +88,39 @@ jobs: uses: guyarb/golang-test-annotations@v0.6.0 with: test-results: test.json + test-v8: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: macos-latest + name: macos + # v8 windows does not work yet CBG-2741 + #- os: windows-latest + #name: windows + - os: ubuntu-latest + name: ubuntu + env: + GOPRIVATE: github.com/couchbaselabs + MallocNanoZone: 0 + name: test v8 (${{ matrix.name }}) + steps: + - uses: actions/setup-go@v3 + with: + go-version: 1.20.3 + - uses: actions/checkout@v3 + - name: Build + run: go build -tags cb_sg_v8 -v "./..." + - name: Run Tests + run: go test -tags cb_sg_v8 -timeout=30m -count=1 -json -v "./..." | tee test.json | jq -s -jr 'sort_by(.Package,.Time) | .[].Output | select (. != null )' + shell: bash + - name: Annotate Failures + if: always() + uses: guyarb/golang-test-annotations@v0.6.0 + with: + test-results: test.json + test-race: runs-on: ubuntu-latest diff --git a/Jenkinsfile b/Jenkinsfile index bd35acbd8c..72826f4692 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -9,6 +9,7 @@ pipeline { BRANCH = "${BRANCH_NAME}" COVERALLS_TOKEN = credentials('SG_COVERALLS_TOKEN') EE_BUILD_TAG = "cb_sg_enterprise" + V8_BUILD_TAG = "cb_sg_v8" SGW_REPO = "github.com/couchbase/sync_gateway" GH_ACCESS_TOKEN_CREDENTIAL = "github_cb-robot-sg_access_token" GO111MODULE = "on" @@ -80,11 +81,21 @@ pipeline { sh "GOOS=linux go build -o sync_gateway_ce-linux -v ${SGW_REPO}" } } + stage('CE Linux V8') { + steps { + sh "GOOS=linux go build -tags ${V8_BUILD_TAG} -o sync_gateway_ce-linux -v ${SGW_REPO}" + } + } stage('EE Linux') { steps { sh "GOOS=linux go build -o sync_gateway_ee-linux -tags ${EE_BUILD_TAG} -v ${SGW_REPO}" } } + stage('EE Linux V8') { + steps { + sh "GOOS=linux go build -o sync_gateway_ee-linux -tags ${EE_BUILD_TAG},${V8_BUILD_TAG} -v ${SGW_REPO}" + } + } stage('CE macOS') { // TODO: Remove skip when { expression { return false } } @@ -291,6 +302,51 @@ pipeline { } } } + stage('EE V8') { + steps { + withEnv(["PATH+GO=${env.GOTOOLS}/bin"]) { + githubNotify(credentialsId: "${GH_ACCESS_TOKEN_CREDENTIAL}", context: 'sgw-pipeline-ee-v8-unit-tests', description: 'EE V8 Unit Tests Running', status: 'PENDING') + + // Build EE coverprofiles + sh "2>&1 go test -timeout=20m -tags ${EE_BUILD_TAG},${V8_BUILD_TAG} -coverpkg=./... -coverprofile=cover_ee_v8.out -race -count=1 -v ./... > verbose_ee_v8.out.raw || true" + + sh 'go tool cover -func=cover_ee_v8.out | awk \'END{print "Total SG EE V8 Coverage: " $3}\'' + + sh 'mkdir -p reports' + + // strip non-printable characters from the raw verbose test output + sh 'LC_CTYPE=C tr -dc [:print:][:space:] < verbose_ee_v8.out.raw > verbose_ee_v8.out' + + // Generate Cobertura XML report that can be parsed by the Jenkins Cobertura Plugin + sh 'gocov convert cover_ee_v8.out | gocov-xml > reports/coverage-ee_v8.xml' + + // Grab test fail/total counts so we can print them later + sh "grep '\\-\\-\\- PASS: ' verbose_ee_v8.out | wc -l | awk '{printf \$1}' > test-ee-v8-pass.count" + sh "grep '\\-\\-\\- FAIL: ' verbose_ee_v8.out | wc -l | awk '{printf \$1}' > test-ee-v8-fail.count" + sh "grep '\\-\\-\\- SKIP: ' verbose_ee_v8.out | wc -l | awk '{printf \$1}' > test-ee-v8-skip.count" + sh "grep '=== RUN' verbose_ee_v8.out | wc -l | awk '{printf \$1}' > test-ee-v8-total.count" + script { + env.TEST_EE_PASS = readFile 'test-ee-v8-pass.count' + env.TEST_EE_FAIL = readFile 'test-ee-v8-fail.count' + env.TEST_EE_SKIP = readFile 'test-ee-v8-skip.count' + env.TEST_EE_TOTAL = readFile 'test-ee-v8-total.count' + } + + // Generate junit-formatted test report + script { + try { + sh 'go2xunit -fail -suite-name-prefix="EE-V8-" -input verbose_ee_v8.out -output reports/test-ee-v8.xml' + githubNotify(credentialsId: "${GH_ACCESS_TOKEN_CREDENTIAL}", context: 'sgw-pipeline-ee-v8-unit-tests', description: env.TEST_EE_V8_PASS+'/'+env.TEST_EE_V8_TOTAL+' passed ('+env.TEST_EE_V8_SKIP+' skipped)', status: 'SUCCESS') + } catch (Exception e) { + githubNotify(credentialsId: "${GH_ACCESS_TOKEN_CREDENTIAL}", context: 'sgw-pipeline-ee-unit-tests', description: env.TEST_EE_V8_FAIL+'/'+env.TEST_EE_V8_TOTAL+' failed ('+env.TEST_EE_V8_SKIP+' skipped)', status: 'FAILURE') + // archive verbose test logs in the event of a test failure + archiveArtifacts artifacts: 'verbose_ee_v8.out', fingerprint: false + unstable("At least one EE V8 unit test failed") + } + } + } + } + } } } diff --git a/auth/auth.go b/auth/auth.go index 2572a2ddfa..118d9fbc1f 100644 --- a/auth/auth.go +++ b/auth/auth.go @@ -32,11 +32,12 @@ type Authenticator struct { } type AuthenticatorOptions struct { - ClientPartitionWindow time.Duration - ChannelsWarningThreshold *uint32 - SessionCookieName string - BcryptCost int - LogCtx context.Context + ClientPartitionWindow time.Duration + ChannelsWarningThreshold *uint32 + ServerlessChannelThreshold uint32 + SessionCookieName string + BcryptCost int + LogCtx context.Context // Collections defines the set of collections used by the authenticator when rebuilding channels. // Channels are only recomputed for collections included in this set. @@ -196,6 +197,17 @@ func (auth *Authenticator) getPrincipal(docID string, factory func() Principal) } changed = true } + // If the channel threshold has been set we need to check the inherited channels across all scopes and collections against the limit + if auth.ServerlessChannelThreshold != 0 { + channelsLength, err := auth.getInheritedChannelsLength(user) + if err != nil { + return nil, nil, false, err + } + err = auth.checkChannelLimits(channelsLength, user) + if err != nil { + return nil, nil, false, err + } + } } if changed { @@ -223,6 +235,73 @@ func (auth *Authenticator) getPrincipal(docID string, factory func() Principal) return princ, nil } +// inheritedCollectionChannels returns channels for a given scope + collection +func (auth *Authenticator) inheritedCollectionChannels(user User, scope, collection string) (ch.TimedSet, error) { + roles, err := auth.getUserRoles(user) + if err != nil { + return nil, err + } + + channels := user.CollectionChannels(scope, collection) + for _, role := range roles { + roleSince := user.RoleNames()[role.Name()] + channels.AddAtSequence(role.CollectionChannels(scope, collection), roleSince.Sequence) + } + return channels, nil +} + +// getInheritedChannelsLength returns number of channels a user has access to across all collections +func (auth *Authenticator) getInheritedChannelsLength(user User) (int, error) { + var cumulativeChannels int + for scope, collections := range auth.Collections { + for collection := range collections { + channels, err := auth.inheritedCollectionChannels(user, scope, collection) + if err != nil { + return 0, err + } + cumulativeChannels += len(channels) + } + } + return cumulativeChannels, nil +} + +// checkChannelLimits logs a warning when the warning threshold is met and will return an error when the channel limit is met +func (auth *Authenticator) checkChannelLimits(channels int, user User) error { + // Error if ServerlessChannelThreshold is set and is >= than the threshold + if uint32(channels) >= auth.ServerlessChannelThreshold { + base.ErrorfCtx(auth.LogCtx, "User ID: %v channel count: %d exceeds %d for channels per user threshold. Auth will be rejected until rectified", + base.UD(user.Name()), channels, auth.ServerlessChannelThreshold) + return base.ErrMaximumChannelsForUserExceeded + } + + // This function is likely to be called once per session when a channel limit is applied, the sync once + // applied here ensures we don't fill logs with warnings about being over warning threshold. We may want + // to revisit this implementation around the warning threshold in future + user.GetWarnChanSync().Do(func() { + if channelsPerUserThreshold := auth.ChannelsWarningThreshold; channelsPerUserThreshold != nil { + if uint32(channels) >= *channelsPerUserThreshold { + base.WarnfCtx(auth.LogCtx, "User ID: %v channel count: %d exceeds %d for channels per user warning threshold", + base.UD(user.Name()), channels, *channelsPerUserThreshold) + } + } + }) + return nil +} + +// getUserRoles gets all roles a user has been granted +func (auth *Authenticator) getUserRoles(user User) ([]Role, error) { + roles := make([]Role, 0, len(user.RoleNames())) + for name := range user.RoleNames() { + role, err := auth.GetRole(name) + if err != nil { + return nil, err + } else if role != nil { + roles = append(roles, role) + } + } + return roles, nil +} + // Rebuild channels computes the full set of channels for all collections defined for the authenticator. // For each collection in Authenticator.collections: // - if there is no CollectionAccess on the principal for the collection, rebuilds channels for that collection @@ -230,6 +309,7 @@ func (auth *Authenticator) getPrincipal(docID string, factory func() Principal) func (auth *Authenticator) rebuildChannels(princ Principal) (changed bool, err error) { changed = false + for scope, collections := range auth.Collections { for collection, _ := range collections { // If collection channels are nil, they have been invalidated and must be rebuilt @@ -242,6 +322,7 @@ func (auth *Authenticator) rebuildChannels(princ Principal) (changed bool, err e } } } + return changed, nil } diff --git a/auth/auth_test.go b/auth/auth_test.go index d6d7079372..f1378b763d 100644 --- a/auth/auth_test.go +++ b/auth/auth_test.go @@ -2752,6 +2752,117 @@ func TestObtainChannelsForDeletedRole(t *testing.T) { } } +func TestServerlessChannelLimitsRoles(t *testing.T) { + testCases := []struct { + Name string + Collection bool + }{ + { + Name: "Single role", + }, + { + Name: "Muliple roles", + }, + } + for _, testCase := range testCases { + t.Run(testCase.Name, func(t *testing.T) { + testBucket := base.GetTestBucket(t) + defer testBucket.Close() + dataStore := testBucket.GetSingleDataStore() + var role2 Role + + opts := DefaultAuthenticatorOptions() + opts.ServerlessChannelThreshold = 5 + opts.Collections = map[string]map[string]struct{}{ + "scope1": {"collection1": struct{}{}, "collection2": struct{}{}}, + } + auth := NewAuthenticator(dataStore, nil, opts) + user1, err := auth.NewUser("user1", "pass", ch.BaseSetOf(t, "ABC")) + require.NoError(t, err) + err = auth.Save(user1) + require.NoError(t, err) + _, err = auth.AuthenticateUser("user1", "pass") + require.NoError(t, err) + + role1, err := auth.NewRole("role1", nil) + require.NoError(t, err) + if testCase.Name == "Single role" { + user1.SetExplicitRoles(ch.TimedSet{"role1": ch.NewVbSimpleSequence(1)}, 1) + require.NoError(t, auth.Save(user1)) + _, err = auth.AuthenticateUser("user1", "pass") + require.NoError(t, err) + + role1.SetCollectionExplicitChannels("scope1", "collection1", ch.AtSequence(ch.BaseSetOf(t, "ABC", "DEF", "GHI", "JKL"), 1), 1) + require.NoError(t, auth.Save(role1)) + } else { + role2, err = auth.NewRole("role2", nil) + require.NoError(t, err) + user1.SetExplicitRoles(ch.TimedSet{"role1": ch.NewVbSimpleSequence(1), "role2": ch.NewVbSimpleSequence(1)}, 1) + require.NoError(t, auth.Save(user1)) + role1.SetCollectionExplicitChannels("scope1", "collection1", ch.AtSequence(ch.BaseSetOf(t, "ABC", "DEF", "GHI", "JKL"), 1), 1) + role2.SetCollectionExplicitChannels("scope1", "collection2", ch.AtSequence(ch.BaseSetOf(t, "MNO", "PQR"), 1), 1) + require.NoError(t, auth.Save(role1)) + require.NoError(t, auth.Save(role2)) + } + _, err = auth.AuthenticateUser("user1", "pass") + require.Error(t, err) + }) + } +} + +func TestServerlessChannelLimits(t *testing.T) { + + testCases := []struct { + Name string + Collection bool + }{ + { + Name: "Collection not enabled", + Collection: false, + }, + { + Name: "Collection is enabled", + Collection: true, + }, + } + for _, testCase := range testCases { + t.Run(testCase.Name, func(t *testing.T) { + testBucket := base.GetTestBucket(t) + defer testBucket.Close() + dataStore := testBucket.GetSingleDataStore() + + opts := DefaultAuthenticatorOptions() + opts.ServerlessChannelThreshold = 5 + if testCase.Collection { + opts.Collections = map[string]map[string]struct{}{ + "scope1": {"collection1": struct{}{}, "collection2": struct{}{}}, + } + } + auth := NewAuthenticator(dataStore, nil, opts) + user1, err := auth.NewUser("user1", "pass", ch.BaseSetOf(t, "ABC")) + require.NoError(t, err) + err = auth.Save(user1) + require.NoError(t, err) + _, err = auth.AuthenticateUser("user1", "pass") + require.NoError(t, err) + + if !testCase.Collection { + user1.SetCollectionExplicitChannels("_default", "_default", ch.AtSequence(ch.BaseSetOf(t, "ABC", "DEF", "GHI", "JKL", "MNO", "PQR"), 1), 1) + err = auth.Save(user1) + require.NoError(t, err) + } else { + user1.SetCollectionExplicitChannels("scope1", "collection1", ch.AtSequence(ch.BaseSetOf(t, "ABC", "DEF", "GHI", "JKL"), 1), 1) + user1.SetCollectionExplicitChannels("scope1", "collection2", ch.AtSequence(ch.BaseSetOf(t, "MNO", "PQR"), 1), 1) + err = auth.Save(user1) + require.NoError(t, err) + } + _, err = auth.AuthenticateUser("user1", "pass") + require.Error(t, err) + assert.Contains(t, err.Error(), base.ErrMaximumChannelsForUserExceeded.Error()) + }) + } +} + func TestInvalidateRoles(t *testing.T) { testBucket := base.GetTestBucket(t) defer testBucket.Close() diff --git a/auth/principal.go b/auth/principal.go index 0f9d83ef7d..39c439c749 100644 --- a/auth/principal.go +++ b/auth/principal.go @@ -9,6 +9,7 @@ package auth import ( + "sync" "time" "github.com/couchbase/sync_gateway/base" @@ -125,6 +126,8 @@ type User interface { InitializeRoles() + GetWarnChanSync() *sync.Once + revokedChannels(since uint64, lowSeq uint64, triggeredBy uint64) RevokedChannels // Obtains the period over which the user had access to the given channel. Either directly or via a role. diff --git a/auth/user.go b/auth/user.go index 34582e76d3..54a2ca9090 100644 --- a/auth/user.go +++ b/auth/user.go @@ -183,6 +183,10 @@ func (user *userImpl) SetEmail(email string) error { return nil } +func (user *userImpl) GetWarnChanSync() *sync.Once { + return &user.warnChanThresholdOnce +} + func (user *userImpl) RoleNames() ch.TimedSet { if user.RoleInvalSeq != 0 { return nil diff --git a/base/bootstrap.go b/base/bootstrap.go index ed7126e868..33ea8e3749 100644 --- a/base/bootstrap.go +++ b/base/bootstrap.go @@ -53,11 +53,11 @@ type CouchbaseCluster struct { clusterOptions gocb.ClusterOptions forcePerBucketAuth bool // Forces perBucketAuth authenticators to be used to connect to the bucket perBucketAuth map[string]*gocb.Authenticator - bucketConnectionMode BucketConnectionMode // Whether to cache cluster connections - cachedClusterConnection *gocb.Cluster // Cached cluster connection, should only be used by GetConfigBuckets - cachedBucketConnections map[string]*cachedBucket // Per-bucket cached connections - cachedConnectionLock sync.Mutex // mutex for access to cachedBucketConnections - configPersistence ConfigPersistence // ConfigPersistence mode + bucketConnectionMode BucketConnectionMode // Whether to cache cluster connections + cachedClusterConnection *gocb.Cluster // Cached cluster connection, should only be used by GetConfigBuckets + cachedBucketConnections cachedBucketConnections // Per-bucket cached connections + cachedConnectionLock sync.Mutex // mutex for access to cachedBucketConnections + configPersistence ConfigPersistence // ConfigPersistence mode } type BucketConnectionMode int @@ -70,13 +70,73 @@ const ( ) type cachedBucket struct { - bucket *gocb.Bucket - teardownFn func() + bucket *gocb.Bucket // underlying bucket + bucketCloseFn func() // teardown function which will close the gocb connection + refcount int // count of how many functions are using this cachedBucket + shouldClose bool // mark this cachedBucket as needing to be closed with ref } -// noopTeardown is returned by getBucket when using a cached bucket - these buckets are torn down -// when CouchbaseCluster.Close is called. -func noopTeardown() {} +// cahedBucketConnections is a lockable map cached buckets containing refcounts +type cachedBucketConnections struct { + buckets map[string]*cachedBucket + lock sync.Mutex +} + +// removeOutdatedBuckets marks any active buckets for closure and removes the cached connections. +func (c *cachedBucketConnections) removeOutdatedBuckets(activeBuckets Set) { + c.lock.Lock() + defer c.lock.Unlock() + for bucketName, bucket := range c.buckets { + _, exists := activeBuckets[bucketName] + if exists { + continue + } + bucket.shouldClose = true + c._teardown(bucketName) + } +} + +// closeAll removes all cached bucekts +func (c *cachedBucketConnections) closeAll() { + c.lock.Lock() + defer c.lock.Unlock() + for _, bucket := range c.buckets { + bucket.shouldClose = true + bucket.bucketCloseFn() + } +} + +// teardown closes the cached bucket connection while locked, suitable for CouchbaseCluster.getBucket() teardowns +func (c *cachedBucketConnections) teardown(bucketName string) { + c.lock.Lock() + defer c.lock.Unlock() + c.buckets[bucketName].refcount-- + c._teardown(bucketName) +} + +// _teardown closes expects the lock to be acquired before calling this function and the reference count to be up to date. +func (c *cachedBucketConnections) _teardown(bucketName string) { + if !c.buckets[bucketName].shouldClose || c.buckets[bucketName].refcount > 0 { + return + } + c.buckets[bucketName].bucketCloseFn() + delete(c.buckets, bucketName) +} + +// get returns a cachedBucket for a given bucketName, or nil if it doesn't exist +func (c *cachedBucketConnections) _get(bucketName string) *cachedBucket { + bucket, ok := c.buckets[bucketName] + if !ok { + return nil + } + c.buckets[bucketName].refcount++ + return bucket +} + +// set adds a cachedBucket for a given bucketName, or nil if it doesn't exist +func (c *cachedBucketConnections) _set(bucketName string, bucket *cachedBucket) { + c.buckets[bucketName] = bucket +} var _ BootstrapConnection = &CouchbaseCluster{} @@ -128,7 +188,7 @@ func NewCouchbaseCluster(server, username, password, } if bucketMode == CachedClusterConnections { - cbCluster.cachedBucketConnections = make(map[string]*cachedBucket) + cbCluster.cachedBucketConnections = cachedBucketConnections{buckets: make(map[string]*cachedBucket)} } cbCluster.configPersistence = &DocumentBootstrapPersistence{} @@ -243,6 +303,8 @@ func (cc *CouchbaseCluster) GetConfigBuckets() ([]string, error) { bucketList = append(bucketList, bucketName) } + cc.cachedBucketConnections.removeOutdatedBuckets(SetOf(bucketList...)) + return bucketList, nil } @@ -399,13 +461,11 @@ func (cc *CouchbaseCluster) KeyExists(location, docID string) (exists bool, err // Close calls teardown for any cached buckets and removes from cachedBucketConnections func (cc *CouchbaseCluster) Close() { + cc.cachedBucketConnections.closeAll() + cc.cachedConnectionLock.Lock() defer cc.cachedConnectionLock.Unlock() - for bucketName, cachedBucket := range cc.cachedBucketConnections { - cachedBucket.teardownFn() - delete(cc.cachedBucketConnections, bucketName) - } if cc.cachedClusterConnection != nil { _ = cc.cachedClusterConnection.Close(nil) cc.cachedClusterConnection = nil @@ -418,36 +478,28 @@ func (cc *CouchbaseCluster) getBucket(bucketName string) (b *gocb.Bucket, teardo return cc.connectToBucket(bucketName) } - cc.cachedConnectionLock.Lock() - defer cc.cachedConnectionLock.Unlock() - - cacheBucket, ok := cc.cachedBucketConnections[bucketName] - if ok { - return cacheBucket.bucket, noopTeardown, nil + teardownFn = func() { + cc.cachedBucketConnections.teardown(bucketName) + } + cc.cachedBucketConnections.lock.Lock() + defer cc.cachedBucketConnections.lock.Unlock() + bucket := cc.cachedBucketConnections._get(bucketName) + if bucket != nil { + return bucket.bucket, teardownFn, nil } // cached bucket not found, connect and add - newBucket, newTeardownFn, err := cc.connectToBucket(bucketName) + newBucket, bucketCloseFn, err := cc.connectToBucket(bucketName) if err != nil { return nil, nil, err } - cc.cachedBucketConnections[bucketName] = &cachedBucket{ - bucket: newBucket, - teardownFn: newTeardownFn, - } - return newBucket, noopTeardown, nil -} - -// For unrecoverable errors when using cached buckets, remove the bucket from the cache to trigger a new connection on next usage -func (cc *CouchbaseCluster) onCachedBucketError(bucketName string) { + cc.cachedBucketConnections._set(bucketName, &cachedBucket{ + bucket: newBucket, + bucketCloseFn: bucketCloseFn, + refcount: 1, + }) - cc.cachedConnectionLock.Lock() - defer cc.cachedConnectionLock.Unlock() - cacheBucket, ok := cc.cachedBucketConnections[bucketName] - if ok { - cacheBucket.teardownFn() - delete(cc.cachedBucketConnections, bucketName) - } + return newBucket, teardownFn, nil } // connectToBucket establishes a new connection to a bucket, and returns the bucket after waiting for it to be ready. diff --git a/base/bootstrap_test.go b/base/bootstrap_test.go index 4c29b1ddb3..c5512e6609 100644 --- a/base/bootstrap_test.go +++ b/base/bootstrap_test.go @@ -9,6 +9,7 @@ package base import ( + "sync" "testing" "github.com/imdario/mergo" @@ -33,3 +34,84 @@ func TestMergeStructPointer(t *testing.T) { assert.Equal(t, "changed", source.Ptr.S) assert.Equal(t, IntPtr(5), source.Ptr.I) } + +func TestBootstrapRefCounting(t *testing.T) { + if UnitTestUrlIsWalrus() { + t.Skip("Test requires making a connection to CBS") + } + // Integration tests are configured to run in these parameters, they are used in main_test_bucket_pool.go + // Future enhancement would be to allow all integration tests to run with TLS + x509CertPath := "" + x509KeyPath := "" + caCertPath := "" + forcePerBucketAuth := false + tlsSkipVerify := BoolPtr(false) + var perBucketCredentialsConfig map[string]*CredentialsConfig + + cluster, err := NewCouchbaseCluster(UnitTestUrl(), TestClusterUsername(), TestClusterPassword(), x509CertPath, x509KeyPath, caCertPath, forcePerBucketAuth, perBucketCredentialsConfig, tlsSkipVerify, BoolPtr(TestUseXattrs()), CachedClusterConnections) + require.NoError(t, err) + defer cluster.Close() + require.NotNil(t, cluster) + + clusterConnection, err := cluster.getClusterConnection() + require.NoError(t, err) + require.NotNil(t, clusterConnection) + + buckets, err := cluster.GetConfigBuckets() + require.NoError(t, err) + require.Len(t, buckets, tbpNumBuckets()) + // GetConfigBuckets doesn't cache connections, it uses cluster connection to determine number of buckets + require.Len(t, cluster.cachedBucketConnections.buckets, 0) + + primeBucketConnectionCache := func(bucketNames []string) { + // Bucket CRUD ops do cache connections + for _, bucketName := range bucketNames { + exists, err := cluster.KeyExists(bucketName, "keyThatDoesNotExist") + require.NoError(t, err) + require.False(t, exists) + } + } + + primeBucketConnectionCache(buckets) + require.Len(t, cluster.cachedBucketConnections.buckets, tbpNumBuckets()) + + // call removeOutdatedBuckets as no-op + cluster.cachedBucketConnections.removeOutdatedBuckets(SetOf(buckets...)) + require.Len(t, cluster.cachedBucketConnections.buckets, tbpNumBuckets()) + + // call removeOutdatedBuckets to remove all cached buckets, call multiple times to make sure idempotent + for i := 0; i < 3; i++ { + cluster.cachedBucketConnections.removeOutdatedBuckets(Set{}) + require.Len(t, cluster.cachedBucketConnections.buckets, 0) + } + + primeBucketConnectionCache(buckets) + require.Len(t, cluster.cachedBucketConnections.buckets, tbpNumBuckets()) + + // make sure that you can still use an active connection while the bucket has been removed + wg := sync.WaitGroup{} + wg.Add(1) + makeConnection := make(chan struct{}) + go func() { + defer wg.Done() + b, teardown, err := cluster.getBucket(buckets[0]) + defer teardown() + require.NoError(t, err) + require.NotNil(t, b) + <-makeConnection + // make sure that we can still use bucket after it is no longer cached + exists, err := cluster.configPersistence.keyExists(b.DefaultCollection(), "keyThatDoesNotExist") + require.NoError(t, err) + require.False(t, exists) + }() + + cluster.cachedBucketConnections.removeOutdatedBuckets(Set{}) + require.Len(t, cluster.cachedBucketConnections.buckets, 0) + makeConnection <- struct{}{} + + wg.Wait() + + // make sure you can "remove" a non existent bucket in the case that bucket removal is called multiple times + cluster.cachedBucketConnections.removeOutdatedBuckets(SetOf("not-a-bucket")) + +} diff --git a/base/bucket_gocb_test.go b/base/bucket_gocb_test.go index 9d56239766..8490ec0204 100644 --- a/base/bucket_gocb_test.go +++ b/base/bucket_gocb_test.go @@ -362,22 +362,35 @@ func TestIncrCounter(t *testing.T) { } }() - // New Counter - incr 1, default 1 - value, err := dataStore.Incr(key, 1, 1, 0) - assert.NoError(t, err, "Error incrementing non-existent counter") - - // key did not exist - so expect the "initial" value of 1 - assert.Equal(t, uint64(1), value) + // New Counter - incr 0, default 0 - expect zero-value counter doc to be created + value, err := dataStore.Incr(key, 0, 0, 0) + require.NoError(t, err, "Error incrementing non-existent counter") + require.Equal(t, uint64(0), value) // Retrieve existing counter value using GetCounter retrieval, err := GetCounter(dataStore, key) - assert.NoError(t, err, "Error retrieving value for existing counter") - assert.Equal(t, uint64(1), retrieval) + require.NoError(t, err, "Error retrieving value for existing counter") + require.Equal(t, uint64(0), retrieval) + + // remove zero value so we're able to test default below + require.NoError(t, dataStore.Delete(key)) + + // New Counter - incr 1, default 5 + value, err = dataStore.Incr(key, 1, 5, 0) + require.NoError(t, err, "Error incrementing non-existent counter") + + // key did not exist - so expect the "initial" value of 5 + require.Equal(t, uint64(5), value) + + // Retrieve existing counter value using GetCounter + retrieval, err = GetCounter(dataStore, key) + require.NoError(t, err, "Error retrieving value for existing counter") + require.Equal(t, uint64(5), retrieval) // Increment existing counter - retrieval, err = dataStore.Incr(key, 1, 1, 0) - assert.NoError(t, err, "Error incrementing value for existing counter") - assert.Equal(t, uint64(2), retrieval) + retrieval, err = dataStore.Incr(key, 1, 5, 0) + require.NoError(t, err, "Error incrementing value for existing counter") + require.Equal(t, uint64(6), retrieval) } func TestGetAndTouchRaw(t *testing.T) { diff --git a/base/collection_gocb.go b/base/collection_gocb.go index 0a14c809fe..5be7e21d0a 100644 --- a/base/collection_gocb.go +++ b/base/collection_gocb.go @@ -356,9 +356,6 @@ func (c *Collection) Update(k string, exp uint32, callback sgbucket.UpdateFunc) func (c *Collection) Incr(k string, amt, def uint64, exp uint32) (uint64, error) { c.Bucket.waitForAvailKvOp() defer c.Bucket.releaseKvOp() - if amt == 0 { - return 0, errors.New("amt passed to Incr must be non-zero") - } incrOptions := gocb.IncrementOptions{ Initial: int64(def), Delta: amt, diff --git a/base/constants.go b/base/constants.go index e5169a0aa8..ca804d9533 100644 --- a/base/constants.go +++ b/base/constants.go @@ -151,6 +151,12 @@ const ( // DefaultJavascriptTimeoutSecs is number of seconds before Javascript functions (i.e. the sync function or import filter) timeout // If set to zero, timeout is disabled. DefaultJavascriptTimeoutSecs = uint32(0) + + // ServerlessChannelLimit is hard limit on channels allowed per user when running in serverless mode + ServerlessChannelLimit = 500 + + // FromConnStrWarningThreshold determines the amount of time it should take before we warn about parsing a connstr (mostly for DNS resolution) + FromConnStrWarningThreshold = 10 * time.Second ) const ( diff --git a/base/dcp_client.go b/base/dcp_client.go index 46547ec52b..d57cf465c7 100644 --- a/base/dcp_client.go +++ b/base/dcp_client.go @@ -26,7 +26,7 @@ import ( const openStreamTimeout = 30 * time.Second const openRetryCount = uint32(10) -const defaultNumWorkers = 8 +const DefaultNumWorkers = 8 // DCP buffer size if we are running in serverless const DefaultDCPBufferServerless = 1 * 1024 * 1024 @@ -37,7 +37,7 @@ const infiniteOpenStreamRetries = uint32(math.MaxUint32) type endStreamCallbackFunc func(e endStreamEvent) -var errVbUUIDMismatch = errors.New("VbUUID mismatch when failOnRollback set") +var ErrVbUUIDMismatch = errors.New("VbUUID mismatch when failOnRollback set") type DCPClient struct { ID string // unique ID for DCPClient - used for DCP stream name, must be unique @@ -81,7 +81,7 @@ type DCPClientOptions struct { func NewDCPClient(ID string, callback sgbucket.FeedEventCallbackFunc, options DCPClientOptions, bucket *GocbV2Bucket) (*DCPClient, error) { - numWorkers := defaultNumWorkers + numWorkers := DefaultNumWorkers if options.NumWorkers > 0 { numWorkers = options.NumWorkers } @@ -320,10 +320,17 @@ func (dc *DCPClient) initAgent(spec BucketSpec) error { } agentConfig := gocbcore.DCPAgentConfig{} + DebugfCtx(context.TODO(), KeyAll, "Parsing cluster connection string %q", UD(connStr)) + beforeFromConnStr := time.Now() connStrError := agentConfig.FromConnStr(connStr) if connStrError != nil { return fmt.Errorf("Unable to start DCP Client - error building conn str: %v", connStrError) } + if d := time.Since(beforeFromConnStr); d > FromConnStrWarningThreshold { + WarnfCtx(context.TODO(), "Parsed cluster connection string %q in: %v", UD(connStr), d) + } else { + DebugfCtx(context.TODO(), KeyAll, "Parsed cluster connection string %q in: %v", UD(connStr), d) + } auth, authErr := spec.GocbcoreAuthProvider() if authErr != nil { @@ -440,7 +447,7 @@ func (dc *DCPClient) openStream(vbID uint16, maxRetries uint32) error { case errors.As(openStreamErr, &rollbackErr): if dc.failOnRollback { InfofCtx(logCtx, KeyDCP, "Open stream for vbID %d failed due to rollback or range error, closing client based on failOnRollback=true", vbID) - return fmt.Errorf("%s, failOnRollback requested", openStreamErr) + return fmt.Errorf("%w, failOnRollback requested", openStreamErr) } InfofCtx(logCtx, KeyDCP, "Open stream for vbID %d failed due to rollback or range error, will roll back metadata and retry: %v", vbID, openStreamErr) @@ -449,7 +456,7 @@ func (dc *DCPClient) openStream(vbID uint16, maxRetries uint32) error { err := fmt.Errorf("Invalid metadata out of range for vbID %d, err: %v metadata %+v, shutting down agent", vbID, openStreamErr, dc.metadata.GetMeta(vbID)) WarnfCtx(logCtx, "%s", err) return err - case errors.Is(openStreamErr, errVbUUIDMismatch): + case errors.Is(openStreamErr, ErrVbUUIDMismatch): WarnfCtx(logCtx, "Closing Stream for vbID: %d, %s", vbID, openStreamErr) return openStreamErr case errors.Is(openStreamErr, gocbcore.ErrShutdown): @@ -549,7 +556,7 @@ func (dc *DCPClient) verifyFailoverLog(vbID uint16, f []gocbcore.FailoverEntry) currentVbUUID := getLatestVbUUID(f) // if previousVbUUID hasn't been set yet (is zero), don't treat as rollback. if previousMeta.VbUUID != currentVbUUID { - return errVbUUIDMismatch + return ErrVbUUIDMismatch } } return nil @@ -650,3 +657,7 @@ func getLatestVbUUID(failoverLog []gocbcore.FailoverEntry) (vbUUID gocbcore.VbUU entry := failoverLog[len(failoverLog)-1] return entry.VbUUID } + +func (dc *DCPClient) GetMetadataKeyPrefix() string { + return dc.metadata.GetKeyPrefix() +} diff --git a/base/dcp_client_metadata.go b/base/dcp_client_metadata.go index 4137421ba1..8a5542bac6 100644 --- a/base/dcp_client_metadata.go +++ b/base/dcp_client_metadata.go @@ -62,6 +62,9 @@ type DCPMetadataStore interface { // Purge removes all metadata associated with the metadata store from the bucket. It does not remove the // in-memory metadata. Purge(numWorkers int) + + // GetKeyPrefix will retrieve the key prefix used for metadata persistence + GetKeyPrefix() string } type dcpMetadataBase struct { @@ -155,6 +158,10 @@ func (md *DCPMetadataMem) Purge(numWorkers int) { return } +func (md *DCPMetadataMem) GetKeyPrefix() string { + return "" +} + // Reset sets metadata sequences to zero, but maintains vbucket UUID and failover entries. Used for scenarios // that want to restart a feed from zero, but detect failover func (md *DCPMetadata) Reset() { @@ -261,6 +268,10 @@ func (m *DCPMetadataCS) Purge(numWorkers int) { } } +func (m *DCPMetadataCS) GetKeyPrefix() string { + return m.keyPrefix +} + func (m *DCPMetadataCS) getMetadataKey(workerID int) string { return fmt.Sprintf("%s%d", m.keyPrefix, workerID) } diff --git a/base/dcp_client_test.go b/base/dcp_client_test.go index 87994ad828..15647522e8 100644 --- a/base/dcp_client_test.go +++ b/base/dcp_client_test.go @@ -341,7 +341,7 @@ func TestContinuousDCPRollback(t *testing.T) { counterCallback := func(event sgbucket.FeedEvent) bool { if bytes.HasPrefix(event.Key, []byte(t.Name())) { atomic.AddUint64(&mutationCount, 1) - if atomic.LoadUint64(&mutationCount) == uint64(1000) { + if atomic.LoadUint64(&mutationCount) == uint64(10000) { c <- true } } @@ -374,14 +374,11 @@ func TestContinuousDCPRollback(t *testing.T) { dcpClient, err := NewDCPClient(feedID, counterCallback, dcpClientOpts, gocbv2Bucket) require.NoError(t, err) - // function to force the rollback of some vBuckets - dcpClient.forceRollbackvBucket(vbUUID) - _, startErr := dcpClient.Start() require.NoError(t, startErr) // Add documents - const numDocs = 1000 + const numDocs = 10000 updatedBody := map[string]interface{}{"foo": "bar"} for i := 0; i < numDocs; i++ { key := fmt.Sprintf("%s_%d", t.Name(), i) @@ -393,17 +390,38 @@ func TestContinuousDCPRollback(t *testing.T) { select { case <-c: mutationCount := atomic.LoadUint64(&mutationCount) - require.Equal(t, uint64(1000), mutationCount) + require.Equal(t, uint64(10000), mutationCount) case <-timeout: t.Fatalf("timeout on client reached") } + // new dcp client to simulate a rollback + dcpClientOpts = DCPClientOptions{ + InitialMetadata: dcpClient.GetMetadata(), + FailOnRollback: false, + OneShot: false, + CollectionIDs: collectionIDs, + CheckpointPrefix: DefaultMetadataKeys.DCPCheckpointPrefix(t.Name()), + MetadataStoreType: DCPMetadataStoreInMemory, + } + require.NoError(t, dcpClient.Close()) + + dcpClient1, err := NewDCPClient(feedID, counterCallback, dcpClientOpts, gocbv2Bucket) + require.NoError(t, err) + // function to force the rollback of some vBuckets + dcpClient1.forceRollbackvBucket(vbUUID) + + _, startErr = dcpClient1.Start() + require.NoError(t, startErr) + // Assert that the number of vBuckets active are the same as the total number of vBuckets on the client. // In continuous rollback the streams should not close after they're finished. - numVBuckets := len(dcpClient.activeVbuckets) - require.Equal(t, dcpClient.numVbuckets, uint16(numVBuckets)) + numVBuckets := len(dcpClient1.activeVbuckets) + require.Equal(t, dcpClient1.numVbuckets, uint16(numVBuckets)) - require.NoError(t, dcpClient.Close()) + defer func() { + assert.NoError(t, dcpClient1.Close()) + }() } @@ -412,13 +430,12 @@ func TestContinuousDCPRollback(t *testing.T) { func (dc *DCPClient) forceRollbackvBucket(uuid gocbcore.VbUUID) { metadata := make([]DCPMetadata, dc.numVbuckets) for i := uint16(0); i < dc.numVbuckets; i++ { + // rollback roughly half the vBuckets if i%2 == 0 { metadata[i] = dc.metadata.GetMeta(i) metadata[i].VbUUID = uuid - } else { - metadata[i] = dc.metadata.GetMeta(i) + dc.metadata.SetMeta(i, metadata[i]) } - dc.metadata.SetMeta(i, metadata[i]) } } diff --git a/base/dcp_sharded.go b/base/dcp_sharded.go index 7d5272a924..83b4d3c117 100644 --- a/base/dcp_sharded.go +++ b/base/dcp_sharded.go @@ -16,7 +16,6 @@ import ( "crypto/tls" "fmt" "sort" - "strconv" "strings" "sync" @@ -52,6 +51,11 @@ type CbgtContext struct { Cfg cbgt.Cfg // Cfg manages storage of the current pindex set and node assignment heartbeater Heartbeater // Heartbeater used for failed node detection heartbeatListener *importHeartbeatListener // Listener subscribed to failed node alerts from heartbeater + eventHandlers *sgMgrEventHandlers // Event handler callbacks + ctx context.Context // Log context + dbName string // Database name + sourceName string // cbgt source name. Store on CbgtContext for access during teardown + sourceUUID string // cbgt source UUID. Store on CbgtContext for access during teardown } // StartShardedDCPFeed initializes and starts a CBGT Manager targeting the provided bucket. @@ -116,11 +120,6 @@ func GenerateLegacyIndexName(dbName string) string { func createCBGTIndex(ctx context.Context, c *CbgtContext, dbName string, configGroupID string, bucket Bucket, spec BucketSpec, scope string, collections []string, numPartitions uint16) error { sourceType := SOURCE_DCP_SG - bucketUUID, err := bucket.UUID() - if err != nil { - return err - } - sourceParams, err := cbgtFeedParams(spec, scope, collections, dbName) if err != nil { return err @@ -191,8 +190,8 @@ func createCBGTIndex(ctx context.Context, c *CbgtContext, dbName string, configG indexType := CBGTIndexTypeSyncGatewayImport + configGroupID err = c.Manager.CreateIndex( sourceType, // sourceType - bucket.GetName(), // sourceName - bucketUUID, // sourceUUID + c.sourceName, // bucket name + c.sourceUUID, // bucket UUID sourceParams, // sourceParams indexType, // indexType indexName, // indexName @@ -316,14 +315,16 @@ func initCBGTManager(ctx context.Context, bucket Bucket, spec BucketSpec, cfgSG // avoids file system usage, in conjunction with managerLoadDataDir=false in options. dataDir := "" - eventHandlers := &sgMgrEventHandlers{ctx: ctx} + eventHandlersCtx, eventHandlersCancel := context.WithCancel(ctx) + eventHandlers := &sgMgrEventHandlers{ctx: eventHandlersCtx, ctxCancel: eventHandlersCancel} // Specify one feed per pindex options := make(map[string]string) options[cbgt.FeedAllotmentOption] = cbgt.FeedAllotmentOnePerPIndex options["managerLoadDataDir"] = "false" - // Ensure we always use TLS if configured - cbgt defaults to non-TLS on initial connection - options["feedInitialBootstrapNonTLS"] = strconv.FormatBool(!spec.IsTLS()) + // TLS is controlled by the connection string. + // cbgt uses this parameter to run in mixed mode - non-TLS for CCCP but TLS for memcached. Sync Gateway does not need to set this parameter. + options["feedInitialBootstrapNonTLS"] = "false" // Disable collections if unsupported if !bucket.IsSupported(sgbucket.BucketStoreFeatureCollections) { @@ -345,10 +346,21 @@ func initCBGTManager(ctx context.Context, bucket Bucket, spec BucketSpec, cfgSG serverURL, eventHandlers, options) + eventHandlers.manager = mgr + + bucketUUID, err := bucket.UUID() + if err != nil { + return nil, fmt.Errorf("failed to fetch UUID of bucket %v: %w", MD(bucket.GetName()).Redact(), err) + } cbgtContext := &CbgtContext{ - Manager: mgr, - Cfg: cfgSG, + Manager: mgr, + Cfg: cfgSG, + eventHandlers: eventHandlers, + ctx: ctx, + dbName: dbName, + sourceName: bucket.GetName(), + sourceUUID: bucketUUID, } if spec.Auth != nil || (spec.Certpath != "" && spec.Keypath != "") { @@ -357,10 +369,6 @@ func initCBGTManager(ctx context.Context, bucket Bucket, spec BucketSpec, cfgSG } if spec.IsTLS() { - bucketUUID, err := bucket.UUID() - if err != nil { - return nil, fmt.Errorf("failed to fetch UUID of bucket %v: %w", MD(bucket.GetName()).Redact(), err) - } if spec.TLSSkipVerify { setCbgtRootCertsForBucket(bucketUUID, nil) } else { @@ -439,13 +447,32 @@ func getMinNodeVersion(cfg cbgt.Cfg) (*ComparableVersion, error) { return minVersion, nil } -// StopHeartbeatListener unregisters the listener from the heartbeater, and stops it. -func (c *CbgtContext) StopHeartbeatListener() { +// Stop unregisters the listener from the heartbeater, and stops it and associated handlers. +func (c *CbgtContext) Stop() { + if c.eventHandlers != nil { + c.eventHandlers.ctxCancel() + } if c.heartbeatListener != nil { c.heartbeater.UnregisterListener(c.heartbeatListener.Name()) c.heartbeatListener.Stop() } + + // Close open PIndexes before stopping the manager. + _, pindexes := c.Manager.CurrentMaps() + for _, pIndex := range pindexes { + err := c.Manager.ClosePIndex(pIndex) + if err != nil { + DebugfCtx(c.ctx, KeyImport, "Error closing pindex: %v", err) + } + } + // ClosePIndex calls are synchronous, so can stop manager once they've completed + c.Manager.Stop() + // CloseStatsClients closes the memcached connection cbgt uses for stats calls (highseqno, etc). sourceName and + // sourceUUID are bucketName/bucket UUID in our usage. cbgt has a single global stats connection per bucket, + // but does a refcount check before closing, so handles the case of multiple SG databases targeting the same bucket. + cbgt.CloseStatsClients(c.sourceName, c.sourceUUID) + c.RemoveFeedCredentials(c.dbName) } func (c *CbgtContext) RemoveFeedCredentials(dbName string) { @@ -696,7 +723,9 @@ func GetDefaultImportPartitions(serverless bool) uint16 { } type sgMgrEventHandlers struct { - ctx context.Context + ctx context.Context + ctxCancel context.CancelFunc + manager *cbgt.Manager } func (meh *sgMgrEventHandlers) OnRefreshManagerOptions(options map[string]string) { @@ -711,40 +740,38 @@ func (meh *sgMgrEventHandlers) OnUnregisterPIndex(pindex *cbgt.PIndex) { // No-op for SG } -// OnFeedError is required to trigger reconnection to a feed on an closed connection (EOF). -// Handling below based on cbft implementation - checks whether the underlying source (bucket) -// still exists with VerifySourceNotExists, and if it exists, calls NotifyMgrOnClose. -// This will trigger cbgt closing and then attempting to reconnect to the feed. -func (meh *sgMgrEventHandlers) OnFeedError(srcType string, r cbgt.Feed, err error) { - - DebugfCtx(meh.ctx, KeyDCP, "cbgt Mgr OnFeedError, srcType: %s, feed name: %s, err: %v", - srcType, r.Name(), err) +// OnFeedError is required to trigger reconnection to a feed on a closed connection (EOF). +// NotifyMgrOnClose will trigger cbgt closing and then attempt to reconnect to the feed, if the manager hasn't +// been stopped. +func (meh *sgMgrEventHandlers) OnFeedError(srcType string, r cbgt.Feed, feedErr error) { + // cbgt always passes srcType = SOURCE_GOCBCORE, but we have a wrapped type associated with our indexes - use that instead + // for our logging + srcType = SOURCE_DCP_SG + var bucketName, bucketUUID string dcpFeed, ok := r.(cbgt.FeedEx) - if !ok { - return - } - - gone, indexUUID, er := dcpFeed.VerifySourceNotExists() - DebugfCtx(meh.ctx, KeyDCP, "cbgt Mgr OnFeedError, VerifySourceNotExists,"+ - " srcType: %s, gone: %t, indexUUID: %s, err: %v", - srcType, gone, indexUUID, er) - if !gone { - // If we get an EOF error from the feeds and the bucket is still alive, - // then there could at the least two potential error scenarios. - // - // 1. Faulty kv node is failed over. - // 2. Ephemeral network connection issues with the host. - // - // In either case, the current feed instance turns dangling. - // Hence we can close the feeds so that they get refreshed to fix - // the connectivity problems either during the next rebalance - // (new kv node after failover-recovery rebalance) or - // on the next janitor work cycle(ephemeral network issue to the same node). - if strings.Contains(err.Error(), "EOF") { - InfofCtx(meh.ctx, KeyDCP, "Handling EOF on cbgt feed - notifying manager to trigger reconnection to feed. indexUUID: %v, err: %v", indexUUID, err) - dcpFeed.NotifyMgrOnClose() + if ok { + bucketName, bucketUUID = dcpFeed.GetBucketDetails() + } + DebugfCtx(meh.ctx, KeyDCP, "cbgt Mgr OnFeedError, srcType: %s, feed name: %s, bucket name: %s, err: %v", + srcType, r.Name(), MD(bucketName), feedErr) + + // If we get an EOF error from the feeds and the import listener hasn't been closed, + // then there could at the least two potential error scenarios. + // + // 1. Faulty kv node is failed over. + // 2. Ephemeral network connection issues with the host. + // + // In either case, the current feed instance turns dangling. + // Hence we can close the feeds so that they get refreshed to fix + // the connectivity problems either during the next rebalance + // (new kv node after failover-recovery rebalance) or + // on the next janitor work cycle(ephemeral network issue to the same node). + if strings.Contains(feedErr.Error(), "EOF") { + // If this wasn't an intentional close, log about the EOF + if meh.ctx.Err() != context.Canceled { + InfofCtx(meh.ctx, KeyDCP, "Handling EOF on cbgt feed - notifying manager to trigger reconnection to feed for bucketName:%v, bucketUUID:%v, err: %v", MD(bucketName), bucketUUID, feedErr) } + dcpFeed.NotifyMgrOnClose() } - } diff --git a/base/error.go b/base/error.go index 45bb127da5..aaa7d0cf82 100644 --- a/base/error.go +++ b/base/error.go @@ -67,6 +67,12 @@ var ( // ErrConfigRegistryReloadRequired is returned when a db config fetch requires a registry reload based on version mismatch (config is newer) ErrConfigRegistryReloadRequired = &sgError{"Config registry reload required"} + + // ErrMaximumChannelsForUserExceeded is returned when running in serverless mode and the user has more than 500 channels granted to them + ErrMaximumChannelsForUserExceeded = &sgError{fmt.Sprintf("User has exceeded maximum of %d channels", ServerlessChannelLimit)} + + // ErrReplicationLimitExceeded is returned when then replication connection threshold is exceeded + ErrReplicationLimitExceeded = &sgError{"Replication limit exceeded. Try agin later."} ) func (e *sgError) Error() string { @@ -115,6 +121,10 @@ func ErrorAsHTTPStatus(err error) (int, string) { return http.StatusRequestEntityTooLarge, "Document too large!" case ErrViewTimeoutError: return http.StatusServiceUnavailable, unwrappedErr.Error() + case ErrMaximumChannelsForUserExceeded: + return http.StatusInternalServerError, "Maximum number of channels exceeded for this user" + case ErrReplicationLimitExceeded: + return http.StatusServiceUnavailable, unwrappedErr.Error() } // gocb V2 errors diff --git a/base/gocb_dcp_feed.go b/base/gocb_dcp_feed.go index 12edfbe35e..811861c87e 100644 --- a/base/gocb_dcp_feed.go +++ b/base/gocb_dcp_feed.go @@ -50,10 +50,6 @@ func getHighSeqMetadata(cbstore CouchbaseBucketStore) ([]DCPMetadata, error) { // StartGocbDCPFeed starts a DCP Feed. func StartGocbDCPFeed(bucket *GocbV2Bucket, bucketName string, args sgbucket.FeedArguments, callback sgbucket.FeedEventCallbackFunc, dbStats *expvar.Map, metadataStoreType DCPMetadataStoreType, groupID string) error { - metadata, err := getHighSeqMetadata(bucket) - if err != nil { - return err - } feedName, err := GenerateDcpStreamName(args.ID) if err != nil { return err @@ -84,19 +80,27 @@ func StartGocbDCPFeed(bucket *GocbV2Bucket, bucketName string, args sgbucket.Fee } } } + options := DCPClientOptions{ + MetadataStoreType: metadataStoreType, + GroupID: groupID, + DbStats: dbStats, + CollectionIDs: collectionIDs, + AgentPriority: gocbcore.DcpAgentPriorityMed, + CheckpointPrefix: args.CheckpointPrefix, + } + + if args.Backfill == sgbucket.FeedNoBackfill { + metadata, err := getHighSeqMetadata(bucket) + if err != nil { + return err + } + options.InitialMetadata = metadata + } dcpClient, err := NewDCPClient( feedName, callback, - DCPClientOptions{ - MetadataStoreType: metadataStoreType, - GroupID: groupID, - InitialMetadata: metadata, - DbStats: dbStats, - CollectionIDs: collectionIDs, - AgentPriority: gocbcore.DcpAgentPriorityMed, - CheckpointPrefix: args.CheckpointPrefix, - }, + options, bucket) if err != nil { return err diff --git a/base/leaky_bucket.go b/base/leaky_bucket.go index 0fc2c0aec9..cf9e257e86 100644 --- a/base/leaky_bucket.go +++ b/base/leaky_bucket.go @@ -11,6 +11,7 @@ package base import ( "expvar" + "fmt" "math" "time" @@ -27,6 +28,7 @@ type LeakyBucket struct { } var _ sgbucket.BucketStore = &LeakyBucket{} +var _ sgbucket.DynamicDataStoreBucket = &LeakyBucket{} func NewLeakyBucket(bucket Bucket, config LeakyBucketConfig) *LeakyBucket { return &LeakyBucket{ @@ -94,6 +96,22 @@ func (b *LeakyBucket) GetUnderlyingBucket() Bucket { return b.bucket } +func (b *LeakyBucket) CreateDataStore(name sgbucket.DataStoreName) error { + dynamicDataStore, ok := b.GetUnderlyingBucket().(sgbucket.DynamicDataStoreBucket) + if !ok { + return fmt.Errorf("Bucket %T doesn't support dynamic collection creation", b.GetUnderlyingBucket()) + } + return dynamicDataStore.CreateDataStore(name) +} + +func (b *LeakyBucket) DropDataStore(name sgbucket.DataStoreName) error { + dynamicDataStore, ok := b.GetUnderlyingBucket().(sgbucket.DynamicDataStoreBucket) + if !ok { + return fmt.Errorf("Bucket %T doesn't support dynamic collection creation", b.GetUnderlyingBucket()) + } + return dynamicDataStore.DropDataStore(name) +} + // The config object that controls the LeakyBucket behavior type LeakyBucketConfig struct { // Incr() fails N times before finally succeeding diff --git a/base/logging.go b/base/logging.go index 814db02c68..6f46e6a2d8 100644 --- a/base/logging.go +++ b/base/logging.go @@ -20,9 +20,17 @@ import ( "testing" "time" + "github.com/couchbase/sg-bucket/js" "github.com/stretchr/testify/assert" ) +func init() { + // Redirect JS package's logging to SG logs: + js.LoggingCallback = func(ctx context.Context, level js.LogLevel, fmt string, args ...any) { + logTo(ctx, LogLevel(level), KeyJavascript, fmt, args...) + } +} + // GetLogKeys returns log keys in a map func GetLogKeys() map[string]bool { consoleLogKeys := ConsoleLogKey().EnabledLogKeys() @@ -173,6 +181,11 @@ func TracefCtx(ctx context.Context, logKey LogKey, format string, args ...interf logTo(ctx, LevelTrace, logKey, format, args...) } +// LogfTo logs a message at a caller-selectable level. +func LogfTo(ctx context.Context, logLevel LogLevel, logKey LogKey, format string, args ...interface{}) { + logTo(ctx, logLevel, logKey, format, args...) +} + // RecordStats writes the given stats JSON content to a stats log file, if enabled. // The content passed in is expected to be a JSON dictionary. func RecordStats(statsJson string) { @@ -212,7 +225,11 @@ func logTo(ctx context.Context, logLevel LogLevel, logKey LogKey, format string, // Error, warn and trace logs also append caller name/line numbers. if logLevel <= LevelWarn || logLevel == LevelTrace { - format += " -- " + GetCallersName(2, true) + stackDepth := 2 + if logKey == KeyJavascript { + stackDepth++ // js logs go through another layer of fn call (js.LoggingCallback) + } + format += " -- " + GetCallersName(stackDepth, true) } // Perform log redaction, if necessary. diff --git a/base/redactable_error.go b/base/redactable_error.go index 9d59071e39..db979f01da 100644 --- a/base/redactable_error.go +++ b/base/redactable_error.go @@ -12,14 +12,18 @@ package base import "fmt" -// A redactable error can be used as a drop-in replacement for a base error (as would have been created via -// fmt.Errorf), which has the ability to redact any sensitive user data by calling redact() on all if it's -// stored args. +// RedactableError is an error that can be used as a drop-in replacement for an error, +// which has the ability to redact any sensitive data by calling redact() on all of its args. type RedactableError struct { fmt string args []interface{} } +var ( + _ error = &RedactableError{} + _ Redactor = &RedactableError{} +) + // Create a new redactable error. Same signature as fmt.Errorf() for easy drop-in replacement. func RedactErrorf(fmt string, args ...interface{}) *RedactableError { return &RedactableError{ @@ -28,12 +32,17 @@ func RedactErrorf(fmt string, args ...interface{}) *RedactableError { } } -// Satisfy error interface +// Error satisfies the error interface func (re *RedactableError) Error() string { + return re.String() +} + +// String returns a non-redacted version of the error - satisfies the Redactor interface. +func (re *RedactableError) String() string { return fmt.Sprintf(re.fmt, re.args...) } -// Satisfy redact interface +// Redact returns a redacted version of the error - satisfies the Redactor interface. func (re *RedactableError) Redact() string { redactedArgs := redact(re.args) return fmt.Sprintf(re.fmt, redactedArgs...) diff --git a/base/stats.go b/base/stats.go index fd5560a78b..224aafbcf0 100644 --- a/base/stats.go +++ b/base/stats.go @@ -376,7 +376,8 @@ type CBLReplicationPullStats struct { // The total amount of time processing rev messages (revisions) during pull revision. RevProcessingTime *SgwIntStat `json:"rev_processing_time"` // The total number of rev messages processed during replication. - RevSendCount *SgwIntStat `json:"rev_send_count"` + RevSendCount *SgwIntStat `json:"rev_send_count"` + RevErrorCount *SgwIntStat `json:"rev_error_count"` // The total amount of time between Sync Gateway receiving a request for a revision and that revision being sent. // // In a pull replication, Sync Gateway sends a /_changes request to the client and the client responds with the list of revisions it wants to receive. @@ -392,6 +393,8 @@ type CBLReplicationPushStats struct { AttachmentPushCount *SgwIntStat `json:"attachment_push_count"` // The total number of documents pushed. DocPushCount *SgwIntStat `json:"doc_push_count"` + // The total number of documents that failed to push. + DocPushErrorCount *SgwIntStat `json:"doc_push_error_count"` // The total number of changes and-or proposeChanges messages processed since node start-up. ProposeChangeCount *SgwIntStat `json:"propose_change_count"` // The total time spent processing changes and/or proposeChanges messages. @@ -430,6 +433,8 @@ type CollectionStats struct { } type DatabaseStats struct { + ReplicationBytesReceived *SgwIntStat `json:"replication_bytes_received"` + ReplicationBytesSent *SgwIntStat `json:"replication_bytes_sent"` // The compaction_attachment_start_time. CompactionAttachmentStartTime *SgwIntStat `json:"compaction_attachment_start_time"` // The compaction_tombstone_start_time. @@ -493,6 +498,8 @@ type DatabaseStats struct { SyncFunctionTime *SgwIntStat `json:"sync_function_time"` // The total number of times that a sync function encountered an exception (across all collections). SyncFunctionExceptionCount *SgwIntStat `json:"sync_function_exception_count"` + // The total number of times a replication connection is rejected due ot it being over the threshold + NumReplicationsRejectedLimit *SgwIntStat `json:"num_replications_rejected_limit"` // These can be cleaned up in future versions of SGW, implemented as maps to reduce amount of potential risk // prior to Hydrogen release. These are not exported as part of prometheus and only exposed through expvars @@ -1198,6 +1205,10 @@ func (d *DbStats) initCBLReplicationPullStats() error { if err != nil { return err } + resUtil.RevErrorCount, err = NewIntStat(SubsystemReplicationPull, "rev_error_count", labelKeys, labelVals, prometheus.CounterValue, 0) + if err != nil { + return err + } resUtil.RevSendLatency, err = NewIntStat(SubsystemReplicationPull, "rev_send_latency", labelKeys, labelVals, prometheus.CounterValue, 0) if err != nil { return err @@ -1223,6 +1234,7 @@ func (d *DbStats) unregisterCBLReplicationPullStats() { prometheus.Unregister(d.CBLReplicationPullStats.RequestChangesTime) prometheus.Unregister(d.CBLReplicationPullStats.RevProcessingTime) prometheus.Unregister(d.CBLReplicationPullStats.RevSendCount) + prometheus.Unregister(d.CBLReplicationPullStats.RevErrorCount) prometheus.Unregister(d.CBLReplicationPullStats.RevSendLatency) } @@ -1248,6 +1260,10 @@ func (d *DbStats) initCBLReplicationPushStats() error { if err != nil { return err } + resUtil.DocPushErrorCount, err = NewIntStat(SubsystemReplicationPush, "doc_push_error_count", labelKeys, labelVals, prometheus.GaugeValue, 0) + if err != nil { + return err + } resUtil.ProposeChangeCount, err = NewIntStat(SubsystemReplicationPush, "propose_change_count", labelKeys, labelVals, prometheus.CounterValue, 0) if err != nil { return err @@ -1269,6 +1285,7 @@ func (d *DbStats) unregisterCBLReplicationPushStats() { prometheus.Unregister(d.CBLReplicationPushStats.AttachmentPushBytes) prometheus.Unregister(d.CBLReplicationPushStats.AttachmentPushCount) prometheus.Unregister(d.CBLReplicationPushStats.DocPushCount) + prometheus.Unregister(d.CBLReplicationPushStats.DocPushErrorCount) prometheus.Unregister(d.CBLReplicationPushStats.ProposeChangeCount) prometheus.Unregister(d.CBLReplicationPushStats.ProposeChangeTime) prometheus.Unregister(d.CBLReplicationPushStats.WriteProcessingTime) @@ -1284,6 +1301,14 @@ func (d *DbStats) initDatabaseStats() error { labelKeys := []string{DatabaseLabelKey} labelVals := []string{d.dbName} + resUtil.ReplicationBytesReceived, err = NewIntStat(SubsystemDatabaseKey, "replication_bytes_received", labelKeys, labelVals, prometheus.CounterValue, 0) + if err != nil { + return err + } + resUtil.ReplicationBytesSent, err = NewIntStat(SubsystemDatabaseKey, "replication_bytes_sent", labelKeys, labelVals, prometheus.CounterValue, 0) + if err != nil { + return err + } resUtil.CompactionAttachmentStartTime, err = NewIntStat(SubsystemDatabaseKey, "compaction_attachment_start_time", labelKeys, labelVals, prometheus.GaugeValue, 0) if err != nil { return err @@ -1412,6 +1437,10 @@ func (d *DbStats) initDatabaseStats() error { if err != nil { return err } + resUtil.NumReplicationsRejectedLimit, err = NewIntStat(SubsystemDatabaseKey, "num_replications_rejected_limit", labelKeys, labelVals, prometheus.CounterValue, 0) + if err != nil { + return err + } resUtil.ImportFeedMapStats = &ExpVarMapWrapper{new(expvar.Map).Init()} resUtil.CacheFeedMapStats = &ExpVarMapWrapper{new(expvar.Map).Init()} @@ -1421,6 +1450,8 @@ func (d *DbStats) initDatabaseStats() error { } func (d *DbStats) unregisterDatabaseStats() { + prometheus.Unregister(d.DatabaseStats.ReplicationBytesReceived) + prometheus.Unregister(d.DatabaseStats.ReplicationBytesSent) prometheus.Unregister(d.DatabaseStats.CompactionAttachmentStartTime) prometheus.Unregister(d.DatabaseStats.CompactionTombstoneStartTime) prometheus.Unregister(d.DatabaseStats.ConflictWriteCount) @@ -1453,6 +1484,7 @@ func (d *DbStats) unregisterDatabaseStats() { prometheus.Unregister(d.DatabaseStats.SyncFunctionCount) prometheus.Unregister(d.DatabaseStats.SyncFunctionTime) prometheus.Unregister(d.DatabaseStats.SyncFunctionExceptionCount) + prometheus.Unregister(d.DatabaseStats.NumReplicationsRejectedLimit) } func (d *DbStats) CollectionStat(scopeName, collectionName string) (*CollectionStats, error) { diff --git a/base/util.go b/base/util.go index 91484eff4d..39a49d981d 100644 --- a/base/util.go +++ b/base/util.go @@ -1652,7 +1652,7 @@ func GetHttpClientForWebSocket(insecureSkipVerify bool) *http.Client { // (There's really no reason for a caller to take note of the return value.) func turnOffNoDelay(ctx context.Context, conn net.Conn) bool { if tcpConn, ok := conn.(*net.TCPConn); !ok { - WarnfCtx(ctx, "Couldn't turn off NODELAY for %v: it's not a TCPConn", conn) + WarnfCtx(ctx, "Couldn't turn off NODELAY for %v: %T is not type *net.TCPConn", conn, conn) } else if err := tcpConn.SetNoDelay(false); err != nil { WarnfCtx(ctx, "Couldn't turn off NODELAY for %v: %v", conn, err) } else { diff --git a/base/util_testing.go b/base/util_testing.go index 806da93c07..44501772d7 100644 --- a/base/util_testing.go +++ b/base/util_testing.go @@ -174,6 +174,22 @@ func (b *TestBucket) GetMetadataStore() sgbucket.DataStore { return b.Bucket.DefaultDataStore() } +func (b *TestBucket) CreateDataStore(name sgbucket.DataStoreName) error { + dynamicDataStore, ok := b.Bucket.(sgbucket.DynamicDataStoreBucket) + if !ok { + return fmt.Errorf("Bucket %T doesn't support dynamic collection creation", b.Bucket) + } + return dynamicDataStore.CreateDataStore(name) +} + +func (b *TestBucket) DropDataStore(name sgbucket.DataStoreName) error { + dynamicDataStore, ok := b.GetUnderlyingBucket().(sgbucket.DynamicDataStoreBucket) + if !ok { + return fmt.Errorf("Bucket %T doesn't support dynamic collection creation", b.GetUnderlyingBucket()) + } + return dynamicDataStore.DropDataStore(name) +} + // GetDefaultDataStore returns the default DataStore. This is likely never actually wanted over GetSingleDataStore, so is left commented until absolutely required. // func (b *TestBucket) GetDefaultDataStore() sgbucket.DataStore { // b.t.Logf("Using default collection - Are you sure you want this instead of GetSingleDataStore() ?") diff --git a/build.sh b/build.sh index 01b4ed2764..7d86917b5d 100755 --- a/build.sh +++ b/build.sh @@ -15,21 +15,21 @@ set -e BLDPARS=${@:2} -SRCPATH=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) +SRCPATH=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) OUTPATH=${SRCPATH}/bin mkdir -p ${OUTPATH} # Build both editions by default # Limit via the $SG_EDITION env var -build_editions=( "CE" "EE" ) +build_editions=("CE" "EE") if [ "${SG_EDITION}" = "CE" -o "${SG_EDITION}" = "EE" ]; then echo "Building only ${SG_EDITION}" - build_editions=( ${SG_EDITION} ) + build_editions=(${SG_EDITION}) else echo "Building all editions ... Limit with 'SG_EDITION=CE $0'" fi -doBuild () { +doBuild() { cd ${SRCPATH} ./set-version-stamp.sh || true privRepos="" @@ -37,11 +37,19 @@ doBuild () { binarySuffix="_ce" if [ "$1" = "EE" ]; then buildTags="-tags cb_sg_enterprise" + if [ -n "${SG_V8:-}" ]; then + buildTags="${buildTags},cb_sg_v8" + fi binarySuffix="" - githubSshConfig=$( ( git config --global --list ; git config --system --list ) | grep -i "url.git@github.com:" | cat ) + githubSshConfig=$( ( + git config --global --list + git config --system --list + ) | grep -i "url.git@github.com:" | cat) if [ -z "${githubSshConfig}" ]; then git config --global url.git@github.com:couchbaselabs/go-fleecedelta.insteadOf https://github.com/couchbaselabs/go-fleecedelta fi + elif [ "${SG_V8:-}" = "CE" ]; then + buildTags="-tags cb_sg_v8" fi ## Go Install Sync Gateway @@ -59,6 +67,16 @@ doBuild () { } for edition in "${build_editions[@]}"; do - echo " Building edition: ${edition}" + if [[ -z "${SG_V8:-}" ]]; then + echo " Building edition: ${edition} without V8" + else + echo " Building edition: ${edition} with V8" + fi (doBuild $edition "$@") + if [[ -z "${SG_V8:-}" ]]; then + echo " Building edition: ${edition} with V8" + SG_V8=1 + (doBuild $edition "$@" -tags cb_sg_v8) + unset SG_V8 + fi done diff --git a/channels/channelmapper.go b/channels/channelmapper.go index f3fcf42348..bd044e46e3 100644 --- a/channels/channelmapper.go +++ b/channels/channelmapper.go @@ -9,15 +9,28 @@ package channels import ( + "context" + _ "embed" "encoding/json" - "strconv" + "fmt" + "strings" "time" - sgbucket "github.com/couchbase/sg-bucket" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" - _ "github.com/robertkrimen/otto/underscore" ) +/** The data given to the channel-mapper function. */ +type ChannelMapperInput struct { + DocID string + RevID string + Body string + OldBody string + Deleted bool + Meta MetaMap + UserCtx map[string]interface{} +} + /** Result of running a channel-mapper function. */ type ChannelMapperOutput struct { Channels base.Set // channels assigned to the document via channel() callback @@ -27,27 +40,67 @@ type ChannelMapperOutput struct { Expiry *uint32 // Expiry value specified by expiry() callback. Standard CBS expiry format: seconds if less than 30 days, epoch time otherwise } +// The object that runs the sync function. type ChannelMapper struct { - *sgbucket.JSServer // "Superclass" + service *js.Service + timeout time.Duration + fnSource string } // Maps user names (or role names prefixed with "role:") to arrays of channel or role names type AccessMap map[string]base.Set -// Number of SyncRunner tasks (and Otto contexts) to cache -// Should be larger than sequence_allocator.maxBatchSize, to avoid pool overflow under some load scenarios (CBG-436) -const kTaskCacheSize = 16 +// If the provided principal name (in access grant format) is a role, returns the role name without prefix +func AccessNameToPrincipalName(accessPrincipalName string) (principalName string, isRole bool) { + if strings.HasPrefix(accessPrincipalName, RoleAccessPrefix) { + return accessPrincipalName[len(RoleAccessPrefix):], true + } + return accessPrincipalName, false +} + +// Document metadata passed to the sync function +type MetaMap struct { + Key string // xattr key; "" if none + JSONValue []byte // raw JSON value of xattr key; nil if none +} + +func (meta MetaMap) MarshalJSON() ([]byte, error) { + var result string + if meta.Key == "" { + result = `{"xattrs":null}` + } else { + result = fmt.Sprintf(`{"xattrs":{%q:`, meta.Key) + if meta.JSONValue != nil { + result += string(meta.JSONValue) + "}}" + } else { + result += "null}}" + } + } + return []byte(result), nil +} + +// Prefix used to identify roles in access grants +const RoleAccessPrefix = "role:" // DocChannelsSyncFunction is the default sync function used prior to collections. const DocChannelsSyncFunction = `function(doc){channel(doc.channels);}` +// The JavaScript code run by the SyncRunner; the sync fn is copied into it. +// See wrappedFuncSource(). +// +//go:embed sync_fn_wrapper_older.js +var kSyncFnHostScriptOlder string + +//go:embed sync_fn_wrapper_modern.js +var kSyncFnHostScriptModern string + // NewChannelMapper creates a new channel mapper with a specific javascript function and a timeout. A zero value timeout will never timeout. -func NewChannelMapper(fnSource string, timeout time.Duration) *ChannelMapper { +func NewChannelMapper(owner js.ServiceHost, fnSource string, timeout time.Duration) *ChannelMapper { + service := js.NewService(owner, "channelMapper", wrappedFuncSource(fnSource, owner)) return &ChannelMapper{ - JSServer: sgbucket.NewJSServer(fnSource, timeout, kTaskCacheSize, - func(fnSource string, timeout time.Duration) (sgbucket.JSServerTask, error) { - return NewSyncRunner(fnSource, timeout) - }), + service: service, + timeout: timeout, + fnSource: fnSource, } } @@ -60,79 +113,130 @@ func GetDefaultSyncFunction(scopeName, collectionName string) string { } -func (mapper *ChannelMapper) MapToChannelsAndAccess(body map[string]interface{}, oldBodyJSON string, metaMap map[string]interface{}, userCtx map[string]interface{}) (*ChannelMapperOutput, error) { - numberFixBody := ConvertJSONNumbers(body) - numberFixMetaMap := ConvertJSONNumbers(metaMap) +func (mapper *ChannelMapper) Function() string { + return mapper.fnSource +} - result1, err := mapper.Call(numberFixBody, sgbucket.JSONString(oldBodyJSON), numberFixMetaMap, userCtx) +// This function is DEPRECATED. It's currently used in some tests that can't easily be changed. +// Its current implementation is a kludge, and it shouldn't be used in production. +func (mapper *ChannelMapper) SetFunction(fnSource string) error { + host := mapper.service.Host() + mapper.fnSource = fnSource + mapper.service = js.NewService(host, "channelMapper", wrappedFuncSource(fnSource, host)) + return nil +} + +func wrappedFuncSource(funcSource string, host js.ServiceHost) string { + // Use different wrapper scripts for modern vs older JS. + script := kSyncFnHostScriptOlder + if host.Engine().LanguageVersion() >= js.ES2015 { + script = kSyncFnHostScriptModern + } + return fmt.Sprintf( + script, + funcSource, + base.SyncFnErrorAdminRequired, + base.SyncFnErrorWrongUser, + base.SyncFnErrorMissingRole, + base.SyncFnErrorMissingChannelAccess, + ) +} + +// Runs the sync function. Thread-safe. +func (mapper *ChannelMapper) Run(input ChannelMapperInput) (*ChannelMapperOutput, error) { + result, err := mapper.service.WithRunner(func(runner js.Runner) (any, error) { + ctx := context.Background() + if mapper.timeout > 0 { + var cancelFn context.CancelFunc + ctx, cancelFn = context.WithTimeout(ctx, mapper.timeout) + defer cancelFn() + } + runner.SetContext(ctx) + return callSyncFn(runner, input) + }) if err != nil { return nil, err } - output := result1.(*ChannelMapperOutput) - return output, nil + return result.(*ChannelMapperOutput), nil } -// Javscript max integer value (https://www.ecma-international.org/ecma-262/5.1/#sec-8.5) -const JavascriptMaxSafeInt = int64(1<<53 - 1) -const JavascriptMinSafeInt = -JavascriptMaxSafeInt - -// ConvertJSONNumbers converts json.Number values to javascript number objects for use in the sync -// function. Integers that would lose precision are left as json.Number, as are floats that can't be -// converted to float64. -func ConvertJSONNumbers(value interface{}) interface{} { - switch value := value.(type) { - case json.Number: - if asInt, err := value.Int64(); err == nil { - if asInt > JavascriptMaxSafeInt || asInt < JavascriptMinSafeInt { - // Integer will lose precision when used in javascript - leave as json.Number - return value - } - return asInt - } else { - numErr, _ := err.(*strconv.NumError) - if numErr.Err == strconv.ErrRange { - return value - } - } +// Parsed version of the JSON object returned by the sync-fn wrapper. +type syncFnResult = struct { + RejectionStatus int + RejectionMessage string + Channels []string + Access map[string][]string + Roles map[string][]string + Expiry any +} - if asFloat, err := value.Float64(); err == nil { - // Can't reliably detect loss of precision in float, due to number of variations in input float format - return asFloat - } - return value - case map[string]interface{}: - for k, v := range value { - value[k] = ConvertJSONNumbers(v) +func callSyncFn(runner js.Runner, in ChannelMapperInput) (*ChannelMapperOutput, error) { + // Call the sync fn: + jsResult, err := runner.Run(in.DocID, in.RevID, in.Deleted, js.JSONString(in.Body), in.OldBody, in.Meta.Key, string(in.Meta.JSONValue), in.UserCtx) + if err != nil { + return nil, fmt.Errorf("unexpected error calling sync fn: %w", err) + } + var result syncFnResult + if err := json.Unmarshal([]byte(jsResult.(string)), &result); err != nil { + return nil, fmt.Errorf("unparseable output from sync-fn wrapper: %w", err) + } + + // Convert the JSON result to a ChannelMapperOutput: + output := &ChannelMapperOutput{} + if result.RejectionStatus >= 400 { + output.Rejection = base.HTTPErrorf(result.RejectionStatus, result.RejectionMessage) + return output, nil + } + if result.Channels != nil { + if output.Channels, err = SetFromArray(result.Channels, ExpandStar); err != nil { + return nil, err } - case []interface{}: - for i, v := range value { - value[i] = ConvertJSONNumbers(v) + } + if output.Access, err = compileJSAccessMap(result.Access, ""); err != nil { + return nil, err + } + if output.Roles, err = compileJSAccessMap(result.Roles, RoleAccessPrefix); err != nil { + return nil, err + } + if result.Expiry != nil { + if expiry, reflectErr := base.ReflectExpiry(result.Expiry); reflectErr == nil { + output.Expiry = expiry + } else { + base.WarnfCtx(runner.Context(), "sync function set invalid expiry value `%+v` ", result.Expiry) } - default: } - return value + return output, nil } -//////// UTILITY FUNCTIONS: +//////// UTILITIES: -// Calls the function for each user whose access is different between the two AccessMaps -func ForChangedUsers(a, b AccessMap, fn func(user string)) { - for name, access := range a { - if !access.Equals(b[name]) { - fn(name) - } - } - for name := range b { - if _, existed := a[name]; !existed { - fn(name) +// Converts the "access" or "roles" property of the result into an AccessMap. +func compileJSAccessMap(result map[string][]string, prefix string) (AccessMap, error) { + var err error + access := make(AccessMap) + for user, values := range result { + if len(values) > 0 { + if err = stripMandatoryPrefix(values, prefix); err != nil { + return nil, err + } + if access[user], err = SetFromArray(values, RemoveStar); err != nil { + return nil, err + } } } + return access, nil } -func (runner *SyncRunner) MapToChannelsAndAccess(body map[string]interface{}, oldBodyJSON string, userCtx map[string]interface{}) (*ChannelMapperOutput, error) { - result, err := runner.Call(body, sgbucket.JSONString(oldBodyJSON), userCtx) - if err != nil { - return nil, err +// Strips a prefix from every item of an array. +func stripMandatoryPrefix(values []string, prefix string) error { + if prefix != "" { + for i, value := range values { + if strings.HasPrefix(value, prefix) { + values[i] = value[len(prefix):] + } else { + return base.RedactErrorf("Value %q does not begin with %q", base.UD(value), base.UD(prefix)) + } + } } - return result.(*ChannelMapperOutput), nil + return nil } diff --git a/channels/channelmapper_test.go b/channels/channelmapper_test.go index c93ce3c949..be4a7967df 100644 --- a/channels/channelmapper_test.go +++ b/channels/channelmapper_test.go @@ -9,595 +9,667 @@ package channels import ( + "encoding/json" "fmt" + "strings" "testing" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" - "github.com/robertkrimen/otto" - "github.com/robertkrimen/otto/underscore" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + // Docs: https://pkg.go.dev/github.com/couchbasedeps/v8go ) -func init() { - underscore.Disable() // It really slows down unit tests (by making otto.New take a lot longer) -} - func parse(jsonStr string) map[string]interface{} { var parsed map[string]interface{} _ = base.JSONUnmarshal([]byte(jsonStr), &parsed) return parsed } -func emptyMetaMap() map[string]interface{} { - return map[string]interface{}{ - base.MetaMapXattrsKey: nil, - } +func emptyMetaMap() MetaMap { + return MetaMap{} } var noUser = map[string]interface{}{"name": nil, "channels": []string{}} -func TestOttoValueToStringArray(t *testing.T) { - // Test for https://github.com/robertkrimen/otto/issues/24 - value, _ := otto.New().ToValue([]string{"foo", "bar", "baz"}) - strings := ottoValueToStringArray(value) - assert.Equal(t, []string{"foo", "bar", "baz"}, strings) - - // Test for https://issues.couchbase.com/browse/CBG-714 - value, _ = otto.New().ToValue([]interface{}{"a", []interface{}{"b", "g"}, "c", 4}) - strings = ottoValueToStringArray(value) - assert.Equal(t, []string{"a", "c"}, strings) +// Runs the sync function. Thread-safe. +// (Wrapper around ChannelMapper.Run, kept around because a bunch of tests still call it.) +func (mapper *ChannelMapper) MapToChannelsAndAccess(body map[string]any, oldBodyJSON string, metaMap MetaMap, userCtx map[string]interface{}) (*ChannelMapperOutput, error) { + bodyJSON, err := json.Marshal(body) + if err != nil { + return nil, err + } + docID, _ := body["_id"].(string) + revID, _ := body["_rev"].(string) + input := ChannelMapperInput{ + DocID: docID, + RevID: revID, + Body: string(bodyJSON), + OldBody: oldBodyJSON, + Meta: metaMap, + UserCtx: userCtx, + } + return mapper.Run(input) } // verify that our version of Otto treats JSON parsed arrays like real arrays func TestJavaScriptWorks(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {channel(doc.x.concat(doc.y));}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{"x":["abc"],"y":["xyz"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, BaseSetOf(t, "abc", "xyz"), res.Channels) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {channel(doc.x.concat(doc.y));}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{"x":["abc"],"y":["xyz"]}`), `{}`, emptyMetaMap(), noUser) + require.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, BaseSetOf(t, "abc", "xyz"), res.Channels) + }) +} + +// Verify the sync fn cannot access the internal JS variables used in the wrapper. +func TestHiddenVariables(t *testing.T) { + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + for _, hidden := range []string{"userCtx", "shouldValidate", "result", "eval", "Function"} { + mapper := NewChannelMapper(vm, `function(doc) {return `+hidden+`;}`, 0) + _, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + require.Error(t, err, "Was able to access %q", hidden) + assert.ErrorContains(t, err, "ReferenceError:") + assert.ErrorContains(t, err, " is not defined") + } + }) } // Just verify that the calls to the channel() fn show up in the output channel list. func TestSyncFunction(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {channel("foo", "bar"); channel("baz")}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": []}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, BaseSetOf(t, "foo", "bar", "baz"), res.Channels) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {channel("foo", "bar"); channel("baz")}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": []}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, BaseSetOf(t, "foo", "bar", "baz"), res.Channels) + }) } // Just verify that the calls to the access() fn show up in the output channel list. func TestAccessFunction(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {access("foo", "bar"); access("foo", "baz")}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, AccessMap{"foo": BaseSetOf(t, "bar", "baz")}, res.Access) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {access("foo", "bar"); access("foo", "baz")}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, AccessMap{"foo": BaseSetOf(t, "bar", "baz")}, res.Access) + }) } // Just verify that the calls to the channel() fn show up in the output channel list. func TestSyncFunctionTakesArray(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {channel(["foo", "bar ok","baz"])}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": []}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, BaseSetOf(t, "foo", "bar ok", "baz"), res.Channels) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {channel(["foo", "bar ok","baz"])}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": []}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, BaseSetOf(t, "foo", "bar ok", "baz"), res.Channels) + }) } // Calling channel() with an invalid channel name should return an error. func TestSyncFunctionRejectsInvalidChannels(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {channel(["foo", "bad,name","baz"])}`, 0) - _, err := mapper.MapToChannelsAndAccess(parse(`{"channels": []}`), `{}`, emptyMetaMap(), noUser) - assert.True(t, err != nil) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {channel(["foo", "bad,name","baz"])}`, 0) + _, err := mapper.MapToChannelsAndAccess(parse(`{"channels": []}`), `{}`, emptyMetaMap(), noUser) + assert.True(t, err != nil) + }) } // Calling access() with an invalid channel name should return an error. func TestAccessFunctionRejectsInvalidChannels(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {access("foo", "bad,name");}`, 0) - _, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.True(t, err != nil) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {access("foo", "bad,name");}`, 0) + _, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.True(t, err != nil) + }) } -// Just verify that the calls to the access() fn show up in the output channel list. +// Verify that the first parameter to access() may be an array of usernames. func TestAccessFunctionTakesArrayOfUsers(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {access(["foo","bar","baz"], "ginger")}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, AccessMap{"bar": BaseSetOf(t, "ginger"), "baz": BaseSetOf(t, "ginger"), "foo": BaseSetOf(t, "ginger")}, res.Access) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {access(["foo","bar","baz"], "ginger")}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + if assert.NoError(t, err, "MapToChannelsAndAccess failed") { + assert.Equal(t, AccessMap{"bar": BaseSetOf(t, "ginger"), "baz": BaseSetOf(t, "ginger"), "foo": BaseSetOf(t, "ginger")}, res.Access) + } + }) } -// Just verify that the calls to the access() fn show up in the output channel list. +// Verify that the second parameter to access() may be an array of channels. func TestAccessFunctionTakesArrayOfChannels(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {access("lee", ["ginger", "earl_grey", "green"])}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, AccessMap{"lee": BaseSetOf(t, "ginger", "earl_grey", "green")}, res.Access) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {access("lee", ["ginger", "earl_grey", "green"])}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, AccessMap{"lee": BaseSetOf(t, "ginger", "earl_grey", "green")}, res.Access) + }) } func TestAccessFunctionTakesArrayOfChannelsAndUsers(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {access(["lee", "nancy"], ["ginger", "earl_grey", "green"])}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, BaseSetOf(t, "ginger", "earl_grey", "green"), res.Access["lee"]) - assert.Equal(t, BaseSetOf(t, "ginger", "earl_grey", "green"), res.Access["nancy"]) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {access(["lee", "nancy"], ["ginger", "earl_grey", "green"])}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, BaseSetOf(t, "ginger", "earl_grey", "green"), res.Access["lee"]) + assert.Equal(t, BaseSetOf(t, "ginger", "earl_grey", "green"), res.Access["nancy"]) + }) } func TestAccessFunctionTakesEmptyArrayUser(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {access([], ["ginger", "earl grey", "green"])}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, AccessMap{}, res.Access) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {access([], ["ginger", "earl grey", "green"])}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, AccessMap{}, res.Access) + }) } func TestAccessFunctionTakesEmptyArrayChannels(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {access("lee", [])}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, AccessMap{}, res.Access) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {access("lee", [])}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, AccessMap{}, res.Access) + }) } func TestAccessFunctionTakesNullUser(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {access(null, ["ginger", "earl grey", "green"])}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, AccessMap{}, res.Access) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {access(null, ["ginger", "earl grey", "green"])}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, AccessMap{}, res.Access) + }) } func TestAccessFunctionTakesNullChannels(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {access("lee", null)}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, AccessMap{}, res.Access) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {access("lee", null)}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, AccessMap{}, res.Access) + }) } func TestAccessFunctionTakesNonChannelsInArray(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {access("lee", ["ginger", null, 5])}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, AccessMap{"lee": BaseSetOf(t, "ginger")}, res.Access) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {access("lee", ["ginger", null, 5])}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, AccessMap{"lee": BaseSetOf(t, "ginger")}, res.Access) + }) } func TestAccessFunctionTakesUndefinedUser(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {var x = {}; access(x.nothing, ["ginger", "earl grey", "green"])}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, AccessMap{}, res.Access) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {var x = {}; access(x.nothing, ["ginger", "earl grey", "green"])}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, AccessMap{}, res.Access) + }) } // Just verify that the calls to the role() fn show up in the output. (It shares a common // implementation with access(), so most of the above tests also apply to it.) func TestRoleFunction(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {role(["foo","bar","baz"], "role:froods")}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, AccessMap{"bar": BaseSetOf(t, "froods"), "baz": BaseSetOf(t, "froods"), "foo": BaseSetOf(t, "froods")}, res.Roles) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {role(["foo","bar","baz"], "role:froods")}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, AccessMap{"bar": BaseSetOf(t, "froods"), "baz": BaseSetOf(t, "froods"), "foo": BaseSetOf(t, "froods")}, res.Roles) + }) } // Now just make sure the input comes through intact func TestInputParse(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {channel(doc.channel);}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{"channel": "foo"}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, BaseSetOf(t, "foo"), res.Channels) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {channel(doc.channel);}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{"channel": "foo"}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, BaseSetOf(t, "foo"), res.Channels) + }) } // A more realistic example func TestDefaultChannelMapper(t *testing.T) { - testCases := []struct { - mapper *ChannelMapper - name string - }{ - { - mapper: NewChannelMapper(DocChannelsSyncFunction, 0), - name: "explicit_function", - }, - { - mapper: NewChannelMapper(GetDefaultSyncFunction(base.DefaultScope, base.DefaultCollection), 0), - name: "explicit_function", - }, - } - - for _, test := range testCases { - t.Run(test.name, func(t *testing.T) { - res, err := test.mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, BaseSetOf(t, "foo", "bar", "baz"), res.Channels) - - res, err = test.mapper.MapToChannelsAndAccess(parse(`{"x": "y"}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, base.Set{}, res.Channels) - }) - } + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + testCases := []struct { + mapper *ChannelMapper + name string + }{ + { + mapper: NewChannelMapper(vm, DocChannelsSyncFunction, 0), + name: "explicit_function", + }, + { + mapper: NewChannelMapper(vm, GetDefaultSyncFunction(base.DefaultScope, base.DefaultCollection), 0), + name: "explicit_function", + }, + } + + for _, test := range testCases { + t.Run(test.name, func(t *testing.T) { + res, err := test.mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, BaseSetOf(t, "foo", "bar", "baz"), res.Channels) + + res, err = test.mapper.MapToChannelsAndAccess(parse(`{"x": "y"}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, base.Set{}, res.Channels) + }) + } + }) } // Empty/no-op channel mapper fn func TestEmptyChannelMapper(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, base.Set{}, res.Channels) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, base.Set{}, res.Channels) + }) } // channel mapper fn that uses _ underscore JS library func TestChannelMapperUnderscoreLib(t *testing.T) { - underscore.Enable() // It really slows down unit tests (by making otto.New take a lot longer) - defer underscore.Disable() - mapper := NewChannelMapper(`function(doc) {channel(_.first(doc.channels));}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, BaseSetOf(t, "foo"), res.Channels) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {channel(_.first(doc.channels));}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, BaseSetOf(t, "foo"), res.Channels) + }) } // Validation by calling reject() func TestChannelMapperReject(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {reject(403, "bad");}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, base.HTTPErrorf(403, "bad"), res.Rejection) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {reject(403, "bad");}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) + if !assert.NoError(t, err, "MapToChannelsAndAccess failed") { + return + } + assert.Equal(t, base.HTTPErrorf(403, "bad"), res.Rejection) + }) } // Rejection by calling throw() func TestChannelMapperThrow(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {throw({forbidden:"bad"});}`, 0) - res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, base.HTTPErrorf(403, "bad"), res.Rejection) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {throw({forbidden:"bad"});}`, 0) + res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, base.HTTPErrorf(403, "bad"), res.Rejection) + }) } // Test other runtime exception func TestChannelMapperException(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {(nil)[5];}`, 0) - _, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) - assert.True(t, err != nil) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {(nil)[5];}`, 0) + _, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) + assert.True(t, err != nil) + }) } // Test the public API func TestPublicChannelMapper(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {channel(doc.channels);}`, 0) - output, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, BaseSetOf(t, "foo", "bar", "baz"), output.Channels) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {channel(doc.channels);}`, 0) + output, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, BaseSetOf(t, "foo", "bar", "baz"), output.Channels) + }) } // Test the userCtx name parameter func TestCheckUser(t *testing.T) { - mapper := NewChannelMapper(`function(doc, oldDoc) { + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc, oldDoc) { requireUser(doc.owner); }`, 0) - var sally = map[string]interface{}{"name": "sally", "channels": []string{}} - res, err := mapper.MapToChannelsAndAccess(parse(`{"owner": "sally"}`), `{}`, emptyMetaMap(), sally) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) - - var linus = map[string]interface{}{"name": "linus", "channels": []string{}} - res, err = mapper.MapToChannelsAndAccess(parse(`{"owner": "sally"}`), `{}`, emptyMetaMap(), linus) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorWrongUser), res.Rejection) - - res, err = mapper.MapToChannelsAndAccess(parse(`{"owner": "sally"}`), `{}`, emptyMetaMap(), nil) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) + var sally = map[string]interface{}{"name": "sally", "channels": []string{}} + res, err := mapper.MapToChannelsAndAccess(parse(`{"owner": "sally"}`), `{}`, emptyMetaMap(), sally) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + + var linus = map[string]interface{}{"name": "linus", "channels": []string{}} + res, err = mapper.MapToChannelsAndAccess(parse(`{"owner": "sally"}`), `{}`, emptyMetaMap(), linus) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorWrongUser), res.Rejection) + + res, err = mapper.MapToChannelsAndAccess(parse(`{"owner": "sally"}`), `{}`, emptyMetaMap(), nil) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + }) } // Test the userCtx name parameter with a list func TestCheckUserArray(t *testing.T) { - mapper := NewChannelMapper(`function(doc, oldDoc) { + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc, oldDoc) { requireUser(doc.owners); }`, 0) - var sally = map[string]interface{}{"name": "sally", "channels": []string{}} - res, err := mapper.MapToChannelsAndAccess(parse(`{"owners": ["sally", "joe"]}`), `{}`, emptyMetaMap(), sally) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) - - var linus = map[string]interface{}{"name": "linus", "channels": []string{}} - res, err = mapper.MapToChannelsAndAccess(parse(`{"owners": ["sally", "joe"]}`), `{}`, emptyMetaMap(), linus) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorWrongUser), res.Rejection) - - res, err = mapper.MapToChannelsAndAccess(parse(`{"owners": ["sally"]}`), `{}`, emptyMetaMap(), nil) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) + var sally = map[string]interface{}{"name": "sally", "channels": []string{}} + res, err := mapper.MapToChannelsAndAccess(parse(`{"owners": ["sally", "joe"]}`), `{}`, emptyMetaMap(), sally) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + + var linus = map[string]interface{}{"name": "linus", "channels": []string{}} + res, err = mapper.MapToChannelsAndAccess(parse(`{"owners": ["sally", "joe"]}`), `{}`, emptyMetaMap(), linus) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorWrongUser), res.Rejection) + + res, err = mapper.MapToChannelsAndAccess(parse(`{"owners": ["sally"]}`), `{}`, emptyMetaMap(), nil) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + }) } // Test the userCtx role parameter func TestCheckRole(t *testing.T) { - mapper := NewChannelMapper(`function(doc, oldDoc) { + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc, oldDoc) { requireRole(doc.role); }`, 0) - var sally = map[string]interface{}{"name": "sally", "roles": map[string]int{"girl": 1, "5yo": 1}} - res, err := mapper.MapToChannelsAndAccess(parse(`{"role": "girl"}`), `{}`, emptyMetaMap(), sally) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) - - var linus = map[string]interface{}{"name": "linus", "roles": []string{"boy", "musician"}} - res, err = mapper.MapToChannelsAndAccess(parse(`{"role": "girl"}`), `{}`, emptyMetaMap(), linus) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorMissingRole), res.Rejection) - - res, err = mapper.MapToChannelsAndAccess(parse(`{"role": "girl"}`), `{}`, emptyMetaMap(), nil) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) + var sally = map[string]interface{}{"name": "sally", "roles": map[string]int{"girl": 1, "5yo": 1}} + res, err := mapper.MapToChannelsAndAccess(parse(`{"role": "girl"}`), `{}`, emptyMetaMap(), sally) + if assert.NoError(t, err, "MapToChannelsAndAccess failed") { + assert.Equal(t, nil, res.Rejection) + } + + var linus = map[string]interface{}{"name": "linus", "roles": []string{"boy", "musician"}} + res, err = mapper.MapToChannelsAndAccess(parse(`{"role": "girl"}`), `{}`, emptyMetaMap(), linus) + if assert.NoError(t, err, "MapToChannelsAndAccess failed") { + assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorMissingRole), res.Rejection) + } + + res, err = mapper.MapToChannelsAndAccess(parse(`{"role": "girl"}`), `{}`, emptyMetaMap(), nil) + require.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + }) } // Test the userCtx role parameter with a list func TestCheckRoleArray(t *testing.T) { - mapper := NewChannelMapper(`function(doc, oldDoc) { + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc, oldDoc) { requireRole(doc.roles); }`, 0) - var sally = map[string]interface{}{"name": "sally", "roles": map[string]int{"girl": 1, "5yo": 1}} - res, err := mapper.MapToChannelsAndAccess(parse(`{"roles": ["kid","girl"]}`), `{}`, emptyMetaMap(), sally) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) - - var linus = map[string]interface{}{"name": "linus", "roles": map[string]int{"boy": 1, "musician": 1}} - res, err = mapper.MapToChannelsAndAccess(parse(`{"roles": ["girl"]}`), `{}`, emptyMetaMap(), linus) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorMissingRole), res.Rejection) - - res, err = mapper.MapToChannelsAndAccess(parse(`{"roles": ["girl"]}`), `{}`, emptyMetaMap(), nil) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) + var sally = map[string]interface{}{"name": "sally", "roles": map[string]int{"girl": 1, "5yo": 1}} + res, err := mapper.MapToChannelsAndAccess(parse(`{"roles": ["kid","girl"]}`), `{}`, emptyMetaMap(), sally) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + + var linus = map[string]interface{}{"name": "linus", "roles": map[string]int{"boy": 1, "musician": 1}} + res, err = mapper.MapToChannelsAndAccess(parse(`{"roles": ["girl"]}`), `{}`, emptyMetaMap(), linus) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorMissingRole), res.Rejection) + + res, err = mapper.MapToChannelsAndAccess(parse(`{"roles": ["girl"]}`), `{}`, emptyMetaMap(), nil) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + }) } // Test the userCtx.channels parameter func TestCheckAccess(t *testing.T) { - mapper := NewChannelMapper(`function(doc, oldDoc) { + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc, oldDoc) { requireAccess(doc.channel) }`, 0) - var sally = map[string]interface{}{"name": "sally", "roles": []string{"girl", "5yo"}, "channels": []string{"party", "school"}} - res, err := mapper.MapToChannelsAndAccess(parse(`{"channel": "party"}`), `{}`, emptyMetaMap(), sally) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) - - var linus = map[string]interface{}{"name": "linus", "roles": []string{"boy", "musician"}, "channels": []string{"party", "school"}} - res, err = mapper.MapToChannelsAndAccess(parse(`{"channel": "work"}`), `{}`, emptyMetaMap(), linus) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorMissingChannelAccess), res.Rejection) - - res, err = mapper.MapToChannelsAndAccess(parse(`{"channel": "magic"}`), `{}`, emptyMetaMap(), nil) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) + var sally = map[string]interface{}{"name": "sally", "roles": []string{"girl", "5yo"}, "channels": []string{"party", "school"}} + res, err := mapper.MapToChannelsAndAccess(parse(`{"channel": "party"}`), `{}`, emptyMetaMap(), sally) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + + var linus = map[string]interface{}{"name": "linus", "roles": []string{"boy", "musician"}, "channels": []string{"party", "school"}} + res, err = mapper.MapToChannelsAndAccess(parse(`{"channel": "work"}`), `{}`, emptyMetaMap(), linus) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorMissingChannelAccess), res.Rejection) + + res, err = mapper.MapToChannelsAndAccess(parse(`{"channel": "magic"}`), `{}`, emptyMetaMap(), nil) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + }) } // Test the userCtx.channels parameter with a list func TestCheckAccessArray(t *testing.T) { - mapper := NewChannelMapper(`function(doc, oldDoc) { - requireAccess(doc.channels) - }`, 0) - var sally = map[string]interface{}{"name": "sally", "roles": []string{"girl", "5yo"}, "channels": []string{"party", "school"}} - res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["swim","party"]}`), `{}`, emptyMetaMap(), sally) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) - - var linus = map[string]interface{}{"name": "linus", "roles": []string{"boy", "musician"}, "channels": []string{"party", "school"}} - res, err = mapper.MapToChannelsAndAccess(parse(`{"channels": ["work"]}`), `{}`, emptyMetaMap(), linus) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorMissingChannelAccess), res.Rejection) - - res, err = mapper.MapToChannelsAndAccess(parse(`{"channels": ["magic"]}`), `{}`, emptyMetaMap(), nil) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, nil, res.Rejection) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc, oldDoc) { requireAccess(doc.channels) }`, 0) + var sally = map[string]interface{}{"name": "sally", "roles": []string{"girl", "5yo"}, "channels": []string{"party", "school"}} + res, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["swim","party"]}`), `{}`, emptyMetaMap(), sally) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + + var linus = map[string]interface{}{"name": "linus", "roles": []string{"boy", "musician"}, "channels": []string{"party", "school"}} + res, err = mapper.MapToChannelsAndAccess(parse(`{"channels": ["work"]}`), `{}`, emptyMetaMap(), linus) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, base.HTTPErrorf(403, base.SyncFnErrorMissingChannelAccess), res.Rejection) + + res, err = mapper.MapToChannelsAndAccess(parse(`{"channels": ["magic"]}`), `{}`, emptyMetaMap(), nil) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, nil, res.Rejection) + }) } // Test changing the function func TestSetFunction(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {channel(doc.channels);}`, 0) - output, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - require.Equal(t, BaseSetOf(t, "foo", "baz", "bar"), output.Channels) - changed, err := mapper.SetFunction(`function(doc) {channel("all");}`) - assert.True(t, changed, "SetFunction failed") - assert.NoError(t, err, "SetFunction failed") - output, err = mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, BaseSetOf(t, "all"), output.Channels) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {channel(doc.channels);}`, 0) + output, err := mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + require.Equal(t, BaseSetOf(t, "foo", "baz", "bar"), output.Channels) + err = mapper.SetFunction(`function(doc) {channel("all");}`) + assert.NoError(t, err, "SetFunction failed") + output, err = mapper.MapToChannelsAndAccess(parse(`{"channels": ["foo", "bar", "baz"]}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess failed") + assert.Equal(t, BaseSetOf(t, "all"), output.Channels) + }) } // Test that expiry function sets the expiry property func TestExpiryFunction(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {expiry(doc.expiry);}`, 0) - res1, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":100}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error") - assert.Equal(t, uint32(100), *res1.Expiry) - - res2, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":"500"}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error") - assert.Equal(t, uint32(500), *res2.Expiry) - - res_stringDate, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":"2105-01-01T00:00:00.000+00:00"}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error") - assert.Equal(t, uint32(4260211200), *res_stringDate.Expiry) - - // Validate invalid expiry values log warning and don't set expiry - res3, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":"abc"}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry:abc") - assert.True(t, res3.Expiry == nil) - - // Invalid: non-numeric - res4, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":["100", "200"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry as array") - assert.True(t, res4.Expiry == nil) - - // Invalid: negative value - res5, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":-100}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry as negative value") - assert.True(t, res5.Expiry == nil) - - // Invalid - larger than uint32 - res6, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":123456789012345}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry > unit32") - assert.True(t, res6.Expiry == nil) - - // Invalid - non-unix date - resInvalidDate, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":"1805-01-01T00:00:00.000+00:00"}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry:1805-01-01T00:00:00.000+00:00") - assert.True(t, resInvalidDate.Expiry == nil) - - // No expiry specified - res7, err := mapper.MapToChannelsAndAccess(parse(`{"value":5}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry not specified") - assert.True(t, res7.Expiry == nil) -} + var res *ChannelMapperOutput + var err error + + checkExp := func(expected int) { + if assert.NoError(t, err, "MapToChannelsAndAccess error") { + if assert.NotNil(t, res.Expiry) { + assert.Equal(t, uint32(expected), *res.Expiry) + } + } + } + checkNilExp := func() { + if assert.NoError(t, err, "MapToChannelsAndAccess error") { + assert.Nil(t, res.Expiry) + } + } -func TestExpiryFunctionConstantValue(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {expiry(100);}`, 0) - res1, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error") - assert.Equal(t, uint32(100), *res1.Expiry) - - mapper = NewChannelMapper(`function(doc) {expiry("500");}`, 0) - res2, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error") - assert.Equal(t, uint32(500), *res2.Expiry) - - mapper = NewChannelMapper(`function(doc) {expiry("2105-01-01T00:00:00.000+00:00");}`, 0) - res_stringDate, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error") - assert.Equal(t, uint32(4260211200), *res_stringDate.Expiry) - - // Validate invalid expiry values log warning and don't set expiry - mapper = NewChannelMapper(`function(doc) {expiry("abc");}`, 0) - res3, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry:abc") - assert.True(t, res3.Expiry == nil) - - // Invalid: non-numeric - mapper = NewChannelMapper(`function(doc) {expiry(["100", "200"]);}`, 0) - res4, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry as array") - assert.True(t, res4.Expiry == nil) - - // Invalid: negative value - mapper = NewChannelMapper(`function(doc) {expiry(-100);}`, 0) - res5, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry as negative value") - assert.True(t, res5.Expiry == nil) - - // Invalid - larger than uint32 - mapper = NewChannelMapper(`function(doc) {expiry(123456789012345);}`, 0) - res6, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry as > unit32") - assert.True(t, res6.Expiry == nil) - - // Invalid - non-unix date - mapper = NewChannelMapper(`function(doc) {expiry("1805-01-01T00:00:00.000+00:00");}`, 0) - resInvalidDate, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry:1805-01-01T00:00:00.000+00:00") - assert.True(t, resInvalidDate.Expiry == nil) - - // No expiry specified - mapper = NewChannelMapper(`function(doc) {expiry();}`, 0) - res7, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess error for expiry not specified") - assert.True(t, res7.Expiry == nil) -} + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {expiry(doc.expiry);}`, 0) -// Test that expiry function when invoked more than once by sync function -func TestExpiryFunctionMultipleInvocation(t *testing.T) { - mapper := NewChannelMapper(`function(doc) {expiry(doc.expiry); expiry(doc.secondExpiry)}`, 0) - res1, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":100}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, uint32(100), *res1.Expiry) + res, err = mapper.MapToChannelsAndAccess(parse(`{"expiry":100}`), `{}`, emptyMetaMap(), noUser) + checkExp(100) - res2, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":"500"}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess failed") - assert.Equal(t, uint32(500), *res2.Expiry) + res, err = mapper.MapToChannelsAndAccess(parse(`{"expiry":"500"}`), `{}`, emptyMetaMap(), noUser) + checkExp(500) - // Validate invalid expiry values log warning and don't set expiry - res3, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":"abc"}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess filed for expiry:abc") - assert.True(t, res3.Expiry == nil) + res, err = mapper.MapToChannelsAndAccess(parse(`{"expiry":"2105-01-01T00:00:00.000+00:00"}`), `{}`, emptyMetaMap(), noUser) + checkExp(4260211200) - // Invalid: non-numeric - res4, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":["100", "200"]}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess filed for expiry as array") - assert.True(t, res4.Expiry == nil) + // Validate invalid expiry values log warning and don't set expiry + res, err = mapper.MapToChannelsAndAccess(parse(`{"expiry":"abc"}`), `{}`, emptyMetaMap(), noUser) + checkNilExp() - // Invalid: negative value - res5, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":-100}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess filed for expiry as array") - assert.True(t, res5.Expiry == nil) + // Invalid: non-numeric + res, err = mapper.MapToChannelsAndAccess(parse(`{"expiry":["100", "200"]}`), `{}`, emptyMetaMap(), noUser) + checkNilExp() - // Invalid - larger than uint32 - res6, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":123456789012345}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess filed for expiry as array") - assert.True(t, res6.Expiry == nil) + // Invalid: negative value + res, err = mapper.MapToChannelsAndAccess(parse(`{"expiry":-100}`), `{}`, emptyMetaMap(), noUser) + checkNilExp() - // No expiry specified - res7, err := mapper.MapToChannelsAndAccess(parse(`{"value":5}`), `{}`, emptyMetaMap(), noUser) - assert.NoError(t, err, "MapToChannelsAndAccess filed for expiry as array") - assert.True(t, res7.Expiry == nil) -} + // Invalid - larger than uint32 + res, err = mapper.MapToChannelsAndAccess(parse(`{"expiry":123456789012345}`), `{}`, emptyMetaMap(), noUser) + checkNilExp() -func TestMetaMap(t *testing.T) { - mapper := NewChannelMapper(`function(doc, oldDoc, meta) {channel(meta.xattrs.myxattr.channels);}`, 0) + // Invalid - non-unix date + res, err = mapper.MapToChannelsAndAccess(parse(`{"expiry":"1805-01-01T00:00:00.000+00:00"}`), `{}`, emptyMetaMap(), noUser) + checkNilExp() - channels := []string{"chan1", "chan2"} + // No expiry specified + res, err = mapper.MapToChannelsAndAccess(parse(`{"value":5}`), `{}`, emptyMetaMap(), noUser) + checkNilExp() + }) +} - metaMap := map[string]interface{}{ - base.MetaMapXattrsKey: map[string]interface{}{ - "myxattr": map[string]interface{}{ - "channels": channels, - }, - }, +func TestExpiryFunctionConstantValue(t *testing.T) { + cases := []struct { + name string + expiry string + expected any + }{ + {"Integer", `100`, uint32(100)}, + {"Numeric string", `"500"`, uint32(500)}, + {"IS08601", `"2105-01-01T00:00:00.000+00:00"`, uint32(4260211200)}, + {"Invalid string", `"abc"`, nil}, + {"Non-numeric", `["100", "200"]`, nil}, + {"Negative", `-100`, nil}, + {"Too Large", `123456789012345`, nil}, + {"Invalid date format", `"1805-01-01T00:00:00.000+00:00"`, nil}, + {"Nothing", ``, nil}, } - res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, metaMap, noUser) - require.NoError(t, err) - assert.ElementsMatch(t, res.Channels.ToArray(), channels) + for _, c := range cases { + t.Run(c.name, func(t *testing.T) { + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {expiry(`+c.expiry+`);}`, 0) + res1, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), noUser) + assert.NoError(t, err, "MapToChannelsAndAccess error") + if c.expected != nil { + if assert.NotNil(t, res1.Expiry) { + assert.Equal(t, c.expected, *res1.Expiry) + } + } else { + assert.Nil(t, res1.Expiry) + } + }) + }) + } } -func TestNilMetaMap(t *testing.T) { - base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) - mapper := NewChannelMapper(`function(doc, oldDoc, meta) {channel(meta.xattrs.myxattr.val);}`, 0) +// Test that expiry function when invoked more than once by sync function +func TestExpiryFunctionMultipleInvocation(t *testing.T) { + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc) {expiry(doc.expiry); expiry(doc.secondExpiry)}`, 0) + res1, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":100}`), `{}`, emptyMetaMap(), noUser) + if assert.NoError(t, err, "MapToChannelsAndAccess failed") { + if assert.NotNil(t, res1.Expiry) { + assert.Equal(t, uint32(100), *res1.Expiry) + } + } + + res2, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":"500"}`), `{}`, emptyMetaMap(), noUser) + if assert.NoError(t, err, "MapToChannelsAndAccess failed") { + assert.Equal(t, uint32(500), *res2.Expiry) + } + + // Validate invalid expiry values log warning and don't set expiry + res3, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":"abc"}`), `{}`, emptyMetaMap(), noUser) + if assert.NoError(t, err, "MapToChannelsAndAccess filed for expiry:abc") { + assert.True(t, res3.Expiry == nil) + } + + // Invalid: non-numeric + res4, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":["100", "200"]}`), `{}`, emptyMetaMap(), noUser) + if assert.NoError(t, err, "MapToChannelsAndAccess filed for expiry as array") { + assert.True(t, res4.Expiry == nil) + } + + // Invalid: negative value + res5, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":-100}`), `{}`, emptyMetaMap(), noUser) + if assert.NoError(t, err, "MapToChannelsAndAccess filed for expiry as array") { + assert.True(t, res5.Expiry == nil) + } + + // Invalid - larger than uint32 + res6, err := mapper.MapToChannelsAndAccess(parse(`{"expiry":123456789012345}`), `{}`, emptyMetaMap(), noUser) + if assert.NoError(t, err, "MapToChannelsAndAccess filed for expiry as array") { + assert.True(t, res6.Expiry == nil) + } + + // No expiry specified + res7, err := mapper.MapToChannelsAndAccess(parse(`{"value":5}`), `{}`, emptyMetaMap(), noUser) + if assert.NoError(t, err, "MapToChannelsAndAccess filed for expiry as array") { + assert.True(t, res7.Expiry == nil) + } + }) +} - metaMap := map[string]interface{}{ - base.MetaMapXattrsKey: map[string]interface{}{ - "": nil, - }, - } +func TestMetaMap(t *testing.T) { + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc, oldDoc, meta) {channel(meta.xattrs.myxattr.channels);}`, 0) + + channels := []string{"chan1", "chan2"} + attr, _ := json.Marshal(map[string]interface{}{ + "channels": channels, + }) + metaMap := MetaMap{Key: "myxattr", JSONValue: attr} - _, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, metaMap, noUser) - require.Error(t, err) - assert.True(t, err.Error() == "TypeError: Cannot access member 'val' of undefined") + res, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, metaMap, noUser) + require.NoError(t, err) + assert.ElementsMatch(t, res.Channels.ToArray(), channels) + }) } -func TestChangedUsers(t *testing.T) { - a := AccessMap{"alice": BaseSetOf(t, "x", "y"), "bita": BaseSetOf(t, "z"), "claire": BaseSetOf(t, "w")} - b := AccessMap{"alice": BaseSetOf(t, "x", "z"), "bita": BaseSetOf(t, "z"), "diana": BaseSetOf(t, "w")} +func TestNilMetaMap(t *testing.T) { + base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + mapper := NewChannelMapper(vm, `function(doc, oldDoc, meta) {channel(meta.xattrs.myxattr.val);}`, 0) + + metaMap := MetaMap{} - changes := map[string]bool{} - ForChangedUsers(a, b, func(name string) { - changes[name] = true + _, err := mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, metaMap, noUser) + if assert.Error(t, err) { + message := err.Error() + assert.True(t, strings.Contains(message, "TypeError: Cannot read properties of null (reading 'myxattr')") || strings.Contains(message, "TypeError: Cannot access member 'myxattr' of null"), + "Unexpected error message: %s", message) + } }) - assert.Equal(t, map[string]bool{"alice": true, "claire": true, "diana": true}, changes) } func TestCollectionSyncFunction(t *testing.T) { - testCases := []struct { - docBody string - name string - }{ - { - docBody: `{"channels": ["foo", "bar", "baz"]}`, - name: "legacyDocBody", - }, - { - docBody: `{"x": "y"}`, - name: "irrelevantData", - }, - { - docBody: `{"x": "y"}`, - name: "irrelevantData", - }, - } - - for _, test := range testCases { - t.Run(test.name, func(t *testing.T) { - collectionName := "barcollection" - mapper := NewChannelMapper(GetDefaultSyncFunction("fooscope", collectionName), 0) - res, err := mapper.MapToChannelsAndAccess(parse(test.docBody), `{}`, emptyMetaMap(), noUser) - require.NoError(t, err) - require.Equal(t, BaseSetOf(t, collectionName), res.Channels) - }) - } + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + testCases := []struct { + docBody string + name string + }{ + { + docBody: `{"channels": ["foo", "bar", "baz"]}`, + name: "legacyDocBody", + }, + { + docBody: `{"x": "y"}`, + name: "irrelevantData", + }, + { + docBody: `{"x": "y"}`, + name: "irrelevantData", + }, + } + + for _, test := range testCases { + t.Run(test.name, func(t *testing.T) { + collectionName := "barcollection" + mapper := NewChannelMapper(vm, GetDefaultSyncFunction("fooscope", collectionName), 0) + res, err := mapper.MapToChannelsAndAccess(parse(test.docBody), `{}`, emptyMetaMap(), noUser) + require.NoError(t, err) + require.Equal(t, BaseSetOf(t, collectionName), res.Channels) + }) + } + }) } func TestGetDefaultSyncFunction(t *testing.T) { diff --git a/channels/sync_fn_wrapper_modern.js b/channels/sync_fn_wrapper_modern.js new file mode 100644 index 0000000000..34b80c2e5a --- /dev/null +++ b/channels/sync_fn_wrapper_modern.js @@ -0,0 +1,211 @@ +function() { const syncFn = %s; +// (put the interpolated sync fn on line 1 so the line numbers in any syntax error will match) + +// Copyright 2012-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. + +// IMPORTANT: There are currently two versions of this file, supporting different JS versions. +// This is the "modern" one, for use with V8. Any changes should be synced with the other. + + if (typeof(syncFn) !== 'function') { + throw new Error(`code does not compile to a function`); + } else if (syncFn.length < 1 || syncFn.length > 3) { + throw new Error(`sync function must have 1-3 arguments`); + } + + { + /**** Variables used during the call but not visible to the sync fn ****/ + + let gUserCtx; // object with keys .name, .roles, .channels + let gShouldValidate; // if false, 'require...' functions are no-ops + let gResult; // object to be returned, with keys .channels, .access + + + /**** Utility functions ****/ + + // Returns true if `what` is equal to `against` or included in it. + function match(what /*:string | string[]*/, against /*:string*/) { + if (Array.isArray(what)) { + return what.includes(against); + } else { + return (what == against); + } + } + + // Returns true if `what` is a key of `against`, or an array that contains a key of it. + function matchInObject(what /*:string | string[]*/, against /*:object*/) { + if (Array.isArray(what)) { + for (let w of what) { + if (against.hasOwnProperty(w)) return true; + } + return false; + } else { + return against.hasOwnProperty(what); + } + } + + // Returns true if `what` is contained in `against`, + // or an array that contains an item of `against`. + function matchInArray(what /*:string | string[]*/, against /*:string[]*/) { + if (Array.isArray(what)) { + for (let w of what) { + if (against.includes(w)) return true; + } + return false; + } else { + return against.includes(what); + } + } + + // Appends a string or array of strings `what` to an array `list`. + function appendTo(what /*:string | string[]*/, list /*:string[]*/) { + if (typeof(what) === 'string') { + list.push(what) + } else if (Array.isArray(what)) { + for (let c of what) { + appendTo(c, list); + } + } else { + console.warn(`Ignoring non-string channel or role name ${what}`); + } + } + + // Appends `items` (a string or array of strings) to the array `map[user]`. + function _appendForUser(map, user, items) { + if (typeof(user) !== 'string') { + console.warn(`Ignoring non-string username ${user}`); + return; + } + let userAccess = map[user]; + if (userAccess === undefined) { + userAccess = map[user] = []; + } + appendTo(items, userAccess); + } + + // Same as _appendForUser, but `user` can be an array of user names. + function appendForUser(map, user, items) { + if (Array.isArray(user)) { + for (let u of user) + _appendForUser(map, u, items); + } else { + _appendForUser(map, user, items); + } + } + + + /**** Validation functions ****/ + + globalThis.requireAdmin = function() { + if (gShouldValidate) + throw({forbidden: "%s"}); + } + + globalThis.requireUser = function(nameOrNames) { + if (gShouldValidate && !match(nameOrNames, gUserCtx.name)) + throw({forbidden: "%s"}); + } + + globalThis.requireRole = function(roles) { + if (gShouldValidate && !matchInObject(roles, gUserCtx.roles)) + throw({forbidden: "%s"}); + } + + globalThis.requireAccess = function(channels) { + if (gShouldValidate && !matchInArray(channels, gUserCtx.channels)) + throw({forbidden: "%s"}); + } + + + /**** Access grant functions ****/ + + globalThis.channel = function(...channels) { + appendTo(channels, gResult.channels) + } + + globalThis.access = function(user, channels) { + if (gResult.access === undefined) gResult.access = {} + appendForUser(gResult.access, user, channels); + } + + globalThis.role = function(user, roles) { + if (gResult.roles === undefined) gResult.roles = {} + appendForUser(gResult.roles, user, roles); + } + + globalThis.expiry = function(x) { + if (typeof(x) === 'number' || typeof(x) === 'string') + gResult.expiry = x; + } + + globalThis.reject = function(status, message) { + gResult.rejectionStatus = status; + gResult.rejectionMessage = message; + } + + globalThis.log = console.log; + + // For security reasons, prevent scripts from dynamically compiling code: + delete globalThis.eval; + delete globalThis.Function; + + /**** The function that runs the sync function ****/ + + return function (docID, revID, del, newDoc, oldDocJSON, metaKey, metaValueJSON, _userCtx) { + if (docID) { + newDoc._id = docID; + } + if (revID) { + newDoc._rev = revID; + } + if (del) { + newDoc._deleted = true; + } + + let oldDoc = undefined; + let meta = undefined; + if (syncFn.length >= 2) { + if (oldDocJSON) { + oldDoc = JSON.parse(oldDocJSON); + if (docID) { + oldDoc._id = docID; + } + } else { + oldDoc = null; + } + + if (syncFn.length >= 3) { + // Construct meta dict. This is not passed as JSON to avoid the overhead of + // marshaling/unmarshaling in the common case where there's no value. + meta = {xattrs: null}; + if (metaKey != "") { + var metaVal = metaValueJSON ? JSON.parse(metaValueJSON) : null; + meta.xattrs = {[metaKey]: metaVal}; + } + } + } + + gUserCtx = _userCtx; + gShouldValidate = (gUserCtx != null && gUserCtx.name != null); + gResult = { channels: [] }; + + try { + syncFn(newDoc, oldDoc, meta); + } catch(x) { + if (x.forbidden) + reject(403, x.forbidden); + else if (x.unauthorized) + reject(401, x.unauthorized); + else + throw(x); + } + + return JSON.stringify(gResult); + } + } +}() diff --git a/channels/sync_fn_wrapper_older.js b/channels/sync_fn_wrapper_older.js new file mode 100644 index 0000000000..31d1d148cc --- /dev/null +++ b/channels/sync_fn_wrapper_older.js @@ -0,0 +1,218 @@ +function() { var syncFn = %s; +// (put the interpolated sync fn on line 1 so the line numbers in any syntax error will match) + +// Copyright 2012-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. + +// IMPORTANT: There are currently two versions of this file, supporting different JS versions. +// This is the "older" one, for use with Otto. Any changes should be synced with the other. + + if (typeof(syncFn) !== 'function') { + throw new Error('code does not compile to a function'); + } else if (syncFn.length < 1 || syncFn.length > 3) { + throw new Error('sync function must have 1-3 arguments'); + } + + // Declare functions that will be available to the sync fn: + var requireAdmin, requireUser, requireRole, requireAccess; + var channel, access, role, expiry, reject; + var log = console.log; + + { + /**** Variables used during the call but not visible to the sync fn ****/ + + var gUserCtx; // object with keys .name, .roles, .channels + var gShouldValidate; // if false, 'require...' functions are no-ops + var gResult; // object to be returned, with keys .channels, .access + + + /**** Utility functions ****/ + + // Returns true if 'what' is equal to 'against' or included in it. + function match(what /*:string | string[]*/, against /*:string*/) { + if (Array.isArray(what)) { + return _.contains(what, against); + } else { + return (what == against); + } + } + + // Returns true if 'what' is a key of 'against', or an array that contains a key of it. + function matchInObject(what /*:string | string[]*/, against /*:object*/) { + if (Array.isArray(what)) { + for (var i = 0; i < what.length; ++i) { + if (against.hasOwnProperty(what[i])) return true; + } + return false; + } else { + return against.hasOwnProperty(what); + } + } + + // Returns true if 'what' is contained in 'against', + // or an array that contains an item of 'against'. + function matchInArray(what /*:string | string[]*/, against /*:string[]*/) { + if (Array.isArray(what)) { + for (var i = 0; i < what.length; ++i) { + if (_.contains(against, what[i])) return true; + } + return false; + } else { + return _.contains(against, what); + } + } + + // Appends a string or array of strings 'what' to an array 'list'. + function appendTo(what /*:string | string[]*/, list /*:string[]*/) { + if (typeof(what) === 'string') { + list.push(what) + } else if (Array.isArray(what)) { + for (var i = 0; i < what.length; ++i) { + appendTo(what[i], list); + } + } else { + console.warn('Ignoring non-string channel or role name ' + what); + } + } + + // Appends 'items' (a string or array of strings) to the array 'map[user]'. + function _appendForUser(map, user, items) { + if (typeof(user) !== 'string') { + console.warn('Ignoring non-string username ' + user); + return; + } + var userAccess = map[user]; + if (userAccess === undefined) { + userAccess = map[user] = []; + } + appendTo(items, userAccess); + } + + // Same as _appendForUser, but 'user' can be an array of user names. + function appendForUser(map, user, items) { + if (Array.isArray(user)) { + for (var i = 0; i < user.length; ++i) { + _appendForUser(map, user[i], items); + } + } else { + _appendForUser(map, user, items); + } + } + + + /**** Validation functions ****/ + + requireAdmin = function() { + if (gShouldValidate) + throw({forbidden: "%s"}); + } + + requireUser = function(nameOrNames) { + if (gShouldValidate && !match(nameOrNames, gUserCtx.name)) + throw({forbidden: "%s"}); + } + + requireRole = function(roles) { + if (gShouldValidate && !matchInObject(roles, gUserCtx.roles)) + throw({forbidden: "%s"}); + } + + requireAccess = function(channels) { + if (gShouldValidate && !matchInArray(channels, gUserCtx.channels)) + throw({forbidden: "%s"}); + } + + + /**** Access grant functions ****/ + + channel = function() { + appendTo(_.toArray(arguments), gResult.channels) + } + + access = function(user, channels) { + if (gResult.access === undefined) gResult.access = {} + appendForUser(gResult.access, user, channels); + } + + role = function(user, roles) { + if (gResult.roles === undefined) gResult.roles = {} + appendForUser(gResult.roles, user, roles); + } + + expiry = function(x) { + if (typeof(x) === 'number' || typeof(x) === 'string') + gResult.expiry = x; + } + + reject = function(status, message) { + gResult.rejectionStatus = status; + gResult.rejectionMessage = message; + } + + log = console.log; + + // For security reasons, prevent scripts from dynamically compiling code: + delete eval; + delete Function; + + /**** The function that runs the sync function ****/ + + return function (docID, revID, del, newDoc, oldDocJSON, metaKey, metaValueJSON, _userCtx) { + if (docID) { + newDoc._id = docID; + } + if (revID) { + newDoc._rev = revID; + } + if (del) { + newDoc._deleted = true; + } + + var oldDoc = undefined; + var meta = undefined; + if (syncFn.length >= 2) { + if (oldDocJSON) { + oldDoc = JSON.parse(oldDocJSON); + if (docID) { + oldDoc._id = docID; + } + } else { + oldDoc = null; + } + + if (syncFn.length >= 3) { + // Construct meta dict. This is not passed as JSON to avoid the overhead of + // marshaling/unmarshaling in the common case where there's no value. + meta = {xattrs: null}; + if (metaKey != "") { + var metaVal = metaValueJSON ? JSON.parse(metaValueJSON) : null; + meta.xattrs = {}; + meta.xattrs[metaKey] = metaVal; + } + } + } + + gUserCtx = _userCtx; + gShouldValidate = (gUserCtx != null && gUserCtx.name != null); + gResult = { channels: [] }; + + try { + syncFn(newDoc, oldDoc, meta); + } catch(x) { + if (x.forbidden) + reject(403, x.forbidden); + else if (x.unauthorized) + reject(401, x.unauthorized); + else + throw(x); + } + + return JSON.stringify(gResult); + } + } +}() diff --git a/channels/sync_runner.go b/channels/sync_runner.go deleted file mode 100644 index 0c45437ff7..0000000000 --- a/channels/sync_runner.go +++ /dev/null @@ -1,282 +0,0 @@ -// Copyright 2012-Present Couchbase, Inc. -// -// Use of this software is governed by the Business Source License included -// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified -// in that file, in accordance with the Business Source License, use of this -// software will be governed by the Apache License, Version 2.0, included in -// the file licenses/APL2.txt. - -package channels - -import ( - "context" - "fmt" - "strings" - "time" - - sgbucket "github.com/couchbase/sg-bucket" - "github.com/couchbase/sync_gateway/base" - "github.com/robertkrimen/otto" - _ "github.com/robertkrimen/otto/underscore" -) - -// Prefix used to identify roles in access grants -const RoleAccessPrefix = "role:" - -const funcWrapper = ` - function() { - - var realUserCtx, shouldValidate; - var syncFn = %s; - - function makeArray(maybeArray) { - if (Array.isArray(maybeArray)) { - return maybeArray; - } else { - return [maybeArray]; - } - } - - function inArray(string, array) { - return array.indexOf(string) != -1; - } - - function anyInArray(any, array) { - for (var i = 0; i < any.length; ++i) { - if (inArray(any[i], array)) - return true; - } - return false; - } - - function anyKeysInArray(any, array) { - for (var key in any) { - if (inArray(key, array)) - return true; - } - return false; - } - - function requireAdmin() { - if (shouldValidate) - throw({forbidden: "%s"}); - } - - function requireUser(names) { - if (!shouldValidate) return; - names = makeArray(names); - if (!inArray(realUserCtx.name, names)) - throw({forbidden: "%s"}); - } - - function requireRole(roles) { - if (!shouldValidate) return; - roles = makeArray(roles); - if (!anyKeysInArray(realUserCtx.roles, roles)) - throw({forbidden: "%s"}); - } - - function requireAccess(channels) { - if (!shouldValidate) return; - channels = makeArray(channels); - if (!anyInArray(realUserCtx.channels, channels)) - throw({forbidden: "%s"}); - } - - return function (newDoc, oldDoc, meta, _realUserCtx) { - realUserCtx = _realUserCtx; - - if (oldDoc) { - oldDoc._id = newDoc._id; - } - - // Proxy userCtx that allows queries but not direct access to user/roles: - shouldValidate = (realUserCtx != null && realUserCtx.name != null); - - try { - syncFn(newDoc, oldDoc, meta); - } catch(x) { - if (x.forbidden) - reject(403, x.forbidden); - else if (x.unauthorized) - reject(401, x.unauthorized); - else - throw(x); - } - } - }()` - -// An object that runs a specific JS sync() function. Not thread-safe! -type SyncRunner struct { - sgbucket.JSRunner // "Superclass" - output *ChannelMapperOutput // Results being accumulated while the JS fn runs - channels []string - access map[string][]string // channels granted to users via access() callback - roles map[string][]string // roles granted to users via role() callback - expiry *uint32 // document expiry (in seconds) specified via expiry() callback -} - -func NewSyncRunner(funcSource string, timeout time.Duration) (*SyncRunner, error) { - ctx := context.Background() - funcSource = wrappedFuncSource(funcSource) - runner := &SyncRunner{} - err := runner.InitWithLogging(funcSource, timeout, - func(s string) { base.ErrorfCtx(ctx, base.KeyJavascript.String()+": Sync %s", base.UD(s)) }, - func(s string) { base.InfofCtx(ctx, base.KeyJavascript, "Sync %s", base.UD(s)) }) - if err != nil { - return nil, err - } - - // Implementation of the 'channel()' callback: - runner.DefineNativeFunction("channel", func(call otto.FunctionCall) otto.Value { - for _, arg := range call.ArgumentList { - if strings := ottoValueToStringArray(arg); strings != nil { - runner.channels = append(runner.channels, strings...) - } - } - return otto.UndefinedValue() - }) - - // Implementation of the 'access()' callback: - runner.DefineNativeFunction("access", func(call otto.FunctionCall) otto.Value { - return runner.addValueForUser(call.Argument(0), call.Argument(1), runner.access) - }) - - // Implementation of the 'role()' callback: - runner.DefineNativeFunction("role", func(call otto.FunctionCall) otto.Value { - return runner.addValueForUser(call.Argument(0), call.Argument(1), runner.roles) - }) - - // Implementation of the 'reject()' callback: - runner.DefineNativeFunction("reject", func(call otto.FunctionCall) otto.Value { - if runner.output.Rejection == nil { - if status, err := call.Argument(0).ToInteger(); err == nil && status >= 400 { - var message string - if len(call.ArgumentList) > 1 { - message = call.Argument(1).String() - } - runner.output.Rejection = base.HTTPErrorf(int(status), message) - } - } - return otto.UndefinedValue() - }) - - // Implementation of the 'expiry()' callback: - runner.DefineNativeFunction("expiry", func(call otto.FunctionCall) otto.Value { - if len(call.ArgumentList) > 0 { - rawExpiry, exportErr := call.Argument(0).Export() - if exportErr != nil { - base.WarnfCtx(ctx, "SyncRunner: Unable to export expiry parameter: %v Error: %s", call.Argument(0), exportErr) - return otto.UndefinedValue() - } - - // Called expiry with null/undefined value - ignore - if rawExpiry == nil || call.Argument(0).IsUndefined() { - return otto.UndefinedValue() - } - - expiry, reflectErr := base.ReflectExpiry(rawExpiry) - if reflectErr != nil { - base.WarnfCtx(ctx, "SyncRunner: Invalid value passed to expiry(). Value:%+v ", call.Argument(0)) - return otto.UndefinedValue() - } - - runner.expiry = expiry - } - return otto.UndefinedValue() - }) - - runner.Before = func() { - runner.output = &ChannelMapperOutput{} - runner.channels = []string{} - runner.access = map[string][]string{} - runner.roles = map[string][]string{} - runner.expiry = nil - } - runner.After = func(result otto.Value, err error) (interface{}, error) { - output := runner.output - runner.output = nil - if err == nil { - output.Channels, err = SetFromArray(runner.channels, ExpandStar) - if err == nil { - output.Access, err = compileAccessMap(runner.access, "") - if err == nil { - output.Roles, err = compileAccessMap(runner.roles, RoleAccessPrefix) - } - } - if runner.expiry != nil { - output.Expiry = runner.expiry - } - } - return output, err - } - return runner, nil -} - -func (runner *SyncRunner) SetFunction(funcSource string) (bool, error) { - funcSource = wrappedFuncSource(funcSource) - return runner.JSRunner.SetFunction(funcSource) -} - -// Common implementation of 'access()' and 'role()' callbacks -func (runner *SyncRunner) addValueForUser(user otto.Value, value otto.Value, mapping map[string][]string) otto.Value { - valueStrings := ottoValueToStringArray(value) - if len(valueStrings) > 0 { - for _, name := range ottoValueToStringArray(user) { - mapping[name] = append(mapping[name], valueStrings...) - } - } - return otto.UndefinedValue() -} - -func compileAccessMap(input map[string][]string, prefix string) (AccessMap, error) { - access := make(AccessMap, len(input)) - for name, values := range input { - // If a prefix is specified, strip it from all values or return error if missing: - if prefix != "" { - for i, value := range values { - if strings.HasPrefix(value, prefix) { - values[i] = value[len(prefix):] - } else { - return nil, base.RedactErrorf("Value %q does not begin with %q", base.UD(value), base.UD(prefix)) - } - } - } - var err error - if access[name], err = SetFromArray(values, RemoveStar); err != nil { - return nil, err - } - } - return access, nil -} - -// If the provided principal name (in access grant format) is a role, returns the role name without prefix -func AccessNameToPrincipalName(accessPrincipalName string) (principalName string, isRole bool) { - if strings.HasPrefix(accessPrincipalName, RoleAccessPrefix) { - return accessPrincipalName[len(RoleAccessPrefix):], true - } - return accessPrincipalName, false -} - -// Converts a JS string or array into a Go string array. -func ottoValueToStringArray(value otto.Value) []string { - nativeValue, _ := value.Export() - - result, nonStrings := base.ValueToStringArray(nativeValue) - - if !value.IsNull() && !value.IsUndefined() && nonStrings != nil { - base.WarnfCtx(context.Background(), "Channel names must be string values only. Ignoring non-string channels: %s", base.UD(nonStrings)) - } - return result -} - -func wrappedFuncSource(funcSource string) string { - return fmt.Sprintf( - funcWrapper, - funcSource, - base.SyncFnErrorAdminRequired, - base.SyncFnErrorWrongUser, - base.SyncFnErrorMissingRole, - base.SyncFnErrorMissingChannelAccess, - ) -} diff --git a/channels/sync_runner_test.go b/channels/sync_runner_test.go index 4c11805141..fa988a9389 100644 --- a/channels/sync_runner_test.go +++ b/channels/sync_runner_test.go @@ -13,75 +13,83 @@ package channels import ( "net/http" "testing" + "time" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" ) func TestRequireUser(t *testing.T) { const funcSource = `function(doc, oldDoc) { requireUser(oldDoc._names) }` - runner, err := NewSyncRunner(funcSource, 0) - require.NoError(t, err) - var result interface{} - result, _ = runner.Call(parse(`{}`), parse(`{"_names": "alpha"}`), emptyMetaMap(), parse(`{"name": "alpha"}`)) - assertNotRejected(t, result) - result, _ = runner.Call(parse(`{}`), parse(`{"_names": ["beta", "gamma"]}`), emptyMetaMap(), parse(`{"name": "beta"}`)) - assertNotRejected(t, result) - result, _ = runner.Call(parse(`{}`), parse(`{"_names": ["delta"]}`), emptyMetaMap(), parse(`{"name": "beta"}`)) - assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorWrongUser)) + withChannelMapper(t, funcSource, 0, func(mapper *ChannelMapper) { + var result interface{} + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{"_names": "alpha"}`, emptyMetaMap(), parse(`{"name": "alpha"}`)) + assertNotRejected(t, result) + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{"_names": ["beta", "gamma"]}`, emptyMetaMap(), parse(`{"name": "beta"}`)) + assertNotRejected(t, result) + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{"_names": ["delta"]}`, emptyMetaMap(), parse(`{"name": "beta"}`)) + assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorWrongUser)) + }) } func TestRequireRole(t *testing.T) { const funcSource = `function(doc, oldDoc) { requireRole(oldDoc._roles) }` - runner, err := NewSyncRunner(funcSource, 0) - require.NoError(t, err) - var result interface{} - result, _ = runner.Call(parse(`{}`), parse(`{"_roles": ["alpha"]}`), emptyMetaMap(), parse(`{"name": "", "roles": {"alpha":""}}`)) - assertNotRejected(t, result) - result, _ = runner.Call(parse(`{}`), parse(`{"_roles": ["beta", "gamma"]}`), emptyMetaMap(), parse(`{"name": "", "roles": {"beta": ""}}`)) - assertNotRejected(t, result) - result, _ = runner.Call(parse(`{}`), parse(`{"_roles": ["delta"]}`), emptyMetaMap(), parse(`{"name": "", "roles": {"beta":""}}`)) - assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorMissingRole)) + withChannelMapper(t, funcSource, 0, func(mapper *ChannelMapper) { + var result interface{} + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{"_roles": ["alpha"]}`, emptyMetaMap(), parse(`{"name": "", "roles": {"alpha":""}}`)) + assertNotRejected(t, result) + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{"_roles": ["beta", "gamma"]}`, emptyMetaMap(), parse(`{"name": "", "roles": {"beta": ""}}`)) + assertNotRejected(t, result) + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{"_roles": ["delta"]}`, emptyMetaMap(), parse(`{"name": "", "roles": {"beta":""}}`)) + assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorMissingRole)) + }) } func TestRequireAccess(t *testing.T) { const funcSource = `function(doc, oldDoc) { requireAccess(oldDoc._access) }` - runner, err := NewSyncRunner(funcSource, 0) - require.NoError(t, err) - var result interface{} - result, _ = runner.Call(parse(`{}`), parse(`{"_access": ["alpha"]}`), emptyMetaMap(), parse(`{"name": "", "channels": ["alpha"]}`)) - assertNotRejected(t, result) - result, _ = runner.Call(parse(`{}`), parse(`{"_access": ["beta", "gamma"]}`), emptyMetaMap(), parse(`{"name": "", "channels": ["beta"]}`)) - assertNotRejected(t, result) - result, _ = runner.Call(parse(`{}`), parse(`{"_access": ["delta"]}`), emptyMetaMap(), parse(`{"name": "", "channels": ["beta"]}`)) - assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorMissingChannelAccess)) + withChannelMapper(t, funcSource, 0, func(mapper *ChannelMapper) { + var result interface{} + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{"_access": ["alpha"]}`, emptyMetaMap(), parse(`{"name": "", "channels": ["alpha"]}`)) + assertNotRejected(t, result) + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{"_access": ["beta", "gamma"]}`, emptyMetaMap(), parse(`{"name": "", "channels": ["beta"]}`)) + assertNotRejected(t, result) + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{"_access": ["delta"]}`, emptyMetaMap(), parse(`{"name": "", "channels": ["beta"]}`)) + assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorMissingChannelAccess)) + }) } func TestRequireAdmin(t *testing.T) { const funcSource = `function(doc, oldDoc) { requireAdmin() }` - runner, err := NewSyncRunner(funcSource, 0) - require.NoError(t, err) - var result interface{} - result, _ = runner.Call(parse(`{}`), parse(`{}`), emptyMetaMap(), parse(`{}`)) - assertNotRejected(t, result) - result, _ = runner.Call(parse(`{}`), parse(`{}`), emptyMetaMap(), parse(`{"name": ""}`)) - assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorAdminRequired)) - result, _ = runner.Call(parse(`{}`), parse(`{}`), emptyMetaMap(), parse(`{"name": "GUEST"}`)) - assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorAdminRequired)) - result, _ = runner.Call(parse(`{}`), parse(`{}`), emptyMetaMap(), parse(`{"name": "beta"}`)) - assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorAdminRequired)) + withChannelMapper(t, funcSource, 0, func(mapper *ChannelMapper) { + var result interface{} + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), parse(`{}`)) + assertNotRejected(t, result) + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), parse(`{"name": ""}`)) + assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorAdminRequired)) + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), parse(`{"name": "GUEST"}`)) + assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorAdminRequired)) + result, _ = mapper.MapToChannelsAndAccess(parse(`{}`), `{}`, emptyMetaMap(), parse(`{"name": "beta"}`)) + assertRejected(t, result, base.HTTPErrorf(http.StatusForbidden, base.SyncFnErrorAdminRequired)) + }) } // Helpers -func assertRejected(t *testing.T, result interface{}, err *base.HTTPError) { + +func withChannelMapper(t *testing.T, syncFn string, timeout time.Duration, fn func(*ChannelMapper)) { + js.TestWithVMPools(t, 1, func(t *testing.T, pool *js.VMPool) { + mapper := NewChannelMapper(pool, syncFn, timeout) + fn(mapper) + }) + +} + +func assertRejected(t *testing.T, result interface{}, err *base.HTTPError) bool { r, ok := result.(*ChannelMapperOutput) - assert.True(t, ok) - assert.Equal(t, r.Rejection, err) + return assert.True(t, ok) && assert.NotNil(t, r) && assert.Equal(t, r.Rejection, err) } -func assertNotRejected(t *testing.T, result interface{}) { +func assertNotRejected(t *testing.T, result interface{}) bool { r, ok := result.(*ChannelMapperOutput) - assert.True(t, ok) - assert.NoError(t, r.Rejection) + return assert.True(t, ok) && assert.NotNil(t, r) && assert.NoError(t, r.Rejection) } diff --git a/db/access_test.go b/db/access_test.go index 79013f1bdb..6e8c22ffdd 100644 --- a/db/access_test.go +++ b/db/access_test.go @@ -34,7 +34,7 @@ func TestDynamicChannelGrant(t *testing.T) { channel(doc.channel) } }` - dbCollection.ChannelMapper = channels.NewChannelMapper(syncFn, db.Options.JavascriptTimeout) + dbCollection.ChannelMapper = channels.NewChannelMapper(&db.JS, syncFn, db.Options.JavascriptTimeout) a := dbCollection.Authenticator(ctx) user, err := a.NewUser("user1", "letmein", nil) diff --git a/db/attachment_compaction.go b/db/attachment_compaction.go index d0e565d0ec..cd5fb914bf 100644 --- a/db/attachment_compaction.go +++ b/db/attachment_compaction.go @@ -29,7 +29,7 @@ const ( CleanupPhase = "cleanup" ) -func attachmentCompactMarkPhase(ctx context.Context, dataStore base.DataStore, collectionID uint32, db *Database, compactionID string, terminator *base.SafeTerminator, markedAttachmentCount *base.AtomicInt) (count int64, vbUUIDs []uint64, err error) { +func attachmentCompactMarkPhase(ctx context.Context, dataStore base.DataStore, collectionID uint32, db *Database, compactionID string, terminator *base.SafeTerminator, markedAttachmentCount *base.AtomicInt) (count int64, vbUUIDs []uint64, checkpointPrefix string, err error) { base.InfofCtx(ctx, base.KeyAll, "Starting first phase of attachment compaction (mark phase) with compactionID: %q", compactionID) compactionLoggingID := "Compaction Mark: " + compactionID @@ -131,32 +131,30 @@ func attachmentCompactMarkPhase(ctx context.Context, dataStore base.DataStore, c clientOptions, err := getCompactionDCPClientOptions(collectionID, db.Options.GroupID, db.MetadataKeys.DCPCheckpointPrefix(db.Options.GroupID)) if err != nil { - return 0, nil, err + return 0, nil, "", err } base.InfofCtx(ctx, base.KeyAll, "[%s] Starting DCP feed for mark phase of attachment compaction", compactionLoggingID) - dcpFeedKey := generateCompactionDCPStreamName(compactionID, MarkPhase) - if err != nil { - return 0, nil, err - } + dcpFeedKey := GenerateCompactionDCPStreamName(compactionID, MarkPhase) bucket, err := base.AsGocbV2Bucket(db.Bucket) if err != nil { - return 0, nil, err + return 0, nil, "", err } dcpClient, err := base.NewDCPClient(dcpFeedKey, callback, *clientOptions, bucket) if err != nil { base.WarnfCtx(ctx, "[%s] Failed to create attachment compaction DCP client! %v", compactionLoggingID, err) - return 0, nil, err + return 0, nil, "", err } + metadataKeyPrefix := dcpClient.GetMetadataKeyPrefix() doneChan, err := dcpClient.Start() if err != nil { base.WarnfCtx(ctx, "[%s] Failed to start attachment compaction DCP feed! %v", compactionLoggingID, err) _ = dcpClient.Close() - return 0, nil, err + return 0, nil, metadataKeyPrefix, err } base.DebugfCtx(ctx, base.KeyAll, "[%s] DCP feed started.", compactionLoggingID) @@ -165,27 +163,27 @@ func attachmentCompactMarkPhase(ctx context.Context, dataStore base.DataStore, c base.InfofCtx(ctx, base.KeyAll, "[%s] Mark phase of attachment compaction completed. Marked %d attachments", compactionLoggingID, markedAttachmentCount.Value()) err = dcpClient.Close() if markProcessFailureErr != nil { - return markedAttachmentCount.Value(), nil, markProcessFailureErr + return markedAttachmentCount.Value(), nil, metadataKeyPrefix, markProcessFailureErr } case <-terminator.Done(): base.DebugfCtx(ctx, base.KeyAll, "[%s] Terminator closed. Stopping mark phase.", compactionLoggingID) err = dcpClient.Close() if markProcessFailureErr != nil { - return markedAttachmentCount.Value(), nil, markProcessFailureErr + return markedAttachmentCount.Value(), nil, metadataKeyPrefix, markProcessFailureErr } if err != nil { - return markedAttachmentCount.Value(), base.GetVBUUIDs(dcpClient.GetMetadata()), err + return markedAttachmentCount.Value(), base.GetVBUUIDs(dcpClient.GetMetadata()), metadataKeyPrefix, err } err = <-doneChan if err != nil { - return markedAttachmentCount.Value(), base.GetVBUUIDs(dcpClient.GetMetadata()), err + return markedAttachmentCount.Value(), base.GetVBUUIDs(dcpClient.GetMetadata()), metadataKeyPrefix, err } base.InfofCtx(ctx, base.KeyAll, "[%s] Mark phase of attachment compaction was terminated. Marked %d attachments", compactionLoggingID, markedAttachmentCount.Value()) } - return markedAttachmentCount.Value(), base.GetVBUUIDs(dcpClient.GetMetadata()), err + return markedAttachmentCount.Value(), base.GetVBUUIDs(dcpClient.GetMetadata()), metadataKeyPrefix, err } // AttachmentsMetaMap struct is a very minimal struct to unmarshal into when getting attachments from bodies @@ -363,7 +361,7 @@ func attachmentCompactSweepPhase(ctx context.Context, dataStore base.DataStore, } clientOptions.InitialMetadata = base.BuildDCPMetadataSliceFromVBUUIDs(vbUUIDs) - dcpFeedKey := generateCompactionDCPStreamName(compactionID, SweepPhase) + dcpFeedKey := GenerateCompactionDCPStreamName(compactionID, SweepPhase) bucket, err := base.AsGocbV2Bucket(db.Bucket) if err != nil { @@ -408,7 +406,7 @@ func attachmentCompactSweepPhase(ctx context.Context, dataStore base.DataStore, return purgedAttachmentCount.Value(), err } -func attachmentCompactCleanupPhase(ctx context.Context, dataStore base.DataStore, collectionID uint32, db *Database, compactionID string, vbUUIDs []uint64, terminator *base.SafeTerminator) error { +func attachmentCompactCleanupPhase(ctx context.Context, dataStore base.DataStore, collectionID uint32, db *Database, compactionID string, vbUUIDs []uint64, terminator *base.SafeTerminator) (string, error) { base.InfofCtx(ctx, base.KeyAll, "Starting third phase of attachment compaction (cleanup phase) with compactionID: %q", compactionID) compactionLoggingID := "Compaction Cleanup: " + compactionID @@ -495,31 +493,32 @@ func attachmentCompactCleanupPhase(ctx context.Context, dataStore base.DataStore clientOptions, err := getCompactionDCPClientOptions(collectionID, db.Options.GroupID, db.MetadataKeys.DCPCheckpointPrefix(db.Options.GroupID)) if err != nil { - return err + return "", err } clientOptions.InitialMetadata = base.BuildDCPMetadataSliceFromVBUUIDs(vbUUIDs) base.InfofCtx(ctx, base.KeyAll, "[%s] Starting DCP feed for cleanup phase of attachment compaction", compactionLoggingID) - dcpFeedKey := generateCompactionDCPStreamName(compactionID, CleanupPhase) + dcpFeedKey := GenerateCompactionDCPStreamName(compactionID, CleanupPhase) bucket, err := base.AsGocbV2Bucket(db.Bucket) if err != nil { - return err + return "", err } dcpClient, err := base.NewDCPClient(dcpFeedKey, callback, *clientOptions, bucket) if err != nil { base.WarnfCtx(ctx, "[%s] Failed to create attachment compaction DCP client! %v", compactionLoggingID, err) - return err + return "", err } + metadataKeyPrefix := dcpClient.GetMetadataKeyPrefix() doneChan, err := dcpClient.Start() if err != nil { base.WarnfCtx(ctx, "[%s] Failed to start attachment compaction DCP feed! %v", compactionLoggingID, err) // simplify close in CBG-2234 _ = dcpClient.Close() - return err + return metadataKeyPrefix, err } select { @@ -532,18 +531,18 @@ func attachmentCompactCleanupPhase(ctx context.Context, dataStore base.DataStore err = dcpClient.Close() if err != nil { base.WarnfCtx(ctx, "[%s] Failed to close attachment compaction DCP client! %v", compactionLoggingID, err) - return err + return metadataKeyPrefix, err } err = <-doneChan if err != nil { - return err + return metadataKeyPrefix, err } base.InfofCtx(ctx, base.KeyAll, "[%s] Cleanup phase of attachment compaction was terminated", compactionLoggingID) } - return err + return metadataKeyPrefix, err } // getCompactionIDSubDocPath is just a tiny helper func that just concatenates the subdoc path we're using to store @@ -566,7 +565,7 @@ func getCompactionDCPClientOptions(collectionID uint32, groupID string, prefix s } -func generateCompactionDCPStreamName(compactionID, compactionAction string) string { +func GenerateCompactionDCPStreamName(compactionID, compactionAction string) string { return fmt.Sprintf( "sg-%v:att_compaction:%v_%v", base.ProductAPIVersion, diff --git a/db/attachment_compaction_test.go b/db/attachment_compaction_test.go index 17a00bc56a..be96483a22 100644 --- a/db/attachment_compaction_test.go +++ b/db/attachment_compaction_test.go @@ -18,6 +18,7 @@ import ( "testing" "time" + "github.com/couchbase/gocbcore/v10" "github.com/couchbase/sync_gateway/base" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -60,7 +61,7 @@ func TestAttachmentMark(t *testing.T) { attKeys = append(attKeys, createDocWithInBodyAttachment(t, ctx, "inBodyDoc", []byte(`{}`), "attForInBodyRef", []byte(`{"val": "inBodyAtt"}`), databaseCollection)) terminator := base.NewSafeTerminator() - attachmentsMarked, _, err := attachmentCompactMarkPhase(ctx, dataStore, collectionID, testDb, t.Name(), terminator, &base.AtomicInt{}) + attachmentsMarked, _, _, err := attachmentCompactMarkPhase(ctx, dataStore, collectionID, testDb, t.Name(), terminator, &base.AtomicInt{}) assert.NoError(t, err) assert.Equal(t, int64(13), attachmentsMarked) @@ -196,7 +197,7 @@ func TestAttachmentCleanup(t *testing.T) { } terminator := base.NewSafeTerminator() - err := attachmentCompactCleanupPhase(ctx, dataStore, collectionID, testDb, t.Name(), nil, terminator) + _, err := attachmentCompactCleanupPhase(ctx, dataStore, collectionID, testDb, t.Name(), nil, terminator) assert.NoError(t, err) for _, docID := range singleMarkedAttIDs { @@ -234,6 +235,90 @@ func TestAttachmentCleanup(t *testing.T) { } +func TestAttachmentCleanupRollback(t *testing.T) { + if base.UnitTestUrlIsWalrus() { + t.Skip("This test only works against Couchbase Server since it requires DCP") + } + base.SetUpTestLogging(t, base.LevelInfo, base.KeyAll) + dbcOptions := DatabaseContextOptions{ + Scopes: GetScopesOptionsDefaultCollectionOnly(t), + } + testDb, ctx := SetupTestDBWithOptions(t, dbcOptions) + defer testDb.Close(ctx) + + var garbageVBUUID gocbcore.VbUUID = 1234 + collection := GetSingleDatabaseCollection(t, testDb.DatabaseContext) + dataStore := collection.dataStore + collectionID := collection.GetCollectionID() + + makeMarkedDoc := func(docid string, compactID string) { + err := dataStore.SetRaw(docid, 0, nil, []byte("{}")) + assert.NoError(t, err) + _, err = dataStore.SetXattr(docid, getCompactionIDSubDocPath(compactID), []byte(strconv.Itoa(int(time.Now().Unix())))) + assert.NoError(t, err) + } + + // create some marked attachments + singleMarkedAttIDs := make([]string, 0, 100) + for i := 0; i < 100; i++ { + docID := fmt.Sprintf("%s%s%d", base.AttPrefix, "marked", i) + makeMarkedDoc(docID, t.Name()) + singleMarkedAttIDs = append(singleMarkedAttIDs, docID) + } + + // assert there are marked attachments to clean up + for _, docID := range singleMarkedAttIDs { + var xattr map[string]interface{} + _, err := dataStore.GetXattr(docID, base.AttachmentCompactionXattrName, &xattr) + assert.NoError(t, err) + } + + bucket, err := base.AsGocbV2Bucket(testDb.Bucket) + require.NoError(t, err) + dcpFeedKey := GenerateCompactionDCPStreamName(t.Name(), CleanupPhase) + clientOptions, err := getCompactionDCPClientOptions(collectionID, testDb.Options.GroupID, testDb.MetadataKeys.DCPCheckpointPrefix(testDb.Options.GroupID)) + require.NoError(t, err) + dcpClient, err := base.NewDCPClient(dcpFeedKey, nil, *clientOptions, bucket) + require.NoError(t, err) + + // alter dcp metadata to feed into the compaction manager + vbUUID := base.GetVBUUIDs(dcpClient.GetMetadata()) + vbUUID[0] = uint64(garbageVBUUID) + + metadataKeys := base.NewMetadataKeys(testDb.Options.MetadataID) + testDb.AttachmentCompactionManager = NewAttachmentCompactionManager(dataStore, metadataKeys) + manager := AttachmentCompactionManager{CompactID: t.Name(), Phase: CleanupPhase, VBUUIDs: vbUUID} + testDb.AttachmentCompactionManager.Process = &manager + + terminator := base.NewSafeTerminator() + err = testDb.AttachmentCompactionManager.Process.Run(ctx, map[string]interface{}{"database": testDb}, testDb.AttachmentCompactionManager.UpdateStatusClusterAware, terminator) + require.NoError(t, err) + + err = WaitForConditionWithOptions(func() bool { + var status AttachmentManagerResponse + rawStatus, err := testDb.AttachmentCompactionManager.GetStatus() + assert.NoError(t, err) + err = base.JSONUnmarshal(rawStatus, &status) + require.NoError(t, err) + + if status.State == BackgroundProcessStateCompleted { + return true + } + + return false + }, 100, 1000) + require.NoError(t, err) + + // assert that the marked attachments have been "cleaned up" + for _, docID := range singleMarkedAttIDs { + var xattr map[string]interface{} + _, err := dataStore.GetXattr(docID, base.AttachmentCompactionXattrName, &xattr) + assert.Error(t, err) + assert.True(t, errors.Is(err, base.ErrXattrNotFound)) + } + +} + func TestAttachmentMarkAndSweepAndCleanup(t *testing.T) { base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) if base.UnitTestUrlIsWalrus() { @@ -271,7 +356,7 @@ func TestAttachmentMarkAndSweepAndCleanup(t *testing.T) { } terminator := base.NewSafeTerminator() - attachmentsMarked, vbUUIDS, err := attachmentCompactMarkPhase(ctx, dataStore, collectionID, testDb, t.Name(), terminator, &base.AtomicInt{}) + attachmentsMarked, vbUUIDS, _, err := attachmentCompactMarkPhase(ctx, dataStore, collectionID, testDb, t.Name(), terminator, &base.AtomicInt{}) assert.NoError(t, err) assert.Equal(t, int64(10), attachmentsMarked) @@ -293,7 +378,7 @@ func TestAttachmentMarkAndSweepAndCleanup(t *testing.T) { } } - err = attachmentCompactCleanupPhase(ctx, dataStore, collectionID, testDb, t.Name(), vbUUIDS, terminator) + _, err = attachmentCompactCleanupPhase(ctx, dataStore, collectionID, testDb, t.Name(), vbUUIDS, terminator) assert.NoError(t, err) for _, attDocKey := range attKeys { @@ -620,7 +705,7 @@ func TestAttachmentDifferentVBUUIDsBetweenPhases(t *testing.T) { // Run mark phase as usual terminator := base.NewSafeTerminator() - _, vbUUIDs, err := attachmentCompactMarkPhase(ctx, dataStore, collectionID, testDB, t.Name(), terminator, &base.AtomicInt{}) + _, vbUUIDs, _, err := attachmentCompactMarkPhase(ctx, dataStore, collectionID, testDB, t.Name(), terminator, &base.AtomicInt{}) assert.NoError(t, err) // Manually modify a vbUUID and ensure the Sweep phase errors @@ -891,7 +976,7 @@ func TestAttachmentCompactIncorrectStat(t *testing.T) { stat := &base.AtomicInt{} count := int64(0) go func() { - attachmentCount, _, err := attachmentCompactMarkPhase(ctx, dataStore, collectionID, testDb, "mark", terminator, stat) + attachmentCount, _, _, err := attachmentCompactMarkPhase(ctx, dataStore, collectionID, testDb, "mark", terminator, stat) atomic.StoreInt64(&count, attachmentCount) require.NoError(t, err) }() diff --git a/db/attachment_test.go b/db/attachment_test.go index 00e4ebf958..d4af7e05fd 100644 --- a/db/attachment_test.go +++ b/db/attachment_test.go @@ -215,7 +215,7 @@ func TestAttachmentForRejectedDocument(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper( + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, `function(doc, oldDoc) { throw({forbidden: "None shall pass!"}); }`, db.Options.JavascriptTimeout) diff --git a/db/background_mgr_attachment_compaction.go b/db/background_mgr_attachment_compaction.go index d085eac459..de28b8a0e8 100644 --- a/db/background_mgr_attachment_compaction.go +++ b/db/background_mgr_attachment_compaction.go @@ -10,9 +10,11 @@ package db import ( "context" + "errors" "sync" "time" + "github.com/couchbase/gocbcore/v10" "github.com/couchbase/sync_gateway/base" "github.com/google/uuid" ) @@ -100,6 +102,23 @@ func (a *AttachmentCompactionManager) Init(ctx context.Context, options map[stri return newRunInit() } +func (a *AttachmentCompactionManager) PurgeDCPMetadata(ctx context.Context, datastore base.DataStore, database *Database, metadataKeyPrefix string) error { + + bucket, err := base.AsGocbV2Bucket(database.Bucket) + if err != nil { + return err + } + numVbuckets, err := bucket.GetMaxVbno() + if err != nil { + return err + } + + metadata := base.NewDCPMetadataCS(datastore, numVbuckets, base.DefaultNumWorkers, metadataKeyPrefix) + base.InfofCtx(ctx, base.KeyDCP, "purging persisted dcp metadata for attachment compaction run %s", a.CompactID) + metadata.Purge(base.DefaultNumWorkers) + return nil +} + func (a *AttachmentCompactionManager) Run(ctx context.Context, options map[string]interface{}, persistClusterStatusCallback updateStatusCallbackFunc, terminator *base.SafeTerminator) error { database := options["database"].(*Database) @@ -110,6 +129,7 @@ func (a *AttachmentCompactionManager) Run(ctx context.Context, options map[strin // but we'll consider that a follow-up enhancement to point this compaction operation at arbitrary collections. dataStore := database.Bucket.DefaultDataStore() collectionID := base.DefaultCollectionID + var metadataKeyPrefix string persistClusterStatus := func() { err := persistClusterStatusCallback() @@ -120,15 +140,29 @@ func (a *AttachmentCompactionManager) Run(ctx context.Context, options map[strin defer persistClusterStatus() + var rollbackErr gocbcore.DCPRollbackError + // Need to check the current phase in the event we are resuming - No need to run mark again if we got as far as // cleanup last time... var err error switch a.Phase { case "mark", "": a.SetPhase("mark") - persistClusterStatus() - _, a.VBUUIDs, err = attachmentCompactMarkPhase(ctx, dataStore, collectionID, database, a.CompactID, terminator, &a.MarkedAttachments) + worker := func() (shouldRetry bool, err error, value interface{}) { + persistClusterStatus() + _, a.VBUUIDs, metadataKeyPrefix, err = attachmentCompactMarkPhase(ctx, dataStore, collectionID, database, a.CompactID, terminator, &a.MarkedAttachments) + if err != nil { + shouldRetry, err = a.handleAttachmentCompactionRollbackError(ctx, options, dataStore, database, err, MarkPhase, metadataKeyPrefix) + } + return shouldRetry, err, nil + } + // retry loop for handling a rollback during mark phase of compaction process + err, _ = base.RetryLoop("attachmentCompactMarkPhase", worker, base.CreateMaxDoublingSleeperFunc(25, 100, 10000)) if err != nil || terminator.IsClosed() { + if errors.As(err, &rollbackErr) || errors.Is(err, base.ErrVbUUIDMismatch) { + // log warning to show we hit max number of retries + base.WarnfCtx(ctx, "maximum retry attempts reached on mark phase: %v", err) + } return err } fallthrough @@ -142,9 +176,21 @@ func (a *AttachmentCompactionManager) Run(ctx context.Context, options map[strin fallthrough case "cleanup": a.SetPhase("cleanup") - persistClusterStatus() - err := attachmentCompactCleanupPhase(ctx, dataStore, collectionID, database, a.CompactID, a.VBUUIDs, terminator) + worker := func() (shouldRetry bool, err error, value interface{}) { + persistClusterStatus() + metadataKeyPrefix, err = attachmentCompactCleanupPhase(ctx, dataStore, collectionID, database, a.CompactID, a.VBUUIDs, terminator) + if err != nil { + shouldRetry, err = a.handleAttachmentCompactionRollbackError(ctx, options, dataStore, database, err, CleanupPhase, metadataKeyPrefix) + } + return shouldRetry, err, nil + } + // retry loop for handling a rollback during mark phase of compaction process + err, _ = base.RetryLoop("attachmentCompactCleanupPhase", worker, base.CreateMaxDoublingSleeperFunc(25, 100, 10000)) if err != nil || terminator.IsClosed() { + if errors.As(err, &rollbackErr) || errors.Is(err, base.ErrVbUUIDMismatch) { + // log warning to show we hit max number of retries + base.WarnfCtx(ctx, "maximum retry attempts reached on cleanup phase: %v", err) + } return err } } @@ -153,6 +199,36 @@ func (a *AttachmentCompactionManager) Run(ctx context.Context, options map[strin return nil } +func (a *AttachmentCompactionManager) handleAttachmentCompactionRollbackError(ctx context.Context, options map[string]interface{}, dataStore base.DataStore, database *Database, err error, phase, keyPrefix string) (bool, error) { + var rollbackErr gocbcore.DCPRollbackError + if errors.As(err, &rollbackErr) || errors.Is(err, base.ErrVbUUIDMismatch) { + base.InfofCtx(ctx, base.KeyDCP, "rollback indicated on %s phase of attachment compaction, resetting the task", phase) + // to rollback any phase for attachment compaction we need to purge all persisted dcp metadata + err = a.PurgeDCPMetadata(ctx, dataStore, database, keyPrefix) + if err != nil { + base.WarnfCtx(ctx, "error occurred during purging of dcp metadata: %w", err) + return false, err + } + if phase == MarkPhase { + // initialise new compaction run as we want to start the phase mark again in event of rollback + err = a.Init(ctx, options, nil) + if err != nil { + base.WarnfCtx(ctx, "error on initialization of new run after rollback has been indicated, %w", err) + return false, err + } + } else { + // we only handle rollback for mark and cleanup so if we call here it will be for cleanup phase + // we need to clear the vbUUID's on the manager for cleanup phase otherwise we will end up in loop of constant rollback + // as these are used for the initial metadata on the client + a.VBUUIDs = nil + } + // we should try again if it is rollback error + return true, nil + } + // if error isn't rollback then assume it's not recoverable + return false, err +} + func (a *AttachmentCompactionManager) SetPhase(phase string) { a.lock.Lock() defer a.lock.Unlock() diff --git a/db/blip_connected_client.go b/db/blip_connected_client.go index f0e7ae8872..b050ef560b 100644 --- a/db/blip_connected_client.go +++ b/db/blip_connected_client.go @@ -92,7 +92,7 @@ func (bh *blipHandler) handleFunction(rq *blip.Message) error { return base.HTTPErrorf(http.StatusBadRequest, "Missing 'name'") } - requestParams, err := bh.parseJsonBody(rq, bh.db.Options.UserFunctions.MaxRequestSize) + requestParams, err := bh.parseJsonBody(rq, bh.db.UserFunctions.MaxRequestSize) if err != nil { return err } @@ -137,13 +137,13 @@ func (bh *blipHandler) handleFunction(rq *blip.Message) error { } else { // Write the single result to the response: - result, err := fn.Run() + result, err := fn.RunAsJSON() if err != nil { return err } response := rq.Response() response.SetCompressed(true) - _ = response.SetJSONBody(result) + response.SetBody(result) return nil } }) @@ -163,7 +163,7 @@ func (bh *blipHandler) handleGraphQL(rq *blip.Message) error { } operationName := rq.Properties[GraphQLOperationName] - variables, err := bh.parseJsonBody(rq, bh.db.Options.GraphQL.MaxRequestSize()) + variables, err := bh.parseJsonBody(rq, bh.db.GraphQL.MaxRequestSize()) if err != nil { return err } @@ -186,7 +186,7 @@ func (bh *blipHandler) parseJsonBody(rq *blip.Message, maxSize *int) (map[string if err != nil { return nil, err } - if err := CheckRequestSize(len(bodyBytes), bh.db.Options.UserFunctions.MaxRequestSize); err != nil { + if err := CheckRequestSize(len(bodyBytes), bh.db.UserFunctions.MaxRequestSize); err != nil { return nil, err } var parsedBody map[string]any diff --git a/db/blip_handler.go b/db/blip_handler.go index 109bbeb871..37cfdbb15f 100644 --- a/db/blip_handler.go +++ b/db/blip_handler.go @@ -295,6 +295,19 @@ func (bh *blipHandler) handleSubChanges(rq *blip.Message) error { continuous := subChangesParams.continuous() + requestPlusSeq := uint64(0) + // If non-continuous, check whether requestPlus handling is set for request or via database config + if continuous == false { + useRequestPlus := subChangesParams.requestPlus(bh.db.Options.ChangesRequestPlus) + if useRequestPlus { + seq, requestPlusErr := bh.db.GetRequestPlusSequence() + if requestPlusErr != nil { + return base.HTTPErrorf(http.StatusServiceUnavailable, "Unable to retrieve current sequence for requestPlus=true: %v", requestPlusErr) + } + requestPlusSeq = seq + } + } + // Start asynchronous changes goroutine go func() { // Pull replication stats by type @@ -325,6 +338,7 @@ func (bh *blipHandler) handleSubChanges(rq *blip.Message) error { clientType: clientType, ignoreNoConflicts: clientType == clientTypeSGR2, // force this side to accept a "changes" message, even in no conflicts mode for SGR2. changesCtx: collectionCtx.changesCtx, + requestPlusSeq: requestPlusSeq, }) base.DebugfCtx(bh.loggingCtx, base.KeySyncMsg, "#%d: Type:%s --> Time:%v", bh.serialNumber, rq.Profile(), time.Since(startTime)) }() @@ -358,6 +372,7 @@ type sendChangesOptions struct { revocations bool ignoreNoConflicts bool changesCtx context.Context + requestPlusSeq uint64 } type changesDeletedFlag uint @@ -385,14 +400,15 @@ func (bh *blipHandler) sendChanges(sender *blip.Sender, opts *sendChangesOptions base.InfofCtx(bh.loggingCtx, base.KeySync, "Sending changes since %v", opts.since) options := ChangesOptions{ - Since: opts.since, - Conflicts: false, // CBL 2.0/BLIP don't support branched rev trees (LiteCore #437) - Continuous: opts.continuous, - ActiveOnly: opts.activeOnly, - Revocations: opts.revocations, - LoggingCtx: bh.loggingCtx, - clientType: opts.clientType, - ChangesCtx: opts.changesCtx, + Since: opts.since, + Conflicts: false, // CBL 2.0/BLIP don't support branched rev trees (LiteCore #437) + Continuous: opts.continuous, + ActiveOnly: opts.activeOnly, + Revocations: opts.revocations, + LoggingCtx: bh.loggingCtx, + clientType: opts.clientType, + ChangesCtx: opts.changesCtx, + RequestPlusSeq: opts.requestPlusSeq, } channelSet := opts.channels @@ -1204,7 +1220,9 @@ func (bh *blipHandler) handleProveAttachment(rq *blip.Message) error { return base.HTTPErrorf(http.StatusBadRequest, "no digest sent with proveAttachment") } - attData, err := bh.collection.GetAttachment(base.AttPrefix + digest) + allowedAttachment := bh.allowedAttachment(digest) + attachmentKey := MakeAttachmentKey(allowedAttachment.version, allowedAttachment.docID, digest) + attData, err := bh.collection.GetAttachment(attachmentKey) if err != nil { if bh.clientType == BLIPClientTypeSGR2 { return ErrAttachmentNotFound diff --git a/db/blip_sync_context.go b/db/blip_sync_context.go index 85c7e285a0..b90560a4e0 100644 --- a/db/blip_sync_context.go +++ b/db/blip_sync_context.go @@ -19,6 +19,7 @@ import ( "runtime/debug" "strconv" "sync" + "sync/atomic" "time" "github.com/couchbase/go-blip" @@ -48,6 +49,7 @@ func NewBlipSyncContext(ctx context.Context, bc *blip.Context, db *Database, con if bsc.replicationStats == nil { bsc.replicationStats = NewBlipSyncStats() } + bsc.stats.lastReportTime.Store(time.Now().UnixMilli()) if u := db.User(); u != nil { bsc.userName = u.Name() @@ -74,7 +76,6 @@ func NewBlipSyncContext(ctx context.Context, bc *blip.Context, db *Database, con bsc.register(profile, handlerFn) } } - return bsc } @@ -115,6 +116,16 @@ type BlipSyncContext struct { readOnly bool collections *blipCollections // all collections handled by blipSyncContext, implicit or via GetCollections + + stats blipSyncStats // internal structure to store stats +} + +// blipSyncStats has support structures to support reporting stats at regular interval +type blipSyncStats struct { + bytesSent atomic.Uint64 // Total bytes sent to client + bytesReceived atomic.Uint64 // Total bytes received from client + lastReportTime atomic.Int64 // last time reported by time.Time // Last time blip stats were reported + lock sync.Mutex } // AllowedAttachment contains the metadata for handling allowed attachments @@ -195,6 +206,8 @@ func (bsc *BlipSyncContext) register(profile string, handlerFn func(*blipHandler respBody, _ := resp.Body() base.TracefCtx(bsc.loggingCtx, base.KeySyncMsg, "Recv Rsp %s: Body: '%s' Properties: %v", resp, base.UD(respBody), base.UD(resp.Properties)) } + + bsc.reportStats(false) } bsc.blipContext.HandlerForProfile[profile] = handlerFnWrapper @@ -214,6 +227,7 @@ func (bsc *BlipSyncContext) Close() { collection.changesCtxCancel() } + bsc.reportStats(true) close(bsc.terminator) }) } @@ -655,3 +669,41 @@ func toHistory(revisions Revisions, knownRevs map[string]bool, maxHistory int) [ } return history } + +// timeElapsedForStatsReporting will return true if enough time has passed since the previous report. +func (bsc *BlipSyncContext) timeElapsedForStatsReporting(currentTime int64) bool { + return (currentTime - bsc.stats.lastReportTime.Load()) >= bsc.blipContextDb.Options.BlipStatsReportingInterval +} + +// reportStats will update the stats on a database immediately if updateImmediately is true, otherwise update on BlipStatsReportinInterval +func (bsc *BlipSyncContext) reportStats(updateImmediately bool) { + if bsc.blipContextDb == nil || bsc.blipContext == nil { + return + } + dbStats := bsc.blipContextDb.DbStats.Database() + if dbStats == nil { + return + } + currentTime := time.Now().UnixMilli() + if !updateImmediately && !bsc.timeElapsedForStatsReporting(currentTime) { + return + } + + bsc.stats.lock.Lock() + defer bsc.stats.lock.Unlock() + + // check a second time after acquiring the lock to see stats reporting was slow enough that a waiting mutex doesn't need to run + if !updateImmediately && !bsc.timeElapsedForStatsReporting(time.Now().UnixMilli()) { + return + } + + totalBytesSent := bsc.blipContext.GetBytesSent() + newBytesSent := totalBytesSent - bsc.stats.bytesSent.Swap(totalBytesSent) + dbStats.ReplicationBytesSent.Add(int64(newBytesSent)) + + totalBytesReceived := bsc.blipContext.GetBytesReceived() + newBytesReceived := totalBytesReceived - bsc.stats.bytesReceived.Swap(totalBytesReceived) + dbStats.ReplicationBytesReceived.Add(int64(newBytesReceived)) + bsc.stats.lastReportTime.Store(currentTime) + +} diff --git a/db/blip_sync_messages.go b/db/blip_sync_messages.go index 381591be0b..1e2a161e73 100644 --- a/db/blip_sync_messages.go +++ b/db/blip_sync_messages.go @@ -68,6 +68,8 @@ const ( SubChangesContinuous = "continuous" SubChangesBatch = "batch" SubChangesRevocations = "revocations" + SubChangesRequestPlus = "requestPlus" + SubChangesFuture = "future" // rev message properties RevMessageID = "id" @@ -163,7 +165,7 @@ func NewSubChangesParams(logCtx context.Context, rq *blip.Message, zeroSeq Seque // Determine incoming since and docIDs once, since there is some overhead associated with their calculation sinceSequenceId := zeroSeq var err error - if rq.Properties["future"] == trueProperty { + if rq.Properties[SubChangesFuture] == trueProperty { sinceSequenceId, err = latestSeq() } else if sinceStr, found := rq.Properties[SubChangesSince]; found { if sinceSequenceId, err = sequenceIDParser(sinceStr); err != nil { @@ -234,6 +236,14 @@ func (s *SubChangesParams) activeOnly() bool { return (s.rq.Properties[SubChangesActiveOnly] == trueProperty) } +func (s *SubChangesParams) requestPlus(defaultValue bool) (value bool) { + propertyValue, isDefined := s.rq.Properties[SubChangesRequestPlus] + if !isDefined { + return defaultValue + } + return propertyValue == trueProperty +} + func (s *SubChangesParams) filter() string { return s.rq.Properties[SubChangesFilter] } diff --git a/db/blip_sync_stats.go b/db/blip_sync_stats.go index 25fedee4ff..6286eae453 100644 --- a/db/blip_sync_stats.go +++ b/db/blip_sync_stats.go @@ -129,11 +129,13 @@ func BlipSyncStatsForCBL(dbStats *base.DbStats) *BlipSyncStats { blipStats.SendRevBytes = dbStats.Database().DocReadsBytesBlip blipStats.SendRevCount = dbStats.Database().NumDocReadsBlip + blipStats.SendRevErrorTotal = dbStats.CBLReplicationPull().RevErrorCount blipStats.HandleRevBytes = dbStats.Database().DocWritesBytesBlip blipStats.HandleRevProcessingTime = dbStats.CBLReplicationPush().WriteProcessingTime blipStats.HandleRevCount = dbStats.CBLReplicationPush().DocPushCount + blipStats.HandleRevErrorCount = dbStats.CBLReplicationPush().DocPushErrorCount blipStats.HandleGetAttachment = dbStats.CBLReplicationPull().AttachmentPullCount blipStats.HandleGetAttachmentBytes = dbStats.CBLReplicationPull().AttachmentPullBytes diff --git a/db/change_cache_test.go b/db/change_cache_test.go index cdb8455a93..a3990ed059 100644 --- a/db/change_cache_test.go +++ b/db/change_cache_test.go @@ -1032,7 +1032,7 @@ func TestChannelQueryCancellation(t *testing.T) { db, ctx := setupTestLeakyDBWithCacheOptions(t, DefaultCacheOptions(), queryCallbackConfig) defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) // Write a handful of docs/sequences to the bucket _, _, err := collection.Put(ctx, "key1", Body{"channels": "ABC"}) @@ -1672,7 +1672,7 @@ func TestInitializeEmptyCache(t *testing.T) { db, ctx := setupTestDBWithCacheOptions(t, cacheOptions) defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) cacheWaiter := db.NewDCPCachingCountWaiter(t) docCount := 0 @@ -1724,7 +1724,7 @@ func TestInitializeCacheUnderLoad(t *testing.T) { db, ctx := setupTestDBWithCacheOptions(t, cacheOptions) defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) // Writes [docCount] documents. Use wait group (writesDone)to identify when all docs have been written. // Use another waitGroup (writesInProgress) to trigger getChanges midway through writes @@ -1780,7 +1780,7 @@ func TestNotifyForInactiveChannel(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) collectionID := collection.GetCollectionID() // -------- Setup notifyChange callback ---------------- diff --git a/db/changes.go b/db/changes.go index d430d51cda..53b1df1cc3 100644 --- a/db/changes.go +++ b/db/changes.go @@ -26,19 +26,20 @@ import ( // Options for changes-feeds. ChangesOptions must not contain any mutable pointer references, as // changes processing currently assumes a deep copy when doing chanOpts := changesOptions. type ChangesOptions struct { - Since SequenceID // sequence # to start _after_ - Limit int // Max number of changes to return, if nonzero - Conflicts bool // Show all conflicting revision IDs, not just winning one? - IncludeDocs bool // Include doc body of each change? - Wait bool // Wait for results, instead of immediately returning empty result? - Continuous bool // Run continuously until terminated? - HeartbeatMs uint64 // How often to send a heartbeat to the client - TimeoutMs uint64 // After this amount of time, close the longpoll connection - ActiveOnly bool // If true, only return information on non-deleted, non-removed revisions - Revocations bool // Specifies whether revocation messages should be sent on the changes feed - clientType clientType // Can be used to determine if the replication is being started from a CBL 2.x or SGR2 client - LoggingCtx context.Context // Used for adding context to logs - ChangesCtx context.Context // Used for cancelling checking the changes feed should stop + Since SequenceID // sequence # to start _after_ + Limit int // Max number of changes to return, if nonzero + Conflicts bool // Show all conflicting revision IDs, not just winning one? + IncludeDocs bool // Include doc body of each change? + Wait bool // Wait for results, instead of immediately returning empty result? + Continuous bool // Run continuously until terminated? + RequestPlusSeq uint64 // Do not stop changes before cached sequence catches up with requestPlusSeq + HeartbeatMs uint64 // How often to send a heartbeat to the client + TimeoutMs uint64 // After this amount of time, close the longpoll connection + ActiveOnly bool // If true, only return information on non-deleted, non-removed revisions + Revocations bool // Specifies whether revocation messages should be sent on the changes feed + clientType clientType // Can be used to determine if the replication is being started from a CBL 2.x or SGR2 client + LoggingCtx context.Context // Used for adding context to logs + ChangesCtx context.Context // Used for cancelling checking the changes feed should stop } // A changes entry; Database.GetChanges returns an array of these. @@ -629,8 +630,9 @@ func (col *DatabaseCollectionWithUser) SimpleMultiChangesFeed(ctx context.Contex var changeWaiter *ChangeWaiter var lowSequence uint64 - var currentCachedSequence uint64 + var currentCachedSequence uint64 // The highest contiguous sequence buffered over the caching feed var lateSequenceFeeds map[channels.ID]*lateSequenceFeed + var useLateSequenceFeeds bool // LateSequence feeds are only used for continuous, or one-shot where options.RequestPlusSeq > currentCachedSequence var userCounter uint64 // Wait counter used to identify changes to the user document var changedChannels channels.ChangedKeys // Tracks channels added/removed to the user during changes processing. var userChanged bool // Whether the user document has changed in a given iteration loop @@ -638,9 +640,9 @@ func (col *DatabaseCollectionWithUser) SimpleMultiChangesFeed(ctx context.Contex // Retrieve the current max cached sequence - ensures there isn't a race between the subsequent channel cache queries currentCachedSequence = col.changeCache().getChannelCache().GetHighCacheSequence() - if options.Wait { - options.Wait = false + // If changes feed requires more than one ChangesLoop iteration, initialize changeWaiter + if options.Wait || options.RequestPlusSeq > currentCachedSequence { changeWaiter = col.startChangeWaiter() // Waiter is updated with the actual channel set (post-user reload) at the start of the outer changes loop userCounter = changeWaiter.CurrentUserCount() // Reload user to pick up user changes that happened between auth and the change waiter @@ -676,7 +678,8 @@ func (col *DatabaseCollectionWithUser) SimpleMultiChangesFeed(ctx context.Contex // For a continuous feed, initialise the lateSequenceFeeds that track late-arriving sequences // to the channel caches. - if options.Continuous { + if options.Continuous || options.RequestPlusSeq > currentCachedSequence { + useLateSequenceFeeds = true lateSequenceFeeds = make(map[channels.ID]*lateSequenceFeed) defer col.closeLateFeeds(lateSequenceFeeds) } @@ -741,7 +744,7 @@ func (col *DatabaseCollectionWithUser) SimpleMultiChangesFeed(ctx context.Contex // Handles previously skipped sequences prior to options.Since that // have arrived in the channel cache since this changes request started. Only needed for // continuous feeds - one-off changes requests only require the standard channel cache. - if options.Continuous { + if useLateSequenceFeeds { lateSequenceFeedHandler := lateSequenceFeeds[chanID] if lateSequenceFeedHandler != nil { latefeed, err := col.getLateFeed(lateSequenceFeedHandler, singleChannelCache) @@ -957,14 +960,19 @@ func (col *DatabaseCollectionWithUser) SimpleMultiChangesFeed(ctx context.Contex } } } - if !options.Continuous && (sentSomething || changeWaiter == nil) { - break + + // Check whether non-continuous changes feeds that aren't waiting to reach requestPlus sequence can exit + if !options.Continuous && currentCachedSequence >= options.RequestPlusSeq { + // If non-longpoll, or longpoll has sent something, can exit + if !options.Wait || sentSomething { + break + } } // For longpoll requests that didn't send any results, reset low sequence to the original since value, // as the system low sequence may change before the longpoll request wakes up, and longpoll feeds don't // use lateSequenceFeeds. - if !options.Continuous { + if !useLateSequenceFeeds { options.Since.LowSeq = requestLowSeq } @@ -981,6 +989,7 @@ func (col *DatabaseCollectionWithUser) SimpleMultiChangesFeed(ctx context.Contex waitForChanges: for { + col.dbStats().CBLReplicationPull().NumPullReplTotalCaughtUp.Add(1) // If we're in a deferred Backfill, the user may not get notification when the cache catches up to the backfill (e.g. when the granting doc isn't // visible to the user), and so ChangeWaiter.Wait() would block until the next user-visible doc arrives. Use a hardcoded wait instead // Similar handling for when we see sequences later than the stable sequence. @@ -992,7 +1001,6 @@ func (col *DatabaseCollectionWithUser) SimpleMultiChangesFeed(ctx context.Contex break waitForChanges } - col.dbStats().CBLReplicationPull().NumPullReplTotalCaughtUp.Add(1) col.dbStats().CBLReplicationPull().NumPullReplCaughtUp.Add(1) waitResponse := changeWaiter.Wait() col.dbStats().CBLReplicationPull().NumPullReplCaughtUp.Add(-1) @@ -1310,7 +1318,7 @@ func createChangesEntry(ctx context.Context, docid string, db *DatabaseCollectio func (options ChangesOptions) String() string { return fmt.Sprintf( - `{Since: %s, Limit: %d, Conflicts: %t, IncludeDocs: %t, Wait: %t, Continuous: %t, HeartbeatMs: %d, TimeoutMs: %d, ActiveOnly: %t}`, + `{Since: %s, Limit: %d, Conflicts: %t, IncludeDocs: %t, Wait: %t, Continuous: %t, HeartbeatMs: %d, TimeoutMs: %d, ActiveOnly: %t, RequestPlusSeq: %d}`, options.Since, options.Limit, options.Conflicts, @@ -1320,6 +1328,7 @@ func (options ChangesOptions) String() string { options.HeartbeatMs, options.TimeoutMs, options.ActiveOnly, + options.RequestPlusSeq, ) } diff --git a/db/changes_test.go b/db/changes_test.go index 6eb45a4932..988e60a661 100644 --- a/db/changes_test.go +++ b/db/changes_test.go @@ -56,7 +56,7 @@ func TestFilterToAvailableChannels(t *testing.T) { db, ctx := setupTestDB(t) defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) auth := db.Authenticator(base.TestCtx(t)) user, err := auth.NewUser("test", "pass", testCase.userChans) @@ -102,7 +102,7 @@ func TestChangesAfterChannelAdded(t *testing.T) { base.SetUpTestLogging(t, base.LevelDebug, base.KeyCache, base.KeyChanges) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) // Create a user with access to channel ABC authenticator := db.Authenticator(base.TestCtx(t)) @@ -213,7 +213,7 @@ func TestDocDeletionFromChannelCoalescedRemoved(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) // Create a user with access to channel A authenticator := db.Authenticator(base.TestCtx(t)) @@ -300,7 +300,7 @@ func TestDocDeletionFromChannelCoalesced(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) // Create a user with access to channel A authenticator := db.Authenticator(base.TestCtx(t)) diff --git a/db/crud.go b/db/crud.go index 410d505b2f..c31b02623f 100644 --- a/db/crud.go +++ b/db/crud.go @@ -952,13 +952,13 @@ func (db *DatabaseCollectionWithUser) Put(ctx context.Context, docid string, bod if conflictErr != nil { if db.ForceAPIForbiddenErrors() { // Make sure the user has permission to modify the document before confirming doc existence - mutableBody, metaMap, newRevID, err := db.prepareSyncFn(doc, newDoc) + bodyJSON, metaMap, newRevID, err := db.prepareSyncFn(doc, newDoc) if err != nil { base.InfofCtx(ctx, base.KeyCRUD, "Failed to prepare to run sync function: %v", err) return nil, nil, false, nil, ErrForbidden } - _, _, _, _, _, err = db.runSyncFn(ctx, doc, mutableBody, metaMap, newRevID) + _, _, _, _, _, err = db.runSyncFn(ctx, doc, bodyJSON, metaMap, newRevID, isDeleted) if err != nil { base.DebugfCtx(ctx, base.KeyCRUD, "Could not modify doc %q due to %s and sync func rejection: %v", base.UD(doc.ID), conflictErr, err) return nil, nil, false, nil, ErrForbidden @@ -1163,20 +1163,14 @@ func (db *DatabaseCollectionWithUser) resolveConflict(ctx context.Context, local // TODO: Make doc expiry (_exp) available over replication. // remoteExpiry := remoteDoc.Expiry - localDocBody, err := localDoc.GetDeepMutableBody() - if err != nil { - return "", nil, err - } + localDocBody := localDoc.Body().ShallowCopy() localDocBody[BodyId] = localDoc.ID localDocBody[BodyRev] = localRevID localDocBody[BodyAttachments] = localAttachments localDocBody[BodyExpiry] = localExpiry localDocBody[BodyDeleted] = localDoc.IsDeleted() - remoteDocBody, err := remoteDoc.GetDeepMutableBody() - if err != nil { - return "", nil, err - } + remoteDocBody := remoteDoc.Body().ShallowCopy() remoteDocBody[BodyId] = remoteDoc.ID remoteDocBody[BodyRev] = remoteRevID remoteDocBody[BodyAttachments] = remoteAttachments @@ -1476,38 +1470,31 @@ func (db *DatabaseCollectionWithUser) storeOldBodyInRevTreeAndUpdateCurrent(ctx } } -func (db *DatabaseCollectionWithUser) prepareSyncFn(doc *Document, newDoc *Document) (mutableBody Body, metaMap map[string]interface{}, newRevID string, err error) { +func (db *DatabaseCollectionWithUser) prepareSyncFn(doc *Document, newDoc *Document) (revBody []byte, metaMap channels.MetaMap, newRevID string, err error) { // Marshal raw user xattrs for use in Sync Fn. If this fails we can bail out so we should do early as possible. metaMap, err = doc.GetMetaMap(db.userXattrKey()) if err != nil { return } - mutableBody, err = newDoc.GetDeepMutableBody() + revBody, err = newDoc.BodyBytes() if err != nil { return } - err = validateNewBody(mutableBody) + err = validateNewBody(newDoc.Body()) if err != nil { return } newRevID = newDoc.RevID - - mutableBody[BodyId] = doc.ID - mutableBody[BodyRev] = newRevID - if newDoc.Deleted { - mutableBody[BodyDeleted] = true - } - return } // Run the sync function on the given document and body. Need to inject the document ID and rev ID temporarily to run // the sync function. -func (db *DatabaseCollectionWithUser) runSyncFn(ctx context.Context, doc *Document, body Body, metaMap map[string]interface{}, newRevId string) (*uint32, string, base.Set, channels.AccessMap, channels.AccessMap, error) { - channelSet, access, roles, syncExpiry, oldBody, err := db.getChannelsAndAccess(ctx, doc, body, metaMap, newRevId) +func (db *DatabaseCollectionWithUser) runSyncFn(ctx context.Context, doc *Document, body []byte, metaMap channels.MetaMap, newRevId string, deleted bool) (*uint32, string, base.Set, channels.AccessMap, channels.AccessMap, error) { + channelSet, access, roles, syncExpiry, oldBody, err := db.getChannelsAndAccess(ctx, doc, body, metaMap, newRevId, deleted) if err != nil { return nil, ``, nil, nil, nil, err } @@ -1515,7 +1502,7 @@ func (db *DatabaseCollectionWithUser) runSyncFn(ctx context.Context, doc *Docume return syncExpiry, oldBody, channelSet, access, roles, nil } -func (db *DatabaseCollectionWithUser) recalculateSyncFnForActiveRev(ctx context.Context, doc *Document, metaMap map[string]interface{}, newRevID string) (channelSet base.Set, access, roles channels.AccessMap, syncExpiry *uint32, oldBodyJSON string, err error) { +func (db *DatabaseCollectionWithUser) recalculateSyncFnForActiveRev(ctx context.Context, doc *Document, metaMap channels.MetaMap, newRevID string) (channelSet base.Set, access, roles channels.AccessMap, syncExpiry *uint32, oldBodyJSON string, err error) { // In some cases an older revision might become the current one. If so, get its // channels & access, for purposes of updating the doc: curBodyBytes, err := db.getAvailable1xRev(ctx, doc, doc.CurrentRev) @@ -1523,16 +1510,10 @@ func (db *DatabaseCollectionWithUser) recalculateSyncFnForActiveRev(ctx context. return } - var curBody Body - err = curBody.Unmarshal(curBodyBytes) - if err != nil { - return - } - - if curBody != nil { + if curBodyBytes != nil && string(curBodyBytes) != "null" { base.DebugfCtx(ctx, base.KeyCRUD, "updateDoc(%q): Rev %q causes %q to become current again", base.UD(doc.ID), newRevID, doc.CurrentRev) - channelSet, access, roles, syncExpiry, oldBodyJSON, err = db.getChannelsAndAccess(ctx, doc, curBody, metaMap, doc.CurrentRev) + channelSet, access, roles, syncExpiry, oldBodyJSON, err = db.getChannelsAndAccess(ctx, doc, curBodyBytes, metaMap, doc.CurrentRev, false) if err != nil { return } @@ -1726,7 +1707,7 @@ func (col *DatabaseCollectionWithUser) documentUpdateFunc(ctx context.Context, d return } - mutableBody, metaMap, newRevID, err := col.prepareSyncFn(doc, newDoc) + revBody, metaMap, newRevID, err := col.prepareSyncFn(doc, newDoc) if err != nil { return } @@ -1736,7 +1717,7 @@ func (col *DatabaseCollectionWithUser) documentUpdateFunc(ctx context.Context, d newDocHasAttachments := len(newAttachments) > 0 col.storeOldBodyInRevTreeAndUpdateCurrent(ctx, doc, prevCurrentRev, newRevID, newDoc, newDocHasAttachments) - syncExpiry, oldBodyJSON, channelSet, access, roles, err := col.runSyncFn(ctx, doc, mutableBody, metaMap, newRevID) + syncExpiry, oldBodyJSON, channelSet, access, roles, err := col.runSyncFn(ctx, doc, revBody, metaMap, newRevID, newDoc.Deleted) if err != nil { if col.ForceAPIForbiddenErrors() { base.InfofCtx(ctx, base.KeyCRUD, "Sync function rejected update to %s %s due to %v", @@ -2251,14 +2232,14 @@ func (db *DatabaseCollectionWithUser) Purge(ctx context.Context, key string) err // Calls the JS sync function to assign the doc to channels, grant users // access to channels, and reject invalid documents. -func (col *DatabaseCollectionWithUser) getChannelsAndAccess(ctx context.Context, doc *Document, body Body, metaMap map[string]interface{}, revID string) ( +func (col *DatabaseCollectionWithUser) getChannelsAndAccess(ctx context.Context, doc *Document, body []byte, metaMap channels.MetaMap, revID string, deleted bool) ( result base.Set, access channels.AccessMap, roles channels.AccessMap, expiry *uint32, oldJson string, err error) { - base.DebugfCtx(ctx, base.KeyCRUD, "Invoking sync on doc %q rev %s", base.UD(doc.ID), body[BodyRev]) + base.DebugfCtx(ctx, base.KeyCRUD, "Invoking sync on doc %q rev %s", base.UD(doc.ID), revID) // Low-level protection against writes for read-only guest. Handles write pathways that don't fail-fast if col.user != nil && col.user.Name() == "" && col.isGuestReadOnly() { @@ -2277,11 +2258,20 @@ func (col *DatabaseCollectionWithUser) getChannelsAndAccess(ctx context.Context, col.dbStats().Database().SyncFunctionCount.Add(1) col.collectionStats.SyncFunctionCount.Add(1) + input := channels.ChannelMapperInput{ + DocID: doc.ID, + RevID: revID, + Deleted: deleted, + Body: string(body), + OldBody: oldJson, + Meta: metaMap, + UserCtx: MakeUserCtx(col.user, col.ScopeName, col.Name), + } var output *channels.ChannelMapperOutput + base.TracefCtx(ctx, base.KeyCRUD, "Calling sync fn with _id=%q, _rev=%q, _del=%v, body %s , oldBody %s", doc.ID, revID, doc.Deleted, body, oldJson) startTime := time.Now() - output, err = col.ChannelMapper.MapToChannelsAndAccess(body, oldJson, metaMap, - MakeUserCtx(col.user, col.ScopeName, col.Name)) + output, err = col.ChannelMapper.Run(input) syncFunctionTimeNano := time.Since(startTime).Nanoseconds() col.dbStats().Database().SyncFunctionTime.Add(syncFunctionTimeNano) @@ -2308,7 +2298,7 @@ func (col *DatabaseCollectionWithUser) getChannelsAndAccess(ctx context.Context, } else { base.WarnfCtx(ctx, "Sync fn exception: %+v; doc %q / %q", err, base.UD(doc.ID), base.MD(doc.CurrentRev)) - if errors.Is(err, sgbucket.ErrJSTimeout) { + if errors.Is(err, context.DeadlineExceeded) { err = base.HTTPErrorf(500, "JS sync function timed out") } else { err = base.HTTPErrorf(500, "Exception in JS sync function") @@ -2320,7 +2310,9 @@ func (col *DatabaseCollectionWithUser) getChannelsAndAccess(ctx context.Context, } else { if base.IsDefaultCollection(col.ScopeName, col.Name) { // No ChannelMapper so by default use the "channels" property: - value := body["channels"] + var bodyMap map[string]any + err = base.JSONUnmarshal(body, &bodyMap) + value := bodyMap["channels"] if value != nil { array, nonStrings := base.ValueToStringArray(value) if nonStrings != nil { diff --git a/db/crud_test.go b/db/crud_test.go index 812bf7ab8a..2b3dab24ba 100644 --- a/db/crud_test.go +++ b/db/crud_test.go @@ -17,6 +17,7 @@ import ( sgbucket "github.com/couchbase/sg-bucket" "github.com/couchbase/sync_gateway/base" + "github.com/couchbase/sync_gateway/channels" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -1588,7 +1589,7 @@ func TestGetChannelsAndAccess(t *testing.T) { t.Run(test.name, func(t *testing.T) { body := Body{} require.NoError(t, body.Unmarshal([]byte(test.body))) - result, access, roles, expiry, oldJson, err := collection.getChannelsAndAccess(base.TestCtx(t), doc, body, nil, "") + result, access, roles, expiry, oldJson, err := collection.getChannelsAndAccess(base.TestCtx(t), doc, []byte(test.body), channels.MetaMap{}, "", false) require.NoError(t, err) require.Equal(t, "", oldJson) require.Nil(t, expiry) diff --git a/db/database.go b/db/database.go index e1026af8e2..dd31be662e 100644 --- a/db/database.go +++ b/db/database.go @@ -21,6 +21,7 @@ import ( "github.com/couchbase/cbgt" sgbucket "github.com/couchbase/sg-bucket" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/auth" "github.com/couchbase/sync_gateway/base" "github.com/couchbase/sync_gateway/channels" @@ -80,6 +81,9 @@ const ( // completion of all background tasks and background managers before the server is stopped. const BGTCompletionMaxWait = 30 * time.Second +// Max number of JavaScript interpreter instances to create (per database) +const MaxJavaScriptVMs = 8 + // Basic description of a database. Shared between all Database objects on the same database. // This object is thread-safe so it can be shared between HTTP handlers. type DatabaseContext struct { @@ -123,9 +127,10 @@ type DatabaseContext struct { ServeInsecureAttachmentTypes bool // Attachment content type will bypass the content-disposition handling, default false NoX509HTTPClient *http.Client // A HTTP Client from gocb to use the management endpoints ServerContextHasStarted chan struct{} // Closed via PostStartup once the server has fully started - userFunctions *UserFunctions // client-callable JavaScript functions + UserFunctions *UserFunctions // JS/N1QL functions clients can call UserFunctionTimeout time.Duration // Default timeout for N1QL, JavaScript and GraphQL queries. (Applies to REST and BLIP requests.) - graphQL *GraphQL // GraphQL query evaluator + GraphQL GraphQL // GraphQL query interface + JS js.VMPool // A pool of preconfigured V8 instances Scopes map[string]Scope // A map keyed by scope name containing a set of scopes/collections. Nil if running with only _default._default CollectionByID map[uint32]*DatabaseCollection // A map keyed by collection ID to Collection CollectionNames map[string]map[string]struct{} // Map of scope, collection names @@ -148,13 +153,12 @@ type DatabaseContextOptions struct { LocalJWTConfig auth.LocalJWTConfig DBOnlineCallback DBOnlineCallback // Callback function to take the DB back online ImportOptions ImportOptions - EnableXattr bool // Use xattr for _sync - LocalDocExpirySecs uint32 // The _local doc expiry time in seconds - SecureCookieOverride bool // Pass-through DBConfig.SecureCookieOverride - SessionCookieName string // Pass-through DbConfig.SessionCookieName - SessionCookieHttpOnly bool // Pass-through DbConfig.SessionCookieHTTPOnly - UserFunctions *UserFunctions // JS/N1QL functions clients can call - GraphQL GraphQL // GraphQL query interface + EnableXattr bool // Use xattr for _sync + LocalDocExpirySecs uint32 // The _local doc expiry time in seconds + SecureCookieOverride bool // Pass-through DBConfig.SecureCookieOverride + SessionCookieName string // Pass-through DbConfig.SessionCookieName + SessionCookieHttpOnly bool // Pass-through DbConfig.SessionCookieHTTPOnly + FunctionsConfig IFunctionsAndGraphQLConfig AllowConflicts *bool // False forbids creating conflicts SendWWWAuthenticateHeader *bool // False disables setting of 'WWW-Authenticate' header DisablePasswordAuthentication bool // True enforces OIDC/guest only @@ -168,12 +172,15 @@ type DatabaseContextOptions struct { ClientPartitionWindow time.Duration BcryptCost int GroupID string + JavaScriptEngine *string // Name of JS engine to use JavascriptTimeout time.Duration // Max time the JS functions run for (ie. sync fn, import filter) Serverless bool // If running in serverless mode Scopes ScopesOptions skipRegisterImportPIndex bool // if set, skips the global gocb PIndex registration MetadataStore base.DataStore // If set, use this location/connection for SG metadata storage - if not set, metadata is stored using the same location/connection as the bucket used for data storage. MetadataID string // MetadataID used for metadata storage + BlipStatsReportingInterval int64 // interval to report blip stats in milliseconds + ChangesRequestPlus bool // Sets the default value for request_plus, for non-continuous changes feeds } type ScopesOptions map[string]ScopeOptions @@ -183,8 +190,8 @@ type ScopeOptions struct { } type CollectionOptions struct { - Sync *string // Collection sync function - ImportFilter *ImportFilterFunction // Opt-in filter for document import + Sync *string // Collection sync function + ImportFilter *string // Source code of filter fn for document import } // Check whether the specified ScopesOptions only defines the default collection @@ -308,17 +315,15 @@ func connectToBucketErrorHandling(ctx context.Context, spec base.BucketSpec, got return false, nil } -type OpenBucketFn func(ctx context.Context, spec base.BucketSpec) (base.Bucket, error) - -// connectToBucketFailFast opens a Couchbase connect and return a specific bucket without retrying on failure. -func connectToBucketFailFast(ctx context.Context, spec base.BucketSpec) (bucket base.Bucket, err error) { - bucket, err = base.GetBucket(spec) - _, err = connectToBucketErrorHandling(ctx, spec, err) - return bucket, err -} +type OpenBucketFn func(context.Context, base.BucketSpec, bool) (base.Bucket, error) -// connectToBucket opens a Couchbase connection and return a specific bucket. -func connectToBucket(ctx context.Context, spec base.BucketSpec) (base.Bucket, error) { +// ConnectToBucket opens a Couchbase connection and return a specific bucket. If failFast is set, fail immediately if the bucket doesn't exist, otherwise retry waiting for bucket to exist. +func ConnectToBucket(ctx context.Context, spec base.BucketSpec, failFast bool) (base.Bucket, error) { + if failFast { + bucket, err := base.GetBucket(spec) + _, err = connectToBucketErrorHandling(ctx, spec, err) + return bucket, err + } // start a retry loop to connect to the bucket backing off double the delay each time worker := func() (bool, error, interface{}) { @@ -340,14 +345,6 @@ func connectToBucket(ctx context.Context, spec base.BucketSpec) (base.Bucket, er return ibucket.(base.Bucket), nil } -// GetConnectToBucketFn returns a different OpenBucketFn to connect to the bucket depending on the value of failFast -func GetConnectToBucketFn(failFast bool) OpenBucketFn { - if failFast { - return connectToBucketFailFast - } - return connectToBucket -} - // Returns Couchbase Server Cluster UUID on a timeout. If running against walrus, do return an empty string. func getServerUUID(ctx context.Context, bucket base.Bucket) (string, error) { gocbV2Bucket, err := base.AsGocbV2Bucket(bucket) @@ -430,6 +427,18 @@ func NewDatabaseContext(ctx context.Context, dbName string, bucket base.Bucket, base.SyncGatewayStats.ClearDBStats(dbName) }) + // Initialize JavaScript VMPool: + jsEngineName := DefaultJavaScriptEngine + if options.JavaScriptEngine != nil { + jsEngineName = *options.JavaScriptEngine + } + if engine := js.EngineNamed(jsEngineName); engine != nil { + dbContext.JS.Init(ctx, engine, MaxJavaScriptVMs) + } else { + return nil, fmt.Errorf("%q is not an available JavaScript engine", jsEngineName) + } + cleanupFunctions = append(cleanupFunctions, dbContext.JS.Close) + if dbContext.AllowConflicts() { dbContext.RevsLimit = DefaultRevsLimitConflicts } else { @@ -530,7 +539,7 @@ func NewDatabaseContext(ctx context.Context, dbName string, bucket base.Bucket, } if collOpts.ImportFilter != nil { - dbCollection.importFilterFunction = collOpts.ImportFilter + dbCollection.importFilterFunction = NewImportFilterFunction(&dbContext.JS, *collOpts.ImportFilter, options.JavascriptTimeout) } dbContext.Scopes[scopeName].Collections[collName] = dbCollection @@ -771,6 +780,13 @@ func NewDatabaseContext(ctx context.Context, dbName string, bucket base.Bucket, dbContext.TombstoneCompactionManager = NewTombstoneCompactionManager() dbContext.AttachmentCompactionManager = NewAttachmentCompactionManager(metadataStore, metaKeys) + if dbContext.Options.FunctionsConfig != nil { + dbContext.UserFunctions, dbContext.GraphQL, err = dbContext.Options.FunctionsConfig.Compile(&dbContext.JS) + if err != nil { + return nil, err + } + } + return dbContext, nil } @@ -824,6 +840,7 @@ func (context *DatabaseContext) Close(ctx context.Context) { base.RemovePerDbStats(context.Name) + context.JS.Close() } // stopBackgroundManagers stops any running BackgroundManager. @@ -1065,16 +1082,21 @@ func (context *DatabaseContext) Authenticator(ctx context.Context) *auth.Authent if context.Options.UnsupportedOptions != nil && context.Options.UnsupportedOptions.WarningThresholds != nil { channelsWarningThreshold = context.Options.UnsupportedOptions.WarningThresholds.ChannelsPerUser } + var channelServerlessThreshold uint32 + if context.IsServerless() { + channelServerlessThreshold = base.ServerlessChannelLimit + } // Authenticators are lightweight & stateless, so it's OK to return a new one every time authenticator := auth.NewAuthenticator(context.MetadataStore, context, auth.AuthenticatorOptions{ - ClientPartitionWindow: context.Options.ClientPartitionWindow, - ChannelsWarningThreshold: channelsWarningThreshold, - SessionCookieName: sessionCookieName, - BcryptCost: context.Options.BcryptCost, - LogCtx: ctx, - Collections: context.CollectionNames, - MetaKeys: context.MetadataKeys, + ClientPartitionWindow: context.Options.ClientPartitionWindow, + ChannelsWarningThreshold: channelsWarningThreshold, + ServerlessChannelThreshold: channelServerlessThreshold, + SessionCookieName: sessionCookieName, + BcryptCost: context.Options.BcryptCost, + LogCtx: ctx, + Collections: context.CollectionNames, + MetaKeys: context.MetadataKeys, }) return authenticator @@ -1906,16 +1928,11 @@ func (db *DatabaseCollectionWithUser) getResyncedDocument(ctx context.Context, d if err != nil { base.WarnfCtx(ctx, "Error getting rev from doc %s/%s %s", base.UD(docid), rev.ID, err) } - var body Body - if err := body.Unmarshal(bodyBytes); err != nil { - base.WarnfCtx(ctx, "Error unmarshalling body %s/%s for sync function %s", base.UD(docid), rev.ID, err) - return - } metaMap, err := doc.GetMetaMap(db.userXattrKey()) if err != nil { return } - channels, access, roles, syncExpiry, _, err := db.getChannelsAndAccess(ctx, doc, body, metaMap, rev.ID) + channels, access, roles, syncExpiry, _, err := db.getChannelsAndAccess(ctx, doc, bodyBytes, metaMap, rev.ID, rev.Deleted) if err != nil { // Probably the validator rejected the doc base.WarnfCtx(ctx, "Error calling sync() on doc %q: %v", base.UD(docid), err) @@ -2162,15 +2179,8 @@ func initDatabaseStats(dbName string, autoImport bool, options DatabaseContextOp } } - if options.UserFunctions != nil { - for _, fn := range options.UserFunctions.Definitions { - if queryName, ok := fn.N1QLQueryName(); ok { - queryNames = append(queryNames, queryName) - } - } - } - if options.GraphQL != nil { - queryNames = append(queryNames, options.GraphQL.N1QLQueryNames()...) + if options.FunctionsConfig != nil { + queryNames = append(queryNames, options.FunctionsConfig.N1QLQueryNames()...) } var collections []string @@ -2319,3 +2329,10 @@ func (dbc *DatabaseContext) AuthenticatorOptions() auth.AuthenticatorOptions { defaultOptions.MetaKeys = dbc.MetadataKeys return defaultOptions } + +// GetRequestPlusSequence fetches the current value of the sequence counter for the database. +// Uses getSequence (instead of lastSequence) as it's intended to be up to date with allocations +// across all nodes, while lastSequence is just the latest allocation from this node +func (dbc *DatabaseContext) GetRequestPlusSequence() (uint64, error) { + return dbc.sequences.getSequence() +} diff --git a/db/database_collection.go b/db/database_collection.go index 68bac60050..13e2184dcc 100644 --- a/db/database_collection.go +++ b/db/database_collection.go @@ -13,6 +13,7 @@ import ( "fmt" "time" + sgbucket "github.com/couchbase/sg-bucket" "github.com/couchbase/sync_gateway/auth" "github.com/couchbase/sync_gateway/base" "github.com/couchbase/sync_gateway/channels" @@ -25,7 +26,7 @@ type DatabaseCollection struct { collectionStats *base.CollectionStats // pointer to the collection stats (to avoid map lookups when used) dbCtx *DatabaseContext // pointer to database context to allow passthrough of functions ChannelMapper *channels.ChannelMapper // Collection's sync function - importFilterFunction *ImportFilterFunction // collections import options + importFilterFunction ImportFilterFunction // collections import options Name string ScopeName string } @@ -176,8 +177,8 @@ func (c *DatabaseCollection) ForceAPIForbiddenErrors() bool { return c.dbCtx.Options.UnsupportedOptions != nil && c.dbCtx.Options.UnsupportedOptions.ForceAPIForbiddenErrors } -// importFilter returns the sync function. -func (c *DatabaseCollection) importFilter() *ImportFilterFunction { +// importFilter returns the import filter function. +func (c *DatabaseCollection) importFilter() ImportFilterFunction { return c.importFilterFunction } @@ -216,6 +217,20 @@ func (c *DatabaseCollection) oldRevExpirySeconds() uint32 { return c.dbCtx.Options.OldRevExpirySeconds } +// Runs a N1QL query. +func (c *DatabaseCollection) Query(ctx context.Context, queryName string, statement string, params map[string]interface{}, consistency base.ConsistencyMode, adhoc bool) (results sgbucket.QueryResultIterator, err error) { + return N1QLQueryWithStats( + ctx, + c.dataStore, + queryName, + statement, + params, + consistency, + adhoc, + c.dbStats(), + c.slowQueryWarningThreshold()) +} + // queryPaginationLimit limits the size of large queries. This is is controlled at a database level. func (c *DatabaseCollection) queryPaginationLimit() int { return c.dbCtx.Options.QueryPaginationLimit @@ -290,9 +305,9 @@ func (c *DatabaseCollection) UpdateSyncFun(ctx context.Context, syncFun string) if syncFun == "" { c.ChannelMapper = nil } else if c.ChannelMapper != nil { - _, err = c.ChannelMapper.SetFunction(syncFun) + err = c.ChannelMapper.SetFunction(syncFun) } else { - c.ChannelMapper = channels.NewChannelMapper(syncFun, c.dbCtx.Options.JavascriptTimeout) + c.ChannelMapper = channels.NewChannelMapper(&c.dbCtx.JS, syncFun, c.dbCtx.Options.JavascriptTimeout) } if err != nil { base.WarnfCtx(ctx, "Error setting sync function: %s", err) diff --git a/db/database_no_v8.go b/db/database_no_v8.go new file mode 100644 index 0000000000..e517c85210 --- /dev/null +++ b/db/database_no_v8.go @@ -0,0 +1,14 @@ +// Copyright 2023-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. + +//go:build !cb_sg_v8 + +package db + +// The default JavaScript engine if not otherwise specified in the DatabaseContextOptions. +const DefaultJavaScriptEngine = "Otto" // Can be "Otto" or "V8" diff --git a/db/database_test.go b/db/database_test.go index 275f336760..009c8ef830 100644 --- a/db/database_test.go +++ b/db/database_test.go @@ -28,14 +28,9 @@ import ( "github.com/couchbase/sync_gateway/auth" "github.com/couchbase/sync_gateway/base" "github.com/couchbase/sync_gateway/channels" - "github.com/robertkrimen/otto/underscore" "github.com/stretchr/testify/assert" ) -func init() { - underscore.Disable() // It really slows down unit tests (by making otto.New take a lot longer) -} - // Note: It is important to call db.Close() on the returned database. func setupTestDB(t testing.TB) (*Database, context.Context) { return setupTestDBWithCacheOptions(t, DefaultCacheOptions()) @@ -49,10 +44,12 @@ func setupTestDBForBucket(t testing.TB, bucket *base.TestBucket) (*Database, con return SetupTestDBForDataStoreWithOptions(t, bucket, dbcOptions) } -func setupTestDBWithOptionsAndImport(t testing.TB, dbcOptions DatabaseContextOptions) (*Database, context.Context) { +func setupTestDBWithOptionsAndImport(t testing.TB, tBucket *base.TestBucket, dbcOptions DatabaseContextOptions) (*Database, context.Context) { ctx := base.TestCtx(t) AddOptionsFromEnvironmentVariables(&dbcOptions) - tBucket := base.GetTestBucket(t) + if tBucket == nil { + tBucket = base.GetTestBucket(t) + } if dbcOptions.Scopes == nil { dbcOptions.Scopes = GetScopesOptions(t, tBucket, 1) } @@ -337,7 +334,7 @@ func TestGetRemovedAsUser(t *testing.T) { db, ctx := setupTestDB(t) defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) rev1body := Body{ "key1": 1234, @@ -446,7 +443,7 @@ func TestGetRemovalMultiChannel(t *testing.T) { db, ctx := setupTestDB(t) defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) auth := db.Authenticator(base.TestCtx(t)) @@ -618,7 +615,7 @@ func TestDeltaSyncWhenToRevIsChannelRemoval(t *testing.T) { db, ctx := setupTestDB(t) defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) // Create the first revision of doc1. rev1Body := Body{ @@ -851,7 +848,7 @@ func TestAllDocsOnly(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) collectionID := collection.GetCollectionID() @@ -1039,7 +1036,7 @@ func TestConflicts(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) // Instantiate channel cache for channel 'all' collectionID := collection.GetCollectionID() @@ -1457,7 +1454,7 @@ func TestInvalidChannel(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) body := Body{"channels": []string{"bad,name"}} _, _, err := collection.Put(ctx, "doc", body) @@ -1849,9 +1846,10 @@ func BenchmarkDatabase(b *testing.B) { for i := 0; i < b.N; i++ { ctx := base.TestCtx(b) - bucket, _ := connectToBucket(ctx, base.BucketSpec{ + bucket, _ := ConnectToBucket(ctx, base.BucketSpec{ Server: base.UnitTestUrl(), - BucketName: fmt.Sprintf("b-%d", i)}) + BucketName: fmt.Sprintf("b-%d", i)}, + true) dbCtx, _ := NewDatabaseContext(ctx, "db", bucket, false, DatabaseContextOptions{}) db, _ := CreateDatabase(dbCtx) collection := GetSingleDatabaseCollectionWithUser(b, db) @@ -1867,9 +1865,10 @@ func BenchmarkPut(b *testing.B) { base.DisableTestLogging(b) ctx := base.TestCtx(b) - bucket, _ := connectToBucket(ctx, base.BucketSpec{ + bucket, _ := ConnectToBucket(ctx, base.BucketSpec{ Server: base.UnitTestUrl(), - BucketName: "Bucket"}) + BucketName: "Bucket"}, + true) context, _ := NewDatabaseContext(ctx, "db", bucket, false, DatabaseContextOptions{}) db, _ := CreateDatabase(context) collection := GetSingleDatabaseCollectionWithUser(b, db) @@ -2456,7 +2455,7 @@ func TestDeleteWithNoTombstoneCreationSupport(t *testing.T) { t.Skip("Xattrs required") } - db, ctx := setupTestDBWithOptionsAndImport(t, DatabaseContextOptions{}) + db, ctx := setupTestDBWithOptionsAndImport(t, nil, DatabaseContextOptions{}) defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) @@ -2971,7 +2970,7 @@ func TestImportCompactPanic(t *testing.T) { } // Set the compaction and purge interval unrealistically low to reproduce faster - db, ctx := setupTestDBWithOptionsAndImport(t, DatabaseContextOptions{ + db, ctx := setupTestDBWithOptionsAndImport(t, nil, DatabaseContextOptions{ CompactInterval: 1, }) defer db.Close(ctx) diff --git a/db/database_v8.go b/db/database_v8.go new file mode 100644 index 0000000000..a2ab901751 --- /dev/null +++ b/db/database_v8.go @@ -0,0 +1,14 @@ +// Copyright 2023-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. + +//go:build cb_sg_v8 + +package db + +// The default JavaScript engine if not otherwise specified in the DatabaseContextOptions. +const DefaultJavaScriptEngine = "V8" // Can be "Otto" or "V8" diff --git a/db/document.go b/db/document.go index 625fbf0027..e2bb013c42 100644 --- a/db/document.go +++ b/db/document.go @@ -279,29 +279,6 @@ func (doc *Document) Body() Body { return doc._body } -// Get a deep mutable copy of the body, using _rawBody. Initializes _rawBody based on _body if not already present. -func (doc *Document) GetDeepMutableBody() (Body, error) { - // If doc._rawBody isn't present, marshal from doc.Body - if doc._rawBody == nil { - if doc._body == nil { - return nil, fmt.Errorf("Unable to get document body due to an empty raw body and body in the document") - } - var err error - doc._rawBody, err = base.JSONMarshal(doc._body) - if err != nil { - return nil, fmt.Errorf("Unable to marshal document body into raw body : %w", err) - } - } - - var mutableBody Body - err := mutableBody.Unmarshal(doc._rawBody) - if err != nil { - return nil, fmt.Errorf("Unable to unmarshal document body into raw body : %w", err) - } - - return mutableBody, nil -} - func (doc *Document) RemoveBody() { doc._body = nil doc._rawBody = nil @@ -338,24 +315,12 @@ func (doc *Document) BodyBytes() ([]byte, error) { // Builds the Meta Map for use in the Sync Function. This meta map currently only includes the user xattr, however, this // can be expanded upon in the future. // NOTE: emptyMetaMap() is used within tests in channelmapper_test.go and therefore this should be expanded if the below is -func (doc *Document) GetMetaMap(userXattrKey string) (map[string]interface{}, error) { - xattrsMap := map[string]interface{}{} - - if userXattrKey != "" { - var userXattr interface{} - - if len(doc.rawUserXattr) > 0 { - err := base.JSONUnmarshal(doc.rawUserXattr, &userXattr) - if err != nil { - return nil, err - } - } - xattrsMap[userXattrKey] = userXattr +func (doc *Document) GetMetaMap(userXattrKey string) (channels.MetaMap, error) { + result := channels.MetaMap{Key: userXattrKey} + if userXattrKey != "" && len(doc.rawUserXattr) > 0 { + result.JSONValue = doc.rawUserXattr } - - return map[string]interface{}{ - base.MetaMapXattrsKey: xattrsMap, - }, nil + return result, nil } func (doc *Document) SetCrc32cUserXattrHash() { diff --git a/db/document_test.go b/db/document_test.go index e15d49ca0a..76fec2f59c 100644 --- a/db/document_test.go +++ b/db/document_test.go @@ -231,61 +231,3 @@ func TestParseDocumentCas(t *testing.T) { assert.Equal(t, uint64(1492749160563736576), casInt) } - -func TestGetDeepMutableBody(t *testing.T) { - testCases := []struct { - name string - inputDoc *Document - expectError bool - expected *Body - }{ - { - name: "Empty doc", - inputDoc: &Document{}, - expectError: true, - expected: nil, - }, - { - name: "Raw body", - inputDoc: &Document{_rawBody: []byte(`{"test": true}`)}, - expectError: false, - expected: &Body{"test": true}, - }, - { - name: "Malformed raw body", - inputDoc: &Document{_rawBody: []byte(`{test: true}`)}, - expectError: true, - expected: nil, - }, - { - name: "Body, no raw body", - inputDoc: &Document{_body: Body{"test": true}}, - expectError: false, - expected: &Body{"test": true}, - }, - { - name: "Inline function in body, no raw body", - inputDoc: &Document{_body: Body{"test": func() bool { return true }}}, - expectError: true, - expected: nil, - }, - { - name: "Body and raw body", - inputDoc: &Document{_rawBody: []byte(`{"test": true}`), _body: Body{"notTest": false}}, - expectError: false, - expected: &Body{"test": true}, - }, - } - for _, test := range testCases { - t.Run(test.name, func(t *testing.T) { - body, err := test.inputDoc.GetDeepMutableBody() - if test.expectError { - assert.Error(t, err) - assert.Nil(t, body) - return - } - assert.Nil(t, err) - assert.Equal(t, *test.expected, body) - }) - } -} diff --git a/db/event.go b/db/event.go index 55e169b246..2442585336 100644 --- a/db/event.go +++ b/db/event.go @@ -15,11 +15,9 @@ import ( "errors" "fmt" "strconv" - "time" - sgbucket "github.com/couchbase/sg-bucket" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" - "github.com/robertkrimen/otto" ) // EventType is an enum for each unique event type. @@ -95,78 +93,23 @@ func (dsce *DBStateChangeEvent) EventType() EventType { return DBStateChange } -// Javascript function handling for events -const kTaskCacheSize = 4 - -type ResponseType uint8 - -const ( - StringResponse ResponseType = iota - JSObjectResponse -) - -// A compiled JavaScript event function. -type jsEventTask struct { - sgbucket.JSRunner - responseType ResponseType -} - -// Compiles a JavaScript event function to a jsEventTask object. -func newJsEventTask(funcSource string) (sgbucket.JSServerTask, error) { - eventTask := &jsEventTask{} - err := eventTask.InitWithLogging(funcSource, 0, - func(s string) { - base.ErrorfCtx(context.Background(), base.KeyJavascript.String()+": Webhook %s", base.UD(s)) - }, - func(s string) { base.InfofCtx(context.Background(), base.KeyJavascript, "Webhook %s", base.UD(s)) }) - if err != nil { - return nil, err - } - - eventTask.After = func(result otto.Value, err error) (interface{}, error) { - nativeValue, _ := result.Export() - /* - switch nativeValue := nativeValue.(type) { - case string: - stringResult = nativeValue - eventTask.responseType = StringResponse - case interface{}: - resultBytes, marshErr := base.JSONMarshal(nativeValue) - if marshErr != nil { - err = marshErr - } else { - stringResult = string(resultBytes) - eventTask.responseType = JSObjectResponse - } - } - */ - return nativeValue, err - } - - return eventTask, nil -} - //////// JSEventFunction -// A thread-safe wrapper around a jsEventTask, i.e. an event function. +// A compiled event function. type JSEventFunction struct { - *sgbucket.JSServer + *js.Service } -func NewJSEventFunction(fnSource string) *JSEventFunction { - +func NewJSEventFunction(host js.ServiceHost, fnSource string) *JSEventFunction { base.InfofCtx(context.Background(), base.KeyEvents, "Creating new JSEventFunction") return &JSEventFunction{ - JSServer: sgbucket.NewJSServer(fnSource, 0, kTaskCacheSize, - func(fnSource string, timeout time.Duration) (sgbucket.JSServerTask, error) { - return newJsEventTask(fnSource) - }), + Service: js.NewService(host, "event", fnSource), } } // Calls a jsEventFunction returning an interface{} func (ef *JSEventFunction) CallFunction(event Event) (interface{}, error) { - + ctx := context.TODO() var err error var result interface{} @@ -174,16 +117,16 @@ func (ef *JSEventFunction) CallFunction(event Event) (interface{}, error) { switch event := event.(type) { case *DocumentChangeEvent: - result, err = ef.Call(sgbucket.JSONString(event.DocBytes), sgbucket.JSONString(event.OldDoc)) + result, err = ef.Run(ctx, js.JSONString(event.DocBytes), js.JSONString(event.OldDoc)) case *DBStateChangeEvent: - result, err = ef.Call(event.Doc) + result, err = ef.Run(ctx, event.Doc) default: base.WarnfCtx(context.TODO(), "unknown event %v tried to call function", event.EventType()) return "", fmt.Errorf("unknown event %v tried to call function", event.EventType()) } if err != nil { - base.WarnfCtx(context.TODO(), "Error calling function - function processing aborted: %v", err) + base.WarnfCtx(ctx, "Error calling function - function processing aborted: %+v", err) return "", err } @@ -192,7 +135,6 @@ func (ef *JSEventFunction) CallFunction(event Event) (interface{}, error) { // Calls a jsEventFunction returning bool. func (ef *JSEventFunction) CallValidateFunction(event Event) (bool, error) { - result, err := ef.CallFunction(event) if err != nil { return false, err @@ -202,14 +144,10 @@ func (ef *JSEventFunction) CallValidateFunction(event Event) (bool, error) { case bool: return result, nil case string: - boolResult, err := strconv.ParseBool(result) - if err != nil { - return false, err - } - return boolResult, nil + return strconv.ParseBool(result) default: base.WarnfCtx(context.TODO(), "Event validate function returned non-boolean result %T %v", result, result) - return false, errors.New("Validate function returned non-boolean value.") + return false, errors.New("validate function returned non-boolean value.") } } diff --git a/db/event_handler.go b/db/event_handler.go index 7bf8102436..4193a53603 100644 --- a/db/event_handler.go +++ b/db/event_handler.go @@ -19,6 +19,7 @@ import ( "net/http" "time" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" ) @@ -50,7 +51,7 @@ const ( ) // Creates a new webhook handler based on the url and filter function. -func NewWebhook(url string, filterFnString string, timeout *uint64, options map[string]interface{}) (*Webhook, error) { +func NewWebhook(url string, filterFnString string, host js.ServiceHost, timeout *uint64, options map[string]interface{}) (*Webhook, error) { var err error @@ -63,7 +64,7 @@ func NewWebhook(url string, filterFnString string, timeout *uint64, options map[ url: url, } if filterFnString != "" { - wh.filter = NewJSEventFunction(filterFnString) + wh.filter = NewJSEventFunction(host, filterFnString) } if timeout != nil { diff --git a/db/event_handler_test.go b/db/event_handler_test.go index 1ad96e29ae..ec38542f75 100644 --- a/db/event_handler_test.go +++ b/db/event_handler_test.go @@ -13,6 +13,7 @@ package db import ( "testing" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" "github.com/stretchr/testify/assert" ) @@ -46,55 +47,60 @@ func TestSanitizedUrl(t *testing.T) { } func TestCallValidateFunction(t *testing.T) { - // Boolean return type handling of CallValidateFunction; Mock up a document change event and - // filter function which returns a bool value while calling CallValidateFunction. - channels := base.SetFromArray([]string{"Netflix"}) - docId, body, oldBodyJSON := "doc1", Body{BodyId: "doc1", "key1": "value1"}, "" - bodyBytes, _ := base.JSONMarshal(body) - event := &DocumentChangeEvent{DocID: docId, DocBytes: bodyBytes, OldDoc: oldBodyJSON, Channels: channels} - - // Boolean return type handling of CallValidateFunction; bool true value. - source := `function(doc) { if (doc.key1 == "value1") { return true; } else { return false; } }` - filterFunc := NewJSEventFunction(source) - result, err := filterFunc.CallValidateFunction(event) - assert.True(t, result, "It should return true since doc.key1 is value1") - assert.NoError(t, err, "It should return boolean result") - - // Boolean return type handling of CallValidateFunction; bool false value. - source = `function(doc) { if (doc.key1 == "value2") { return true; } else { return false; } }` - filterFunc = NewJSEventFunction(source) - result, err = filterFunc.CallValidateFunction(event) - assert.False(t, result, "It should return false since doc.key1 is not value2") - assert.NoError(t, err, "It should return boolean result") - - // Parsable boolean string return type handling of CallValidateFunction. - source = `function(doc) { if (doc.key1 == "value1") { return "true"; } else { return "false"; } }` - filterFunc = NewJSEventFunction(source) - result, err = filterFunc.CallValidateFunction(event) - assert.True(t, result, "It should return true since doc.key1 is value1") - assert.NoError(t, err, "It should return parsable boolean result") - - // Non parsable boolean string return type handling of CallValidateFunction. - source = `function(doc) { if (doc.key1 == "value1") { return "TrUe"; } else { return "false"; } }` - filterFunc = NewJSEventFunction(source) - result, err = filterFunc.CallValidateFunction(event) - assert.False(t, result, "It should return false since 'TrUe' is non parsable boolean string") - assert.Error(t, err, "It should return parsable throw ParseBool error") - assert.Contains(t, err.Error(), `invalid syntax`) - - // Not boolean and not parsable boolean string return type handling of CallValidateFunction. - source = `function(doc) { if (doc.key1 == "Pi") { return 3.14; } else { return 0.0; } }` - filterFunc = NewJSEventFunction(source) - result, err = filterFunc.CallValidateFunction(event) - assert.False(t, result, "It should return not boolean and not parsable boolean string value") - assert.Error(t, err, "It should throw Validate function returned non-boolean value error") - assert.Contains(t, err.Error(), "Validate function returned non-boolean value.") - - // Simulate CallFunction failure by making syntax error in filter function. - source = `function(doc) { invalidKeyword if (doc.key1 == "value1") { return true; } else { return false; } }` - filterFunc = NewJSEventFunction(source) - result, err = filterFunc.CallValidateFunction(event) - assert.False(t, result, "It should return false due to the syntax error in filter function") - assert.Error(t, err, "It should throw an error due to syntax error") - assert.Contains(t, err.Error(), "Unexpected token") + js.TestWithVMs(t, func(t *testing.T, host js.VM) { + // Boolean return type handling of CallValidateFunction; Mock up a document change event and + // filter function which returns a bool value while calling CallValidateFunction. + channels := base.SetFromArray([]string{"Netflix"}) + docId, body, oldBodyJSON := "doc1", Body{BodyId: "doc1", "key1": "value1"}, "" + bodyBytes, _ := base.JSONMarshal(body) + event := &DocumentChangeEvent{DocID: docId, DocBytes: bodyBytes, OldDoc: oldBodyJSON, Channels: channels} + + // Boolean return type handling of CallValidateFunction; bool true value. + source := `function(doc) { if (doc.key1 == "value1") { return true; } else { return false; } }` + filterFunc := NewJSEventFunction(host, source) + result, err := filterFunc.CallValidateFunction(event) + if assert.NoError(t, err, "It should return boolean result") { + assert.True(t, result, "It should return true since doc.key1 is value1") + } + + // Boolean return type handling of CallValidateFunction; bool false value. + source = `function(doc) { if (doc.key1 == "value2") { return true; } else { return false; } }` + filterFunc = NewJSEventFunction(host, source) + result, err = filterFunc.CallValidateFunction(event) + if assert.NoError(t, err, "It should return boolean result") { + assert.False(t, result, "It should return false since doc.key1 is not value2") + } + + // Parsable boolean string return type handling of CallValidateFunction. + source = `function(doc) { if (doc.key1 == "value1") { return "true"; } else { return "false"; } }` + filterFunc = NewJSEventFunction(host, source) + result, err = filterFunc.CallValidateFunction(event) + if assert.NoError(t, err, "It should return parsable boolean result") { + assert.True(t, result, "It should return true since doc.key1 is value1") + } + + // Non parsable boolean string return type handling of CallValidateFunction. + source = `function(doc) { if (doc.key1 == "value1") { return "TrUe"; } else { return "false"; } }` + filterFunc = NewJSEventFunction(host, source) + result, err = filterFunc.CallValidateFunction(event) + assert.False(t, result, "It should return false since 'TrUe' is non parsable boolean string") + assert.Error(t, err, "It should return parsable throw ParseBool error") + assert.Contains(t, err.Error(), `invalid syntax`) + + // Not boolean and not parsable boolean string return type handling of CallValidateFunction. + source = `function(doc) { if (doc.key1 == "Pi") { return 3.14; } else { return 0.0; } }` + filterFunc = NewJSEventFunction(host, source) + result, err = filterFunc.CallValidateFunction(event) + assert.False(t, result, "It should return not boolean and not parsable boolean string value") + assert.Error(t, err, "It should throw Validate function returned non-boolean value error") + assert.Contains(t, err.Error(), "validate function returned non-boolean value.") + + // Simulate CallFunction failure by making syntax error in filter function. + source = `function(doc) { invalidKeyword if (doc.key1 == "value1") { return true; } else { return false; } }` + filterFunc = NewJSEventFunction(host, source) + result, err = filterFunc.CallValidateFunction(event) + assert.False(t, result, "It should return false due to the syntax error in filter function") + assert.Error(t, err, "It should throw an error due to syntax error") + assert.Contains(t, err.Error(), "Unexpected token") + }) } diff --git a/db/event_manager_test.go b/db/event_manager_test.go index 4ec09bb134..f97f0ba4d4 100644 --- a/db/event_manager_test.go +++ b/db/event_manager_test.go @@ -24,6 +24,7 @@ import ( "testing" "time" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" "github.com/stretchr/testify/assert" ) @@ -432,91 +433,93 @@ func InitWebhookTest() (*httptest.Server, *WebhookRequest) { } func TestWebhookBasic(t *testing.T) { - base.LongRunningTest(t) + js.TestWithVMPools(t, 4, func(t *testing.T, host *js.VMPool) { + base.LongRunningTest(t) - terminator := make(chan bool) - defer close(terminator) + terminator := make(chan bool) + defer close(terminator) - ts, wr := InitWebhookTest() - defer ts.Close() - url := ts.URL - - ids := make([]string, 200) - for i := 0; i < 200; i++ { - ids[i] = fmt.Sprintf("%d", i) - } + ts, wr := InitWebhookTest() + defer ts.Close() + url := ts.URL - eventForTest := func(i int) (Body, string, base.Set) { - testBody := Body{ - BodyId: ids[i], - "value": i, + ids := make([]string, 200) + for i := 0; i < 200; i++ { + ids[i] = fmt.Sprintf("%d", i) } - var channelSet base.Set - if i%2 == 0 { - channelSet = base.SetFromArray([]string{"Even"}) - } else { - channelSet = base.SetFromArray([]string{"Odd"}) + + eventForTest := func(i int) (Body, string, base.Set) { + testBody := Body{ + BodyId: ids[i], + "value": i, + } + var channelSet base.Set + if i%2 == 0 { + channelSet = base.SetFromArray([]string{"Even"}) + } else { + channelSet = base.SetFromArray([]string{"Odd"}) + } + return testBody, ids[i], channelSet } - return testBody, ids[i], channelSet - } - // Test basic webhook - log.Println("Test basic webhook") - em := NewEventManager(terminator) - em.Start(0, -1) - webhookHandler, _ := NewWebhook(fmt.Sprintf("%s/echo", url), "", nil, nil) - em.RegisterEventHandler(webhookHandler, DocumentChange) - for i := 0; i < 10; i++ { - body, docId, channels := eventForTest(i) - bodyBytes, _ := base.JSONMarshal(body) - err := em.RaiseDocumentChangeEvent(bodyBytes, docId, "", channels, false) + // Test basic webhook + log.Println("Test basic webhook") + em := NewEventManager(terminator) + em.Start(0, -1) + webhookHandler, _ := NewWebhook(fmt.Sprintf("%s/echo", url), "", nil, nil, nil) + em.RegisterEventHandler(webhookHandler, DocumentChange) + for i := 0; i < 10; i++ { + body, docId, channels := eventForTest(i) + bodyBytes, _ := base.JSONMarshal(body) + err := em.RaiseDocumentChangeEvent(bodyBytes, docId, "", channels, false) + assert.NoError(t, err) + } + err := em.waitForProcessedTotal(base.TestCtx(t), 10, DefaultWaitForWebhook) assert.NoError(t, err) - } - err := em.waitForProcessedTotal(base.TestCtx(t), 10, DefaultWaitForWebhook) - assert.NoError(t, err) - assert.Equal(t, int64(10), em.GetEventsProcessedSuccess()) - - // Test webhook filter function - log.Println("Test filter function") - wr.Clear() - em = NewEventManager(terminator) - em.Start(0, -1) - filterFunction := `function(doc) { + assert.Equal(t, int64(10), em.GetEventsProcessedSuccess()) + + // Test webhook filter function + log.Println("Test filter function") + wr.Clear() + em = NewEventManager(terminator) + em.Start(0, -1) + filterFunction := `function(doc) { if (doc.value < 6) { return false; } else { return true; } }` - webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/echo", url), filterFunction, nil, nil) - em.RegisterEventHandler(webhookHandler, DocumentChange) - for i := 0; i < 10; i++ { - body, docId, channels := eventForTest(i) - bodyBytes, _ := base.JSONMarshal(body) - err := em.RaiseDocumentChangeEvent(bodyBytes, docId, "", channels, false) - assert.NoError(t, err) - } - - err = em.waitForProcessedTotal(base.TestCtx(t), 10, DefaultWaitForWebhook) - assert.NoError(t, err) - assert.Equal(t, int64(4), em.GetEventsProcessedSuccess()) + webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/echo", url), filterFunction, host, nil, nil) + em.RegisterEventHandler(webhookHandler, DocumentChange) + for i := 0; i < 10; i++ { + body, docId, channels := eventForTest(i) + bodyBytes, _ := base.JSONMarshal(body) + err := em.RaiseDocumentChangeEvent(bodyBytes, docId, "", channels, false) + assert.NoError(t, err) + } - // Validate payload - log.Println("Test payload validation") - wr.Clear() - em = NewEventManager(terminator) - em.Start(0, -1) - webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/echo", url), "", nil, nil) - em.RegisterEventHandler(webhookHandler, DocumentChange) - body, docId, channels := eventForTest(0) - bodyBytes, _ := base.JSONMarshalCanonical(body) - err = em.RaiseDocumentChangeEvent(bodyBytes, docId, "", channels, false) - assert.NoError(t, err) - err = em.waitForProcessedTotal(base.TestCtx(t), 1, DefaultWaitForWebhook) - assert.NoError(t, err) - receivedPayload := string((wr.GetPayloads())[0]) - fmt.Println("payload:", receivedPayload) - assert.Equal(t, `{"_id":"0","value":0}`, receivedPayload) + err = em.waitForProcessedTotal(base.TestCtx(t), 10, DefaultWaitForWebhook) + assert.NoError(t, err) + assert.Equal(t, int64(4), em.GetEventsProcessedSuccess()) + + // Validate payload + log.Println("Test payload validation") + wr.Clear() + em = NewEventManager(terminator) + em.Start(0, -1) + webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/echo", url), "", nil, nil, nil) + em.RegisterEventHandler(webhookHandler, DocumentChange) + body, docId, channels := eventForTest(0) + bodyBytes, _ := base.JSONMarshalCanonical(body) + err = em.RaiseDocumentChangeEvent(bodyBytes, docId, "", channels, false) + assert.NoError(t, err) + err = em.waitForProcessedTotal(base.TestCtx(t), 1, DefaultWaitForWebhook) + assert.NoError(t, err) + receivedPayload := string((wr.GetPayloads())[0]) + fmt.Println("payload:", receivedPayload) + assert.Equal(t, `{"_id":"0","value":0}`, receivedPayload) + }) } func TestWebhookOverflows(t *testing.T) { @@ -557,7 +560,7 @@ func TestWebhookOverflows(t *testing.T) { em := NewEventManager(terminator) em.Start(5, -1) timeout := uint64(60) - webhookHandler, _ := NewWebhook(fmt.Sprintf("%s/echo", url), "", &timeout, nil) + webhookHandler, _ := NewWebhook(fmt.Sprintf("%s/echo", url), "", nil, &timeout, nil) em.RegisterEventHandler(webhookHandler, DocumentChange) for i := 0; i < 100; i++ { body, docId, channels := eventForTest(i % 10) @@ -577,7 +580,7 @@ func TestWebhookOverflows(t *testing.T) { errCount := 0 em = NewEventManager(terminator) em.Start(5, 1) - webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/slow", url), "", nil, nil) + webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/slow", url), "", nil, nil, nil) em.RegisterEventHandler(webhookHandler, DocumentChange) for i := 0; i < 100; i++ { body, docId, channels := eventForTest(i) @@ -600,7 +603,7 @@ func TestWebhookOverflows(t *testing.T) { wr.Clear() em = NewEventManager(terminator) em.Start(5, 1500) - webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/slow", url), "", nil, nil) + webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/slow", url), "", nil, nil, nil) em.RegisterEventHandler(webhookHandler, DocumentChange) for i := 0; i < 100; i++ { body, docId, channels := eventForTest(i % 10) @@ -616,143 +619,144 @@ func TestWebhookOverflows(t *testing.T) { // Test Webhook where there is an old doc revision and where the filter // function is expecting an old doc revision. func TestWebhookOldDoc(t *testing.T) { - terminator := make(chan bool) - defer close(terminator) + js.TestWithVMPools(t, 4, func(t *testing.T, host *js.VMPool) { + terminator := make(chan bool) + defer close(terminator) - ts, wr := InitWebhookTest() - defer ts.Close() - url := ts.URL - - ids := make([]string, 200) - for i := 0; i < 200; i++ { - ids[i] = fmt.Sprintf("%d", i) - } + ts, wr := InitWebhookTest() + defer ts.Close() + url := ts.URL - eventForTest := func(k string, v int) (Body, string, base.Set) { - testBody := Body{ - BodyId: ids[v], - "value": k, - } - var channelSet base.Set - if v%2 == 0 { - channelSet = base.SetFromArray([]string{"Even"}) - } else { - channelSet = base.SetFromArray([]string{"Odd"}) + ids := make([]string, 200) + for i := 0; i < 200; i++ { + ids[i] = fmt.Sprintf("%d", i) } - return testBody, ids[v], channelSet - } - // Test basic webhook where an old doc is passed but not filtered - log.Println("Test basic webhook where an old doc is passed but not filtered") - em := NewEventManager(terminator) - em.Start(0, -1) - webhookHandler, _ := NewWebhook(fmt.Sprintf("%s/echo", url), "", nil, nil) - em.RegisterEventHandler(webhookHandler, DocumentChange) - for i := 0; i < 10; i++ { - oldBody, oldDocId, _ := eventForTest(strconv.Itoa(-i), i) - oldBody[BodyId] = oldDocId - oldBodyBytes, _ := base.JSONMarshal(oldBody) - body, docId, channels := eventForTest(strconv.Itoa(i), i) - bodyBytes, _ := base.JSONMarshal(body) - err := em.RaiseDocumentChangeEvent(bodyBytes, docId, string(oldBodyBytes), channels, false) - assert.NoError(t, err) + eventForTest := func(k string, v int) (Body, string, base.Set) { + testBody := Body{ + BodyId: ids[v], + "value": k, + } + var channelSet base.Set + if v%2 == 0 { + channelSet = base.SetFromArray([]string{"Even"}) + } else { + channelSet = base.SetFromArray([]string{"Odd"}) + } + return testBody, ids[v], channelSet + } - } - err := em.waitForProcessedTotal(base.TestCtx(t), 10, DefaultWaitForWebhook) - assert.NoError(t, err) - assert.Equal(t, int64(10), em.eventsProcessedSuccess) - log.Printf("Actual: %v, Expected: %v", wr.GetCount(), 10) + // Test basic webhook where an old doc is passed but not filtered + log.Println("Test basic webhook where an old doc is passed but not filtered") + em := NewEventManager(terminator) + em.Start(0, -1) + webhookHandler, _ := NewWebhook(fmt.Sprintf("%s/echo", url), "", nil, nil, nil) + em.RegisterEventHandler(webhookHandler, DocumentChange) + for i := 0; i < 10; i++ { + oldBody, oldDocId, _ := eventForTest(strconv.Itoa(-i), i) + oldBody[BodyId] = oldDocId + oldBodyBytes, _ := base.JSONMarshal(oldBody) + body, docId, channels := eventForTest(strconv.Itoa(i), i) + bodyBytes, _ := base.JSONMarshal(body) + err := em.RaiseDocumentChangeEvent(bodyBytes, docId, string(oldBodyBytes), channels, false) + assert.NoError(t, err) - // Test webhook where an old doc is passed and is not used by the filter - log.Println("Test filter function with old doc which is not referenced") - wr.Clear() - em = NewEventManager(terminator) - em.Start(0, -1) - filterFunction := `function(doc) { + } + err := em.waitForProcessedTotal(base.TestCtx(t), 10, DefaultWaitForWebhook) + assert.NoError(t, err) + assert.Equal(t, int64(10), em.eventsProcessedSuccess) + log.Printf("Actual: %v, Expected: %v", wr.GetCount(), 10) + + // Test webhook where an old doc is passed and is not used by the filter + log.Println("Test filter function with old doc which is not referenced") + wr.Clear() + em = NewEventManager(terminator) + em.Start(0, -1) + filterFunction := `function(doc) { if (doc.value < 6) { return false; } else { return true; } }` - webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/echo", url), filterFunction, nil, nil) - em.RegisterEventHandler(webhookHandler, DocumentChange) - for i := 0; i < 10; i++ { - oldBody, oldDocId, _ := eventForTest(strconv.Itoa(-i), i) - oldBody[BodyId] = oldDocId - oldBodyBytes, _ := base.JSONMarshal(oldBody) - body, docId, channels := eventForTest(strconv.Itoa(i), i) - bodyBytes, _ := base.JSONMarshal(body) - err := em.RaiseDocumentChangeEvent(bodyBytes, docId, string(oldBodyBytes), channels, false) + webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/echo", url), filterFunction, host, nil, nil) + em.RegisterEventHandler(webhookHandler, DocumentChange) + for i := 0; i < 10; i++ { + oldBody, oldDocId, _ := eventForTest(strconv.Itoa(-i), i) + oldBody[BodyId] = oldDocId + oldBodyBytes, _ := base.JSONMarshal(oldBody) + body, docId, channels := eventForTest(strconv.Itoa(i), i) + bodyBytes, _ := base.JSONMarshal(body) + err := em.RaiseDocumentChangeEvent(bodyBytes, docId, string(oldBodyBytes), channels, false) + assert.NoError(t, err) + } + err = em.waitForProcessedTotal(base.TestCtx(t), 10, DefaultWaitForWebhook) assert.NoError(t, err) - } - err = em.waitForProcessedTotal(base.TestCtx(t), 10, DefaultWaitForWebhook) - assert.NoError(t, err) - assert.Equal(t, int64(4), em.eventsProcessedSuccess) - log.Printf("Actual: %v, Expected: %v", wr.GetCount(), 4) - - // Test webhook where an old doc is passed and is validated by the filter - log.Println("Test filter function with old doc") - wr.Clear() - em = NewEventManager(terminator) - em.Start(0, -1) - filterFunction = `function(doc, oldDoc) { + assert.Equal(t, int64(4), em.eventsProcessedSuccess) + log.Printf("Actual: %v, Expected: %v", wr.GetCount(), 4) + + // Test webhook where an old doc is passed and is validated by the filter + log.Println("Test filter function with old doc") + wr.Clear() + em = NewEventManager(terminator) + em.Start(0, -1) + filterFunction = `function(doc, oldDoc) { if (doc.value < 6 && doc.value == -oldDoc.value) { return false; } else { return true; } }` - webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/echo", url), filterFunction, nil, nil) - em.RegisterEventHandler(webhookHandler, DocumentChange) - for i := 0; i < 10; i++ { - oldBody, oldDocId, _ := eventForTest(strconv.Itoa(-i), i) - oldBody[BodyId] = oldDocId - oldBodyBytes, _ := base.JSONMarshal(oldBody) - body, docId, channels := eventForTest(strconv.Itoa(i), i) - bodyBytes, _ := base.JSONMarshal(body) - err := em.RaiseDocumentChangeEvent(bodyBytes, docId, string(oldBodyBytes), channels, false) + webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/echo", url), filterFunction, host, nil, nil) + em.RegisterEventHandler(webhookHandler, DocumentChange) + for i := 0; i < 10; i++ { + oldBody, oldDocId, _ := eventForTest(strconv.Itoa(-i), i) + oldBody[BodyId] = oldDocId + oldBodyBytes, _ := base.JSONMarshal(oldBody) + body, docId, channels := eventForTest(strconv.Itoa(i), i) + bodyBytes, _ := base.JSONMarshal(body) + err := em.RaiseDocumentChangeEvent(bodyBytes, docId, string(oldBodyBytes), channels, false) + assert.NoError(t, err) + } + err = em.waitForProcessedTotal(base.TestCtx(t), 10, DefaultWaitForWebhook) assert.NoError(t, err) - } - err = em.waitForProcessedTotal(base.TestCtx(t), 10, DefaultWaitForWebhook) - assert.NoError(t, err) - assert.Equal(t, int64(4), em.eventsProcessedSuccess) - log.Printf("Actual: %v, Expected: %v", wr.GetCount(), 4) - - // Test webhook where an old doc is not passed but is referenced in the filter function args - log.Println("Test filter function with old doc") - wr.Clear() - em = NewEventManager(terminator) - em.Start(0, -1) - filterFunction = `function(doc, oldDoc) { + assert.Equal(t, int64(4), em.eventsProcessedSuccess) + log.Printf("Actual: %v, Expected: %v", wr.GetCount(), 4) + + // Test webhook where an old doc is not passed but is referenced in the filter function args + log.Println("Test filter function with old doc") + wr.Clear() + em = NewEventManager(terminator) + em.Start(0, -1) + filterFunction = `function(doc, oldDoc) { if (oldDoc) { return true; } else { return false; } }` - webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/echo", url), filterFunction, nil, nil) - em.RegisterEventHandler(webhookHandler, DocumentChange) - for i := 0; i < 10; i++ { - body, docId, channels := eventForTest(strconv.Itoa(i), i) - bodyBytes, _ := base.JSONMarshal(body) - err := em.RaiseDocumentChangeEvent(bodyBytes, docId, "", channels, false) - assert.NoError(t, err) - } - for i := 10; i < 20; i++ { - oldBody, oldDocId, _ := eventForTest(strconv.Itoa(-i), i) - oldBody[BodyId] = oldDocId - oldBodyBytes, _ := base.JSONMarshal(oldBody) - body, docId, channels := eventForTest(strconv.Itoa(i), i) - bodyBytes, _ := base.JSONMarshal(body) - err := em.RaiseDocumentChangeEvent(bodyBytes, docId, string(oldBodyBytes), channels, false) + webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/echo", url), filterFunction, host, nil, nil) + em.RegisterEventHandler(webhookHandler, DocumentChange) + for i := 0; i < 10; i++ { + body, docId, channels := eventForTest(strconv.Itoa(i), i) + bodyBytes, _ := base.JSONMarshal(body) + err := em.RaiseDocumentChangeEvent(bodyBytes, docId, "", channels, false) + assert.NoError(t, err) + } + for i := 10; i < 20; i++ { + oldBody, oldDocId, _ := eventForTest(strconv.Itoa(-i), i) + oldBody[BodyId] = oldDocId + oldBodyBytes, _ := base.JSONMarshal(oldBody) + body, docId, channels := eventForTest(strconv.Itoa(i), i) + bodyBytes, _ := base.JSONMarshal(body) + err := em.RaiseDocumentChangeEvent(bodyBytes, docId, string(oldBodyBytes), channels, false) + assert.NoError(t, err) + } + err = em.waitForProcessedTotal(base.TestCtx(t), 20, DefaultWaitForWebhook) assert.NoError(t, err) - } - err = em.waitForProcessedTotal(base.TestCtx(t), 20, DefaultWaitForWebhook) - assert.NoError(t, err) - assert.Equal(t, int64(10), em.eventsProcessedSuccess) - log.Printf("Actual: %v, Expected: %v", wr.GetCount(), 10) - + assert.Equal(t, int64(10), em.eventsProcessedSuccess) + log.Printf("Actual: %v, Expected: %v", wr.GetCount(), 10) + }) } func TestWebhookTimeout(t *testing.T) { @@ -790,7 +794,7 @@ func TestWebhookTimeout(t *testing.T) { em := NewEventManager(terminator) em.Start(0, -1) timeout := uint64(2) - webhookHandler, _ := NewWebhook(fmt.Sprintf("%s/echo", url), "", &timeout, nil) + webhookHandler, _ := NewWebhook(fmt.Sprintf("%s/echo", url), "", nil, &timeout, nil) em.RegisterEventHandler(webhookHandler, DocumentChange) for i := 0; i < 10; i++ { body, docid, channels := eventForTest(strconv.Itoa(i), i) @@ -812,7 +816,7 @@ func TestWebhookTimeout(t *testing.T) { em = NewEventManager(terminator) em.Start(1, 1500) timeout = uint64(1) - webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/slow_2s", url), "", &timeout, nil) + webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/slow_2s", url), "", nil, &timeout, nil) em.RegisterEventHandler(webhookHandler, DocumentChange) for i := 0; i < 10; i++ { body, docid, channels := eventForTest(strconv.Itoa(i), i) @@ -837,7 +841,7 @@ func TestWebhookTimeout(t *testing.T) { em = NewEventManager(terminator) em.Start(1, 100) timeout = uint64(9) - webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/slow_5s", url), "", &timeout, nil) + webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/slow_5s", url), "", nil, &timeout, nil) em.RegisterEventHandler(webhookHandler, DocumentChange) for i := 0; i < 10; i++ { body, docid, channels := eventForTest(strconv.Itoa(i), i) @@ -860,7 +864,7 @@ func TestWebhookTimeout(t *testing.T) { em = NewEventManager(terminator) em.Start(1, 1500) timeout = uint64(0) - webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/slow", url), "", &timeout, nil) + webhookHandler, _ = NewWebhook(fmt.Sprintf("%s/slow", url), "", nil, &timeout, nil) em.RegisterEventHandler(webhookHandler, DocumentChange) for i := 0; i < 10; i++ { body, docid, channels := eventForTest(strconv.Itoa(i), i) @@ -908,7 +912,7 @@ func TestUnavailableWebhook(t *testing.T) { em := NewEventManager(terminator) em.Start(0, -1) - webhookHandler, _ := NewWebhook("http://badhost:1000/echo", "", nil, nil) + webhookHandler, _ := NewWebhook("http://badhost:1000/echo", "", nil, nil, nil) em.RegisterEventHandler(webhookHandler, DocumentChange) for i := 0; i < 10; i++ { body, docId, channels := eventForTest(strconv.Itoa(-i), i) @@ -978,14 +982,16 @@ func TestWebhookHandleUnsupportedEventType(t *testing.T) { // Simulate the filter function processing abort scenario. func TestWebhookHandleEventDBStateChangeFilterFuncError(t *testing.T) { - ts, _ := InitWebhookTest() - defer ts.Close() - wh := &Webhook{url: ts.URL} - event := mockDBStateChangeEvent("db", "online", "Index service is listening", "127.0.0.1:4985") - source := `function (doc) { invalidKeyword if (doc.state == "online") { return true; } else { return false; } }` - wh.filter = NewJSEventFunction(source) - success := wh.HandleEvent(event) - assert.False(t, success, "Filter function processing should be aborted and warnings should be logged") + js.TestWithVMPools(t, 4, func(t *testing.T, host *js.VMPool) { + ts, _ := InitWebhookTest() + defer ts.Close() + wh := &Webhook{url: ts.URL} + event := mockDBStateChangeEvent("db", "online", "Index service is listening", "127.0.0.1:4985") + source := `function (doc) { invalidKeyword if (doc.state == "online") { return true; } else { return false; } }` + wh.filter = NewJSEventFunction(host, source) + success := wh.HandleEvent(event) + assert.False(t, success, "Filter function processing should be aborted and warnings should be logged") + }) } // Simulate marshalling doc error for webhook post against DBStateChangeEvent diff --git a/db/functions.go b/db/functions.go index 80d3a67e02..1d14b67f72 100644 --- a/db/functions.go +++ b/db/functions.go @@ -18,9 +18,9 @@ import ( "time" sgbucket "github.com/couchbase/sg-bucket" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/auth" "github.com/couchbase/sync_gateway/base" - "github.com/graphql-go/graphql" ) /* This is the interface to the functions and GraphQL APIs implemented in the functions package. */ @@ -28,6 +28,15 @@ import ( // Timeout for N1QL, JavaScript and GraphQL queries. (Applies to REST and BLIP requests.) const defaultUserFunctionTimeout = 60 * time.Second +// Abstract interface for user-functions & GraphQL configuration. (Implemented by functions.Config) +type IFunctionsAndGraphQLConfig interface { + // Compiles the configuration into a live UserFunctions intance. + Compile(*js.VMPool) (*UserFunctions, GraphQL, error) + + // Returns the names of all N1QL queries used. + N1QLQueryNames() []string +} + //////// USER FUNCTIONS // A map from names to user functions. @@ -58,6 +67,9 @@ type UserFunctionInvocation interface { // Calls a user function, returning the entire result. // (If this is a N1QL query it will return all the result rows in an array, which is less efficient than iterating them, so try calling `Iterate` first.) Run() (interface{}, error) + + // Same as Run() but the result is encoded as JSON. + RunAsJSON() ([]byte, error) } //////// GRAPHQL @@ -69,18 +81,47 @@ type GraphQL interface { MaxRequestSize() *int // Runs a GraphQL query on behalf of a user, presumably invoked via a REST or BLIP API. - Query(db *Database, query string, operationName string, variables map[string]interface{}, mutationAllowed bool, ctx context.Context) (*graphql.Result, error) + // The result is an object with keys `data`, `errors`. + // If `jsonEncoded` is true, it will be JSON-encoded and returned as a []byte. + Query(db *Database, query string, operationName string, variables map[string]interface{}, mutationAllowed bool, ctx context.Context) (*GraphQLResult, error) + + // Same as Query() but the result is JSON-encoded. + QueryAsJSON(db *Database, query string, operationName string, variables map[string]interface{}, mutationAllowed bool, ctx context.Context) ([]byte, error) // Returns the names of all N1QL queries used. N1QLQueryNames() []string } +// Go representation of JSON result of a GraphQL query. +type GraphQLResult struct { + Data interface{} `json:"data"` + Errors []*FormattedError `json:"errors,omitempty"` + Extensions map[string]interface{} `json:"extensions,omitempty"` +} + +// Go representation of an error in a GraphQL query result. +type FormattedError struct { + Message string `json:"message"` + Locations []SourceLocation `json:"locations"` + Path []interface{} `json:"path,omitempty"` + Extensions map[string]interface{} `json:"extensions,omitempty"` +} + +func (err *FormattedError) Error() string { + return err.Message +} + +type SourceLocation struct { + Line int `json:"line"` + Column int `json:"column"` +} + //////// DATABASE API FOR USER FUNCTIONS: // Looks up a UserFunction by name and returns an Invocation. func (db *Database) GetUserFunction(name string, args map[string]interface{}, mutationAllowed bool, ctx context.Context) (UserFunctionInvocation, error) { - if db.Options.UserFunctions != nil { - if fn, found := db.Options.UserFunctions.Definitions[name]; found { + if db.UserFunctions != nil { + if fn, found := db.UserFunctions.Definitions[name]; found { return fn.Invoke(db, args, mutationAllowed, ctx) } } @@ -97,8 +138,8 @@ func (db *Database) CallUserFunction(name string, args map[string]interface{}, m } // Top-level public method to run a GraphQL query on a db.Database. -func (db *Database) UserGraphQLQuery(query string, operationName string, variables map[string]interface{}, mutationAllowed bool, ctx context.Context) (*graphql.Result, error) { - if graphql := db.Options.GraphQL; graphql == nil { +func (db *Database) UserGraphQLQuery(query string, operationName string, variables map[string]interface{}, mutationAllowed bool, ctx context.Context) (*GraphQLResult, error) { + if graphql := db.GraphQL; graphql == nil { return nil, base.HTTPErrorf(http.StatusServiceUnavailable, "GraphQL is not configured") } else { return graphql.Query(db, query, operationName, variables, mutationAllowed, ctx) diff --git a/db/functions/callbacks.go b/db/functions/callbacks.go new file mode 100644 index 0000000000..6065dd688a --- /dev/null +++ b/db/functions/callbacks.go @@ -0,0 +1,244 @@ +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +package functions + +import ( + "bytes" + "context" + "errors" + "fmt" + "net/http" + + "github.com/couchbase/gocb/v2" + sgbucket "github.com/couchbase/sg-bucket" + "github.com/couchbase/sync_gateway/base" + "github.com/couchbase/sync_gateway/db" +) + +type n1qlUserArgument struct { + Name *string `json:"name,omitempty"` + Channels []string `json:"channels,omitempty"` + Roles []string `json:"roles,omitempty"` +} + +//////// DATABASE EVALUATOR DELEGATE: + +// The "real" implementation of EvaluatorDelegate. +type databaseDelegate struct { + db *db.Database // The database (with user) + ctx context.Context // Context for timeouts etc. + user *userCredentials // User's info +} + +func (d *databaseDelegate) init(dbc *db.Database, ctx context.Context) error { + if ctx == nil { + return fmt.Errorf("missing Context") + } + if err := db.CheckTimeout(ctx); err != nil { + return err + } + d.db = dbc + d.ctx = ctx + if dbUser := dbc.User(); dbUser != nil { + d.user = &userCredentials{ + Name: dbUser.Name(), + Roles: dbUser.RoleNames().AllKeys(), + Channels: dbUser.Channels().AllKeys(), + } + } + return nil +} + +func (d *databaseDelegate) getCollection(collectionName string) (*db.DatabaseCollectionWithUser, error) { + return d.db.GetDatabaseCollectionWithUser(base.DefaultScope, collectionName) +} + +// Temporarily gives the `db.Database` admin powers. Returns a fn that will revert the upgrade. +// Must be called as `defer d.asAdmin()()` +func (d *databaseDelegate) asAdmin() func() { + user := d.db.User() + d.db.SetUser(nil) + return func() { d.db.SetUser(user) } // <-- this is what will be run by `defer` +} + +func (d *databaseDelegate) checkTimeout() error { + return db.CheckTimeout(d.ctx) +} + +func (d *databaseDelegate) get(docID string, collectionName string, asAdmin bool) (doc map[string]any, err error) { + if asAdmin { + defer d.asAdmin()() + } + collection, err := d.getCollection(collectionName) + if err != nil { + return nil, err + } + rev, err := collection.GetRev(d.ctx, docID, "", false, nil) + if err != nil { + status, _ := base.ErrorAsHTTPStatus(err) + if status == http.StatusNotFound { + // Not-found is not an error; just return null. + return nil, nil + } + return nil, err + } + body, err := rev.Body() + if err != nil { + return nil, err + } + body["_id"] = docID + body["_rev"] = rev.RevID + return body, nil +} + +func (d *databaseDelegate) save(body map[string]any, docID string, collectionName string, asAdmin bool) (bool, error) { + if asAdmin { + defer d.asAdmin()() + } + delete(body, "_id") + collection, err := d.getCollection(collectionName) + if err != nil { + return false, err + } + if _, found := body["_rev"]; found { + // If caller provided `_rev` property, use MVCC as normal: + if _, _, err := collection.Put(d.ctx, docID, body); err != nil { + if status, _ := base.ErrorAsHTTPStatus(err); status == http.StatusConflict { + err = nil // conflict: no error, but returns false + } + return false, err + } + + } else { + // If caller didn't provide a `_rev` property, fall back to "last writer wins": + // get the current revision if any, and pass it to Put so that the save always succeeds. + for { + rev, err := collection.GetRev(d.ctx, docID, "", false, []string{}) + if err != nil { + if status, _ := base.ErrorAsHTTPStatus(err); status != http.StatusNotFound { + return false, err + } else if del, found := body["_deleted"].(bool); found && del { + // Deleting nonexistent doc: success + return true, nil + } + } + if rev.RevID == "" { + delete(body, "_rev") + } else { + body["_rev"] = rev.RevID + } + + _, _, err = collection.Put(d.ctx, docID, body) + if err == nil { + break // success! + } else if status, _ := base.ErrorAsHTTPStatus(err); status != http.StatusConflict { + return false, err + } + // on conflict (race condition), retry... + } + } + // success + return true, nil +} + +func (d *databaseDelegate) delete(docID string, revID string, collectionName string, asAdmin bool) (bool, error) { + tombstone := map[string]any{"_deleted": true} + if revID != "" { + tombstone["_rev"] = revID + } + return d.save(tombstone, docID, collectionName, asAdmin) +} + +func (d *databaseDelegate) query(fnName string, n1ql string, args map[string]any, asAdmin bool) (string, error) { + var userArg n1qlUserArgument + if asAdmin { + defer d.asAdmin()() + } else if d.user != nil { + userArg.Name = base.StringPtr(d.user.Name) + userArg.Channels = d.user.Channels + userArg.Roles = d.user.Roles + } + if args == nil { + args = map[string]any{} + } + args["user"] = &userArg + + // Run the N1QL query: + rows, err := db.N1QLQueryWithStats( + d.ctx, + d.db.Bucket.DefaultDataStore(), + db.QueryTypeUserFunctionPrefix+fnName, + n1ql, + args, + base.RequestPlus, + false, + d.db.DbStats, + d.db.Options.SlowQueryWarningThreshold) + + var rowsJSON string + if err == nil { + // JSON-encode the iterator (see below): + rowsJSON, err = d.writeRowsToJSON(rows) + } + if err != nil { + // Return a friendlier error: + var qe *gocb.QueryError + if errors.As(err, &qe) { + base.WarnfCtx(d.ctx, "Error running query %q: %v", fnName, err) + return "", base.HTTPErrorf(http.StatusInternalServerError, "Query %q: %s", fnName, qe.Errors[0].Message) + } else { + base.WarnfCtx(d.ctx, "Unknown error running query %q: %T %#v", fnName, err, err) + return "", base.HTTPErrorf(http.StatusInternalServerError, "Unknown error running query %q (see logs)", fnName) + } + } + return rowsJSON, nil +} + +// Subroutine of `query` that encodes the QueryResultIterator as a JSON array. +// Guarantees to close the iterator. +func (d *databaseDelegate) writeRowsToJSON(rows sgbucket.QueryResultIterator) (string, error) { + defer func() { + if rows != nil { + _ = rows.Close() // only called if there's an error already + } + }() + + var out bytes.Buffer + out.Write([]byte(`[`)) + first := true + var row interface{} + for rows.Next(&row) { + if first { + first = false + } else { + if _, err := out.Write([]byte(`,`)); err != nil { + return "", err + } + } + enc := base.JSONEncoderCanonical(&out) + if err := enc.Encode(row); err != nil { + return "", err + } + // The iterator streams results as the query engine produces them, so this loop may take most of the query's time; check for timeout after each iteration: + if err := db.CheckTimeout(d.ctx); err != nil { + return "", err + } + } + err := rows.Close() + rows = nil // prevent double-close on exit + if err != nil { + return "", err + } + if _, err := out.Write([]byte("]\n")); err != nil { + return "", err + } + return out.String(), nil +} diff --git a/db/functions/concurrent_test.go b/db/functions/concurrent_test.go new file mode 100644 index 0000000000..dcd77c8818 --- /dev/null +++ b/db/functions/concurrent_test.go @@ -0,0 +1,95 @@ +//go:build cb_sg_v8 + +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +package functions + +import ( + "context" + "log" + "runtime" + "sync" + "testing" + "time" + + "github.com/couchbase/sync_gateway/base" + "github.com/stretchr/testify/assert" +) + +const kConcurrentTestNumTasks = 100000 +const kConcurrentTestTimeout = 60 * time.Second + +func TestGraphQLConcurrently(t *testing.T) { + const kConcurrentTestNumTasks = 100000 + maxProcs := runtime.GOMAXPROCS(0) + log.Printf("FYI, GOMAXPROCS = %d", maxProcs) + + fnConfig := &FunctionsConfig{ + Definitions: FunctionsDefs{ + "square": { + Type: "javascript", + Code: "function(context,args) {return args.n * args.n;}", + Args: []string{"n"}, + Allow: &Allow{Channels: []string{"*"}}, + }, + }, + } + gqConfig := &GraphQLConfig{ + Schema: base.StringPtr(`type Query { square(n: Int!): Int! }`), + Resolvers: map[string]GraphQLResolverConfig{ + "Query": { + "square": FunctionConfig{ + Type: "javascript", + Code: `function(context,args) {return args.n * args.n;}`, + Allow: &Allow{Channels: []string{"*"}}, + }, + }, + }, + } + + db, ctx := setupTestDBWithFunctionsAndLogging(t, fnConfig, gqConfig, false) + defer db.Close(ctx) + + runConcurrently(ctx, kConcurrentTestNumTasks, maxProcs, func(ctx context.Context) bool { + _, err := db.UserGraphQLQuery(`{"query":"query{ square(n:13) }"}`, "", nil, false, ctx) + return assert.Nil(t, err) + }) +} + +func runSequentially(ctx context.Context, numTasks int, testFunc func(context.Context) bool) time.Duration { + ctx, cancel := context.WithTimeout(ctx, kConcurrentTestTimeout) + defer cancel() + startTime := time.Now() + for i := 0; i < numTasks; i++ { + testFunc(ctx) + } + return time.Since(startTime) +} + +func runConcurrently(ctx context.Context, numTasks int, numThreads int, testFunc func(context.Context) bool) time.Duration { + var wg sync.WaitGroup + startTime := time.Now() + for i := 0; i < numThreads; i++ { + wg.Add(1) + go func() { + defer wg.Done() + myCtx, cancel := context.WithTimeout(ctx, kConcurrentTestTimeout) + defer cancel() + for j := 0; j < numTasks/numThreads; j++ { + if !testFunc(myCtx) { + break + } + } + }() + } + wg.Wait() + return time.Since(startTime) +} diff --git a/db/functions/engine/.gitignore b/db/functions/engine/.gitignore new file mode 100644 index 0000000000..07e6e472cc --- /dev/null +++ b/db/functions/engine/.gitignore @@ -0,0 +1 @@ +/node_modules diff --git a/db/functions/engine/README.md b/db/functions/engine/README.md new file mode 100644 index 0000000000..323fb9a7f7 --- /dev/null +++ b/db/functions/engine/README.md @@ -0,0 +1,36 @@ +# The Sync Gateway GraphQL/Functions Engine + +This is a node.js project, although the actual runtime environment isn't node.js, rather just an in-process V8 runtime. + +The TypeScript source code lives in `src`. This is compiled (transpiled) into JavaScript and merged into a single file, `dist/main.js`. Finally, the Go compiler embeds the contents of `main.js` into `environment.go` as the string constant `kJavaScriptCode`, which at runtime is passed to V8 to evaluate when it starts up. + +Since most SG developers won't be changing the TypeScript code, the build output (`main.js`) is checked in. That means **you can build SG normally without having to install node.js or worry about any of this stuff.** + +But if you _do_ touch anything herein... + +## How To Rebuild After Changing TypeScript Files Or Updating JS Dependencies + +### Prerequisites + +Only needs to be done once per machine. + +1. Install node.js (e.g. `brew install node`) +2. Install TypeScript (e.g. `brew install typescript`) + +### Setup + +This must be done before a clean build, and after any changes to package.json, i.e. after a git pull. It downloads or updates all of the module dependencies. + +1. `cd db/functions/engine` +2. `npm install` + +### Building It + +On a clean build, or after any changes in the `engine` source tree: + +1. `cd db/functions/engine` +2. `npm run build` + +(Alternatively, if you're actively working on the TypeScript source files, use `npm run watch` instead: it will rebuild incrementally whenever you save changes to a file.) + +The build product is the file `dist/main.js`. Now the next time you build SG itself, it will pick up the updated JavaScript. And you'll need to check the updated `main.js` into Git. diff --git a/db/functions/engine/dist/main.js b/db/functions/engine/dist/main.js new file mode 100644 index 0000000000..b71f7e6d58 --- /dev/null +++ b/db/functions/engine/dist/main.js @@ -0,0 +1,54242 @@ +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. + +NOTE: This file was automatically generated by WebPack -- see ../README.md for instructions. +DO NOT EDIT IT. + +NOTE: The above copyright notice applies ONLY to the Couchbase source code in this file, +generated from the TypeScript files in ../src, not to the third-party code also included. +*/ + +var SG_Engine; +/******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ 9825: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.cacheControlFromInfo = exports.maybeCacheControlFromInfo = void 0; +function maybeCacheControlFromInfo(info) { + var _a, _b; + if ((_b = (_a = info.cacheControl) === null || _a === void 0 ? void 0 : _a.cacheHint) === null || _b === void 0 ? void 0 : _b.restrict) { + return info.cacheControl; + } + return null; +} +exports.maybeCacheControlFromInfo = maybeCacheControlFromInfo; +function cacheControlFromInfo(info) { + var _a, _b; + if (!("cacheControl" in info)) { + throw new Error("The `info` argument does not appear to have a cacheControl field. " + + "Check that you are using Apollo Server 3 or newer and that you aren't using " + + "ApolloServerPluginCacheControlDisabled."); + } + if (!((_b = (_a = info.cacheControl) === null || _a === void 0 ? void 0 : _a.cacheHint) === null || _b === void 0 ? void 0 : _b.restrict)) { + throw new Error("The `info` argument has a cacheControl field but it does not appear to be from Apollo" + + "Server 3 or newer. Check that you are using Apollo Server 3 or newer and that you aren't using " + + "ApolloServerPluginCacheControlDisabled."); + } + return info.cacheControl; +} +exports.cacheControlFromInfo = cacheControlFromInfo; +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 7964: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.builtTypeReference = exports.buildSchemaFromAST = exports.buildSchema = void 0; +const graphql_1 = __webpack_require__(8929); +const values_1 = __webpack_require__(3421); +const definitions_1 = __webpack_require__(4177); +const error_1 = __webpack_require__(8116); +function buildValue(value) { + return value ? (0, values_1.valueFromASTUntyped)(value) : undefined; +} +function buildSchema(source, options) { + return buildSchemaFromAST((0, graphql_1.parse)(source), options); +} +exports.buildSchema = buildSchema; +function buildSchemaFromAST(documentNode, options) { + var _a; + const errors = []; + const schema = new definitions_1.Schema(options === null || options === void 0 ? void 0 : options.blueprint); + const { directiveDefinitions, typeDefinitions, typeExtensions, schemaDefinitions, schemaExtensions, } = buildNamedTypeAndDirectivesShallow(documentNode, schema, errors); + for (const typeNode of typeDefinitions) { + if (typeNode.kind === graphql_1.Kind.ENUM_TYPE_DEFINITION) { + buildEnumTypeValuesWithoutDirectiveApplications(typeNode, schema.type(typeNode.name.value)); + } + } + for (const typeExtensionNode of typeExtensions) { + if (typeExtensionNode.kind === graphql_1.Kind.ENUM_TYPE_EXTENSION) { + const toExtend = schema.type(typeExtensionNode.name.value); + const extension = toExtend.newExtension(); + extension.sourceAST = typeExtensionNode; + buildEnumTypeValuesWithoutDirectiveApplications(typeExtensionNode, schema.type(typeExtensionNode.name.value), extension); + } + } + for (const directiveDefinitionNode of directiveDefinitions) { + buildDirectiveDefinitionInnerWithoutDirectiveApplications(directiveDefinitionNode, schema.directive(directiveDefinitionNode.name.value), errors); + } + for (const schemaDefinition of schemaDefinitions) { + buildSchemaDefinitionInner(schemaDefinition, schema.schemaDefinition, errors); + } + for (const schemaExtension of schemaExtensions) { + buildSchemaDefinitionInner(schemaExtension, schema.schemaDefinition, errors, schema.schemaDefinition.newExtension()); + } + errors.push(...schema.blueprint.onDirectiveDefinitionAndSchemaParsed(schema)); + for (const directiveDefinitionNode of directiveDefinitions) { + buildDirectiveApplicationsInDirectiveDefinition(directiveDefinitionNode, schema.directive(directiveDefinitionNode.name.value), errors); + } + for (const typeNode of typeDefinitions) { + buildNamedTypeInner(typeNode, schema.type(typeNode.name.value), schema.blueprint, errors); + } + for (const typeExtensionNode of typeExtensions) { + const toExtend = schema.type(typeExtensionNode.name.value); + const extension = toExtend.newExtension(); + extension.sourceAST = typeExtensionNode; + buildNamedTypeInner(typeExtensionNode, toExtend, schema.blueprint, errors, extension); + } + if (errors.length > 0) { + throw (0, definitions_1.ErrGraphQLValidationFailed)(errors); + } + if ((_a = options === null || options === void 0 ? void 0 : options.validate) !== null && _a !== void 0 ? _a : true) { + schema.validate(); + } + return schema; +} +exports.buildSchemaFromAST = buildSchemaFromAST; +function buildNamedTypeAndDirectivesShallow(documentNode, schema, errors) { + const directiveDefinitions = []; + const typeDefinitions = []; + const typeExtensions = []; + const schemaDefinitions = []; + const schemaExtensions = []; + for (const definitionNode of documentNode.definitions) { + switch (definitionNode.kind) { + case 'OperationDefinition': + case 'FragmentDefinition': + errors.push(error_1.ERRORS.INVALID_GRAPHQL.err("Invalid executable definition found while building schema", { nodes: definitionNode })); + continue; + case 'SchemaDefinition': + schemaDefinitions.push(definitionNode); + schema.schemaDefinition.preserveEmptyDefinition = true; + break; + case 'SchemaExtension': + schemaExtensions.push(definitionNode); + break; + case 'ScalarTypeDefinition': + case 'ObjectTypeDefinition': + case 'InterfaceTypeDefinition': + case 'UnionTypeDefinition': + case 'EnumTypeDefinition': + case 'InputObjectTypeDefinition': + typeDefinitions.push(definitionNode); + let type = schema.type(definitionNode.name.value); + if (!type || type.isBuiltIn) { + type = schema.addType((0, definitions_1.newNamedType)(withoutTrailingDefinition(definitionNode.kind), definitionNode.name.value)); + } + else if (type.preserveEmptyDefinition) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`There can be only one type named "${definitionNode.name.value}"`); + } + type.preserveEmptyDefinition = true; + break; + case 'ScalarTypeExtension': + case 'ObjectTypeExtension': + case 'InterfaceTypeExtension': + case 'UnionTypeExtension': + case 'EnumTypeExtension': + case 'InputObjectTypeExtension': + typeExtensions.push(definitionNode); + const existing = schema.type(definitionNode.name.value); + if (!existing) { + schema.addType((0, definitions_1.newNamedType)(withoutTrailingDefinition(definitionNode.kind), definitionNode.name.value)); + } + else if (existing.isBuiltIn) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Cannot extend built-in type "${definitionNode.name.value}"`); + } + break; + case 'DirectiveDefinition': + directiveDefinitions.push(definitionNode); + schema.addDirectiveDefinition(definitionNode.name.value); + break; + } + } + return { + directiveDefinitions, + typeDefinitions, + typeExtensions, + schemaDefinitions, + schemaExtensions, + }; +} +function withoutTrailingDefinition(str) { + const endString = str.endsWith('Definition') ? 'Definition' : 'Extension'; + return str.slice(0, str.length - endString.length); +} +function getReferencedType(node, schema) { + const type = schema.type(node.name.value); + if (!type) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Unknown type ${node.name.value}`, { nodes: node }); + } + return type; +} +function withNodeAttachedToError(operation, node, errors) { + try { + operation(); + } + catch (e) { + const causes = (0, error_1.errorCauses)(e); + if (causes) { + for (const cause of causes) { + const allNodes = cause.nodes ? [node, ...cause.nodes] : node; + errors.push((0, error_1.withModifiedErrorNodes)(cause, allNodes)); + } + } + else { + throw e; + } + } +} +function buildSchemaDefinitionInner(schemaNode, schemaDefinition, errors, extension) { + var _a, _b; + for (const opTypeNode of (_a = schemaNode.operationTypes) !== null && _a !== void 0 ? _a : []) { + withNodeAttachedToError(() => schemaDefinition.setRoot(opTypeNode.operation, opTypeNode.type.name.value).setOfExtension(extension), opTypeNode, errors); + } + schemaDefinition.sourceAST = schemaNode; + if ('description' in schemaNode) { + schemaDefinition.description = (_b = schemaNode.description) === null || _b === void 0 ? void 0 : _b.value; + } + buildAppliedDirectives(schemaNode, schemaDefinition, errors, extension); +} +function buildAppliedDirectives(elementNode, element, errors, extension) { + var _a; + for (const directive of (_a = elementNode.directives) !== null && _a !== void 0 ? _a : []) { + withNodeAttachedToError(() => { + if (element !== element.schema().schemaDefinition || directive.name.value === 'link' || !element.schema().blueprint.applyDirectivesAfterParsing()) { + const d = element.applyDirective(directive.name.value, buildArgs(directive)); + d.setOfExtension(extension); + d.sourceAST = directive; + } + else { + element.addUnappliedDirective({ + extension, + directive, + args: buildArgs(directive), + nameOrDef: directive.name.value, + }); + } + }, directive, errors); + } +} +function buildArgs(argumentsNode) { + var _a; + const args = Object.create(null); + for (const argNode of (_a = argumentsNode.arguments) !== null && _a !== void 0 ? _a : []) { + args[argNode.name.value] = buildValue(argNode.value); + } + return args; +} +function buildNamedTypeInner(definitionNode, type, blueprint, errors, extension) { + var _a, _b, _c, _d, _e; + switch (definitionNode.kind) { + case 'EnumTypeDefinition': + case 'EnumTypeExtension': + const enumType = type; + for (const enumVal of (_a = definitionNode.values) !== null && _a !== void 0 ? _a : []) { + buildAppliedDirectives(enumVal, enumType.value(enumVal.name.value), errors); + } + break; + case 'ObjectTypeDefinition': + case 'ObjectTypeExtension': + case 'InterfaceTypeDefinition': + case 'InterfaceTypeExtension': + const fieldBasedType = type; + for (const fieldNode of (_b = definitionNode.fields) !== null && _b !== void 0 ? _b : []) { + if (blueprint.ignoreParsedField(type, fieldNode.name.value)) { + continue; + } + const field = fieldBasedType.addField(fieldNode.name.value); + field.setOfExtension(extension); + buildFieldDefinitionInner(fieldNode, field, errors); + } + for (const itfNode of (_c = definitionNode.interfaces) !== null && _c !== void 0 ? _c : []) { + withNodeAttachedToError(() => { + const itfName = itfNode.name.value; + if (fieldBasedType.implementsInterface(itfName)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Type "${type}" can only implement "${itfName}" once.`); + } + fieldBasedType.addImplementedInterface(itfName).setOfExtension(extension); + }, itfNode, errors); + } + break; + case 'UnionTypeDefinition': + case 'UnionTypeExtension': + const unionType = type; + for (const namedType of (_d = definitionNode.types) !== null && _d !== void 0 ? _d : []) { + withNodeAttachedToError(() => { + const name = namedType.name.value; + if (unionType.hasTypeMember(name)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Union type "${unionType}" can only include type "${name}" once.`); + } + unionType.addType(name).setOfExtension(extension); + }, namedType, errors); + } + break; + case 'InputObjectTypeDefinition': + case 'InputObjectTypeExtension': + const inputObjectType = type; + for (const fieldNode of (_e = definitionNode.fields) !== null && _e !== void 0 ? _e : []) { + const field = inputObjectType.addField(fieldNode.name.value); + field.setOfExtension(extension); + buildInputFieldDefinitionInner(fieldNode, field, errors); + } + break; + } + buildAppliedDirectives(definitionNode, type, errors, extension); + buildDescriptionAndSourceAST(definitionNode, type); +} +function buildEnumTypeValuesWithoutDirectiveApplications(definitionNode, type, extension) { + var _a; + const enumType = type; + for (const enumVal of (_a = definitionNode.values) !== null && _a !== void 0 ? _a : []) { + const v = enumType.addValue(enumVal.name.value); + if (enumVal.description) { + v.description = enumVal.description.value; + } + v.setOfExtension(extension); + } + buildDescriptionAndSourceAST(definitionNode, type); +} +function buildDescriptionAndSourceAST(definitionNode, dest) { + if (definitionNode.description) { + dest.description = definitionNode.description.value; + } + dest.sourceAST = definitionNode; +} +function buildFieldDefinitionInner(fieldNode, field, errors) { + var _a, _b; + const type = buildTypeReferenceFromAST(fieldNode.type, field.schema()); + field.type = validateOutputType(type, field.coordinate, fieldNode, errors); + for (const inputValueDef of (_a = fieldNode.arguments) !== null && _a !== void 0 ? _a : []) { + buildArgumentDefinitionInner(inputValueDef, field.addArgument(inputValueDef.name.value), errors, true); + } + buildAppliedDirectives(fieldNode, field, errors); + field.description = (_b = fieldNode.description) === null || _b === void 0 ? void 0 : _b.value; + field.sourceAST = fieldNode; +} +function validateOutputType(type, what, node, errors) { + if ((0, definitions_1.isOutputType)(type)) { + return type; + } + else { + errors.push(error_1.ERRORS.INVALID_GRAPHQL.err(`The type of "${what}" must be Output Type but got "${type}", a ${type.kind}.`, { nodes: node })); + return undefined; + } +} +function validateInputType(type, what, node, errors) { + if ((0, definitions_1.isInputType)(type)) { + return type; + } + else { + errors.push(error_1.ERRORS.INVALID_GRAPHQL.err(`The type of "${what}" must be Input Type but got "${type}", a ${type.kind}.`, { nodes: node })); + return undefined; + } +} +function builtTypeReference(encodedType, schema) { + return buildTypeReferenceFromAST((0, graphql_1.parseType)(encodedType), schema); +} +exports.builtTypeReference = builtTypeReference; +function buildTypeReferenceFromAST(typeNode, schema) { + switch (typeNode.kind) { + case graphql_1.Kind.LIST_TYPE: + return new definitions_1.ListType(buildTypeReferenceFromAST(typeNode.type, schema)); + case graphql_1.Kind.NON_NULL_TYPE: + const wrapped = buildTypeReferenceFromAST(typeNode.type, schema); + if (wrapped.kind == graphql_1.Kind.NON_NULL_TYPE) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Cannot apply the non-null operator (!) twice to the same type`, { nodes: typeNode }); + } + return new definitions_1.NonNullType(wrapped); + default: + return getReferencedType(typeNode, schema); + } +} +function buildArgumentDefinitionInner(inputNode, arg, errors, includeDirectiveApplication) { + var _a; + const type = buildTypeReferenceFromAST(inputNode.type, arg.schema()); + arg.type = validateInputType(type, arg.coordinate, inputNode, errors); + arg.defaultValue = buildValue(inputNode.defaultValue); + if (includeDirectiveApplication) { + buildAppliedDirectives(inputNode, arg, errors); + } + arg.description = (_a = inputNode.description) === null || _a === void 0 ? void 0 : _a.value; + arg.sourceAST = inputNode; +} +function buildInputFieldDefinitionInner(fieldNode, field, errors) { + var _a; + const type = buildTypeReferenceFromAST(fieldNode.type, field.schema()); + field.type = validateInputType(type, field.coordinate, fieldNode, errors); + field.defaultValue = buildValue(fieldNode.defaultValue); + buildAppliedDirectives(fieldNode, field, errors); + field.description = (_a = fieldNode.description) === null || _a === void 0 ? void 0 : _a.value; + field.sourceAST = fieldNode; +} +function buildDirectiveDefinitionInnerWithoutDirectiveApplications(directiveNode, directive, errors) { + var _a; + for (const inputValueDef of (_a = directiveNode.arguments) !== null && _a !== void 0 ? _a : []) { + buildArgumentDefinitionInner(inputValueDef, directive.addArgument(inputValueDef.name.value), errors, false); + } + directive.repeatable = directiveNode.repeatable; + const locations = directiveNode.locations.map(({ value }) => value); + directive.addLocations(...locations); + buildDescriptionAndSourceAST(directiveNode, directive); +} +function buildDirectiveApplicationsInDirectiveDefinition(directiveNode, directive, errors) { + var _a; + for (const inputValueDef of (_a = directiveNode.arguments) !== null && _a !== void 0 ? _a : []) { + buildAppliedDirectives(inputValueDef, directive.argument(inputValueDef.name.value), errors); + } +} +//# sourceMappingURL=buildSchema.js.map + +/***/ }), + +/***/ 9209: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.removeAllCoreFeatures = exports.LINK_VERSIONS = exports.CORE_VERSIONS = exports.findCoreSpecVersion = exports.FeatureUrl = exports.FeatureVersion = exports.FeatureDefinitions = exports.CoreSpecDefinition = exports.isCoreSpecDirectiveApplication = exports.extractCoreFeatureImports = exports.FeatureDefinition = exports.corePurposes = exports.ErrCoreCheckFailed = exports.linkDirectiveDefaultName = exports.linkIdentity = exports.coreIdentity = void 0; +const graphql_1 = __webpack_require__(8929); +const url_1 = __webpack_require__(4888); +const definitions_1 = __webpack_require__(4177); +const types_1 = __webpack_require__(5811); +const utils_1 = __webpack_require__(9724); +const error_1 = __webpack_require__(8116); +const values_1 = __webpack_require__(3421); +const knownCoreFeatures_1 = __webpack_require__(5848); +const suggestions_1 = __webpack_require__(5388); +const directiveAndTypeSpecification_1 = __webpack_require__(3208); +exports.coreIdentity = 'https://specs.apollo.dev/core'; +exports.linkIdentity = 'https://specs.apollo.dev/link'; +exports.linkDirectiveDefaultName = 'link'; +const ErrCoreCheckFailed = (causes) => (0, error_1.aggregateError)('CheckFailed', 'one or more checks failed', causes); +exports.ErrCoreCheckFailed = ErrCoreCheckFailed; +function buildError(message) { + return new Error(message); +} +exports.corePurposes = [ + 'SECURITY', + 'EXECUTION', +]; +function purposesDescription(purpose) { + switch (purpose) { + case 'SECURITY': return "`SECURITY` features provide metadata necessary to securely resolve fields."; + case 'EXECUTION': return "`EXECUTION` features provide metadata necessary for operation execution."; + } +} +class FeatureDefinition { + constructor(url) { + this.url = typeof url === 'string' ? FeatureUrl.parse(url) : url; + } + get identity() { + return this.url.identity; + } + get version() { + return this.url.version; + } + isSpecType(type) { + const nameInSchema = this.nameInSchema(type.schema()); + return nameInSchema !== undefined && type.name.startsWith(`${nameInSchema}__`); + } + isSpecDirective(directive) { + const nameInSchema = this.nameInSchema(directive.schema()); + return nameInSchema != undefined && (directive.name === nameInSchema || directive.name.startsWith(`${nameInSchema}__`)); + } + nameInSchema(schema) { + const feature = this.featureInSchema(schema); + return feature === null || feature === void 0 ? void 0 : feature.nameInSchema; + } + directiveNameInSchema(schema, directiveName) { + const feature = this.featureInSchema(schema); + return feature ? feature.directiveNameInSchema(directiveName) : undefined; + } + typeNameInSchema(schema, typeName) { + const feature = this.featureInSchema(schema); + return feature ? feature.typeNameInSchema(typeName) : undefined; + } + rootDirective(schema) { + const name = this.nameInSchema(schema); + return name ? schema.directive(name) : undefined; + } + directive(schema, elementName) { + const name = this.directiveNameInSchema(schema, elementName); + return name ? schema.directive(name) : undefined; + } + type(schema, elementName) { + const name = this.typeNameInSchema(schema, elementName); + return name ? schema.type(name) : undefined; + } + addRootDirective(schema) { + return schema.addDirectiveDefinition(this.nameInSchema(schema)); + } + addDirective(schema, name) { + return schema.addDirectiveDefinition(this.directiveNameInSchema(schema, name)); + } + addDirectiveSpec(schema, spec) { + return spec.checkOrAdd(schema, this.directiveNameInSchema(schema, spec.name)); + } + addTypeSpec(schema, spec) { + return spec.checkOrAdd(schema, this.typeNameInSchema(schema, spec.name)); + } + addScalarType(schema, name) { + return schema.addType(new definitions_1.ScalarType(this.typeNameInSchema(schema, name))); + } + addEnumType(schema, name) { + return schema.addType(new definitions_1.EnumType(this.typeNameInSchema(schema, name))); + } + featureInSchema(schema) { + const features = schema.coreFeatures; + if (!features) { + throw buildError(`Schema is not a core schema (add @core first)`); + } + return features.getByIdentity(this.identity); + } + get defaultCorePurpose() { + return undefined; + } + toString() { + return `${this.identity}/${this.version}`; + } +} +exports.FeatureDefinition = FeatureDefinition; +function extractCoreFeatureImports(url, directive) { + const args = directive.arguments(); + if (!('import' in args) || !args.import) { + return []; + } + const importArgValue = args.import; + const definition = (0, knownCoreFeatures_1.coreFeatureDefinitionIfKnown)(url); + const knownElements = definition === null || definition === void 0 ? void 0 : definition.allElementNames(); + const errors = []; + const imports = []; + importArgLoop: for (const elt of importArgValue) { + if (typeof elt === 'string') { + imports.push({ name: elt }); + validateImportedName(elt, knownElements, errors, directive); + continue; + } + if (typeof elt !== 'object') { + errors.push(error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Invalid sub-value ${(0, values_1.valueToString)(elt)} for @link(import:) argument: values should be either strings or input object values of the form { name: "", as: "" }.`, { nodes: directive.sourceAST })); + continue; + } + let name; + for (const [key, value] of Object.entries(elt)) { + switch (key) { + case 'name': + if (typeof value !== 'string') { + errors.push(error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Invalid value for the "name" field for sub-value ${(0, values_1.valueToString)(elt)} of @link(import:) argument: must be a string.`, { nodes: directive.sourceAST })); + continue importArgLoop; + } + name = value; + break; + case 'as': + if (typeof value !== 'string') { + errors.push(error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Invalid value for the "as" field for sub-value ${(0, values_1.valueToString)(elt)} of @link(import:) argument: must be a string.`, { nodes: directive.sourceAST })); + continue importArgLoop; + } + break; + default: + errors.push(error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Unknown field "${key}" for sub-value ${(0, values_1.valueToString)(elt)} of @link(import:) argument.`, { nodes: directive.sourceAST })); + continue importArgLoop; + } + } + if (name) { + const i = elt; + imports.push(i); + if (i.as) { + if (i.name.charAt(0) === '@' && i.as.charAt(0) !== '@') { + errors.push(error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Invalid @link import renaming: directive "${i.name}" imported name should start with a '@' character, but got "${i.as}".`, { nodes: directive.sourceAST })); + } + else if (i.name.charAt(0) !== '@' && i.as.charAt(0) === '@') { + errors.push(error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Invalid @link import renaming: type "${i.name}" imported name should not start with a '@' character, but got "${i.as}" (or, if @${i.name} is a directive, then it should be referred to with a '@').`, { nodes: directive.sourceAST })); + } + } + validateImportedName(name, knownElements, errors, directive); + } + else { + errors.push(error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Invalid sub-value ${(0, values_1.valueToString)(elt)} for @link(import:) argument: missing mandatory "name" field.`, { nodes: directive.sourceAST })); + } + } + if (errors.length > 0) { + throw (0, definitions_1.ErrGraphQLValidationFailed)(errors); + } + return imports; +} +exports.extractCoreFeatureImports = extractCoreFeatureImports; +function validateImportedName(name, knownElements, errors, directive) { + if (knownElements && !knownElements.includes(name)) { + let details = ''; + if (!name.startsWith('@') && knownElements.includes('@' + name)) { + details = ` Did you mean directive "@${name}"?`; + } + else { + const suggestions = (0, suggestions_1.suggestionList)(name, knownElements); + if (suggestions) { + details = (0, suggestions_1.didYouMean)(suggestions); + } + } + errors.push(error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Cannot import unknown element "${name}".${details}`, { nodes: directive.sourceAST })); + } +} +function isCoreSpecDirectiveApplication(directive) { + var _a, _b, _c; + const definition = directive.definition; + if (!definition) { + return false; + } + const asArg = definition.argument('as'); + if (asArg && !(0, types_1.sameType)(asArg.type, directive.schema().stringType())) { + return false; + } + if (!definition.repeatable || definition.locations.length !== 1 || definition.locations[0] !== graphql_1.DirectiveLocation.SCHEMA) { + return false; + } + const urlArg = (_a = definition.argument('url')) !== null && _a !== void 0 ? _a : definition.argument('feature'); + if (!urlArg || !isValidUrlArgumentType(urlArg.type, directive.schema())) { + return false; + } + const args = directive.arguments(); + try { + const url = FeatureUrl.parse(args[urlArg.name]); + if (url.identity === exports.coreIdentity) { + return directive.name === ((_b = args.as) !== null && _b !== void 0 ? _b : 'core'); + } + else { + return url.identity === exports.linkIdentity && directive.name === ((_c = args.as) !== null && _c !== void 0 ? _c : exports.linkDirectiveDefaultName); + } + } + catch (err) { + return false; + } +} +exports.isCoreSpecDirectiveApplication = isCoreSpecDirectiveApplication; +function isValidUrlArgumentType(type, schema) { + return (0, types_1.sameType)(type, schema.stringType()) + || (0, types_1.sameType)(type, new definitions_1.NonNullType(schema.stringType())); +} +const linkPurposeTypeSpec = (0, directiveAndTypeSpecification_1.createEnumTypeSpecification)({ + name: 'Purpose', + values: exports.corePurposes.map((name) => ({ name, description: purposesDescription(name) })) +}); +const linkImportTypeSpec = (0, directiveAndTypeSpecification_1.createScalarTypeSpecification)({ name: 'Import' }); +class CoreSpecDefinition extends FeatureDefinition { + constructor(version, identity = exports.linkIdentity, name = exports.linkDirectiveDefaultName) { + super(new FeatureUrl(identity, name, version)); + this.directiveDefinitionSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name, + locations: [graphql_1.DirectiveLocation.SCHEMA], + repeatable: true, + argumentFct: (schema, nameInSchema) => this.createDefinitionArgumentSpecifications(schema, nameInSchema), + }); + } + createDefinitionArgumentSpecifications(schema, nameInSchema) { + const args = [ + { name: this.urlArgName(), type: schema.stringType() }, + { name: 'as', type: schema.stringType() }, + ]; + if (this.supportPurposes()) { + const purposeName = `${nameInSchema !== null && nameInSchema !== void 0 ? nameInSchema : this.url.name}__${linkPurposeTypeSpec.name}`; + const errors = linkPurposeTypeSpec.checkOrAdd(schema, purposeName); + if (errors.length > 0) { + return { args, errors }; + } + args.push({ name: 'for', type: schema.type(purposeName) }); + } + if (this.supportImport()) { + const importName = `${nameInSchema !== null && nameInSchema !== void 0 ? nameInSchema : this.url.name}__${linkImportTypeSpec.name}`; + const errors = linkImportTypeSpec.checkOrAdd(schema, importName); + if (errors.length > 0) { + return { args, errors }; + } + args.push({ name: 'import', type: new definitions_1.ListType(schema.type(importName)) }); + } + return { args, errors: [] }; + } + addElementsToSchema(_) { + return []; + } + addToSchema(schema, alias) { + const errors = this.addDefinitionsToSchema(schema, alias); + if (errors.length > 0) { + return errors; + } + const args = { [this.urlArgName()]: this.toString() }; + if (alias) { + args.as = alias; + } + const schemaDef = schema.schemaDefinition; + const hasDefinition = schemaDef.hasNonExtensionElements(); + const directive = schemaDef.applyDirective(alias !== null && alias !== void 0 ? alias : this.url.name, args, true); + if (!hasDefinition && schemaDef.hasExtensionElements()) { + const extension = (0, utils_1.firstOf)(schemaDef.extensions()); + (0, utils_1.assert)(extension, '`hasExtensionElements` should not have been `true`'); + directive.setOfExtension(extension); + } + return []; + } + addDefinitionsToSchema(schema, as) { + const existingCore = schema.coreFeatures; + if (existingCore) { + if (existingCore.coreItself.url.identity === this.identity) { + return []; + } + else { + return [error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Cannot add feature ${this} to the schema, it already uses ${existingCore.coreItself.url}`)]; + } + } + const nameInSchema = as !== null && as !== void 0 ? as : this.url.name; + return this.directiveDefinitionSpec.checkOrAdd(schema, nameInSchema); + } + allElementNames() { + const names = [`@${this.url.name}`]; + if (this.supportPurposes()) { + names.push('Purpose'); + } + if (this.supportImport()) { + names.push('Import'); + } + return names; + } + supportPurposes() { + return this.version.strictlyGreaterThan(new FeatureVersion(0, 1)); + } + supportImport() { + return this.url.name === exports.linkDirectiveDefaultName; + } + extractFeature(schema) { + const features = schema.coreFeatures; + if (!features) { + throw buildError(`Schema is not a core schema (add @core first)`); + } + if (!features.coreItself.url.version.equals(this.version)) { + throw buildError(`Cannot use this version of @core (${this.version}), the schema uses version ${features.coreItself.url.version}`); + } + return features.coreItself; + } + coreDirective(schema) { + const feature = this.extractFeature(schema); + const directive = schema.directive(feature.nameInSchema); + return directive; + } + coreVersion(schema) { + const feature = this.extractFeature(schema); + return feature.url.version; + } + applyFeatureToSchema(schema, feature, as, purpose) { + const coreDirective = this.coreDirective(schema); + const args = { + [this.urlArgName()]: feature.toString(), + as, + }; + if (this.supportPurposes() && purpose) { + args.for = purpose; + } + schema.schemaDefinition.applyDirective(coreDirective, args); + return feature.addElementsToSchema(schema); + } + extractFeatureUrl(args) { + return FeatureUrl.parse(args[this.urlArgName()]); + } + urlArgName() { + return this.url.name === 'core' ? 'feature' : 'url'; + } +} +exports.CoreSpecDefinition = CoreSpecDefinition; +class FeatureDefinitions { + constructor(identity) { + this.identity = identity; + this._definitions = []; + } + add(definition) { + if (definition.identity !== this.identity) { + throw buildError(`Cannot add definition for ${definition} to the versions of definitions for ${this.identity}`); + } + if (this._definitions.find(def => definition.version.equals(def.version))) { + return this; + } + this._definitions.push(definition); + this._definitions.sort((def1, def2) => -def1.version.compareTo(def2.version)); + return this; + } + find(requested) { + return this._definitions.find(def => def.version.satisfies(requested)); + } + versions() { + return this._definitions.map(def => def.version); + } + latest() { + (0, utils_1.assert)(this._definitions.length > 0, 'Trying to get latest when no definitions exist'); + return this._definitions[0]; + } +} +exports.FeatureDefinitions = FeatureDefinitions; +class FeatureVersion { + constructor(major, minor) { + this.major = major; + this.minor = minor; + } + static parse(input) { + const match = input.match(this.VERSION_RE); + if (!match) { + throw error_1.ERRORS.INVALID_LINK_IDENTIFIER.err(`Expected a version string (of the form v1.2), got ${input}`); + } + return new this(+match[1], +match[2]); + } + satisfies(required) { + const { major, minor } = this; + const { major: rMajor, minor: rMinor } = required; + return rMajor == major && (major == 0 + ? rMinor == minor + : rMinor <= minor); + } + get series() { + const { major } = this; + return major > 0 ? `${major}.x` : String(this); + } + compareTo(other) { + if (this.major > other.major) { + return 1; + } + if (this.major < other.major) { + return -1; + } + if (this.minor > other.minor) { + return 1; + } + if (this.minor < other.minor) { + return -1; + } + return 0; + } + strictlyGreaterThan(version) { + return this.compareTo(version) > 0; + } + toString() { + return `v${this.major}.${this.minor}`; + } + equals(other) { + return this.major === other.major && this.minor === other.minor; + } +} +exports.FeatureVersion = FeatureVersion; +FeatureVersion.VERSION_RE = /^v(\d+)\.(\d+)$/; +class FeatureUrl { + constructor(identity, name, version, element) { + this.identity = identity; + this.name = name; + this.version = version; + this.element = element; + } + static parse(input, node) { + const url = new url_1.URL(input); + if (!url.pathname || url.pathname === '/') { + throw error_1.ERRORS.INVALID_LINK_IDENTIFIER.err(`Missing path in feature url '${url}'`, { nodes: node }); + } + const path = url.pathname.split('/'); + const verStr = path.pop(); + if (!verStr) { + throw error_1.ERRORS.INVALID_LINK_IDENTIFIER.err(`Missing version component in feature url '${url}'`, { nodes: node }); + } + const version = FeatureVersion.parse(verStr); + const name = path[path.length - 1]; + if (!name) { + throw error_1.ERRORS.INVALID_LINK_IDENTIFIER.err(`Missing feature name component in feature url '${url}'`, { nodes: node }); + } + const element = url.hash ? url.hash.slice(1) : undefined; + url.hash = ''; + url.search = ''; + url.password = ''; + url.username = ''; + url.pathname = path.join('/'); + return new FeatureUrl(url.toString(), name, version, element); + } + static decode(node) { + return this.parse(node.value, node); + } + satisfies(requested) { + return requested.identity === this.identity && + this.version.satisfies(requested.version); + } + equals(other) { + return this.identity === other.identity && + this.version.equals(other.version); + } + get url() { + return this.element ? + `${this.identity}/${this.version}#${this.element}` + : `${this.identity}/${this.version}`; + } + get isDirective() { + var _a; + return (_a = this.element) === null || _a === void 0 ? void 0 : _a.startsWith('@'); + } + get elementName() { + var _a; + return this.isDirective ? (_a = this.element) === null || _a === void 0 ? void 0 : _a.slice(1) : this.element; + } + get base() { + if (!this.element) + return this; + return new FeatureUrl(this.identity, this.name, this.version); + } + toString() { + return this.url; + } +} +exports.FeatureUrl = FeatureUrl; +function findCoreSpecVersion(featureUrl) { + return featureUrl.name === 'core' + ? exports.CORE_VERSIONS.find(featureUrl.version) + : (featureUrl.name === exports.linkDirectiveDefaultName ? exports.LINK_VERSIONS.find(featureUrl.version) : undefined); +} +exports.findCoreSpecVersion = findCoreSpecVersion; +exports.CORE_VERSIONS = new FeatureDefinitions(exports.coreIdentity) + .add(new CoreSpecDefinition(new FeatureVersion(0, 1), exports.coreIdentity, 'core')) + .add(new CoreSpecDefinition(new FeatureVersion(0, 2), exports.coreIdentity, 'core')); +exports.LINK_VERSIONS = new FeatureDefinitions(exports.linkIdentity) + .add(new CoreSpecDefinition(new FeatureVersion(1, 0))); +(0, knownCoreFeatures_1.registerKnownFeature)(exports.CORE_VERSIONS); +(0, knownCoreFeatures_1.registerKnownFeature)(exports.LINK_VERSIONS); +function removeAllCoreFeatures(schema) { + var _a, _b; + const coreFeatures = [...((_b = (_a = schema.coreFeatures) === null || _a === void 0 ? void 0 : _a.allFeatures()) !== null && _b !== void 0 ? _b : [])]; + const typeReferences = []; + for (const feature of coreFeatures) { + const featureDirectiveDefs = schema.directives() + .filter(d => feature.isFeatureDefinition(d)); + featureDirectiveDefs.forEach(def => def.remove().forEach(application => application.remove())); + const featureTypes = schema.types() + .filter(t => feature.isFeatureDefinition(t)); + featureTypes.forEach(type => { + const references = type.remove(); + if (references.length > 0) { + typeReferences.push({ + feature, + type, + references, + }); + } + }); + } + const errors = []; + for (const { feature, type, references } of typeReferences) { + const referencesInSchema = references.filter(r => r.isAttached()); + if (referencesInSchema.length > 0) { + errors.push(error_1.ERRORS.REFERENCED_INACCESSIBLE.err(`Cannot remove elements of feature ${feature} as feature type ${type}` + + ` is referenced by elements: ${referencesInSchema.join(', ')}`, { nodes: (0, definitions_1.sourceASTs)(...references) })); + } + } + if (errors.length > 0) { + throw (0, definitions_1.ErrGraphQLAPISchemaValidationFailed)(errors); + } +} +exports.removeAllCoreFeatures = removeAllCoreFeatures; +//# sourceMappingURL=coreSpec.js.map + +/***/ }), + +/***/ 2116: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +"use strict"; + +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.DebugLogger = exports.newDebugLogger = void 0; +const chalk_1 = __importDefault(__webpack_require__(4061)); +const utils_1 = __webpack_require__(9724); +function indentString(indentLevel) { + let str = ""; + for (let i = 0; i < indentLevel; i++) { + str += chalk_1.default.blackBright("⎸ "); + } + return str; +} +function isEnabled(name) { + const v = process.env.APOLLO_FEDERATION_DEBUG; + const bool = (0, utils_1.validateStringContainsBoolean)(v); + if (bool !== undefined) { + return bool; + } + const enabledNames = v.split(',').map(n => n.trim()); + return enabledNames.includes(name); +} +let currentIndentLevel = 0; +let currentIndentation = ''; +let maxLoggerNameLength = 0; +const createdLoggers = []; +function newDebugLogger(name) { + const enabled = isEnabled(name); + const created = new DebugLogger(name, enabled); + if (enabled) { + __webpack_require__.g.console = __webpack_require__(5108); + createdLoggers.push(created); + maxLoggerNameLength = Math.max(maxLoggerNameLength, name.length); + for (const logger of createdLoggers) { + DebugLogger.prototype['updateHeader'].call(logger, maxLoggerNameLength); + } + } + return created; +} +exports.newDebugLogger = newDebugLogger; +function increaseIndentation() { + currentIndentLevel++; + currentIndentation = indentString(currentIndentLevel); +} +function decreaseIndentation() { + if (currentIndentLevel > 0) { + currentIndentLevel--; + currentIndentation = indentString(currentIndentLevel); + } +} +class DebugLogger { + constructor(name, enabled) { + this.name = name; + this.enabled = enabled; + this.header = chalk_1.default.blackBright(`[${name}] `); + } + updateHeader(maxLength) { + let padding = ""; + if (maxLength > this.name.length) { + const toPad = maxLength - this.name.length; + for (let i = 0; i < toPad; i++) { + padding += " "; + } + } + this.header = chalk_1.default.blackBright('[' + padding + this.name + '] '); + } + doLog(str) { + const indent = this.header + currentIndentation; + const withIndentedNewlines = str.replace(/\n/g, '\n' + indent + ' '); + console.log(indent + withIndentedNewlines); + } + log(message, prefix = chalk_1.default.yellow('• ')) { + if (!this.enabled) + return this; + if (typeof message !== 'string') { + message = message(); + } + this.doLog(prefix + message); + return this; + } + groupedValues(values, printFn, initialMessage) { + if (!this.enabled) + return this; + this.group(initialMessage); + for (const value of values) { + this.doLog('- ' + printFn(value)); + } + return this.groupEnd(); + } + groupedEntries(map, keyPrintFn, valuePrintFn) { + if (!this.enabled) + return this; + this.group(); + for (const [k, v] of map.entries()) { + this.doLog('- ' + keyPrintFn(k) + ': ' + valuePrintFn(v)); + } + return this.groupEnd(); + } + group(openingMessage) { + if (this.enabled) { + if (openingMessage) { + this.log(openingMessage, chalk_1.default.blue('‣ ')); + } + increaseIndentation(); + } + return this; + } + groupEnd(closingMessage) { + if (!this.enabled) { + return this; + } + decreaseIndentation(); + if (closingMessage) { + this.log(closingMessage, chalk_1.default.green('⇒ ')); + } + return this; + } +} +exports.DebugLogger = DebugLogger; +//# sourceMappingURL=debug.js.map + +/***/ }), + +/***/ 4177: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.CoreFeatures = exports.CoreFeature = exports.defaultSchemaBlueprint = exports.SchemaBlueprint = exports.NamedSchemaElementWithType = exports.NamedSchemaElement = exports.SchemaElement = exports.Extension = exports.sourceASTs = exports.DirectiveTargetElement = exports.isLeafType = exports.typeFromAST = exports.typeToAST = exports.isTypeSystemDirectiveLocation = exports.typeSystemDirectiveLocations = exports.isExecutableDirectiveLocation = exports.executableDirectiveLocations = exports.isConditionalDirective = exports.runtimeTypesIntersects = exports.possibleRuntimeTypes = exports.isCompositeType = exports.isAbstractType = exports.isNullableType = exports.baseType = exports.filterTypesOfKind = exports.isTypeOfKind = exports.isInputType = exports.isOutputType = exports.isInputObjectType = exports.isUnionType = exports.isEnumType = exports.isInterfaceType = exports.isObjectType = exports.isIDType = exports.isBooleanType = exports.isFloatType = exports.isStringType = exports.isIntType = exports.isCustomScalarType = exports.isScalarType = exports.isNonNullType = exports.isListType = exports.isWrapperType = exports.isNamedType = exports.isSchemaRootType = exports.defaultRootName = exports.allSchemaRootKinds = exports.typenameFieldName = exports.ErrGraphQLAPISchemaValidationFailed = exports.ErrGraphQLValidationFailed = void 0; +exports.copyDirectiveDefinitionToSchema = exports.newNamedType = exports.variableDefinitionFromAST = exports.variableDefinitionsFromAST = exports.VariableDefinitions = exports.VariableDefinition = exports.variablesInArguments = exports.isVariable = exports.containsVariable = exports.mergeVariables = exports.Variable = exports.directiveApplicationsSubstraction = exports.isDirectiveApplicationsSubset = exports.sameDirectiveApplications = exports.sameDirectiveApplication = exports.Directive = exports.DirectiveDefinition = exports.EnumValue = exports.ArgumentDefinition = exports.InputFieldDefinition = exports.FieldDefinition = exports.NonNullType = exports.ListType = exports.InputObjectType = exports.EnumType = exports.UnionType = exports.UnionMember = exports.InterfaceType = exports.ObjectType = exports.InterfaceImplementation = exports.ScalarType = exports.SchemaDefinition = exports.RootType = exports.Schema = void 0; +const graphql_1 = __webpack_require__(8929); +const coreSpec_1 = __webpack_require__(9209); +const utils_1 = __webpack_require__(9724); +const values_1 = __webpack_require__(3421); +const inaccessibleSpec_1 = __webpack_require__(5322); +const print_1 = __webpack_require__(2850); +const types_1 = __webpack_require__(5811); +const introspection_1 = __webpack_require__(9495); +const validate_1 = __webpack_require__(9504); +const specifiedRules_1 = __webpack_require__(4710); +const validate_2 = __webpack_require__(5663); +const directiveAndTypeSpecification_1 = __webpack_require__(3208); +const suggestions_1 = __webpack_require__(5388); +const error_1 = __webpack_require__(8116); +const validationErrorCode = 'GraphQLValidationFailed'; +const DEFAULT_VALIDATION_ERROR_MESSAGE = 'The schema is not a valid GraphQL schema.'; +const ErrGraphQLValidationFailed = (causes, message = DEFAULT_VALIDATION_ERROR_MESSAGE) => (0, error_1.aggregateError)(validationErrorCode, message, causes); +exports.ErrGraphQLValidationFailed = ErrGraphQLValidationFailed; +const apiSchemaValidationErrorCode = 'GraphQLAPISchemaValidationFailed'; +const ErrGraphQLAPISchemaValidationFailed = (causes) => (0, error_1.aggregateError)(apiSchemaValidationErrorCode, 'The supergraph schema failed to produce a valid API schema', causes); +exports.ErrGraphQLAPISchemaValidationFailed = ErrGraphQLAPISchemaValidationFailed; +exports.typenameFieldName = '__typename'; +exports.allSchemaRootKinds = ['query', 'mutation', 'subscription']; +function defaultRootName(rootKind) { + return rootKind.charAt(0).toUpperCase() + rootKind.slice(1); +} +exports.defaultRootName = defaultRootName; +function checkDefaultSchemaRoot(type) { + if (type.kind !== 'ObjectType') { + return undefined; + } + switch (type.name) { + case 'Query': return 'query'; + case 'Mutation': return 'mutation'; + case 'Subscription': return 'subscription'; + default: return undefined; + } +} +function isSchemaRootType(type) { + return isObjectType(type) && type.isRootType(); +} +exports.isSchemaRootType = isSchemaRootType; +function isNamedType(type) { + return type instanceof BaseNamedType; +} +exports.isNamedType = isNamedType; +function isWrapperType(type) { + return isListType(type) || isNonNullType(type); +} +exports.isWrapperType = isWrapperType; +function isListType(type) { + return type.kind == 'ListType'; +} +exports.isListType = isListType; +function isNonNullType(type) { + return type.kind == 'NonNullType'; +} +exports.isNonNullType = isNonNullType; +function isScalarType(type) { + return type.kind == 'ScalarType'; +} +exports.isScalarType = isScalarType; +function isCustomScalarType(type) { + return isScalarType(type) && !graphQLBuiltInTypes.includes(type.name); +} +exports.isCustomScalarType = isCustomScalarType; +function isIntType(type) { + return type === type.schema().intType(); +} +exports.isIntType = isIntType; +function isStringType(type) { + return type === type.schema().stringType(); +} +exports.isStringType = isStringType; +function isFloatType(type) { + return type === type.schema().floatType(); +} +exports.isFloatType = isFloatType; +function isBooleanType(type) { + return type === type.schema().booleanType(); +} +exports.isBooleanType = isBooleanType; +function isIDType(type) { + return type === type.schema().idType(); +} +exports.isIDType = isIDType; +function isObjectType(type) { + return type.kind == 'ObjectType'; +} +exports.isObjectType = isObjectType; +function isInterfaceType(type) { + return type.kind == 'InterfaceType'; +} +exports.isInterfaceType = isInterfaceType; +function isEnumType(type) { + return type.kind == 'EnumType'; +} +exports.isEnumType = isEnumType; +function isUnionType(type) { + return type.kind == 'UnionType'; +} +exports.isUnionType = isUnionType; +function isInputObjectType(type) { + return type.kind == 'InputObjectType'; +} +exports.isInputObjectType = isInputObjectType; +function isOutputType(type) { + switch (baseType(type).kind) { + case 'ScalarType': + case 'ObjectType': + case 'UnionType': + case 'EnumType': + case 'InterfaceType': + return true; + default: + return false; + } +} +exports.isOutputType = isOutputType; +function isInputType(type) { + switch (baseType(type).kind) { + case 'ScalarType': + case 'EnumType': + case 'InputObjectType': + return true; + default: + return false; + } +} +exports.isInputType = isInputType; +function isTypeOfKind(type, kind) { + return type.kind === kind; +} +exports.isTypeOfKind = isTypeOfKind; +function filterTypesOfKind(types, kind) { + return types.reduce((acc, type) => { + if (isTypeOfKind(type, kind)) { + acc.push(type); + } + return acc; + }, []); +} +exports.filterTypesOfKind = filterTypesOfKind; +function baseType(type) { + return isWrapperType(type) ? type.baseType() : type; +} +exports.baseType = baseType; +function isNullableType(type) { + return !isNonNullType(type); +} +exports.isNullableType = isNullableType; +function isAbstractType(type) { + return isInterfaceType(type) || isUnionType(type); +} +exports.isAbstractType = isAbstractType; +function isCompositeType(type) { + return isObjectType(type) || isInterfaceType(type) || isUnionType(type); +} +exports.isCompositeType = isCompositeType; +function possibleRuntimeTypes(type) { + switch (type.kind) { + case 'InterfaceType': return type.possibleRuntimeTypes(); + case 'UnionType': return type.types(); + case 'ObjectType': return [type]; + } +} +exports.possibleRuntimeTypes = possibleRuntimeTypes; +function runtimeTypesIntersects(t1, t2) { + const rt1 = possibleRuntimeTypes(t1); + const rt2 = possibleRuntimeTypes(t2); + for (const obj1 of rt1) { + if (rt2.some(obj2 => obj1.name === obj2.name)) { + return true; + } + } + return false; +} +exports.runtimeTypesIntersects = runtimeTypesIntersects; +function isConditionalDirective(directive) { + return ['include', 'skip'].includes(directive.name); +} +exports.isConditionalDirective = isConditionalDirective; +exports.executableDirectiveLocations = [ + graphql_1.DirectiveLocation.QUERY, + graphql_1.DirectiveLocation.MUTATION, + graphql_1.DirectiveLocation.SUBSCRIPTION, + graphql_1.DirectiveLocation.FIELD, + graphql_1.DirectiveLocation.FRAGMENT_DEFINITION, + graphql_1.DirectiveLocation.FRAGMENT_SPREAD, + graphql_1.DirectiveLocation.INLINE_FRAGMENT, + graphql_1.DirectiveLocation.VARIABLE_DEFINITION, +]; +const executableDirectiveLocationsSet = new Set(exports.executableDirectiveLocations); +function isExecutableDirectiveLocation(loc) { + return executableDirectiveLocationsSet.has(loc); +} +exports.isExecutableDirectiveLocation = isExecutableDirectiveLocation; +exports.typeSystemDirectiveLocations = [ + graphql_1.DirectiveLocation.SCHEMA, + graphql_1.DirectiveLocation.SCALAR, + graphql_1.DirectiveLocation.OBJECT, + graphql_1.DirectiveLocation.FIELD_DEFINITION, + graphql_1.DirectiveLocation.ARGUMENT_DEFINITION, + graphql_1.DirectiveLocation.INTERFACE, + graphql_1.DirectiveLocation.UNION, + graphql_1.DirectiveLocation.ENUM, + graphql_1.DirectiveLocation.ENUM_VALUE, + graphql_1.DirectiveLocation.INPUT_OBJECT, + graphql_1.DirectiveLocation.INPUT_FIELD_DEFINITION, +]; +const typeSystemDirectiveLocationsSet = new Set(exports.typeSystemDirectiveLocations); +function isTypeSystemDirectiveLocation(loc) { + return typeSystemDirectiveLocationsSet.has(loc); +} +exports.isTypeSystemDirectiveLocation = isTypeSystemDirectiveLocation; +function typeToAST(type) { + switch (type.kind) { + case 'ListType': + return { + kind: graphql_1.Kind.LIST_TYPE, + type: typeToAST(type.ofType) + }; + case 'NonNullType': + return { + kind: graphql_1.Kind.NON_NULL_TYPE, + type: typeToAST(type.ofType) + }; + default: + return { + kind: graphql_1.Kind.NAMED_TYPE, + name: { kind: graphql_1.Kind.NAME, value: type.name } + }; + } +} +exports.typeToAST = typeToAST; +function typeFromAST(schema, node) { + switch (node.kind) { + case graphql_1.Kind.LIST_TYPE: + return new ListType(typeFromAST(schema, node.type)); + case graphql_1.Kind.NON_NULL_TYPE: + return new NonNullType(typeFromAST(schema, node.type)); + default: + const type = schema.type(node.name.value); + if (!type) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Unknown type "${node.name.value}"`, { nodes: node }); + } + return type; + } +} +exports.typeFromAST = typeFromAST; +function isLeafType(type) { + return isScalarType(type) || isEnumType(type); +} +exports.isLeafType = isLeafType; +class DirectiveTargetElement { + constructor(_schema) { + this._schema = _schema; + } + schema() { + return this._schema; + } + appliedDirectivesOf(nameOrDefinition) { + const directiveName = typeof nameOrDefinition === 'string' ? nameOrDefinition : nameOrDefinition.name; + return this.appliedDirectives.filter(d => d.name == directiveName); + } + get appliedDirectives() { + var _a; + return (_a = this._appliedDirectives) !== null && _a !== void 0 ? _a : []; + } + hasAppliedDirective(nameOrDefinition) { + const directiveName = typeof nameOrDefinition === 'string' ? nameOrDefinition : nameOrDefinition.name; + return this.appliedDirectives.some(d => d.name == directiveName); + } + applyDirective(defOrDirective, args) { + let toAdd; + if (defOrDirective instanceof Directive) { + if (defOrDirective.schema() != this.schema()) { + throw new Error(`Cannot add directive ${defOrDirective} to ${this} as it is attached to another schema`); + } + toAdd = defOrDirective; + if (args) { + toAdd.setArguments(args); + } + } + else { + toAdd = new Directive(defOrDirective.name, args !== null && args !== void 0 ? args : Object.create(null)); + } + Element.prototype['setParent'].call(toAdd, this); + if (this._appliedDirectives) { + this._appliedDirectives.push(toAdd); + } + else { + this._appliedDirectives = [toAdd]; + } + return toAdd; + } + appliedDirectivesToDirectiveNodes() { + if (this.appliedDirectives.length == 0) { + return undefined; + } + return this.appliedDirectives.map(directive => { + return { + kind: graphql_1.Kind.DIRECTIVE, + name: { + kind: graphql_1.Kind.NAME, + value: directive.name, + }, + arguments: directive.argumentsToAST() + }; + }); + } + appliedDirectivesToString() { + return this.appliedDirectives.length == 0 + ? '' + : ' ' + this.appliedDirectives.join(' '); + } + variablesInAppliedDirectives() { + return this.appliedDirectives.reduce((acc, d) => mergeVariables(acc, variablesInArguments(d.arguments())), []); + } +} +exports.DirectiveTargetElement = DirectiveTargetElement; +function sourceASTs(...elts) { + return elts.map(elt => elt === null || elt === void 0 ? void 0 : elt.sourceAST).filter((elt) => elt !== undefined); +} +exports.sourceASTs = sourceASTs; +class Element { + schema() { + const schema = this.schemaInternal(); + (0, utils_1.assert)(schema, 'requested schema does not exist. Probably because the element is unattached'); + return schema; + } + schemaInternal() { + if (!this._parent) { + return undefined; + } + else if (this._parent instanceof Schema) { + return this._parent; + } + else if (this._parent instanceof SchemaElement) { + return this._parent.schemaInternal(); + } + else if (this._parent instanceof DirectiveTargetElement) { + return this._parent.schema(); + } + (0, utils_1.assert)(false, 'unreachable code. parent is of unknown type'); + } + get parent() { + (0, utils_1.assert)(this._parent, 'trying to access non-existent parent'); + return this._parent; + } + isAttached() { + return !!this._parent; + } + setParent(parent) { + (0, utils_1.assert)(!this._parent, "Cannot set parent of an already attached element"); + this._parent = parent; + this.onAttached(); + } + onAttached() { + } + checkUpdate() { + (0, utils_1.assert)(this.isAttached(), () => `Cannot modify detached element ${this}`); + } +} +class Extension { + get extendedElement() { + return this._extendedElement; + } + setExtendedElement(element) { + (0, utils_1.assert)(!this._extendedElement, "Cannot attached already attached extension"); + this._extendedElement = element; + } +} +exports.Extension = Extension; +class SchemaElement extends Element { + addUnappliedDirective({ nameOrDef, args, extension, directive }) { + const toAdd = { + nameOrDef, + args: args !== null && args !== void 0 ? args : {}, + extension, + directive, + }; + if (this._unappliedDirectives) { + this._unappliedDirectives.push(toAdd); + } + else { + this._unappliedDirectives = [toAdd]; + } + } + processUnappliedDirectives() { + var _a; + for (const { nameOrDef, args, extension, directive } of (_a = this._unappliedDirectives) !== null && _a !== void 0 ? _a : []) { + const d = this.applyDirective(nameOrDef, args); + d.setOfExtension(extension); + d.sourceAST = directive; + } + this._unappliedDirectives = undefined; + } + get appliedDirectives() { + var _a; + return (_a = this._appliedDirectives) !== null && _a !== void 0 ? _a : []; + } + appliedDirectivesOf(nameOrDefinition) { + const directiveName = typeof nameOrDefinition === 'string' ? nameOrDefinition : nameOrDefinition.name; + return this.appliedDirectives.filter(d => d.name == directiveName); + } + hasAppliedDirective(nameOrDefinition) { + return (typeof nameOrDefinition === 'string' + ? this.appliedDirectivesOf(nameOrDefinition) + : this.appliedDirectivesOf(nameOrDefinition)).length !== 0; + } + applyDirective(nameOrDef, args, asFirstDirective = false) { + var _a; + let name; + if (typeof nameOrDef === 'string') { + this.checkUpdate(); + const def = (_a = this.schema().directive(nameOrDef)) !== null && _a !== void 0 ? _a : this.schema().blueprint.onMissingDirectiveDefinition(this.schema(), nameOrDef, args); + if (!def) { + throw this.schema().blueprint.onGraphQLJSValidationError(this.schema(), error_1.ERRORS.INVALID_GRAPHQL.err(`Unknown directive "@${nameOrDef}".`)); + } + if (Array.isArray(def)) { + throw (0, exports.ErrGraphQLValidationFailed)(def); + } + name = nameOrDef; + } + else { + this.checkUpdate(nameOrDef); + name = nameOrDef.name; + } + const toAdd = new Directive(name, args !== null && args !== void 0 ? args : Object.create(null)); + Element.prototype['setParent'].call(toAdd, this); + if (this._appliedDirectives) { + if (asFirstDirective) { + this._appliedDirectives.unshift(toAdd); + } + else { + this._appliedDirectives.push(toAdd); + } + } + else { + this._appliedDirectives = [toAdd]; + } + DirectiveDefinition.prototype['addReferencer'].call(toAdd.definition, toAdd); + this.onModification(); + return toAdd; + } + removeAppliedDirectives() { + if (!this._appliedDirectives) { + return; + } + const applied = this._appliedDirectives.concat(); + applied.forEach(d => d.remove()); + } + onModification() { + const schema = this.schemaInternal(); + if (schema) { + Schema.prototype['onModification'].call(schema); + } + } + isElementBuiltIn() { + return false; + } + removeTypeReferenceInternal(type) { + this.removeTypeReference(type); + } + checkRemoval() { + (0, utils_1.assert)(!this.isElementBuiltIn() || Schema.prototype['canModifyBuiltIn'].call(this.schema()), () => `Cannot modify built-in ${this}`); + } + checkUpdate(addedElement) { + super.checkUpdate(); + if (!Schema.prototype['canModifyBuiltIn'].call(this.schema())) { + let thisElement = this; + while (thisElement && thisElement instanceof SchemaElement) { + (0, utils_1.assert)(!thisElement.isElementBuiltIn(), () => `Cannot modify built-in (or part of built-in) ${this}`); + thisElement = thisElement.parent; + } + } + if (addedElement && addedElement.isAttached()) { + const thatSchema = addedElement.schema(); + (0, utils_1.assert)(!thatSchema || thatSchema === this.schema(), () => `Cannot add element ${addedElement} to ${this} as it is attached to another schema`); + } + } +} +exports.SchemaElement = SchemaElement; +class NamedSchemaElement extends SchemaElement { + constructor(name) { + super(); + this._name = name; + } + get name() { + return this._name; + } +} +exports.NamedSchemaElement = NamedSchemaElement; +class BaseNamedType extends NamedSchemaElement { + constructor(name, isBuiltIn = false) { + super(name); + this.isBuiltIn = isBuiltIn; + this.preserveEmptyDefinition = false; + } + addReferencer(referencer) { + if (this._referencers) { + if (!this._referencers.includes(referencer)) { + this._referencers.push(referencer); + } + } + else { + this._referencers = [referencer]; + } + } + removeReferencer(referencer) { + if (this._referencers) { + (0, utils_1.removeArrayElement)(referencer, this._referencers); + } + } + get coordinate() { + return this.name; + } + *allChildElements() { + } + extensions() { + var _a; + return (_a = this._extensions) !== null && _a !== void 0 ? _a : []; + } + hasExtension(extension) { + var _a, _b; + return (_b = (_a = this._extensions) === null || _a === void 0 ? void 0 : _a.includes(extension)) !== null && _b !== void 0 ? _b : false; + } + newExtension() { + return this.addExtension(new Extension()); + } + addExtension(extension) { + this.checkUpdate(); + if (this.hasExtension(extension)) { + return extension; + } + (0, utils_1.assert)(!extension.extendedElement, () => `Cannot add extension to type ${this}: it is already added to another type`); + if (this._extensions) { + this._extensions.push(extension); + } + else { + this._extensions = [extension]; + } + Extension.prototype['setExtendedElement'].call(extension, this); + this.onModification(); + return extension; + } + removeExtensions() { + if (!this._extensions) { + return; + } + this._extensions = undefined; + for (const directive of this.appliedDirectives) { + directive.removeOfExtension(); + } + this.removeInnerElementsExtensions(); + } + isIntrospectionType() { + return (0, introspection_1.isIntrospectionName)(this.name); + } + hasExtensionElements() { + return !!this._extensions; + } + hasNonExtensionElements() { + return this.preserveEmptyDefinition + || this.appliedDirectives.some(d => d.ofExtension() === undefined) + || this.hasNonExtensionInnerElements(); + } + isElementBuiltIn() { + return this.isBuiltIn; + } + rename(newName) { + this.checkUpdate(); + const oldName = this._name; + this._name = newName; + Schema.prototype['renameTypeInternal'].call(this._parent, oldName, newName); + this.onModification(); + } + remove() { + var _a, _b; + if (!this._parent) { + return []; + } + this.checkRemoval(); + this.onModification(); + this.sourceAST = undefined; + this.removeAppliedDirectives(); + this.removeInnerElements(); + const toReturn = (_b = (_a = this._referencers) === null || _a === void 0 ? void 0 : _a.map(r => { + SchemaElement.prototype['removeTypeReferenceInternal'].call(r, this); + return r; + })) !== null && _b !== void 0 ? _b : []; + this._referencers = undefined; + Schema.prototype['removeTypeInternal'].call(this._parent, this); + this._parent = undefined; + return toReturn; + } + removeRecursive() { + this.remove().forEach(ref => this.removeReferenceRecursive(ref)); + } + referencers() { + var _a; + return (_a = this._referencers) !== null && _a !== void 0 ? _a : []; + } + isReferenced() { + return !!this._referencers; + } + toString() { + return this.name; + } +} +class NamedSchemaElementWithType extends NamedSchemaElement { + get type() { + return this._type; + } + set type(type) { + if (type) { + this.checkUpdate(type); + } + else { + this.checkRemoval(); + } + if (this._type) { + removeReferenceToType(this, this._type); + } + this._type = type; + if (type) { + addReferenceToType(this, type); + } + } + removeTypeReference(type) { + (0, utils_1.assert)(this._type && baseType(this._type) === type, () => `Cannot remove reference to type ${type} on ${this} as its type is ${this._type}`); + this._type = undefined; + } +} +exports.NamedSchemaElementWithType = NamedSchemaElementWithType; +class BaseExtensionMember extends Element { + ofExtension() { + return this._extension; + } + removeOfExtension() { + this._extension = undefined; + } + setOfExtension(extension) { + var _a; + this.checkUpdate(); + (0, utils_1.assert)(!extension || ((_a = this._parent) === null || _a === void 0 ? void 0 : _a.hasExtension(extension)), () => `Cannot set object as part of the provided extension: it is not an extension of parent ${this.parent}`); + this._extension = extension; + } + remove() { + this.removeInner(); + Schema.prototype['onModification'].call(this.schema()); + this._extension = undefined; + this._parent = undefined; + } +} +class SchemaBlueprint { + onMissingDirectiveDefinition(_schema, _name, _args) { + return undefined; + } + onDirectiveDefinitionAndSchemaParsed(_) { + return []; + } + ignoreParsedField(_type, _fieldName) { + return false; + } + onConstructed(_) { + } + onAddedCoreFeature(_schema, _feature) { + } + onInvalidation(_) { + } + onValidation(_schema) { + return []; + } + validationRules() { + return specifiedRules_1.specifiedSDLRules; + } + onGraphQLJSValidationError(schema, error) { + var _a; + const matcher = /^Unknown directive "@(?[_A-Za-z][_0-9A-Za-z]*)"\.$/.exec(error.message); + const name = (_a = matcher === null || matcher === void 0 ? void 0 : matcher.groups) === null || _a === void 0 ? void 0 : _a.directive; + if (!name) { + return error; + } + const allDefinedDirectiveNames = schema.allDirectives().map((d) => d.name); + const suggestions = (0, suggestions_1.suggestionList)(name, allDefinedDirectiveNames); + if (suggestions.length === 0) { + return this.onUnknownDirectiveValidationError(schema, name, error); + } + else { + return (0, error_1.withModifiedErrorMessage)(error, `${error.message}${(0, suggestions_1.didYouMean)(suggestions.map((s) => '@' + s))}`); + } + } + onUnknownDirectiveValidationError(_schema, _unknownDirectiveName, error) { + return error; + } + applyDirectivesAfterParsing() { + return false; + } +} +exports.SchemaBlueprint = SchemaBlueprint; +exports.defaultSchemaBlueprint = new SchemaBlueprint(); +class CoreFeature { + constructor(url, nameInSchema, directive, imports, purpose) { + this.url = url; + this.nameInSchema = nameInSchema; + this.directive = directive; + this.imports = imports; + this.purpose = purpose; + } + isFeatureDefinition(element) { + const importName = element.kind === 'DirectiveDefinition' + ? '@' + element.name + : element.name; + return element.name.startsWith(this.nameInSchema + '__') + || (element.kind === 'DirectiveDefinition' && element.name === this.nameInSchema) + || !!this.imports.find((i) => { var _a; return importName === ((_a = i.as) !== null && _a !== void 0 ? _a : i.name); }); + } + directiveNameInSchema(name) { + var _a, _b; + const elementImport = this.imports.find((i) => i.name.charAt(0) === '@' && i.name.slice(1) === name); + return elementImport + ? ((_b = (_a = elementImport.as) === null || _a === void 0 ? void 0 : _a.slice(1)) !== null && _b !== void 0 ? _b : name) + : (name === this.url.name + ? this.nameInSchema + : this.nameInSchema + '__' + name); + } + typeNameInSchema(name) { + var _a; + const elementImport = this.imports.find((i) => i.name === name); + return elementImport ? ((_a = elementImport.as) !== null && _a !== void 0 ? _a : name) : this.nameInSchema + '__' + name; + } +} +exports.CoreFeature = CoreFeature; +class CoreFeatures { + constructor(coreItself) { + this.coreItself = coreItself; + this.byAlias = new Map(); + this.byIdentity = new Map(); + this.add(coreItself); + const coreDef = (0, coreSpec_1.findCoreSpecVersion)(coreItself.url); + if (!coreDef) { + throw error_1.ERRORS.UNKNOWN_LINK_VERSION.err(`Schema uses unknown version ${coreItself.url.version} of the ${coreItself.url.name} spec`); + } + this.coreDefinition = coreDef; + } + getByIdentity(identity) { + return this.byIdentity.get(identity); + } + allFeatures() { + return this.byIdentity.values(); + } + removeFeature(featureIdentity) { + const feature = this.byIdentity.get(featureIdentity); + if (feature) { + this.byIdentity.delete(featureIdentity); + this.byAlias.delete(feature.nameInSchema); + } + } + maybeAddFeature(directive) { + var _a, _b; + if (((_a = directive.definition) === null || _a === void 0 ? void 0 : _a.name) !== this.coreItself.nameInSchema) { + return undefined; + } + const typedDirective = directive; + const args = typedDirective.arguments(); + const url = this.coreDefinition.extractFeatureUrl(args); + const existing = this.byIdentity.get(url.identity); + if (existing) { + throw error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Duplicate inclusion of feature ${url.identity}`); + } + const imports = (0, coreSpec_1.extractCoreFeatureImports)(url, typedDirective); + const feature = new CoreFeature(url, (_b = args.as) !== null && _b !== void 0 ? _b : url.name, directive, imports, args.for); + this.add(feature); + directive.schema().blueprint.onAddedCoreFeature(directive.schema(), feature); + return feature; + } + add(feature) { + this.byAlias.set(feature.nameInSchema, feature); + this.byIdentity.set(feature.url.identity, feature); + } + sourceFeature(element) { + var _a, _b; + const isDirective = element instanceof DirectiveDefinition || element instanceof Directive; + const splitted = element.name.split('__'); + if (splitted.length > 1) { + const feature = this.byAlias.get(splitted[0]); + return feature ? { + feature, + nameInFeature: splitted[1], + isImported: false, + } : undefined; + } + else { + const directFeature = this.byAlias.get(element.name); + if (directFeature && isDirective) { + return { + feature: directFeature, + nameInFeature: (_b = (_a = directFeature.imports.find(imp => imp.as === `@${element.name}`)) === null || _a === void 0 ? void 0 : _a.name.slice(1)) !== null && _b !== void 0 ? _b : element.name, + isImported: true, + }; + } + const importName = isDirective ? '@' + element.name : element.name; + const allFeatures = [this.coreItself, ...this.byIdentity.values()]; + for (const feature of allFeatures) { + for (const { as, name } of feature.imports) { + if ((as !== null && as !== void 0 ? as : name) === importName) { + return { + feature, + nameInFeature: name.slice(1), + isImported: true, + }; + } + } + } + return undefined; + } + } +} +exports.CoreFeatures = CoreFeatures; +const graphQLBuiltInTypes = ['Int', 'Float', 'String', 'Boolean', 'ID']; +const graphQLBuiltInTypesSpecifications = graphQLBuiltInTypes.map((name) => (0, directiveAndTypeSpecification_1.createScalarTypeSpecification)({ name })); +const graphQLBuiltInDirectivesSpecifications = [ + (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'include', + locations: [graphql_1.DirectiveLocation.FIELD, graphql_1.DirectiveLocation.FRAGMENT_SPREAD, graphql_1.DirectiveLocation.INLINE_FRAGMENT], + argumentFct: (schema) => ({ args: [{ name: 'if', type: new NonNullType(schema.booleanType()) }], errors: [] }) + }), + (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'skip', + locations: [graphql_1.DirectiveLocation.FIELD, graphql_1.DirectiveLocation.FRAGMENT_SPREAD, graphql_1.DirectiveLocation.INLINE_FRAGMENT], + argumentFct: (schema) => ({ args: [{ name: 'if', type: new NonNullType(schema.booleanType()) }], errors: [] }) + }), + (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'deprecated', + locations: [graphql_1.DirectiveLocation.FIELD_DEFINITION, graphql_1.DirectiveLocation.ENUM_VALUE, graphql_1.DirectiveLocation.ARGUMENT_DEFINITION, graphql_1.DirectiveLocation.INPUT_FIELD_DEFINITION], + argumentFct: (schema) => ({ args: [{ name: 'reason', type: schema.stringType(), defaultValue: 'No longer supported' }], errors: [] }) + }), + (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'specifiedBy', + locations: [graphql_1.DirectiveLocation.SCALAR], + argumentFct: (schema) => ({ args: [{ name: 'url', type: new NonNullType(schema.stringType()) }], errors: [] }) + }), + (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'defer', + locations: [graphql_1.DirectiveLocation.FRAGMENT_SPREAD, graphql_1.DirectiveLocation.INLINE_FRAGMENT], + argumentFct: (schema) => ({ + args: [ + { name: 'label', type: schema.stringType() }, + { name: 'if', type: new NonNullType(schema.booleanType()), defaultValue: true }, + ], + errors: [], + }) + }), + (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'stream', + locations: [graphql_1.DirectiveLocation.FIELD], + argumentFct: (schema) => ({ + args: [ + { name: 'label', type: schema.stringType() }, + { name: 'initialCount', type: schema.intType(), defaultValue: 0 }, + { name: 'if', type: new NonNullType(schema.booleanType()), defaultValue: true }, + ], + errors: [], + }) + }), +]; +const coordinateRegexp = /^@?[_A-Za-z][_0-9A-Za-z]*(\.[_A-Za-z][_0-9A-Za-z]*)?(\([_A-Za-z][_0-9A-Za-z]*:\))?$/; +class Schema { + constructor(blueprint = exports.defaultSchemaBlueprint, config = {}) { + this.blueprint = blueprint; + this.config = config; + this._builtInTypes = new utils_1.MapWithCachedArrays(); + this._types = new utils_1.MapWithCachedArrays(); + this._builtInDirectives = new utils_1.MapWithCachedArrays(); + this._directives = new utils_1.MapWithCachedArrays(); + this.isConstructed = false; + this.isValidated = false; + this._schemaDefinition = new SchemaDefinition(); + Element.prototype['setParent'].call(this._schemaDefinition, this); + graphQLBuiltInTypesSpecifications.forEach((spec) => spec.checkOrAdd(this, undefined, true)); + graphQLBuiltInDirectivesSpecifications.forEach((spec) => spec.checkOrAdd(this, undefined, true)); + blueprint.onConstructed(this); + this.isConstructed = true; + } + canModifyBuiltIn() { + return !this.isConstructed; + } + runWithBuiltInModificationAllowed(fct) { + const wasConstructed = this.isConstructed; + this.isConstructed = false; + fct(); + this.isConstructed = wasConstructed; + } + renameTypeInternal(oldName, newName) { + this._types.set(newName, this._types.get(oldName)); + this._types.delete(oldName); + } + removeTypeInternal(type) { + this._types.delete(type.name); + } + removeDirectiveInternal(definition) { + this._directives.delete(definition.name); + } + markAsCoreSchema(coreItself) { + this._coreFeatures = new CoreFeatures(coreItself); + } + unmarkAsCoreSchema() { + this._coreFeatures = undefined; + } + onModification() { + if (this.isConstructed) { + this.invalidate(); + this.cachedDocument = undefined; + this.apiSchema = undefined; + } + } + isCoreSchema() { + return this.coreFeatures !== undefined; + } + get coreFeatures() { + return this._coreFeatures; + } + toAST() { + var _a; + if (!this.cachedDocument) { + const ast = (0, graphql_1.parse)((0, print_1.printSchema)(this), { noLocation: true }); + const shouldCache = (_a = this.config.cacheAST) !== null && _a !== void 0 ? _a : false; + if (!shouldCache) { + return ast; + } + this.cachedDocument = ast; + } + return this.cachedDocument; + } + toAPISchema() { + if (!this.apiSchema) { + this.validate(); + const apiSchema = this.clone(); + for (const toRemoveIfCustom of ['defer', 'stream']) { + const directive = apiSchema.directive(toRemoveIfCustom); + if (directive && !directive.isBuiltIn) { + directive.removeRecursive(); + } + } + (0, inaccessibleSpec_1.removeInaccessibleElements)(apiSchema); + (0, coreSpec_1.removeAllCoreFeatures)(apiSchema); + (0, utils_1.assert)(!apiSchema.isCoreSchema(), "The API schema shouldn't be a core schema"); + apiSchema.validate(); + this.apiSchema = apiSchema; + } + return this.apiSchema; + } + emptyASTDefinitionsForExtensionsWithoutDefinition() { + const nodes = []; + if (this.schemaDefinition.hasExtensionElements() && !this.schemaDefinition.hasNonExtensionElements()) { + const node = { kind: graphql_1.Kind.SCHEMA_DEFINITION, operationTypes: [] }; + nodes.push(node); + } + for (const type of this.types()) { + if (type.hasExtensionElements() && !type.hasNonExtensionElements()) { + const node = { + kind: type.astDefinitionKind, + name: { kind: graphql_1.Kind.NAME, value: type.name }, + }; + nodes.push(node); + } + } + return nodes; + } + toGraphQLJSSchema(config) { + var _a, _b; + const includeDefer = (_a = config === null || config === void 0 ? void 0 : config.includeDefer) !== null && _a !== void 0 ? _a : false; + const includeStream = (_b = config === null || config === void 0 ? void 0 : config.includeStream) !== null && _b !== void 0 ? _b : false; + let ast = this.toAST(); + const additionalNodes = this.emptyASTDefinitionsForExtensionsWithoutDefinition(); + if (includeDefer) { + additionalNodes.push(this.deferDirective().toAST()); + } + if (includeStream) { + additionalNodes.push(this.streamDirective().toAST()); + } + if (additionalNodes.length > 0) { + ast = { + kind: graphql_1.Kind.DOCUMENT, + definitions: ast.definitions.concat(additionalNodes), + }; + } + const graphQLSchema = (0, graphql_1.buildASTSchema)(ast); + if (additionalNodes.length > 0) { + for (const node of additionalNodes) { + switch (node.kind) { + case graphql_1.Kind.SCHEMA_DEFINITION: + graphQLSchema.astNode = undefined; + break; + case graphql_1.Kind.SCALAR_TYPE_DEFINITION: + case graphql_1.Kind.OBJECT_TYPE_DEFINITION: + case graphql_1.Kind.INTERFACE_TYPE_DEFINITION: + case graphql_1.Kind.ENUM_TYPE_DEFINITION: + case graphql_1.Kind.UNION_TYPE_DEFINITION: + case graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION: + const type = graphQLSchema.getType(node.name.value); + if (type) { + type.astNode = undefined; + } + } + } + } + return graphQLSchema; + } + get schemaDefinition() { + return this._schemaDefinition; + } + types() { + return this._types.values(); + } + interfaceTypes() { + return filterTypesOfKind(this.types(), 'InterfaceType'); + } + objectTypes() { + return filterTypesOfKind(this.types(), 'ObjectType'); + } + unionTypes() { + return filterTypesOfKind(this.types(), 'UnionType'); + } + scalarTypes() { + return filterTypesOfKind(this.types(), 'ScalarType'); + } + inputTypes() { + return filterTypesOfKind(this.types(), 'InputObjectType'); + } + enumTypes() { + return filterTypesOfKind(this.types(), 'EnumType'); + } + builtInTypes(includeShadowed = false) { + const allBuiltIns = this._builtInTypes.values(); + return includeShadowed + ? allBuiltIns + : allBuiltIns.filter(t => !this.isShadowedBuiltInType(t)); + } + isShadowedBuiltInType(type) { + return type.isBuiltIn && this._types.has(type.name); + } + allTypes() { + return this.builtInTypes().concat(this.types()); + } + type(name) { + const type = this._types.get(name); + return type ? type : this._builtInTypes.get(name); + } + typeOfKind(name, kind) { + const type = this.type(name); + return type && type.kind === kind ? type : undefined; + } + intType() { + return this._builtInTypes.get('Int'); + } + floatType() { + return this._builtInTypes.get('Float'); + } + stringType() { + return this._builtInTypes.get('String'); + } + booleanType() { + return this._builtInTypes.get('Boolean'); + } + idType() { + return this._builtInTypes.get('ID'); + } + addType(type) { + const existing = this.type(type.name); + if (existing) { + (0, utils_1.assert)(existing.isBuiltIn, () => `Type ${type} already exists in this schema`); + } + if (type.isAttached()) { + (0, utils_1.assert)(type.parent == this, () => `Cannot add type ${type} to this schema; it is already attached to another schema`); + return type; + } + if (type.isBuiltIn) { + (0, utils_1.assert)(!this.isConstructed, `Cannot add built-in ${type} to this schema (built-ins can only be added at schema construction time)`); + this._builtInTypes.set(type.name, type); + } + else { + this._types.set(type.name, type); + } + Element.prototype['setParent'].call(type, this); + const defaultSchemaRoot = checkDefaultSchemaRoot(type); + if (defaultSchemaRoot && !this.schemaDefinition.root(defaultSchemaRoot)) { + this.schemaDefinition.setRoot(defaultSchemaRoot, type); + } + this.onModification(); + return type; + } + directives() { + return this._directives.values(); + } + builtInDirectives(includeShadowed = false) { + return includeShadowed + ? this._builtInDirectives.values() + : this._builtInDirectives.values().filter(d => !this.isShadowedBuiltInDirective(d)); + } + allDirectives() { + return this.builtInDirectives().concat(this.directives()); + } + isShadowedBuiltInDirective(directive) { + return directive.isBuiltIn && this._directives.has(directive.name); + } + directive(name) { + const directive = this._directives.get(name); + return directive ? directive : this.builtInDirective(name); + } + builtInDirective(name) { + return this._builtInDirectives.get(name); + } + *allNamedSchemaElement() { + for (const type of this.types()) { + yield type; + yield* type.allChildElements(); + } + for (const directive of this.directives()) { + yield directive; + yield* directive.arguments(); + } + } + *allSchemaElement() { + yield this._schemaDefinition; + yield* this.allNamedSchemaElement(); + } + addDirectiveDefinition(directiveOrName) { + const definition = typeof directiveOrName === 'string' ? new DirectiveDefinition(directiveOrName) : directiveOrName; + const existing = this.directive(definition.name); + (0, utils_1.assert)(!existing || existing.isBuiltIn, () => `Directive ${definition} already exists in this schema`); + if (definition.isAttached()) { + (0, utils_1.assert)(definition.parent == this, () => `Cannot add directive ${definition} to this schema; it is already attached to another schema`); + return definition; + } + if (definition.isBuiltIn) { + (0, utils_1.assert)(!this.isConstructed, () => `Cannot add built-in ${definition} to this schema (built-ins can only be added at schema construction time)`); + this._builtInDirectives.set(definition.name, definition); + } + else { + this._directives.set(definition.name, definition); + } + Element.prototype['setParent'].call(definition, this); + this.onModification(); + return definition; + } + invalidate() { + if (this.isValidated) { + this.blueprint.onInvalidation(this); + } + this.isValidated = false; + } + validate() { + if (this.isValidated) { + return; + } + this.runWithBuiltInModificationAllowed(() => { + (0, introspection_1.addIntrospectionFields)(this); + }); + let errors = (0, validate_1.validateSDL)(this.toAST(), undefined, this.blueprint.validationRules()).map((e) => this.blueprint.onGraphQLJSValidationError(this, e)); + errors = errors.concat((0, validate_2.validateSchema)(this)); + if (errors.length === 0) { + this.runWithBuiltInModificationAllowed(() => { + errors = this.blueprint.onValidation(this); + }); + } + if (errors.length > 0) { + throw (0, exports.ErrGraphQLValidationFailed)(errors); + } + this.isValidated = true; + } + clone(builtIns) { + const cloned = new Schema(builtIns !== null && builtIns !== void 0 ? builtIns : this.blueprint); + copy(this, cloned); + if (this.isValidated) { + cloned.validate(); + } + return cloned; + } + getBuiltInDirective(name) { + const directive = this.directive(name); + (0, utils_1.assert)(directive, `The provided schema has not be built with the ${name} directive built-in`); + return directive; + } + includeDirective() { + return this.getBuiltInDirective('include'); + } + skipDirective() { + return this.getBuiltInDirective('skip'); + } + deprecatedDirective() { + return this.getBuiltInDirective('deprecated'); + } + specifiedByDirective() { + return this.getBuiltInDirective('specifiedBy'); + } + deferDirective() { + return this.getBuiltInDirective('defer'); + } + streamDirective() { + return this.getBuiltInDirective('stream'); + } + elementByCoordinate(coordinate) { + if (!coordinate.match(coordinateRegexp)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid argument "${coordinate}: it is not a syntactically valid graphQL coordinate."`); + } + const argStartIdx = coordinate.indexOf('('); + const start = argStartIdx < 0 ? coordinate : coordinate.slice(0, argStartIdx); + const argName = argStartIdx < 0 ? undefined : coordinate.slice(argStartIdx + 1, coordinate.length - 2); + const splittedStart = start.split('.'); + const typeOrDirectiveName = splittedStart[0]; + const fieldOrEnumName = splittedStart[1]; + const isDirective = typeOrDirectiveName.startsWith('@'); + if (isDirective) { + if (fieldOrEnumName) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid argument "${coordinate}: it is not a syntactically valid graphQL coordinate."`); + } + const directive = this.directive(typeOrDirectiveName.slice(1)); + return argName ? directive === null || directive === void 0 ? void 0 : directive.argument(argName) : directive; + } + else { + const type = this.type(typeOrDirectiveName); + if (!type || !fieldOrEnumName) { + return type; + } + switch (type.kind) { + case 'ObjectType': + case 'InterfaceType': + const field = type.field(fieldOrEnumName); + return argName ? field === null || field === void 0 ? void 0 : field.argument(argName) : field; + case 'InputObjectType': + if (argName) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid argument "${coordinate}: it is not a syntactically valid graphQL coordinate."`); + } + return type.field(fieldOrEnumName); + case 'EnumType': + if (argName) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid argument "${coordinate}: it is not a syntactically valid graphQL coordinate."`); + } + return type.value(fieldOrEnumName); + default: + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid argument "${coordinate}: it is not a syntactically valid graphQL coordinate."`); + } + } + } +} +exports.Schema = Schema; +class RootType extends BaseExtensionMember { + constructor(rootKind, type) { + super(); + this.rootKind = rootKind; + this.type = type; + } + isDefaultRootName() { + return defaultRootName(this.rootKind) == this.type.name; + } + removeInner() { + SchemaDefinition.prototype['removeRootType'].call(this._parent, this); + } +} +exports.RootType = RootType; +class SchemaDefinition extends SchemaElement { + constructor() { + super(...arguments); + this.kind = 'SchemaDefinition'; + this._roots = new utils_1.MapWithCachedArrays(); + this.preserveEmptyDefinition = false; + } + roots() { + return this._roots.values(); + } + applyDirective(nameOrDef, args, asFirstDirective = false) { + var _a, _b; + const applied = super.applyDirective(nameOrDef, args, asFirstDirective); + const schema = this.schema(); + const coreFeatures = schema.coreFeatures; + if ((0, coreSpec_1.isCoreSpecDirectiveApplication)(applied)) { + if (coreFeatures) { + throw error_1.ERRORS.INVALID_LINK_DIRECTIVE_USAGE.err(`Invalid duplicate application of @core/@link`); + } + const schemaDirective = applied; + const args = schemaDirective.arguments(); + const url = coreSpec_1.FeatureUrl.parse(((_a = args.url) !== null && _a !== void 0 ? _a : args.feature)); + const imports = (0, coreSpec_1.extractCoreFeatureImports)(url, schemaDirective); + const core = new CoreFeature(url, (_b = args.as) !== null && _b !== void 0 ? _b : url.name, schemaDirective, imports, args.for); + Schema.prototype['markAsCoreSchema'].call(schema, core); + this.appliedDirectives + .filter((a) => a !== applied) + .forEach((other) => CoreFeatures.prototype['maybeAddFeature'].call(schema.coreFeatures, other)); + } + else if (coreFeatures) { + CoreFeatures.prototype['maybeAddFeature'].call(coreFeatures, applied); + } + this.onModification(); + return applied; + } + root(rootKind) { + return this._roots.get(rootKind); + } + rootType(rootKind) { + var _a; + return (_a = this.root(rootKind)) === null || _a === void 0 ? void 0 : _a.type; + } + setRoot(rootKind, nameOrType) { + let toSet; + if (typeof nameOrType === 'string') { + this.checkUpdate(); + const obj = this.schema().type(nameOrType); + if (!obj) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Cannot set schema ${rootKind} root to unknown type ${nameOrType}`); + } + else if (obj.kind != 'ObjectType') { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`${defaultRootName(rootKind)} root type must be an Object type${rootKind === 'query' ? '' : ' if provided'}, it cannot be set to ${nameOrType} (an ${obj.kind}).`); + } + toSet = new RootType(rootKind, obj); + } + else { + this.checkUpdate(nameOrType); + toSet = new RootType(rootKind, nameOrType); + } + const prevRoot = this._roots.get(rootKind); + if (prevRoot) { + removeReferenceToType(this, prevRoot.type); + } + this._roots.set(rootKind, toSet); + Element.prototype['setParent'].call(toSet, this); + addReferenceToType(this, toSet.type); + this.onModification(); + return toSet; + } + extensions() { + var _a; + return (_a = this._extensions) !== null && _a !== void 0 ? _a : []; + } + hasExtension(extension) { + var _a, _b; + return (_b = (_a = this._extensions) === null || _a === void 0 ? void 0 : _a.includes(extension)) !== null && _b !== void 0 ? _b : false; + } + newExtension() { + return this.addExtension(new Extension()); + } + addExtension(extension) { + this.checkUpdate(); + if (this.hasExtension(extension)) { + return extension; + } + (0, utils_1.assert)(!extension.extendedElement, 'Cannot add extension to this schema: extension is already added to another schema'); + if (this._extensions) { + this._extensions.push(extension); + } + else { + this._extensions = [extension]; + } + Extension.prototype['setExtendedElement'].call(extension, this); + this.onModification(); + return extension; + } + hasExtensionElements() { + return !!this._extensions; + } + hasNonExtensionElements() { + return this.preserveEmptyDefinition + || this.appliedDirectives.some((d) => d.ofExtension() === undefined) + || this.roots().some((r) => r.ofExtension() === undefined); + } + removeRootType(rootType) { + this._roots.delete(rootType.rootKind); + removeReferenceToType(this, rootType.type); + } + removeTypeReference(toRemove) { + for (const rootType of this.roots()) { + if (rootType.type == toRemove) { + this._roots.delete(rootType.rootKind); + } + } + } + toString() { + return `schema[${this._roots.keys().join(', ')}]`; + } +} +exports.SchemaDefinition = SchemaDefinition; +class ScalarType extends BaseNamedType { + constructor() { + super(...arguments); + this.kind = 'ScalarType'; + this.astDefinitionKind = graphql_1.Kind.SCALAR_TYPE_DEFINITION; + } + removeTypeReference(type) { + (0, utils_1.assert)(false, `Scalar type ${this} can't reference other types; shouldn't be asked to remove reference to ${type}`); + } + hasNonExtensionInnerElements() { + return false; + } + removeInnerElementsExtensions() { + } + removeInnerElements() { + } + removeReferenceRecursive(ref) { + ref.remove(); + } +} +exports.ScalarType = ScalarType; +class InterfaceImplementation extends BaseExtensionMember { + constructor(itf) { + super(); + this.interface = itf; + } + removeInner() { + FieldBasedType.prototype['removeInterfaceImplementation'].call(this._parent, this.interface); + } + toString() { + return `'implements ${this.interface}'`; + } +} +exports.InterfaceImplementation = InterfaceImplementation; +class FieldBasedType extends BaseNamedType { + constructor() { + super(...arguments); + this._fields = new utils_1.MapWithCachedArrays(); + } + onAttached() { + Schema.prototype['runWithBuiltInModificationAllowed'].call(this.schema(), () => { + this.addField(new FieldDefinition(exports.typenameFieldName, true), new NonNullType(this.schema().stringType())); + }); + } + removeFieldInternal(field) { + this._fields.delete(field.name); + this._cachedNonBuiltInFields = undefined; + } + interfaceImplementations() { + var _a, _b; + return (_b = (_a = this._interfaceImplementations) === null || _a === void 0 ? void 0 : _a.values()) !== null && _b !== void 0 ? _b : []; + } + interfaceImplementation(type) { + return this._interfaceImplementations ? this._interfaceImplementations.get(typeof type === 'string' ? type : type.name) : undefined; + } + interfaces() { + return this.interfaceImplementations().map(impl => impl.interface); + } + implementsInterface(type) { + var _a, _b; + return (_b = (_a = this._interfaceImplementations) === null || _a === void 0 ? void 0 : _a.has(typeof type === 'string' ? type : type.name)) !== null && _b !== void 0 ? _b : false; + } + addImplementedInterface(nameOrItfOrItfImpl) { + var _a; + let toAdd; + if (nameOrItfOrItfImpl instanceof InterfaceImplementation) { + this.checkUpdate(nameOrItfOrItfImpl); + toAdd = nameOrItfOrItfImpl; + } + else { + let itf; + if (typeof nameOrItfOrItfImpl === 'string') { + this.checkUpdate(); + const maybeItf = this.schema().type(nameOrItfOrItfImpl); + if (!maybeItf) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Cannot implement unknown type ${nameOrItfOrItfImpl}`); + } + else if (maybeItf.kind != 'InterfaceType') { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Cannot implement non-interface type ${nameOrItfOrItfImpl} (of type ${maybeItf.kind})`); + } + itf = maybeItf; + } + else { + itf = nameOrItfOrItfImpl; + } + toAdd = new InterfaceImplementation(itf); + } + const existing = (_a = this._interfaceImplementations) === null || _a === void 0 ? void 0 : _a.get(toAdd.interface.name); + if (!existing) { + if (!this._interfaceImplementations) { + this._interfaceImplementations = new utils_1.MapWithCachedArrays(); + } + this._interfaceImplementations.set(toAdd.interface.name, toAdd); + addReferenceToType(this, toAdd.interface); + Element.prototype['setParent'].call(toAdd, this); + this.onModification(); + return toAdd; + } + else { + return existing; + } + } + fields() { + if (!this._cachedNonBuiltInFields) { + this._cachedNonBuiltInFields = this._fields.values().filter(f => !f.isBuiltIn); + } + return this._cachedNonBuiltInFields; + } + hasFields() { + return this.fields().length > 0; + } + builtInFields() { + return this.allFields().filter(f => f.isBuiltIn); + } + allFields() { + return this._fields.values(); + } + field(name) { + return this._fields.get(name); + } + typenameField() { + return this.field(exports.typenameFieldName); + } + addField(nameOrField, type) { + let toAdd; + if (typeof nameOrField === 'string') { + this.checkUpdate(); + toAdd = new FieldDefinition(nameOrField); + } + else { + this.checkUpdate(nameOrField); + toAdd = nameOrField; + } + if (this.field(toAdd.name)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Field ${toAdd.name} already exists on ${this}`); + } + if (type && !isOutputType(type)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid input type ${type} for field ${toAdd.name}: object and interface field types should be output types.`); + } + this._fields.set(toAdd.name, toAdd); + this._cachedNonBuiltInFields = undefined; + Element.prototype['setParent'].call(toAdd, this); + if (type) { + toAdd.type = type; + } + this.onModification(); + return toAdd; + } + *allChildElements() { + for (const field of this._fields.values()) { + yield field; + yield* field.arguments(); + } + } + removeInterfaceImplementation(itf) { + var _a; + (_a = this._interfaceImplementations) === null || _a === void 0 ? void 0 : _a.delete(itf.name); + removeReferenceToType(this, itf); + } + removeTypeReference(type) { + var _a; + (_a = this._interfaceImplementations) === null || _a === void 0 ? void 0 : _a.delete(type.name); + } + removeInnerElements() { + for (const interfaceImpl of this.interfaceImplementations()) { + interfaceImpl.remove(); + } + for (const field of this.allFields()) { + if (field.isBuiltIn) { + FieldDefinition.prototype['removeParent'].call(field); + } + else { + field.remove(); + } + } + } + hasNonExtensionInnerElements() { + return this.interfaceImplementations().some(itf => itf.ofExtension() === undefined) + || this.fields().some(f => f.ofExtension() === undefined); + } + removeInnerElementsExtensions() { + this.interfaceImplementations().forEach(itf => itf.removeOfExtension()); + this.fields().forEach(f => f.removeOfExtension()); + } +} +class ObjectType extends FieldBasedType { + constructor() { + super(...arguments); + this.kind = 'ObjectType'; + this.astDefinitionKind = graphql_1.Kind.OBJECT_TYPE_DEFINITION; + } + isRootType() { + const schema = this.schema(); + return schema.schemaDefinition.roots().some(rt => rt.type == this); + } + isQueryRootType() { + var _a; + const schema = this.schema(); + return ((_a = schema.schemaDefinition.root('query')) === null || _a === void 0 ? void 0 : _a.type) === this; + } + removeReferenceRecursive(ref) { + switch (ref.kind) { + case 'FieldDefinition': + ref.removeRecursive(); + break; + case 'UnionType': + if (ref.membersCount() === 0) { + ref.removeRecursive(); + } + break; + } + } +} +exports.ObjectType = ObjectType; +class InterfaceType extends FieldBasedType { + constructor() { + super(...arguments); + this.kind = 'InterfaceType'; + this.astDefinitionKind = graphql_1.Kind.INTERFACE_TYPE_DEFINITION; + } + allImplementations() { + return this.referencers().filter(ref => ref.kind === 'ObjectType' || ref.kind === 'InterfaceType'); + } + possibleRuntimeTypes() { + return this.allImplementations().filter(impl => impl.kind === 'ObjectType'); + } + isPossibleRuntimeType(type) { + const typeName = typeof type === 'string' ? type : type.name; + return this.possibleRuntimeTypes().some(t => t.name == typeName); + } + removeReferenceRecursive(ref) { + if (ref.kind === 'FieldDefinition') { + ref.removeRecursive(); + } + } +} +exports.InterfaceType = InterfaceType; +class UnionMember extends BaseExtensionMember { + constructor(type) { + super(); + this.type = type; + } + removeInner() { + UnionType.prototype['removeMember'].call(this._parent, this.type); + } +} +exports.UnionMember = UnionMember; +class UnionType extends BaseNamedType { + constructor() { + super(...arguments); + this.kind = 'UnionType'; + this.astDefinitionKind = graphql_1.Kind.UNION_TYPE_DEFINITION; + this._members = new utils_1.MapWithCachedArrays(); + } + onAttached() { + Schema.prototype['runWithBuiltInModificationAllowed'].call(this.schema(), () => { + this._typenameField = new FieldDefinition(exports.typenameFieldName, true); + Element.prototype['setParent'].call(this._typenameField, this); + this._typenameField.type = new NonNullType(this.schema().stringType()); + }); + } + types() { + return this.members().map(m => m.type); + } + members() { + return this._members.values(); + } + membersCount() { + return this._members.size; + } + hasTypeMember(type) { + return this._members.has(typeof type === 'string' ? type : type.name); + } + addType(nameOrTypeOrMember) { + let toAdd; + if (nameOrTypeOrMember instanceof UnionMember) { + this.checkUpdate(nameOrTypeOrMember); + toAdd = nameOrTypeOrMember; + } + else { + let obj; + if (typeof nameOrTypeOrMember === 'string') { + this.checkUpdate(); + const maybeObj = this.schema().type(nameOrTypeOrMember); + if (!maybeObj) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Cannot add unknown type ${nameOrTypeOrMember} as member of union type ${this.name}`); + } + else if (maybeObj.kind != 'ObjectType') { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Cannot add non-object type ${nameOrTypeOrMember} (of type ${maybeObj.kind}) as member of union type ${this.name}`); + } + obj = maybeObj; + } + else { + this.checkUpdate(nameOrTypeOrMember); + obj = nameOrTypeOrMember; + } + toAdd = new UnionMember(obj); + } + const existing = this._members.get(toAdd.type.name); + if (!existing) { + this._members.set(toAdd.type.name, toAdd); + Element.prototype['setParent'].call(toAdd, this); + addReferenceToType(this, toAdd.type); + this.onModification(); + return toAdd; + } + else { + return existing; + } + } + clearTypes() { + for (const type of this.types()) { + this.removeMember(type); + } + this.onModification(); + } + field(name) { + if (name === exports.typenameFieldName && this._typenameField) { + return this._typenameField; + } + return undefined; + } + typenameField() { + return this._typenameField; + } + removeMember(type) { + this._members.delete(type.name); + removeReferenceToType(this, type); + } + removeTypeReference(type) { + this._members.delete(type.name); + } + removeInnerElements() { + for (const member of this.members()) { + member.remove(); + } + } + hasNonExtensionInnerElements() { + return this.members().some(m => m.ofExtension() === undefined); + } + removeReferenceRecursive(ref) { + ref.removeRecursive(); + } + removeInnerElementsExtensions() { + this.members().forEach(m => m.removeOfExtension()); + } +} +exports.UnionType = UnionType; +class EnumType extends BaseNamedType { + constructor() { + super(...arguments); + this.kind = 'EnumType'; + this.astDefinitionKind = graphql_1.Kind.ENUM_TYPE_DEFINITION; + this._values = []; + } + get values() { + return Array.from(this._values); + } + value(name) { + return this._values.find(v => v.name === name); + } + addValue(nameOrValue) { + let toAdd; + if (typeof nameOrValue === 'string') { + this.checkUpdate(); + toAdd = new EnumValue(nameOrValue); + } + else { + this.checkUpdate(nameOrValue); + toAdd = nameOrValue; + } + const existing = this.value(toAdd.name); + if (!existing) { + this._values.push(toAdd); + Element.prototype['setParent'].call(toAdd, this); + this.onModification(); + return toAdd; + } + else { + return existing; + } + } + removeTypeReference(type) { + (0, utils_1.assert)(false, `Eum type ${this} can't reference other types; shouldn't be asked to remove reference to ${type}`); + } + removeValueInternal(value) { + (0, utils_1.removeArrayElement)(value, this._values); + } + removeInnerElements() { + const values = this.values; + for (const value of values) { + value.remove(); + } + } + hasNonExtensionInnerElements() { + return this._values.some(v => v.ofExtension() === undefined); + } + removeReferenceRecursive(ref) { + ref.removeRecursive(); + } + removeInnerElementsExtensions() { + this._values.forEach(v => v.removeOfExtension()); + } +} +exports.EnumType = EnumType; +class InputObjectType extends BaseNamedType { + constructor() { + super(...arguments); + this.kind = 'InputObjectType'; + this.astDefinitionKind = graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION; + this._fields = new Map(); + } + fields() { + if (!this._cachedFieldsArray) { + this._cachedFieldsArray = (0, utils_1.mapValues)(this._fields); + } + return this._cachedFieldsArray; + } + field(name) { + return this._fields.get(name); + } + addField(nameOrField, type) { + const toAdd = typeof nameOrField === 'string' ? new InputFieldDefinition(nameOrField) : nameOrField; + this.checkUpdate(toAdd); + if (this.field(toAdd.name)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Field ${toAdd.name} already exists on ${this}`); + } + if (type && !isInputType(type)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid output type ${type} for field ${toAdd.name}: input field types should be input types.`); + } + this._fields.set(toAdd.name, toAdd); + this._cachedFieldsArray = undefined; + Element.prototype['setParent'].call(toAdd, this); + if (typeof nameOrField === 'string' && type) { + toAdd.type = type; + } + this.onModification(); + return toAdd; + } + hasFields() { + return this._fields.size > 0; + } + *allChildElements() { + yield* this._fields.values(); + } + removeTypeReference(type) { + (0, utils_1.assert)(false, `Input Object type ${this} can't reference other types; shouldn't be asked to remove reference to ${type}`); + } + removeInnerElements() { + for (const field of this.fields()) { + field.remove(); + } + } + removeFieldInternal(field) { + this._fields.delete(field.name); + this._cachedFieldsArray = undefined; + } + hasNonExtensionInnerElements() { + return this.fields().some(f => f.ofExtension() === undefined); + } + removeReferenceRecursive(ref) { + if (ref.kind === 'ArgumentDefinition') { + ref.parent().removeRecursive(); + } + else { + ref.removeRecursive(); + } + } + removeInnerElementsExtensions() { + this.fields().forEach(f => f.removeOfExtension()); + } +} +exports.InputObjectType = InputObjectType; +class BaseWrapperType { + constructor(_type) { + this._type = _type; + (0, utils_1.assert)(this._type, 'Cannot wrap an undefined/null type'); + } + schema() { + return this.baseType().schema(); + } + isAttached() { + return this.baseType().isAttached(); + } + get ofType() { + return this._type; + } + baseType() { + return baseType(this._type); + } +} +class ListType extends BaseWrapperType { + constructor(type) { + super(type); + this.kind = 'ListType'; + } + toString() { + return `[${this.ofType}]`; + } +} +exports.ListType = ListType; +class NonNullType extends BaseWrapperType { + constructor(type) { + super(type); + this.kind = 'NonNullType'; + } + toString() { + return `${this.ofType}!`; + } +} +exports.NonNullType = NonNullType; +class FieldDefinition extends NamedSchemaElementWithType { + constructor(name, isBuiltIn = false) { + super(name); + this.isBuiltIn = isBuiltIn; + this.kind = 'FieldDefinition'; + } + isElementBuiltIn() { + return this.isBuiltIn; + } + get coordinate() { + const parent = this._parent; + return `${parent == undefined ? '' : parent.coordinate}.${this.name}`; + } + hasArguments() { + return !!this._args && this._args.size > 0; + } + arguments() { + var _a, _b; + return (_b = (_a = this._args) === null || _a === void 0 ? void 0 : _a.values()) !== null && _b !== void 0 ? _b : []; + } + argument(name) { + var _a; + return (_a = this._args) === null || _a === void 0 ? void 0 : _a.get(name); + } + addArgument(nameOrArg, type, defaultValue) { + let toAdd; + if (typeof nameOrArg === 'string') { + this.checkUpdate(); + toAdd = new ArgumentDefinition(nameOrArg); + toAdd.defaultValue = defaultValue; + } + else { + this.checkUpdate(nameOrArg); + toAdd = nameOrArg; + } + const existing = this.argument(toAdd.name); + if (existing) { + if (type && existing.type && !(0, types_1.sameType)(type, existing.type)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Argument ${toAdd.name} already exists on field ${this.name} with a different type (${existing.type})`); + } + if (defaultValue && (!existing.defaultValue || !(0, values_1.valueEquals)(defaultValue, existing.defaultValue))) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Argument ${toAdd.name} already exists on field ${this.name} with a different default value (${(0, values_1.valueToString)(existing.defaultValue)})`); + } + return existing; + } + if (type && !isInputType(type)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid output type ${type} for argument ${toAdd.name} of ${this}: arguments should be input types.`); + } + if (!this._args) { + this._args = new utils_1.MapWithCachedArrays(); + } + this._args.set(toAdd.name, toAdd); + Element.prototype['setParent'].call(toAdd, this); + if (typeof nameOrArg === 'string') { + toAdd.type = type; + } + this.onModification(); + return toAdd; + } + ofExtension() { + return this._extension; + } + removeOfExtension() { + this._extension = undefined; + } + setOfExtension(extension) { + var _a; + this.checkUpdate(); + (0, utils_1.assert)(!extension || ((_a = this._parent) === null || _a === void 0 ? void 0 : _a.hasExtension(extension)), () => `Cannot mark field ${this.name} as part of the provided extension: it is not an extension of field parent type ${this.parent}`); + this._extension = extension; + this.onModification(); + } + isIntrospectionField() { + return (0, introspection_1.isIntrospectionName)(this.name); + } + isSchemaIntrospectionField() { + return introspection_1.introspectionFieldNames.includes(this.name); + } + removeArgumentInternal(name) { + if (this._args) { + this._args.delete(name); + } + } + removeParent() { + this._parent = undefined; + } + isDeprecated() { + return this.hasAppliedDirective('deprecated'); + } + remove() { + if (!this._parent) { + return []; + } + this.checkRemoval(); + this.onModification(); + this.sourceAST = undefined; + this.type = undefined; + this.removeAppliedDirectives(); + for (const arg of this.arguments()) { + arg.remove(); + } + FieldBasedType.prototype['removeFieldInternal'].call(this._parent, this); + this._parent = undefined; + this._extension = undefined; + return []; + } + removeRecursive() { + const parent = this._parent; + this.remove(); + if (parent && !isUnionType(parent) && parent.fields().length === 0) { + parent.removeRecursive(); + } + } + toString() { + const args = this.hasArguments() + ? '(' + this.arguments().map(arg => arg.toString()).join(', ') + ')' + : ""; + return `${this.name}${args}: ${this.type}`; + } +} +exports.FieldDefinition = FieldDefinition; +class InputFieldDefinition extends NamedSchemaElementWithType { + constructor() { + super(...arguments); + this.kind = 'InputFieldDefinition'; + } + get coordinate() { + const parent = this._parent; + return `${parent == undefined ? '' : parent.coordinate}.${this.name}`; + } + isRequired() { + return isNonNullType(this.type) && this.defaultValue === undefined; + } + ofExtension() { + return this._extension; + } + removeOfExtension() { + this._extension = undefined; + } + setOfExtension(extension) { + var _a; + this.checkUpdate(); + (0, utils_1.assert)(!extension || ((_a = this._parent) === null || _a === void 0 ? void 0 : _a.hasExtension(extension)), () => `Cannot mark field ${this.name} as part of the provided extension: it is not an extension of field parent type ${this.parent}`); + this._extension = extension; + this.onModification(); + } + isDeprecated() { + return this.hasAppliedDirective('deprecated'); + } + remove() { + if (!this._parent) { + return []; + } + this.checkRemoval(); + this.onModification(); + this.sourceAST = undefined; + this.type = undefined; + this.defaultValue = undefined; + this.removeAppliedDirectives(); + InputObjectType.prototype['removeFieldInternal'].call(this._parent, this); + this._parent = undefined; + this._extension = undefined; + return []; + } + removeRecursive() { + const parent = this._parent; + this.remove(); + if (parent && parent.fields().length === 0) { + parent.removeRecursive(); + } + } + toString() { + const defaultStr = this.defaultValue === undefined ? "" : ` = ${(0, values_1.valueToString)(this.defaultValue, this.type)}`; + return `${this.name}: ${this.type}${defaultStr}`; + } +} +exports.InputFieldDefinition = InputFieldDefinition; +class ArgumentDefinition extends NamedSchemaElementWithType { + constructor(name) { + super(name); + this.kind = 'ArgumentDefinition'; + } + get coordinate() { + const parent = this._parent; + return `${parent == undefined ? '' : parent.coordinate}(${this.name}:)`; + } + isRequired() { + return isNonNullType(this.type) && this.defaultValue === undefined; + } + isDeprecated() { + return this.hasAppliedDirective('deprecated'); + } + remove() { + if (!this._parent) { + return []; + } + this.checkRemoval(); + this.onModification(); + this.sourceAST = undefined; + this.type = undefined; + this.defaultValue = undefined; + this.removeAppliedDirectives(); + if (this._parent instanceof FieldDefinition) { + FieldDefinition.prototype['removeArgumentInternal'].call(this._parent, this.name); + } + else { + DirectiveDefinition.prototype['removeArgumentInternal'].call(this._parent, this.name); + } + this._parent = undefined; + return []; + } + toString() { + const defaultStr = this.defaultValue === undefined ? "" : ` = ${(0, values_1.valueToString)(this.defaultValue, this.type)}`; + return `${this.name}: ${this.type}${defaultStr}`; + } +} +exports.ArgumentDefinition = ArgumentDefinition; +class EnumValue extends NamedSchemaElement { + constructor() { + super(...arguments); + this.kind = 'EnumValue'; + } + get coordinate() { + const parent = this._parent; + return `${parent == undefined ? '' : parent.coordinate}.${this.name}`; + } + ofExtension() { + return this._extension; + } + removeOfExtension() { + this._extension = undefined; + } + setOfExtension(extension) { + var _a; + this.checkUpdate(); + (0, utils_1.assert)(!extension || ((_a = this._parent) === null || _a === void 0 ? void 0 : _a.hasExtension(extension)), () => `Cannot mark field ${this.name} as part of the provided extension: it is not an extension of enum value parent type ${this.parent}`); + this._extension = extension; + this.onModification(); + } + isDeprecated() { + return this.hasAppliedDirective('deprecated'); + } + remove() { + if (!this._parent) { + return []; + } + this.checkRemoval(); + this.onModification(); + this.sourceAST = undefined; + this.removeAppliedDirectives(); + EnumType.prototype['removeValueInternal'].call(this._parent, this); + this._parent = undefined; + this._extension = undefined; + return []; + } + removeTypeReference(type) { + (0, utils_1.assert)(false, `Enum value ${this} can't reference other types; shouldn't be asked to remove reference to ${type}`); + } + toString() { + return `${this.name}`; + } +} +exports.EnumValue = EnumValue; +class DirectiveDefinition extends NamedSchemaElement { + constructor(name, isBuiltIn = false) { + super(name); + this.isBuiltIn = isBuiltIn; + this.kind = 'DirectiveDefinition'; + this.repeatable = false; + this._locations = []; + } + get coordinate() { + return `@${this.name}`; + } + arguments() { + var _a, _b; + return (_b = (_a = this._args) === null || _a === void 0 ? void 0 : _a.values()) !== null && _b !== void 0 ? _b : []; + } + argument(name) { + var _a; + return (_a = this._args) === null || _a === void 0 ? void 0 : _a.get(name); + } + addArgument(nameOrArg, type, defaultValue) { + let toAdd; + if (typeof nameOrArg === 'string') { + this.checkUpdate(); + toAdd = new ArgumentDefinition(nameOrArg); + toAdd.defaultValue = defaultValue; + } + else { + this.checkUpdate(nameOrArg); + toAdd = nameOrArg; + } + if (this.argument(toAdd.name)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Argument ${toAdd.name} already exists on field ${this.name}`); + } + if (!this._args) { + this._args = new utils_1.MapWithCachedArrays(); + } + this._args.set(toAdd.name, toAdd); + Element.prototype['setParent'].call(toAdd, this); + if (typeof nameOrArg === 'string') { + toAdd.type = type; + } + this.onModification(); + return toAdd; + } + removeArgumentInternal(name) { + var _a; + (_a = this._args) === null || _a === void 0 ? void 0 : _a.delete(name); + } + get locations() { + return this._locations; + } + addLocations(...locations) { + let modified = false; + for (const location of locations) { + if (!this._locations.includes(location)) { + this._locations.push(location); + modified = true; + } + } + if (modified) { + this.onModification(); + } + return this; + } + addAllLocations() { + return this.addLocations(...Object.values(graphql_1.DirectiveLocation)); + } + addAllTypeLocations() { + return this.addLocations(graphql_1.DirectiveLocation.SCALAR, graphql_1.DirectiveLocation.OBJECT, graphql_1.DirectiveLocation.INTERFACE, graphql_1.DirectiveLocation.UNION, graphql_1.DirectiveLocation.ENUM, graphql_1.DirectiveLocation.INPUT_OBJECT); + } + removeLocations(...locations) { + let modified = false; + for (const location of locations) { + modified || (modified = (0, utils_1.removeArrayElement)(location, this._locations)); + } + if (modified) { + this.onModification(); + } + return this; + } + hasExecutableLocations() { + return this.locations.some((loc) => isExecutableDirectiveLocation(loc)); + } + hasTypeSystemLocations() { + return this.locations.some((loc) => isTypeSystemDirectiveLocation(loc)); + } + applications() { + var _a; + return (_a = this._referencers) !== null && _a !== void 0 ? _a : []; + } + addReferencer(referencer) { + (0, utils_1.assert)(referencer, 'Referencer should exists'); + if (this._referencers) { + if (!this._referencers.includes(referencer)) { + this._referencers.push(referencer); + } + } + else { + this._referencers = [referencer]; + } + } + removeReferencer(referencer) { + if (this._referencers) { + (0, utils_1.removeArrayElement)(referencer, this._referencers); + } + } + removeTypeReference(type) { + (0, utils_1.assert)(false, `Directive definition ${this} can't reference other types (it's arguments can); shouldn't be asked to remove reference to ${type}`); + } + remove() { + var _a; + if (!this._parent) { + return []; + } + this.checkRemoval(); + this.onModification(); + this.sourceAST = undefined; + (0, utils_1.assert)(!this._appliedDirectives || this._appliedDirectives.length === 0, "Directive definition should not have directive applied to it"); + for (const arg of this.arguments()) { + arg.remove(); + } + const toReturn = (_a = this._referencers) !== null && _a !== void 0 ? _a : []; + this._referencers = undefined; + Schema.prototype['removeDirectiveInternal'].call(this._parent, this); + this._parent = undefined; + return toReturn; + } + removeRecursive() { + this.remove().forEach(ref => ref.remove()); + } + toAST() { + const doc = (0, graphql_1.parse)((0, print_1.printDirectiveDefinition)(this)); + return doc.definitions[0]; + } + toString() { + return `@${this.name}`; + } +} +exports.DirectiveDefinition = DirectiveDefinition; +class Directive extends Element { + constructor(name, _args) { + super(); + this.name = name; + this._args = _args; + } + schema() { + return this.parent.schema(); + } + get definition() { + if (!this.isAttached()) { + return undefined; + } + const doc = this.schema(); + return doc.directive(this.name); + } + arguments(includeDefaultValues = false) { + if (!includeDefaultValues) { + return this._args; + } + const definition = this.definition; + (0, utils_1.assert)(definition, () => `Cannot include default values for arguments: cannot find directive definition for ${this.name}`); + const updated = Object.create(null); + for (const argDef of definition.arguments()) { + const argValue = (0, values_1.withDefaultValues)(this._args[argDef.name], argDef); + if (argValue !== undefined) { + updated[argDef.name] = argValue; + } + } + return updated; + } + onModification() { + if (this.isAttachedToSchemaElement()) { + Schema.prototype['onModification'].call(this.schema()); + } + } + isAttachedToSchemaElement() { + return this.isAttached(); + } + setArguments(args) { + this._args = args; + this.onModification(); + } + argumentType(name) { + var _a, _b; + return (_b = (_a = this.definition) === null || _a === void 0 ? void 0 : _a.argument(name)) === null || _b === void 0 ? void 0 : _b.type; + } + matchArguments(expectedArgs) { + const entries = Object.entries(this._args); + if (entries.length !== Object.keys(expectedArgs).length) { + return false; + } + for (const [key, val] of entries) { + if (!(key in expectedArgs)) { + return false; + } + const expectedVal = expectedArgs[key]; + if (!(0, values_1.valueEquals)(expectedVal, val)) { + return false; + } + } + return true; + } + ofExtension() { + return this._extension; + } + removeOfExtension() { + this._extension = undefined; + } + setOfExtension(extension) { + this.checkUpdate(); + if (extension) { + const parent = this.parent; + (0, utils_1.assert)(parent instanceof SchemaDefinition || parent instanceof BaseNamedType, 'Can only mark directive parts of extensions when directly apply to type or schema definition.'); + (0, utils_1.assert)(parent.hasExtension(extension), () => `Cannot mark directive ${this.name} as part of the provided extension: it is not an extension of parent ${parent}`); + } + this._extension = extension; + this.onModification(); + } + argumentsToAST() { + const entries = Object.entries(this._args); + if (entries.length === 0) { + return undefined; + } + const definition = this.definition; + (0, utils_1.assert)(definition, () => `Cannot convert arguments of detached directive ${this}`); + return entries.map(([n, v]) => { + return { + kind: graphql_1.Kind.ARGUMENT, + name: { kind: graphql_1.Kind.NAME, value: n }, + value: (0, values_1.valueToAST)(v, definition.argument(n).type), + }; + }); + } + remove() { + if (!this._parent) { + return false; + } + this.onModification(); + const coreFeatures = this.schema().coreFeatures; + if (coreFeatures && this.name === coreFeatures.coreItself.nameInSchema) { + const url = coreSpec_1.FeatureUrl.parse(this._args[coreFeatures.coreDefinition.urlArgName()]); + if (url.identity === coreFeatures.coreItself.url.identity) { + Schema.prototype['unmarkAsCoreSchema'].call(this.schema()); + for (const d of this.schema().schemaDefinition.appliedDirectivesOf(coreFeatures.coreItself.nameInSchema)) { + d.removeInternal(); + } + return true; + } + else { + CoreFeatures.prototype['removeFeature'].call(coreFeatures, url.identity); + } + } + return this.removeInternal(); + } + removeInternal() { + if (!this._parent) { + return false; + } + const definition = this.definition; + if (definition && this.isAttachedToSchemaElement()) { + DirectiveDefinition.prototype['removeReferencer'].call(definition, this); + } + const parentDirectives = this._parent.appliedDirectives; + const removed = (0, utils_1.removeArrayElement)(this, parentDirectives); + (0, utils_1.assert)(removed, () => `Directive ${this} lists ${this._parent} as parent, but that parent doesn't list it as applied directive`); + this._parent = undefined; + this._extension = undefined; + return true; + } + toString() { + const entries = Object.entries(this._args).filter(([_, v]) => v !== undefined); + const args = entries.length == 0 ? '' : '(' + entries.map(([n, v]) => `${n}: ${(0, values_1.valueToString)(v, this.argumentType(n))}`).join(', ') + ')'; + return `@${this.name}${args}`; + } +} +exports.Directive = Directive; +function sameDirectiveApplication(application1, application2, directivesNeverEqualToThemselves = ['defer']) { + return application1.name === application2.name + && !directivesNeverEqualToThemselves.includes(application1.name) + && !directivesNeverEqualToThemselves.includes(application2.name) + && (0, values_1.argumentsEquals)(application1.arguments(), application2.arguments()); +} +exports.sameDirectiveApplication = sameDirectiveApplication; +function sameDirectiveApplications(applications1, applications2, directivesNeverEqualToThemselves = ['defer']) { + if (applications1.length !== applications2.length) { + return false; + } + for (const directive1 of applications1) { + if (!applications2.some(directive2 => sameDirectiveApplication(directive1, directive2, directivesNeverEqualToThemselves))) { + return false; + } + } + return true; +} +exports.sameDirectiveApplications = sameDirectiveApplications; +function isDirectiveApplicationsSubset(applications, maybeSubset) { + if (maybeSubset.length > applications.length) { + return false; + } + for (const directive1 of maybeSubset) { + if (!applications.some(directive2 => sameDirectiveApplication(directive1, directive2))) { + return false; + } + } + return true; +} +exports.isDirectiveApplicationsSubset = isDirectiveApplicationsSubset; +function directiveApplicationsSubstraction(baseApplications, toRemove) { + return baseApplications.filter((application) => !toRemove.some((other) => sameDirectiveApplication(application, other))); +} +exports.directiveApplicationsSubstraction = directiveApplicationsSubstraction; +class Variable { + constructor(name) { + this.name = name; + } + toVariableNode() { + return { + kind: graphql_1.Kind.VARIABLE, + name: { kind: graphql_1.Kind.NAME, value: this.name }, + }; + } + toString() { + return '$' + this.name; + } +} +exports.Variable = Variable; +function mergeVariables(v1s, v2s) { + if (v1s.length == 0) { + return v2s; + } + if (v2s.length == 0) { + return v1s; + } + const res = v1s.concat(); + for (const v of v2s) { + if (!containsVariable(v1s, v)) { + res.push(v); + } + } + return res; +} +exports.mergeVariables = mergeVariables; +function containsVariable(variables, toCheck) { + return variables.some(v => v.name == toCheck.name); +} +exports.containsVariable = containsVariable; +function isVariable(v) { + return v instanceof Variable; +} +exports.isVariable = isVariable; +function variablesInArguments(args) { + let variables = []; + for (const value of Object.values(args)) { + variables = mergeVariables(variables, (0, values_1.variablesInValue)(value)); + } + return variables; +} +exports.variablesInArguments = variablesInArguments; +class VariableDefinition extends DirectiveTargetElement { + constructor(schema, variable, type, defaultValue) { + super(schema); + this.variable = variable; + this.type = type; + this.defaultValue = defaultValue; + } + toVariableDefinitionNode() { + const ast = (0, values_1.valueToAST)(this.defaultValue, this.type); + return { + kind: graphql_1.Kind.VARIABLE_DEFINITION, + variable: this.variable.toVariableNode(), + type: typeToAST(this.type), + defaultValue: (ast !== undefined) ? (0, values_1.valueNodeToConstValueNode)(ast) : undefined, + directives: this.appliedDirectivesToDirectiveNodes(), + }; + } + toString() { + let base = this.variable + ': ' + this.type; + if (this.defaultValue) { + base = base + ' = ' + (0, values_1.valueToString)(this.defaultValue, this.type); + } + return base + this.appliedDirectivesToString(); + } +} +exports.VariableDefinition = VariableDefinition; +class VariableDefinitions { + constructor() { + this._definitions = new utils_1.MapWithCachedArrays(); + } + add(definition) { + if (this._definitions.has(definition.variable.name)) { + return false; + } + this._definitions.set(definition.variable.name, definition); + return true; + } + addAll(definitions) { + for (const definition of definitions._definitions.values()) { + this.add(definition); + } + } + definition(variable) { + const varName = typeof variable === 'string' ? variable : variable.name; + return this._definitions.get(varName); + } + isEmpty() { + return this._definitions.size === 0; + } + definitions() { + return this._definitions.values(); + } + filter(variables) { + if (variables.length === 0) { + return new VariableDefinitions(); + } + const newDefs = new VariableDefinitions(); + for (const variable of variables) { + const def = this.definition(variable); + if (!def) { + throw new Error(`Cannot find variable ${variable} in definitions ${this}`); + } + newDefs.add(def); + } + return newDefs; + } + toVariableDefinitionNodes() { + if (this._definitions.size === 0) { + return undefined; + } + return this.definitions().map(def => def.toVariableDefinitionNode()); + } + toString() { + return '(' + this.definitions().join(', ') + ')'; + } +} +exports.VariableDefinitions = VariableDefinitions; +function variableDefinitionsFromAST(schema, definitionNodes) { + const definitions = new VariableDefinitions(); + for (const definitionNode of definitionNodes) { + if (!definitions.add(variableDefinitionFromAST(schema, definitionNode))) { + const name = definitionNode.variable.name.value; + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Duplicate definition for variable ${name}`, { nodes: definitionNodes.filter(n => n.variable.name.value === name) }); + } + } + return definitions; +} +exports.variableDefinitionsFromAST = variableDefinitionsFromAST; +function variableDefinitionFromAST(schema, definitionNode) { + const variable = new Variable(definitionNode.variable.name.value); + const type = typeFromAST(schema, definitionNode.type); + if (!isInputType(type)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid type "${type}" for variable $${variable}: not an input type`, { nodes: definitionNode.type }); + } + const def = new VariableDefinition(schema, variable, type, definitionNode.defaultValue ? (0, values_1.valueFromAST)(definitionNode.defaultValue, type) : undefined); + return def; +} +exports.variableDefinitionFromAST = variableDefinitionFromAST; +function addReferenceToType(referencer, type) { + switch (type.kind) { + case 'ListType': + addReferenceToType(referencer, type.baseType()); + break; + case 'NonNullType': + addReferenceToType(referencer, type.baseType()); + break; + default: + BaseNamedType.prototype['addReferencer'].call(type, referencer); + break; + } +} +function removeReferenceToType(referencer, type) { + switch (type.kind) { + case 'ListType': + removeReferenceToType(referencer, type.baseType()); + break; + case 'NonNullType': + removeReferenceToType(referencer, type.baseType()); + break; + default: + BaseNamedType.prototype['removeReferencer'].call(type, referencer); + break; + } +} +function newNamedType(kind, name) { + switch (kind) { + case 'ScalarType': + return new ScalarType(name); + case 'ObjectType': + return new ObjectType(name); + case 'InterfaceType': + return new InterfaceType(name); + case 'UnionType': + return new UnionType(name); + case 'EnumType': + return new EnumType(name); + case 'InputObjectType': + return new InputObjectType(name); + default: + (0, utils_1.assert)(false, `Unhandled kind ${kind} for type ${name}`); + } +} +exports.newNamedType = newNamedType; +function* typesToCopy(source, dest) { + var _a; + for (const type of source.builtInTypes()) { + if (!type.isIntrospectionType() && !((_a = dest.type(type.name)) === null || _a === void 0 ? void 0 : _a.isBuiltIn)) { + yield type; + } + } + yield* source.types(); +} +function* directivesToCopy(source, dest) { + var _a; + for (const directive of source.builtInDirectives()) { + if (!((_a = dest.directive(directive.name)) === null || _a === void 0 ? void 0 : _a.isBuiltIn)) { + yield directive; + } + } + yield* source.directives(); +} +function copyDirectiveDefinitionToSchema({ definition, schema, copyDirectiveApplicationsInArguments = true, locationFilter, }) { + copyDirectiveDefinitionInner(definition, schema.addDirectiveDefinition(definition.name), copyDirectiveApplicationsInArguments, locationFilter); +} +exports.copyDirectiveDefinitionToSchema = copyDirectiveDefinitionToSchema; +function copy(source, dest) { + for (const type of typesToCopy(source, dest)) { + dest.addType(newNamedType(type.kind, type.name)); + } + for (const directive of directivesToCopy(source, dest)) { + dest.addDirectiveDefinition(directive.name); + } + for (const directive of directivesToCopy(source, dest)) { + copyDirectiveDefinitionInner(directive, dest.directive(directive.name)); + } + copySchemaDefinitionInner(source.schemaDefinition, dest.schemaDefinition); + for (const type of typesToCopy(source, dest)) { + copyNamedTypeInner(type, dest.type(type.name)); + } +} +function copyExtensions(source, dest) { + const extensionMap = new Map(); + for (const sourceExtension of source.extensions()) { + const destExtension = new Extension(); + dest.addExtension(destExtension); + extensionMap.set(sourceExtension, destExtension); + } + return extensionMap; +} +function copyOfExtension(extensionsMap, source, dest) { + const toCopy = source.ofExtension(); + if (toCopy) { + dest.setOfExtension(extensionsMap.get(toCopy)); + } +} +function copySchemaDefinitionInner(source, dest) { + dest.preserveEmptyDefinition = source.preserveEmptyDefinition; + const extensionsMap = copyExtensions(source, dest); + for (const rootType of source.roots()) { + copyOfExtension(extensionsMap, rootType, dest.setRoot(rootType.rootKind, rootType.type.name)); + } + for (const directive of source.appliedDirectives) { + copyOfExtension(extensionsMap, directive, copyAppliedDirective(directive, dest)); + } + dest.description = source.description; + dest.sourceAST = source.sourceAST; +} +function copyNamedTypeInner(source, dest) { + dest.preserveEmptyDefinition = source.preserveEmptyDefinition; + const extensionsMap = copyExtensions(source, dest); + for (const directive of source.appliedDirectives) { + copyOfExtension(extensionsMap, directive, copyAppliedDirective(directive, dest)); + } + dest.description = source.description; + dest.sourceAST = source.sourceAST; + switch (source.kind) { + case 'ObjectType': + case 'InterfaceType': + const destFieldBasedType = dest; + for (const sourceField of source.fields()) { + const destField = destFieldBasedType.addField(new FieldDefinition(sourceField.name)); + copyOfExtension(extensionsMap, sourceField, destField); + copyFieldDefinitionInner(sourceField, destField); + } + for (const sourceImpl of source.interfaceImplementations()) { + const destImpl = destFieldBasedType.addImplementedInterface(sourceImpl.interface.name); + copyOfExtension(extensionsMap, sourceImpl, destImpl); + } + break; + case 'UnionType': + const destUnionType = dest; + for (const sourceType of source.members()) { + const destType = destUnionType.addType(sourceType.type.name); + copyOfExtension(extensionsMap, sourceType, destType); + } + break; + case 'EnumType': + const destEnumType = dest; + for (const sourceValue of source.values) { + const destValue = destEnumType.addValue(sourceValue.name); + destValue.description = sourceValue.description; + copyOfExtension(extensionsMap, sourceValue, destValue); + copyAppliedDirectives(sourceValue, destValue); + } + break; + case 'InputObjectType': + const destInputType = dest; + for (const sourceField of source.fields()) { + const destField = destInputType.addField(new InputFieldDefinition(sourceField.name)); + copyOfExtension(extensionsMap, sourceField, destField); + copyInputFieldDefinitionInner(sourceField, destField); + } + } +} +function copyAppliedDirectives(source, dest) { + source.appliedDirectives.forEach((d) => copyAppliedDirective(d, dest)); +} +function copyAppliedDirective(source, dest) { + const res = dest.applyDirective(source.name, { ...source.arguments() }); + res.sourceAST = source.sourceAST; + return res; +} +function copyFieldDefinitionInner(source, dest) { + const type = copyWrapperTypeOrTypeRef(source.type, dest.schema()); + dest.type = type; + for (const arg of source.arguments()) { + const argType = copyWrapperTypeOrTypeRef(arg.type, dest.schema()); + copyArgumentDefinitionInner(arg, dest.addArgument(arg.name, argType)); + } + copyAppliedDirectives(source, dest); + dest.description = source.description; + dest.sourceAST = source.sourceAST; +} +function copyInputFieldDefinitionInner(source, dest) { + const type = copyWrapperTypeOrTypeRef(source.type, dest.schema()); + dest.type = type; + dest.defaultValue = source.defaultValue; + copyAppliedDirectives(source, dest); + dest.description = source.description; + dest.sourceAST = source.sourceAST; +} +function copyWrapperTypeOrTypeRef(source, destParent) { + if (!source) { + return undefined; + } + switch (source.kind) { + case 'ListType': + return new ListType(copyWrapperTypeOrTypeRef(source.ofType, destParent)); + case 'NonNullType': + return new NonNullType(copyWrapperTypeOrTypeRef(source.ofType, destParent)); + default: + return destParent.type(source.name); + } +} +function copyArgumentDefinitionInner(source, dest, copyDirectiveApplications = true) { + const type = copyWrapperTypeOrTypeRef(source.type, dest.schema()); + dest.type = type; + dest.defaultValue = source.defaultValue; + if (copyDirectiveApplications) { + copyAppliedDirectives(source, dest); + } + dest.description = source.description; + dest.sourceAST = source.sourceAST; +} +function copyDirectiveDefinitionInner(source, dest, copyDirectiveApplicationsInArguments = true, locationFilter) { + let locations = source.locations; + if (locationFilter) { + locations = locations.filter((loc) => locationFilter(loc)); + } + if (locations.length === 0) { + return; + } + for (const arg of source.arguments()) { + const type = copyWrapperTypeOrTypeRef(arg.type, dest.schema()); + copyArgumentDefinitionInner(arg, dest.addArgument(arg.name, type), copyDirectiveApplicationsInArguments); + } + dest.repeatable = source.repeatable; + dest.addLocations(...locations); + dest.sourceAST = source.sourceAST; + dest.description = source.description; +} +//# sourceMappingURL=definitions.js.map + +/***/ }), + +/***/ 3208: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.createEnumTypeSpecification = exports.createUnionTypeSpecification = exports.createObjectTypeSpecification = exports.createScalarTypeSpecification = exports.createDirectiveSpecification = void 0; +const definitions_1 = __webpack_require__(4177); +const error_1 = __webpack_require__(8116); +const values_1 = __webpack_require__(3421); +const types_1 = __webpack_require__(5811); +const utils_1 = __webpack_require__(9724); +function createDirectiveSpecification({ name, locations, repeatable = false, argumentFct = undefined, }) { + return { + name, + checkOrAdd: (schema, nameInSchema, asBuiltIn) => { + const actualName = nameInSchema !== null && nameInSchema !== void 0 ? nameInSchema : name; + const { args, errors } = argumentFct ? argumentFct(schema, actualName) : { args: [], errors: [] }; + if (errors.length > 0) { + return errors; + } + const existing = schema.directive(actualName); + if (existing) { + return ensureSameDirectiveStructure({ name: actualName, locations, repeatable, args }, existing); + } + else { + const directive = schema.addDirectiveDefinition(new definitions_1.DirectiveDefinition(actualName, asBuiltIn)); + directive.repeatable = repeatable; + directive.addLocations(...locations); + for (const { name, type, defaultValue } of args) { + directive.addArgument(name, type, defaultValue); + } + return []; + } + }, + }; +} +exports.createDirectiveSpecification = createDirectiveSpecification; +function createScalarTypeSpecification({ name }) { + return { + name, + checkOrAdd: (schema, nameInSchema, asBuiltIn) => { + const actualName = nameInSchema !== null && nameInSchema !== void 0 ? nameInSchema : name; + const existing = schema.type(actualName); + if (existing) { + return ensureSameTypeKind('ScalarType', existing); + } + else { + schema.addType(new definitions_1.ScalarType(actualName, asBuiltIn)); + return []; + } + }, + }; +} +exports.createScalarTypeSpecification = createScalarTypeSpecification; +function createObjectTypeSpecification({ name, fieldsFct, }) { + return { + name, + checkOrAdd: (schema, nameInSchema, asBuiltIn) => { + const actualName = nameInSchema !== null && nameInSchema !== void 0 ? nameInSchema : name; + const expectedFields = fieldsFct(schema); + const existing = schema.type(actualName); + if (existing) { + let errors = ensureSameTypeKind('ObjectType', existing); + if (errors.length > 0) { + return errors; + } + (0, utils_1.assert)((0, definitions_1.isObjectType)(existing), 'Should be an object type'); + for (const { name, type, args } of expectedFields) { + const existingField = existing.field(name); + if (!existingField) { + errors = errors.concat(error_1.ERRORS.TYPE_DEFINITION_INVALID.err(`Invalid definition of type ${name}: missing field ${name}`, { nodes: existing.sourceAST })); + continue; + } + let existingType = existingField.type; + if (!(0, definitions_1.isNonNullType)(type) && (0, definitions_1.isNonNullType)(existingType)) { + existingType = existingType.ofType; + } + if (!(0, types_1.sameType)(type, existingType)) { + errors = errors.concat(error_1.ERRORS.TYPE_DEFINITION_INVALID.err(`Invalid definition for field ${name} of type ${name}: should have type ${type} but found type ${existingField.type}`, { nodes: existingField.sourceAST })); + } + errors = errors.concat(ensureSameArguments({ name, args }, existingField, `field "${existingField.coordinate}"`)); + } + return errors; + } + else { + const createdType = schema.addType(new definitions_1.ObjectType(actualName, asBuiltIn)); + for (const { name, type, args } of expectedFields) { + const field = createdType.addField(name, type); + for (const { name: argName, type: argType, defaultValue } of args !== null && args !== void 0 ? args : []) { + field.addArgument(argName, argType, defaultValue); + } + } + return []; + } + }, + }; +} +exports.createObjectTypeSpecification = createObjectTypeSpecification; +function createUnionTypeSpecification({ name, membersFct, }) { + return { + name, + checkOrAdd: (schema, nameInSchema, asBuiltIn) => { + const actualName = nameInSchema !== null && nameInSchema !== void 0 ? nameInSchema : name; + const existing = schema.type(actualName); + const expectedMembers = membersFct(schema).sort((n1, n2) => n1.localeCompare(n2)); + if (expectedMembers.length === 0) { + if (existing) { + return [error_1.ERRORS.TYPE_DEFINITION_INVALID.err(`Invalid definition of type ${name}: expected the union type to not exist/have no members but it is defined.`, { nodes: existing.sourceAST })]; + } + return []; + } + if (existing) { + let errors = ensureSameTypeKind('UnionType', existing); + if (errors.length > 0) { + return errors; + } + (0, utils_1.assert)((0, definitions_1.isUnionType)(existing), 'Should be an union type'); + const actualMembers = existing.members().map(m => m.type.name).sort((n1, n2) => n1.localeCompare(n2)); + if (!(0, utils_1.arrayEquals)(expectedMembers, actualMembers)) { + errors = errors.concat(error_1.ERRORS.TYPE_DEFINITION_INVALID.err(`Invalid definition of type ${name}: expected members [${expectedMembers}] but found [${actualMembers}].`, { nodes: existing.sourceAST })); + } + return errors; + } + else { + const type = schema.addType(new definitions_1.UnionType(actualName, asBuiltIn)); + for (const member of expectedMembers) { + type.addType(member); + } + return []; + } + }, + }; +} +exports.createUnionTypeSpecification = createUnionTypeSpecification; +function createEnumTypeSpecification({ name, values, }) { + return { + name, + checkOrAdd: (schema, nameInSchema, asBuiltIn) => { + const actualName = nameInSchema !== null && nameInSchema !== void 0 ? nameInSchema : name; + const existing = schema.type(actualName); + const expectedValueNames = values.map((v) => v.name).sort((n1, n2) => n1.localeCompare(n2)); + if (existing) { + let errors = ensureSameTypeKind('EnumType', existing); + if (errors.length > 0) { + return errors; + } + (0, utils_1.assert)((0, definitions_1.isEnumType)(existing), 'Should be an enum type'); + const actualValueNames = existing.values.map(v => v.name).sort((n1, n2) => n1.localeCompare(n2)); + if (!(0, utils_1.arrayEquals)(expectedValueNames, actualValueNames)) { + errors = errors.concat(error_1.ERRORS.TYPE_DEFINITION_INVALID.err(`Invalid definition for type "${name}": expected values [${expectedValueNames.join(', ')}] but found [${actualValueNames.join(', ')}].`, { nodes: existing.sourceAST })); + } + return errors; + } + else { + const type = schema.addType(new definitions_1.EnumType(actualName, asBuiltIn)); + for (const { name, description } of values) { + type.addValue(name).description = description; + } + return []; + } + }, + }; +} +exports.createEnumTypeSpecification = createEnumTypeSpecification; +function ensureSameTypeKind(expected, actual) { + return expected === actual.kind + ? [] + : [ + error_1.ERRORS.TYPE_DEFINITION_INVALID.err(`Invalid definition for type ${actual.name}: ${actual.name} should be a ${expected} but is defined as a ${actual.kind}`, { nodes: actual.sourceAST }) + ]; +} +function ensureSameDirectiveStructure(expected, actual) { + const directiveName = `"@${expected.name}"`; + let errors = ensureSameArguments(expected, actual, `directive ${directiveName}`); + if (!expected.repeatable && actual.repeatable) { + errors = errors.concat(error_1.ERRORS.DIRECTIVE_DEFINITION_INVALID.err(`Invalid definition for directive ${directiveName}: ${directiveName} should${expected.repeatable ? "" : " not"} be repeatable`, { nodes: actual.sourceAST })); + } + if (!actual.locations.every(loc => expected.locations.includes(loc))) { + errors = errors.concat(error_1.ERRORS.DIRECTIVE_DEFINITION_INVALID.err(`Invalid definition for directive ${directiveName}: ${directiveName} should have locations ${expected.locations.join(', ')}, but found (non-subset) ${actual.locations.join(', ')}`, { nodes: actual.sourceAST })); + } + return errors; +} +function ensureSameArguments(expected, actual, what, containerSourceAST) { + var _a; + const expectedArguments = (_a = expected.args) !== null && _a !== void 0 ? _a : []; + const errors = []; + for (const { name, type, defaultValue } of expectedArguments) { + const actualArgument = actual.argument(name); + if (!actualArgument) { + if ((0, definitions_1.isNonNullType)(type) && defaultValue === undefined) { + errors.push(error_1.ERRORS.DIRECTIVE_DEFINITION_INVALID.err(`Invalid definition for ${what}: missing required argument "${name}"`, { nodes: containerSourceAST })); + } + continue; + } + let actualType = actualArgument.type; + if ((0, definitions_1.isNonNullType)(actualType) && !(0, definitions_1.isNonNullType)(type)) { + actualType = actualType.ofType; + } + if (!(0, types_1.sameType)(type, actualType) && !isValidInputTypeRedefinition(type, actualType)) { + errors.push(error_1.ERRORS.DIRECTIVE_DEFINITION_INVALID.err(`Invalid definition for ${what}: argument "${name}" should have type "${type}" but found type "${actualArgument.type}"`, { nodes: actualArgument.sourceAST })); + } + else if (!(0, definitions_1.isNonNullType)(actualArgument.type) && !(0, values_1.valueEquals)(defaultValue, actualArgument.defaultValue)) { + errors.push(error_1.ERRORS.DIRECTIVE_DEFINITION_INVALID.err(`Invalid definition for ${what}: argument "${name}" should have default value ${(0, values_1.valueToString)(defaultValue)} but found default value ${(0, values_1.valueToString)(actualArgument.defaultValue)}`, { nodes: actualArgument.sourceAST })); + } + } + for (const actualArgument of actual.arguments()) { + if (!expectedArguments.some((arg) => arg.name === actualArgument.name)) { + errors.push(error_1.ERRORS.DIRECTIVE_DEFINITION_INVALID.err(`Invalid definition for ${what}: unknown/unsupported argument "${actualArgument.name}"`, { nodes: actualArgument.sourceAST })); + } + } + return errors; +} +function isValidInputTypeRedefinition(expectedType, actualType) { + if ((0, definitions_1.isListType)(expectedType)) { + return (0, definitions_1.isListType)(actualType) && isValidInputTypeRedefinition(expectedType.ofType, actualType.ofType); + } + if ((0, definitions_1.isNonNullType)(expectedType)) { + return (0, definitions_1.isNonNullType)(actualType) && isValidInputTypeRedefinition(expectedType.ofType, actualType.ofType); + } + return (0, definitions_1.isCustomScalarType)(expectedType) && !(0, definitions_1.isCustomScalarType)(actualType); +} +//# sourceMappingURL=directiveAndTypeSpecification.js.map + +/***/ }), + +/***/ 8116: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.REMOVED_ERRORS = exports.ERRORS = exports.ERROR_CATEGORIES = exports.withModifiedErrorNodes = exports.withModifiedErrorMessage = exports.errorCodeDef = exports.errorCode = exports.printErrors = exports.printGraphQLErrorsOrRethrow = exports.errorCauses = exports.aggregateError = exports.extractGraphQLErrorOptions = void 0; +const graphql_1 = __webpack_require__(8929); +const utils_1 = __webpack_require__(9724); +const FED1_CODE = '0.x'; +const makeCodeDefinition = (code, description, metadata = DEFAULT_METADATA) => ({ + code, + description, + metadata, + err: (message, options) => new graphql_1.GraphQLError(message, { + ...options, + extensions: { + ...options === null || options === void 0 ? void 0 : options.extensions, + code, + } + }), +}); +function extractGraphQLErrorOptions(e) { + return { + nodes: e.nodes, + source: e.source, + positions: e.positions, + path: e.path, + originalError: e.originalError, + extensions: e.extensions, + }; +} +exports.extractGraphQLErrorOptions = extractGraphQLErrorOptions; +class AggregateGraphQLError extends graphql_1.GraphQLError { + constructor(code, message, causes, options) { + super(message + '. Caused by:\n' + causes.map((c) => c.toString()).join('\n\n'), { + ...options, + extensions: { code }, + }); + this.causes = causes; + } + toString() { + let output = `[${this.extensions.code}] ${super.toString()}`; + output += "\ncaused by:"; + for (const cause of this.causes) { + output += "\n\n - "; + output += cause.toString().split("\n").join("\n "); + } + return output; + } +} +function aggregateError(code, message, causes) { + return new AggregateGraphQLError(code, message, causes); +} +exports.aggregateError = aggregateError; +function errorCauses(e) { + if (e instanceof AggregateGraphQLError) { + return e.causes; + } + if (e instanceof graphql_1.GraphQLError) { + return [e]; + } + return undefined; +} +exports.errorCauses = errorCauses; +function printGraphQLErrorsOrRethrow(e) { + const causes = errorCauses(e); + if (!causes) { + throw e; + } + return causes.map(e => e.toString()).join('\n\n'); +} +exports.printGraphQLErrorsOrRethrow = printGraphQLErrorsOrRethrow; +function printErrors(errors) { + return errors.map(e => e.toString()).join('\n\n'); +} +exports.printErrors = printErrors; +const DEFAULT_METADATA = { addedIn: '2.0.0' }; +const makeErrorCodeCategory = (extractCode, makeDescription, metadata = DEFAULT_METADATA) => ({ + createCode: (element) => { + return makeCodeDefinition(extractCode(element), makeDescription(element), metadata); + }, + get: (element) => { + const def = codeDefByCode[extractCode(element)]; + (0, utils_1.assert)(def, `Unexpected element: ${element}`); + return def; + } +}); +const makeFederationDirectiveErrorCodeCategory = (codeSuffix, makeDescription, metadata = DEFAULT_METADATA) => makeErrorCodeCategory((directive) => `${directive.toLocaleUpperCase()}_${codeSuffix}`, makeDescription, metadata); +function errorCode(e) { + if (!e.extensions || !('code' in e.extensions)) { + return undefined; + } + return e.extensions.code; +} +exports.errorCode = errorCode; +function errorCodeDef(e) { + const code = typeof e === 'string' ? e : errorCode(e); + return code ? codeDefByCode[code] : undefined; +} +exports.errorCodeDef = errorCodeDef; +function withModifiedErrorMessage(e, newMessage) { + return new graphql_1.GraphQLError(newMessage, { + nodes: e.nodes, + source: e.source, + positions: e.positions, + path: e.path, + originalError: e.originalError, + extensions: e.extensions + }); +} +exports.withModifiedErrorMessage = withModifiedErrorMessage; +function withModifiedErrorNodes(e, newNodes) { + return new graphql_1.GraphQLError(e.message, { + nodes: newNodes, + source: e.source, + positions: e.positions, + path: e.path, + originalError: e.originalError, + extensions: e.extensions + }); +} +exports.withModifiedErrorNodes = withModifiedErrorNodes; +const INVALID_GRAPHQL = makeCodeDefinition('INVALID_GRAPHQL', 'A schema is invalid GraphQL: it violates one of the rule of the specification.'); +const DIRECTIVE_DEFINITION_INVALID = makeCodeDefinition('DIRECTIVE_DEFINITION_INVALID', 'A built-in or federation directive has an invalid definition in the schema.', { ...DEFAULT_METADATA, replaces: ['TAG_DEFINITION_INVALID'] }); +const TYPE_DEFINITION_INVALID = makeCodeDefinition('TYPE_DEFINITION_INVALID', 'A built-in or federation type has an invalid definition in the schema.'); +const UNSUPPORTED_LINKED_FEATURE = makeCodeDefinition('UNSUPPORTED_LINKED_FEATURE', 'Indicates that a feature used in a @link is either unsupported or is used with unsupported options.'); +const UNKNOWN_FEDERATION_LINK_VERSION = makeCodeDefinition('UNKNOWN_FEDERATION_LINK_VERSION', 'The version of federation in a @link directive on the schema is unknown.'); +const UNKNOWN_LINK_VERSION = makeCodeDefinition('UNKNOWN_LINK_VERSION', 'The version of @link set on the schema is unknown.', { addedIn: '2.1.0' }); +const FIELDS_HAS_ARGS = makeFederationDirectiveErrorCodeCategory('FIELDS_HAS_ARGS', (directive) => `The \`fields\` argument of a \`@${directive}\` directive includes a field defined with arguments (which is not currently supported).`); +const KEY_FIELDS_HAS_ARGS = FIELDS_HAS_ARGS.createCode('key'); +const PROVIDES_FIELDS_HAS_ARGS = FIELDS_HAS_ARGS.createCode('provides'); +const DIRECTIVE_FIELDS_MISSING_EXTERNAL = makeFederationDirectiveErrorCodeCategory('FIELDS_MISSING_EXTERNAL', (directive) => `The \`fields\` argument of a \`@${directive}\` directive includes a field that is not marked as \`@external\`.`, { addedIn: FED1_CODE }); +const PROVIDES_MISSING_EXTERNAL = DIRECTIVE_FIELDS_MISSING_EXTERNAL.createCode('provides'); +const REQUIRES_MISSING_EXTERNAL = DIRECTIVE_FIELDS_MISSING_EXTERNAL.createCode('requires'); +const DIRECTIVE_UNSUPPORTED_ON_INTERFACE = makeFederationDirectiveErrorCodeCategory('UNSUPPORTED_ON_INTERFACE', (directive) => `A \`@${directive}\` directive is used on an interface, which is not (yet) supported.`); +const KEY_UNSUPPORTED_ON_INTERFACE = DIRECTIVE_UNSUPPORTED_ON_INTERFACE.createCode('key'); +const PROVIDES_UNSUPPORTED_ON_INTERFACE = DIRECTIVE_UNSUPPORTED_ON_INTERFACE.createCode('provides'); +const REQUIRES_UNSUPPORTED_ON_INTERFACE = DIRECTIVE_UNSUPPORTED_ON_INTERFACE.createCode('requires'); +const DIRECTIVE_IN_FIELDS_ARG = makeFederationDirectiveErrorCodeCategory('DIRECTIVE_IN_FIELDS_ARG', (directive) => `The \`fields\` argument of a \`@${directive}\` directive includes some directive applications. This is not supported`, { addedIn: '2.1.0' }); +const KEY_HAS_DIRECTIVE_IN_FIELDS_ARGS = DIRECTIVE_IN_FIELDS_ARG.createCode('key'); +const PROVIDES_HAS_DIRECTIVE_IN_FIELDS_ARGS = DIRECTIVE_IN_FIELDS_ARG.createCode('provides'); +const REQUIRES_HAS_DIRECTIVE_IN_FIELDS_ARGS = DIRECTIVE_IN_FIELDS_ARG.createCode('requires'); +const EXTERNAL_UNUSED = makeCodeDefinition('EXTERNAL_UNUSED', 'An `@external` field is not being used by any instance of `@key`, `@requires`, `@provides` or to satisfy an interface implementation.', { addedIn: FED1_CODE }); +const TYPE_WITH_ONLY_UNUSED_EXTERNAL = makeCodeDefinition('TYPE_WITH_ONLY_UNUSED_EXTERNAL', 'A federation 1 schema has a composite type comprised only of unused external fields.' + + ` Note that this error can _only_ be raised for federation 1 schema as federation 2 schema do not allow unused external fields (and errors with code ${EXTERNAL_UNUSED.code} will be raised in that case).` + + ' But when federation 1 schema are automatically migrated to federation 2 ones, unused external fields are automatically removed, and in rare case this can leave a type empty. If that happens, an error with this code will be raised'); +const PROVIDES_ON_NON_OBJECT_FIELD = makeCodeDefinition('PROVIDES_ON_NON_OBJECT_FIELD', 'A `@provides` directive is used to mark a field whose base type is not an object type.'); +const DIRECTIVE_INVALID_FIELDS_TYPE = makeFederationDirectiveErrorCodeCategory('INVALID_FIELDS_TYPE', (directive) => `The value passed to the \`fields\` argument of a \`@${directive}\` directive is not a string.`); +const KEY_INVALID_FIELDS_TYPE = DIRECTIVE_INVALID_FIELDS_TYPE.createCode('key'); +const PROVIDES_INVALID_FIELDS_TYPE = DIRECTIVE_INVALID_FIELDS_TYPE.createCode('provides'); +const REQUIRES_INVALID_FIELDS_TYPE = DIRECTIVE_INVALID_FIELDS_TYPE.createCode('requires'); +const DIRECTIVE_INVALID_FIELDS = makeFederationDirectiveErrorCodeCategory('INVALID_FIELDS', (directive) => `The \`fields\` argument of a \`@${directive}\` directive is invalid (it has invalid syntax, includes unknown fields, ...).`); +const KEY_INVALID_FIELDS = DIRECTIVE_INVALID_FIELDS.createCode('key'); +const PROVIDES_INVALID_FIELDS = DIRECTIVE_INVALID_FIELDS.createCode('provides'); +const REQUIRES_INVALID_FIELDS = DIRECTIVE_INVALID_FIELDS.createCode('requires'); +const KEY_FIELDS_SELECT_INVALID_TYPE = makeCodeDefinition('KEY_FIELDS_SELECT_INVALID_TYPE', 'The `fields` argument of `@key` directive includes a field whose type is a list, interface, or union type. Fields of these types cannot be part of a `@key`', { addedIn: FED1_CODE }); +const ROOT_TYPE_USED = makeErrorCodeCategory((kind) => `ROOT_${kind.toLocaleUpperCase()}_USED`, (kind) => `A subgraph's schema defines a type with the name \`${kind}\`, while also specifying a _different_ type name as the root query object. This is not allowed.`, { addedIn: FED1_CODE }); +const ROOT_QUERY_USED = ROOT_TYPE_USED.createCode('query'); +const ROOT_MUTATION_USED = ROOT_TYPE_USED.createCode('mutation'); +const ROOT_SUBSCRIPTION_USED = ROOT_TYPE_USED.createCode('subscription'); +const INVALID_SUBGRAPH_NAME = makeCodeDefinition('INVALID_SUBGRAPH_NAME', 'A subgraph name is invalid (subgraph names cannot be a single underscore ("_")).'); +const NO_QUERIES = makeCodeDefinition('NO_QUERIES', 'None of the composed subgraphs expose any query.'); +const INTERFACE_FIELD_NO_IMPLEM = makeCodeDefinition('INTERFACE_FIELD_NO_IMPLEM', 'After subgraph merging, an implementation is missing a field of one of the interface it implements (which can happen for valid subgraphs).'); +const TYPE_KIND_MISMATCH = makeCodeDefinition('TYPE_KIND_MISMATCH', 'A type has the same name in different subgraphs, but a different kind. For instance, one definition is an object type but another is an interface.', { ...DEFAULT_METADATA, replaces: ['VALUE_TYPE_KIND_MISMATCH', 'EXTENSION_OF_WRONG_KIND', 'ENUM_MISMATCH_TYPE'] }); +const EXTERNAL_TYPE_MISMATCH = makeCodeDefinition('EXTERNAL_TYPE_MISMATCH', 'An `@external` field has a type that is incompatible with the declaration(s) of that field in other subgraphs.', { addedIn: FED1_CODE }); +const EXTERNAL_COLLISION_WITH_ANOTHER_DIRECTIVE = makeCodeDefinition('EXTERNAL_COLLISION_WITH_ANOTHER_DIRECTIVE', 'The @external directive collides with other directives in some situations.', { addedIn: '2.1.0' }); +const EXTERNAL_ARGUMENT_MISSING = makeCodeDefinition('EXTERNAL_ARGUMENT_MISSING', 'An `@external` field is missing some arguments present in the declaration(s) of that field in other subgraphs.'); +const EXTERNAL_ARGUMENT_TYPE_MISMATCH = makeCodeDefinition('EXTERNAL_ARGUMENT_TYPE_MISMATCH', 'An `@external` field declares an argument with a type that is incompatible with the corresponding argument in the declaration(s) of that field in other subgraphs.'); +const EXTERNAL_ARGUMENT_DEFAULT_MISMATCH = makeCodeDefinition('EXTERNAL_ARGUMENT_DEFAULT_MISMATCH', 'An `@external` field declares an argument with a default that is incompatible with the corresponding argument in the declaration(s) of that field in other subgraphs.'); +const EXTERNAL_ON_INTERFACE = makeCodeDefinition('EXTERNAL_ON_INTERFACE', 'The field of an interface type is marked with `@external`: as external is about marking field not resolved by the subgraph and as interface field are not resolved (only implementations of those fields are), an "external" interface field is nonsensical'); +const MERGED_DIRECTIVE_APPLICATION_ON_EXTERNAL = makeCodeDefinition('MERGED_DIRECTIVE_APPLICATION_ON_EXTERNAL', 'In a subgraph, a field is both marked @external and has a merged directive applied to it'); +const FIELD_TYPE_MISMATCH = makeCodeDefinition('FIELD_TYPE_MISMATCH', 'A field has a type that is incompatible with other declarations of that field in other subgraphs.', { ...DEFAULT_METADATA, replaces: ['VALUE_TYPE_FIELD_TYPE_MISMATCH'] }); +const ARGUMENT_TYPE_MISMATCH = makeCodeDefinition('FIELD_ARGUMENT_TYPE_MISMATCH', 'An argument (of a field/directive) has a type that is incompatible with that of other declarations of that same argument in other subgraphs.', { ...DEFAULT_METADATA, replaces: ['VALUE_TYPE_INPUT_VALUE_MISMATCH'] }); +const INPUT_FIELD_DEFAULT_MISMATCH = makeCodeDefinition('INPUT_FIELD_DEFAULT_MISMATCH', 'An input field has a default value that is incompatible with other declarations of that field in other subgraphs.'); +const ARGUMENT_DEFAULT_MISMATCH = makeCodeDefinition('FIELD_ARGUMENT_DEFAULT_MISMATCH', 'An argument (of a field/directive) has a default value that is incompatible with that of other declarations of that same argument in other subgraphs.'); +const EXTENSION_WITH_NO_BASE = makeCodeDefinition('EXTENSION_WITH_NO_BASE', 'A subgraph is attempting to `extend` a type that is not originally defined in any known subgraph.', { addedIn: FED1_CODE }); +const EXTERNAL_MISSING_ON_BASE = makeCodeDefinition('EXTERNAL_MISSING_ON_BASE', 'A field is marked as `@external` in a subgraph but with no non-external declaration in any other subgraph.', { addedIn: FED1_CODE }); +const INTERFACE_FIELD_IMPLEM_TYPE_MISMATCH = makeCodeDefinition('INTERFACE_FIELD_IMPLEM_TYPE_MISMATCH', 'For an interface field, some of its concrete implementations have @external or @requires and there is difference in those implementations return type (which is currently not supported; see https://github.com/apollographql/federation/issues/1257)'); +const INVALID_FIELD_SHARING = makeCodeDefinition('INVALID_FIELD_SHARING', 'A field that is non-shareable in at least one subgraph is resolved by multiple subgraphs.'); +const INVALID_LINK_DIRECTIVE_USAGE = makeCodeDefinition('INVALID_LINK_DIRECTIVE_USAGE', 'An application of the @link directive is invalid/does not respect the specification.'); +const INVALID_LINK_IDENTIFIER = makeCodeDefinition('INVALID_LINK_IDENTIFIER', 'A url/version for a @link feature is invalid/does not respect the specification.', { addedIn: '2.1.0' }); +const LINK_IMPORT_NAME_MISMATCH = makeCodeDefinition('LINK_IMPORT_NAME_MISMATCH', 'The import name for a merged directive (as declared by the relevant `@link(import:)` argument) is inconsistent between subgraphs.'); +const REFERENCED_INACCESSIBLE = makeCodeDefinition('REFERENCED_INACCESSIBLE', 'An element is marked as @inaccessible but is referenced by an element visible in the API schema.'); +const DEFAULT_VALUE_USES_INACCESSIBLE = makeCodeDefinition('DEFAULT_VALUE_USES_INACCESSIBLE', 'An element is marked as @inaccessible but is used in the default value of an element visible in the API schema.'); +const QUERY_ROOT_TYPE_INACCESSIBLE = makeCodeDefinition('QUERY_ROOT_TYPE_INACCESSIBLE', 'An element is marked as @inaccessible but is the query root type, which must be visible in the API schema.'); +const REQUIRED_INACCESSIBLE = makeCodeDefinition('REQUIRED_INACCESSIBLE', 'An element is marked as @inaccessible but is required by an element visible in the API schema.'); +const IMPLEMENTED_BY_INACCESSIBLE = makeCodeDefinition('IMPLEMENTED_BY_INACCESSIBLE', 'An element is marked as @inaccessible but implements an element visible in the API schema.'); +const DISALLOWED_INACCESSIBLE = makeCodeDefinition('DISALLOWED_INACCESSIBLE', 'An element is marked as @inaccessible that is not allowed to be @inaccessible.'); +const ONLY_INACCESSIBLE_CHILDREN = makeCodeDefinition('ONLY_INACCESSIBLE_CHILDREN', 'A type visible in the API schema has only @inaccessible children.'); +const REQUIRED_INPUT_FIELD_MISSING_IN_SOME_SUBGRAPH = makeCodeDefinition('REQUIRED_INPUT_FIELD_MISSING_IN_SOME_SUBGRAPH', 'A field of an input object type is mandatory in some subgraphs, but the field is not defined in all the subgraphs that define the input object type.'); +const REQUIRED_ARGUMENT_MISSING_IN_SOME_SUBGRAPH = makeCodeDefinition('REQUIRED_ARGUMENT_MISSING_IN_SOME_SUBGRAPH', 'An argument of a field or directive definition is mandatory in some subgraphs, but the argument is not defined in all the subgraphs that define the field or directive definition.'); +const EMPTY_MERGED_INPUT_TYPE = makeCodeDefinition('EMPTY_MERGED_INPUT_TYPE', 'An input object type has no field common to all the subgraphs that define the type. Merging that type would result in an invalid empty input object type.'); +const ENUM_VALUE_MISMATCH = makeCodeDefinition('ENUM_VALUE_MISMATCH', 'An enum type that is used as both an input and output type has a value that is not defined in all the subgraphs that define the enum type.'); +const EMPTY_MERGED_ENUM_TYPE = makeCodeDefinition('EMPTY_MERGED_ENUM_TYPE', 'An enum type has no value common to all the subgraphs that define the type. Merging that type would result in an invalid empty enum type.'); +const SATISFIABILITY_ERROR = makeCodeDefinition('SATISFIABILITY_ERROR', 'Subgraphs can be merged, but the resulting supergraph API would have queries that cannot be satisfied by those subgraphs.'); +const OVERRIDE_FROM_SELF_ERROR = makeCodeDefinition('OVERRIDE_FROM_SELF_ERROR', 'Field with `@override` directive has "from" location that references its own subgraph.'); +const OVERRIDE_SOURCE_HAS_OVERRIDE = makeCodeDefinition('OVERRIDE_SOURCE_HAS_OVERRIDE', 'Field which is overridden to another subgraph is also marked @override.'); +const OVERRIDE_COLLISION_WITH_ANOTHER_DIRECTIVE = makeCodeDefinition('OVERRIDE_COLLISION_WITH_ANOTHER_DIRECTIVE', 'The @override directive cannot be used on external fields, nor to override fields with either @external, @provides, or @requires.'); +const UNSUPPORTED_FEATURE = makeCodeDefinition('UNSUPPORTED_FEATURE', 'Indicates an error due to feature currently unsupported by federation.', { addedIn: '2.1.0' }); +const INVALID_FEDERATION_SUPERGRAPH = makeCodeDefinition('INVALID_FEDERATION_SUPERGRAPH', 'Indicates that a schema provided for an Apollo Federation supergraph is not a valid supergraph schema.', { addedIn: '2.1.0' }); +const DOWNSTREAM_SERVICE_ERROR = makeCodeDefinition('DOWNSTREAM_SERVICE_ERROR', 'Indicates an error in a subgraph service query during query execution in a federated service.', { addedIn: FED1_CODE }); +const DIRECTIVE_COMPOSITION_ERROR = makeCodeDefinition('DIRECTIVE_COMPOSITION_ERROR', 'Error when composing custom directives.', { addedIn: '2.1.0' }); +exports.ERROR_CATEGORIES = { + DIRECTIVE_FIELDS_MISSING_EXTERNAL, + DIRECTIVE_UNSUPPORTED_ON_INTERFACE, + DIRECTIVE_INVALID_FIELDS_TYPE, + DIRECTIVE_INVALID_FIELDS, + FIELDS_HAS_ARGS, + ROOT_TYPE_USED, + DIRECTIVE_IN_FIELDS_ARG, +}; +exports.ERRORS = { + INVALID_GRAPHQL, + DIRECTIVE_DEFINITION_INVALID, + TYPE_DEFINITION_INVALID, + UNSUPPORTED_LINKED_FEATURE, + UNKNOWN_FEDERATION_LINK_VERSION, + UNKNOWN_LINK_VERSION, + KEY_FIELDS_HAS_ARGS, + PROVIDES_FIELDS_HAS_ARGS, + PROVIDES_MISSING_EXTERNAL, + REQUIRES_MISSING_EXTERNAL, + KEY_UNSUPPORTED_ON_INTERFACE, + PROVIDES_UNSUPPORTED_ON_INTERFACE, + REQUIRES_UNSUPPORTED_ON_INTERFACE, + EXTERNAL_UNUSED, + EXTERNAL_COLLISION_WITH_ANOTHER_DIRECTIVE, + TYPE_WITH_ONLY_UNUSED_EXTERNAL, + PROVIDES_ON_NON_OBJECT_FIELD, + KEY_INVALID_FIELDS_TYPE, + PROVIDES_INVALID_FIELDS_TYPE, + REQUIRES_INVALID_FIELDS_TYPE, + KEY_INVALID_FIELDS, + PROVIDES_INVALID_FIELDS, + REQUIRES_INVALID_FIELDS, + KEY_FIELDS_SELECT_INVALID_TYPE, + ROOT_QUERY_USED, + ROOT_MUTATION_USED, + ROOT_SUBSCRIPTION_USED, + INVALID_SUBGRAPH_NAME, + NO_QUERIES, + INTERFACE_FIELD_NO_IMPLEM, + TYPE_KIND_MISMATCH, + EXTERNAL_TYPE_MISMATCH, + EXTERNAL_ARGUMENT_MISSING, + EXTERNAL_ARGUMENT_TYPE_MISMATCH, + EXTERNAL_ARGUMENT_DEFAULT_MISMATCH, + EXTERNAL_ON_INTERFACE, + MERGED_DIRECTIVE_APPLICATION_ON_EXTERNAL, + FIELD_TYPE_MISMATCH, + ARGUMENT_TYPE_MISMATCH, + INPUT_FIELD_DEFAULT_MISMATCH, + ARGUMENT_DEFAULT_MISMATCH, + EXTENSION_WITH_NO_BASE, + EXTERNAL_MISSING_ON_BASE, + INTERFACE_FIELD_IMPLEM_TYPE_MISMATCH, + INVALID_FIELD_SHARING, + INVALID_LINK_DIRECTIVE_USAGE, + INVALID_LINK_IDENTIFIER, + LINK_IMPORT_NAME_MISMATCH, + REFERENCED_INACCESSIBLE, + DEFAULT_VALUE_USES_INACCESSIBLE, + QUERY_ROOT_TYPE_INACCESSIBLE, + REQUIRED_INACCESSIBLE, + DISALLOWED_INACCESSIBLE, + IMPLEMENTED_BY_INACCESSIBLE, + ONLY_INACCESSIBLE_CHILDREN, + REQUIRED_ARGUMENT_MISSING_IN_SOME_SUBGRAPH, + REQUIRED_INPUT_FIELD_MISSING_IN_SOME_SUBGRAPH, + EMPTY_MERGED_INPUT_TYPE, + ENUM_VALUE_MISMATCH, + EMPTY_MERGED_ENUM_TYPE, + SATISFIABILITY_ERROR, + OVERRIDE_COLLISION_WITH_ANOTHER_DIRECTIVE, + OVERRIDE_FROM_SELF_ERROR, + OVERRIDE_SOURCE_HAS_OVERRIDE, + UNSUPPORTED_FEATURE, + INVALID_FEDERATION_SUPERGRAPH, + DOWNSTREAM_SERVICE_ERROR, + KEY_HAS_DIRECTIVE_IN_FIELDS_ARGS, + PROVIDES_HAS_DIRECTIVE_IN_FIELDS_ARGS, + REQUIRES_HAS_DIRECTIVE_IN_FIELDS_ARGS, + DIRECTIVE_COMPOSITION_ERROR, +}; +const codeDefByCode = Object.values(exports.ERRORS).reduce((obj, codeDef) => { obj[codeDef.code] = codeDef; return obj; }, {}); +exports.REMOVED_ERRORS = [ + ['KEY_FIELDS_MISSING_ON_BASE', 'Keys can now use any field from any other subgraph.'], + ['KEY_FIELDS_MISSING_EXTERNAL', 'Using `@external` for key fields is now discouraged, unless the field is truly meant to be external.'], + ['KEY_MISSING_ON_BASE', 'Each subgraph is now free to declare a key only if it needs it.'], + ['MULTIPLE_KEYS_ON_EXTENSION', 'Every subgraph can have multiple keys, as necessary.'], + ['KEY_NOT_SPECIFIED', 'Each subgraph can declare key independently of any other subgraph.'], + ['EXTERNAL_USED_ON_BASE', 'As there is not type ownership anymore, there is also no particular limitation as to where a field can be external.'], + ['PROVIDES_NOT_ON_ENTITY', '@provides can now be used on any type.'], + ['REQUIRES_FIELDS_MISSING_ON_BASE', 'Fields in @requires can now be from any subgraph.'], + ['REQUIRES_USED_ON_BASE', 'As there is not type ownership anymore, there is also no particular limitation as to which subgraph can use a @requires.'], + ['DUPLICATE_SCALAR_DEFINITION', 'As duplicate scalar definitions is invalid GraphQL, this will now be an error with code `INVALID_GRAPHQL`'], + ['DUPLICATE_ENUM_DEFINITION', 'As duplicate enum definitions is invalid GraphQL, this will now be an error with code `INVALID_GRAPHQL`'], + ['DUPLICATE_ENUM_VALUE', 'As duplicate enum values is invalid GraphQL, this will now be an error with code `INVALID_GRAPHQL`'], + ['ENUM_MISMATCH', 'Subgraph definitions for an enum are now merged by composition'], + ['VALUE_TYPE_NO_ENTITY', 'There is no strong different between entity and value types in the model (they are just usage pattern) and a type can have keys in one subgraph but not another.'], + ['VALUE_TYPE_UNION_TYPES_MISMATCH', 'Subgraph definitions for an union are now merged by composition'], + ['PROVIDES_FIELDS_SELECT_INVALID_TYPE', '@provides can now be used on field of interface, union and list types'], + ['RESERVED_FIELD_USED', 'This error was previously not correctly enforced: the _service and _entities, if present, were overridden; this is still the case'], + ['NON_REPEATABLE_DIRECTIVE_ARGUMENTS_MISMATCH', 'Since federation 2.1.0, the case this error used to cover is now a warning (with code `INCONSISTENT_NON_REPEATABLE_DIRECTIVE_ARGUMENTS`) instead of an error'], + ['REQUIRES_FIELDS_HAS_ARGS', 'Since federation 2.1.1, using fields with arguments in a @requires is fully supported'], +]; +//# sourceMappingURL=error.js.map + +/***/ }), + +/***/ 8220: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +"use strict"; + +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.extractSubgraphsFromSupergraph = exports.extractSubgraphsNamesAndUrlsFromSupergraph = void 0; +const definitions_1 = __webpack_require__(4177); +const federation_1 = __webpack_require__(4408); +const coreSpec_1 = __webpack_require__(9209); +const federation_2 = __webpack_require__(4408); +const utils_1 = __webpack_require__(9724); +const supergraphs_1 = __webpack_require__(9624); +const buildSchema_1 = __webpack_require__(7964); +const types_1 = __webpack_require__(5811); +const print_1 = __webpack_require__(2850); +const operations_1 = __webpack_require__(758); +const fs_1 = __importDefault(__webpack_require__(8222)); +const path_1 = __importDefault(__webpack_require__(6470)); +const utils_2 = __webpack_require__(9724); +const _1 = __webpack_require__(415); +function filteredTypes(supergraph, joinSpec, coreSpec) { + return supergraph.types().filter(t => !joinSpec.isSpecType(t) && !coreSpec.isSpecType(t)); +} +function extractSubgraphsNamesAndUrlsFromSupergraph(supergraph) { + const [_, joinSpec] = (0, supergraphs_1.validateSupergraph)(supergraph); + const [subgraphs] = collectEmptySubgraphs(supergraph, joinSpec); + return subgraphs.values().map(subgraph => { return { name: subgraph.name, url: subgraph.url }; }); +} +exports.extractSubgraphsNamesAndUrlsFromSupergraph = extractSubgraphsNamesAndUrlsFromSupergraph; +function collectEmptySubgraphs(supergraph, joinSpec) { + const subgraphs = new federation_2.Subgraphs(); + const graphDirective = joinSpec.graphDirective(supergraph); + const graphEnum = joinSpec.graphEnum(supergraph); + const graphEnumNameToSubgraphName = new Map(); + for (const value of graphEnum.values) { + const graphApplications = value.appliedDirectivesOf(graphDirective); + if (!graphApplications.length) { + throw new Error(`Value ${value} of join__Graph enum has no @join__graph directive`); + } + const info = graphApplications[0].arguments(); + const subgraph = new federation_2.Subgraph(info.name, info.url, (0, federation_1.newEmptyFederation2Schema)()); + subgraphs.add(subgraph); + graphEnumNameToSubgraphName.set(value.name, info.name); + } + return [subgraphs, graphEnumNameToSubgraphName]; +} +class SubgraphExtractionError { + constructor(originalError, subgraph) { + this.originalError = originalError; + this.subgraph = subgraph; + } +} +function collectFieldReachableTypesForSubgraph(supergraph, subgraphName, addReachableType, fieldInfoInSubgraph, typeInfoInSubgraph) { + const seenTypes = new Set(); + const stack = supergraph.schemaDefinition.roots().map((root) => root.type); + for (const type of supergraph.types()) { + const { isEntityWithKeyInSubgraph, typesInFederationDirectives } = typeInfoInSubgraph(type, subgraphName); + if (isEntityWithKeyInSubgraph) { + stack.push(type); + } + typesInFederationDirectives.forEach((t) => stack.push(t)); + } + while (stack.length > 0) { + const type = stack.pop(); + addReachableType(type); + if (seenTypes.has(type.name)) { + continue; + } + seenTypes.add(type.name); + switch (type.kind) { + case 'InterfaceType': + type.allImplementations().forEach((t) => stack.push(t)); + case 'ObjectType': + type.interfaces().forEach((t) => stack.push(t)); + for (const field of type.fields()) { + const { isInSubgraph, typesInFederationDirectives } = fieldInfoInSubgraph(field, subgraphName); + if (isInSubgraph) { + field.arguments().forEach((arg) => stack.push((0, definitions_1.baseType)(arg.type))); + stack.push((0, definitions_1.baseType)(field.type)); + typesInFederationDirectives.forEach((t) => stack.push(t)); + } + } + break; + case 'InputObjectType': + for (const field of type.fields()) { + const { isInSubgraph, typesInFederationDirectives } = fieldInfoInSubgraph(field, subgraphName); + if (isInSubgraph) { + stack.push((0, definitions_1.baseType)(field.type)); + typesInFederationDirectives.forEach((t) => stack.push(t)); + } + } + break; + case 'UnionType': + type.members().forEach((m) => stack.push(m.type)); + break; + } + } + for (const directive of supergraph.directives()) { + if (!directive.hasExecutableLocations()) { + continue; + } + directive.arguments().forEach((arg) => stack.push((0, definitions_1.baseType)(arg.type))); + } +} +function collectFieldReachableTypesForAllSubgraphs(supergraph, allSubgraphs, fieldInfoInSubgraph, typeInfoInSubgraph) { + const reachableTypesBySubgraphs = new Map(); + for (const subgraphName of allSubgraphs) { + const reachableTypes = new Set(); + collectFieldReachableTypesForSubgraph(supergraph, subgraphName, (t) => reachableTypes.add(t.name), fieldInfoInSubgraph, typeInfoInSubgraph); + reachableTypesBySubgraphs.set(subgraphName, reachableTypes); + } + return reachableTypesBySubgraphs; +} +function typesUsedInFederationDirective(fieldSet, parentType) { + if (!fieldSet) { + return []; + } + const usedTypes = []; + (0, operations_1.parseSelectionSet)({ + parentType, + source: fieldSet, + fieldAccessor: (type, fieldName) => { + const field = type.field(fieldName); + if (field) { + usedTypes.push((0, definitions_1.baseType)(field.type)); + } + return field; + }, + validate: false, + }); + return usedTypes; +} +function extractSubgraphsFromSupergraph(supergraph) { + const [coreFeatures, joinSpec] = (0, supergraphs_1.validateSupergraph)(supergraph); + const isFed1 = joinSpec.version.equals(new coreSpec_1.FeatureVersion(0, 1)); + try { + const [subgraphs, graphEnumNameToSubgraphName] = collectEmptySubgraphs(supergraph, joinSpec); + const typeDirective = joinSpec.typeDirective(supergraph); + const implementsDirective = joinSpec.implementsDirective(supergraph); + const ownerDirective = joinSpec.ownerDirective(supergraph); + const fieldDirective = joinSpec.fieldDirective(supergraph); + const getSubgraph = (application) => graphEnumNameToSubgraphName.get(application.arguments().graph); + let includeTypeInSubgraph = () => true; + if (isFed1) { + const reachableTypesBySubgraph = collectFieldReachableTypesForAllSubgraphs(supergraph, subgraphs.names(), (f, name) => { + const fieldApplications = f.appliedDirectivesOf(fieldDirective); + if (fieldApplications.length) { + const application = fieldApplications.find((application) => getSubgraph(application) === name); + if (application) { + const args = application.arguments(); + const typesInFederationDirectives = typesUsedInFederationDirective(args.provides, (0, definitions_1.baseType)(f.type)) + .concat(typesUsedInFederationDirective(args.requires, f.parent)); + return { isInSubgraph: true, typesInFederationDirectives }; + } + else { + return { isInSubgraph: false, typesInFederationDirectives: [] }; + } + } + else { + const ownerApplications = ownerDirective ? f.parent.appliedDirectivesOf(ownerDirective) : []; + return { isInSubgraph: !ownerApplications.length || getSubgraph(ownerApplications[0]) == name, typesInFederationDirectives: [] }; + } + }, (t, name) => { + const typeApplications = t.appliedDirectivesOf(typeDirective); + const application = typeApplications.find((application) => (application.arguments().key && (getSubgraph(application) === name))); + if (application) { + const typesInFederationDirectives = typesUsedInFederationDirective(application.arguments().key, t); + return { isEntityWithKeyInSubgraph: true, typesInFederationDirectives }; + } + else { + return { isEntityWithKeyInSubgraph: false, typesInFederationDirectives: [] }; + } + }); + includeTypeInSubgraph = (t, name) => { var _a, _b; return (_b = (_a = reachableTypesBySubgraph.get(name)) === null || _a === void 0 ? void 0 : _a.has(t.name)) !== null && _b !== void 0 ? _b : false; }; + } + for (const type of filteredTypes(supergraph, joinSpec, coreFeatures.coreDefinition)) { + const typeApplications = type.appliedDirectivesOf(typeDirective); + if (!typeApplications.length) { + subgraphs + .values() + .filter((sg) => includeTypeInSubgraph(type, sg.name)) + .map(sg => sg.schema).forEach(schema => schema.addType((0, definitions_1.newNamedType)(type.kind, type.name))); + } + else { + for (const application of typeApplications) { + const args = application.arguments(); + const subgraphName = getSubgraph(application); + const schema = subgraphs.get(subgraphName).schema; + let subgraphType = schema.type(type.name); + if (!subgraphType) { + subgraphType = schema.addType((0, definitions_1.newNamedType)(type.kind, type.name)); + } + if (args.key) { + const { resolvable } = args; + const directive = subgraphType.applyDirective('key', { 'fields': args.key, resolvable }); + if (args.extension) { + directive.setOfExtension(subgraphType.newExtension()); + } + } + } + } + } + for (const type of filteredTypes(supergraph, joinSpec, coreFeatures.coreDefinition)) { + switch (type.kind) { + case 'ObjectType': + case 'InterfaceType': + const addedInterfaces = []; + const implementsApplications = implementsDirective ? type.appliedDirectivesOf(implementsDirective) : []; + for (const application of implementsApplications) { + const args = application.arguments(); + const subgraph = subgraphs.get(graphEnumNameToSubgraphName.get(args.graph)); + const schema = subgraph.schema; + schema.type(type.name).addImplementedInterface(args.interface); + addedInterfaces.push(args.interface); + } + for (const implementations of type.interfaceImplementations()) { + const name = implementations.interface.name; + if (!addedInterfaces.includes(name)) { + for (const subgraph of subgraphs) { + const subgraphType = subgraph.schema.type(type.name); + const subgraphItf = subgraph.schema.type(name); + if (subgraphType && subgraphItf) { + subgraphType.addImplementedInterface(name); + } + } + } + } + case 'InputObjectType': + for (const field of type.fields()) { + const fieldApplications = field.appliedDirectivesOf(fieldDirective); + if (!fieldApplications.length) { + const ownerApplications = ownerDirective ? type.appliedDirectivesOf(ownerDirective) : []; + if (!ownerApplications.length) { + const fieldBaseType = (0, definitions_1.baseType)(field.type); + for (const subgraph of subgraphs) { + if (subgraph.schema.type(fieldBaseType.name)) { + addSubgraphField(field, subgraph); + } + } + } + else { + (0, utils_1.assert)(ownerApplications.length == 1, () => `Found multiple join__owner directives on type ${type}`); + const subgraph = subgraphs.get(graphEnumNameToSubgraphName.get(ownerApplications[0].arguments().graph)); + const subgraphField = addSubgraphField(field, subgraph); + (0, utils_1.assert)(subgraphField, () => `Found join__owner directive on ${type} but no corresponding join__type`); + } + } + else { + for (const application of fieldApplications) { + const args = application.arguments(); + const subgraph = subgraphs.get(graphEnumNameToSubgraphName.get(args.graph)); + const subgraphField = addSubgraphField(field, subgraph, args.type); + if (!subgraphField) { + (0, utils_1.assert)(!includeTypeInSubgraph(type, subgraph.name), () => `Found join__field directive for graph ${subgraph.name} on field ${field.coordinate} but no corresponding join__type on ${type}`); + continue; + } + if (args.requires) { + subgraphField.applyDirective(subgraph.metadata().requiresDirective(), { 'fields': args.requires }); + } + if (args.provides) { + subgraphField.applyDirective(subgraph.metadata().providesDirective(), { 'fields': args.provides }); + } + if (args.external) { + subgraphField.applyDirective(subgraph.metadata().externalDirective()); + } + if (args.usedOverridden) { + subgraphField.applyDirective(subgraph.metadata().externalDirective(), { 'reason': '[overridden]' }); + } + if (args.override) { + subgraphField.applyDirective(subgraph.metadata().overrideDirective(), { 'from': args.override }); + } + } + } + } + break; + case 'EnumType': + for (const subgraph of subgraphs) { + const subgraphEnum = subgraph.schema.type(type.name); + if (!subgraphEnum) { + continue; + } + (0, utils_1.assert)((0, definitions_1.isEnumType)(subgraphEnum), () => `${subgraphEnum} should be an enum but found a ${subgraphEnum.kind}`); + for (const value of type.values) { + subgraphEnum.addValue(value.name); + } + } + break; + case 'UnionType': + for (const subgraph of subgraphs) { + const subgraphUnion = subgraph.schema.type(type.name); + if (!subgraphUnion) { + continue; + } + (0, utils_1.assert)((0, definitions_1.isUnionType)(subgraphUnion), () => `${subgraphUnion} should be an enum but found a ${subgraphUnion.kind}`); + for (const memberType of type.types()) { + const subgraphType = subgraph.schema.type(memberType.name); + if (subgraphType) { + subgraphUnion.addType(subgraphType); + } + } + } + break; + } + } + const allExecutableDirectives = supergraph.directives().filter((def) => def.hasExecutableLocations()); + for (const subgraph of subgraphs) { + if (isFed1) { + addExternalFields(subgraph, supergraph, isFed1); + } + (0, federation_1.removeInactiveProvidesAndRequires)(subgraph.schema); + for (const type of subgraph.schema.types()) { + switch (type.kind) { + case 'ObjectType': + case 'InterfaceType': + case 'InputObjectType': + if (!type.hasFields()) { + type.removeRecursive(); + } + break; + case 'UnionType': + if (type.membersCount() === 0) { + type.removeRecursive(); + } + break; + } + } + for (const definition of allExecutableDirectives) { + (0, definitions_1.copyDirectiveDefinitionToSchema)({ + definition, + schema: subgraph.schema, + copyDirectiveApplicationsInArguments: false, + locationFilter: (loc) => (0, definitions_1.isExecutableDirectiveLocation)(loc), + }); + } + } + if (isFed1) { + for (const subgraph of subgraphs) { + for (const itf of subgraph.schema.interfaceTypes()) { + const implementations = itf.possibleRuntimeTypes(); + for (const field of itf.fields()) { + if (!implementations.every(implem => implem.field(field.name))) { + field.remove(); + } + } + if (!itf.hasFields()) { + itf.remove(); + } + } + } + } + for (const subgraph of subgraphs) { + try { + subgraph.validate(); + } + catch (e) { + throw new SubgraphExtractionError(e, subgraph); + } + } + return subgraphs; + } + catch (e) { + let error = e; + let subgraph = undefined; + if (e instanceof SubgraphExtractionError) { + error = e.originalError; + subgraph = e.subgraph; + } + const impacted = subgraph ? `subgraph "${subgraph.name}"` : 'subgraphs'; + if (isFed1) { + const msg = `Error extracting ${impacted} from the supergraph: this might be due to errors in subgraphs that were mistakenly ignored by federation 0.x versions but are rejected by federation 2.\n` + + 'Please try composing your subgraphs with federation 2: this should help precisely pinpoint the problems and, once fixed, generate a correct federation 2 supergraph'; + throw new Error(`${msg}.\n\nDetails:\n${errorToString(error)}`); + } + else { + const msg = `Unexpected error extracting ${impacted} from the supergraph: this is either a bug, or the supergraph has been corrupted`; + const dumpMsg = subgraph ? '\n\n' + maybeDumpSubgraphSchema(subgraph) : ''; + throw new Error(`${msg}.\n\nDetails:\n${errorToString(error)}${dumpMsg}`); + } + } +} +exports.extractSubgraphsFromSupergraph = extractSubgraphsFromSupergraph; +const DEBUG_SUBGRAPHS_ENV_VARIABLE_NAME = 'APOLLO_FEDERATION_DEBUG_SUBGRAPHS'; +function maybeDumpSubgraphSchema(subgraph) { + const shouldDump = !!(0, utils_2.validateStringContainsBoolean)(process.env[DEBUG_SUBGRAPHS_ENV_VARIABLE_NAME]); + if (!shouldDump) { + return `Re-run with environment variable '${DEBUG_SUBGRAPHS_ENV_VARIABLE_NAME}' set to 'true' to extract the invalid subgraph`; + } + try { + const filename = `extracted-subgraph-${subgraph.name}-${Date.now()}.graphql`; + const file = path_1.default.resolve(filename); + if (fs_1.default.existsSync(file)) { + throw new Error(`candidate file ${filename} already existed`); + } + fs_1.default.writeFileSync(file, (0, print_1.printSchema)(subgraph.schema)); + return `The (invalid) extracted subgraph has been written in: ${file}.`; + } + catch (e2) { + return `Was not able to print generated subgraph for "${subgraph.name}" because: ${errorToString(e2)}`; + } +} +function errorToString(e) { + const causes = (0, _1.errorCauses)(e); + return causes ? (0, _1.printErrors)(causes) : String(e); +} +function addSubgraphField(supergraphField, subgraph, encodedType) { + if (supergraphField instanceof definitions_1.FieldDefinition) { + return addSubgraphObjectOrInterfaceField(supergraphField, subgraph, encodedType); + } + else { + return addSubgraphInputField(supergraphField, subgraph, encodedType); + } +} +function addSubgraphObjectOrInterfaceField(supergraphField, subgraph, encodedType) { + const subgraphType = subgraph.schema.type(supergraphField.parent.name); + if (subgraphType) { + const copiedType = encodedType + ? decodeType(encodedType, subgraph.schema, subgraph.name) + : copyType(supergraphField.type, subgraph.schema, subgraph.name); + const field = subgraphType.addField(supergraphField.name, copiedType); + for (const arg of supergraphField.arguments()) { + field.addArgument(arg.name, copyType(arg.type, subgraph.schema, subgraph.name), arg.defaultValue); + } + return field; + } + else { + return undefined; + } +} +function addSubgraphInputField(supergraphField, subgraph, encodedType) { + const subgraphType = subgraph.schema.type(supergraphField.parent.name); + if (subgraphType) { + const copiedType = encodedType + ? decodeType(encodedType, subgraph.schema, subgraph.name) + : copyType(supergraphField.type, subgraph.schema, subgraph.name); + return subgraphType.addField(supergraphField.name, copiedType); + } + else { + return undefined; + } +} +function decodeType(encodedType, subgraph, subgraphName) { + try { + return (0, buildSchema_1.builtTypeReference)(encodedType, subgraph); + } + catch (e) { + (0, utils_1.assert)(false, () => `Cannot parse type "${encodedType}" in subgraph ${subgraphName}: ${e}`); + } +} +function copyType(type, subgraph, subgraphName) { + switch (type.kind) { + case 'ListType': + return new definitions_1.ListType(copyType(type.ofType, subgraph, subgraphName)); + case 'NonNullType': + return new definitions_1.NonNullType(copyType(type.ofType, subgraph, subgraphName)); + default: + const subgraphType = subgraph.type(type.name); + (0, utils_1.assert)(subgraphType, () => `Cannot find type "${type.name}" in subgraph "${subgraphName}"`); + return subgraphType; + } +} +function addExternalFields(subgraph, supergraph, isFed1) { + const metadata = subgraph.metadata(); + for (const type of subgraph.schema.types()) { + if (!(0, definitions_1.isObjectType)(type) && !(0, definitions_1.isInterfaceType)(type)) { + continue; + } + for (const keyApplication of type.appliedDirectivesOf(metadata.keyDirective())) { + const forceNonExternal = isFed1 || !!keyApplication.ofExtension(); + addExternalFieldsFromDirectiveFieldSet(subgraph, type, keyApplication, supergraph, forceNonExternal); + } + for (const field of type.fields()) { + for (const requiresApplication of field.appliedDirectivesOf(metadata.requiresDirective())) { + addExternalFieldsFromDirectiveFieldSet(subgraph, type, requiresApplication, supergraph); + } + const fieldBaseType = (0, definitions_1.baseType)(field.type); + for (const providesApplication of field.appliedDirectivesOf(metadata.providesDirective())) { + (0, utils_1.assert)((0, definitions_1.isObjectType)(fieldBaseType) || (0, definitions_1.isInterfaceType)(fieldBaseType), () => `Found @provides on field ${field.coordinate} whose type ${field.type} (${fieldBaseType.kind}) is not an object or interface `); + addExternalFieldsFromDirectiveFieldSet(subgraph, fieldBaseType, providesApplication, supergraph); + } + } + addExternalFieldsFromInterface(metadata, type); + } +} +function addExternalFieldsFromDirectiveFieldSet(subgraph, parentType, directive, supergraph, forceNonExternal = false) { + const external = subgraph.metadata().externalDirective(); + const fieldAccessor = function (type, fieldName) { + const field = type.field(fieldName); + if (field) { + if (forceNonExternal && field.hasAppliedDirective(external)) { + field.appliedDirectivesOf(external).forEach(d => d.remove()); + } + return field; + } + (0, utils_1.assert)(!(0, definitions_1.isUnionType)(type), () => `Shouldn't select field ${fieldName} from union type ${type}`); + const supergraphType = supergraph.type(type.name); + const supergraphField = supergraphType.field(fieldName); + (0, utils_1.assert)(supergraphField, () => `No field named ${fieldName} found on type ${type.name} in the supergraph`); + const created = addSubgraphObjectOrInterfaceField(supergraphField, subgraph); + if (!forceNonExternal) { + created.applyDirective(external); + } + return created; + }; + try { + (0, federation_1.parseFieldSetArgument)({ parentType, directive, fieldAccessor, validate: false }); + } + catch (e) { + } +} +function addExternalFieldsFromInterface(metadata, type) { + for (const itf of type.interfaces()) { + for (const field of itf.fields()) { + const typeField = type.field(field.name); + if (!typeField) { + copyFieldAsExternal(metadata, field, type); + } + else if (typeField.hasAppliedDirective(metadata.externalDirective())) { + maybeUpdateFieldForInterface(typeField, field); + } + } + } +} +function copyFieldAsExternal(metadata, field, type) { + const newField = type.addField(field.name, field.type); + for (const arg of field.arguments()) { + newField.addArgument(arg.name, arg.type, arg.defaultValue); + } + newField.applyDirective(metadata.externalDirective()); +} +function maybeUpdateFieldForInterface(toModify, itfField) { + if (!(0, types_1.isSubtype)(itfField.type, toModify.type)) { + (0, utils_1.assert)((0, types_1.isSubtype)(toModify.type, itfField.type), () => `For ${toModify.coordinate}, expected ${itfField.type} and ${toModify.type} to be in a subtyping relationship`); + toModify.type = itfField.type; + } +} +//# sourceMappingURL=extractSubgraphsFromSupergraph.js.map + +/***/ }), + +/***/ 4408: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.removeInactiveProvidesAndRequires = exports.addSubgraphToError = exports.addSubgraphToASTNode = exports.Subgraph = exports.FEDERATION_OPERATION_FIELDS = exports.entitiesFieldName = exports.serviceFieldName = exports.FEDERATION_OPERATION_TYPES = exports.entityTypeSpec = exports.serviceTypeSpec = exports.anyTypeSpec = exports.Subgraphs = exports.subgraphsFromServiceList = exports.collectTargetFields = exports.parseFieldSetArgument = exports.newEmptyFederation2Schema = exports.buildSubgraph = exports.isEntityType = exports.isFederationField = exports.isFederationSubgraphSchema = exports.federationMetadata = exports.printSubgraphNames = exports.asFed2SubgraphDocument = exports.FEDERATION2_LINK_WTH_FULL_IMPORTS = exports.setSchemaAsFed2Subgraph = exports.FederationBlueprint = exports.FederationMetadata = exports.collectUsedFields = exports.FEDERATION_UNNAMED_SUBGRAPH_NAME = exports.FEDERATION_RESERVED_SUBGRAPH_NAME = void 0; +const definitions_1 = __webpack_require__(4177); +const utils_1 = __webpack_require__(9724); +const specifiedRules_1 = __webpack_require__(4710); +const graphql_1 = __webpack_require__(8929); +const KnownTypeNamesInFederationRule_1 = __webpack_require__(4150); +const buildSchema_1 = __webpack_require__(7964); +const operations_1 = __webpack_require__(758); +const tagSpec_1 = __webpack_require__(1697); +const inaccessibleSpec_1 = __webpack_require__(5322); +const error_1 = __webpack_require__(8116); +const precompute_1 = __webpack_require__(7678); +const coreSpec_1 = __webpack_require__(9209); +const federationSpec_1 = __webpack_require__(9480); +const print_1 = __webpack_require__(2850); +const directiveAndTypeSpecification_1 = __webpack_require__(3208); +const suggestions_1 = __webpack_require__(5388); +const linkSpec = coreSpec_1.LINK_VERSIONS.latest(); +const tagSpec = tagSpec_1.TAG_VERSIONS.latest(); +const inaccessibleSpec = inaccessibleSpec_1.INACCESSIBLE_VERSIONS.latest(); +const federationSpec = federationSpec_1.FEDERATION_VERSIONS.latest(); +exports.FEDERATION_RESERVED_SUBGRAPH_NAME = '_'; +exports.FEDERATION_UNNAMED_SUBGRAPH_NAME = ''; +const FEDERATION_OMITTED_VALIDATION_RULES = [ + graphql_1.PossibleTypeExtensionsRule, + graphql_1.KnownTypeNamesRule +]; +const FEDERATION_SPECIFIC_VALIDATION_RULES = [ + KnownTypeNamesInFederationRule_1.KnownTypeNamesInFederationRule +]; +const FEDERATION_VALIDATION_RULES = specifiedRules_1.specifiedSDLRules.filter(rule => !FEDERATION_OMITTED_VALIDATION_RULES.includes(rule)).concat(FEDERATION_SPECIFIC_VALIDATION_RULES); +function validateFieldSetSelections({ directiveName, selectionSet, hasExternalInParents, metadata, onError, allowOnNonExternalLeafFields, allowFieldsWithArguments, }) { + for (const selection of selectionSet.selections()) { + const appliedDirectives = selection.element().appliedDirectives; + if (appliedDirectives.length > 0) { + onError(error_1.ERROR_CATEGORIES.DIRECTIVE_IN_FIELDS_ARG.get(directiveName).err(`cannot have directive applications in the @${directiveName}(fields:) argument but found ${appliedDirectives.join(', ')}.`)); + } + if (selection.kind === 'FieldSelection') { + const field = selection.element().definition; + const isExternal = metadata.isFieldExternal(field); + if (!allowFieldsWithArguments && field.hasArguments()) { + onError(error_1.ERROR_CATEGORIES.FIELDS_HAS_ARGS.get(directiveName).err(`field ${field.coordinate} cannot be included because it has arguments (fields with argument are not allowed in @${directiveName})`, { nodes: field.sourceAST })); + } + const mustBeExternal = !selection.selectionSet && !allowOnNonExternalLeafFields && !hasExternalInParents; + if (!isExternal && mustBeExternal) { + const errorCode = error_1.ERROR_CATEGORIES.DIRECTIVE_FIELDS_MISSING_EXTERNAL.get(directiveName); + if (metadata.isFieldFakeExternal(field)) { + onError(errorCode.err(`field "${field.coordinate}" should not be part of a @${directiveName} since it is already "effectively" provided by this subgraph ` + + `(while it is marked @${federationSpec_1.externalDirectiveSpec.name}, it is a @${federationSpec_1.keyDirectiveSpec.name} field of an extension type, which are not internally considered external for historical/backward compatibility reasons)`, { nodes: field.sourceAST })); + } + else { + onError(errorCode.err(`field "${field.coordinate}" should not be part of a @${directiveName} since it is already provided by this subgraph (it is not marked @${federationSpec_1.externalDirectiveSpec.name})`, { nodes: field.sourceAST })); + } + } + if (selection.selectionSet) { + let newHasExternalInParents = hasExternalInParents || isExternal; + const parentType = field.parent; + if (!newHasExternalInParents && (0, definitions_1.isInterfaceType)(parentType)) { + for (const implem of parentType.possibleRuntimeTypes()) { + const fieldInImplem = implem.field(field.name); + if (fieldInImplem && metadata.isFieldExternal(fieldInImplem)) { + newHasExternalInParents = true; + break; + } + } + } + validateFieldSetSelections({ + directiveName, + selectionSet: selection.selectionSet, + hasExternalInParents: newHasExternalInParents, + metadata, + onError, + allowOnNonExternalLeafFields, + allowFieldsWithArguments, + }); + } + } + else { + validateFieldSetSelections({ + directiveName, + selectionSet: selection.selectionSet, + hasExternalInParents, + metadata, + onError, + allowOnNonExternalLeafFields, + allowFieldsWithArguments, + }); + } + } +} +function validateFieldSet({ type, directive, metadata, errorCollector, allowOnNonExternalLeafFields, allowFieldsWithArguments, onFields, }) { + try { + const fieldAccessor = onFields + ? (type, fieldName) => { + const field = type.field(fieldName); + if (field) { + onFields(field); + } + return field; + } + : undefined; + const selectionSet = parseFieldSetArgument({ parentType: type, directive, fieldAccessor }); + validateFieldSetSelections({ + directiveName: directive.name, + selectionSet, + hasExternalInParents: false, + metadata, + onError: (error) => errorCollector.push(handleFieldSetValidationError(directive, error)), + allowOnNonExternalLeafFields, + allowFieldsWithArguments, + }); + } + catch (e) { + if (e instanceof graphql_1.GraphQLError) { + errorCollector.push(e); + } + else { + throw e; + } + } +} +function handleFieldSetValidationError(directive, originalError, messageUpdater) { + const nodes = (0, definitions_1.sourceASTs)(directive); + if (originalError.nodes) { + nodes.push(...originalError.nodes); + } + let codeDef = (0, error_1.errorCodeDef)(originalError); + if (!codeDef || codeDef === error_1.ERRORS.INVALID_GRAPHQL) { + codeDef = error_1.ERROR_CATEGORIES.DIRECTIVE_INVALID_FIELDS.get(directive.name); + } + let msg = originalError.message.trim(); + if (messageUpdater) { + msg = messageUpdater(msg); + } + return codeDef.err(`${fieldSetErrorDescriptor(directive)}: ${msg}`, { + nodes, + originalError, + }); +} +function fieldSetErrorDescriptor(directive) { + return `On ${fieldSetTargetDescription(directive)}, for ${directiveStrUsingASTIfPossible(directive)}`; +} +function directiveStrUsingASTIfPossible(directive) { + return directive.sourceAST ? (0, graphql_1.print)(directive.sourceAST) : directive.toString(); +} +function fieldSetTargetDescription(directive) { + var _a; + const targetKind = directive.parent instanceof definitions_1.FieldDefinition ? "field" : "type"; + return `${targetKind} "${(_a = directive.parent) === null || _a === void 0 ? void 0 : _a.coordinate}"`; +} +function validateAllFieldSet({ definition, targetTypeExtractor, errorCollector, metadata, isOnParentType = false, allowOnNonExternalLeafFields = false, allowFieldsWithArguments = false, onFields, }) { + for (const application of definition.applications()) { + const elt = application.parent; + const type = targetTypeExtractor(elt); + const parentType = isOnParentType ? type : elt.parent; + if ((0, definitions_1.isInterfaceType)(parentType)) { + const code = error_1.ERROR_CATEGORIES.DIRECTIVE_UNSUPPORTED_ON_INTERFACE.get(definition.name); + errorCollector.push(code.err(isOnParentType + ? `Cannot use ${definition.coordinate} on interface "${parentType.coordinate}": ${definition.coordinate} is not yet supported on interfaces` + : `Cannot use ${definition.coordinate} on ${fieldSetTargetDescription(application)} of parent type "${parentType}": ${definition.coordinate} is not yet supported within interfaces`, { nodes: (0, definitions_1.sourceASTs)(application).concat(isOnParentType ? [] : (0, definitions_1.sourceASTs)(type)) })); + } + validateFieldSet({ + type, + directive: application, + metadata, + errorCollector, + allowOnNonExternalLeafFields, + allowFieldsWithArguments, + onFields, + }); + } +} +function collectUsedFields(metadata) { + const usedFields = new Set(); + collectUsedFieldsForDirective(metadata.keyDirective(), type => type, usedFields); + collectUsedFieldsForDirective(metadata.requiresDirective(), field => field.parent, usedFields); + collectUsedFieldsForDirective(metadata.providesDirective(), field => { + const type = (0, definitions_1.baseType)(field.type); + return (0, definitions_1.isCompositeType)(type) ? type : undefined; + }, usedFields); + for (const itfType of metadata.schema.interfaceTypes()) { + const runtimeTypes = itfType.possibleRuntimeTypes(); + for (const field of itfType.fields()) { + for (const runtimeType of runtimeTypes) { + const implemField = runtimeType.field(field.name); + if (implemField) { + usedFields.add(implemField); + } + } + } + } + return usedFields; +} +exports.collectUsedFields = collectUsedFields; +function collectUsedFieldsForDirective(definition, targetTypeExtractor, usedFieldDefs) { + for (const application of definition.applications()) { + const type = targetTypeExtractor(application.parent); + if (!type) { + continue; + } + collectTargetFields({ + parentType: type, + directive: application, + includeInterfaceFieldsImplementations: true, + validate: false, + }).forEach((field) => usedFieldDefs.add(field)); + } +} +function validateAllExternalFieldsUsed(metadata, errorCollector) { + for (const type of metadata.schema.types()) { + if (!(0, definitions_1.isObjectType)(type) && !(0, definitions_1.isInterfaceType)(type)) { + continue; + } + for (const field of type.fields()) { + if (!metadata.isFieldExternal(field) || metadata.isFieldUsed(field)) { + continue; + } + errorCollector.push(error_1.ERRORS.EXTERNAL_UNUSED.err(`Field "${field.coordinate}" is marked @external but is not used in any federation directive (@key, @provides, @requires) or to satisfy an interface;` + + ' the field declaration has no use and should be removed (or the field should not be @external).', { nodes: field.sourceAST })); + } + } +} +function validateNoExternalOnInterfaceFields(metadata, errorCollector) { + for (const itf of metadata.schema.interfaceTypes()) { + for (const field of itf.fields()) { + if (metadata.isFieldExternal(field)) { + errorCollector.push(error_1.ERRORS.EXTERNAL_ON_INTERFACE.err(`Interface type field "${field.coordinate}" is marked @external but @external is not allowed on interface fields (it is nonsensical).`, { nodes: field.sourceAST })); + } + } + } +} +function validateInterfaceRuntimeImplementationFieldsTypes(itf, metadata, errorCollector) { + var _a; + const requiresDirective = (_a = federationMetadata(itf.schema())) === null || _a === void 0 ? void 0 : _a.requiresDirective(); + (0, utils_1.assert)(requiresDirective, 'Schema should be a federation subgraph, but @requires directive not found'); + const runtimeTypes = itf.possibleRuntimeTypes(); + for (const field of itf.fields()) { + const withExternalOrRequires = []; + const typeToImplems = new utils_1.MultiMap(); + const nodes = []; + for (const type of runtimeTypes) { + const implemField = type.field(field.name); + if (!implemField) + continue; + if (implemField.sourceAST) { + nodes.push(implemField.sourceAST); + } + if (metadata.isFieldExternal(implemField) || implemField.hasAppliedDirective(requiresDirective)) { + withExternalOrRequires.push(implemField); + } + const returnType = implemField.type; + typeToImplems.add(returnType.toString(), implemField); + } + if (withExternalOrRequires.length > 0 && typeToImplems.size > 1) { + const typeToImplemsArray = [...typeToImplems.entries()]; + errorCollector.push(error_1.ERRORS.INTERFACE_FIELD_IMPLEM_TYPE_MISMATCH.err(`Some of the runtime implementations of interface field "${field.coordinate}" are marked @external or have a @require (${withExternalOrRequires.map(printFieldCoordinate)}) so all the implementations should use the same type (a current limitation of federation; see https://github.com/apollographql/federation/issues/1257), but ${formatFieldsToReturnType(typeToImplemsArray[0])} while ${(0, utils_1.joinStrings)(typeToImplemsArray.slice(1).map(formatFieldsToReturnType), ' and ')}.`, { nodes })); + } + } +} +const printFieldCoordinate = (f) => `"${f.coordinate}"`; +function formatFieldsToReturnType([type, implems]) { + return `${(0, utils_1.joinStrings)(implems.map(printFieldCoordinate))} ${implems.length == 1 ? 'has' : 'have'} type "${type}"`; +} +class FederationMetadata { + constructor(schema) { + this.schema = schema; + } + onInvalidate() { + this._externalTester = undefined; + this._sharingPredicate = undefined; + this._isFed2Schema = undefined; + this._fieldUsedPredicate = undefined; + } + isFed2Schema() { + if (!this._isFed2Schema) { + const feature = this.federationFeature(); + this._isFed2Schema = !!feature && feature.url.version.satisfies(new coreSpec_1.FeatureVersion(2, 0)); + } + return this._isFed2Schema; + } + federationFeature() { + var _a; + return (_a = this.schema.coreFeatures) === null || _a === void 0 ? void 0 : _a.getByIdentity(federationSpec.identity); + } + externalTester() { + if (!this._externalTester) { + this._externalTester = new ExternalTester(this.schema); + } + return this._externalTester; + } + sharingPredicate() { + if (!this._sharingPredicate) { + this._sharingPredicate = (0, precompute_1.computeShareables)(this.schema); + } + return this._sharingPredicate; + } + fieldUsedPredicate() { + if (!this._fieldUsedPredicate) { + const usedFields = collectUsedFields(this); + this._fieldUsedPredicate = (field) => !!usedFields.has(field); + } + return this._fieldUsedPredicate; + } + isFieldUsed(field) { + return this.fieldUsedPredicate()(field); + } + isFieldExternal(field) { + return this.externalTester().isExternal(field); + } + isFieldPartiallyExternal(field) { + return this.externalTester().isPartiallyExternal(field); + } + isFieldFullyExternal(field) { + return this.externalTester().isFullyExternal(field); + } + isFieldFakeExternal(field) { + return this.externalTester().isFakeExternal(field); + } + selectionSelectsAnyExternalField(selectionSet) { + return this.externalTester().selectsAnyExternalField(selectionSet); + } + isFieldShareable(field) { + return this.sharingPredicate()(field); + } + federationDirectiveNameInSchema(name) { + if (this.isFed2Schema()) { + const coreFeatures = this.schema.coreFeatures; + (0, utils_1.assert)(coreFeatures, 'Schema should be a core schema'); + const federationFeature = coreFeatures.getByIdentity(federationSpec.identity); + (0, utils_1.assert)(federationFeature, 'Schema should have the federation feature'); + return federationFeature.directiveNameInSchema(name); + } + else { + return name; + } + } + federationTypeNameInSchema(name) { + if (name.charAt(0) === '_') { + return name; + } + if (this.isFed2Schema()) { + const coreFeatures = this.schema.coreFeatures; + (0, utils_1.assert)(coreFeatures, 'Schema should be a core schema'); + const federationFeature = coreFeatures.getByIdentity(federationSpec.identity); + (0, utils_1.assert)(federationFeature, 'Schema should have the federation feature'); + return federationFeature.typeNameInSchema(name); + } + else { + return '_' + name; + } + } + getFederationDirective(name) { + const directive = this.schema.directive(this.federationDirectiveNameInSchema(name)); + (0, utils_1.assert)(directive, `The provided schema does not have federation directive @${name}`); + return directive; + } + keyDirective() { + return this.getFederationDirective(federationSpec_1.keyDirectiveSpec.name); + } + overrideDirective() { + return this.getFederationDirective(federationSpec_1.overrideDirectiveSpec.name); + } + extendsDirective() { + return this.getFederationDirective(federationSpec_1.extendsDirectiveSpec.name); + } + externalDirective() { + return this.getFederationDirective(federationSpec_1.externalDirectiveSpec.name); + } + requiresDirective() { + return this.getFederationDirective(federationSpec_1.requiresDirectiveSpec.name); + } + providesDirective() { + return this.getFederationDirective(federationSpec_1.providesDirectiveSpec.name); + } + shareableDirective() { + return this.getFederationDirective(federationSpec_1.shareableDirectiveSpec.name); + } + tagDirective() { + return this.getFederationDirective(tagSpec.tagDirectiveSpec.name); + } + composeDirective() { + return this.getFederationDirective(federationSpec_1.composeDirectiveSpec.name); + } + inaccessibleDirective() { + return this.getFederationDirective(inaccessibleSpec.inaccessibleDirectiveSpec.name); + } + allFederationDirectives() { + const baseDirectives = [ + this.keyDirective(), + this.externalDirective(), + this.requiresDirective(), + this.providesDirective(), + this.tagDirective(), + this.extendsDirective(), + ]; + return this.isFed2Schema() + ? baseDirectives.concat(this.shareableDirective(), this.inaccessibleDirective(), this.overrideDirective(), this.composeDirective()) + : baseDirectives; + } + entityType() { + return this.schema.type(this.federationTypeNameInSchema(exports.entityTypeSpec.name)); + } + anyType() { + return this.schema.type(this.federationTypeNameInSchema(exports.anyTypeSpec.name)); + } + serviceType() { + return this.schema.type(this.federationTypeNameInSchema(exports.serviceTypeSpec.name)); + } + fieldSetType() { + return this.schema.type(this.federationTypeNameInSchema(federationSpec_1.fieldSetTypeSpec.name)); + } + allFederationTypes() { + const baseTypes = [ + this.anyType(), + this.serviceType(), + this.fieldSetType(), + ]; + const entityType = this.entityType(); + if (entityType) { + baseTypes.push(entityType); + } + return baseTypes; + } +} +exports.FederationMetadata = FederationMetadata; +class FederationBlueprint extends definitions_1.SchemaBlueprint { + constructor(withRootTypeRenaming) { + super(); + this.withRootTypeRenaming = withRootTypeRenaming; + } + onAddedCoreFeature(schema, feature) { + super.onAddedCoreFeature(schema, feature); + if (feature.url.identity === federationSpec_1.federationIdentity) { + const spec = federationSpec_1.FEDERATION_VERSIONS.find(feature.url.version); + if (spec) { + spec.addElementsToSchema(schema); + } + } + } + onMissingDirectiveDefinition(schema, name, args) { + if (name === coreSpec_1.linkDirectiveDefaultName) { + const url = args && args['url']; + const as = url && url.startsWith(linkSpec.identity) ? args['as'] : undefined; + const errors = linkSpec.addDefinitionsToSchema(schema, as); + return errors.length > 0 ? errors : schema.directive(name); + } + return super.onMissingDirectiveDefinition(schema, name, args); + } + ignoreParsedField(type, fieldName) { + if (!exports.FEDERATION_OPERATION_FIELDS.includes(fieldName)) { + return false; + } + const metadata = federationMetadata(type.schema()); + return !!metadata && !metadata.isFed2Schema(); + } + onConstructed(schema) { + const existing = federationMetadata(schema); + if (!existing) { + schema['_federationMetadata'] = new FederationMetadata(schema); + } + } + onDirectiveDefinitionAndSchemaParsed(schema) { + const errors = completeSubgraphSchema(schema); + schema.schemaDefinition.processUnappliedDirectives(); + return errors; + } + onInvalidation(schema) { + super.onInvalidation(schema); + const metadata = federationMetadata(schema); + (0, utils_1.assert)(metadata, 'Federation schema should have had its metadata set on construction'); + FederationMetadata.prototype['onInvalidate'].call(metadata); + } + onValidation(schema) { + var _a; + const errorCollector = super.onValidation(schema); + if (this.withRootTypeRenaming) { + for (const k of definitions_1.allSchemaRootKinds) { + const type = (_a = schema.schemaDefinition.root(k)) === null || _a === void 0 ? void 0 : _a.type; + const defaultName = (0, definitions_1.defaultRootName)(k); + if (type && type.name !== defaultName) { + const existing = schema.type(defaultName); + if (existing) { + errorCollector.push(error_1.ERROR_CATEGORIES.ROOT_TYPE_USED.get(k).err(`The schema has a type named "${defaultName}" but it is not set as the ${k} root type ("${type.name}" is instead): ` + + 'this is not supported by federation. ' + + 'If a root type does not use its default name, there should be no other type with that default name.', { nodes: (0, definitions_1.sourceASTs)(type, existing) })); + } + type.rename(defaultName); + } + } + } + const metadata = federationMetadata(schema); + (0, utils_1.assert)(metadata, 'Federation schema should have had its metadata set on construction'); + if (!metadata.isFed2Schema()) { + return errorCollector; + } + const keyDirective = metadata.keyDirective(); + validateAllFieldSet({ + definition: keyDirective, + targetTypeExtractor: type => type, + errorCollector, + metadata, + isOnParentType: true, + allowOnNonExternalLeafFields: true, + onFields: field => { + const type = (0, definitions_1.baseType)(field.type); + if ((0, definitions_1.isUnionType)(type) || (0, definitions_1.isInterfaceType)(type)) { + let kind = type.kind; + kind = kind.slice(0, kind.length - 'Type'.length); + throw error_1.ERRORS.KEY_FIELDS_SELECT_INVALID_TYPE.err(`field "${field.coordinate}" is a ${kind} type which is not allowed in @key`); + } + } + }); + validateAllFieldSet({ + definition: metadata.requiresDirective(), + targetTypeExtractor: field => field.parent, + errorCollector, + metadata, + allowFieldsWithArguments: true, + }); + validateAllFieldSet({ + definition: metadata.providesDirective(), + targetTypeExtractor: field => { + if (metadata.isFieldExternal(field)) { + throw error_1.ERRORS.EXTERNAL_COLLISION_WITH_ANOTHER_DIRECTIVE.err(`Cannot have both @provides and @external on field "${field.coordinate}"`, { nodes: field.sourceAST }); + } + const type = (0, definitions_1.baseType)(field.type); + if (!(0, definitions_1.isCompositeType)(type)) { + throw error_1.ERRORS.PROVIDES_ON_NON_OBJECT_FIELD.err(`Invalid @provides directive on field "${field.coordinate}": field has type "${field.type}" which is not a Composite Type`, { nodes: field.sourceAST }); + } + return type; + }, + errorCollector, + metadata, + }); + validateNoExternalOnInterfaceFields(metadata, errorCollector); + validateAllExternalFieldsUsed(metadata, errorCollector); + const tagDirective = metadata.tagDirective(); + if (tagDirective) { + const error = tagSpec.checkCompatibleDirective(tagDirective); + if (error) { + errorCollector.push(error); + } + } + for (const itf of schema.interfaceTypes()) { + validateInterfaceRuntimeImplementationFieldsTypes(itf, metadata, errorCollector); + } + return errorCollector; + } + validationRules() { + return FEDERATION_VALIDATION_RULES; + } + onUnknownDirectiveValidationError(schema, unknownDirectiveName, error) { + const metadata = federationMetadata(schema); + (0, utils_1.assert)(metadata, `This method should only have been called on a subgraph schema`); + if (federationSpec_1.ALL_FEDERATION_DIRECTIVES_DEFAULT_NAMES.includes(unknownDirectiveName)) { + if (metadata.isFed2Schema()) { + const federationFeature = metadata.federationFeature(); + (0, utils_1.assert)(federationFeature, 'Fed2 subgraph _must_ link to the federation feature'); + const directiveNameInSchema = federationFeature.directiveNameInSchema(unknownDirectiveName); + if (directiveNameInSchema.startsWith(federationFeature.nameInSchema + '__')) { + return (0, error_1.withModifiedErrorMessage)(error, `${error.message} If you meant the "@${unknownDirectiveName}" federation directive, you should use fully-qualified name "@${directiveNameInSchema}" or add "@${unknownDirectiveName}" to the \`import\` argument of the @link to the federation specification.`); + } + else { + return (0, error_1.withModifiedErrorMessage)(error, `${error.message} If you meant the "@${unknownDirectiveName}" federation directive, you should use "@${directiveNameInSchema}" as it is imported under that name in the @link to the federation specification of this schema.`); + } + } + else { + return (0, error_1.withModifiedErrorMessage)(error, `${error.message} If you meant the "@${unknownDirectiveName}" federation 2 directive, note that this schema is a federation 1 schema. To be a federation 2 schema, it needs to @link to the federation specifcation v2.`); + } + } + else if (!metadata.isFed2Schema()) { + const suggestions = (0, suggestions_1.suggestionList)(unknownDirectiveName, federationSpec_1.FEDERATION2_ONLY_SPEC_DIRECTIVES.map((spec) => spec.name)); + if (suggestions.length > 0) { + return (0, error_1.withModifiedErrorMessage)(error, `${error.message}${(0, suggestions_1.didYouMean)(suggestions.map((s) => '@' + s))} If so, note that ${suggestions.length === 1 ? 'it is a federation 2 directive' : 'they are federation 2 directives'} but this schema is a federation 1 one. To be a federation 2 schema, it needs to @link to the federation specifcation v2.`); + } + } + return error; + } + applyDirectivesAfterParsing() { + return true; + } +} +exports.FederationBlueprint = FederationBlueprint; +function findUnusedNamedForLinkDirective(schema) { + if (!schema.directive(linkSpec.url.name)) { + return undefined; + } + const baseName = linkSpec.url.name; + let n = 1; + for (;;) { + const candidate = baseName + n; + if (!schema.directive(candidate)) { + return candidate; + } + } +} +function setSchemaAsFed2Subgraph(schema) { + let core = schema.coreFeatures; + let spec; + if (core) { + spec = core.coreDefinition; + (0, utils_1.assert)(spec.url.version.satisfies(linkSpec.version), `Fed2 schema must use @link with version >= 1.0, but schema uses ${spec.url}`); + } + else { + const alias = findUnusedNamedForLinkDirective(schema); + const errors = linkSpec.addToSchema(schema, alias); + if (errors.length > 0) { + throw (0, definitions_1.ErrGraphQLValidationFailed)(errors); + } + spec = linkSpec; + core = schema.coreFeatures; + (0, utils_1.assert)(core, 'Schema should now be a core schema'); + } + (0, utils_1.assert)(!core.getByIdentity(federationSpec.identity), 'Schema already set as a federation subgraph'); + schema.schemaDefinition.applyDirective(core.coreItself.nameInSchema, { + url: federationSpec.url.toString(), + import: federationSpec_1.FEDERATION2_SPEC_DIRECTIVES.map((spec) => `@${spec.name}`), + }); + const errors = completeSubgraphSchema(schema); + if (errors.length > 0) { + throw (0, definitions_1.ErrGraphQLValidationFailed)(errors); + } +} +exports.setSchemaAsFed2Subgraph = setSchemaAsFed2Subgraph; +exports.FEDERATION2_LINK_WTH_FULL_IMPORTS = '@link(url: "https://specs.apollo.dev/federation/v2.1", import: ["@key", "@requires", "@provides", "@external", "@tag", "@extends", "@shareable", "@inaccessible", "@override", "@composeDirective"])'; +function asFed2SubgraphDocument(document) { + const fed2LinkExtension = { + kind: graphql_1.Kind.SCHEMA_EXTENSION, + directives: [{ + kind: graphql_1.Kind.DIRECTIVE, + name: { kind: graphql_1.Kind.NAME, value: coreSpec_1.linkDirectiveDefaultName }, + arguments: [{ + kind: graphql_1.Kind.ARGUMENT, + name: { kind: graphql_1.Kind.NAME, value: 'url' }, + value: { kind: graphql_1.Kind.STRING, value: federationSpec.url.toString() } + }, + { + kind: graphql_1.Kind.ARGUMENT, + name: { kind: graphql_1.Kind.NAME, value: 'import' }, + value: { kind: graphql_1.Kind.LIST, values: federationSpec_1.FEDERATION2_SPEC_DIRECTIVES.map((spec) => ({ kind: graphql_1.Kind.STRING, value: `@${spec.name}` })) } + }] + }] + }; + return { + kind: graphql_1.Kind.DOCUMENT, + loc: document.loc, + definitions: document.definitions.concat(fed2LinkExtension) + }; +} +exports.asFed2SubgraphDocument = asFed2SubgraphDocument; +function printSubgraphNames(names) { + return (0, utils_1.printHumanReadableList)(names.map(n => `"${n}"`), { + prefix: 'subgraph', + prefixPlural: 'subgraphs', + }); +} +exports.printSubgraphNames = printSubgraphNames; +function federationMetadata(schema) { + return schema['_federationMetadata']; +} +exports.federationMetadata = federationMetadata; +function isFederationSubgraphSchema(schema) { + return !!federationMetadata(schema); +} +exports.isFederationSubgraphSchema = isFederationSubgraphSchema; +function isFederationField(field) { + var _a; + if (field.parent === ((_a = field.schema().schemaDefinition.root("query")) === null || _a === void 0 ? void 0 : _a.type)) { + return exports.FEDERATION_OPERATION_FIELDS.includes(field.name); + } + return false; +} +exports.isFederationField = isFederationField; +function isEntityType(type) { + if (type.kind !== "ObjectType") { + return false; + } + const metadata = federationMetadata(type.schema()); + return !!metadata && type.hasAppliedDirective(metadata.keyDirective()); +} +exports.isEntityType = isEntityType; +function buildSubgraph(name, url, source, withRootTypeRenaming = true) { + const buildOptions = { + blueprint: new FederationBlueprint(withRootTypeRenaming), + validate: false, + }; + let subgraph; + try { + const schema = typeof source === 'string' + ? (0, buildSchema_1.buildSchema)(new graphql_1.Source(source, name), buildOptions) + : (0, buildSchema_1.buildSchemaFromAST)(source, buildOptions); + subgraph = new Subgraph(name, url, schema); + } + catch (e) { + if (e instanceof graphql_1.GraphQLError && name !== exports.FEDERATION_UNNAMED_SUBGRAPH_NAME) { + throw addSubgraphToError(e, name, error_1.ERRORS.INVALID_GRAPHQL); + } + else { + throw e; + } + } + return subgraph.validate(); +} +exports.buildSubgraph = buildSubgraph; +function newEmptyFederation2Schema(config) { + const schema = new definitions_1.Schema(new FederationBlueprint(true), config); + setSchemaAsFed2Subgraph(schema); + return schema; +} +exports.newEmptyFederation2Schema = newEmptyFederation2Schema; +function completeSubgraphSchema(schema) { + const coreFeatures = schema.coreFeatures; + if (coreFeatures) { + const fedFeature = coreFeatures.getByIdentity(federationSpec_1.federationIdentity); + if (fedFeature) { + return completeFed2SubgraphSchema(schema); + } + else { + return completeFed1SubgraphSchema(schema); + } + } + else { + const fedLink = schema.schemaDefinition.appliedDirectivesOf(coreSpec_1.linkDirectiveDefaultName).find(isFedSpecLinkDirective); + if (fedLink) { + const errors = linkSpec.addToSchema(schema); + if (errors.length > 0) { + return errors; + } + return completeFed2SubgraphSchema(schema); + } + else { + return completeFed1SubgraphSchema(schema); + } + } +} +function isFedSpecLinkDirective(directive) { + const args = directive.arguments(); + return directive.name === coreSpec_1.linkDirectiveDefaultName && args['url'] && args['url'].startsWith(federationSpec_1.federationIdentity); +} +function completeFed1SubgraphSchema(schema) { + var _a, _b; + for (const spec of [federationSpec_1.keyDirectiveSpec, federationSpec_1.providesDirectiveSpec, federationSpec_1.requiresDirectiveSpec]) { + const directive = schema.directive(spec.name); + if (!directive) { + continue; + } + (0, utils_1.assert)(directive.applications().length === 0, `${directive} shouldn't have had validation at that places`); + const fieldType = (_b = (_a = directive.argument('fields')) === null || _a === void 0 ? void 0 : _a.type) === null || _b === void 0 ? void 0 : _b.toString(); + const fieldTypeIsWrongInKnownWays = !!fieldType + && directive.arguments().length === 1 + && (fieldType === 'String' || fieldType === '_FieldSet' || fieldType === 'FieldSet'); + if (directive.arguments().length === 0 || fieldTypeIsWrongInKnownWays) { + directive.remove(); + } + } + return [ + federationSpec_1.fieldSetTypeSpec.checkOrAdd(schema, '_' + federationSpec_1.fieldSetTypeSpec.name), + federationSpec_1.keyDirectiveSpec.checkOrAdd(schema), + federationSpec_1.requiresDirectiveSpec.checkOrAdd(schema), + federationSpec_1.providesDirectiveSpec.checkOrAdd(schema), + federationSpec_1.extendsDirectiveSpec.checkOrAdd(schema), + federationSpec_1.externalDirectiveSpec.checkOrAdd(schema), + tagSpec.tagDirectiveSpec.checkOrAdd(schema), + ].flat(); +} +function completeFed2SubgraphSchema(schema) { + const coreFeatures = schema.coreFeatures; + (0, utils_1.assert)(coreFeatures, 'This method should not have been called on a non-core schema'); + const fedFeature = coreFeatures.getByIdentity(federationSpec_1.federationIdentity); + (0, utils_1.assert)(fedFeature, 'This method should not have been called on a schema with no @link for federation'); + const spec = federationSpec_1.FEDERATION_VERSIONS.find(fedFeature.url.version); + if (!spec) { + return [error_1.ERRORS.UNKNOWN_FEDERATION_LINK_VERSION.err(`Invalid version ${fedFeature.url.version} for the federation feature in @link direction on schema`, { nodes: fedFeature.directive.sourceAST })]; + } + return spec.addElementsToSchema(schema); +} +function parseFieldSetArgument({ parentType, directive, fieldAccessor, validate, decorateValidationErrors = true, }) { + try { + const selectionSet = (0, operations_1.parseSelectionSet)({ + parentType, + source: validateFieldSetValue(directive), + fieldAccessor, + validate, + }); + if (validate !== null && validate !== void 0 ? validate : true) { + selectionSet.forEachElement((elt) => { + if (elt.kind === 'Field' && elt.alias) { + throw new graphql_1.GraphQLError(`Cannot use alias "${elt.alias}" in "${elt}": aliases are not currently supported in @${directive.name}`); + } + }); + } + return selectionSet; + } + catch (e) { + if (!(e instanceof graphql_1.GraphQLError) || !decorateValidationErrors) { + throw e; + } + throw handleFieldSetValidationError(directive, e, (msg) => { + if (msg.startsWith('Cannot query field')) { + if (msg.endsWith('.')) { + msg = msg.slice(0, msg.length - 1); + } + if (directive.name === federationSpec_1.keyDirectiveSpec.name) { + msg = msg + ' (the field should either be added to this subgraph or, if it should not be resolved by this subgraph, you need to add it to this subgraph with @external).'; + } + else { + msg = msg + ' (if the field is defined in another subgraph, you need to add it to this subgraph with @external).'; + } + } + return msg; + }); + } +} +exports.parseFieldSetArgument = parseFieldSetArgument; +function collectTargetFields({ parentType, directive, includeInterfaceFieldsImplementations, validate = true, }) { + const fields = []; + try { + parseFieldSetArgument({ + parentType, + directive, + fieldAccessor: (t, f) => { + const field = t.field(f); + if (field) { + fields.push(field); + if (includeInterfaceFieldsImplementations && (0, definitions_1.isInterfaceType)(t)) { + for (const implType of t.possibleRuntimeTypes()) { + const implField = implType.field(f); + if (implField) { + fields.push(implField); + } + } + } + } + return field; + }, + validate, + }); + } + catch (e) { + const isGraphQLError = (0, error_1.errorCauses)(e) !== undefined; + if (!isGraphQLError || validate) { + throw e; + } + } + return fields; +} +exports.collectTargetFields = collectTargetFields; +function validateFieldSetValue(directive) { + var _a; + const fields = directive.arguments().fields; + const nodes = directive.sourceAST; + if (typeof fields !== 'string') { + throw error_1.ERROR_CATEGORIES.DIRECTIVE_INVALID_FIELDS_TYPE.get(directive.name).err(`Invalid value for argument "${directive.definition.argument('fields').name}": must be a string.`, { nodes }); + } + if (nodes && nodes.kind === 'Directive') { + for (const argNode of (_a = nodes.arguments) !== null && _a !== void 0 ? _a : []) { + if (argNode.name.value === 'fields') { + if (argNode.value.kind !== 'StringValue') { + throw error_1.ERROR_CATEGORIES.DIRECTIVE_INVALID_FIELDS_TYPE.get(directive.name).err(`Invalid value for argument "${directive.definition.argument('fields').name}": must be a string.`, { nodes }); + } + break; + } + } + } + return fields; +} +function subgraphsFromServiceList(serviceList) { + var _a; + let errors = []; + const subgraphs = new Subgraphs(); + for (const service of serviceList) { + try { + subgraphs.add(buildSubgraph(service.name, (_a = service.url) !== null && _a !== void 0 ? _a : '', service.typeDefs)); + } + catch (e) { + const causes = (0, error_1.errorCauses)(e); + if (causes) { + errors = errors.concat(causes); + } + else { + throw e; + } + } + } + return errors.length === 0 ? subgraphs : errors; +} +exports.subgraphsFromServiceList = subgraphsFromServiceList; +class Subgraphs { + constructor() { + this.subgraphs = new utils_1.OrderedMap(); + } + add(subgraph) { + if (this.subgraphs.has(subgraph.name)) { + throw new Error(`A subgraph named ${subgraph.name} already exists` + (subgraph.url ? ` (with url '${subgraph.url}')` : '')); + } + this.subgraphs.add(subgraph.name, subgraph); + return subgraph; + } + get(name) { + return this.subgraphs.get(name); + } + size() { + return this.subgraphs.size; + } + names() { + return this.subgraphs.keys(); + } + values() { + return this.subgraphs.values(); + } + *[Symbol.iterator]() { + for (const subgraph of this.subgraphs) { + yield subgraph; + } + } + validate() { + let errors = []; + for (const subgraph of this.values()) { + try { + subgraph.validate(); + } + catch (e) { + const causes = (0, error_1.errorCauses)(e); + if (!causes) { + throw e; + } + errors = errors.concat(causes); + } + } + return errors.length === 0 ? undefined : errors; + } + toString() { + return '[' + this.subgraphs.keys().join(', ') + ']'; + } +} +exports.Subgraphs = Subgraphs; +exports.anyTypeSpec = (0, directiveAndTypeSpecification_1.createScalarTypeSpecification)({ name: '_Any' }); +exports.serviceTypeSpec = (0, directiveAndTypeSpecification_1.createObjectTypeSpecification)({ + name: '_Service', + fieldsFct: (schema) => [{ name: 'sdl', type: schema.stringType() }], +}); +exports.entityTypeSpec = (0, directiveAndTypeSpecification_1.createUnionTypeSpecification)({ + name: '_Entity', + membersFct: (schema) => { + return schema.objectTypes().filter(isEntityType).map((t) => t.name); + }, +}); +exports.FEDERATION_OPERATION_TYPES = [exports.anyTypeSpec, exports.serviceTypeSpec, exports.entityTypeSpec]; +exports.serviceFieldName = '_service'; +exports.entitiesFieldName = '_entities'; +exports.FEDERATION_OPERATION_FIELDS = [exports.serviceFieldName, exports.entitiesFieldName]; +class Subgraph { + constructor(name, url, schema) { + this.name = name; + this.url = url; + this.schema = schema; + if (name === exports.FEDERATION_RESERVED_SUBGRAPH_NAME) { + throw error_1.ERRORS.INVALID_SUBGRAPH_NAME.err(`Invalid name ${exports.FEDERATION_RESERVED_SUBGRAPH_NAME} for a subgraph: this name is reserved`); + } + } + metadata() { + const metadata = federationMetadata(this.schema); + (0, utils_1.assert)(metadata, 'The subgraph schema should have built with the federation built-ins.'); + return metadata; + } + isFed2Subgraph() { + return this.metadata().isFed2Schema(); + } + addFederationOperations() { + const metadata = this.metadata(); + for (const type of exports.FEDERATION_OPERATION_TYPES) { + type.checkOrAdd(this.schema); + } + const queryRoot = this.schema.schemaDefinition.root("query"); + const queryType = queryRoot ? queryRoot.type : this.schema.addType(new definitions_1.ObjectType("Query")); + const entityField = queryType.field(exports.entitiesFieldName); + const entityType = metadata.entityType(); + if (entityType) { + const entityFieldType = new definitions_1.NonNullType(new definitions_1.ListType(entityType)); + if (!entityField) { + queryType.addField(exports.entitiesFieldName, entityFieldType) + .addArgument('representations', new definitions_1.NonNullType(new definitions_1.ListType(new definitions_1.NonNullType(metadata.anyType())))); + } + else if (!entityField.type) { + entityField.type = entityType; + } + } + else if (entityField) { + entityField.remove(); + } + if (!queryType.field(exports.serviceFieldName)) { + queryType.addField(exports.serviceFieldName, new definitions_1.NonNullType(metadata.serviceType())); + } + } + validate() { + try { + this.addFederationOperations(); + this.schema.validate(); + return this; + } + catch (e) { + if (e instanceof graphql_1.GraphQLError) { + throw addSubgraphToError(e, this.name, error_1.ERRORS.INVALID_GRAPHQL); + } + else { + throw e; + } + } + } + isPrintedDirective(d) { + var _a; + if (this.metadata().allFederationDirectives().includes(d)) { + return false; + } + const core = this.schema.coreFeatures; + return !core || ((_a = core.sourceFeature(d)) === null || _a === void 0 ? void 0 : _a.feature.url.identity) !== coreSpec_1.linkIdentity; + } + isPrintedType(t) { + var _a; + if (this.metadata().allFederationTypes().includes(t)) { + return false; + } + if ((0, definitions_1.isObjectType)(t) && t.isQueryRootType() && t.fields().filter((f) => !isFederationField(f)).length === 0) { + return false; + } + const core = this.schema.coreFeatures; + return !core || ((_a = core.sourceFeature(t)) === null || _a === void 0 ? void 0 : _a.feature.url.identity) !== coreSpec_1.linkIdentity; + } + isPrintedDirectiveApplication(d) { + if (!this.schema.coreFeatures || d.name !== linkSpec.url.name) { + return true; + } + const args = d.arguments(); + let urlArg = undefined; + if ('url' in args) { + try { + urlArg = coreSpec_1.FeatureUrl.parse(args['url']); + } + catch (e) { + } + } + const isDefaultLinkToLink = (urlArg === null || urlArg === void 0 ? void 0 : urlArg.identity) === coreSpec_1.linkIdentity && Object.keys(args).length === 1; + return !isDefaultLinkToLink; + } + toString(basePrintOptions = print_1.defaultPrintOptions) { + return (0, print_1.printSchema)(this.schema, { + ...basePrintOptions, + directiveDefinitionFilter: (d) => this.isPrintedDirective(d), + typeFilter: (t) => this.isPrintedType(t), + fieldFilter: (f) => !isFederationField(f), + directiveApplicationFilter: (d) => this.isPrintedDirectiveApplication(d), + }); + } +} +exports.Subgraph = Subgraph; +function addSubgraphToASTNode(node, subgraph) { + if ('subgraph' in node) { + return node; + } + return { + ...node, + subgraph + }; +} +exports.addSubgraphToASTNode = addSubgraphToASTNode; +function addSubgraphToError(e, subgraphName, errorCode) { + const updatedCauses = (0, error_1.errorCauses)(e).map(cause => { + var _a; + const message = `[${subgraphName}] ${cause.message}`; + const nodes = cause.nodes + ? cause.nodes.map(node => addSubgraphToASTNode(node, subgraphName)) + : undefined; + const code = (_a = (0, error_1.errorCodeDef)(cause)) !== null && _a !== void 0 ? _a : errorCode; + const options = { + ...(0, error_1.extractGraphQLErrorOptions)(cause), + nodes, + originalError: cause, + }; + return code + ? code.err(message, options) + : new graphql_1.GraphQLError(message, options); + }); + return updatedCauses.length === 1 ? updatedCauses[0] : (0, definitions_1.ErrGraphQLValidationFailed)(updatedCauses); +} +exports.addSubgraphToError = addSubgraphToError; +class ExternalTester { + constructor(schema) { + this.schema = schema; + this.fakeExternalFields = new Set(); + this.providedFields = new Set(); + this.externalDirective = this.metadata().externalDirective(); + this.collectFakeExternals(); + this.collectProvidedFields(); + } + metadata() { + const metadata = federationMetadata(this.schema); + (0, utils_1.assert)(metadata, 'Schema should be a subgraphs schema'); + return metadata; + } + collectFakeExternals() { + const metadata = this.metadata(); + const extendsDirective = metadata.extendsDirective(); + for (const key of metadata.keyDirective().applications()) { + const parentType = key.parent; + if (!(key.ofExtension() || parentType.hasAppliedDirective(extendsDirective))) { + continue; + } + collectTargetFields({ + parentType, + directive: key, + includeInterfaceFieldsImplementations: false, + validate: false, + }).filter((field) => field.hasAppliedDirective(this.externalDirective)) + .forEach((field) => this.fakeExternalFields.add(field.coordinate)); + } + } + collectProvidedFields() { + for (const provides of this.metadata().providesDirective().applications()) { + const parent = provides.parent; + collectTargetFields({ + parentType: (0, definitions_1.baseType)(parent.type), + directive: provides, + includeInterfaceFieldsImplementations: true, + validate: false, + }).forEach((f) => this.providedFields.add(f.coordinate)); + } + } + isExternal(field) { + return field.hasAppliedDirective(this.externalDirective) && !this.isFakeExternal(field); + } + isFakeExternal(field) { + return this.fakeExternalFields.has(field.coordinate); + } + selectsAnyExternalField(selectionSet) { + for (const selection of selectionSet.selections()) { + if (selection.kind === 'FieldSelection' && this.isExternal(selection.element().definition)) { + return true; + } + if (selection.selectionSet) { + if (this.selectsAnyExternalField(selection.selectionSet)) { + return true; + } + } + } + return false; + } + isPartiallyExternal(field) { + return this.isExternal(field) && this.providedFields.has(field.coordinate); + } + isFullyExternal(field) { + return this.isExternal(field) && !this.providedFields.has(field.coordinate); + } +} +function removeInactiveProvidesAndRequires(schema, onModified = () => { }) { + const metadata = federationMetadata(schema); + if (!metadata) { + return; + } + const providesDirective = metadata.providesDirective(); + const requiresDirective = metadata.requiresDirective(); + for (const type of schema.types()) { + if (!(0, definitions_1.isObjectType)(type) && !(0, definitions_1.isInterfaceType)(type)) { + continue; + } + for (const field of type.fields()) { + const fieldBaseType = (0, definitions_1.baseType)(field.type); + removeInactiveApplications(providesDirective, field, fieldBaseType, onModified); + removeInactiveApplications(requiresDirective, field, type, onModified); + } + } +} +exports.removeInactiveProvidesAndRequires = removeInactiveProvidesAndRequires; +function removeInactiveApplications(directiveDefinition, field, parentType, onModified) { + for (const application of field.appliedDirectivesOf(directiveDefinition)) { + let selection; + try { + selection = parseFieldSetArgument({ parentType, directive: application }); + } + catch (e) { + continue; + } + if (selectsNonExternalLeafField(selection)) { + application.remove(); + const updated = withoutNonExternalLeafFields(selection); + if (!updated.isEmpty()) { + const updatedDirective = field.applyDirective(directiveDefinition, { fields: updated.toString(true, false) }); + onModified(field, application, updatedDirective); + } + else { + onModified(field, application); + } + } + } +} +function isExternalOrHasExternalImplementations(field) { + const metadata = federationMetadata(field.schema()); + if (!metadata) { + return false; + } + if (field.hasAppliedDirective(metadata.externalDirective())) { + return true; + } + const parentType = field.parent; + if ((0, definitions_1.isInterfaceType)(parentType)) { + for (const implem of parentType.possibleRuntimeTypes()) { + const fieldInImplem = implem.field(field.name); + if (fieldInImplem && fieldInImplem.hasAppliedDirective(metadata.externalDirective())) { + return true; + } + } + } + return false; +} +function selectsNonExternalLeafField(selection) { + return selection.selections().some(s => { + if (s.kind === 'FieldSelection') { + if (isExternalOrHasExternalImplementations(s.field.definition)) { + return false; + } + return !s.selectionSet || selectsNonExternalLeafField(s.selectionSet); + } + else { + return selectsNonExternalLeafField(s.selectionSet); + } + }); +} +function withoutNonExternalLeafFields(selectionSet) { + const newSelectionSet = new operations_1.SelectionSet(selectionSet.parentType); + for (const selection of selectionSet.selections()) { + if (selection.kind === 'FieldSelection') { + if (isExternalOrHasExternalImplementations(selection.field.definition)) { + newSelectionSet.add(selection); + continue; + } + } + if (selection.selectionSet) { + const updated = withoutNonExternalLeafFields(selection.selectionSet); + if (!updated.isEmpty()) { + newSelectionSet.add((0, operations_1.selectionOfElement)(selection.element(), updated)); + } + } + } + return newSelectionSet; +} +//# sourceMappingURL=federation.js.map + +/***/ }), + +/***/ 9480: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.FEDERATION_VERSIONS = exports.FederationSpecDefinition = exports.FEDERATION_SPEC_TYPES = exports.ALL_FEDERATION_DIRECTIVES_DEFAULT_NAMES = exports.FEDERATION2_SPEC_DIRECTIVES = exports.FEDERATION2_1_ONLY_SPEC_DIRECTIVES = exports.FEDERATION2_ONLY_SPEC_DIRECTIVES = exports.composeDirectiveSpec = exports.overrideDirectiveSpec = exports.shareableDirectiveSpec = exports.providesDirectiveSpec = exports.requiresDirectiveSpec = exports.externalDirectiveSpec = exports.extendsDirectiveSpec = exports.keyDirectiveSpec = exports.fieldSetTypeSpec = exports.federationIdentity = void 0; +const definitions_1 = __webpack_require__(4177); +const coreSpec_1 = __webpack_require__(9209); +const directiveAndTypeSpecification_1 = __webpack_require__(3208); +const graphql_1 = __webpack_require__(8929); +const utils_1 = __webpack_require__(9724); +const tagSpec_1 = __webpack_require__(1697); +const federation_1 = __webpack_require__(4408); +const knownCoreFeatures_1 = __webpack_require__(5848); +const inaccessibleSpec_1 = __webpack_require__(5322); +exports.federationIdentity = 'https://specs.apollo.dev/federation'; +exports.fieldSetTypeSpec = (0, directiveAndTypeSpecification_1.createScalarTypeSpecification)({ name: 'FieldSet' }); +exports.keyDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'key', + locations: [graphql_1.DirectiveLocation.OBJECT, graphql_1.DirectiveLocation.INTERFACE], + repeatable: true, + argumentFct: (schema) => ({ + args: [ + fieldsArgument(schema), + { name: 'resolvable', type: schema.booleanType(), defaultValue: true }, + ], + errors: [], + }), +}); +exports.extendsDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'extends', + locations: [graphql_1.DirectiveLocation.OBJECT, graphql_1.DirectiveLocation.INTERFACE], +}); +exports.externalDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'external', + locations: [graphql_1.DirectiveLocation.OBJECT, graphql_1.DirectiveLocation.FIELD_DEFINITION], + argumentFct: (schema) => ({ + args: [{ name: 'reason', type: schema.stringType() }], + errors: [], + }), +}); +exports.requiresDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'requires', + locations: [graphql_1.DirectiveLocation.FIELD_DEFINITION], + argumentFct: (schema) => ({ + args: [fieldsArgument(schema)], + errors: [], + }), +}); +exports.providesDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'provides', + locations: [graphql_1.DirectiveLocation.FIELD_DEFINITION], + argumentFct: (schema) => ({ + args: [fieldsArgument(schema)], + errors: [], + }), +}); +exports.shareableDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'shareable', + locations: [graphql_1.DirectiveLocation.OBJECT, graphql_1.DirectiveLocation.FIELD_DEFINITION], +}); +exports.overrideDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'override', + locations: [graphql_1.DirectiveLocation.FIELD_DEFINITION], + argumentFct: (schema) => ({ + args: [{ name: 'from', type: new definitions_1.NonNullType(schema.stringType()) }], + errors: [], + }), +}); +exports.composeDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'composeDirective', + locations: [graphql_1.DirectiveLocation.SCHEMA], + repeatable: true, + argumentFct: (schema) => ({ + args: [{ name: 'name', type: schema.stringType() }], + errors: [], + }), +}); +function fieldsArgument(schema) { + return { name: 'fields', type: fieldSetType(schema) }; +} +function fieldSetType(schema) { + const metadata = (0, federation_1.federationMetadata)(schema); + (0, utils_1.assert)(metadata, `The schema is not a federation subgraph`); + return new definitions_1.NonNullType(metadata.fieldSetType()); +} +exports.FEDERATION2_ONLY_SPEC_DIRECTIVES = [ + exports.shareableDirectiveSpec, + inaccessibleSpec_1.INACCESSIBLE_VERSIONS.latest().inaccessibleDirectiveSpec, + exports.overrideDirectiveSpec, +]; +exports.FEDERATION2_1_ONLY_SPEC_DIRECTIVES = [ + exports.composeDirectiveSpec, +]; +const PRE_FEDERATION2_SPEC_DIRECTIVES = [ + exports.keyDirectiveSpec, + exports.requiresDirectiveSpec, + exports.providesDirectiveSpec, + exports.externalDirectiveSpec, + tagSpec_1.TAG_VERSIONS.latest().tagDirectiveSpec, + exports.extendsDirectiveSpec, +]; +exports.FEDERATION2_SPEC_DIRECTIVES = [ + ...PRE_FEDERATION2_SPEC_DIRECTIVES, + ...exports.FEDERATION2_ONLY_SPEC_DIRECTIVES, + ...exports.FEDERATION2_1_ONLY_SPEC_DIRECTIVES, +]; +exports.ALL_FEDERATION_DIRECTIVES_DEFAULT_NAMES = exports.FEDERATION2_SPEC_DIRECTIVES.map((spec) => spec.name); +exports.FEDERATION_SPEC_TYPES = [ + exports.fieldSetTypeSpec, +]; +class FederationSpecDefinition extends coreSpec_1.FeatureDefinition { + constructor(version) { + super(new coreSpec_1.FeatureUrl(exports.federationIdentity, 'federation', version)); + } + allFedDirectives() { + return PRE_FEDERATION2_SPEC_DIRECTIVES + .concat(exports.FEDERATION2_ONLY_SPEC_DIRECTIVES) + .concat(this.url.version >= (new coreSpec_1.FeatureVersion(2, 1)) ? exports.FEDERATION2_1_ONLY_SPEC_DIRECTIVES : []); + } + addElementsToSchema(schema) { + const feature = this.featureInSchema(schema); + (0, utils_1.assert)(feature, 'The federation specification should have been added to the schema before this is called'); + let errors = []; + errors = errors.concat(this.addTypeSpec(schema, exports.fieldSetTypeSpec)); + for (const directive of this.allFedDirectives()) { + errors = errors.concat(this.addDirectiveSpec(schema, directive)); + } + return errors; + } + allElementNames() { + return this.allFedDirectives().map((spec) => `@${spec.name}`).concat([ + exports.fieldSetTypeSpec.name, + ]); + } +} +exports.FederationSpecDefinition = FederationSpecDefinition; +exports.FEDERATION_VERSIONS = new coreSpec_1.FeatureDefinitions(exports.federationIdentity) + .add(new FederationSpecDefinition(new coreSpec_1.FeatureVersion(2, 0))) + .add(new FederationSpecDefinition(new coreSpec_1.FeatureVersion(2, 1))); +(0, knownCoreFeatures_1.registerKnownFeature)(exports.FEDERATION_VERSIONS); +//# sourceMappingURL=federationSpec.js.map + +/***/ }), + +/***/ 9535: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.graphQLJSDirectiveToAST = exports.graphQLJSNamedTypeToAST = exports.graphQLJSSchemaToAST = void 0; +const graphql_1 = __webpack_require__(8929); +const definitions_1 = __webpack_require__(4177); +const allOperationTypeNode = [graphql_1.OperationTypeNode.QUERY, graphql_1.OperationTypeNode.MUTATION, graphql_1.OperationTypeNode.SUBSCRIPTION]; +function graphQLJSSchemaToAST(schema) { + const types = Object.values(schema.getTypeMap()).filter((type) => !(0, graphql_1.isIntrospectionType)(type) && !(0, graphql_1.isSpecifiedScalarType)(type)); + const directives = schema.getDirectives().filter((directive) => !(0, graphql_1.isSpecifiedDirective)(directive)); + const schemaASTs = toNodeArray(graphQLJSSchemaToSchemaDefinitionAST(schema)); + const typesASTs = types.map((type) => toNodeArray(graphQLJSNamedTypeToAST(type))).flat(); + const directivesASTs = directives.map((directive) => graphQLJSDirectiveToAST(directive)); + return { + kind: graphql_1.Kind.DOCUMENT, + definitions: [...schemaASTs, ...typesASTs, ...directivesASTs], + }; +} +exports.graphQLJSSchemaToAST = graphQLJSSchemaToAST; +function toNodeArray({ definition, extensions, }) { + return definition ? [definition, ...extensions] : extensions; +} +function maybe(v) { + return v ? v : undefined; +} +function graphQLJSSchemaToSchemaDefinitionAST(schema) { + if (schema.astNode || schema.extensionASTNodes.length > 0) { + return { + definition: maybe(schema.astNode), + extensions: schema.extensionASTNodes, + }; + } + else { + let definition = undefined; + if (hasNonDefaultRootNames(schema)) { + const operationTypes = []; + for (const operation of allOperationTypeNode) { + const type = schema.getRootType(operation); + if (type) { + operationTypes.push({ + kind: graphql_1.Kind.OPERATION_TYPE_DEFINITION, + operation, + type: { kind: graphql_1.Kind.NAMED_TYPE, name: { kind: graphql_1.Kind.NAME, value: type.name } }, + }); + } + } + definition = { + kind: graphql_1.Kind.SCHEMA_DEFINITION, + description: schema.description ? { + kind: graphql_1.Kind.STRING, + value: schema.description, + } : undefined, + operationTypes, + }; + } + return { + definition, + extensions: [], + }; + } +} +function hasNonDefaultRootNames(schema) { + return allOperationTypeNode.some((t) => isNonDefaultRootName(schema.getRootType(t), t)); +} +function isNonDefaultRootName(type, operation) { + return !!type && type.name !== (0, definitions_1.defaultRootName)(operation); +} +function graphQLJSNamedTypeToAST(type) { + if (type.astNode || type.extensionASTNodes.length > 0) { + return { + definition: maybe(type.astNode), + extensions: type.extensionASTNodes, + }; + } + else { + return { + definition: (0, graphql_1.parse)((0, graphql_1.printType)(type)).definitions[0], + extensions: [], + }; + } +} +exports.graphQLJSNamedTypeToAST = graphQLJSNamedTypeToAST; +function graphQLJSDirectiveToAST(directive) { + if (directive.astNode) { + return directive.astNode; + } + else { + const fakeSchema = new graphql_1.GraphQLSchema({ + directives: [directive], + assumeValid: true, + }); + const reparsed = (0, graphql_1.parse)((0, graphql_1.printSchema)(fakeSchema)); + return reparsed.definitions.find((def) => def.kind === graphql_1.Kind.DIRECTIVE_DEFINITION); + } +} +exports.graphQLJSDirectiveToAST = graphQLJSDirectiveToAST; +//# sourceMappingURL=graphQLJSSchemaToAST.js.map + +/***/ }), + +/***/ 5322: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.removeInaccessibleElements = exports.INACCESSIBLE_VERSIONS = exports.InaccessibleSpecDefinition = exports.inaccessibleIdentity = void 0; +const coreSpec_1 = __webpack_require__(9209); +const definitions_1 = __webpack_require__(4177); +const graphql_1 = __webpack_require__(8929); +const knownCoreFeatures_1 = __webpack_require__(5848); +const error_1 = __webpack_require__(8116); +const directiveAndTypeSpecification_1 = __webpack_require__(3208); +const utils_1 = __webpack_require__(9724); +exports.inaccessibleIdentity = 'https://specs.apollo.dev/inaccessible'; +class InaccessibleSpecDefinition extends coreSpec_1.FeatureDefinition { + constructor(version) { + super(new coreSpec_1.FeatureUrl(exports.inaccessibleIdentity, 'inaccessible', version)); + this.inaccessibleLocations = [ + graphql_1.DirectiveLocation.FIELD_DEFINITION, + graphql_1.DirectiveLocation.OBJECT, + graphql_1.DirectiveLocation.INTERFACE, + graphql_1.DirectiveLocation.UNION, + ]; + this.printedInaccessibleDefinition = 'directive @inaccessible on FIELD_DEFINITION | INTERFACE | OBJECT | UNION'; + if (!this.isV01()) { + this.inaccessibleLocations.push(graphql_1.DirectiveLocation.ARGUMENT_DEFINITION, graphql_1.DirectiveLocation.SCALAR, graphql_1.DirectiveLocation.ENUM, graphql_1.DirectiveLocation.ENUM_VALUE, graphql_1.DirectiveLocation.INPUT_OBJECT, graphql_1.DirectiveLocation.INPUT_FIELD_DEFINITION); + this.printedInaccessibleDefinition = 'directive @inaccessible on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION'; + } + this.inaccessibleDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'inaccessible', + locations: this.inaccessibleLocations, + }); + } + isV01() { + return this.version.equals(new coreSpec_1.FeatureVersion(0, 1)); + } + addElementsToSchema(schema) { + return this.addDirectiveSpec(schema, this.inaccessibleDirectiveSpec); + } + inaccessibleDirective(schema) { + return this.directive(schema, 'inaccessible'); + } + checkCompatibleDirective(definition) { + const hasUnknownArguments = Object.keys(definition.arguments()).length > 0; + const hasRepeatable = definition.repeatable; + const hasValidLocations = definition.locations.every(loc => this.inaccessibleLocations.includes(loc)); + if (hasUnknownArguments || hasRepeatable || !hasValidLocations) { + return error_1.ERRORS.DIRECTIVE_DEFINITION_INVALID.err(`Found invalid @inaccessible directive definition. Please ensure the directive definition in your schema's definitions matches the following:\n\t${this.printedInaccessibleDefinition}`); + } + return undefined; + } + allElementNames() { + return ['@inaccessible']; + } + get defaultCorePurpose() { + return 'SECURITY'; + } +} +exports.InaccessibleSpecDefinition = InaccessibleSpecDefinition; +exports.INACCESSIBLE_VERSIONS = new coreSpec_1.FeatureDefinitions(exports.inaccessibleIdentity) + .add(new InaccessibleSpecDefinition(new coreSpec_1.FeatureVersion(0, 1))) + .add(new InaccessibleSpecDefinition(new coreSpec_1.FeatureVersion(0, 2))); +(0, knownCoreFeatures_1.registerKnownFeature)(exports.INACCESSIBLE_VERSIONS); +function removeInaccessibleElements(schema) { + schema.validate(); + const coreFeatures = schema.coreFeatures; + if (!coreFeatures) { + return; + } + const inaccessibleFeature = coreFeatures.getByIdentity(exports.inaccessibleIdentity); + if (!inaccessibleFeature) { + return; + } + const inaccessibleSpec = exports.INACCESSIBLE_VERSIONS.find(inaccessibleFeature.url.version); + if (!inaccessibleSpec) { + throw (0, definitions_1.ErrGraphQLAPISchemaValidationFailed)([new graphql_1.GraphQLError(`Cannot remove inaccessible elements: the schema uses unsupported` + + ` inaccessible spec version ${inaccessibleFeature.url.version}` + + ` (supported versions: ${exports.INACCESSIBLE_VERSIONS.versions().join(', ')})`)]); + } + const inaccessibleDirective = inaccessibleSpec.inaccessibleDirective(schema); + if (!inaccessibleDirective) { + throw (0, definitions_1.ErrGraphQLAPISchemaValidationFailed)([new graphql_1.GraphQLError(`Invalid schema: declares ${inaccessibleSpec.url} spec but does not` + + ` define a @inaccessible directive.`)]); + } + const incompatibleError = inaccessibleSpec.checkCompatibleDirective(inaccessibleDirective); + if (incompatibleError) { + throw (0, definitions_1.ErrGraphQLAPISchemaValidationFailed)([incompatibleError]); + } + validateInaccessibleElements(schema, coreFeatures, inaccessibleSpec, inaccessibleDirective); + removeInaccessibleElementsAssumingValid(schema, inaccessibleDirective); +} +exports.removeInaccessibleElements = removeInaccessibleElements; +function validateInaccessibleElements(schema, coreFeatures, inaccessibleSpec, inaccessibleDirective) { + var _a, _b, _c; + function isInaccessible(element) { + return element.hasAppliedDirective(inaccessibleDirective); + } + const featureList = [...coreFeatures.allFeatures()]; + function isFeatureDefinition(element) { + return featureList.some((feature) => feature.isFeatureDefinition(element)); + } + function isInAPISchema(element) { + if (!(element instanceof definitions_1.DirectiveDefinition) && + isInaccessible(element)) + return false; + if ((element instanceof definitions_1.ObjectType) || + (element instanceof definitions_1.InterfaceType) || + (element instanceof definitions_1.UnionType) || + (element instanceof definitions_1.ScalarType) || + (element instanceof definitions_1.EnumType) || + (element instanceof definitions_1.InputObjectType) || + (element instanceof definitions_1.DirectiveDefinition)) { + return true; + } + else if ((element instanceof definitions_1.FieldDefinition) || + (element instanceof definitions_1.ArgumentDefinition) || + (element instanceof definitions_1.InputFieldDefinition) || + (element instanceof definitions_1.EnumValue)) { + return isInAPISchema(element.parent); + } + (0, utils_1.assert)(false, "Unreachable code, element is of unknown type."); + } + function fetchInaccessibleElementsDeep(element) { + const inaccessibleElements = []; + if (isInaccessible(element)) { + inaccessibleElements.push(element); + } + if ((element instanceof definitions_1.ObjectType) || + (element instanceof definitions_1.InterfaceType) || + (element instanceof definitions_1.InputObjectType)) { + for (const field of element.fields()) { + inaccessibleElements.push(...fetchInaccessibleElementsDeep(field)); + } + return inaccessibleElements; + } + else if (element instanceof definitions_1.EnumType) { + for (const enumValue of element.values) { + inaccessibleElements.push(...fetchInaccessibleElementsDeep(enumValue)); + } + return inaccessibleElements; + } + else if ((element instanceof definitions_1.DirectiveDefinition) || + (element instanceof definitions_1.FieldDefinition)) { + for (const argument of element.arguments()) { + inaccessibleElements.push(...fetchInaccessibleElementsDeep(argument)); + } + return inaccessibleElements; + } + else if ((element instanceof definitions_1.UnionType) || + (element instanceof definitions_1.ScalarType) || + (element instanceof definitions_1.ArgumentDefinition) || + (element instanceof definitions_1.InputFieldDefinition) || + (element instanceof definitions_1.EnumValue)) { + return inaccessibleElements; + } + (0, utils_1.assert)(false, "Unreachable code, element is of unknown type."); + } + const errors = []; + let defaultValueReferencers = undefined; + if (!inaccessibleSpec.isV01()) { + defaultValueReferencers = computeDefaultValueReferencers(schema); + } + for (const type of schema.allTypes()) { + if (hasBuiltInName(type)) { + const inaccessibleElements = fetchInaccessibleElementsDeep(type); + if (inaccessibleElements.length > 0) { + errors.push(error_1.ERRORS.DISALLOWED_INACCESSIBLE.err(`Built-in type "${type.coordinate}" cannot use @inaccessible.`, { + nodes: type.sourceAST, + extensions: { + inaccessible_elements: inaccessibleElements + .map((element) => element.coordinate), + inaccessible_referencers: [type.coordinate], + } + })); + } + } + else if (isFeatureDefinition(type)) { + const inaccessibleElements = fetchInaccessibleElementsDeep(type); + if (inaccessibleElements.length > 0) { + errors.push(error_1.ERRORS.DISALLOWED_INACCESSIBLE.err(`Core feature type "${type.coordinate}" cannot use @inaccessible.`, { + nodes: type.sourceAST, + extensions: { + inaccessible_elements: inaccessibleElements + .map((element) => element.coordinate), + inaccessible_referencers: [type.coordinate], + } + })); + } + } + else if (isInaccessible(type)) { + const referencers = type.referencers(); + for (const referencer of referencers) { + if (referencer instanceof definitions_1.FieldDefinition || + referencer instanceof definitions_1.ArgumentDefinition || + referencer instanceof definitions_1.InputFieldDefinition) { + if (isInAPISchema(referencer)) { + errors.push(error_1.ERRORS.REFERENCED_INACCESSIBLE.err(`Type "${type.coordinate}" is @inaccessible but is referenced` + + ` by "${referencer.coordinate}", which is in the API schema.`, { + nodes: type.sourceAST, + extensions: { + inaccessible_elements: [type.coordinate], + inaccessible_referencers: [referencer.coordinate], + } + })); + } + } + else if (referencer instanceof definitions_1.SchemaDefinition) { + if (type === referencer.rootType('query')) { + errors.push(error_1.ERRORS.QUERY_ROOT_TYPE_INACCESSIBLE.err(`Type "${type.coordinate}" is @inaccessible but is the root` + + ` query type, which must be in the API schema.`, { + nodes: type.sourceAST, + extensions: { + inaccessible_elements: [type.coordinate], + } + })); + } + } + } + } + else { + if ((type instanceof definitions_1.ObjectType) || + (type instanceof definitions_1.InterfaceType) || + (type instanceof definitions_1.InputObjectType)) { + let isEmpty = true; + for (const field of type.fields()) { + if (!isInaccessible(field)) + isEmpty = false; + } + if (isEmpty) { + errors.push(error_1.ERRORS.ONLY_INACCESSIBLE_CHILDREN.err(`Type "${type.coordinate}" is in the API schema but all of its` + + ` ${(type instanceof definitions_1.InputObjectType) ? 'input ' : ''}fields` + + ` are @inaccessible.`, { + nodes: type.sourceAST, + extensions: { + inaccessible_elements: type.fields() + .map((field) => field.coordinate), + inaccessible_referencers: [type.coordinate], + } + })); + } + } + else if (type instanceof definitions_1.UnionType) { + let isEmpty = true; + for (const member of type.types()) { + if (!isInaccessible(member)) + isEmpty = false; + } + if (isEmpty) { + errors.push(error_1.ERRORS.ONLY_INACCESSIBLE_CHILDREN.err(`Type "${type.coordinate}" is in the API schema but all of its` + + ` members are @inaccessible.`, { + nodes: type.sourceAST, + extensions: { + inaccessible_elements: type.types() + .map((type) => type.coordinate), + inaccessible_referencers: [type.coordinate], + } + })); + } + } + else if (type instanceof definitions_1.EnumType) { + let isEmpty = true; + for (const enumValue of type.values) { + if (!isInaccessible(enumValue)) + isEmpty = false; + } + if (isEmpty) { + errors.push(error_1.ERRORS.ONLY_INACCESSIBLE_CHILDREN.err(`Type "${type.coordinate}" is in the API schema but all of its` + + ` values are @inaccessible.`, { + nodes: type.sourceAST, + extensions: { + inaccessible_elements: type.values + .map((enumValue) => enumValue.coordinate), + inaccessible_referencers: [type.coordinate], + } + })); + } + } + if ((type instanceof definitions_1.ObjectType) || + (type instanceof definitions_1.InterfaceType)) { + const implementedInterfaces = type.interfaces(); + const implementingTypes = []; + if (type instanceof definitions_1.InterfaceType) { + for (const referencer of type.referencers()) { + if ((referencer instanceof definitions_1.ObjectType) || + (referencer instanceof definitions_1.InterfaceType)) { + implementingTypes.push(referencer); + } + } + } + for (const field of type.fields()) { + if (isInaccessible(field)) { + for (const implementedInterface of implementedInterfaces) { + const implementedField = implementedInterface.field(field.name); + if (implementedField && isInAPISchema(implementedField)) { + errors.push(error_1.ERRORS.IMPLEMENTED_BY_INACCESSIBLE.err(`Field "${field.coordinate}" is @inaccessible but` + + ` implements the interface field` + + ` "${implementedField.coordinate}", which is in the API` + + ` schema.`, { + nodes: field.sourceAST, + extensions: { + inaccessible_elements: [field.coordinate], + inaccessible_referencers: [implementedField.coordinate], + } + })); + } + } + } + else { + for (const argument of field.arguments()) { + if (isInaccessible(argument)) { + if (argument.isRequired()) { + errors.push(error_1.ERRORS.REQUIRED_INACCESSIBLE.err(`Argument "${argument.coordinate}" is @inaccessible but` + + ` is a required argument of its field.`, { + nodes: argument.sourceAST, + extensions: { + inaccessible_elements: [argument.coordinate], + inaccessible_referencers: [argument.coordinate], + } + })); + } + for (const implementingType of implementingTypes) { + const implementingField = implementingType.field(field.name); + (0, utils_1.assert)(implementingField, "Schema should have been valid, but an implementing type" + + " did not implement one of this type's fields."); + const implementingArgument = implementingField + .argument(argument.name); + (0, utils_1.assert)(implementingArgument, "Schema should have been valid, but an implementing type" + + " did not implement one of this type's field's arguments."); + if (isInAPISchema(implementingArgument) && + implementingArgument.isRequired()) { + errors.push(error_1.ERRORS.REQUIRED_INACCESSIBLE.err(`Argument "${argument.coordinate}" is @inaccessible` + + ` but is implemented by the required argument` + + ` "${implementingArgument.coordinate}", which is` + + ` in the API schema.`, { + nodes: argument.sourceAST, + extensions: { + inaccessible_elements: [argument.coordinate], + inaccessible_referencers: [ + implementingArgument.coordinate, + ], + } + })); + } + } + for (const implementedInterface of implementedInterfaces) { + const implementedArgument = (_a = implementedInterface + .field(field.name)) === null || _a === void 0 ? void 0 : _a.argument(argument.name); + if (implementedArgument && + isInAPISchema(implementedArgument)) { + errors.push(error_1.ERRORS.IMPLEMENTED_BY_INACCESSIBLE.err(`Argument "${argument.coordinate}" is @inaccessible` + + ` but implements the interface argument` + + ` "${implementedArgument.coordinate}", which is in` + + ` the API schema.`, { + nodes: argument.sourceAST, + extensions: { + inaccessible_elements: [argument.coordinate], + inaccessible_referencers: [ + implementedArgument.coordinate, + ], + } + })); + } + } + } + } + } + } + } + else if (type instanceof definitions_1.InputObjectType) { + for (const inputField of type.fields()) { + if (isInaccessible(inputField)) { + if (inputField.isRequired()) { + errors.push(error_1.ERRORS.REQUIRED_INACCESSIBLE.err(`Input field "${inputField.coordinate}" is @inaccessible` + + ` but is a required input field of its type.`, { + nodes: inputField.sourceAST, + extensions: { + inaccessible_elements: [inputField.coordinate], + inaccessible_referencers: [inputField.coordinate], + } + })); + } + (0, utils_1.assert)(defaultValueReferencers, "Input fields can't be @inaccessible in v0.1, but default value" + + " referencers weren't computed (which is only skipped for v0.1)."); + const referencers = (_b = defaultValueReferencers.get(inputField)) !== null && _b !== void 0 ? _b : []; + for (const referencer of referencers) { + if (isInAPISchema(referencer)) { + errors.push(error_1.ERRORS.DEFAULT_VALUE_USES_INACCESSIBLE.err(`Input field "${inputField.coordinate}" is @inaccessible` + + ` but is used in the default value of` + + ` "${referencer.coordinate}", which is in the API schema.`, { + nodes: type.sourceAST, + extensions: { + inaccessible_elements: [type.coordinate], + inaccessible_referencers: [referencer.coordinate], + } + })); + } + } + } + } + } + else if (type instanceof definitions_1.EnumType) { + for (const enumValue of type.values) { + if (isInaccessible(enumValue)) { + (0, utils_1.assert)(defaultValueReferencers, "Enum values can't be @inaccessible in v0.1, but default value" + + " referencers weren't computed (which is only skipped for v0.1)."); + const referencers = (_c = defaultValueReferencers.get(enumValue)) !== null && _c !== void 0 ? _c : []; + for (const referencer of referencers) { + if (isInAPISchema(referencer)) { + errors.push(error_1.ERRORS.DEFAULT_VALUE_USES_INACCESSIBLE.err(`Enum value "${enumValue.coordinate}" is @inaccessible` + + ` but is used in the default value of` + + ` "${referencer.coordinate}", which is in the API schema.`, { + nodes: type.sourceAST, + extensions: { + inaccessible_elements: [type.coordinate], + inaccessible_referencers: [referencer.coordinate], + } + })); + } + } + } + } + } + } + } + for (const directive of schema.allDirectives()) { + const typeSystemLocations = directive.locations.filter((loc) => (0, definitions_1.isTypeSystemDirectiveLocation)(loc)); + if (hasBuiltInName(directive)) { + const inaccessibleElements = fetchInaccessibleElementsDeep(directive); + if (inaccessibleElements.length > 0) { + errors.push(error_1.ERRORS.DISALLOWED_INACCESSIBLE.err(`Built-in directive "${directive.coordinate}" cannot use @inaccessible.`, { + nodes: directive.sourceAST, + extensions: { + inaccessible_elements: inaccessibleElements + .map((element) => element.coordinate), + inaccessible_referencers: [directive.coordinate], + } + })); + } + } + else if (isFeatureDefinition(directive)) { + const inaccessibleElements = fetchInaccessibleElementsDeep(directive); + if (inaccessibleElements.length > 0) { + errors.push(error_1.ERRORS.DISALLOWED_INACCESSIBLE.err(`Core feature directive "${directive.coordinate}" cannot use @inaccessible.`, { + nodes: directive.sourceAST, + extensions: { + inaccessible_elements: inaccessibleElements + .map((element) => element.coordinate), + inaccessible_referencers: [directive.coordinate], + } + })); + } + } + else if (typeSystemLocations.length > 0) { + const inaccessibleElements = fetchInaccessibleElementsDeep(directive); + if (inaccessibleElements.length > 0) { + errors.push(error_1.ERRORS.DISALLOWED_INACCESSIBLE.err(`Directive "${directive.coordinate}" cannot use @inaccessible` + + ` because it may be applied to these type-system locations:` + + ` ${typeSystemLocations.join(', ')}.`, { + nodes: directive.sourceAST, + extensions: { + inaccessible_elements: inaccessibleElements + .map((element) => element.coordinate), + inaccessible_referencers: [directive.coordinate], + } + })); + } + } + else { + for (const argument of directive.arguments()) { + if (argument.isRequired()) { + if (isInaccessible(argument)) { + errors.push(error_1.ERRORS.REQUIRED_INACCESSIBLE.err(`Argument "${argument.coordinate}" is @inaccessible but is a` + + ` required argument of its directive.`, { + nodes: argument.sourceAST, + extensions: { + inaccessible_elements: [argument.coordinate], + inaccessible_referencers: [argument.coordinate], + } + })); + } + } + } + } + } + if (errors.length > 0) { + throw (0, definitions_1.ErrGraphQLAPISchemaValidationFailed)(errors); + } +} +function computeDefaultValueReferencers(schema) { + const referencers = new Map(); + function addReference(reference, referencer) { + var _a; + const referencerList = (_a = referencers.get(reference)) !== null && _a !== void 0 ? _a : []; + if (referencerList.length === 0) { + referencers.set(reference, referencerList); + } + referencerList.push(referencer); + } + for (const type of schema.allTypes()) { + if (hasBuiltInName(type)) + continue; + if ((type instanceof definitions_1.ObjectType) || + (type instanceof definitions_1.InterfaceType)) { + for (const field of type.fields()) { + for (const argument of field.arguments()) { + for (const reference of computeDefaultValueReferences(argument)) { + addReference(reference, argument); + } + } + } + } + if (type instanceof definitions_1.InputObjectType) { + for (const inputField of type.fields()) { + for (const reference of computeDefaultValueReferences(inputField)) { + addReference(reference, inputField); + } + } + } + } + for (const directive of schema.allDirectives()) { + if (hasBuiltInName(directive)) + continue; + for (const argument of directive.arguments()) { + for (const reference of computeDefaultValueReferences(argument)) { + addReference(reference, argument); + } + } + } + return referencers; +} +function computeDefaultValueReferences(element) { + const references = []; + addValueReferences(element.defaultValue, getInputType(element), references); + return references; +} +function getInputType(element) { + const type = element.type; + (0, utils_1.assert)(type, "Schema should have been valid, but argument/input field did not have type."); + return type; +} +function addValueReferences(value, type, references) { + if (value === undefined || value === null) { + return; + } + if ((0, definitions_1.isNonNullType)(type)) { + return addValueReferences(value, type.ofType, references); + } + if ((0, definitions_1.isScalarType)(type)) { + return; + } + if ((0, definitions_1.isVariable)(value)) { + return; + } + if (Array.isArray(value)) { + if ((0, definitions_1.isListType)(type)) { + const itemType = type.ofType; + for (const item of value) { + addValueReferences(item, itemType, references); + } + } + else { + } + return; + } + if ((0, definitions_1.isListType)(type)) { + return addValueReferences(value, type.ofType, references); + } + if (typeof value === 'object') { + if ((0, definitions_1.isInputObjectType)(type)) { + for (const field of type.fields()) { + const fieldValue = value[field.name]; + if (fieldValue !== undefined) { + references.push(field); + addValueReferences(fieldValue, field.type, references); + } + else { + } + } + } + else { + } + return; + } + if (typeof value === 'string') { + if ((0, definitions_1.isEnumType)(type)) { + const enumValue = type.value(value); + if (enumValue !== undefined) { + references.push(enumValue); + } + else { + } + } + else { + } + return; + } + return; +} +function hasBuiltInName(element) { + const schema = element.schema(); + if ((element instanceof definitions_1.ObjectType) || + (element instanceof definitions_1.InterfaceType) || + (element instanceof definitions_1.UnionType) || + (element instanceof definitions_1.ScalarType) || + (element instanceof definitions_1.EnumType) || + (element instanceof definitions_1.InputObjectType)) { + return schema.builtInTypes(true).some((type) => type.name === element.name); + } + else if (element instanceof definitions_1.DirectiveDefinition) { + return schema.builtInDirectives(true).some((directive) => directive.name === element.name); + } + (0, utils_1.assert)(false, "Unreachable code, element is of unknown type."); +} +function removeInaccessibleElementsAssumingValid(schema, inaccessibleDirective) { + function isInaccessible(element) { + return element.hasAppliedDirective(inaccessibleDirective); + } + for (const type of schema.types()) { + if (isInaccessible(type)) { + type.remove(); + } + else { + if ((type instanceof definitions_1.ObjectType) || (type instanceof definitions_1.InterfaceType)) { + for (const field of type.fields()) { + if (isInaccessible(field)) { + field.remove(); + } + else { + for (const argument of field.arguments()) { + if (isInaccessible(argument)) { + argument.remove(); + } + } + } + } + } + else if (type instanceof definitions_1.InputObjectType) { + for (const inputField of type.fields()) { + if (isInaccessible(inputField)) { + inputField.remove(); + } + } + } + else if (type instanceof definitions_1.EnumType) { + for (const enumValue of type.values) { + if (isInaccessible(enumValue)) { + enumValue.remove(); + } + } + } + } + } + for (const directive of schema.directives()) { + for (const argument of directive.arguments()) { + if (isInaccessible(argument)) { + argument.remove(); + } + } + } +} +//# sourceMappingURL=inaccessibleSpec.js.map + +/***/ }), + +/***/ 415: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +__exportStar(__webpack_require__(4177), exports); +__exportStar(__webpack_require__(7964), exports); +__exportStar(__webpack_require__(2850), exports); +__exportStar(__webpack_require__(3421), exports); +__exportStar(__webpack_require__(4408), exports); +__exportStar(__webpack_require__(5811), exports); +__exportStar(__webpack_require__(758), exports); +__exportStar(__webpack_require__(9724), exports); +__exportStar(__webpack_require__(2116), exports); +__exportStar(__webpack_require__(9209), exports); +__exportStar(__webpack_require__(6920), exports); +__exportStar(__webpack_require__(1697), exports); +__exportStar(__webpack_require__(5322), exports); +__exportStar(__webpack_require__(9480), exports); +__exportStar(__webpack_require__(9624), exports); +__exportStar(__webpack_require__(8220), exports); +__exportStar(__webpack_require__(8116), exports); +__exportStar(__webpack_require__(5015), exports); +__exportStar(__webpack_require__(5388), exports); +__exportStar(__webpack_require__(9535), exports); +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 9495: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.addIntrospectionFields = exports.isIntrospectionName = exports.introspectionFieldNames = void 0; +const graphql_1 = __webpack_require__(8929); +const definitions_1 = __webpack_require__(4177); +exports.introspectionFieldNames = ['__schema', '__type']; +function isIntrospectionName(name) { + return name.startsWith('__'); +} +exports.isIntrospectionName = isIntrospectionName; +function addIntrospectionFields(schema) { + if (schema.type('__Schema')) { + return; + } + const typeKindEnum = schema.addType(new definitions_1.EnumType('__TypeKind', true)); + typeKindEnum.addValue('SCALAR'); + typeKindEnum.addValue('OBJECT'); + typeKindEnum.addValue('INTERFACE'); + typeKindEnum.addValue('UNION'); + typeKindEnum.addValue('ENUM'); + typeKindEnum.addValue('INPUT_OBJECT'); + typeKindEnum.addValue('LIST'); + typeKindEnum.addValue('NON_NULL'); + const inputValueType = schema.addType(new definitions_1.ObjectType('__InputValue', true)); + const fieldType = schema.addType(new definitions_1.ObjectType('__Field', true)); + const typeType = schema.addType(new definitions_1.ObjectType('__Type', true)); + const enumValueType = schema.addType(new definitions_1.ObjectType('__EnumValue', true)); + typeType.addField('kind', new definitions_1.NonNullType(typeKindEnum)); + typeType.addField('name', schema.stringType()); + typeType.addField('description', schema.stringType()); + typeType.addField('fields', new definitions_1.ListType(new definitions_1.NonNullType(fieldType))) + .addArgument('includeDeprecated', schema.booleanType(), false); + typeType.addField('interfaces', new definitions_1.ListType(new definitions_1.NonNullType(typeType))); + typeType.addField('possibleTypes', new definitions_1.ListType(new definitions_1.NonNullType(typeType))); + typeType.addField('enumValues', new definitions_1.ListType(new definitions_1.NonNullType(enumValueType))) + .addArgument('includeDeprecated', schema.booleanType(), false); + typeType.addField('inputFields', new definitions_1.ListType(new definitions_1.NonNullType(inputValueType))) + .addArgument('includeDeprecated', schema.booleanType(), false); + typeType.addField('ofType', typeType); + typeType.addField('specifiedByURL', schema.stringType()); + fieldType.addField('name', new definitions_1.NonNullType(schema.stringType())); + fieldType.addField('description', schema.stringType()); + fieldType.addField('args', new definitions_1.NonNullType(new definitions_1.ListType(new definitions_1.NonNullType(inputValueType)))) + .addArgument('includeDeprecated', schema.booleanType(), false); + fieldType.addField('type', new definitions_1.NonNullType(typeType)); + fieldType.addField('isDeprecated', new definitions_1.NonNullType(schema.booleanType())); + fieldType.addField('deprecationReason', schema.stringType()); + inputValueType.addField('name', new definitions_1.NonNullType(schema.stringType())); + inputValueType.addField('description', schema.stringType()); + inputValueType.addField('type', new definitions_1.NonNullType(typeType)); + inputValueType.addField('defaultValue', schema.stringType()); + inputValueType.addField('isDeprecated', new definitions_1.NonNullType(schema.booleanType())); + inputValueType.addField('deprecationReason', schema.stringType()); + enumValueType.addField('name', new definitions_1.NonNullType(schema.stringType())); + enumValueType.addField('description', schema.stringType()); + enumValueType.addField('isDeprecated', new definitions_1.NonNullType(schema.booleanType())); + enumValueType.addField('deprecationReason', schema.stringType()); + const directiveLocationEnum = schema.addType(new definitions_1.EnumType('__DirectiveLocation', true)); + for (const location of Object.values(graphql_1.DirectiveLocation)) { + directiveLocationEnum.addValue(location); + } + const directiveType = schema.addType(new definitions_1.ObjectType('__Directive', true)); + directiveType.addField('name', new definitions_1.NonNullType(schema.stringType())); + directiveType.addField('description', schema.stringType()); + directiveType.addField('locations', new definitions_1.NonNullType(new definitions_1.ListType(new definitions_1.NonNullType(directiveLocationEnum)))); + directiveType.addField('args', new definitions_1.NonNullType(new definitions_1.ListType(new definitions_1.NonNullType(inputValueType)))) + .addArgument('includeDeprecated', schema.booleanType(), false); + directiveType.addField('isRepeatable', new definitions_1.NonNullType(schema.booleanType())); + const schemaType = schema.addType(new definitions_1.ObjectType('__Schema', true)); + schemaType.addField('description', schema.stringType()); + schemaType.addField('types', new definitions_1.NonNullType(new definitions_1.ListType(new definitions_1.NonNullType(typeType)))); + schemaType.addField('queryType', new definitions_1.NonNullType(typeType)); + schemaType.addField('mutationType', new definitions_1.NonNullType(typeType)); + schemaType.addField('subscriptionType', new definitions_1.NonNullType(typeType)); + schemaType.addField('directives', new definitions_1.NonNullType(new definitions_1.ListType(new definitions_1.NonNullType(directiveType)))); + let queryRoot = schema.schemaDefinition.rootType('query'); + if (!queryRoot) { + queryRoot = schema.addType(new definitions_1.ObjectType('Query')); + schema.schemaDefinition.setRoot('query', queryRoot); + } + queryRoot.addField(new definitions_1.FieldDefinition('__schema', true), new definitions_1.NonNullType(schemaType)); + queryRoot.addField(new definitions_1.FieldDefinition('__type', true), typeType) + .addArgument('name', new definitions_1.NonNullType(schema.stringType())); +} +exports.addIntrospectionFields = addIntrospectionFields; +//# sourceMappingURL=introspection.js.map + +/***/ }), + +/***/ 6920: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.JOIN_VERSIONS = exports.JoinSpecDefinition = exports.joinIdentity = void 0; +const graphql_1 = __webpack_require__(8929); +const coreSpec_1 = __webpack_require__(9209); +const definitions_1 = __webpack_require__(4177); +const knownCoreFeatures_1 = __webpack_require__(5848); +const utils_1 = __webpack_require__(9724); +exports.joinIdentity = 'https://specs.apollo.dev/join'; +function sanitizeGraphQLName(name) { + const alphaNumericUnderscoreOnly = name.replace(/[\W]/g, '_'); + const noNumericFirstChar = alphaNumericUnderscoreOnly.match(/^\d/) + ? '_' + alphaNumericUnderscoreOnly + : alphaNumericUnderscoreOnly; + const noUnderscoreNumericEnding = noNumericFirstChar.match(/_\d+$/) + ? noNumericFirstChar + '_' + : noNumericFirstChar; + const toUpper = noUnderscoreNumericEnding.toLocaleUpperCase(); + return toUpper; +} +class JoinSpecDefinition extends coreSpec_1.FeatureDefinition { + constructor(version) { + super(new coreSpec_1.FeatureUrl(exports.joinIdentity, 'join', version)); + } + isV01() { + return this.version.equals(new coreSpec_1.FeatureVersion(0, 1)); + } + addElementsToSchema(schema) { + const joinGraph = this.addDirective(schema, 'graph').addLocations(graphql_1.DirectiveLocation.ENUM_VALUE); + joinGraph.addArgument('name', new definitions_1.NonNullType(schema.stringType())); + joinGraph.addArgument('url', new definitions_1.NonNullType(schema.stringType())); + const graphEnum = this.addEnumType(schema, 'Graph'); + const joinFieldSet = this.addScalarType(schema, 'FieldSet'); + const joinType = this.addDirective(schema, 'type').addLocations(graphql_1.DirectiveLocation.OBJECT, graphql_1.DirectiveLocation.INTERFACE, graphql_1.DirectiveLocation.UNION, graphql_1.DirectiveLocation.ENUM, graphql_1.DirectiveLocation.INPUT_OBJECT, graphql_1.DirectiveLocation.SCALAR); + if (!this.isV01()) { + joinType.repeatable = true; + } + joinType.addArgument('graph', new definitions_1.NonNullType(graphEnum)); + joinType.addArgument('key', joinFieldSet); + if (!this.isV01()) { + joinType.addArgument('extension', new definitions_1.NonNullType(schema.booleanType()), false); + joinType.addArgument('resolvable', new definitions_1.NonNullType(schema.booleanType()), true); + } + const joinField = this.addDirective(schema, 'field').addLocations(graphql_1.DirectiveLocation.FIELD_DEFINITION, graphql_1.DirectiveLocation.INPUT_FIELD_DEFINITION); + joinField.repeatable = true; + joinField.addArgument('graph', new definitions_1.NonNullType(graphEnum)); + joinField.addArgument('requires', joinFieldSet); + joinField.addArgument('provides', joinFieldSet); + if (!this.isV01()) { + joinField.addArgument('type', schema.stringType()); + joinField.addArgument('external', schema.booleanType()); + joinField.addArgument('override', schema.stringType()); + joinField.addArgument('usedOverridden', schema.booleanType()); + } + if (!this.isV01()) { + const joinImplements = this.addDirective(schema, 'implements').addLocations(graphql_1.DirectiveLocation.OBJECT, graphql_1.DirectiveLocation.INTERFACE); + joinImplements.repeatable = true; + joinImplements.addArgument('graph', new definitions_1.NonNullType(graphEnum)); + joinImplements.addArgument('interface', new definitions_1.NonNullType(schema.stringType())); + } + if (this.isV01()) { + const joinOwner = this.addDirective(schema, 'owner').addLocations(graphql_1.DirectiveLocation.OBJECT); + joinOwner.addArgument('graph', new definitions_1.NonNullType(graphEnum)); + } + return []; + } + allElementNames() { + const names = [ + 'graph', + 'Graph', + 'FieldSet', + '@type', + '@field', + ]; + if (this.isV01()) { + names.push('@owner'); + } + else { + names.push('@implements'); + } + return names; + } + populateGraphEnum(schema, subgraphs) { + const sanitizedNameToSubgraphs = new utils_1.MultiMap(); + for (const subgraph of subgraphs) { + const sanitized = sanitizeGraphQLName(subgraph.name); + sanitizedNameToSubgraphs.add(sanitized, subgraph); + } + const subgraphToEnumName = new Map(); + for (const [sanitizedName, subgraphsForName] of sanitizedNameToSubgraphs) { + if (subgraphsForName.length === 1) { + subgraphToEnumName.set(subgraphsForName[0].name, sanitizedName); + } + else { + for (const [index, subgraph] of subgraphsForName.entries()) { + subgraphToEnumName.set(subgraph.name, `${sanitizedName}_${index + 1}`); + } + } + } + const graphEnum = this.graphEnum(schema); + const graphDirective = this.graphDirective(schema); + for (const subgraph of subgraphs) { + const enumValue = graphEnum.addValue(subgraphToEnumName.get(subgraph.name)); + enumValue.applyDirective(graphDirective, { name: subgraph.name, url: subgraph.url }); + } + return subgraphToEnumName; + } + fieldSetScalar(schema) { + return this.type(schema, 'FieldSet'); + } + graphEnum(schema) { + return this.type(schema, 'Graph'); + } + graphDirective(schema) { + return this.directive(schema, 'graph'); + } + typeDirective(schema) { + return this.directive(schema, 'type'); + } + implementsDirective(schema) { + return this.directive(schema, 'implements'); + } + fieldDirective(schema) { + return this.directive(schema, 'field'); + } + ownerDirective(schema) { + return this.directive(schema, 'owner'); + } + get defaultCorePurpose() { + return 'EXECUTION'; + } +} +exports.JoinSpecDefinition = JoinSpecDefinition; +exports.JOIN_VERSIONS = new coreSpec_1.FeatureDefinitions(exports.joinIdentity) + .add(new JoinSpecDefinition(new coreSpec_1.FeatureVersion(0, 1))) + .add(new JoinSpecDefinition(new coreSpec_1.FeatureVersion(0, 2))); +(0, knownCoreFeatures_1.registerKnownFeature)(exports.JOIN_VERSIONS); +//# sourceMappingURL=joinSpec.js.map + +/***/ }), + +/***/ 5848: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.coreFeatureDefinitionIfKnown = exports.registerKnownFeature = void 0; +const registeredFeatures = new Map(); +function registerKnownFeature(definitions) { + if (!registeredFeatures.has(definitions.identity)) { + registeredFeatures.set(definitions.identity, definitions); + } +} +exports.registerKnownFeature = registerKnownFeature; +function coreFeatureDefinitionIfKnown(url) { + var _a; + return (_a = registeredFeatures.get(url.identity)) === null || _a === void 0 ? void 0 : _a.find(url.version); +} +exports.coreFeatureDefinitionIfKnown = coreFeatureDefinitionIfKnown; +//# sourceMappingURL=knownCoreFeatures.js.map + +/***/ }), + +/***/ 758: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.operationToDocument = exports.parseSelectionSet = exports.parseOperation = exports.operationFromDocument = exports.FragmentSelection = exports.FieldSelection = exports.selectionOfElement = exports.selectionSetOfElement = exports.allFieldDefinitionsInSelectionSet = exports.SelectionSet = exports.NamedFragments = exports.NamedFragmentDefinition = exports.selectionSetOf = exports.Operation = exports.concatOperationPaths = exports.conditionalDirectivesInOperationPath = exports.sameOperationPaths = exports.FragmentElement = exports.Field = void 0; +const graphql_1 = __webpack_require__(8929); +const definitions_1 = __webpack_require__(4177); +const error_1 = __webpack_require__(8116); +const types_1 = __webpack_require__(5811); +const utils_1 = __webpack_require__(9724); +const values_1 = __webpack_require__(3421); +function validate(condition, message, sourceAST) { + if (!condition) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(message(), { nodes: sourceAST }); + } +} +function haveSameDirectives(op1, op2) { + return (0, definitions_1.sameDirectiveApplications)(op1.appliedDirectives, op2.appliedDirectives); +} +class AbstractOperationElement extends definitions_1.DirectiveTargetElement { + constructor(schema, variablesInElement) { + super(schema); + this.variablesInElement = variablesInElement; + } + variables() { + return (0, definitions_1.mergeVariables)(this.variablesInElement, this.variablesInAppliedDirectives()); + } + addAttachement(key, value) { + if (!this.attachements) { + this.attachements = new Map(); + } + this.attachements.set(key, value); + } + getAttachement(key) { + var _a; + return (_a = this.attachements) === null || _a === void 0 ? void 0 : _a.get(key); + } + copyAttachementsTo(elt) { + if (this.attachements) { + for (const [k, v] of this.attachements.entries()) { + elt.addAttachement(k, v); + } + } + } +} +class Field extends AbstractOperationElement { + constructor(definition, args = Object.create(null), variableDefinitions = new definitions_1.VariableDefinitions(), alias) { + super(definition.schema(), (0, definitions_1.variablesInArguments)(args)); + this.definition = definition; + this.args = args; + this.variableDefinitions = variableDefinitions; + this.alias = alias; + this.kind = 'Field'; + } + get name() { + return this.definition.name; + } + responseName() { + return this.alias ? this.alias : this.name; + } + get parentType() { + return this.definition.parent; + } + withUpdatedDefinition(newDefinition) { + const newField = new Field(newDefinition, this.args, this.variableDefinitions, this.alias); + for (const directive of this.appliedDirectives) { + newField.applyDirective(directive.definition, directive.arguments()); + } + this.copyAttachementsTo(newField); + return newField; + } + appliesTo(type) { + const definition = type.field(this.name); + return !!definition && this.selects(definition); + } + selects(definition, assumeValid = false) { + if (definition == this.definition) { + return true; + } + if (this.name !== definition.name) { + return false; + } + for (const argDef of definition.arguments()) { + const appliedValue = this.args[argDef.name]; + if (appliedValue === undefined) { + if (argDef.defaultValue === undefined && !(0, definitions_1.isNullableType)(argDef.type)) { + return false; + } + } + else { + if (!assumeValid && !(0, values_1.isValidValue)(appliedValue, argDef, this.variableDefinitions)) { + return false; + } + } + } + if (!assumeValid) { + for (const [name, value] of Object.entries(this.args)) { + if (value !== null && definition.argument(name) === undefined) { + return false; + } + } + } + return true; + } + validate() { + validate(this.name === this.definition.name, () => `Field name "${this.name}" cannot select field "${this.definition.coordinate}: name mismatch"`); + for (const argDef of this.definition.arguments()) { + const appliedValue = this.args[argDef.name]; + if (appliedValue === undefined) { + validate(argDef.defaultValue !== undefined || (0, definitions_1.isNullableType)(argDef.type), () => `Missing mandatory value for argument "${argDef.name}" of field "${this.definition.coordinate}" in selection "${this}"`); + } + else { + validate((0, values_1.isValidValue)(appliedValue, argDef, this.variableDefinitions), () => `Invalid value ${(0, values_1.valueToString)(appliedValue)} for argument "${argDef.coordinate}" of type ${argDef.type}`); + } + } + for (const [name, value] of Object.entries(this.args)) { + validate(value === null || this.definition.argument(name) !== undefined, () => `Unknown argument "${name}" in field application of "${this.name}"`); + } + } + updateForAddingTo(selectionSet) { + const selectionParent = selectionSet.parentType; + const fieldParent = this.definition.parent; + if (selectionParent === fieldParent) { + return this; + } + if (this.name === definitions_1.typenameFieldName) { + return this.withUpdatedDefinition(selectionParent.typenameField()); + } + validate(selectionParent.name == fieldParent.name + || ((0, definitions_1.isInterfaceType)(fieldParent) && fieldParent.allImplementations().some(i => i.name == selectionParent.name)), () => `Cannot add selection of field "${this.definition.coordinate}" to selection set of parent type "${selectionSet.parentType}"`); + const fieldDef = selectionParent.field(this.name); + validate(fieldDef, () => `Cannot add selection of field "${this.definition.coordinate}" to selection set of parent type "${selectionParent}" (that does not declare that field)`); + return this.withUpdatedDefinition(fieldDef); + } + hasDefer() { + return false; + } + deferDirectiveArgs() { + return undefined; + } + withoutDefer() { + return this; + } + equals(that) { + if (this === that) { + return true; + } + return that.kind === 'Field' + && this.name === that.name + && this.alias === that.alias + && (0, values_1.argumentsEquals)(this.args, that.args) + && haveSameDirectives(this, that); + } + toString() { + const alias = this.alias ? this.alias + ': ' : ''; + const entries = Object.entries(this.args); + const args = entries.length == 0 + ? '' + : '(' + entries.map(([n, v]) => { var _a; return `${n}: ${(0, values_1.valueToString)(v, (_a = this.definition.argument(n)) === null || _a === void 0 ? void 0 : _a.type)}`; }).join(', ') + ')'; + return alias + this.name + args + this.appliedDirectivesToString(); + } +} +exports.Field = Field; +class FragmentElement extends AbstractOperationElement { + constructor(sourceType, typeCondition) { + super(sourceType.schema(), []); + this.sourceType = sourceType; + this.kind = 'FragmentElement'; + this.typeCondition = typeCondition !== undefined && typeof typeCondition === 'string' + ? this.schema().type(typeCondition) + : typeCondition; + } + get parentType() { + return this.sourceType; + } + castedType() { + return this.typeCondition ? this.typeCondition : this.sourceType; + } + withUpdatedSourceType(newSourceType) { + var _a; + const newFragment = new FragmentElement(newSourceType, (_a = this.typeCondition) === null || _a === void 0 ? void 0 : _a.name); + for (const directive of this.appliedDirectives) { + newFragment.applyDirective(directive.definition, directive.arguments()); + } + this.copyAttachementsTo(newFragment); + return newFragment; + } + updateForAddingTo(selectionSet) { + const selectionParent = selectionSet.parentType; + const fragmentParent = this.parentType; + const typeCondition = this.typeCondition; + if (selectionParent != fragmentParent) { + validate(!typeCondition || (0, definitions_1.runtimeTypesIntersects)(selectionParent, typeCondition), () => `Cannot add fragment of parent type "${this.parentType}" to selection set of parent type "${selectionSet.parentType}"`); + return this.withUpdatedSourceType(selectionParent); + } + return this; + } + hasDefer() { + return this.hasAppliedDirective('defer'); + } + hasStream() { + return this.hasAppliedDirective('stream'); + } + deferDirectiveArgs() { + var _a; + return (_a = this.appliedDirectivesOf(this.schema().deferDirective())[0]) === null || _a === void 0 ? void 0 : _a.arguments(); + } + withoutDefer() { + const deferName = this.schema().deferDirective().name; + const updatedDirectives = this.appliedDirectives.filter((d) => d.name !== deferName); + if (!this.typeCondition && updatedDirectives.length === 0) { + return undefined; + } + if (updatedDirectives.length === this.appliedDirectives.length) { + return this; + } + const updated = new FragmentElement(this.sourceType, this.typeCondition); + this.copyAttachementsTo(updated); + updatedDirectives.forEach((d) => updated.applyDirective(d.definition, d.arguments())); + return updated; + } + withNormalizedDefer(normalizer) { + const deferArgs = this.deferDirectiveArgs(); + if (!deferArgs) { + return this; + } + let newDeferArgs = undefined; + let conditionVariable = undefined; + if (deferArgs.if !== undefined) { + if (typeof deferArgs.if === 'boolean') { + if (deferArgs.if) { + newDeferArgs = { + ...deferArgs, + if: undefined, + }; + } + else { + return this.withoutDefer(); + } + } + else { + conditionVariable = deferArgs.if; + } + } + let label = deferArgs.label; + if (!label) { + label = normalizer.newLabel(); + if (newDeferArgs) { + newDeferArgs.label = label; + } + else { + newDeferArgs = { + ...deferArgs, + label, + }; + } + } + if (conditionVariable) { + normalizer.registerCondition(label, conditionVariable); + } + if (!newDeferArgs) { + return this; + } + const updated = new FragmentElement(this.sourceType, this.typeCondition); + this.copyAttachementsTo(updated); + const deferDirective = this.schema().deferDirective(); + this.appliedDirectives.filter((d) => d.name !== deferDirective.name).forEach((d) => updated.applyDirective(d.definition, d.arguments())); + updated.applyDirective(this.schema().deferDirective(), newDeferArgs); + return updated; + } + equals(that) { + var _a, _b; + if (this === that) { + return true; + } + return that.kind === 'FragmentElement' + && ((_a = this.typeCondition) === null || _a === void 0 ? void 0 : _a.name) === ((_b = that.typeCondition) === null || _b === void 0 ? void 0 : _b.name) + && haveSameDirectives(this, that); + } + toString() { + return '...' + (this.typeCondition ? ' on ' + this.typeCondition : '') + this.appliedDirectivesToString(); + } +} +exports.FragmentElement = FragmentElement; +function sameOperationPaths(p1, p2) { + if (p1 === p2) { + return true; + } + if (p1.length !== p2.length) { + return false; + } + for (let i = 0; i < p1.length; i++) { + if (!p1[i].equals(p2[i])) { + return false; + } + } + return true; +} +exports.sameOperationPaths = sameOperationPaths; +function conditionalDirectivesInOperationPath(path) { + return path.map((e) => e.appliedDirectives).flat().filter((d) => (0, definitions_1.isConditionalDirective)(d)); +} +exports.conditionalDirectivesInOperationPath = conditionalDirectivesInOperationPath; +function concatOperationPaths(head, tail) { + if (head.length === 0) { + return tail; + } + if (tail.length === 0) { + return head; + } + const lastOfHead = head[head.length - 1]; + const conditionals = conditionalDirectivesInOperationPath(head); + let firstOfTail = tail[0]; + while (firstOfTail && isUselessFollowupElement(lastOfHead, firstOfTail, conditionals)) { + tail = tail.slice(1); + firstOfTail = tail[0]; + } + return head.concat(tail); +} +exports.concatOperationPaths = concatOperationPaths; +function isUselessFollowupElement(first, followup, conditionals) { + const typeOfFirst = first.kind === 'Field' + ? (0, definitions_1.baseType)(first.definition.type) + : first.typeCondition; + return !!typeOfFirst + && followup.kind === 'FragmentElement' + && !!followup.typeCondition + && (followup.appliedDirectives.length === 0 || (0, definitions_1.isDirectiveApplicationsSubset)(conditionals, followup.appliedDirectives)) + && (0, types_1.sameType)(typeOfFirst, followup.typeCondition); +} +class Operation { + constructor(rootKind, selectionSet, variableDefinitions, name) { + this.rootKind = rootKind; + this.selectionSet = selectionSet; + this.variableDefinitions = variableDefinitions; + this.name = name; + } + optimize(fragments, minUsagesToOptimize = 2) { + (0, utils_1.assert)(minUsagesToOptimize >= 1, `Expected 'minUsagesToOptimize' to be at least 1, but got ${minUsagesToOptimize}`); + if (!fragments || fragments.isEmpty()) { + return this; + } + let optimizedSelection = this.selectionSet.optimize(fragments); + if (optimizedSelection === this.selectionSet) { + return this; + } + const usages = new Map(); + optimizedSelection.collectUsedFragmentNames(usages); + for (const fragment of fragments.names()) { + if (!usages.has(fragment)) { + usages.set(fragment, 0); + } + } + const toDeoptimize = (0, utils_1.mapEntries)(usages).filter(([_, count]) => count < minUsagesToOptimize).map(([name]) => name); + optimizedSelection = optimizedSelection.expandFragments(toDeoptimize); + return new Operation(this.rootKind, optimizedSelection, this.variableDefinitions, this.name); + } + expandAllFragments() { + const expandedSelections = this.selectionSet.expandFragments(); + if (expandedSelections === this.selectionSet) { + return this; + } + return new Operation(this.rootKind, expandedSelections, this.variableDefinitions, this.name); + } + withoutDefer(labelsToRemove) { + (0, utils_1.assert)(!this.selectionSet.fragments || this.selectionSet.fragments.isEmpty(), 'Removing @defer currently only work on "expanded" selections (no named fragments)'); + const updated = this.selectionSet.withoutDefer(labelsToRemove); + return updated == this.selectionSet + ? this + : new Operation(this.rootKind, updated, this.variableDefinitions, this.name); + } + withNormalizedDefer() { + (0, utils_1.assert)(!this.selectionSet.fragments || this.selectionSet.fragments.isEmpty(), 'Assigning @defer lables currently only work on "expanded" selections (no named fragments)'); + const normalizer = new DeferNormalizer(); + const { hasDefers, hasNonLabelledOrConditionalDefers } = normalizer.init(this.selectionSet); + let updatedOperation = this; + if (hasNonLabelledOrConditionalDefers) { + const updated = this.selectionSet.withNormalizedDefer(normalizer); + updatedOperation = new Operation(this.rootKind, updated, this.variableDefinitions, this.name); + } + return { + operation: updatedOperation, + hasDefers, + assignedDeferLabels: normalizer.assignedLabels, + deferConditions: normalizer.deferConditions, + }; + } + toString(expandFragments = false, prettyPrint = true) { + return this.selectionSet.toOperationString(this.rootKind, this.variableDefinitions, this.name, expandFragments, prettyPrint); + } +} +exports.Operation = Operation; +function addDirectiveNodesToElement(directiveNodes, element) { + if (!directiveNodes) { + return; + } + const schema = element.schema(); + for (const node of directiveNodes) { + const directiveDef = schema.directive(node.name.value); + validate(directiveDef, () => `Unknown directive "@${node.name.value}" in selection`); + element.applyDirective(directiveDef, (0, values_1.argumentsFromAST)(directiveDef.coordinate, node.arguments, directiveDef)); + } +} +function selectionSetOf(parentType, selection) { + const selectionSet = new SelectionSet(parentType); + selectionSet.add(selection); + return selectionSet; +} +exports.selectionSetOf = selectionSetOf; +class NamedFragmentDefinition extends definitions_1.DirectiveTargetElement { + constructor(schema, name, typeCondition, selectionSet) { + super(schema); + this.name = name; + this.typeCondition = typeCondition; + this.selectionSet = selectionSet; + } + withUpdatedSelectionSet(newSelectionSet) { + return new NamedFragmentDefinition(this.schema(), this.name, this.typeCondition, newSelectionSet); + } + variables() { + return (0, definitions_1.mergeVariables)(this.variablesInAppliedDirectives(), this.selectionSet.usedVariables()); + } + collectUsedFragmentNames(collector) { + this.selectionSet.collectUsedFragmentNames(collector); + } + toFragmentDefinitionNode() { + return { + kind: graphql_1.Kind.FRAGMENT_DEFINITION, + name: { + kind: graphql_1.Kind.NAME, + value: this.name + }, + typeCondition: { + kind: graphql_1.Kind.NAMED_TYPE, + name: { + kind: graphql_1.Kind.NAME, + value: this.typeCondition.name + } + }, + selectionSet: this.selectionSet.toSelectionSetNode() + }; + } + canApplyAtType(type) { + return ((0, types_1.sameType)(this.typeCondition, type) + || ((0, definitions_1.isAbstractType)(this.typeCondition) && !(0, definitions_1.isUnionType)(type) && (0, types_1.isDirectSubtype)(this.typeCondition, type))); + } + toString(indent) { + return (indent !== null && indent !== void 0 ? indent : '') + `fragment ${this.name} on ${this.typeCondition}${this.appliedDirectivesToString()} ${this.selectionSet.toString(false, true, indent)}`; + } +} +exports.NamedFragmentDefinition = NamedFragmentDefinition; +class NamedFragments { + constructor() { + this.fragments = new utils_1.MapWithCachedArrays(); + } + isEmpty() { + return this.fragments.size === 0; + } + variables() { + let variables = []; + for (const fragment of this.fragments.values()) { + variables = (0, definitions_1.mergeVariables)(variables, fragment.variables()); + } + return variables; + } + names() { + return this.fragments.keys(); + } + add(fragment) { + if (this.fragments.has(fragment.name)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Duplicate fragment name '${fragment}'`); + } + this.fragments.set(fragment.name, fragment); + } + addIfNotExist(fragment) { + if (!this.fragments.has(fragment.name)) { + this.fragments.set(fragment.name, fragment); + } + } + maybeApplyingAtType(type) { + return this.fragments.values().filter(f => f.canApplyAtType(type)); + } + without(names) { + if (!names.some(n => this.fragments.has(n))) { + return this; + } + const newFragments = new NamedFragments(); + for (const fragment of this.fragments.values()) { + if (!names.includes(fragment.name)) { + const updatedSelection = fragment.selectionSet.expandFragments(names, false); + const newFragment = updatedSelection === fragment.selectionSet + ? fragment + : new NamedFragmentDefinition(fragment.schema(), fragment.name, fragment.typeCondition, updatedSelection); + newFragments.add(newFragment); + } + } + return newFragments; + } + get(name) { + return this.fragments.get(name); + } + has(name) { + return this.fragments.has(name); + } + definitions() { + return this.fragments.values(); + } + validate() { + for (const fragment of this.fragments.values()) { + fragment.selectionSet.validate(); + } + } + toFragmentDefinitionNodes() { + return this.definitions().map(f => f.toFragmentDefinitionNode()); + } + toString(indent) { + return this.definitions().map(f => f.toString(indent)).join('\n\n'); + } +} +exports.NamedFragments = NamedFragments; +class Freezable { + constructor() { + this._isFrozen = false; + } + freeze() { + if (!this.isFrozen()) { + this.freezeInternals(); + this._isFrozen = true; + } + return this.us(); + } + isFrozen() { + return this._isFrozen; + } + cloneIfFrozen() { + return this.isFrozen() ? this.clone() : this.us(); + } +} +class DeferNormalizer { + constructor() { + this.index = 0; + this.assignedLabels = new Set(); + this.deferConditions = new utils_1.SetMultiMap(); + this.usedLabels = new Set(); + } + init(selectionSet) { + let hasNonLabelledOrConditionalDefers = false; + let hasDefers = false; + const stack = selectionSet.selections().concat(); + while (stack.length > 0) { + const selection = stack.pop(); + if (selection.kind === 'FragmentSelection') { + const deferArgs = selection.element().deferDirectiveArgs(); + if (deferArgs) { + hasDefers = true; + if (!deferArgs.label || deferArgs.if !== undefined) { + hasNonLabelledOrConditionalDefers = true; + } + if (deferArgs.label) { + this.usedLabels.add(deferArgs.label); + } + } + } + if (selection.selectionSet) { + selection.selectionSet.selections().forEach((s) => stack.push(s)); + } + } + return { hasDefers, hasNonLabelledOrConditionalDefers }; + } + nextLabel() { + return `qp__${this.index++}`; + } + newLabel() { + let candidate = this.nextLabel(); + while (this.usedLabels.has(candidate)) { + candidate = this.nextLabel(); + } + this.assignedLabels.add(candidate); + return candidate; + } + registerCondition(label, condition) { + this.deferConditions.add(condition.name, label); + } +} +class SelectionSet extends Freezable { + constructor(parentType, fragments) { + super(); + this.parentType = parentType; + this.fragments = fragments; + this._selections = new utils_1.MultiMap(); + this._selectionCount = 0; + validate(!(0, definitions_1.isLeafType)(parentType), () => `Cannot have selection on non-leaf type ${parentType}`); + } + us() { + return this; + } + selections(reversedOrder = false) { + if (!this._cachedSelections) { + const selections = new Array(this._selectionCount); + let idx = 0; + for (const byResponseName of this._selections.values()) { + for (const selection of byResponseName) { + selections[idx++] = selection; + } + } + this._cachedSelections = selections; + } + (0, utils_1.assert)(this._cachedSelections, 'Cache should have been populated'); + if (reversedOrder && this._cachedSelections.length > 1) { + const reversed = new Array(this._selectionCount); + for (let i = 0; i < this._selectionCount; i++) { + reversed[i] = this._cachedSelections[this._selectionCount - i - 1]; + } + return reversed; + } + return this._cachedSelections; + } + usedVariables() { + let variables = []; + for (const byResponseName of this._selections.values()) { + for (const selection of byResponseName) { + variables = (0, definitions_1.mergeVariables)(variables, selection.usedVariables()); + } + } + if (this.fragments) { + variables = (0, definitions_1.mergeVariables)(variables, this.fragments.variables()); + } + return variables; + } + collectUsedFragmentNames(collector) { + for (const byResponseName of this._selections.values()) { + for (const selection of byResponseName) { + selection.collectUsedFragmentNames(collector); + } + } + } + optimize(fragments) { + if (!fragments || fragments.isEmpty()) { + return this; + } + if (this.fragments && this.fragments.definitions().some(def => fragments.get(def.name))) { + return this; + } + const optimized = new SelectionSet(this.parentType, fragments); + for (const selection of this.selections()) { + optimized.add(selection.optimize(fragments)); + } + return optimized; + } + expandFragments(names, updateSelectionSetFragments = true) { + var _a; + if (names && names.length === 0) { + return this; + } + const newFragments = updateSelectionSetFragments + ? (names ? (_a = this.fragments) === null || _a === void 0 ? void 0 : _a.without(names) : undefined) + : this.fragments; + const withExpanded = new SelectionSet(this.parentType, newFragments); + for (const selection of this.selections()) { + const expanded = selection.expandFragments(names, updateSelectionSetFragments); + if (Array.isArray(expanded)) { + withExpanded.addAll(expanded); + } + else { + withExpanded.add(expanded); + } + } + return withExpanded; + } + lazyMap(mapper) { + let updatedSelections = undefined; + const selections = this.selections(); + for (let i = 0; i < selections.length; i++) { + const selection = selections[i]; + const updated = mapper(selection); + if (updated !== selection && !updatedSelections) { + updatedSelections = []; + for (let j = 0; j < i; j++) { + updatedSelections.push(selections[j]); + } + } + if (!!updated && updatedSelections) { + if (updated instanceof SelectionSet) { + updated.selections().forEach((s) => updatedSelections.push(s)); + } + else { + updatedSelections.push(updated); + } + } + } + if (!updatedSelections) { + return this; + } + return new SelectionSet(this.parentType, this.fragments).addAll(updatedSelections); + } + withoutDefer(labelsToRemove) { + (0, utils_1.assert)(!this.fragments, 'Not yet supported'); + return this.lazyMap((selection) => selection.withoutDefer(labelsToRemove)); + } + withNormalizedDefer(normalizer) { + (0, utils_1.assert)(!this.fragments, 'Not yet supported'); + return this.lazyMap((selection) => selection.withNormalizedDefer(normalizer)); + } + filter(predicate) { + return this.lazyMap((selection) => selection.filter(predicate)); + } + withoutEmptyBranches() { + const updated = this.filter((selection) => { var _a; return ((_a = selection.selectionSet) === null || _a === void 0 ? void 0 : _a.isEmpty()) !== true; }); + return updated.isEmpty() ? undefined : updated; + } + freezeInternals() { + for (const selection of this.selections()) { + selection.freeze(); + } + } + mergeIn(selectionSet) { + for (const selection of selectionSet.selections()) { + this.add(selection); + } + } + addAll(selections) { + selections.forEach(s => this.add(s)); + return this; + } + add(selection) { + (0, utils_1.assert)(!this.isFrozen(), () => `Cannot add to frozen selection: ${this}`); + const toAdd = selection.updateForAddingTo(this); + const key = toAdd.key(); + const existing = this._selections.get(key); + if (existing) { + for (const existingSelection of existing) { + if (existingSelection.kind === toAdd.kind && haveSameDirectives(existingSelection.element(), toAdd.element())) { + if (toAdd.selectionSet) { + existingSelection.selectionSet.mergeIn(toAdd.selectionSet); + } + return existingSelection; + } + } + } + this._selections.add(key, toAdd); + ++this._selectionCount; + this._cachedSelections = undefined; + return toAdd; + } + addPath(path, onPathEnd) { + let previousSelections = this; + let currentSelections = this; + for (const element of path) { + validate(currentSelections, () => `Cannot apply selection ${element} to non-selectable parent type "${previousSelections.parentType}"`); + const mergedSelection = currentSelections.add(selectionOfElement(element)); + previousSelections = currentSelections; + currentSelections = mergedSelection.selectionSet; + } + if (onPathEnd) { + onPathEnd(currentSelections); + } + } + addSelectionSetNode(node, variableDefinitions, fieldAccessor = (type, name) => type.field(name)) { + if (!node) { + return; + } + for (const selectionNode of node.selections) { + this.addSelectionNode(selectionNode, variableDefinitions, fieldAccessor); + } + } + addSelectionNode(node, variableDefinitions, fieldAccessor = (type, name) => type.field(name)) { + this.add(this.nodeToSelection(node, variableDefinitions, fieldAccessor)); + } + nodeToSelection(node, variableDefinitions, fieldAccessor) { + var _a, _b; + let selection; + switch (node.kind) { + case graphql_1.Kind.FIELD: + const definition = fieldAccessor(this.parentType, node.name.value); + validate(definition, () => `Cannot query field "${node.name.value}" on type "${this.parentType}".`, this.parentType.sourceAST); + const type = (0, definitions_1.baseType)(definition.type); + selection = new FieldSelection(new Field(definition, (0, values_1.argumentsFromAST)(definition.coordinate, node.arguments, definition), variableDefinitions, (_a = node.alias) === null || _a === void 0 ? void 0 : _a.value), (0, definitions_1.isLeafType)(type) ? undefined : new SelectionSet(type, this.fragments)); + if (node.selectionSet) { + validate(selection.selectionSet, () => `Unexpected selection set on leaf field "${selection.element()}"`, selection.element().definition.sourceAST); + selection.selectionSet.addSelectionSetNode(node.selectionSet, variableDefinitions, fieldAccessor); + } + break; + case graphql_1.Kind.INLINE_FRAGMENT: + const element = new FragmentElement(this.parentType, (_b = node.typeCondition) === null || _b === void 0 ? void 0 : _b.name.value); + selection = new InlineFragmentSelection(element, new SelectionSet(element.typeCondition ? element.typeCondition : element.parentType, this.fragments)); + selection.selectionSet.addSelectionSetNode(node.selectionSet, variableDefinitions, fieldAccessor); + break; + case graphql_1.Kind.FRAGMENT_SPREAD: + const fragmentName = node.name.value; + validate(this.fragments, () => `Cannot find fragment name "${fragmentName}" (no fragments were provided)`); + selection = new FragmentSpreadSelection(this.parentType, this.fragments, fragmentName); + break; + } + addDirectiveNodesToElement(node.directives, selection.element()); + return selection; + } + equals(that) { + if (this === that) { + return true; + } + if (this._selections.size !== that._selections.size) { + return false; + } + for (const [key, thisSelections] of this._selections) { + const thatSelections = that._selections.get(key); + if (!thatSelections + || thisSelections.length !== thatSelections.length + || !thisSelections.every(thisSelection => thatSelections.some(thatSelection => thisSelection.equals(thatSelection)))) { + return false; + } + } + return true; + } + contains(that) { + if (this._selections.size < that._selections.size) { + return false; + } + for (const [key, thatSelections] of that._selections) { + const thisSelections = this._selections.get(key); + if (!thisSelections + || (thisSelections.length < thatSelections.length + || !thatSelections.every(thatSelection => thisSelections.some(thisSelection => thisSelection.contains(thatSelection))))) { + return false; + } + } + return true; + } + validate() { + validate(!this.isEmpty(), () => `Invalid empty selection set`); + for (const selection of this.selections()) { + selection.validate(); + } + } + isEmpty() { + return this._selections.size === 0; + } + toSelectionSetNode() { + if (this.isEmpty()) { + return { + kind: graphql_1.Kind.SELECTION_SET, + selections: [{ + kind: graphql_1.Kind.FIELD, + name: { + kind: graphql_1.Kind.NAME, + value: '...', + }, + }] + }; + } + return { + kind: graphql_1.Kind.SELECTION_SET, + selections: Array.from(this.selectionsInPrintOrder(), s => s.toSelectionNode()) + }; + } + selectionsInPrintOrder() { + const typenameSelection = this._selections.get(definitions_1.typenameFieldName); + const isNonAliasedTypenameSelection = (s) => s.kind === 'FieldSelection' && !s.field.alias && s.field.name === definitions_1.typenameFieldName; + if (typenameSelection) { + return typenameSelection.concat(this.selections().filter(s => !isNonAliasedTypenameSelection(s))); + } + else { + return this.selections(); + } + } + toOperationPaths() { + return this.toOperationPathsInternal([]); + } + toOperationPathsInternal(parentPaths) { + return this.selections().flatMap((selection) => { + const updatedPaths = parentPaths.map(path => path.concat(selection.element())); + return selection.selectionSet + ? selection.selectionSet.toOperationPathsInternal(updatedPaths) + : updatedPaths; + }); + } + forEachElement(callback) { + var _a; + const stack = this.selections().concat(); + while (stack.length > 0) { + const selection = stack.pop(); + callback(selection.element()); + (_a = selection.selectionSet) === null || _a === void 0 ? void 0 : _a.selections(true).forEach((s) => stack.push(s)); + } + } + clone() { + const cloned = new SelectionSet(this.parentType); + for (const selection of this.selections()) { + const clonedSelection = selection.clone(); + cloned._selections.add(clonedSelection.key(), clonedSelection); + ++cloned._selectionCount; + } + return cloned; + } + toOperationString(rootKind, variableDefinitions, operationName, expandFragments = false, prettyPrint = true) { + const indent = prettyPrint ? '' : undefined; + const fragmentsDefinitions = !expandFragments && this.fragments && !this.fragments.isEmpty() + ? this.fragments.toString(indent) + "\n\n" + : ""; + if (rootKind == "query" && !operationName && variableDefinitions.isEmpty()) { + return fragmentsDefinitions + this.toString(expandFragments, true, indent); + } + const nameAndVariables = operationName + ? " " + (operationName + (variableDefinitions.isEmpty() ? "" : variableDefinitions.toString())) + : (variableDefinitions.isEmpty() ? "" : " " + variableDefinitions.toString()); + return fragmentsDefinitions + rootKind + nameAndVariables + " " + this.toString(expandFragments, true, indent); + } + toString(expandFragments = true, includeExternalBrackets = true, indent) { + if (indent === undefined) { + const selectionsToString = this.selections().map(s => s.toString(expandFragments)).join(' '); + return includeExternalBrackets ? '{ ' + selectionsToString + ' }' : selectionsToString; + } + else { + const selectionIndent = includeExternalBrackets ? indent + " " : indent; + const selectionsToString = this.selections().map(s => s.toString(expandFragments, selectionIndent)).join('\n'); + return includeExternalBrackets + ? '{\n' + selectionsToString + '\n' + indent + '}' + : selectionsToString; + } + } +} +exports.SelectionSet = SelectionSet; +function allFieldDefinitionsInSelectionSet(selection) { + const stack = Array.from(selection.selections()); + const allFields = []; + while (stack.length > 0) { + const selection = stack.pop(); + if (selection.kind === 'FieldSelection') { + allFields.push(selection.field.definition); + } + if (selection.selectionSet) { + stack.push(...selection.selectionSet.selections()); + } + } + return allFields; +} +exports.allFieldDefinitionsInSelectionSet = allFieldDefinitionsInSelectionSet; +function selectionSetOfElement(element, subSelection) { + const selectionSet = new SelectionSet(element.parentType); + selectionSet.add(selectionOfElement(element, subSelection)); + return selectionSet; +} +exports.selectionSetOfElement = selectionSetOfElement; +function selectionOfElement(element, subSelection) { + return element.kind === 'Field' ? new FieldSelection(element, subSelection) : new InlineFragmentSelection(element, subSelection); +} +exports.selectionOfElement = selectionOfElement; +class FieldSelection extends Freezable { + constructor(field, initialSelectionSet) { + super(); + this.field = field; + this.kind = 'FieldSelection'; + const type = (0, definitions_1.baseType)(field.definition.type); + this.selectionSet = (0, definitions_1.isLeafType)(type) ? undefined : (initialSelectionSet ? initialSelectionSet.cloneIfFrozen() : new SelectionSet(type)); + } + us() { + return this; + } + key() { + return this.element().responseName(); + } + element() { + return this.field; + } + usedVariables() { + var _a, _b; + return (0, definitions_1.mergeVariables)(this.element().variables(), (_b = (_a = this.selectionSet) === null || _a === void 0 ? void 0 : _a.usedVariables()) !== null && _b !== void 0 ? _b : []); + } + collectUsedFragmentNames(collector) { + if (this.selectionSet) { + this.selectionSet.collectUsedFragmentNames(collector); + } + } + optimize(fragments) { + const optimizedSelection = this.selectionSet ? this.selectionSet.optimize(fragments) : undefined; + const fieldBaseType = (0, definitions_1.baseType)(this.field.definition.type); + if ((0, definitions_1.isCompositeType)(fieldBaseType) && optimizedSelection) { + for (const candidate of fragments.maybeApplyingAtType(fieldBaseType)) { + if (optimizedSelection.equals(candidate.selectionSet)) { + const fragmentSelection = new FragmentSpreadSelection(fieldBaseType, fragments, candidate.name); + return new FieldSelection(this.field, selectionSetOf(fieldBaseType, fragmentSelection)); + } + } + } + return this.selectionSet === optimizedSelection + ? this + : new FieldSelection(this.field, optimizedSelection); + } + filter(predicate) { + if (!this.selectionSet) { + return predicate(this) ? this : undefined; + } + const updatedSelectionSet = this.selectionSet.filter(predicate); + const thisWithFilteredSelectionSet = this.selectionSet === updatedSelectionSet + ? this + : new FieldSelection(this.field, updatedSelectionSet); + return predicate(thisWithFilteredSelectionSet) ? thisWithFilteredSelectionSet : undefined; + } + freezeInternals() { + var _a; + (_a = this.selectionSet) === null || _a === void 0 ? void 0 : _a.freeze(); + } + expandFragments(names, updateSelectionSetFragments = true) { + const expandedSelection = this.selectionSet ? this.selectionSet.expandFragments(names, updateSelectionSetFragments) : undefined; + return this.selectionSet === expandedSelection + ? this + : new FieldSelection(this.field, expandedSelection); + } + fieldArgumentsToAST() { + const entries = Object.entries(this.field.args); + if (entries.length === 0) { + return undefined; + } + return entries.map(([n, v]) => { + return { + kind: graphql_1.Kind.ARGUMENT, + name: { kind: graphql_1.Kind.NAME, value: n }, + value: (0, values_1.valueToAST)(v, this.field.definition.argument(n).type), + }; + }); + } + validate() { + var _a; + this.field.validate(); + validate(!(this.selectionSet && this.selectionSet.isEmpty()), () => `Invalid empty selection set for field "${this.field.definition.coordinate}" of non-leaf type ${this.field.definition.type}`, this.field.definition.sourceAST); + (_a = this.selectionSet) === null || _a === void 0 ? void 0 : _a.validate(); + } + updateForAddingTo(selectionSet) { + var _a; + const updatedField = this.field.updateForAddingTo(selectionSet); + if (this.field === updatedField) { + return this.cloneIfFrozen(); + } + const updatedBaseType = (0, definitions_1.baseType)(updatedField.definition.type); + let updatedSelectionSet; + if (this.selectionSet && this.selectionSet.parentType !== updatedBaseType) { + (0, utils_1.assert)((0, definitions_1.isCompositeType)(updatedBaseType), `Expected ${updatedBaseType.coordinate} to be composite but ${updatedBaseType.kind}`); + updatedSelectionSet = new SelectionSet(updatedBaseType); + for (const selection of this.selectionSet.selections()) { + updatedSelectionSet.add(selection); + } + } + else { + updatedSelectionSet = (_a = this.selectionSet) === null || _a === void 0 ? void 0 : _a.cloneIfFrozen(); + } + return new FieldSelection(updatedField, updatedSelectionSet); + } + toSelectionNode() { + var _a; + const alias = this.field.alias ? { kind: graphql_1.Kind.NAME, value: this.field.alias, } : undefined; + return { + kind: graphql_1.Kind.FIELD, + name: { + kind: graphql_1.Kind.NAME, + value: this.field.name, + }, + alias, + arguments: this.fieldArgumentsToAST(), + directives: this.element().appliedDirectivesToDirectiveNodes(), + selectionSet: (_a = this.selectionSet) === null || _a === void 0 ? void 0 : _a.toSelectionSetNode() + }; + } + withUpdatedSubSelection(newSubSelection) { + return new FieldSelection(this.field, newSubSelection); + } + equals(that) { + if (this === that) { + return true; + } + if (!(that instanceof FieldSelection) || !this.field.equals(that.field)) { + return false; + } + if (!this.selectionSet) { + return !that.selectionSet; + } + return !!that.selectionSet && this.selectionSet.equals(that.selectionSet); + } + contains(that) { + if (!(that instanceof FieldSelection) || !this.field.equals(that.field)) { + return false; + } + if (!that.selectionSet) { + return true; + } + return !!this.selectionSet && this.selectionSet.contains(that.selectionSet); + } + namedFragments() { + var _a; + return (_a = this.selectionSet) === null || _a === void 0 ? void 0 : _a.fragments; + } + withoutDefer(labelsToRemove) { + var _a; + const updatedSubSelections = (_a = this.selectionSet) === null || _a === void 0 ? void 0 : _a.withoutDefer(labelsToRemove); + return updatedSubSelections === this.selectionSet + ? this + : new FieldSelection(this.field, updatedSubSelections); + } + withNormalizedDefer(normalizer) { + var _a; + const updatedSubSelections = (_a = this.selectionSet) === null || _a === void 0 ? void 0 : _a.withNormalizedDefer(normalizer); + return updatedSubSelections === this.selectionSet + ? this + : new FieldSelection(this.field, updatedSubSelections); + } + clone() { + if (!this.selectionSet) { + return this; + } + return new FieldSelection(this.field, this.selectionSet.clone()); + } + toString(expandFragments = true, indent) { + return (indent !== null && indent !== void 0 ? indent : '') + this.field + (this.selectionSet ? ' ' + this.selectionSet.toString(expandFragments, true, indent) : ''); + } +} +exports.FieldSelection = FieldSelection; +class FragmentSelection extends Freezable { + constructor() { + super(...arguments); + this.kind = 'FragmentSelection'; + } + us() { + return this; + } + validateDeferAndStream() { + if (this.element().hasDefer() || this.element().hasStream()) { + const schemaDef = this.element().schema().schemaDefinition; + const parentType = this.element().parentType; + validate(schemaDef.rootType('mutation') !== parentType && schemaDef.rootType('subscription') !== parentType, () => { var _a; return `The @defer and @stream directives cannot be used on ${(_a = schemaDef.roots().filter((t) => t.type === parentType).pop()) === null || _a === void 0 ? void 0 : _a.rootKind} root type "${parentType}"`; }); + } + } + usedVariables() { + return (0, definitions_1.mergeVariables)(this.element().variables(), this.selectionSet.usedVariables()); + } + filter(predicate) { + const selectionSet = this.selectionSet; + const updatedSelectionSet = selectionSet.filter(predicate); + const thisWithFilteredSelectionSet = updatedSelectionSet === selectionSet + ? this + : new InlineFragmentSelection(this.element(), updatedSelectionSet); + return predicate(thisWithFilteredSelectionSet) ? thisWithFilteredSelectionSet : undefined; + } + freezeInternals() { + this.selectionSet.freeze(); + } + equals(that) { + if (this === that) { + return true; + } + return (that instanceof FragmentSelection) + && this.element().equals(that.element()) + && this.selectionSet.equals(that.selectionSet); + } + contains(that) { + return (that instanceof FragmentSelection) + && this.element().equals(that.element()) + && this.selectionSet.contains(that.selectionSet); + } + clone() { + return new InlineFragmentSelection(this.element(), this.selectionSet.clone()); + } +} +exports.FragmentSelection = FragmentSelection; +class InlineFragmentSelection extends FragmentSelection { + constructor(fragmentElement, initialSelectionSet) { + super(); + this.fragmentElement = fragmentElement; + this._selectionSet = initialSelectionSet + ? initialSelectionSet.cloneIfFrozen() + : new SelectionSet(fragmentElement.typeCondition ? fragmentElement.typeCondition : fragmentElement.parentType); + } + key() { + var _a, _b; + return (_b = (_a = this.element().typeCondition) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : ''; + } + validate() { + this.validateDeferAndStream(); + validate(!this.selectionSet.isEmpty(), () => `Invalid empty selection set for fragment "${this.element()}"`); + this.selectionSet.validate(); + } + updateForAddingTo(selectionSet) { + var _a; + const updatedFragment = this.element().updateForAddingTo(selectionSet); + if (this.element() === updatedFragment) { + return this.cloneIfFrozen(); + } + const updatedCastedType = updatedFragment.castedType(); + let updatedSelectionSet; + if (this.selectionSet.parentType !== updatedCastedType) { + updatedSelectionSet = new SelectionSet(updatedCastedType); + for (const selection of this.selectionSet.selections()) { + updatedSelectionSet.add(selection); + } + } + else { + updatedSelectionSet = (_a = this.selectionSet) === null || _a === void 0 ? void 0 : _a.cloneIfFrozen(); + } + return new InlineFragmentSelection(updatedFragment, updatedSelectionSet); + } + get selectionSet() { + return this._selectionSet; + } + namedFragments() { + return this.selectionSet.fragments; + } + element() { + return this.fragmentElement; + } + toSelectionNode() { + const typeCondition = this.element().typeCondition; + return { + kind: graphql_1.Kind.INLINE_FRAGMENT, + typeCondition: typeCondition + ? { + kind: graphql_1.Kind.NAMED_TYPE, + name: { + kind: graphql_1.Kind.NAME, + value: typeCondition.name, + }, + } + : undefined, + directives: this.element().appliedDirectivesToDirectiveNodes(), + selectionSet: this.selectionSet.toSelectionSetNode() + }; + } + optimize(fragments) { + let optimizedSelection = this.selectionSet.optimize(fragments); + const typeCondition = this.element().typeCondition; + if (typeCondition) { + for (const candidate of fragments.maybeApplyingAtType(typeCondition)) { + if (optimizedSelection.equals(candidate.selectionSet)) { + const spread = new FragmentSpreadSelection(this.element().parentType, fragments, candidate.name); + if ((0, types_1.sameType)(typeCondition, candidate.typeCondition)) { + this.fragmentElement.appliedDirectives.forEach((directive) => { + spread.element().applyDirective(directive.definition, directive.arguments()); + }); + return spread; + } + optimizedSelection = selectionSetOf(spread.element().parentType, spread); + break; + } + } + } + return this.selectionSet === optimizedSelection + ? this + : new InlineFragmentSelection(this.fragmentElement, optimizedSelection); + } + expandFragments(names, updateSelectionSetFragments = true) { + const expandedSelection = this.selectionSet.expandFragments(names, updateSelectionSetFragments); + return this.selectionSet === expandedSelection + ? this + : new InlineFragmentSelection(this.element(), expandedSelection); + } + collectUsedFragmentNames(collector) { + this.selectionSet.collectUsedFragmentNames(collector); + } + withoutDefer(labelsToRemove) { + const updatedSubSelections = this.selectionSet.withoutDefer(labelsToRemove); + const deferArgs = this.fragmentElement.deferDirectiveArgs(); + const hasDeferToRemove = deferArgs && (!labelsToRemove || (deferArgs.label && labelsToRemove.has(deferArgs.label))); + if (updatedSubSelections === this.selectionSet && !hasDeferToRemove) { + return this; + } + const newFragment = hasDeferToRemove ? this.fragmentElement.withoutDefer() : this.fragmentElement; + if (!newFragment) { + return updatedSubSelections; + } + return new InlineFragmentSelection(newFragment, updatedSubSelections); + } + withNormalizedDefer(normalizer) { + const newFragment = this.fragmentElement.withNormalizedDefer(normalizer); + const updatedSubSelections = this.selectionSet.withNormalizedDefer(normalizer); + if (!newFragment) { + return updatedSubSelections; + } + return newFragment === this.fragmentElement && updatedSubSelections === this.selectionSet + ? this + : new InlineFragmentSelection(newFragment, updatedSubSelections); + } + withUpdatedSubSelection(newSubSelection) { + return new InlineFragmentSelection(this.fragmentElement, newSubSelection); + } + toString(expandFragments = true, indent) { + return (indent !== null && indent !== void 0 ? indent : '') + this.fragmentElement + ' ' + this.selectionSet.toString(expandFragments, true, indent); + } +} +class FragmentSpreadSelection extends FragmentSelection { + constructor(sourceType, fragments, fragmentName) { + super(); + this.fragments = fragments; + const fragmentDefinition = fragments.get(fragmentName); + validate(fragmentDefinition, () => `Unknown fragment "...${fragmentName}"`); + this.namedFragment = fragmentDefinition; + this._element = new FragmentElement(sourceType, fragmentDefinition.typeCondition); + for (const directive of fragmentDefinition.appliedDirectives) { + this._element.applyDirective(directive.definition, directive.arguments()); + } + } + key() { + return '...' + this.namedFragment.name; + } + element() { + return this._element; + } + namedFragments() { + return this.fragments; + } + get selectionSet() { + return this.namedFragment.selectionSet; + } + validate() { + this.validateDeferAndStream(); + } + toSelectionNode() { + const spreadDirectives = this.spreadDirectives(); + const directiveNodes = spreadDirectives.length === 0 + ? undefined + : spreadDirectives.map(directive => { + return { + kind: graphql_1.Kind.DIRECTIVE, + name: { + kind: graphql_1.Kind.NAME, + value: directive.name, + }, + arguments: directive.argumentsToAST() + }; + }); + return { + kind: graphql_1.Kind.FRAGMENT_SPREAD, + name: { kind: graphql_1.Kind.NAME, value: this.namedFragment.name }, + directives: directiveNodes, + }; + } + optimize(_) { + return this; + } + updateForAddingTo(_selectionSet) { + return this; + } + expandFragments(names, updateSelectionSetFragments = true) { + if (names && !names.includes(this.namedFragment.name)) { + return this; + } + const expandedSubSelections = this.selectionSet.expandFragments(names, updateSelectionSetFragments); + return (0, types_1.sameType)(this._element.parentType, this.namedFragment.typeCondition) && this._element.appliedDirectives.length === 0 + ? expandedSubSelections.selections() + : new InlineFragmentSelection(this._element, expandedSubSelections); + } + collectUsedFragmentNames(collector) { + this.selectionSet.collectUsedFragmentNames(collector); + const usageCount = collector.get(this.namedFragment.name); + collector.set(this.namedFragment.name, usageCount === undefined ? 1 : usageCount + 1); + } + withoutDefer(_labelsToRemove) { + (0, utils_1.assert)(false, 'Unsupported, see `Operation.withoutDefer`'); + } + withNormalizedDefer(_normalizezr) { + (0, utils_1.assert)(false, 'Unsupported, see `Operation.withAllDeferLabelled`'); + } + spreadDirectives() { + return this._element.appliedDirectives.slice(this.namedFragment.appliedDirectives.length); + } + withUpdatedSubSelection(_) { + (0, utils_1.assert)(false, `Unssupported`); + } + toString(expandFragments = true, indent) { + if (expandFragments) { + return (indent !== null && indent !== void 0 ? indent : '') + this._element + ' ' + this.selectionSet.toString(true, true, indent); + } + else { + const directives = this.spreadDirectives(); + const directiveString = directives.length == 0 ? '' : ' ' + directives.join(' '); + return (indent !== null && indent !== void 0 ? indent : '') + '...' + this.namedFragment.name + directiveString; + } + } +} +function operationFromDocument(schema, document, options) { + let operation; + const operationName = options === null || options === void 0 ? void 0 : options.operationName; + const fragments = new NamedFragments(); + document.definitions.forEach(definition => { + switch (definition.kind) { + case graphql_1.Kind.OPERATION_DEFINITION: + validate(!operation || operationName, () => 'Must provide operation name if query contains multiple operations.'); + if (!operationName || (definition.name && definition.name.value === operationName)) { + operation = definition; + } + break; + case graphql_1.Kind.FRAGMENT_DEFINITION: + const name = definition.name.value; + const typeName = definition.typeCondition.name.value; + const typeCondition = schema.type(typeName); + if (!typeCondition) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Unknown type "${typeName}" for fragment "${name}"`, { nodes: definition }); + } + if (!(0, definitions_1.isCompositeType)(typeCondition)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid fragment "${name}" on non-composite type "${typeName}"`, { nodes: definition }); + } + const fragment = new NamedFragmentDefinition(schema, name, typeCondition, new SelectionSet(typeCondition, fragments)); + addDirectiveNodesToElement(definition.directives, fragment); + fragments.add(fragment); + break; + } + }); + validate(operation, () => operationName ? `Unknown operation named "${operationName}"` : 'No operation found in provided document.'); + const variableDefinitions = operation.variableDefinitions + ? (0, definitions_1.variableDefinitionsFromAST)(schema, operation.variableDefinitions) + : new definitions_1.VariableDefinitions(); + document.definitions.forEach(definition => { + switch (definition.kind) { + case graphql_1.Kind.FRAGMENT_DEFINITION: + const fragment = fragments.get(definition.name.value); + fragment.selectionSet.addSelectionSetNode(definition.selectionSet, variableDefinitions); + break; + } + }); + fragments.validate(); + return operationFromAST({ schema, operation, fragments, validateInput: options === null || options === void 0 ? void 0 : options.validate }); +} +exports.operationFromDocument = operationFromDocument; +function operationFromAST({ schema, operation, fragments, validateInput, }) { + var _a; + const rootType = schema.schemaDefinition.root(operation.operation); + validate(rootType, () => `The schema has no "${operation.operation}" root type defined`); + const variableDefinitions = operation.variableDefinitions ? (0, definitions_1.variableDefinitionsFromAST)(schema, operation.variableDefinitions) : new definitions_1.VariableDefinitions(); + return new Operation(operation.operation, parseSelectionSet({ + parentType: rootType.type, + source: operation.selectionSet, + variableDefinitions, + fragments, + validate: validateInput, + }), variableDefinitions, (_a = operation.name) === null || _a === void 0 ? void 0 : _a.value); +} +function parseOperation(schema, operation, options) { + return operationFromDocument(schema, (0, graphql_1.parse)(operation), options); +} +exports.parseOperation = parseOperation; +function parseSelectionSet({ parentType, source, variableDefinitions, fragments, fieldAccessor, validate = true, }) { + const node = typeof source === 'string' + ? parseOperationAST(source.trim().startsWith('{') ? source : `{${source}}`).selectionSet + : source; + const selectionSet = new SelectionSet(parentType, fragments); + selectionSet.addSelectionSetNode(node, variableDefinitions !== null && variableDefinitions !== void 0 ? variableDefinitions : new definitions_1.VariableDefinitions(), fieldAccessor); + if (validate) + selectionSet.validate(); + return selectionSet; +} +exports.parseSelectionSet = parseSelectionSet; +function parseOperationAST(source) { + const parsed = (0, graphql_1.parse)(source); + validate(parsed.definitions.length === 1, () => 'Selections should contain a single definitions, found ' + parsed.definitions.length); + const def = parsed.definitions[0]; + validate(def.kind === graphql_1.Kind.OPERATION_DEFINITION, () => 'Expected an operation definition but got a ' + def.kind); + return def; +} +function operationToDocument(operation) { + var _a; + const operationAST = { + kind: graphql_1.Kind.OPERATION_DEFINITION, + operation: operation.rootKind, + name: operation.name ? { kind: graphql_1.Kind.NAME, value: operation.name } : undefined, + selectionSet: operation.selectionSet.toSelectionSetNode(), + variableDefinitions: operation.variableDefinitions.toVariableDefinitionNodes(), + }; + const fragmentASTs = operation.selectionSet.fragments + ? (_a = operation.selectionSet.fragments) === null || _a === void 0 ? void 0 : _a.toFragmentDefinitionNodes() + : []; + return { + kind: graphql_1.Kind.DOCUMENT, + definitions: [operationAST].concat(fragmentASTs), + }; +} +exports.operationToDocument = operationToDocument; +//# sourceMappingURL=operations.js.map + +/***/ }), + +/***/ 7678: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.computeShareables = void 0; +const _1 = __webpack_require__(415); +function computeShareables(schema) { + const metadata = (0, _1.federationMetadata)(schema); + (0, _1.assert)(metadata, 'Schema should be a federation subgraph'); + const keyDirective = metadata.keyDirective(); + const providesDirective = metadata.providesDirective(); + const shareableDirective = metadata.isFed2Schema() ? metadata.shareableDirective() : undefined; + const shareableFields = new Set(); + const addKeyFields = (type) => { + for (const key of type.appliedDirectivesOf(keyDirective)) { + (0, _1.collectTargetFields)({ + parentType: type, + directive: key, + includeInterfaceFieldsImplementations: true, + validate: false, + }).forEach((f) => shareableFields.add(f.coordinate)); + } + }; + for (const type of schema.objectTypes()) { + addKeyFields(type); + const shareablesOnType = shareableDirective ? type.appliedDirectivesOf(shareableDirective) : []; + for (const field of type.fields()) { + const fieldIsShareable = shareableDirective && field.hasAppliedDirective(shareableDirective) + || (shareablesOnType.length > 0 && shareablesOnType.some((d) => field.ofExtension() === d.ofExtension())); + if (fieldIsShareable) { + shareableFields.add(field.coordinate); + } + for (const provides of field.appliedDirectivesOf(providesDirective)) { + (0, _1.collectTargetFields)({ + parentType: (0, _1.baseType)(field.type), + directive: provides, + includeInterfaceFieldsImplementations: true, + validate: false, + }).forEach((f) => { + if (metadata.isFieldExternal(f)) { + shareableFields.add(f.coordinate); + } + }); + } + } + } + for (const type of schema.interfaceTypes()) { + addKeyFields(type); + } + return (field) => shareableFields.has(field.coordinate); +} +exports.computeShareables = computeShareables; +//# sourceMappingURL=precompute.js.map + +/***/ }), + +/***/ 2850: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.printDirectiveDefinition = exports.printTypeDefinitionAndExtensions = exports.printType = exports.printSchema = exports.orderPrintedDefinitions = exports.defaultPrintOptions = void 0; +const utils_1 = __webpack_require__(9724); +const values_1 = __webpack_require__(3421); +exports.defaultPrintOptions = { + indentString: " ", + definitionsOrder: ['schema', 'directives', 'types'], + rootTypesOrder: ['query', 'mutation', 'subscription'], + mergeTypesAndExtensions: false, + showAllBuiltIns: false, + noDescriptions: false, + typeFilter: () => true, + fieldFilter: () => true, + directiveApplicationFilter: () => true, +}; +function orderPrintedDefinitions(options) { + return { + ...options, + typeCompareFn: (t1, t2) => t1.name.localeCompare(t2.name), + directiveCompareFn: (t1, t2) => t1.name.localeCompare(t2.name), + }; +} +exports.orderPrintedDefinitions = orderPrintedDefinitions; +function isDefinitionOrderValid(options) { + return options.definitionsOrder.length === 3 + && options.definitionsOrder.indexOf('schema') >= 0 + && options.definitionsOrder.indexOf('types') >= 0 + && options.definitionsOrder.indexOf('directives') >= 0; +} +function validateOptions(options) { + if (!isDefinitionOrderValid(options)) { + throw new Error(`'definitionsOrder' should be a 3-element array containing 'schema', 'types' and 'directives' in the desired order (got: [${options.definitionsOrder.join(', ')}])`); + } +} +function printSchema(schema, options = exports.defaultPrintOptions) { + validateOptions(options); + let directives = options.showAllBuiltIns ? schema.allDirectives() : schema.directives(); + if (options.directiveDefinitionFilter) { + directives = directives.filter(options.directiveDefinitionFilter); + } + if (options.directiveCompareFn) { + directives = directives.concat().sort(options.directiveCompareFn); + } + let types = options.showAllBuiltIns ? schema.allTypes() : schema.types(); + if (options.typeFilter) { + types = types.filter(options.typeFilter); + } + if (options.typeCompareFn) { + types = types.concat().sort(options.typeCompareFn); + } + const definitions = new Array(3); + definitions[options.definitionsOrder.indexOf('schema')] = printSchemaDefinitionAndExtensions(schema.schemaDefinition, options); + definitions[options.definitionsOrder.indexOf('directives')] = directives.map(directive => printDirectiveDefinition(directive, options)); + definitions[options.definitionsOrder.indexOf('types')] = types.flatMap(type => printTypeDefinitionAndExtensions(type, options)); + return definitions.flat().join('\n\n'); +} +exports.printSchema = printSchema; +function definitionAndExtensions(element, options) { + return options.mergeTypesAndExtensions ? [undefined] : [null, ...element.extensions()]; +} +function printSchemaDefinitionAndExtensions(schemaDefinition, options) { + return printDefinitionAndExtensions(schemaDefinition, options, printSchemaDefinitionOrExtension); +} +function printDefinitionAndExtensions(t, options, printer) { + return definitionAndExtensions(t, options) + .map(ext => printer(t, options, ext)) + .filter(v => v !== undefined); +} +function printIsExtension(extension) { + return extension ? 'extend ' : ''; +} +function forExtension(ts, extension) { + if (extension === undefined) { + return ts; + } + return ts.filter(r => { var _a; return ((_a = r.ofExtension()) !== null && _a !== void 0 ? _a : null) === extension; }); +} +function orderRoots(roots, options) { + return roots.concat().sort((r1, r2) => options.rootTypesOrder.indexOf(r1.rootKind) - options.rootTypesOrder.indexOf(r2.rootKind)); +} +function appliedDirectives(element, options, extension) { + let directives = forExtension(element.appliedDirectives, extension); + if (options.directiveApplicationFilter) { + directives = directives.filter(options.directiveApplicationFilter); + } + return directives; +} +function printSchemaDefinitionOrExtension(schemaDefinition, options, extension) { + const roots = forExtension(schemaDefinition.roots(), extension); + const directives = appliedDirectives(schemaDefinition, options, extension); + if (!roots.length && !directives.length) { + return undefined; + } + if (!extension && !directives.length && isSchemaOfCommonNames(schemaDefinition)) { + return undefined; + } + const rootEntries = orderRoots(roots, options).map((rootType) => `${options.indentString}${rootType.rootKind}: ${rootType.type}`); + return printDescription(schemaDefinition, options, extension) + + printIsExtension(extension) + + 'schema' + + printAppliedDirectives(directives, options, true, rootEntries.length !== 0) + + (directives.length === 0 ? ' ' : '') + + (rootEntries.length === 0 ? '' : '{\n' + rootEntries.join('\n') + '\n}'); +} +function isSchemaOfCommonNames(schema) { + return !schema.description && schema.roots().every(r => r.isDefaultRootName()); +} +function printType(type, options = exports.defaultPrintOptions) { + const definitionAndExtensions = printTypeDefinitionAndExtensions(type, options); + (0, utils_1.assert)(definitionAndExtensions.length == 1, `Type ${type} is built from more than 1 definition or extension`); + return definitionAndExtensions[0]; +} +exports.printType = printType; +function printTypeDefinitionAndExtensions(type, options = exports.defaultPrintOptions) { + switch (type.kind) { + case 'ScalarType': return printDefinitionAndExtensions(type, options, printScalarDefinitionOrExtension); + case 'ObjectType': return printDefinitionAndExtensions(type, options, (t, options, ext) => printFieldBasedTypeDefinitionOrExtension('type', t, options, ext)); + case 'InterfaceType': return printDefinitionAndExtensions(type, options, (t, options, ext) => printFieldBasedTypeDefinitionOrExtension('interface', t, options, ext)); + case 'UnionType': return printDefinitionAndExtensions(type, options, printUnionDefinitionOrExtension); + case 'EnumType': return printDefinitionAndExtensions(type, options, printEnumDefinitionOrExtension); + case 'InputObjectType': return printDefinitionAndExtensions(type, options, printInputDefinitionOrExtension); + } +} +exports.printTypeDefinitionAndExtensions = printTypeDefinitionAndExtensions; +function printDirectiveDefinition(directive, options = exports.defaultPrintOptions) { + const locations = directive.locations.join(' | '); + return `${printDescription(directive, options, null)}directive ${directive}${printArgs(directive.arguments(), options)}${directive.repeatable ? ' repeatable' : ''} on ${locations}`; +} +exports.printDirectiveDefinition = printDirectiveDefinition; +function printAppliedDirectives(appliedDirectives, options, onNewLines = false, endWithNewLine = onNewLines) { + if (appliedDirectives.length == 0) { + return ""; + } + const joinStr = onNewLines ? '\n' + options.indentString : ' '; + const directives = appliedDirectives.map(d => d.toString()).join(joinStr); + return onNewLines ? '\n' + options.indentString + directives + (endWithNewLine ? '\n' : '') : ' ' + directives; +} +function printDescription(element, options, extension, indentation = '', firstInBlock = true) { + if (extension || element.description === undefined || options.noDescriptions) { + return ''; + } + const preferMultipleLines = element.description.length > 70; + const blockString = printBlockString(element.description, '', preferMultipleLines); + const prefix = indentation && !firstInBlock ? '\n' + indentation : indentation; + return prefix + blockString.replace(/\n/g, '\n' + indentation) + '\n'; +} +function printScalarDefinitionOrExtension(type, options, extension) { + const directives = appliedDirectives(type, options, extension); + if (extension && !directives.length) { + return undefined; + } + return `${printDescription(type, options, extension)}${printIsExtension(extension)}scalar ${type.name}${printAppliedDirectives(directives, options, true, false)}`; +} +function printImplementedInterfaces(implementations) { + return implementations.length + ? ' implements ' + implementations.map(i => i.interface.name).join(' & ') + : ''; +} +function printFieldBasedTypeDefinitionOrExtension(kind, type, options, extension) { + const directives = appliedDirectives(type, options, extension); + const interfaces = forExtension(type.interfaceImplementations(), extension); + let fields = forExtension(type.fields(), extension); + if (options.fieldFilter) { + fields = fields.filter(options.fieldFilter); + } + if (!directives.length && !interfaces.length && !fields.length && (extension || !type.preserveEmptyDefinition)) { + return undefined; + } + return printDescription(type, options, extension) + + printIsExtension(extension) + + kind + ' ' + type + + printImplementedInterfaces(interfaces) + + printAppliedDirectives(directives, options, true, fields.length > 0) + + (directives.length === 0 && fields.length > 0 ? ' ' : '') + + printFields(fields, options); +} +function printUnionDefinitionOrExtension(type, options, extension) { + const directives = appliedDirectives(type, options, extension); + const members = forExtension(type.members(), extension); + if (!directives.length && !members.length && (extension || !type.preserveEmptyDefinition)) { + return undefined; + } + const possibleTypes = members.length ? ' = ' + members.map(m => m.type).join(' | ') : ''; + return printDescription(type, options, extension) + + printIsExtension(extension) + + 'union ' + type + + printAppliedDirectives(directives, options, true, members.length > 0) + + possibleTypes; +} +function printEnumDefinitionOrExtension(type, options, extension) { + const directives = appliedDirectives(type, options, extension); + const values = forExtension(type.values, extension); + if (!directives.length && !values.length && (extension || !type.preserveEmptyDefinition)) { + return undefined; + } + const vals = values.map((v, i) => printDescription(v, options, extension, options.indentString, !i) + + options.indentString + + v + + printAppliedDirectives(v.appliedDirectives, options)); + return printDescription(type, options, extension) + + printIsExtension(extension) + + 'enum ' + type + + printAppliedDirectives(directives, options, true, vals.length > 0) + + (directives.length === 0 && vals.length > 0 ? ' ' : '') + + printBlock(vals); +} +function printInputDefinitionOrExtension(type, options, extension) { + const directives = appliedDirectives(type, options, extension); + const fields = forExtension(type.fields(), extension); + if (!directives.length && !fields.length && (extension || !type.preserveEmptyDefinition)) { + return undefined; + } + return printDescription(type, options, extension) + + printIsExtension(extension) + + 'input ' + type + + printAppliedDirectives(directives, options, true, fields.length > 0) + + (directives.length === 0 && fields.length > 0 ? ' ' : '') + + printFields(fields, options); +} +function printFields(fields, options) { + return printBlock(fields.map((f, i) => printDescription(f, options, undefined, options.indentString, !i) + + options.indentString + + printField(f, options) + + printAppliedDirectives(appliedDirectives(f, options), options))); +} +function printField(field, options) { + const args = field.kind == 'FieldDefinition' ? printArgs(field.arguments(), options, options.indentString) : ''; + const defaultValue = field.kind === 'InputFieldDefinition' && field.defaultValue !== undefined + ? ' = ' + (0, values_1.valueToString)(field.defaultValue, field.type) + : ''; + return `${field.name}${args}: ${field.type}${defaultValue}`; +} +function printArgs(args, options, indentation = '') { + if (args.length === 0) { + return ''; + } + if (args.every(arg => !arg.description)) { + return '(' + args.map(arg => printArg(arg, options)).join(', ') + ')'; + } + const formattedArgs = args + .map((arg, i) => printDescription(arg, options, null, ' ' + indentation, !i) + ' ' + indentation + printArg(arg, options)) + .join('\n'); + return `(\n${formattedArgs}\n${indentation})`; +} +function printArg(arg, options) { + return `${arg}${printAppliedDirectives(appliedDirectives(arg, options), options)}`; +} +function printBlock(items) { + return items.length !== 0 ? '{\n' + items.join('\n') + '\n}' : ''; +} +function printBlockString(value, indentation = '', preferMultipleLines = false) { + const isSingleLine = value.indexOf('\n') === -1; + const hasLeadingSpace = value[0] === ' ' || value[0] === '\t'; + const hasTrailingQuote = value[value.length - 1] === '"'; + const hasTrailingSlash = value[value.length - 1] === '\\'; + const printAsMultipleLines = !isSingleLine || + hasTrailingQuote || + hasTrailingSlash || + preferMultipleLines; + let result = ''; + if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) { + result += '\n' + indentation; + } + result += indentation ? value.replace(/\n/g, '\n' + indentation) : value; + if (printAsMultipleLines) { + result += '\n'; + } + return '"""' + result.replace(/"""/g, '\\"""') + '"""'; +} +//# sourceMappingURL=print.js.map + +/***/ }), + +/***/ 5015: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.upgradeSubgraphsIfNecessary = exports.RemovedTagOnExternal = exports.FieldsArgumentCoercionToString = exports.ProvidesOnNonCompositeRemoval = exports.ProvidesOrRequiresOnInterfaceFieldRemoval = exports.KeyOnInterfaceRemoval = exports.ShareableTypeAddition = exports.ShareableFieldAddition = exports.InactiveProvidesOrRequiresFieldsRemoval = exports.InactiveProvidesOrRequiresRemoval = exports.TypeWithOnlyUnusedExternalRemoval = exports.UnusedExternalRemoval = exports.ExternalOnInterfaceRemoval = exports.TypeExtensionRemoval = exports.ExternalOnTypeExtensionRemoval = void 0; +const graphql_1 = __webpack_require__(8929); +const error_1 = __webpack_require__(8116); +const definitions_1 = __webpack_require__(4177); +const federation_1 = __webpack_require__(4408); +const utils_1 = __webpack_require__(9724); +const federationSpec_1 = __webpack_require__(9480); +const values_1 = __webpack_require__(3421); +class ExternalOnTypeExtensionRemoval { + constructor(field) { + this.field = field; + this.id = 'EXTERNAL_ON_TYPE_EXTENSION_REMOVAL'; + } + toString() { + return `Removed @external from field "${this.field}" as it is a key of an extension type`; + } +} +exports.ExternalOnTypeExtensionRemoval = ExternalOnTypeExtensionRemoval; +class TypeExtensionRemoval { + constructor(type) { + this.type = type; + this.id = 'TYPE_EXTENSION_REMOVAL'; + } + toString() { + return `Switched type "${this.type}" from an extension to a definition`; + } +} +exports.TypeExtensionRemoval = TypeExtensionRemoval; +class ExternalOnInterfaceRemoval { + constructor(field) { + this.field = field; + this.id = 'EXTERNAL_ON_INTERFACE_REMOVAL'; + } + toString() { + return `Removed @external directive on interface type field "${this.field}": @external is nonsensical on interface fields`; + } +} +exports.ExternalOnInterfaceRemoval = ExternalOnInterfaceRemoval; +class UnusedExternalRemoval { + constructor(field) { + this.field = field; + this.id = 'UNUSED_EXTERNAL_REMOVAL'; + } + toString() { + return `Removed @external field "${this.field}" as it was not used in any @key, @provides or @requires`; + } +} +exports.UnusedExternalRemoval = UnusedExternalRemoval; +class TypeWithOnlyUnusedExternalRemoval { + constructor(type) { + this.type = type; + this.id = 'TYPE_WITH_ONLY_UNUSED_EXTERNAL_REMOVAL'; + } + toString() { + return `Removed type ${this.type} that is not referenced in the schema and only declares unused @external fields`; + } +} +exports.TypeWithOnlyUnusedExternalRemoval = TypeWithOnlyUnusedExternalRemoval; +class InactiveProvidesOrRequiresRemoval { + constructor(parent, removed) { + this.parent = parent; + this.removed = removed; + this.id = 'INACTIVE_PROVIDES_OR_REQUIRES_REMOVAL'; + } + toString() { + return `Removed directive ${this.removed} on "${this.parent}": none of the fields were truly @external`; + } +} +exports.InactiveProvidesOrRequiresRemoval = InactiveProvidesOrRequiresRemoval; +class InactiveProvidesOrRequiresFieldsRemoval { + constructor(parent, original, updated) { + this.parent = parent; + this.original = original; + this.updated = updated; + this.id = 'INACTIVE_PROVIDES_OR_REQUIRES_FIELDS_REMOVAL'; + } + toString() { + return `Updated directive ${this.original} on "${this.parent}" to ${this.updated}: removed fields that were not truly @external`; + } +} +exports.InactiveProvidesOrRequiresFieldsRemoval = InactiveProvidesOrRequiresFieldsRemoval; +class ShareableFieldAddition { + constructor(field, declaringSubgraphs) { + this.field = field; + this.declaringSubgraphs = declaringSubgraphs; + this.id = 'SHAREABLE_FIELD_ADDITION'; + } + toString() { + return `Added @shareable to field "${this.field}": it is also resolved by ${(0, federation_1.printSubgraphNames)(this.declaringSubgraphs)}`; + } +} +exports.ShareableFieldAddition = ShareableFieldAddition; +class ShareableTypeAddition { + constructor(type, declaringSubgraphs) { + this.type = type; + this.declaringSubgraphs = declaringSubgraphs; + this.id = 'SHAREABLE_TYPE_ADDITION'; + } + toString() { + return `Added @shareable to type "${this.type}": it is a "value type" and is also declared in ${(0, federation_1.printSubgraphNames)(this.declaringSubgraphs)}`; + } +} +exports.ShareableTypeAddition = ShareableTypeAddition; +class KeyOnInterfaceRemoval { + constructor(type) { + this.type = type; + this.id = 'KEY_ON_INTERFACE_REMOVAL'; + } + toString() { + return `Removed @key on interface "${this.type}": while allowed by federation 0.x, @key on interfaces were completely ignored/had no effect`; + } +} +exports.KeyOnInterfaceRemoval = KeyOnInterfaceRemoval; +class ProvidesOrRequiresOnInterfaceFieldRemoval { + constructor(field, directive) { + this.field = field; + this.directive = directive; + this.id = 'PROVIDES_OR_REQUIRES_ON_INTERFACE_FIELD_REMOVAL'; + } + toString() { + return `Removed @${this.directive} on interface field "${this.field}": while allowed by federation 0.x, @${this.directive} on interface fields were completely ignored/had no effect`; + } +} +exports.ProvidesOrRequiresOnInterfaceFieldRemoval = ProvidesOrRequiresOnInterfaceFieldRemoval; +class ProvidesOnNonCompositeRemoval { + constructor(field, type) { + this.field = field; + this.type = type; + this.id = 'PROVIDES_ON_NON_COMPOSITE_REMOVAL'; + } + toString() { + return `Removed @provides directive on field "${this.field}" as it is of non-composite type "${this.type}": while not rejected by federation 0.x, such @provide is nonsensical and was ignored`; + } +} +exports.ProvidesOnNonCompositeRemoval = ProvidesOnNonCompositeRemoval; +class FieldsArgumentCoercionToString { + constructor(element, directive, before, after) { + this.element = element; + this.directive = directive; + this.before = before; + this.after = after; + this.id = 'FIELDS_ARGUMENT_COERCION_TO_STRING'; + } + toString() { + return `Coerced "fields" argument for directive @${this.directive} for "${this.element}" into a string: coerced from ${this.before} to ${this.after}`; + } +} +exports.FieldsArgumentCoercionToString = FieldsArgumentCoercionToString; +class RemovedTagOnExternal { + constructor(application, element) { + this.application = application; + this.element = element; + this.id = 'REMOVED_TAG_ON_EXTERNAL'; + } + toString() { + return `Removed ${this.application} application on @external "${this.element}" as the @tag application is on another definition`; + } +} +exports.RemovedTagOnExternal = RemovedTagOnExternal; +function upgradeSubgraphsIfNecessary(inputs) { + const changes = new Map(); + if (inputs.values().every((s) => s.isFed2Subgraph())) { + return { subgraphs: inputs, changes }; + } + const subgraphs = new federation_1.Subgraphs(); + let errors = []; + for (const subgraph of inputs.values()) { + if (subgraph.isFed2Subgraph()) { + subgraphs.add(subgraph); + } + else { + const otherSubgraphs = inputs.values().filter((s) => s.name !== subgraph.name); + const res = new SchemaUpgrader(subgraph, otherSubgraphs).upgrade(); + if (res.errors) { + errors = errors.concat(res.errors); + } + else { + subgraphs.add(res.upgraded); + changes.set(subgraph.name, res.changes); + } + } + } + return errors.length === 0 ? { subgraphs, changes } : { errors }; +} +exports.upgradeSubgraphsIfNecessary = upgradeSubgraphsIfNecessary; +function isFederationTypeExtension(type) { + const metadata = (0, federation_1.federationMetadata)(type.schema()); + (0, utils_1.assert)(metadata, 'Should be a subgraph schema'); + const hasExtend = type.hasAppliedDirective(metadata.extendsDirective()); + return (type.hasExtensionElements() || hasExtend) + && ((0, definitions_1.isObjectType)(type) || (0, definitions_1.isInterfaceType)(type)) + && (hasExtend || !type.hasNonExtensionElements()); +} +function isRootTypeExtension(type) { + const metadata = (0, federation_1.federationMetadata)(type.schema()); + (0, utils_1.assert)(metadata, 'Should be a subgraph schema'); + return (0, definitions_1.isObjectType)(type) + && type.isRootType() + && (type.hasAppliedDirective(metadata.extendsDirective()) || (type.hasExtensionElements() && !type.hasNonExtensionElements())); +} +function resolvesField(subgraph, field) { + const metadata = subgraph.metadata(); + const t = subgraph.schema.type(field.parent.name); + if (!t || !(0, definitions_1.isObjectType)(t)) { + return false; + } + const f = t.field(field.name); + return !!f && (!metadata.isFieldExternal(f) || metadata.isFieldPartiallyExternal(f)); +} +function getField(schema, typeName, fieldName) { + const type = schema.type(typeName); + return type && (0, definitions_1.isCompositeType)(type) ? type.field(fieldName) : undefined; +} +class SchemaUpgrader { + constructor(originalSubgraph, otherSubgraphs) { + this.originalSubgraph = originalSubgraph; + this.otherSubgraphs = otherSubgraphs; + this.changes = new utils_1.MultiMap(); + this.errors = []; + this.schema = originalSubgraph.schema.clone(); + this.renameFederationTypes(); + this.subgraph = new federation_1.Subgraph(originalSubgraph.name, originalSubgraph.url, this.schema); + try { + (0, federation_1.setSchemaAsFed2Subgraph)(this.schema); + } + catch (e) { + const causes = (0, error_1.errorCauses)(e); + if (causes) { + causes.forEach((c) => this.addError(c)); + } + else { + throw e; + } + } + this.metadata = this.subgraph.metadata(); + } + addError(e) { + this.errors.push((0, federation_1.addSubgraphToError)(e, this.subgraph.name, error_1.ERRORS.INVALID_GRAPHQL)); + } + renameFederationTypes() { + for (const typeSpec of federationSpec_1.FEDERATION_SPEC_TYPES) { + const typeNameInOriginal = this.originalSubgraph.metadata().federationTypeNameInSchema(typeSpec.name); + const type = this.schema.type(typeNameInOriginal); + if (type) { + type.rename(`federation__${typeSpec.name}`); + } + } + } + external(elt) { + const applications = elt.appliedDirectivesOf(this.metadata.externalDirective()); + return applications.length === 0 ? undefined : applications[0]; + } + addChange(change) { + this.changes.add(change.id, change); + } + checkForExtensionWithNoBase(type) { + var _a; + if (isRootTypeExtension(type) || !isFederationTypeExtension(type)) { + return; + } + const extensionAST = (_a = (0, utils_1.firstOf)(type.extensions().values())) === null || _a === void 0 ? void 0 : _a.sourceAST; + for (const subgraph of this.otherSubgraphs) { + const otherType = subgraph.schema.type(type.name); + if (otherType && otherType.hasNonExtensionElements()) { + return; + } + } + this.addError(error_1.ERRORS.EXTENSION_WITH_NO_BASE.err(`Type "${type}" is an extension type, but there is no type definition for "${type}" in any subgraph.`, { nodes: extensionAST })); + } + preUpgradeValidations() { + for (const type of this.schema.types()) { + this.checkForExtensionWithNoBase(type); + } + } + upgrade() { + this.preUpgradeValidations(); + this.fixFederationDirectivesArguments(); + this.removeExternalOnInterface(); + this.removeExternalOnTypeExtensions(); + this.fixInactiveProvidesAndRequires(); + this.removeTypeExtensions(); + this.removeDirectivesOnInterface(); + this.removeProvidesOnNonComposite(); + this.removeUnusedExternals(); + this.addShareable(); + this.removeTagOnExternal(); + if (this.errors.length > 0) { + return { errors: this.errors }; + } + try { + this.subgraph.validate(); + return { + upgraded: this.subgraph, + changes: this.changes, + }; + } + catch (e) { + const errors = (0, error_1.errorCauses)(e); + if (!errors) { + throw e; + } + return { errors }; + } + } + fixFederationDirectivesArguments() { + var _a; + for (const directive of [this.metadata.keyDirective(), this.metadata.requiresDirective(), this.metadata.providesDirective()]) { + for (const application of Array.from(directive.applications())) { + const fields = application.arguments().fields; + if (typeof fields !== 'string') { + if (Array.isArray(fields) && fields.every((f) => typeof f === 'string')) { + this.replaceFederationDirectiveApplication(application, application.toString(), fields.join(' '), directive.sourceAST); + } + continue; + } + const nodes = application.sourceAST; + if (nodes && nodes.kind === 'Directive') { + for (const argNode of (_a = nodes.arguments) !== null && _a !== void 0 ? _a : []) { + if (argNode.name.value === 'fields') { + if (argNode.value.kind === graphql_1.Kind.ENUM) { + this.replaceFederationDirectiveApplication(application, (0, graphql_1.print)(nodes), fields, { + ...nodes, + arguments: [{ + ...argNode, + value: { + kind: graphql_1.Kind.STRING, + value: fields + } + }] + }); + break; + } + } + } + } + } + } + } + removeExternalOnInterface() { + for (const itf of this.schema.interfaceTypes()) { + for (const field of itf.fields()) { + const external = this.external(field); + if (external) { + this.addChange(new ExternalOnInterfaceRemoval(field.coordinate)); + external.remove(); + } + } + } + } + replaceFederationDirectiveApplication(application, before, fields, updatedSourceAST) { + const directive = application.definition; + const parent = application.parent; + application.remove(); + const newDirective = parent.applyDirective(directive, { fields }); + newDirective.sourceAST = updatedSourceAST; + this.addChange(new FieldsArgumentCoercionToString(parent.coordinate, directive.name, before, newDirective.toString())); + } + fixInactiveProvidesAndRequires() { + (0, federation_1.removeInactiveProvidesAndRequires)(this.schema, (field, original, updated) => { + if (updated) { + this.addChange(new InactiveProvidesOrRequiresFieldsRemoval(field.coordinate, original.toString(), updated.toString())); + } + else { + this.addChange(new InactiveProvidesOrRequiresRemoval(field.coordinate, original.toString())); + } + }); + } + removeExternalOnTypeExtensions() { + for (const type of this.schema.types()) { + if (!(0, definitions_1.isCompositeType)(type)) { + continue; + } + if (!isFederationTypeExtension(type) && !isRootTypeExtension(type)) { + continue; + } + const keyApplications = type.appliedDirectivesOf(this.metadata.keyDirective()); + if (keyApplications.length > 0) { + for (const keyApplication of type.appliedDirectivesOf(this.metadata.keyDirective())) { + (0, federation_1.collectTargetFields)({ + parentType: type, + directive: keyApplication, + includeInterfaceFieldsImplementations: false, + validate: false, + }).forEach((field) => { + if (field.parent !== type) { + return; + } + const external = this.external(field); + if (external) { + this.addChange(new ExternalOnTypeExtensionRemoval(field.coordinate)); + external.remove(); + } + }); + } + } + else { + for (const other of this.otherSubgraphs) { + const typeInOther = other.schema.type(type.name); + if (!typeInOther) { + continue; + } + (0, utils_1.assert)((0, definitions_1.isCompositeType)(typeInOther), () => `Type ${type} is of kind ${type.kind} in ${this.subgraph.name} but ${typeInOther.kind} in ${other.name}`); + const keysInOther = typeInOther.appliedDirectivesOf(other.metadata().keyDirective()); + if (keysInOther.length === 0) { + continue; + } + (0, federation_1.collectTargetFields)({ + parentType: typeInOther, + directive: keysInOther[0], + includeInterfaceFieldsImplementations: false, + validate: false, + }).forEach((field) => { + if (field.parent !== typeInOther) { + return; + } + const ownField = type.field(field.name); + if (!ownField) { + return; + } + const external = this.external(ownField); + if (external) { + this.addChange(new ExternalOnTypeExtensionRemoval(ownField.coordinate)); + external.remove(); + } + }); + } + } + } + } + removeTypeExtensions() { + for (const type of this.schema.types()) { + if (!isFederationTypeExtension(type) && !isRootTypeExtension(type)) { + continue; + } + this.addChange(new TypeExtensionRemoval(type.coordinate)); + type.removeExtensions(); + } + } + removeUnusedExternals() { + for (const type of this.schema.types()) { + if (!(0, definitions_1.isObjectType)(type) && !(0, definitions_1.isInterfaceType)(type)) { + continue; + } + for (const field of type.fields()) { + if (this.metadata.isFieldExternal(field) && !this.metadata.isFieldUsed(field)) { + this.addChange(new UnusedExternalRemoval(field.coordinate)); + field.remove(); + } + } + if (!type.hasFields()) { + if (type.isReferenced()) { + this.addError(error_1.ERRORS.TYPE_WITH_ONLY_UNUSED_EXTERNAL.err(`Type ${type} contains only external fields and all those fields are all unused (they do not appear in any @key, @provides or @requires).`, { nodes: type.sourceAST })); + } + else { + this.addChange(new TypeWithOnlyUnusedExternalRemoval(type.name)); + type.remove(); + } + } + } + } + removeDirectivesOnInterface() { + for (const type of this.schema.interfaceTypes()) { + for (const application of type.appliedDirectivesOf(this.metadata.keyDirective())) { + this.addChange(new KeyOnInterfaceRemoval(type.name)); + application.remove(); + } + for (const field of type.fields()) { + for (const directive of [this.metadata.providesDirective(), this.metadata.requiresDirective()]) { + for (const application of field.appliedDirectivesOf(directive)) { + this.addChange(new ProvidesOrRequiresOnInterfaceFieldRemoval(field.coordinate, directive.name)); + application.remove(); + } + } + } + } + } + removeProvidesOnNonComposite() { + for (const type of this.schema.objectTypes()) { + for (const field of type.fields()) { + if ((0, definitions_1.isCompositeType)((0, definitions_1.baseType)(field.type))) { + continue; + } + for (const application of field.appliedDirectivesOf(this.metadata.providesDirective())) { + this.addChange(new ProvidesOnNonCompositeRemoval(field.coordinate, field.type.toString())); + application.remove(); + } + } + } + } + addShareable() { + const originalMetadata = this.originalSubgraph.metadata(); + const keyDirective = this.metadata.keyDirective(); + const shareableDirective = this.metadata.shareableDirective(); + for (const type of this.schema.objectTypes()) { + if (type.hasAppliedDirective(keyDirective) || type.isRootType()) { + for (const field of type.fields()) { + if (originalMetadata.isFieldShareable(field)) { + continue; + } + const otherResolvingSubgraphs = this.otherSubgraphs.filter((s) => resolvesField(s, field)); + if (otherResolvingSubgraphs.length > 0 && !field.hasAppliedDirective(shareableDirective)) { + field.applyDirective(shareableDirective); + this.addChange(new ShareableFieldAddition(field.coordinate, otherResolvingSubgraphs.map((s) => s.name))); + } + } + } + else { + const otherDeclaringSubgraphs = this.otherSubgraphs.filter((s) => s.schema.type(type.name)); + if (otherDeclaringSubgraphs.length > 0 && !type.hasAppliedDirective(shareableDirective)) { + type.applyDirective(shareableDirective); + this.addChange(new ShareableTypeAddition(type.coordinate, otherDeclaringSubgraphs.map((s) => s.name))); + } + } + } + } + removeTagOnExternal() { + const tagDirective = this.schema.directive('tag'); + if (!tagDirective) { + return; + } + for (const application of Array.from(tagDirective.applications())) { + const element = application.parent; + if (!(element instanceof definitions_1.FieldDefinition)) { + continue; + } + if (this.external(element)) { + const tagIsUsedInOtherDefinition = this.otherSubgraphs + .map((s) => getField(s.schema, element.parent.name, element.name)) + .filter((f) => !(f && f.hasAppliedDirective('external'))) + .some((f) => f && f.appliedDirectivesOf('tag').some((d) => (0, values_1.valueEquals)(application.arguments(), d.arguments()))); + if (tagIsUsedInOtherDefinition) { + this.addChange(new RemovedTagOnExternal(application.toString(), element.coordinate)); + application.remove(); + } + } + } + } +} +//# sourceMappingURL=schemaUpgrader.js.map + +/***/ }), + +/***/ 5388: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +"use strict"; + +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.didYouMean = exports.suggestionList = void 0; +const js_levenshtein_1 = __importDefault(__webpack_require__(9991)); +const utils_1 = __webpack_require__(9724); +function suggestionList(input, options) { + const optionsByDistance = new Map(); + const threshold = Math.floor(input.length * 0.4) + 1; + const inputLowerCase = input.toLowerCase(); + for (const option of options) { + const distance = inputLowerCase === option.toLowerCase() + ? 1 + : (0, js_levenshtein_1.default)(input, option); + if (distance <= threshold) { + optionsByDistance.set(option, distance); + } + } + return (0, utils_1.mapKeys)(optionsByDistance).sort((a, b) => { + const distanceDiff = optionsByDistance.get(a) - optionsByDistance.get(b); + return distanceDiff !== 0 ? distanceDiff : a.localeCompare(b); + }); +} +exports.suggestionList = suggestionList; +const MAX_SUGGESTIONS = 5; +function didYouMean(suggestions) { + const message = ' Did you mean '; + const quotedSuggestions = suggestions.map((x) => `"${x}"`); + switch (suggestions.length) { + case 0: + return ''; + case 1: + return message + quotedSuggestions[0] + '?'; + case 2: + return message + quotedSuggestions[0] + ' or ' + quotedSuggestions[1] + '?'; + } + const selected = quotedSuggestions.slice(0, MAX_SUGGESTIONS); + const lastItem = selected.pop(); + return message + selected.join(', ') + ', or ' + lastItem + '?'; +} +exports.didYouMean = didYouMean; +//# sourceMappingURL=suggestions.js.map + +/***/ }), + +/***/ 9624: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.isFed1Supergraph = exports.validateSupergraph = exports.buildSupergraphSchema = void 0; +const coreSpec_1 = __webpack_require__(9209); +const definitions_1 = __webpack_require__(4177); +const joinSpec_1 = __webpack_require__(6920); +const buildSchema_1 = __webpack_require__(7964); +const extractSubgraphsFromSupergraph_1 = __webpack_require__(8220); +const error_1 = __webpack_require__(8116); +const SUPPORTED_FEATURES = new Set([ + 'https://specs.apollo.dev/core/v0.1', + 'https://specs.apollo.dev/core/v0.2', + 'https://specs.apollo.dev/join/v0.1', + 'https://specs.apollo.dev/join/v0.2', + 'https://specs.apollo.dev/tag/v0.1', + 'https://specs.apollo.dev/tag/v0.2', + 'https://specs.apollo.dev/inaccessible/v0.1', + 'https://specs.apollo.dev/inaccessible/v0.2', +]); +const coreVersionZeroDotOneUrl = coreSpec_1.FeatureUrl.parse('https://specs.apollo.dev/core/v0.1'); +function buildSupergraphSchema(supergraphSdl) { + const schema = typeof supergraphSdl === 'string' + ? (0, buildSchema_1.buildSchema)(supergraphSdl, { validate: false }) + : (0, buildSchema_1.buildSchemaFromAST)(supergraphSdl, { validate: false }); + const [coreFeatures] = validateSupergraph(schema); + checkFeatureSupport(coreFeatures); + schema.validate(); + return [schema, (0, extractSubgraphsFromSupergraph_1.extractSubgraphsNamesAndUrlsFromSupergraph)(schema)]; +} +exports.buildSupergraphSchema = buildSupergraphSchema; +function checkFeatureSupport(coreFeatures) { + const errors = []; + const coreItself = coreFeatures.coreItself; + if (coreItself.url.equals(coreVersionZeroDotOneUrl)) { + const purposefulFeatures = [...coreFeatures.allFeatures()].filter(f => f.purpose); + if (purposefulFeatures.length > 0) { + errors.push(error_1.ERRORS.UNSUPPORTED_LINKED_FEATURE.err(`the \`for:\` argument is unsupported by version ${coreItself.url.version} ` + + `of the core spec. Please upgrade to at least @core v0.2 (https://specs.apollo.dev/core/v0.2).`, { + nodes: (0, definitions_1.sourceASTs)(coreItself.directive, ...purposefulFeatures.map(f => f.directive)) + })); + } + } + for (const feature of coreFeatures.allFeatures()) { + if (feature.url.equals(coreVersionZeroDotOneUrl) || feature.purpose === 'EXECUTION' || feature.purpose === 'SECURITY') { + if (!SUPPORTED_FEATURES.has(feature.url.base.toString())) { + errors.push(error_1.ERRORS.UNSUPPORTED_LINKED_FEATURE.err(`feature ${feature.url} is for: ${feature.purpose} but is unsupported`, { nodes: feature.directive.sourceAST })); + } + } + } + if (errors.length > 0) { + throw (0, coreSpec_1.ErrCoreCheckFailed)(errors); + } +} +function validateSupergraph(supergraph) { + const coreFeatures = supergraph.coreFeatures; + if (!coreFeatures) { + throw error_1.ERRORS.INVALID_FEDERATION_SUPERGRAPH.err("Invalid supergraph: must be a core schema"); + } + const joinFeature = coreFeatures.getByIdentity(joinSpec_1.joinIdentity); + if (!joinFeature) { + throw error_1.ERRORS.INVALID_FEDERATION_SUPERGRAPH.err("Invalid supergraph: must use the join spec"); + } + const joinSpec = joinSpec_1.JOIN_VERSIONS.find(joinFeature.url.version); + if (!joinSpec) { + throw error_1.ERRORS.INVALID_FEDERATION_SUPERGRAPH.err(`Invalid supergraph: uses unsupported join spec version ${joinFeature.url.version} (supported versions: ${joinSpec_1.JOIN_VERSIONS.versions().join(', ')})`); + } + return [coreFeatures, joinSpec]; +} +exports.validateSupergraph = validateSupergraph; +function isFed1Supergraph(supergraph) { + return validateSupergraph(supergraph)[1].version.equals(new coreSpec_1.FeatureVersion(0, 1)); +} +exports.isFed1Supergraph = isFed1Supergraph; +//# sourceMappingURL=supergraphs.js.map + +/***/ }), + +/***/ 1697: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.TAG_VERSIONS = exports.TagSpecDefinition = exports.tagIdentity = void 0; +const graphql_1 = __webpack_require__(8929); +const coreSpec_1 = __webpack_require__(9209); +const definitions_1 = __webpack_require__(4177); +const directiveAndTypeSpecification_1 = __webpack_require__(3208); +const error_1 = __webpack_require__(8116); +const knownCoreFeatures_1 = __webpack_require__(5848); +const types_1 = __webpack_require__(5811); +exports.tagIdentity = 'https://specs.apollo.dev/tag'; +class TagSpecDefinition extends coreSpec_1.FeatureDefinition { + constructor(version) { + super(new coreSpec_1.FeatureUrl(exports.tagIdentity, 'tag', version)); + this.tagLocations = [ + graphql_1.DirectiveLocation.FIELD_DEFINITION, + graphql_1.DirectiveLocation.OBJECT, + graphql_1.DirectiveLocation.INTERFACE, + graphql_1.DirectiveLocation.UNION, + ]; + this.printedTagDefinition = 'directive @tag(name: String!) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION'; + if (!this.isV01()) { + this.tagLocations.push(graphql_1.DirectiveLocation.ARGUMENT_DEFINITION, graphql_1.DirectiveLocation.SCALAR, graphql_1.DirectiveLocation.ENUM, graphql_1.DirectiveLocation.ENUM_VALUE, graphql_1.DirectiveLocation.INPUT_OBJECT, graphql_1.DirectiveLocation.INPUT_FIELD_DEFINITION); + this.printedTagDefinition = 'directive @tag(name: String!) repeatable on FIELD_DEFINITION | INTERFACE | OBJECT | UNION | ARGUMENT_DEFINITION | SCALAR | ENUM | ENUM_VALUE | INPUT_OBJECT | INPUT_FIELD_DEFINITION'; + } + this.tagDirectiveSpec = (0, directiveAndTypeSpecification_1.createDirectiveSpecification)({ + name: 'tag', + locations: this.tagLocations, + repeatable: true, + argumentFct: (schema) => ({ + args: [{ name: 'name', type: new definitions_1.NonNullType(schema.stringType()) }], + errors: [], + }), + }); + } + isV01() { + return this.version.equals(new coreSpec_1.FeatureVersion(0, 1)); + } + addElementsToSchema(schema) { + return this.addDirectiveSpec(schema, this.tagDirectiveSpec); + } + tagDirective(schema) { + return this.directive(schema, 'tag'); + } + checkCompatibleDirective(definition) { + const hasUnknownArguments = Object.keys(definition.arguments()).length > 1; + const nameArg = definition.argument('name'); + const hasValidNameArg = nameArg && (0, types_1.sameType)(nameArg.type, new definitions_1.NonNullType(definition.schema().stringType())); + const hasValidLocations = definition.locations.every(loc => this.tagLocations.includes(loc)); + if (hasUnknownArguments || !hasValidNameArg || !hasValidLocations) { + return error_1.ERRORS.DIRECTIVE_DEFINITION_INVALID.err(`Found invalid @tag directive definition. Please ensure the directive definition in your schema's definitions matches the following:\n\t${this.printedTagDefinition}`); + } + return undefined; + } + allElementNames() { + return ["@tag"]; + } +} +exports.TagSpecDefinition = TagSpecDefinition; +exports.TAG_VERSIONS = new coreSpec_1.FeatureDefinitions(exports.tagIdentity) + .add(new TagSpecDefinition(new coreSpec_1.FeatureVersion(0, 1))) + .add(new TagSpecDefinition(new coreSpec_1.FeatureVersion(0, 2))); +(0, knownCoreFeatures_1.registerKnownFeature)(exports.TAG_VERSIONS); +//# sourceMappingURL=tagSpec.js.map + +/***/ }), + +/***/ 5811: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.isStrictSubtype = exports.isSubtype = exports.isDirectSubtype = exports.sameType = exports.DEFAULT_SUBTYPING_RULES = exports.ALL_SUBTYPING_RULES = void 0; +const definitions_1 = __webpack_require__(4177); +exports.ALL_SUBTYPING_RULES = [ + 'direct', + 'nonNullable_downgrade', + 'list_upgrade', + 'list_propagation', + 'nonNullable_propagation' +]; +exports.DEFAULT_SUBTYPING_RULES = exports.ALL_SUBTYPING_RULES.filter(r => r !== "list_upgrade"); +function sameType(t1, t2) { + if (t1.kind !== t2.kind) { + return false; + } + switch (t1.kind) { + case 'ListType': + return sameType(t1.ofType, t2.ofType); + case 'NonNullType': + return sameType(t1.ofType, t2.ofType); + default: + return t1.name === t2.name; + } +} +exports.sameType = sameType; +function isDirectSubtype(type, maybeSubType, unionMembershipTester = (u, m) => u.hasTypeMember(m), implementsInterfaceTester = (m, i) => m.implementsInterface(i)) { + if ((0, definitions_1.isUnionType)(type)) { + return (0, definitions_1.isObjectType)(maybeSubType) && unionMembershipTester(type, maybeSubType); + } + return implementsInterfaceTester(maybeSubType, type); +} +exports.isDirectSubtype = isDirectSubtype; +function isSubtype(type, maybeSubType, allowedRules = exports.DEFAULT_SUBTYPING_RULES, unionMembershipTester = (u, m) => u.hasTypeMember(m), implementsInterfaceTester = (m, i) => m.implementsInterface(i)) { + return sameType(type, maybeSubType) || isStrictSubtype(type, maybeSubType, allowedRules, unionMembershipTester, implementsInterfaceTester); +} +exports.isSubtype = isSubtype; +function isStrictSubtype(type, maybeSubType, allowedRules = exports.DEFAULT_SUBTYPING_RULES, unionMembershipTester = (u, m) => u.hasTypeMember(m), implementsInterfaceTester = (m, i) => m.implementsInterface(i)) { + switch (maybeSubType.kind) { + case 'ListType': + return allowedRules.includes('list_propagation') + && (0, definitions_1.isListType)(type) + && isSubtype(type.ofType, maybeSubType.ofType, allowedRules, unionMembershipTester, implementsInterfaceTester); + case 'NonNullType': + if ((0, definitions_1.isNonNullType)(type)) { + return allowedRules.includes('nonNullable_propagation') + && isSubtype(type.ofType, maybeSubType.ofType, allowedRules, unionMembershipTester, implementsInterfaceTester); + } + return allowedRules.includes('nonNullable_downgrade') + && isSubtype(type, maybeSubType.ofType, allowedRules, unionMembershipTester, implementsInterfaceTester); + case 'ObjectType': + case 'InterfaceType': + if ((0, definitions_1.isListType)(type)) { + return allowedRules.includes('list_upgrade') + && isSubtype(type.ofType, maybeSubType, allowedRules, unionMembershipTester, implementsInterfaceTester); + } + return allowedRules.includes('direct') + && ((0, definitions_1.isInterfaceType)(type) || (0, definitions_1.isUnionType)(type)) + && isDirectSubtype(type, maybeSubType, unionMembershipTester, implementsInterfaceTester); + default: + return (0, definitions_1.isListType)(type) + && allowedRules.includes('list_upgrade') + && isSubtype(type.ofType, maybeSubType, allowedRules, unionMembershipTester, implementsInterfaceTester); + } +} +exports.isStrictSubtype = isStrictSubtype; +//# sourceMappingURL=types.js.map + +/***/ }), + +/***/ 9724: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.removeArrayElement = exports.isDefined = exports.printHumanReadableList = exports.joinStrings = exports.validateStringContainsBoolean = exports.copyWitNewLength = exports.MapWithCachedArrays = exports.setValues = exports.mapEntries = exports.mapKeys = exports.mapValues = exports.firstOf = exports.arrayEquals = exports.OrderedMap = exports.SetMultiMap = exports.MultiMap = exports.assertUnreachable = exports.assert = void 0; +function assert(condition, message) { + if (!condition) { + throw new Error(typeof message === 'string' ? message : message()); + } +} +exports.assert = assert; +function assertUnreachable(_) { + throw new Error("Didn't expect to get here"); +} +exports.assertUnreachable = assertUnreachable; +class MultiMap extends Map { + add(key, value) { + const values = this.get(key); + if (values) { + values.push(value); + } + else { + this.set(key, [value]); + } + return this; + } + addAll(otherMap) { + for (const [k, vs] of otherMap.entries()) { + for (const v of vs) { + this.add(k, v); + } + } + return this; + } +} +exports.MultiMap = MultiMap; +class SetMultiMap extends Map { + add(key, value) { + let values = this.get(key); + if (!values) { + values = new Set(); + this.set(key, values); + } + values.add(value); + return this; + } + addAll(otherMap) { + for (const [k, vs] of otherMap.entries()) { + for (const v of vs) { + this.add(k, v); + } + } + return this; + } +} +exports.SetMultiMap = SetMultiMap; +class OrderedMap { + constructor(compareFn = OrderedMap.defaultCompareFn) { + this._keys = []; + this._values = new Map(); + this._compareFn = compareFn; + } + static defaultCompareFn(a, b) { + if (a < b) { + return -1; + } + else if (b < a) { + return 1; + } + return 0; + } + add(key, value) { + if (!this._values.has(key)) { + this.insertKeyInOrder(key); + } + this._values.set(key, value); + } + get(key) { + return this._values.get(key); + } + has(key) { + return this._values.has(key); + } + get size() { + return this._keys.length; + } + keys() { + return this._keys; + } + values() { + return this._keys.map(key => { + const v = this._values.get(key); + assert(v, 'value for known key not found in OrderedMap'); + return v; + }); + } + insertKeyInOrder(key) { + let lower = 0; + let upper = this._keys.length - 1; + while (lower <= upper) { + const middle = Math.floor((upper + lower) / 2); + if (this._compareFn(this._keys[middle], key) < 0) { + lower = middle + 1; + } + else { + upper = middle - 1; + } + } + this._keys = this._keys.slice(0, lower).concat(key).concat(this._keys.slice(lower)); + } + *[Symbol.iterator]() { + for (let i = 0; i < this._keys.length; i += 1) { + const v = this._values.get(this._keys[i]); + assert(v, 'value for known key not found in OrderedMap'); + yield v; + } + } +} +exports.OrderedMap = OrderedMap; +function arrayEquals(a, b, equalFct) { + if (a === b) { + return true; + } + if (a.length !== b.length) { + return false; + } + for (let i = 0; i < a.length; ++i) { + const eltEqual = equalFct ? equalFct(a[i], b[i]) : a[i] === b[i]; + if (!eltEqual) { + return false; + } + } + return true; +} +exports.arrayEquals = arrayEquals; +function firstOf(iterable) { + const res = iterable[Symbol.iterator]().next(); + return res.done ? undefined : res.value; +} +exports.firstOf = firstOf; +function mapValues(map) { + const array = new Array(map.size); + let i = 0; + for (const v of map.values()) { + array[i++] = v; + } + return array; +} +exports.mapValues = mapValues; +function mapKeys(map) { + const array = new Array(map.size); + let i = 0; + for (const k of map.keys()) { + array[i++] = k; + } + return array; +} +exports.mapKeys = mapKeys; +function mapEntries(map) { + const array = new Array(map.size); + let i = 0; + for (const entry of map.entries()) { + array[i++] = entry; + } + return array; +} +exports.mapEntries = mapEntries; +function setValues(set) { + const array = new Array(set.size); + let i = 0; + for (const v of set.values()) { + array[i++] = v; + } + return array; +} +exports.setValues = setValues; +class MapWithCachedArrays { + constructor() { + this.map = new Map(); + } + clearCaches() { + this.cachedKeys = undefined; + this.cachedValues = undefined; + } + get size() { + return this.map.size; + } + has(key) { + return this.map.has(key); + } + get(key) { + return this.map.get(key); + } + set(key, value) { + this.map.set(key, value); + this.clearCaches(); + return this; + } + delete(key) { + const deleted = this.map.delete(key); + if (deleted) { + this.clearCaches(); + } + return deleted; + } + clear() { + this.map.clear(); + this.clearCaches(); + } + keys() { + if (!this.cachedKeys) { + this.cachedKeys = mapKeys(this.map); + } + return this.cachedKeys; + } + values() { + if (!this.cachedValues) { + this.cachedValues = mapValues(this.map); + } + return this.cachedValues; + } +} +exports.MapWithCachedArrays = MapWithCachedArrays; +function copyWitNewLength(arr, newLength) { + assert(newLength >= arr.length, () => `${newLength} < ${arr.length}`); + const copy = new Array(newLength); + for (let i = 0; i < arr.length; i++) { + copy[i] = arr[i]; + } + return copy; +} +exports.copyWitNewLength = copyWitNewLength; +function validateStringContainsBoolean(str) { + if (!str) { + return false; + } + switch (str.toLocaleLowerCase()) { + case "true": + case "yes": + case "1": + return true; + case "false": + case "no": + case "0": + return false; + default: + return undefined; + } +} +exports.validateStringContainsBoolean = validateStringContainsBoolean; +function joinStrings(toJoin, sep = ', ', firstSep, lastSep = ' and ') { + if (toJoin.length == 0) { + return ''; + } + const first = toJoin[0]; + if (toJoin.length == 1) { + return first; + } + const last = toJoin[toJoin.length - 1]; + if (toJoin.length == 2) { + return first + (firstSep ? firstSep : lastSep) + last; + } + return first + (firstSep ? firstSep : sep) + toJoin.slice(1, toJoin.length - 1) + lastSep + last; +} +exports.joinStrings = joinStrings; +const DEFAULT_HUMAN_READABLE_LIST_CUTOFF_LENGTH = 100; +function printHumanReadableList(names, { emptyValue, prefix, prefixPlural, lastSeparator, cutoff_output_length, }) { + if (names.length === 0) { + return emptyValue !== null && emptyValue !== void 0 ? emptyValue : ''; + } + if (names.length == 1) { + return prefix ? prefix + ' ' + names[0] : names[0]; + } + const cutoff = cutoff_output_length !== null && cutoff_output_length !== void 0 ? cutoff_output_length : DEFAULT_HUMAN_READABLE_LIST_CUTOFF_LENGTH; + const { lastIdx } = names.reduce(({ lastIdx, length }, name) => { + if (length + name.length > cutoff) { + return { + lastIdx, + length, + }; + } + return { + lastIdx: lastIdx + 1, + length: length + name.length, + }; + }, { lastIdx: 0, length: 0 }); + const toDisplay = names.slice(0, Math.max(1, lastIdx)); + const actualPrefix = prefixPlural + ? prefixPlural + ' ' + : (prefix ? prefix + ' ' : ''); + if (toDisplay.length === names.length) { + return actualPrefix + joinStrings(toDisplay, ', ', undefined, lastSeparator); + } + else { + return actualPrefix + joinStrings(toDisplay, ', ', undefined, ', ') + ', ...'; + } +} +exports.printHumanReadableList = printHumanReadableList; +const isDefined = (t) => t === undefined ? false : true; +exports.isDefined = isDefined; +function removeArrayElement(element, array) { + const index = array.indexOf(element); + if (index >= 0) { + array.splice(index, 1); + return true; + } + else { + return false; + } +} +exports.removeArrayElement = removeArrayElement; +//# sourceMappingURL=utils.js.map + +/***/ }), + +/***/ 5663: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.validateSchema = void 0; +const definitions_1 = __webpack_require__(4177); +const graphql_1 = __webpack_require__(8929); +const values_1 = __webpack_require__(3421); +const introspection_1 = __webpack_require__(9495); +const types_1 = __webpack_require__(5811); +const error_1 = __webpack_require__(8116); +function validateSchema(schema) { + return new Validator(schema).validate(); +} +exports.validateSchema = validateSchema; +class InputObjectCircularRefsValidator { + constructor(onError) { + this.onError = onError; + this.visitedTypes = new Set(); + this.fieldPath = []; + this.fieldPathIndexByTypeName = new Map(); + } + detectCycles(type) { + if (this.visitedTypes.has(type.name)) { + return; + } + this.visitedTypes.add(type.name); + this.fieldPathIndexByTypeName.set(type.name, this.fieldPath.length); + for (const field of type.fields()) { + if ((0, definitions_1.isNonNullType)(field.type) && (0, definitions_1.isInputObjectType)(field.type.ofType)) { + const fieldType = field.type.ofType; + const cycleIndex = this.fieldPathIndexByTypeName.get(fieldType.name); + this.fieldPath.push(field); + if (cycleIndex === undefined) { + this.detectCycles(fieldType); + } + else { + const cyclePath = this.fieldPath.slice(cycleIndex); + const pathStr = cyclePath.map((fieldObj) => fieldObj.name).join('.'); + this.onError(`Cannot reference Input Object "${fieldType.name}" within itself through a series of non-null fields: "${pathStr}".`, { nodes: (0, definitions_1.sourceASTs)(...cyclePath) }); + } + this.fieldPath.pop(); + } + } + this.fieldPathIndexByTypeName.delete(type.name); + } +} +class Validator { + constructor(schema) { + this.schema = schema; + this.emptyVariables = new definitions_1.VariableDefinitions(); + this.hasMissingTypes = false; + this.errors = []; + } + validate() { + for (const type of this.schema.types()) { + this.validateName(type); + switch (type.kind) { + case 'ObjectType': + case 'InterfaceType': + this.validateObjectOrInterfaceType(type); + break; + case 'InputObjectType': + this.validateInputObjectType(type); + break; + case 'UnionType': + this.validateUnionType(type); + break; + case 'EnumType': + this.validateEnumType(type); + break; + } + } + for (const directive of this.schema.allDirectives()) { + this.validateName(directive); + for (const arg of directive.arguments()) { + this.validateArg(arg); + } + for (const application of directive.applications()) { + this.validateDirectiveApplication(directive, application); + } + } + if (!this.hasMissingTypes) { + const refsValidator = new InputObjectCircularRefsValidator((msg, opts) => this.addError(msg, opts)); + for (const type of this.schema.types()) { + switch (type.kind) { + case 'ObjectType': + case 'InterfaceType': + this.validateImplementedInterfaces(type); + break; + case 'InputObjectType': + refsValidator.detectCycles(type); + break; + } + } + } + return this.errors; + } + addError(message, options) { + this.errors.push(error_1.ERRORS.INVALID_GRAPHQL.err(message, options)); + } + validateHasType(elt) { + if (!elt.type) { + this.addError(`Element ${elt.coordinate} does not have a type set`, { nodes: elt.sourceAST }); + this.hasMissingTypes = false; + } + return !!elt.type; + } + validateName(elt) { + if ((0, introspection_1.isIntrospectionName)(elt.name)) { + return; + } + try { + (0, graphql_1.assertName)(elt.name); + } + catch (e) { + this.addError(e.message, elt.sourceAST ? { nodes: elt.sourceAST } : {}); + } + } + validateObjectOrInterfaceType(type) { + if (!type.hasFields()) { + this.addError(`Type ${type.name} must define one or more fields.`, { nodes: type.sourceAST }); + } + for (const field of type.fields()) { + this.validateName(field); + this.validateHasType(field); + for (const arg of field.arguments()) { + this.validateArg(arg); + } + } + } + validateImplementedInterfaces(type) { + if (type.implementsInterface(type.name)) { + this.addError(`Type ${type} cannot implement itself because it would create a circular reference.`, { nodes: (0, definitions_1.sourceASTs)(type, type.interfaceImplementation(type.name)) }); + } + for (const itf of type.interfaces()) { + for (const itfField of itf.fields()) { + const field = type.field(itfField.name); + if (!field) { + this.addError(`Interface field ${itfField.coordinate} expected but ${type} does not provide it.`, { nodes: (0, definitions_1.sourceASTs)(itfField, type) }); + continue; + } + if (this.validateHasType(itfField) && !(0, types_1.isSubtype)(itfField.type, field.type)) { + this.addError(`Interface field ${itfField.coordinate} expects type ${itfField.type} but ${field.coordinate} of type ${field.type} is not a proper subtype.`, { nodes: (0, definitions_1.sourceASTs)(itfField, field) }); + } + for (const itfArg of itfField.arguments()) { + const arg = field.argument(itfArg.name); + if (!arg) { + this.addError(`Interface field argument ${itfArg.coordinate} expected but ${field.coordinate} does not provide it.`, { nodes: (0, definitions_1.sourceASTs)(itfArg, field) }); + continue; + } + if (this.validateHasType(itfArg) && !(0, types_1.sameType)(itfArg.type, arg.type)) { + this.addError(`Interface field argument ${itfArg.coordinate} expects type ${itfArg.type} but ${arg.coordinate} is type ${arg.type}.`, { nodes: (0, definitions_1.sourceASTs)(itfArg, arg) }); + } + } + for (const arg of field.arguments()) { + if (itfField.argument(arg.name)) { + continue; + } + if (arg.isRequired()) { + this.addError(`Field ${field.coordinate} includes required argument ${arg.name} that is missing from the Interface field ${itfField.coordinate}.`, { nodes: (0, definitions_1.sourceASTs)(arg, itfField) }); + } + } + } + for (const itfOfItf of itf.interfaces()) { + if (!type.implementsInterface(itfOfItf)) { + if (itfOfItf === type) { + this.addError(`Type ${type} cannot implement ${itf} because it would create a circular reference.`, { nodes: (0, definitions_1.sourceASTs)(type, itf) }); + } + else { + this.addError(`Type ${type} must implement ${itfOfItf} because it is implemented by ${itf}.`, { nodes: (0, definitions_1.sourceASTs)(type, itf, itfOfItf) }); + } + } + } + } + } + validateInputObjectType(type) { + if (!type.hasFields()) { + this.addError(`Input Object type ${type.name} must define one or more fields.`, { nodes: type.sourceAST }); + } + for (const field of type.fields()) { + this.validateName(field); + if (!this.validateHasType(field)) { + continue; + } + if (field.isRequired() && field.isDeprecated()) { + this.addError(`Required input field ${field.coordinate} cannot be deprecated.`, { nodes: (0, definitions_1.sourceASTs)(field.appliedDirectivesOf('deprecated')[0], field) }); + } + if (field.defaultValue !== undefined && !(0, values_1.isValidValue)(field.defaultValue, field, new definitions_1.VariableDefinitions())) { + this.addError(`Invalid default value (got: ${(0, values_1.valueToString)(field.defaultValue)}) provided for input field ${field.coordinate} of type ${field.type}.`, { nodes: (0, definitions_1.sourceASTs)(field) }); + } + } + } + validateArg(arg) { + this.validateName(arg); + if (!this.validateHasType(arg)) { + return; + } + if (arg.isRequired() && arg.isDeprecated()) { + this.addError(`Required argument ${arg.coordinate} cannot be deprecated.`, { nodes: (0, definitions_1.sourceASTs)(arg.appliedDirectivesOf('deprecated')[0], arg) }); + } + if (arg.defaultValue !== undefined && !(0, values_1.isValidValue)(arg.defaultValue, arg, new definitions_1.VariableDefinitions())) { + this.addError(`Invalid default value (got: ${(0, values_1.valueToString)(arg.defaultValue)}) provided for argument ${arg.coordinate} of type ${arg.type}.`, { nodes: (0, definitions_1.sourceASTs)(arg) }); + } + } + validateUnionType(type) { + if (type.membersCount() === 0) { + this.addError(`Union type ${type.coordinate} must define one or more member types.`, { nodes: type.sourceAST }); + } + } + validateEnumType(type) { + if (type.values.length === 0) { + this.addError(`Enum type ${type.coordinate} must define one or more values.`, { nodes: type.sourceAST }); + } + for (const value of type.values) { + this.validateName(value); + if (value.name === 'true' || value.name === 'false' || value.name === 'null') { + this.addError(`Enum type ${type.coordinate} cannot include value: ${value}.`, { nodes: value.sourceAST }); + } + } + } + validateDirectiveApplication(definition, application) { + for (const argument of definition.arguments()) { + const value = application.arguments()[argument.name]; + if (!value) { + continue; + } + if (argument.type && !(0, values_1.isValidValue)(value, argument, this.emptyVariables)) { + const parent = application.parent; + const parentDesc = parent instanceof definitions_1.NamedSchemaElement + ? parent.coordinate + : 'schema'; + this.addError(`Invalid value for "${argument.coordinate}" of type "${argument.type}" in application of "${definition.coordinate}" to "${parentDesc}".`, { nodes: (0, definitions_1.sourceASTs)(application, argument) }); + } + } + } +} +//# sourceMappingURL=validate.js.map + +/***/ }), + +/***/ 4150: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.KnownTypeNamesInFederationRule = void 0; +const graphql_1 = __webpack_require__(8929); +const suggestions_1 = __webpack_require__(5388); +function KnownTypeNamesInFederationRule(context) { + const schema = context.getSchema(); + const existingTypesMap = schema ? schema.getTypeMap() : Object.create(null); + const definedTypes = Object.create(null); + for (const def of context.getDocument().definitions) { + if ((0, graphql_1.isTypeDefinitionNode)(def) || (0, graphql_1.isTypeExtensionNode)(def)) { + definedTypes[def.name.value] = true; + } + } + const typeNames = Object.keys(existingTypesMap).concat(Object.keys(definedTypes)); + return { + NamedType(node, _1, parent, _2, ancestors) { + var _a; + const typeName = node.name.value; + if (!existingTypesMap[typeName] && !definedTypes[typeName]) { + const definitionNode = (_a = ancestors[2]) !== null && _a !== void 0 ? _a : parent; + const isSDL = definitionNode != null && isSDLNode(definitionNode); + if (isSDL && isStandardTypeName(typeName)) { + return; + } + const suggestedTypes = (0, suggestions_1.suggestionList)(typeName, isSDL ? standardTypeNames.concat(typeNames) : typeNames); + context.reportError(new graphql_1.GraphQLError(`Unknown type "${typeName}".` + (0, suggestions_1.didYouMean)(suggestedTypes), { nodes: node })); + } + }, + }; +} +exports.KnownTypeNamesInFederationRule = KnownTypeNamesInFederationRule; +const standardTypeNames = [...graphql_1.specifiedScalarTypes, ...graphql_1.introspectionTypes].map((type) => type.name); +function isStandardTypeName(typeName) { + return standardTypeNames.indexOf(typeName) !== -1; +} +function isSDLNode(value) { + return (!Array.isArray(value) && + ((0, graphql_1.isTypeSystemDefinitionNode)(value) || (0, graphql_1.isTypeSystemExtensionNode)(value))); +} +//# sourceMappingURL=KnownTypeNamesInFederationRule.js.map + +/***/ }), + +/***/ 3421: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.variablesInValue = exports.argumentsFromAST = exports.valueFromASTUntyped = exports.valueFromAST = exports.isValidValue = exports.valueToAST = exports.valueNodeToConstValueNode = exports.withDefaultValues = exports.argumentsEquals = exports.valueEquals = exports.valueToString = void 0; +const definitions_1 = __webpack_require__(4177); +const graphql_1 = __webpack_require__(8929); +const suggestions_1 = __webpack_require__(5388); +const util_1 = __webpack_require__(9539); +const types_1 = __webpack_require__(5811); +const utils_1 = __webpack_require__(9724); +const error_1 = __webpack_require__(8116); +const MAX_INT = 2147483647; +const MIN_INT = -2147483648; +function valueToString(v, expectedType) { + if (v === undefined || v === null) { + return "null"; + } + if (expectedType && (0, definitions_1.isNonNullType)(expectedType)) { + return valueToString(v, expectedType.ofType); + } + if (expectedType && (0, definitions_1.isCustomScalarType)(expectedType)) { + expectedType = undefined; + } + if ((0, definitions_1.isVariable)(v)) { + return v.toString(); + } + if (Array.isArray(v)) { + let elementsType = undefined; + if (expectedType && (0, definitions_1.isListType)(expectedType)) { + elementsType = expectedType.ofType; + } + return '[' + v.map(e => valueToString(e, elementsType)).join(', ') + ']'; + } + if (expectedType && (0, definitions_1.isListType)(expectedType)) { + return valueToString(v, expectedType.ofType); + } + if (typeof v === 'object') { + if (expectedType && !(0, definitions_1.isInputObjectType)(expectedType)) { + expectedType = undefined; + } + return '{' + Object.keys(v).map(k => { + var _a; + const valueType = expectedType ? (_a = expectedType.field(k)) === null || _a === void 0 ? void 0 : _a.type : undefined; + return `${k}: ${valueToString(v[k], valueType)}`; + }).join(', ') + '}'; + } + if (typeof v === 'string') { + if (expectedType) { + if ((0, definitions_1.isEnumType)(expectedType)) { + return expectedType.value(v) ? v : JSON.stringify(v); + } + if (expectedType === expectedType.schema().idType() && integerStringRegExp.test(v)) { + return v; + } + } + return JSON.stringify(v); + } + return String(v); +} +exports.valueToString = valueToString; +function valueEquals(a, b) { + if (a === b) { + return true; + } + if (Array.isArray(a)) { + return Array.isArray(b) && arrayValueEquals(a, b); + } + if (typeof a === 'object') { + return typeof b === 'object' && objectEquals(a, b); + } + return a === b; +} +exports.valueEquals = valueEquals; +function arrayValueEquals(a, b) { + if (a.length !== b.length) { + return false; + } + for (let i = 0; i < a.length; ++i) { + if (!valueEquals(a[i], b[i])) { + return false; + } + } + return true; +} +function objectEquals(a, b) { + const keys1 = Object.keys(a); + const keys2 = Object.keys(b); + if (keys1.length != keys2.length) { + return false; + } + for (const key of keys1) { + const v1 = a[key]; + const v2 = b[key]; + if (v2 === undefined && !keys2.includes(key)) { + return false; + } + if (!valueEquals(v1, v2)) { + return false; + } + } + return true; +} +function argumentsEquals(args1, args2) { + if (args1 === args2) { + return true; + } + return objectEquals(args1, args2); +} +exports.argumentsEquals = argumentsEquals; +function buildError(message) { + return new Error(message); +} +function applyDefaultValues(value, type) { + if ((0, definitions_1.isVariable)(value)) { + return value; + } + if (value === null) { + if ((0, definitions_1.isNonNullType)(type)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid null value for non-null type ${type} while computing default values`); + } + return null; + } + if ((0, definitions_1.isNonNullType)(type)) { + return applyDefaultValues(value, type.ofType); + } + if ((0, definitions_1.isListType)(type)) { + if (Array.isArray(value)) { + return value.map(v => applyDefaultValues(v, type.ofType)); + } + else { + return applyDefaultValues(value, type.ofType); + } + } + if ((0, definitions_1.isInputObjectType)(type)) { + if (typeof value !== 'object') { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Expected value for type ${type} to be an object, but is ${typeof value}.`); + } + const updated = Object.create(null); + for (const field of type.fields()) { + if (!field.type) { + throw buildError(`Cannot compute default value for field ${field.name} of ${type} as the field type is undefined`); + } + const fieldValue = value[field.name]; + if (fieldValue === undefined) { + if (field.defaultValue !== undefined) { + updated[field.name] = applyDefaultValues(field.defaultValue, field.type); + } + else if ((0, definitions_1.isNonNullType)(field.type)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Field "${field.name}" of required type ${type} was not provided.`); + } + } + else { + updated[field.name] = applyDefaultValues(fieldValue, field.type); + } + } + for (const fieldName of Object.keys(value)) { + if (!type.field(fieldName)) { + const suggestions = (0, suggestions_1.suggestionList)(fieldName, type.fields().map(f => f.name)); + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Field "${fieldName}" is not defined by type "${type}".` + (0, suggestions_1.didYouMean)(suggestions)); + } + } + return updated; + } + return value; +} +function withDefaultValues(value, argument) { + if (!argument.type) { + throw buildError(`Cannot compute default value for argument ${argument} as the type is undefined`); + } + if (value === undefined) { + if (argument.defaultValue) { + return applyDefaultValues(argument.defaultValue, argument.type); + } + } + return applyDefaultValues(value, argument.type); +} +exports.withDefaultValues = withDefaultValues; +const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/; +function objectFieldNodeToConst(field) { + return { ...field, value: valueNodeToConstValueNode(field.value) }; +} +function valueNodeToConstValueNode(value) { + if (value.kind === graphql_1.Kind.NULL + || value.kind === graphql_1.Kind.INT + || value.kind === graphql_1.Kind.FLOAT + || value.kind === graphql_1.Kind.STRING + || value.kind === graphql_1.Kind.BOOLEAN + || value.kind === graphql_1.Kind.ENUM) { + return value; + } + if (value.kind === graphql_1.Kind.LIST) { + const constValues = value.values.map(v => valueNodeToConstValueNode(v)); + return { ...value, values: constValues }; + } + if (value.kind === graphql_1.Kind.OBJECT) { + const constFields = value.fields.map(f => objectFieldNodeToConst(f)); + return { ...value, fields: constFields }; + } + if (value.kind === graphql_1.Kind.VARIABLE) { + throw new Error('Unexpected VariableNode in const AST'); + } + (0, utils_1.assertUnreachable)(value); +} +exports.valueNodeToConstValueNode = valueNodeToConstValueNode; +function valueToAST(value, type) { + if (value === undefined) { + return undefined; + } + if ((0, definitions_1.isNonNullType)(type)) { + const astValue = valueToAST(value, type.ofType); + if ((astValue === null || astValue === void 0 ? void 0 : astValue.kind) === graphql_1.Kind.NULL) { + throw buildError(`Invalid null value ${valueToString(value)} for non-null type ${type}`); + } + return astValue; + } + if (value === null) { + return { kind: graphql_1.Kind.NULL }; + } + if ((0, definitions_1.isVariable)(value)) { + return { kind: graphql_1.Kind.VARIABLE, name: { kind: graphql_1.Kind.NAME, value: value.name } }; + } + if ((0, definitions_1.isCustomScalarType)(type)) { + return valueToASTUntyped(value); + } + if ((0, definitions_1.isListType)(type)) { + const itemType = type.ofType; + const items = Array.from(value); + if (items != null) { + const valuesNodes = []; + for (const item of items) { + const itemNode = valueToAST(item, itemType); + if (itemNode != null) { + valuesNodes.push(itemNode); + } + } + return { kind: graphql_1.Kind.LIST, values: valuesNodes }; + } + return valueToAST(value, itemType); + } + if ((0, definitions_1.isInputObjectType)(type)) { + if (typeof value !== 'object') { + throw buildError(`Invalid non-objet value for input type ${type}, cannot be converted to AST: ${(0, util_1.inspect)(value, true, 10, true)}`); + } + const fieldNodes = []; + for (const field of type.fields()) { + if (!field.type) { + throw buildError(`Cannot convert value ${valueToString(value)} as field ${field} has no type set`); + } + const fieldValue = valueToAST(value[field.name], field.type); + if (fieldValue) { + fieldNodes.push({ + kind: graphql_1.Kind.OBJECT_FIELD, + name: { kind: graphql_1.Kind.NAME, value: field.name }, + value: fieldValue, + }); + } + } + return { kind: graphql_1.Kind.OBJECT, fields: fieldNodes }; + } + if (typeof value === 'boolean') { + return { kind: graphql_1.Kind.BOOLEAN, value: value }; + } + if (typeof value === 'number' && isFinite(value)) { + const stringNum = String(value); + return integerStringRegExp.test(stringNum) + ? { kind: graphql_1.Kind.INT, value: stringNum } + : { kind: graphql_1.Kind.FLOAT, value: stringNum }; + } + if (typeof value === 'string') { + if ((0, definitions_1.isEnumType)(type)) { + return { kind: graphql_1.Kind.ENUM, value: value }; + } + if (type === type.schema().idType() && integerStringRegExp.test(value)) { + return { kind: graphql_1.Kind.INT, value: value }; + } + return { + kind: graphql_1.Kind.STRING, + value: value, + }; + } + throw buildError(`Invalid value for type ${type}, cannot be converted to AST: ${(0, util_1.inspect)(value)}`); +} +exports.valueToAST = valueToAST; +function valueToASTUntyped(value) { + if (value === undefined) { + return undefined; + } + if (value === null) { + return { kind: graphql_1.Kind.NULL }; + } + if ((0, definitions_1.isVariable)(value)) { + return { kind: graphql_1.Kind.VARIABLE, name: { kind: graphql_1.Kind.NAME, value: value.name } }; + } + if (Array.isArray(value)) { + const valuesNodes = []; + for (const item of value) { + const itemNode = valueToASTUntyped(item); + if (itemNode !== undefined) { + valuesNodes.push(itemNode); + } + } + return { kind: graphql_1.Kind.LIST, values: valuesNodes }; + } + if (typeof value === 'object') { + const fieldNodes = []; + for (const key of Object.keys(value)) { + const fieldValue = valueToASTUntyped(value[key]); + if (fieldValue) { + fieldNodes.push({ + kind: graphql_1.Kind.OBJECT_FIELD, + name: { kind: graphql_1.Kind.NAME, value: key }, + value: fieldValue, + }); + } + } + return { kind: graphql_1.Kind.OBJECT, fields: fieldNodes }; + } + if (typeof value === 'boolean') { + return { kind: graphql_1.Kind.BOOLEAN, value: value }; + } + if (typeof value === 'number' && isFinite(value)) { + const stringNum = String(value); + return integerStringRegExp.test(stringNum) + ? { kind: graphql_1.Kind.INT, value: stringNum } + : { kind: graphql_1.Kind.FLOAT, value: stringNum }; + } + if (typeof value === 'string') { + return { kind: graphql_1.Kind.STRING, value: value }; + } + throw buildError(`Invalid value, cannot be converted to AST: ${(0, util_1.inspect)(value, true, 10, true)}`); +} +function isValidVariable(variable, locationType, locationDefault) { + const variableType = variable.type; + if ((0, definitions_1.isNonNullType)(locationType) && !(0, definitions_1.isNonNullType)(variableType)) { + const hasVariableDefault = variable.defaultValue !== undefined && variable.defaultValue !== null; + const hasLocationDefault = locationDefault !== undefined; + if (!hasVariableDefault && !hasLocationDefault) { + return false; + } + return areTypesCompatible(variableType, locationType.ofType); + } + return areTypesCompatible(variableType, locationType); +} +function areTypesCompatible(variableType, locationType) { + if ((0, definitions_1.isNonNullType)(locationType)) { + if (!(0, definitions_1.isNonNullType)(variableType)) { + return false; + } + return areTypesCompatible(variableType.ofType, locationType.ofType); + } + if ((0, definitions_1.isNonNullType)(variableType)) { + return areTypesCompatible(variableType.ofType, locationType); + } + if ((0, definitions_1.isListType)(locationType)) { + if (!(0, definitions_1.isListType)(variableType)) { + return false; + } + return areTypesCompatible(variableType.ofType, locationType.ofType); + } + return !(0, definitions_1.isListType)(variableType) && (0, types_1.sameType)(variableType, locationType); +} +function isValidValue(value, argument, variableDefinitions) { + return isValidValueApplication(value, argument.type, argument.defaultValue, variableDefinitions); +} +exports.isValidValue = isValidValue; +function isValidValueApplication(value, locationType, locationDefault, variableDefinitions) { + if ((0, definitions_1.isVariable)(value)) { + const definition = variableDefinitions.definition(value); + return !!definition && isValidVariable(definition, locationType, locationDefault); + } + if ((0, definitions_1.isNonNullType)(locationType)) { + return value !== null && isValidValueApplication(value, locationType.ofType, undefined, variableDefinitions); + } + if (value === null || value === undefined) { + return true; + } + if ((0, definitions_1.isCustomScalarType)(locationType)) { + return true; + } + if ((0, definitions_1.isListType)(locationType)) { + const itemType = locationType.ofType; + if (Array.isArray(value)) { + return value.every(item => isValidValueApplication(item, itemType, undefined, variableDefinitions)); + } + return isValidValueApplication(value, itemType, locationDefault, variableDefinitions); + } + if ((0, definitions_1.isInputObjectType)(locationType)) { + if (typeof value !== 'object') { + return false; + } + const valueKeys = new Set(Object.keys(value)); + const fieldsAreValid = locationType.fields().every(field => { + valueKeys.delete(field.name); + return isValidValueApplication(value[field.name], field.type, field.defaultValue, variableDefinitions); + }); + const hasUnexpectedField = valueKeys.size !== 0; + return fieldsAreValid && !hasUnexpectedField; + } + const schema = locationType.schema(); + if (typeof value === 'boolean') { + return locationType === schema.booleanType(); + } + if (typeof value === 'number' && isFinite(value)) { + const stringNum = String(value); + if (locationType === schema.intType() || locationType === schema.idType()) { + return integerStringRegExp.test(stringNum); + } + return locationType === schema.floatType(); + } + if (typeof value === 'string') { + if ((0, definitions_1.isEnumType)(locationType)) { + return locationType.value(value) !== undefined; + } + return (0, definitions_1.isScalarType)(locationType) + && locationType !== schema.booleanType() + && locationType !== schema.intType() + && locationType !== schema.floatType(); + } + return false; +} +function valueFromAST(node, expectedType) { + if (node.kind === graphql_1.Kind.NULL) { + if ((0, definitions_1.isNonNullType)(expectedType)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid null value for non-null type "${expectedType}"`); + } + return null; + } + if (node.kind === graphql_1.Kind.VARIABLE) { + return new definitions_1.Variable(node.name.value); + } + if ((0, definitions_1.isNonNullType)(expectedType)) { + expectedType = expectedType.ofType; + } + if ((0, definitions_1.isListType)(expectedType)) { + const baseType = expectedType.ofType; + if (node.kind === graphql_1.Kind.LIST) { + return node.values.map(v => valueFromAST(v, baseType)); + } + return [valueFromAST(node, baseType)]; + } + if ((0, definitions_1.isIntType)(expectedType)) { + if (node.kind !== graphql_1.Kind.INT) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Int cannot represent non-integer value ${(0, graphql_1.print)(node)}.`); + } + const i = parseInt(node.value, 10); + if (i > MAX_INT || i < MIN_INT) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Int cannot represent non 32-bit signed integer value ${i}.`); + } + return i; + } + if ((0, definitions_1.isFloatType)(expectedType)) { + let parsed; + if (node.kind === graphql_1.Kind.INT) { + parsed = parseInt(node.value, 10); + } + else if (node.kind === graphql_1.Kind.FLOAT) { + parsed = parseFloat(node.value); + } + else { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Float can only represent integer or float value, but got a ${node.kind}.`); + } + if (!isFinite(parsed)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Float cannot represent non numeric value ${parsed}.`); + } + return parsed; + } + if ((0, definitions_1.isBooleanType)(expectedType)) { + if (node.kind !== graphql_1.Kind.BOOLEAN) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Boolean cannot represent a non boolean value ${(0, graphql_1.print)(node)}.`); + } + return node.value; + } + if ((0, definitions_1.isStringType)(expectedType)) { + if (node.kind !== graphql_1.Kind.STRING) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`String cannot represent non string value ${(0, graphql_1.print)(node)}.`); + } + return node.value; + } + if ((0, definitions_1.isIDType)(expectedType)) { + if (node.kind !== graphql_1.Kind.STRING && node.kind !== graphql_1.Kind.INT) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`ID cannot represent value ${(0, graphql_1.print)(node)}.`); + } + return node.value; + } + if ((0, definitions_1.isScalarType)(expectedType)) { + return valueFromASTUntyped(node); + } + if ((0, definitions_1.isInputObjectType)(expectedType)) { + if (node.kind !== graphql_1.Kind.OBJECT) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Input Object Type ${expectedType} cannot represent non-object value ${(0, graphql_1.print)(node)}.`); + } + const obj = Object.create(null); + for (const f of node.fields) { + const name = f.name.value; + const field = expectedType.field(name); + if (!field) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Unknown field "${name}" found in value for Input Object Type "${expectedType}".`); + } + obj[name] = valueFromAST(f.value, field.type); + } + return obj; + } + if ((0, definitions_1.isEnumType)(expectedType)) { + if (node.kind !== graphql_1.Kind.STRING && node.kind !== graphql_1.Kind.ENUM) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Enum Type ${expectedType} cannot represent value ${(0, graphql_1.print)(node)}.`); + } + if (!expectedType.value(node.value)) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Enum Type ${expectedType} has no value ${node.value}.`); + } + return node.value; + } + (0, utils_1.assert)(false, () => `Unexpected input type ${expectedType} of kind ${expectedType.kind}.`); +} +exports.valueFromAST = valueFromAST; +function valueFromASTUntyped(node) { + switch (node.kind) { + case graphql_1.Kind.NULL: + return null; + case graphql_1.Kind.INT: + return parseInt(node.value, 10); + case graphql_1.Kind.FLOAT: + return parseFloat(node.value); + case graphql_1.Kind.STRING: + case graphql_1.Kind.ENUM: + case graphql_1.Kind.BOOLEAN: + return node.value; + case graphql_1.Kind.LIST: + return node.values.map(valueFromASTUntyped); + case graphql_1.Kind.OBJECT: + const obj = Object.create(null); + node.fields.forEach(f => obj[f.name.value] = valueFromASTUntyped(f.value)); + return obj; + case graphql_1.Kind.VARIABLE: + return new definitions_1.Variable(node.name.value); + } +} +exports.valueFromASTUntyped = valueFromASTUntyped; +function argumentsFromAST(context, args, argsDefiner) { + var _a; + const values = Object.create(null); + if (args) { + for (const argNode of args) { + const name = argNode.name.value; + const expectedType = (_a = argsDefiner.argument(name)) === null || _a === void 0 ? void 0 : _a.type; + if (!expectedType) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Unknown argument "${name}" found in value: "${context}" has no argument named "${name}"`); + } + try { + values[name] = valueFromAST(argNode.value, expectedType); + } + catch (e) { + if (e instanceof graphql_1.GraphQLError) { + throw error_1.ERRORS.INVALID_GRAPHQL.err(`Invalid value for argument "${name}": ${e.message}`); + } + throw e; + } + } + } + return values; +} +exports.argumentsFromAST = argumentsFromAST; +function variablesInValue(value) { + const variables = []; + collectVariables(value, variables); + return variables; +} +exports.variablesInValue = variablesInValue; +function collectVariables(value, variables) { + if ((0, definitions_1.isVariable)(value)) { + if (!variables.some(v => v.name === value.name)) { + variables.push(value); + } + return; + } + if (!value) { + return; + } + if (Array.isArray(value)) { + value.forEach(v => collectVariables(v, variables)); + } + if (typeof value === 'object') { + Object.keys(value).forEach(k => collectVariables(value[k], variables)); + } +} +//# sourceMappingURL=values.js.map + +/***/ }), + +/***/ 3154: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.buildFederatedSchema = exports.buildSubgraphSchema = void 0; +const util_1 = __webpack_require__(9539); +const graphql_1 = __webpack_require__(8929); +const schema_helper_1 = __webpack_require__(1846); +const federation_internals_1 = __webpack_require__(415); +const types_1 = __webpack_require__(3647); +function buildSubgraphSchema(modulesOrSDL) { + var _a; + let shapedModulesOrSDL; + if ('typeDefs' in modulesOrSDL) { + const { typeDefs, resolvers } = modulesOrSDL; + const augmentedTypeDefs = Array.isArray(typeDefs) ? typeDefs : [typeDefs]; + shapedModulesOrSDL = augmentedTypeDefs.map((typeDefs, i) => { + const module = { typeDefs }; + if (i === 0 && resolvers) + module.resolvers = resolvers; + return module; + }); + } + else { + shapedModulesOrSDL = modulesOrSDL; + } + const modules = (0, schema_helper_1.modulesFromSDL)(shapedModulesOrSDL); + const documentAST = (0, graphql_1.concatAST)(modules.map(module => module.typeDefs)); + const subgraph = (0, federation_internals_1.buildSubgraph)(federation_internals_1.FEDERATION_UNNAMED_SUBGRAPH_NAME, '', documentAST, false); + const sdl = (0, federation_internals_1.printSchema)(subgraph.schema); + const schema = subgraph.schema.toGraphQLJSSchema(); + const queryRootName = (_a = subgraph.schema.schemaDefinition.rootType('query')) === null || _a === void 0 ? void 0 : _a.name; + (0, federation_internals_1.assert)(queryRootName, 'A Query root type should have been added by `buildSubgraph`'); + (0, schema_helper_1.addResolversToSchema)(schema, { + [queryRootName]: { + _service: () => ({ sdl }), + } + }); + if (subgraph.metadata().entityType()) { + (0, schema_helper_1.addResolversToSchema)(schema, { + [queryRootName]: { + _entities: (_source, { representations }, context, info) => (0, types_1.entitiesResolver)({ representations, context, info }), + }, + _Entity: { + __resolveType(parent) { + return parent.__typename; + }, + } + }); + } + for (const module of modules) { + if (!module.resolvers) + continue; + (0, schema_helper_1.addResolversToSchema)(schema, module.resolvers); + } + return schema; +} +exports.buildSubgraphSchema = buildSubgraphSchema; +exports.buildFederatedSchema = (0, util_1.deprecate)(buildSubgraphSchema, `'buildFederatedSchema' is deprecated. Use 'buildSubgraphSchema' instead.`); +//# sourceMappingURL=buildSubgraphSchema.js.map + +/***/ }), + +/***/ 4903: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; +var __webpack_unused_export__; + +__webpack_unused_export__ = ({ value: true }); +__webpack_unused_export__ = exports.en = void 0; +var buildSubgraphSchema_1 = __webpack_require__(3154); +Object.defineProperty(exports, "en", ({ enumerable: true, get: function () { return buildSubgraphSchema_1.buildSubgraphSchema; } })); +var printSubgraphSchema_1 = __webpack_require__(5357); +__webpack_unused_export__ = ({ enumerable: true, get: function () { return printSubgraphSchema_1.printSubgraphSchema; } }); +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 5357: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.printBlockString = exports.printType = exports.printIntrospectionSchema = exports.printSubgraphSchema = void 0; +const graphql_1 = __webpack_require__(8929); +const federation_internals_1 = __webpack_require__(415); +function printSubgraphSchema(schema) { + const ast = (0, federation_internals_1.graphQLJSSchemaToAST)(schema); + const subgraph = (0, federation_internals_1.buildSubgraph)(federation_internals_1.FEDERATION_UNNAMED_SUBGRAPH_NAME, '', ast, false); + return subgraph.toString(); +} +exports.printSubgraphSchema = printSubgraphSchema; +function printIntrospectionSchema(schema) { + const ast = (0, federation_internals_1.graphQLJSSchemaToAST)(schema); + const subgraph = (0, federation_internals_1.buildSubgraph)(federation_internals_1.FEDERATION_UNNAMED_SUBGRAPH_NAME, '', ast, false); + return (0, federation_internals_1.printSchema)(subgraph.schema); +} +exports.printIntrospectionSchema = printIntrospectionSchema; +function printType(type) { + const { definition, extensions } = (0, federation_internals_1.graphQLJSNamedTypeToAST)(type); + const defAst = definition ? [definition] : []; + return defAst.concat(extensions).map((n) => (0, graphql_1.print)(n)).join('\n\n'); +} +exports.printType = printType; +function printBlockString(value, preferMultipleLines = false) { + const isSingleLine = !value.includes('\n'); + const hasLeadingSpace = value[0] === ' ' || value[0] === '\t'; + const hasTrailingQuote = value[value.length - 1] === '"'; + const hasTrailingSlash = value[value.length - 1] === '\\'; + const printAsMultipleLines = !isSingleLine || + hasTrailingQuote || + hasTrailingSlash || + preferMultipleLines; + let result = ''; + if (printAsMultipleLines && !(isSingleLine && hasLeadingSpace)) { + result += '\n'; + } + result += value; + if (printAsMultipleLines) { + result += '\n'; + } + return '"""' + result.replace(/"""/g, '\\"""') + '"""'; +} +exports.printBlockString = printBlockString; +//# sourceMappingURL=printSubgraphSchema.js.map + +/***/ }), + +/***/ 6139: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.buildSchemaFromSDL = exports.addResolversToSchema = exports.modulesFromSDL = exports.isDocumentNode = exports.isNode = void 0; +const graphql_1 = __webpack_require__(8929); +const validation_1 = __webpack_require__(1122); +const validate_1 = __webpack_require__(9504); +const specifiedRules_1 = __webpack_require__(4710); +const error_1 = __webpack_require__(863); +function isNotNullOrUndefined(value) { + return value !== null && typeof value !== 'undefined'; +} +function isNode(maybeNode) { + return maybeNode && typeof maybeNode.kind === "string"; +} +exports.isNode = isNode; +function isDocumentNode(node) { + return isNode(node) && node.kind === graphql_1.Kind.DOCUMENT; +} +exports.isDocumentNode = isDocumentNode; +function mapValues(object, callback) { + const result = Object.create(null); + for (const [key, value] of Object.entries(object)) { + result[key] = callback(value); + } + return result; +} +const skippedSDLRules = [ + validation_1.KnownTypeNamesRule, + validation_1.UniqueDirectivesPerLocationRule, + validation_1.PossibleTypeExtensionsRule, +]; +const sdlRules = specifiedRules_1.specifiedSDLRules.filter(rule => !skippedSDLRules.includes(rule)); +const extKindToDefKind = { + [graphql_1.Kind.SCALAR_TYPE_EXTENSION]: graphql_1.Kind.SCALAR_TYPE_DEFINITION, + [graphql_1.Kind.OBJECT_TYPE_EXTENSION]: graphql_1.Kind.OBJECT_TYPE_DEFINITION, + [graphql_1.Kind.INTERFACE_TYPE_EXTENSION]: graphql_1.Kind.INTERFACE_TYPE_DEFINITION, + [graphql_1.Kind.UNION_TYPE_EXTENSION]: graphql_1.Kind.UNION_TYPE_DEFINITION, + [graphql_1.Kind.ENUM_TYPE_EXTENSION]: graphql_1.Kind.ENUM_TYPE_DEFINITION, + [graphql_1.Kind.INPUT_OBJECT_TYPE_EXTENSION]: graphql_1.Kind.INPUT_OBJECT_TYPE_DEFINITION +}; +function modulesFromSDL(modulesOrSDL) { + if (Array.isArray(modulesOrSDL)) { + return modulesOrSDL.map(moduleOrSDL => { + if (isNode(moduleOrSDL) && isDocumentNode(moduleOrSDL)) { + return { typeDefs: moduleOrSDL }; + } + else { + return moduleOrSDL; + } + }); + } + else { + return [{ typeDefs: modulesOrSDL }]; + } +} +exports.modulesFromSDL = modulesFromSDL; +function addResolversToSchema(schema, resolvers) { + var _a, _b; + for (const [typeName, fieldConfigs] of Object.entries(resolvers)) { + const type = schema.getType(typeName); + if ((0, graphql_1.isAbstractType)(type)) { + const existingExtensions = type.extensions; + for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) { + if (fieldName === '__resolveReference') { + type.extensions = { + ...existingExtensions, + apollo: { + ...existingExtensions.apollo, + subgraph: { + ...(_a = existingExtensions.apollo) === null || _a === void 0 ? void 0 : _a.subgraph, + resolveReference: fieldConfig, + }, + }, + }; + } + else if (fieldName === '__resolveType') { + type.resolveType = fieldConfig; + } + } + } + if ((0, graphql_1.isScalarType)(type)) { + for (const fn in fieldConfigs) { + type[fn] = fieldConfigs[fn]; + } + } + if ((0, graphql_1.isEnumType)(type)) { + const values = type.getValues(); + const newValues = {}; + values.forEach(value => { + let newValue = fieldConfigs[value.name]; + if (newValue === undefined) { + newValue = value.name; + } + newValues[value.name] = { + value: newValue, + deprecationReason: value.deprecationReason, + description: value.description, + astNode: value.astNode, + extensions: undefined + }; + }); + Object.assign(type, new graphql_1.GraphQLEnumType({ + ...type.toConfig(), + values: newValues + })); + } + if (!(0, graphql_1.isObjectType)(type)) + continue; + const fieldMap = type.getFields(); + const existingExtensions = type.extensions; + for (const [fieldName, fieldConfig] of Object.entries(fieldConfigs)) { + if (fieldName === '__resolveReference') { + type.extensions = { + ...existingExtensions, + apollo: { + ...existingExtensions.apollo, + subgraph: { + ...(_b = existingExtensions.apollo) === null || _b === void 0 ? void 0 : _b.subgraph, + resolveReference: fieldConfig, + }, + }, + }; + continue; + } + else if (fieldName === '__isTypeOf') { + type.isTypeOf = fieldConfig; + continue; + } + const field = fieldMap[fieldName]; + if (!field) + continue; + if (typeof fieldConfig === "function") { + field.resolve = fieldConfig; + } + else { + field.resolve = fieldConfig.resolve; + } + } + } +} +exports.addResolversToSchema = addResolversToSchema; +function buildSchemaFromSDL(modulesOrSDL, schemaToExtend) { + const modules = modulesFromSDL(modulesOrSDL); + const documentAST = (0, graphql_1.concatAST)(modules.map(module => module.typeDefs)); + const errors = (0, validate_1.validateSDL)(documentAST, schemaToExtend, sdlRules); + if (errors.length > 0) { + throw new error_1.GraphQLSchemaValidationError(errors); + } + const definitionsMap = Object.create(null); + const extensionsMap = Object.create(null); + const directiveDefinitions = []; + const schemaDefinitions = []; + const schemaExtensions = []; + const schemaDirectives = []; + let description; + for (const definition of documentAST.definitions) { + if ((0, graphql_1.isTypeDefinitionNode)(definition)) { + const typeName = definition.name.value; + if (definitionsMap[typeName]) { + definitionsMap[typeName].push(definition); + } + else { + definitionsMap[typeName] = [definition]; + } + } + else if ((0, graphql_1.isTypeExtensionNode)(definition)) { + const typeName = definition.name.value; + if (extensionsMap[typeName]) { + extensionsMap[typeName].push(definition); + } + else { + extensionsMap[typeName] = [definition]; + } + } + else if (definition.kind === graphql_1.Kind.DIRECTIVE_DEFINITION) { + directiveDefinitions.push(definition); + } + else if (definition.kind === graphql_1.Kind.SCHEMA_DEFINITION) { + schemaDefinitions.push(definition); + schemaDirectives.push(...(definition.directives ? definition.directives : [])); + description = definition.description; + } + else if (definition.kind === graphql_1.Kind.SCHEMA_EXTENSION) { + schemaExtensions.push(definition); + schemaDirectives.push(...(definition.directives ? definition.directives : [])); + } + } + let schema = schemaToExtend + ? schemaToExtend + : new graphql_1.GraphQLSchema({ + query: undefined + }); + const missingTypeDefinitions = []; + for (const [extendedTypeName, extensions] of Object.entries(extensionsMap)) { + if (!definitionsMap[extendedTypeName]) { + const extension = extensions[0]; + const kind = extension.kind; + const definition = { + kind: extKindToDefKind[kind], + name: extension.name + }; + missingTypeDefinitions.push(definition); + } + } + schema = (0, graphql_1.extendSchema)(schema, { + kind: graphql_1.Kind.DOCUMENT, + definitions: [ + ...Object.values(definitionsMap).flat(), + ...missingTypeDefinitions, + ...directiveDefinitions + ] + }, { + assumeValidSDL: true + }); + schema = (0, graphql_1.extendSchema)(schema, { + kind: graphql_1.Kind.DOCUMENT, + definitions: Object.values(extensionsMap).flat(), + }, { + assumeValidSDL: true + }); + let operationTypeMap; + const operationTypes = [...schemaDefinitions, ...schemaExtensions] + .map(node => node.operationTypes) + .filter(isNotNullOrUndefined) + .flat(); + if (operationTypes.length > 0) { + operationTypeMap = {}; + for (const { operation, type } of operationTypes) { + operationTypeMap[operation] = type.name.value; + } + } + else { + operationTypeMap = { + query: "Query", + mutation: "Mutation", + subscription: "Subscription" + }; + } + schema = new graphql_1.GraphQLSchema({ + ...schema.toConfig(), + ...mapValues(operationTypeMap, typeName => typeName + ? schema.getType(typeName) + : undefined), + description: description === null || description === void 0 ? void 0 : description.value, + astNode: { + kind: graphql_1.Kind.SCHEMA_DEFINITION, + description, + directives: schemaDirectives, + operationTypes: [] + } + }); + for (const module of modules) { + if (!module.resolvers) + continue; + addResolversToSchema(schema, module.resolvers); + } + return schema; +} +exports.buildSchemaFromSDL = buildSchemaFromSDL; +//# sourceMappingURL=buildSchemaFromSDL.js.map + +/***/ }), + +/***/ 863: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.GraphQLSchemaValidationError = void 0; +class GraphQLSchemaValidationError extends Error { + constructor(errors) { + super(); + this.errors = errors; + this.name = this.constructor.name; + Error.captureStackTrace(this, this.constructor); + this.message = errors.map(error => error.message).join("\n\n"); + } +} +exports.GraphQLSchemaValidationError = GraphQLSchemaValidationError; +//# sourceMappingURL=error.js.map + +/***/ }), + +/***/ 1846: +/***/ (function(__unused_webpack_module, exports, __webpack_require__) { + +"use strict"; + +var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + var desc = Object.getOwnPropertyDescriptor(m, k); + if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { + desc = { enumerable: true, get: function() { return m[k]; } }; + } + Object.defineProperty(o, k2, desc); +}) : (function(o, m, k, k2) { + if (k2 === undefined) k2 = k; + o[k2] = m[k]; +})); +var __exportStar = (this && this.__exportStar) || function(m, exports) { + for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); +}; +Object.defineProperty(exports, "__esModule", ({ value: true })); +__exportStar(__webpack_require__(2601), exports); +__exportStar(__webpack_require__(6139), exports); +__exportStar(__webpack_require__(863), exports); +__exportStar(__webpack_require__(1511), exports); +//# sourceMappingURL=index.js.map + +/***/ }), + +/***/ 2601: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +//# sourceMappingURL=resolverMap.js.map + +/***/ }), + +/***/ 1511: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.transformSchema = void 0; +const graphql_1 = __webpack_require__(8929); +function mapValues(object, callback) { + const result = Object.create(null); + for (const [key, value] of Object.entries(object)) { + result[key] = callback(value); + } + return result; +} +function transformSchema(schema, transformType) { + const typeMap = Object.create(null); + for (const oldType of Object.values(schema.getTypeMap())) { + if ((0, graphql_1.isIntrospectionType)(oldType)) + continue; + const result = transformType(oldType); + if (result === null) + continue; + const newType = result || oldType; + typeMap[newType.name] = recreateNamedType(newType); + } + const schemaConfig = schema.toConfig(); + return new graphql_1.GraphQLSchema({ + ...schemaConfig, + types: Object.values(typeMap), + query: replaceMaybeType(schemaConfig.query), + mutation: replaceMaybeType(schemaConfig.mutation), + subscription: replaceMaybeType(schemaConfig.subscription), + directives: replaceDirectives(schemaConfig.directives) + }); + function recreateNamedType(type) { + if ((0, graphql_1.isObjectType)(type)) { + const config = type.toConfig(); + return new graphql_1.GraphQLObjectType({ + ...config, + interfaces: () => config.interfaces.map(replaceNamedType), + fields: () => replaceFields(config.fields) + }); + } + else if ((0, graphql_1.isInterfaceType)(type)) { + const config = type.toConfig(); + return new graphql_1.GraphQLInterfaceType({ + ...config, + interfaces: () => config.interfaces.map(replaceNamedType), + fields: () => replaceFields(config.fields) + }); + } + else if ((0, graphql_1.isUnionType)(type)) { + const config = type.toConfig(); + return new graphql_1.GraphQLUnionType({ + ...config, + types: () => config.types.map(replaceNamedType) + }); + } + else if ((0, graphql_1.isInputObjectType)(type)) { + const config = type.toConfig(); + return new graphql_1.GraphQLInputObjectType({ + ...config, + fields: () => replaceInputFields(config.fields) + }); + } + return type; + } + function replaceType(type) { + if ((0, graphql_1.isListType)(type)) { + return new graphql_1.GraphQLList(replaceType(type.ofType)); + } + else if ((0, graphql_1.isNonNullType)(type)) { + return new graphql_1.GraphQLNonNull(replaceType(type.ofType)); + } + return replaceNamedType(type); + } + function replaceNamedType(type) { + const newType = typeMap[type.name]; + return newType ? newType : type; + } + function replaceMaybeType(type) { + return type ? replaceNamedType(type) : undefined; + } + function replaceFields(fieldsMap) { + return mapValues(fieldsMap, field => ({ + ...field, + type: replaceType(field.type), + args: field.args ? replaceArgs(field.args) : undefined + })); + } + function replaceInputFields(fieldsMap) { + return mapValues(fieldsMap, field => ({ + ...field, + type: replaceType(field.type) + })); + } + function replaceArgs(args) { + return mapValues(args, (arg) => ({ + ...arg, + type: replaceType(arg.type), + })); + } + function replaceDirectives(directives) { + return directives.map((directive) => { + const config = directive.toConfig(); + return new graphql_1.GraphQLDirective({ + ...config, + args: replaceArgs(config.args), + }); + }); + } +} +exports.transformSchema = transformSchema; +//# sourceMappingURL=transformSchema.js.map + +/***/ }), + +/***/ 3647: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + +Object.defineProperty(exports, "__esModule", ({ value: true })); +exports.isFederationType = exports.federationTypes = exports.serviceField = exports.entitiesField = exports.entitiesResolver = exports.LinkImportType = exports.AnyType = exports.ServiceType = exports.EntityType = void 0; +const graphql_1 = __webpack_require__(8929); +const cache_control_types_1 = __webpack_require__(9825); +exports.EntityType = new graphql_1.GraphQLUnionType({ + name: '_Entity', + types: [], +}); +exports.ServiceType = new graphql_1.GraphQLObjectType({ + name: '_Service', + fields: { + sdl: { + type: graphql_1.GraphQLString, + description: 'The sdl representing the federated service capabilities. Includes federation directives, removes federation types, and includes rest of full schema after schema directives have been applied', + }, + }, +}); +exports.AnyType = new graphql_1.GraphQLScalarType({ + name: '_Any', + serialize(value) { + return value; + }, +}); +exports.LinkImportType = new graphql_1.GraphQLScalarType({ + name: 'link__Import', + specifiedByURL: null +}); +function isPromise(value) { + return typeof (value === null || value === void 0 ? void 0 : value.then) === 'function'; +} +function addTypeNameToPossibleReturn(maybeObject, typename) { + if (maybeObject !== null && typeof maybeObject === 'object') { + Object.defineProperty(maybeObject, '__typename', { + value: typename, + }); + } + return maybeObject; +} +function entitiesResolver({ representations, context, info }) { + return representations.map((reference) => { + var _a, _b, _c; + const { __typename } = reference; + const type = info.schema.getType(__typename); + if (!type || !(0, graphql_1.isObjectType)(type)) { + throw new Error(`The _entities resolver tried to load an entity for type "${__typename}", but no object type of that name was found in the schema`); + } + const cacheControl = (0, cache_control_types_1.maybeCacheControlFromInfo)(info); + if (cacheControl) { + const cacheHint = cacheControl.cacheHintFromType(type); + if (cacheHint) { + cacheControl.cacheHint.restrict(cacheHint); + } + } + const extensions = type.extensions; + const resolveReference = (_c = (_b = (_a = extensions.apollo) === null || _a === void 0 ? void 0 : _a.subgraph) === null || _b === void 0 ? void 0 : _b.resolveReference) !== null && _c !== void 0 ? _c : (() => reference); + const result = resolveReference(reference, context, info); + if (isPromise(result)) { + return result.then((x) => addTypeNameToPossibleReturn(x, __typename)); + } + return addTypeNameToPossibleReturn(result, __typename); + }); +} +exports.entitiesResolver = entitiesResolver; +exports.entitiesField = { + type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(exports.EntityType)), + args: { + representations: { + type: new graphql_1.GraphQLNonNull(new graphql_1.GraphQLList(new graphql_1.GraphQLNonNull(exports.AnyType))), + }, + }, + resolve(_source, { representations }, context, info) { + return entitiesResolver({ representations, context, info }); + }, +}; +exports.serviceField = { + type: new graphql_1.GraphQLNonNull(exports.ServiceType), +}; +exports.federationTypes = [ + exports.ServiceType, + exports.AnyType, + exports.EntityType, + exports.LinkImportType, +]; +function isFederationType(type) { + return ((0, graphql_1.isNamedType)(type) && exports.federationTypes.some(({ name }) => name === type.name)); +} +exports.isFederationType = isFederationType; +//# sourceMappingURL=types.js.map + +/***/ }), + +/***/ 6434: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +/* module decorator */ module = __webpack_require__.nmd(module); + + +const wrapAnsi16 = (fn, offset) => (...args) => { + const code = fn(...args); + return `\u001B[${code + offset}m`; +}; + +const wrapAnsi256 = (fn, offset) => (...args) => { + const code = fn(...args); + return `\u001B[${38 + offset};5;${code}m`; +}; + +const wrapAnsi16m = (fn, offset) => (...args) => { + const rgb = fn(...args); + return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`; +}; + +const ansi2ansi = n => n; +const rgb2rgb = (r, g, b) => [r, g, b]; + +const setLazyProperty = (object, property, get) => { + Object.defineProperty(object, property, { + get: () => { + const value = get(); + + Object.defineProperty(object, property, { + value, + enumerable: true, + configurable: true + }); + + return value; + }, + enumerable: true, + configurable: true + }); +}; + +/** @type {typeof import('color-convert')} */ +let colorConvert; +const makeDynamicStyles = (wrap, targetSpace, identity, isBackground) => { + if (colorConvert === undefined) { + colorConvert = __webpack_require__(2085); + } + + const offset = isBackground ? 10 : 0; + const styles = {}; + + for (const [sourceSpace, suite] of Object.entries(colorConvert)) { + const name = sourceSpace === 'ansi16' ? 'ansi' : sourceSpace; + if (sourceSpace === targetSpace) { + styles[name] = wrap(identity, offset); + } else if (typeof suite === 'object') { + styles[name] = wrap(suite[targetSpace], offset); + } + } + + return styles; +}; + +function assembleStyles() { + const codes = new Map(); + const styles = { + modifier: { + reset: [0, 0], + // 21 isn't widely supported and 22 does the same thing + bold: [1, 22], + dim: [2, 22], + italic: [3, 23], + underline: [4, 24], + inverse: [7, 27], + hidden: [8, 28], + strikethrough: [9, 29] + }, + color: { + black: [30, 39], + red: [31, 39], + green: [32, 39], + yellow: [33, 39], + blue: [34, 39], + magenta: [35, 39], + cyan: [36, 39], + white: [37, 39], + + // Bright color + blackBright: [90, 39], + redBright: [91, 39], + greenBright: [92, 39], + yellowBright: [93, 39], + blueBright: [94, 39], + magentaBright: [95, 39], + cyanBright: [96, 39], + whiteBright: [97, 39] + }, + bgColor: { + bgBlack: [40, 49], + bgRed: [41, 49], + bgGreen: [42, 49], + bgYellow: [43, 49], + bgBlue: [44, 49], + bgMagenta: [45, 49], + bgCyan: [46, 49], + bgWhite: [47, 49], + + // Bright color + bgBlackBright: [100, 49], + bgRedBright: [101, 49], + bgGreenBright: [102, 49], + bgYellowBright: [103, 49], + bgBlueBright: [104, 49], + bgMagentaBright: [105, 49], + bgCyanBright: [106, 49], + bgWhiteBright: [107, 49] + } + }; + + // Alias bright black as gray (and grey) + styles.color.gray = styles.color.blackBright; + styles.bgColor.bgGray = styles.bgColor.bgBlackBright; + styles.color.grey = styles.color.blackBright; + styles.bgColor.bgGrey = styles.bgColor.bgBlackBright; + + for (const [groupName, group] of Object.entries(styles)) { + for (const [styleName, style] of Object.entries(group)) { + styles[styleName] = { + open: `\u001B[${style[0]}m`, + close: `\u001B[${style[1]}m` + }; + + group[styleName] = styles[styleName]; + + codes.set(style[0], style[1]); + } + + Object.defineProperty(styles, groupName, { + value: group, + enumerable: false + }); + } + + Object.defineProperty(styles, 'codes', { + value: codes, + enumerable: false + }); + + styles.color.close = '\u001B[39m'; + styles.bgColor.close = '\u001B[49m'; + + setLazyProperty(styles.color, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false)); + setLazyProperty(styles.color, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false)); + setLazyProperty(styles.color, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false)); + setLazyProperty(styles.bgColor, 'ansi', () => makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true)); + setLazyProperty(styles.bgColor, 'ansi256', () => makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true)); + setLazyProperty(styles.bgColor, 'ansi16m', () => makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true)); + + return styles; +} + +// Make the export immutable +Object.defineProperty(module, 'exports', { + enumerable: true, + get: assembleStyles +}); + + +/***/ }), + +/***/ 9282: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +// Currently in sync with Node.js lib/assert.js +// https://github.com/nodejs/node/commit/2a51ae424a513ec9a6aa3466baa0cc1d55dd4f3b +// Originally from narwhal.js (http://narwhaljs.org) +// Copyright (c) 2009 Thomas Robinson <280north.com> +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the 'Software'), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN +// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +var _require = __webpack_require__(2136), + _require$codes = _require.codes, + ERR_AMBIGUOUS_ARGUMENT = _require$codes.ERR_AMBIGUOUS_ARGUMENT, + ERR_INVALID_ARG_TYPE = _require$codes.ERR_INVALID_ARG_TYPE, + ERR_INVALID_ARG_VALUE = _require$codes.ERR_INVALID_ARG_VALUE, + ERR_INVALID_RETURN_VALUE = _require$codes.ERR_INVALID_RETURN_VALUE, + ERR_MISSING_ARGS = _require$codes.ERR_MISSING_ARGS; + +var AssertionError = __webpack_require__(9363); + +var _require2 = __webpack_require__(9539), + inspect = _require2.inspect; + +var _require$types = (__webpack_require__(9539).types), + isPromise = _require$types.isPromise, + isRegExp = _require$types.isRegExp; + +var objectAssign = Object.assign ? Object.assign : (__webpack_require__(8091).assign); +var objectIs = Object.is ? Object.is : __webpack_require__(609); +var errorCache = new Map(); +var isDeepEqual; +var isDeepStrictEqual; +var parseExpressionAt; +var findNodeAround; +var decoder; + +function lazyLoadComparison() { + var comparison = __webpack_require__(9158); + + isDeepEqual = comparison.isDeepEqual; + isDeepStrictEqual = comparison.isDeepStrictEqual; +} // Escape control characters but not \n and \t to keep the line breaks and +// indentation intact. +// eslint-disable-next-line no-control-regex + + +var escapeSequencesRegExp = /[\x00-\x08\x0b\x0c\x0e-\x1f]/g; +var meta = (/* unused pure expression or super */ null && (["\\u0000", "\\u0001", "\\u0002", "\\u0003", "\\u0004", "\\u0005", "\\u0006", "\\u0007", '\\b', '', '', "\\u000b", '\\f', '', "\\u000e", "\\u000f", "\\u0010", "\\u0011", "\\u0012", "\\u0013", "\\u0014", "\\u0015", "\\u0016", "\\u0017", "\\u0018", "\\u0019", "\\u001a", "\\u001b", "\\u001c", "\\u001d", "\\u001e", "\\u001f"])); + +var escapeFn = function escapeFn(str) { + return meta[str.charCodeAt(0)]; +}; + +var warned = false; // The assert module provides functions that throw +// AssertionError's when particular conditions are not met. The +// assert module must conform to the following interface. + +var assert = module.exports = ok; +var NO_EXCEPTION_SENTINEL = {}; // All of the following functions must throw an AssertionError +// when a corresponding condition is not met, with a message that +// may be undefined if not provided. All assertion methods provide +// both the actual and expected values to the assertion error for +// display purposes. + +function innerFail(obj) { + if (obj.message instanceof Error) throw obj.message; + throw new AssertionError(obj); +} + +function fail(actual, expected, message, operator, stackStartFn) { + var argsLen = arguments.length; + var internalMessage; + + if (argsLen === 0) { + internalMessage = 'Failed'; + } else if (argsLen === 1) { + message = actual; + actual = undefined; + } else { + if (warned === false) { + warned = true; + var warn = process.emitWarning ? process.emitWarning : console.warn.bind(console); + warn('assert.fail() with more than one argument is deprecated. ' + 'Please use assert.strictEqual() instead or only pass a message.', 'DeprecationWarning', 'DEP0094'); + } + + if (argsLen === 2) operator = '!='; + } + + if (message instanceof Error) throw message; + var errArgs = { + actual: actual, + expected: expected, + operator: operator === undefined ? 'fail' : operator, + stackStartFn: stackStartFn || fail + }; + + if (message !== undefined) { + errArgs.message = message; + } + + var err = new AssertionError(errArgs); + + if (internalMessage) { + err.message = internalMessage; + err.generatedMessage = true; + } + + throw err; +} + +assert.fail = fail; // The AssertionError is defined in internal/error. + +assert.AssertionError = AssertionError; + +function innerOk(fn, argLen, value, message) { + if (!value) { + var generatedMessage = false; + + if (argLen === 0) { + generatedMessage = true; + message = 'No value argument passed to `assert.ok()`'; + } else if (message instanceof Error) { + throw message; + } + + var err = new AssertionError({ + actual: value, + expected: true, + message: message, + operator: '==', + stackStartFn: fn + }); + err.generatedMessage = generatedMessage; + throw err; + } +} // Pure assertion tests whether a value is truthy, as determined +// by !!value. + + +function ok() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + innerOk.apply(void 0, [ok, args.length].concat(args)); +} + +assert.ok = ok; // The equality assertion tests shallow, coercive equality with ==. + +/* eslint-disable no-restricted-properties */ + +assert.equal = function equal(actual, expected, message) { + if (arguments.length < 2) { + throw new ERR_MISSING_ARGS('actual', 'expected'); + } // eslint-disable-next-line eqeqeq + + + if (actual != expected) { + innerFail({ + actual: actual, + expected: expected, + message: message, + operator: '==', + stackStartFn: equal + }); + } +}; // The non-equality assertion tests for whether two objects are not +// equal with !=. + + +assert.notEqual = function notEqual(actual, expected, message) { + if (arguments.length < 2) { + throw new ERR_MISSING_ARGS('actual', 'expected'); + } // eslint-disable-next-line eqeqeq + + + if (actual == expected) { + innerFail({ + actual: actual, + expected: expected, + message: message, + operator: '!=', + stackStartFn: notEqual + }); + } +}; // The equivalence assertion tests a deep equality relation. + + +assert.deepEqual = function deepEqual(actual, expected, message) { + if (arguments.length < 2) { + throw new ERR_MISSING_ARGS('actual', 'expected'); + } + + if (isDeepEqual === undefined) lazyLoadComparison(); + + if (!isDeepEqual(actual, expected)) { + innerFail({ + actual: actual, + expected: expected, + message: message, + operator: 'deepEqual', + stackStartFn: deepEqual + }); + } +}; // The non-equivalence assertion tests for any deep inequality. + + +assert.notDeepEqual = function notDeepEqual(actual, expected, message) { + if (arguments.length < 2) { + throw new ERR_MISSING_ARGS('actual', 'expected'); + } + + if (isDeepEqual === undefined) lazyLoadComparison(); + + if (isDeepEqual(actual, expected)) { + innerFail({ + actual: actual, + expected: expected, + message: message, + operator: 'notDeepEqual', + stackStartFn: notDeepEqual + }); + } +}; +/* eslint-enable */ + + +assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) { + if (arguments.length < 2) { + throw new ERR_MISSING_ARGS('actual', 'expected'); + } + + if (isDeepEqual === undefined) lazyLoadComparison(); + + if (!isDeepStrictEqual(actual, expected)) { + innerFail({ + actual: actual, + expected: expected, + message: message, + operator: 'deepStrictEqual', + stackStartFn: deepStrictEqual + }); + } +}; + +assert.notDeepStrictEqual = notDeepStrictEqual; + +function notDeepStrictEqual(actual, expected, message) { + if (arguments.length < 2) { + throw new ERR_MISSING_ARGS('actual', 'expected'); + } + + if (isDeepEqual === undefined) lazyLoadComparison(); + + if (isDeepStrictEqual(actual, expected)) { + innerFail({ + actual: actual, + expected: expected, + message: message, + operator: 'notDeepStrictEqual', + stackStartFn: notDeepStrictEqual + }); + } +} + +assert.strictEqual = function strictEqual(actual, expected, message) { + if (arguments.length < 2) { + throw new ERR_MISSING_ARGS('actual', 'expected'); + } + + if (!objectIs(actual, expected)) { + innerFail({ + actual: actual, + expected: expected, + message: message, + operator: 'strictEqual', + stackStartFn: strictEqual + }); + } +}; + +assert.notStrictEqual = function notStrictEqual(actual, expected, message) { + if (arguments.length < 2) { + throw new ERR_MISSING_ARGS('actual', 'expected'); + } + + if (objectIs(actual, expected)) { + innerFail({ + actual: actual, + expected: expected, + message: message, + operator: 'notStrictEqual', + stackStartFn: notStrictEqual + }); + } +}; + +var Comparison = function Comparison(obj, keys, actual) { + var _this = this; + + _classCallCheck(this, Comparison); + + keys.forEach(function (key) { + if (key in obj) { + if (actual !== undefined && typeof actual[key] === 'string' && isRegExp(obj[key]) && obj[key].test(actual[key])) { + _this[key] = actual[key]; + } else { + _this[key] = obj[key]; + } + } + }); +}; + +function compareExceptionKey(actual, expected, key, message, keys, fn) { + if (!(key in actual) || !isDeepStrictEqual(actual[key], expected[key])) { + if (!message) { + // Create placeholder objects to create a nice output. + var a = new Comparison(actual, keys); + var b = new Comparison(expected, keys, actual); + var err = new AssertionError({ + actual: a, + expected: b, + operator: 'deepStrictEqual', + stackStartFn: fn + }); + err.actual = actual; + err.expected = expected; + err.operator = fn.name; + throw err; + } + + innerFail({ + actual: actual, + expected: expected, + message: message, + operator: fn.name, + stackStartFn: fn + }); + } +} + +function expectedException(actual, expected, msg, fn) { + if (typeof expected !== 'function') { + if (isRegExp(expected)) return expected.test(actual); // assert.doesNotThrow does not accept objects. + + if (arguments.length === 2) { + throw new ERR_INVALID_ARG_TYPE('expected', ['Function', 'RegExp'], expected); + } // Handle primitives properly. + + + if (_typeof(actual) !== 'object' || actual === null) { + var err = new AssertionError({ + actual: actual, + expected: expected, + message: msg, + operator: 'deepStrictEqual', + stackStartFn: fn + }); + err.operator = fn.name; + throw err; + } + + var keys = Object.keys(expected); // Special handle errors to make sure the name and the message are compared + // as well. + + if (expected instanceof Error) { + keys.push('name', 'message'); + } else if (keys.length === 0) { + throw new ERR_INVALID_ARG_VALUE('error', expected, 'may not be an empty object'); + } + + if (isDeepEqual === undefined) lazyLoadComparison(); + keys.forEach(function (key) { + if (typeof actual[key] === 'string' && isRegExp(expected[key]) && expected[key].test(actual[key])) { + return; + } + + compareExceptionKey(actual, expected, key, msg, keys, fn); + }); + return true; + } // Guard instanceof against arrow functions as they don't have a prototype. + + + if (expected.prototype !== undefined && actual instanceof expected) { + return true; + } + + if (Error.isPrototypeOf(expected)) { + return false; + } + + return expected.call({}, actual) === true; +} + +function getActual(fn) { + if (typeof fn !== 'function') { + throw new ERR_INVALID_ARG_TYPE('fn', 'Function', fn); + } + + try { + fn(); + } catch (e) { + return e; + } + + return NO_EXCEPTION_SENTINEL; +} + +function checkIsPromise(obj) { + // Accept native ES6 promises and promises that are implemented in a similar + // way. Do not accept thenables that use a function as `obj` and that have no + // `catch` handler. + // TODO: thenables are checked up until they have the correct methods, + // but according to documentation, the `then` method should receive + // the `fulfill` and `reject` arguments as well or it may be never resolved. + return isPromise(obj) || obj !== null && _typeof(obj) === 'object' && typeof obj.then === 'function' && typeof obj.catch === 'function'; +} + +function waitForActual(promiseFn) { + return Promise.resolve().then(function () { + var resultPromise; + + if (typeof promiseFn === 'function') { + // Return a rejected promise if `promiseFn` throws synchronously. + resultPromise = promiseFn(); // Fail in case no promise is returned. + + if (!checkIsPromise(resultPromise)) { + throw new ERR_INVALID_RETURN_VALUE('instance of Promise', 'promiseFn', resultPromise); + } + } else if (checkIsPromise(promiseFn)) { + resultPromise = promiseFn; + } else { + throw new ERR_INVALID_ARG_TYPE('promiseFn', ['Function', 'Promise'], promiseFn); + } + + return Promise.resolve().then(function () { + return resultPromise; + }).then(function () { + return NO_EXCEPTION_SENTINEL; + }).catch(function (e) { + return e; + }); + }); +} + +function expectsError(stackStartFn, actual, error, message) { + if (typeof error === 'string') { + if (arguments.length === 4) { + throw new ERR_INVALID_ARG_TYPE('error', ['Object', 'Error', 'Function', 'RegExp'], error); + } + + if (_typeof(actual) === 'object' && actual !== null) { + if (actual.message === error) { + throw new ERR_AMBIGUOUS_ARGUMENT('error/message', "The error message \"".concat(actual.message, "\" is identical to the message.")); + } + } else if (actual === error) { + throw new ERR_AMBIGUOUS_ARGUMENT('error/message', "The error \"".concat(actual, "\" is identical to the message.")); + } + + message = error; + error = undefined; + } else if (error != null && _typeof(error) !== 'object' && typeof error !== 'function') { + throw new ERR_INVALID_ARG_TYPE('error', ['Object', 'Error', 'Function', 'RegExp'], error); + } + + if (actual === NO_EXCEPTION_SENTINEL) { + var details = ''; + + if (error && error.name) { + details += " (".concat(error.name, ")"); + } + + details += message ? ": ".concat(message) : '.'; + var fnType = stackStartFn.name === 'rejects' ? 'rejection' : 'exception'; + innerFail({ + actual: undefined, + expected: error, + operator: stackStartFn.name, + message: "Missing expected ".concat(fnType).concat(details), + stackStartFn: stackStartFn + }); + } + + if (error && !expectedException(actual, error, message, stackStartFn)) { + throw actual; + } +} + +function expectsNoError(stackStartFn, actual, error, message) { + if (actual === NO_EXCEPTION_SENTINEL) return; + + if (typeof error === 'string') { + message = error; + error = undefined; + } + + if (!error || expectedException(actual, error)) { + var details = message ? ": ".concat(message) : '.'; + var fnType = stackStartFn.name === 'doesNotReject' ? 'rejection' : 'exception'; + innerFail({ + actual: actual, + expected: error, + operator: stackStartFn.name, + message: "Got unwanted ".concat(fnType).concat(details, "\n") + "Actual message: \"".concat(actual && actual.message, "\""), + stackStartFn: stackStartFn + }); + } + + throw actual; +} + +assert.throws = function throws(promiseFn) { + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + expectsError.apply(void 0, [throws, getActual(promiseFn)].concat(args)); +}; + +assert.rejects = function rejects(promiseFn) { + for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) { + args[_key3 - 1] = arguments[_key3]; + } + + return waitForActual(promiseFn).then(function (result) { + return expectsError.apply(void 0, [rejects, result].concat(args)); + }); +}; + +assert.doesNotThrow = function doesNotThrow(fn) { + for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) { + args[_key4 - 1] = arguments[_key4]; + } + + expectsNoError.apply(void 0, [doesNotThrow, getActual(fn)].concat(args)); +}; + +assert.doesNotReject = function doesNotReject(fn) { + for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) { + args[_key5 - 1] = arguments[_key5]; + } + + return waitForActual(fn).then(function (result) { + return expectsNoError.apply(void 0, [doesNotReject, result].concat(args)); + }); +}; + +assert.ifError = function ifError(err) { + if (err !== null && err !== undefined) { + var message = 'ifError got unwanted exception: '; + + if (_typeof(err) === 'object' && typeof err.message === 'string') { + if (err.message.length === 0 && err.constructor) { + message += err.constructor.name; + } else { + message += err.message; + } + } else { + message += inspect(err); + } + + var newErr = new AssertionError({ + actual: err, + expected: null, + operator: 'ifError', + message: message, + stackStartFn: ifError + }); // Make sure we actually have a stack trace! + + var origStack = err.stack; + + if (typeof origStack === 'string') { + // This will remove any duplicated frames from the error frames taken + // from within `ifError` and add the original error frames to the newly + // created ones. + var tmp2 = origStack.split('\n'); + tmp2.shift(); // Filter all frames existing in err.stack. + + var tmp1 = newErr.stack.split('\n'); + + for (var i = 0; i < tmp2.length; i++) { + // Find the first occurrence of the frame. + var pos = tmp1.indexOf(tmp2[i]); + + if (pos !== -1) { + // Only keep new frames. + tmp1 = tmp1.slice(0, pos); + break; + } + } + + newErr.stack = "".concat(tmp1.join('\n'), "\n").concat(tmp2.join('\n')); + } + + throw newErr; + } +}; // Expose a strict only variant of assert + + +function strict() { + for (var _len6 = arguments.length, args = new Array(_len6), _key6 = 0; _key6 < _len6; _key6++) { + args[_key6] = arguments[_key6]; + } + + innerOk.apply(void 0, [strict, args.length].concat(args)); +} + +assert.strict = objectAssign(strict, assert, { + equal: assert.strictEqual, + deepEqual: assert.deepStrictEqual, + notEqual: assert.notStrictEqual, + notDeepEqual: assert.notDeepStrictEqual +}); +assert.strict.strict = assert.strict; + +/***/ }), + +/***/ 9363: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +// Currently in sync with Node.js lib/internal/assert/assertion_error.js +// https://github.com/nodejs/node/commit/0817840f775032169ddd70c85ac059f18ffcc81c + + +function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; } + +function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + +function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); } + +function isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } } + +function _construct(Parent, args, Class) { if (isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); } + +function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var _require = __webpack_require__(9539), + inspect = _require.inspect; + +var _require2 = __webpack_require__(2136), + ERR_INVALID_ARG_TYPE = _require2.codes.ERR_INVALID_ARG_TYPE; // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith + + +function endsWith(str, search, this_len) { + if (this_len === undefined || this_len > str.length) { + this_len = str.length; + } + + return str.substring(this_len - search.length, this_len) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat + + +function repeat(str, count) { + count = Math.floor(count); + if (str.length == 0 || count == 0) return ''; + var maxCount = str.length * count; + count = Math.floor(Math.log(count) / Math.log(2)); + + while (count) { + str += str; + count--; + } + + str += str.substring(0, maxCount - str.length); + return str; +} + +var blue = ''; +var green = ''; +var red = ''; +var white = ''; +var kReadableOperator = { + deepStrictEqual: 'Expected values to be strictly deep-equal:', + strictEqual: 'Expected values to be strictly equal:', + strictEqualObject: 'Expected "actual" to be reference-equal to "expected":', + deepEqual: 'Expected values to be loosely deep-equal:', + equal: 'Expected values to be loosely equal:', + notDeepStrictEqual: 'Expected "actual" not to be strictly deep-equal to:', + notStrictEqual: 'Expected "actual" to be strictly unequal to:', + notStrictEqualObject: 'Expected "actual" not to be reference-equal to "expected":', + notDeepEqual: 'Expected "actual" not to be loosely deep-equal to:', + notEqual: 'Expected "actual" to be loosely unequal to:', + notIdentical: 'Values identical but not reference-equal:' +}; // Comparing short primitives should just show === / !== instead of using the +// diff. + +var kMaxShortLength = 10; + +function copyError(source) { + var keys = Object.keys(source); + var target = Object.create(Object.getPrototypeOf(source)); + keys.forEach(function (key) { + target[key] = source[key]; + }); + Object.defineProperty(target, 'message', { + value: source.message + }); + return target; +} + +function inspectValue(val) { + // The util.inspect default values could be changed. This makes sure the + // error messages contain the necessary information nevertheless. + return inspect(val, { + compact: false, + customInspect: false, + depth: 1000, + maxArrayLength: Infinity, + // Assert compares only enumerable properties (with a few exceptions). + showHidden: false, + // Having a long line as error is better than wrapping the line for + // comparison for now. + // TODO(BridgeAR): `breakLength` should be limited as soon as soon as we + // have meta information about the inspected properties (i.e., know where + // in what line the property starts and ends). + breakLength: Infinity, + // Assert does not detect proxies currently. + showProxy: false, + sorted: true, + // Inspect getters as we also check them when comparing entries. + getters: true + }); +} + +function createErrDiff(actual, expected, operator) { + var other = ''; + var res = ''; + var lastPos = 0; + var end = ''; + var skipped = false; + var actualInspected = inspectValue(actual); + var actualLines = actualInspected.split('\n'); + var expectedLines = inspectValue(expected).split('\n'); + var i = 0; + var indicator = ''; // In case both values are objects explicitly mark them as not reference equal + // for the `strictEqual` operator. + + if (operator === 'strictEqual' && _typeof(actual) === 'object' && _typeof(expected) === 'object' && actual !== null && expected !== null) { + operator = 'strictEqualObject'; + } // If "actual" and "expected" fit on a single line and they are not strictly + // equal, check further special handling. + + + if (actualLines.length === 1 && expectedLines.length === 1 && actualLines[0] !== expectedLines[0]) { + var inputLength = actualLines[0].length + expectedLines[0].length; // If the character length of "actual" and "expected" together is less than + // kMaxShortLength and if neither is an object and at least one of them is + // not `zero`, use the strict equal comparison to visualize the output. + + if (inputLength <= kMaxShortLength) { + if ((_typeof(actual) !== 'object' || actual === null) && (_typeof(expected) !== 'object' || expected === null) && (actual !== 0 || expected !== 0)) { + // -0 === +0 + return "".concat(kReadableOperator[operator], "\n\n") + "".concat(actualLines[0], " !== ").concat(expectedLines[0], "\n"); + } + } else if (operator !== 'strictEqualObject') { + // If the stderr is a tty and the input length is lower than the current + // columns per line, add a mismatch indicator below the output. If it is + // not a tty, use a default value of 80 characters. + var maxLength = process.stderr && process.stderr.isTTY ? process.stderr.columns : 80; + + if (inputLength < maxLength) { + while (actualLines[0][i] === expectedLines[0][i]) { + i++; + } // Ignore the first characters. + + + if (i > 2) { + // Add position indicator for the first mismatch in case it is a + // single line and the input length is less than the column length. + indicator = "\n ".concat(repeat(' ', i), "^"); + i = 0; + } + } + } + } // Remove all ending lines that match (this optimizes the output for + // readability by reducing the number of total changed lines). + + + var a = actualLines[actualLines.length - 1]; + var b = expectedLines[expectedLines.length - 1]; + + while (a === b) { + if (i++ < 2) { + end = "\n ".concat(a).concat(end); + } else { + other = a; + } + + actualLines.pop(); + expectedLines.pop(); + if (actualLines.length === 0 || expectedLines.length === 0) break; + a = actualLines[actualLines.length - 1]; + b = expectedLines[expectedLines.length - 1]; + } + + var maxLines = Math.max(actualLines.length, expectedLines.length); // Strict equal with identical objects that are not identical by reference. + // E.g., assert.deepStrictEqual({ a: Symbol() }, { a: Symbol() }) + + if (maxLines === 0) { + // We have to get the result again. The lines were all removed before. + var _actualLines = actualInspected.split('\n'); // Only remove lines in case it makes sense to collapse those. + // TODO: Accept env to always show the full error. + + + if (_actualLines.length > 30) { + _actualLines[26] = "".concat(blue, "...").concat(white); + + while (_actualLines.length > 27) { + _actualLines.pop(); + } + } + + return "".concat(kReadableOperator.notIdentical, "\n\n").concat(_actualLines.join('\n'), "\n"); + } + + if (i > 3) { + end = "\n".concat(blue, "...").concat(white).concat(end); + skipped = true; + } + + if (other !== '') { + end = "\n ".concat(other).concat(end); + other = ''; + } + + var printedLines = 0; + var msg = kReadableOperator[operator] + "\n".concat(green, "+ actual").concat(white, " ").concat(red, "- expected").concat(white); + var skippedMsg = " ".concat(blue, "...").concat(white, " Lines skipped"); + + for (i = 0; i < maxLines; i++) { + // Only extra expected lines exist + var cur = i - lastPos; + + if (actualLines.length < i + 1) { + // If the last diverging line is more than one line above and the + // current line is at least line three, add some of the former lines and + // also add dots to indicate skipped entries. + if (cur > 1 && i > 2) { + if (cur > 4) { + res += "\n".concat(blue, "...").concat(white); + skipped = true; + } else if (cur > 3) { + res += "\n ".concat(expectedLines[i - 2]); + printedLines++; + } + + res += "\n ".concat(expectedLines[i - 1]); + printedLines++; + } // Mark the current line as the last diverging one. + + + lastPos = i; // Add the expected line to the cache. + + other += "\n".concat(red, "-").concat(white, " ").concat(expectedLines[i]); + printedLines++; // Only extra actual lines exist + } else if (expectedLines.length < i + 1) { + // If the last diverging line is more than one line above and the + // current line is at least line three, add some of the former lines and + // also add dots to indicate skipped entries. + if (cur > 1 && i > 2) { + if (cur > 4) { + res += "\n".concat(blue, "...").concat(white); + skipped = true; + } else if (cur > 3) { + res += "\n ".concat(actualLines[i - 2]); + printedLines++; + } + + res += "\n ".concat(actualLines[i - 1]); + printedLines++; + } // Mark the current line as the last diverging one. + + + lastPos = i; // Add the actual line to the result. + + res += "\n".concat(green, "+").concat(white, " ").concat(actualLines[i]); + printedLines++; // Lines diverge + } else { + var expectedLine = expectedLines[i]; + var actualLine = actualLines[i]; // If the lines diverge, specifically check for lines that only diverge by + // a trailing comma. In that case it is actually identical and we should + // mark it as such. + + var divergingLines = actualLine !== expectedLine && (!endsWith(actualLine, ',') || actualLine.slice(0, -1) !== expectedLine); // If the expected line has a trailing comma but is otherwise identical, + // add a comma at the end of the actual line. Otherwise the output could + // look weird as in: + // + // [ + // 1 // No comma at the end! + // + 2 + // ] + // + + if (divergingLines && endsWith(expectedLine, ',') && expectedLine.slice(0, -1) === actualLine) { + divergingLines = false; + actualLine += ','; + } + + if (divergingLines) { + // If the last diverging line is more than one line above and the + // current line is at least line three, add some of the former lines and + // also add dots to indicate skipped entries. + if (cur > 1 && i > 2) { + if (cur > 4) { + res += "\n".concat(blue, "...").concat(white); + skipped = true; + } else if (cur > 3) { + res += "\n ".concat(actualLines[i - 2]); + printedLines++; + } + + res += "\n ".concat(actualLines[i - 1]); + printedLines++; + } // Mark the current line as the last diverging one. + + + lastPos = i; // Add the actual line to the result and cache the expected diverging + // line so consecutive diverging lines show up as +++--- and not +-+-+-. + + res += "\n".concat(green, "+").concat(white, " ").concat(actualLine); + other += "\n".concat(red, "-").concat(white, " ").concat(expectedLine); + printedLines += 2; // Lines are identical + } else { + // Add all cached information to the result before adding other things + // and reset the cache. + res += other; + other = ''; // If the last diverging line is exactly one line above or if it is the + // very first line, add the line to the result. + + if (cur === 1 || i === 0) { + res += "\n ".concat(actualLine); + printedLines++; + } + } + } // Inspected object to big (Show ~20 rows max) + + + if (printedLines > 20 && i < maxLines - 2) { + return "".concat(msg).concat(skippedMsg, "\n").concat(res, "\n").concat(blue, "...").concat(white).concat(other, "\n") + "".concat(blue, "...").concat(white); + } + } + + return "".concat(msg).concat(skipped ? skippedMsg : '', "\n").concat(res).concat(other).concat(end).concat(indicator); +} + +var AssertionError = +/*#__PURE__*/ +function (_Error) { + _inherits(AssertionError, _Error); + + function AssertionError(options) { + var _this; + + _classCallCheck(this, AssertionError); + + if (_typeof(options) !== 'object' || options === null) { + throw new ERR_INVALID_ARG_TYPE('options', 'Object', options); + } + + var message = options.message, + operator = options.operator, + stackStartFn = options.stackStartFn; + var actual = options.actual, + expected = options.expected; + var limit = Error.stackTraceLimit; + Error.stackTraceLimit = 0; + + if (message != null) { + _this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, String(message))); + } else { + if (process.stderr && process.stderr.isTTY) { + // Reset on each call to make sure we handle dynamically set environment + // variables correct. + if (process.stderr && process.stderr.getColorDepth && process.stderr.getColorDepth() !== 1) { + blue = "\x1B[34m"; + green = "\x1B[32m"; + white = "\x1B[39m"; + red = "\x1B[31m"; + } else { + blue = ''; + green = ''; + white = ''; + red = ''; + } + } // Prevent the error stack from being visible by duplicating the error + // in a very close way to the original in case both sides are actually + // instances of Error. + + + if (_typeof(actual) === 'object' && actual !== null && _typeof(expected) === 'object' && expected !== null && 'stack' in actual && actual instanceof Error && 'stack' in expected && expected instanceof Error) { + actual = copyError(actual); + expected = copyError(expected); + } + + if (operator === 'deepStrictEqual' || operator === 'strictEqual') { + _this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, createErrDiff(actual, expected, operator))); + } else if (operator === 'notDeepStrictEqual' || operator === 'notStrictEqual') { + // In case the objects are equal but the operator requires unequal, show + // the first object and say A equals B + var base = kReadableOperator[operator]; + var res = inspectValue(actual).split('\n'); // In case "actual" is an object, it should not be reference equal. + + if (operator === 'notStrictEqual' && _typeof(actual) === 'object' && actual !== null) { + base = kReadableOperator.notStrictEqualObject; + } // Only remove lines in case it makes sense to collapse those. + // TODO: Accept env to always show the full error. + + + if (res.length > 30) { + res[26] = "".concat(blue, "...").concat(white); + + while (res.length > 27) { + res.pop(); + } + } // Only print a single input. + + + if (res.length === 1) { + _this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, "".concat(base, " ").concat(res[0]))); + } else { + _this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, "".concat(base, "\n\n").concat(res.join('\n'), "\n"))); + } + } else { + var _res = inspectValue(actual); + + var other = ''; + var knownOperators = kReadableOperator[operator]; + + if (operator === 'notDeepEqual' || operator === 'notEqual') { + _res = "".concat(kReadableOperator[operator], "\n\n").concat(_res); + + if (_res.length > 1024) { + _res = "".concat(_res.slice(0, 1021), "..."); + } + } else { + other = "".concat(inspectValue(expected)); + + if (_res.length > 512) { + _res = "".concat(_res.slice(0, 509), "..."); + } + + if (other.length > 512) { + other = "".concat(other.slice(0, 509), "..."); + } + + if (operator === 'deepEqual' || operator === 'equal') { + _res = "".concat(knownOperators, "\n\n").concat(_res, "\n\nshould equal\n\n"); + } else { + other = " ".concat(operator, " ").concat(other); + } + } + + _this = _possibleConstructorReturn(this, _getPrototypeOf(AssertionError).call(this, "".concat(_res).concat(other))); + } + } + + Error.stackTraceLimit = limit; + _this.generatedMessage = !message; + Object.defineProperty(_assertThisInitialized(_this), 'name', { + value: 'AssertionError [ERR_ASSERTION]', + enumerable: false, + writable: true, + configurable: true + }); + _this.code = 'ERR_ASSERTION'; + _this.actual = actual; + _this.expected = expected; + _this.operator = operator; + + if (Error.captureStackTrace) { + // eslint-disable-next-line no-restricted-syntax + Error.captureStackTrace(_assertThisInitialized(_this), stackStartFn); + } // Create error message including the error code in the name. + + + _this.stack; // Reset the name. + + _this.name = 'AssertionError'; + return _possibleConstructorReturn(_this); + } + + _createClass(AssertionError, [{ + key: "toString", + value: function toString() { + return "".concat(this.name, " [").concat(this.code, "]: ").concat(this.message); + } + }, { + key: inspect.custom, + value: function value(recurseTimes, ctx) { + // This limits the `actual` and `expected` property default inspection to + // the minimum depth. Otherwise those values would be too verbose compared + // to the actual error message which contains a combined view of these two + // input values. + return inspect(this, _objectSpread({}, ctx, { + customInspect: false, + depth: 0 + })); + } + }]); + + return AssertionError; +}(_wrapNativeSuper(Error)); + +module.exports = AssertionError; + +/***/ }), + +/***/ 2136: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +// Currently in sync with Node.js lib/internal/errors.js +// https://github.com/nodejs/node/commit/3b044962c48fe313905877a96b5d0894a5404f6f + +/* eslint node-core/documented-errors: "error" */ + +/* eslint node-core/alphabetize-errors: "error" */ + +/* eslint node-core/prefer-util-format-errors: "error" */ + // The whole point behind this internal module is to allow Node.js to no +// longer be forced to treat every error message change as a semver-major +// change. The NodeError classes here all expose a `code` property whose +// value statically and permanently identifies the error. While the error +// message may change, the code should not. + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + +function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); } + +function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; } + +function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); } + +function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); } + +function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); } + +var codes = {}; // Lazy loaded + +var assert; +var util; + +function createErrorType(code, message, Base) { + if (!Base) { + Base = Error; + } + + function getMessage(arg1, arg2, arg3) { + if (typeof message === 'string') { + return message; + } else { + return message(arg1, arg2, arg3); + } + } + + var NodeError = + /*#__PURE__*/ + function (_Base) { + _inherits(NodeError, _Base); + + function NodeError(arg1, arg2, arg3) { + var _this; + + _classCallCheck(this, NodeError); + + _this = _possibleConstructorReturn(this, _getPrototypeOf(NodeError).call(this, getMessage(arg1, arg2, arg3))); + _this.code = code; + return _this; + } + + return NodeError; + }(Base); + + codes[code] = NodeError; +} // https://github.com/nodejs/node/blob/v10.8.0/lib/internal/errors.js + + +function oneOf(expected, thing) { + if (Array.isArray(expected)) { + var len = expected.length; + expected = expected.map(function (i) { + return String(i); + }); + + if (len > 2) { + return "one of ".concat(thing, " ").concat(expected.slice(0, len - 1).join(', '), ", or ") + expected[len - 1]; + } else if (len === 2) { + return "one of ".concat(thing, " ").concat(expected[0], " or ").concat(expected[1]); + } else { + return "of ".concat(thing, " ").concat(expected[0]); + } + } else { + return "of ".concat(thing, " ").concat(String(expected)); + } +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/startsWith + + +function startsWith(str, search, pos) { + return str.substr(!pos || pos < 0 ? 0 : +pos, search.length) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/endsWith + + +function endsWith(str, search, this_len) { + if (this_len === undefined || this_len > str.length) { + this_len = str.length; + } + + return str.substring(this_len - search.length, this_len) === search; +} // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/includes + + +function includes(str, search, start) { + if (typeof start !== 'number') { + start = 0; + } + + if (start + search.length > str.length) { + return false; + } else { + return str.indexOf(search, start) !== -1; + } +} + +createErrorType('ERR_AMBIGUOUS_ARGUMENT', 'The "%s" argument is ambiguous. %s', TypeError); +createErrorType('ERR_INVALID_ARG_TYPE', function (name, expected, actual) { + if (assert === undefined) assert = __webpack_require__(9282); + assert(typeof name === 'string', "'name' must be a string"); // determiner: 'must be' or 'must not be' + + var determiner; + + if (typeof expected === 'string' && startsWith(expected, 'not ')) { + determiner = 'must not be'; + expected = expected.replace(/^not /, ''); + } else { + determiner = 'must be'; + } + + var msg; + + if (endsWith(name, ' argument')) { + // For cases like 'first argument' + msg = "The ".concat(name, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } else { + var type = includes(name, '.') ? 'property' : 'argument'; + msg = "The \"".concat(name, "\" ").concat(type, " ").concat(determiner, " ").concat(oneOf(expected, 'type')); + } // TODO(BridgeAR): Improve the output by showing `null` and similar. + + + msg += ". Received type ".concat(_typeof(actual)); + return msg; +}, TypeError); +createErrorType('ERR_INVALID_ARG_VALUE', function (name, value) { + var reason = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'is invalid'; + if (util === undefined) util = __webpack_require__(9539); + var inspected = util.inspect(value); + + if (inspected.length > 128) { + inspected = "".concat(inspected.slice(0, 128), "..."); + } + + return "The argument '".concat(name, "' ").concat(reason, ". Received ").concat(inspected); +}, TypeError, RangeError); +createErrorType('ERR_INVALID_RETURN_VALUE', function (input, name, value) { + var type; + + if (value && value.constructor && value.constructor.name) { + type = "instance of ".concat(value.constructor.name); + } else { + type = "type ".concat(_typeof(value)); + } + + return "Expected ".concat(input, " to be returned from the \"").concat(name, "\"") + " function but got ".concat(type, "."); +}, TypeError); +createErrorType('ERR_MISSING_ARGS', function () { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } + + if (assert === undefined) assert = __webpack_require__(9282); + assert(args.length > 0, 'At least one arg needs to be specified'); + var msg = 'The '; + var len = args.length; + args = args.map(function (a) { + return "\"".concat(a, "\""); + }); + + switch (len) { + case 1: + msg += "".concat(args[0], " argument"); + break; + + case 2: + msg += "".concat(args[0], " and ").concat(args[1], " arguments"); + break; + + default: + msg += args.slice(0, len - 1).join(', '); + msg += ", and ".concat(args[len - 1], " arguments"); + break; + } + + return "".concat(msg, " must be specified"); +}, TypeError); +module.exports.codes = codes; + +/***/ }), + +/***/ 9158: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; +// Currently in sync with Node.js lib/internal/util/comparisons.js +// https://github.com/nodejs/node/commit/112cc7c27551254aa2b17098fb774867f05ed0d9 + + +function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); } + +function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } + +function _iterableToArrayLimit(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + +function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } + +function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } + +var regexFlagsSupported = /a/g.flags !== undefined; + +var arrayFromSet = function arrayFromSet(set) { + var array = []; + set.forEach(function (value) { + return array.push(value); + }); + return array; +}; + +var arrayFromMap = function arrayFromMap(map) { + var array = []; + map.forEach(function (value, key) { + return array.push([key, value]); + }); + return array; +}; + +var objectIs = Object.is ? Object.is : __webpack_require__(609); +var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols : function () { + return []; +}; +var numberIsNaN = Number.isNaN ? Number.isNaN : __webpack_require__(360); + +function uncurryThis(f) { + return f.call.bind(f); +} + +var hasOwnProperty = uncurryThis(Object.prototype.hasOwnProperty); +var propertyIsEnumerable = uncurryThis(Object.prototype.propertyIsEnumerable); +var objectToString = uncurryThis(Object.prototype.toString); + +var _require$types = (__webpack_require__(9539).types), + isAnyArrayBuffer = _require$types.isAnyArrayBuffer, + isArrayBufferView = _require$types.isArrayBufferView, + isDate = _require$types.isDate, + isMap = _require$types.isMap, + isRegExp = _require$types.isRegExp, + isSet = _require$types.isSet, + isNativeError = _require$types.isNativeError, + isBoxedPrimitive = _require$types.isBoxedPrimitive, + isNumberObject = _require$types.isNumberObject, + isStringObject = _require$types.isStringObject, + isBooleanObject = _require$types.isBooleanObject, + isBigIntObject = _require$types.isBigIntObject, + isSymbolObject = _require$types.isSymbolObject, + isFloat32Array = _require$types.isFloat32Array, + isFloat64Array = _require$types.isFloat64Array; + +function isNonIndex(key) { + if (key.length === 0 || key.length > 10) return true; + + for (var i = 0; i < key.length; i++) { + var code = key.charCodeAt(i); + if (code < 48 || code > 57) return true; + } // The maximum size for an array is 2 ** 32 -1. + + + return key.length === 10 && key >= Math.pow(2, 32); +} + +function getOwnNonIndexProperties(value) { + return Object.keys(value).filter(isNonIndex).concat(objectGetOwnPropertySymbols(value).filter(Object.prototype.propertyIsEnumerable.bind(value))); +} // Taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js +// original notice: + +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ + + +function compare(a, b) { + if (a === b) { + return 0; + } + + var x = a.length; + var y = b.length; + + for (var i = 0, len = Math.min(x, y); i < len; ++i) { + if (a[i] !== b[i]) { + x = a[i]; + y = b[i]; + break; + } + } + + if (x < y) { + return -1; + } + + if (y < x) { + return 1; + } + + return 0; +} + +var ONLY_ENUMERABLE = undefined; +var kStrict = true; +var kLoose = false; +var kNoIterator = 0; +var kIsArray = 1; +var kIsSet = 2; +var kIsMap = 3; // Check if they have the same source and flags + +function areSimilarRegExps(a, b) { + return regexFlagsSupported ? a.source === b.source && a.flags === b.flags : RegExp.prototype.toString.call(a) === RegExp.prototype.toString.call(b); +} + +function areSimilarFloatArrays(a, b) { + if (a.byteLength !== b.byteLength) { + return false; + } + + for (var offset = 0; offset < a.byteLength; offset++) { + if (a[offset] !== b[offset]) { + return false; + } + } + + return true; +} + +function areSimilarTypedArrays(a, b) { + if (a.byteLength !== b.byteLength) { + return false; + } + + return compare(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength)) === 0; +} + +function areEqualArrayBuffers(buf1, buf2) { + return buf1.byteLength === buf2.byteLength && compare(new Uint8Array(buf1), new Uint8Array(buf2)) === 0; +} + +function isEqualBoxedPrimitive(val1, val2) { + if (isNumberObject(val1)) { + return isNumberObject(val2) && objectIs(Number.prototype.valueOf.call(val1), Number.prototype.valueOf.call(val2)); + } + + if (isStringObject(val1)) { + return isStringObject(val2) && String.prototype.valueOf.call(val1) === String.prototype.valueOf.call(val2); + } + + if (isBooleanObject(val1)) { + return isBooleanObject(val2) && Boolean.prototype.valueOf.call(val1) === Boolean.prototype.valueOf.call(val2); + } + + if (isBigIntObject(val1)) { + return isBigIntObject(val2) && BigInt.prototype.valueOf.call(val1) === BigInt.prototype.valueOf.call(val2); + } + + return isSymbolObject(val2) && Symbol.prototype.valueOf.call(val1) === Symbol.prototype.valueOf.call(val2); +} // Notes: Type tags are historical [[Class]] properties that can be set by +// FunctionTemplate::SetClassName() in C++ or Symbol.toStringTag in JS +// and retrieved using Object.prototype.toString.call(obj) in JS +// See https://tc39.github.io/ecma262/#sec-object.prototype.tostring +// for a list of tags pre-defined in the spec. +// There are some unspecified tags in the wild too (e.g. typed array tags). +// Since tags can be altered, they only serve fast failures +// +// Typed arrays and buffers are checked by comparing the content in their +// underlying ArrayBuffer. This optimization requires that it's +// reasonable to interpret their underlying memory in the same way, +// which is checked by comparing their type tags. +// (e.g. a Uint8Array and a Uint16Array with the same memory content +// could still be different because they will be interpreted differently). +// +// For strict comparison, objects should have +// a) The same built-in type tags +// b) The same prototypes. + + +function innerDeepEqual(val1, val2, strict, memos) { + // All identical values are equivalent, as determined by ===. + if (val1 === val2) { + if (val1 !== 0) return true; + return strict ? objectIs(val1, val2) : true; + } // Check more closely if val1 and val2 are equal. + + + if (strict) { + if (_typeof(val1) !== 'object') { + return typeof val1 === 'number' && numberIsNaN(val1) && numberIsNaN(val2); + } + + if (_typeof(val2) !== 'object' || val1 === null || val2 === null) { + return false; + } + + if (Object.getPrototypeOf(val1) !== Object.getPrototypeOf(val2)) { + return false; + } + } else { + if (val1 === null || _typeof(val1) !== 'object') { + if (val2 === null || _typeof(val2) !== 'object') { + // eslint-disable-next-line eqeqeq + return val1 == val2; + } + + return false; + } + + if (val2 === null || _typeof(val2) !== 'object') { + return false; + } + } + + var val1Tag = objectToString(val1); + var val2Tag = objectToString(val2); + + if (val1Tag !== val2Tag) { + return false; + } + + if (Array.isArray(val1)) { + // Check for sparse arrays and general fast path + if (val1.length !== val2.length) { + return false; + } + + var keys1 = getOwnNonIndexProperties(val1, ONLY_ENUMERABLE); + var keys2 = getOwnNonIndexProperties(val2, ONLY_ENUMERABLE); + + if (keys1.length !== keys2.length) { + return false; + } + + return keyCheck(val1, val2, strict, memos, kIsArray, keys1); + } // [browserify] This triggers on certain types in IE (Map/Set) so we don't + // wan't to early return out of the rest of the checks. However we can check + // if the second value is one of these values and the first isn't. + + + if (val1Tag === '[object Object]') { + // return keyCheck(val1, val2, strict, memos, kNoIterator); + if (!isMap(val1) && isMap(val2) || !isSet(val1) && isSet(val2)) { + return false; + } + } + + if (isDate(val1)) { + if (!isDate(val2) || Date.prototype.getTime.call(val1) !== Date.prototype.getTime.call(val2)) { + return false; + } + } else if (isRegExp(val1)) { + if (!isRegExp(val2) || !areSimilarRegExps(val1, val2)) { + return false; + } + } else if (isNativeError(val1) || val1 instanceof Error) { + // Do not compare the stack as it might differ even though the error itself + // is otherwise identical. + if (val1.message !== val2.message || val1.name !== val2.name) { + return false; + } + } else if (isArrayBufferView(val1)) { + if (!strict && (isFloat32Array(val1) || isFloat64Array(val1))) { + if (!areSimilarFloatArrays(val1, val2)) { + return false; + } + } else if (!areSimilarTypedArrays(val1, val2)) { + return false; + } // Buffer.compare returns true, so val1.length === val2.length. If they both + // only contain numeric keys, we don't need to exam further than checking + // the symbols. + + + var _keys = getOwnNonIndexProperties(val1, ONLY_ENUMERABLE); + + var _keys2 = getOwnNonIndexProperties(val2, ONLY_ENUMERABLE); + + if (_keys.length !== _keys2.length) { + return false; + } + + return keyCheck(val1, val2, strict, memos, kNoIterator, _keys); + } else if (isSet(val1)) { + if (!isSet(val2) || val1.size !== val2.size) { + return false; + } + + return keyCheck(val1, val2, strict, memos, kIsSet); + } else if (isMap(val1)) { + if (!isMap(val2) || val1.size !== val2.size) { + return false; + } + + return keyCheck(val1, val2, strict, memos, kIsMap); + } else if (isAnyArrayBuffer(val1)) { + if (!areEqualArrayBuffers(val1, val2)) { + return false; + } + } else if (isBoxedPrimitive(val1) && !isEqualBoxedPrimitive(val1, val2)) { + return false; + } + + return keyCheck(val1, val2, strict, memos, kNoIterator); +} + +function getEnumerables(val, keys) { + return keys.filter(function (k) { + return propertyIsEnumerable(val, k); + }); +} + +function keyCheck(val1, val2, strict, memos, iterationType, aKeys) { + // For all remaining Object pairs, including Array, objects and Maps, + // equivalence is determined by having: + // a) The same number of owned enumerable properties + // b) The same set of keys/indexes (although not necessarily the same order) + // c) Equivalent values for every corresponding key/index + // d) For Sets and Maps, equal contents + // Note: this accounts for both named and indexed properties on Arrays. + if (arguments.length === 5) { + aKeys = Object.keys(val1); + var bKeys = Object.keys(val2); // The pair must have the same number of owned properties. + + if (aKeys.length !== bKeys.length) { + return false; + } + } // Cheap key test + + + var i = 0; + + for (; i < aKeys.length; i++) { + if (!hasOwnProperty(val2, aKeys[i])) { + return false; + } + } + + if (strict && arguments.length === 5) { + var symbolKeysA = objectGetOwnPropertySymbols(val1); + + if (symbolKeysA.length !== 0) { + var count = 0; + + for (i = 0; i < symbolKeysA.length; i++) { + var key = symbolKeysA[i]; + + if (propertyIsEnumerable(val1, key)) { + if (!propertyIsEnumerable(val2, key)) { + return false; + } + + aKeys.push(key); + count++; + } else if (propertyIsEnumerable(val2, key)) { + return false; + } + } + + var symbolKeysB = objectGetOwnPropertySymbols(val2); + + if (symbolKeysA.length !== symbolKeysB.length && getEnumerables(val2, symbolKeysB).length !== count) { + return false; + } + } else { + var _symbolKeysB = objectGetOwnPropertySymbols(val2); + + if (_symbolKeysB.length !== 0 && getEnumerables(val2, _symbolKeysB).length !== 0) { + return false; + } + } + } + + if (aKeys.length === 0 && (iterationType === kNoIterator || iterationType === kIsArray && val1.length === 0 || val1.size === 0)) { + return true; + } // Use memos to handle cycles. + + + if (memos === undefined) { + memos = { + val1: new Map(), + val2: new Map(), + position: 0 + }; + } else { + // We prevent up to two map.has(x) calls by directly retrieving the value + // and checking for undefined. The map can only contain numbers, so it is + // safe to check for undefined only. + var val2MemoA = memos.val1.get(val1); + + if (val2MemoA !== undefined) { + var val2MemoB = memos.val2.get(val2); + + if (val2MemoB !== undefined) { + return val2MemoA === val2MemoB; + } + } + + memos.position++; + } + + memos.val1.set(val1, memos.position); + memos.val2.set(val2, memos.position); + var areEq = objEquiv(val1, val2, strict, aKeys, memos, iterationType); + memos.val1.delete(val1); + memos.val2.delete(val2); + return areEq; +} + +function setHasEqualElement(set, val1, strict, memo) { + // Go looking. + var setValues = arrayFromSet(set); + + for (var i = 0; i < setValues.length; i++) { + var val2 = setValues[i]; + + if (innerDeepEqual(val1, val2, strict, memo)) { + // Remove the matching element to make sure we do not check that again. + set.delete(val2); + return true; + } + } + + return false; +} // See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Equality_comparisons_and_sameness#Loose_equality_using +// Sadly it is not possible to detect corresponding values properly in case the +// type is a string, number, bigint or boolean. The reason is that those values +// can match lots of different string values (e.g., 1n == '+00001'). + + +function findLooseMatchingPrimitives(prim) { + switch (_typeof(prim)) { + case 'undefined': + return null; + + case 'object': + // Only pass in null as object! + return undefined; + + case 'symbol': + return false; + + case 'string': + prim = +prim; + // Loose equal entries exist only if the string is possible to convert to + // a regular number and not NaN. + // Fall through + + case 'number': + if (numberIsNaN(prim)) { + return false; + } + + } + + return true; +} + +function setMightHaveLoosePrim(a, b, prim) { + var altValue = findLooseMatchingPrimitives(prim); + if (altValue != null) return altValue; + return b.has(altValue) && !a.has(altValue); +} + +function mapMightHaveLoosePrim(a, b, prim, item, memo) { + var altValue = findLooseMatchingPrimitives(prim); + + if (altValue != null) { + return altValue; + } + + var curB = b.get(altValue); + + if (curB === undefined && !b.has(altValue) || !innerDeepEqual(item, curB, false, memo)) { + return false; + } + + return !a.has(altValue) && innerDeepEqual(item, curB, false, memo); +} + +function setEquiv(a, b, strict, memo) { + // This is a lazily initiated Set of entries which have to be compared + // pairwise. + var set = null; + var aValues = arrayFromSet(a); + + for (var i = 0; i < aValues.length; i++) { + var val = aValues[i]; // Note: Checking for the objects first improves the performance for object + // heavy sets but it is a minor slow down for primitives. As they are fast + // to check this improves the worst case scenario instead. + + if (_typeof(val) === 'object' && val !== null) { + if (set === null) { + set = new Set(); + } // If the specified value doesn't exist in the second set its an not null + // object (or non strict only: a not matching primitive) we'll need to go + // hunting for something thats deep-(strict-)equal to it. To make this + // O(n log n) complexity we have to copy these values in a new set first. + + + set.add(val); + } else if (!b.has(val)) { + if (strict) return false; // Fast path to detect missing string, symbol, undefined and null values. + + if (!setMightHaveLoosePrim(a, b, val)) { + return false; + } + + if (set === null) { + set = new Set(); + } + + set.add(val); + } + } + + if (set !== null) { + var bValues = arrayFromSet(b); + + for (var _i = 0; _i < bValues.length; _i++) { + var _val = bValues[_i]; // We have to check if a primitive value is already + // matching and only if it's not, go hunting for it. + + if (_typeof(_val) === 'object' && _val !== null) { + if (!setHasEqualElement(set, _val, strict, memo)) return false; + } else if (!strict && !a.has(_val) && !setHasEqualElement(set, _val, strict, memo)) { + return false; + } + } + + return set.size === 0; + } + + return true; +} + +function mapHasEqualEntry(set, map, key1, item1, strict, memo) { + // To be able to handle cases like: + // Map([[{}, 'a'], [{}, 'b']]) vs Map([[{}, 'b'], [{}, 'a']]) + // ... we need to consider *all* matching keys, not just the first we find. + var setValues = arrayFromSet(set); + + for (var i = 0; i < setValues.length; i++) { + var key2 = setValues[i]; + + if (innerDeepEqual(key1, key2, strict, memo) && innerDeepEqual(item1, map.get(key2), strict, memo)) { + set.delete(key2); + return true; + } + } + + return false; +} + +function mapEquiv(a, b, strict, memo) { + var set = null; + var aEntries = arrayFromMap(a); + + for (var i = 0; i < aEntries.length; i++) { + var _aEntries$i = _slicedToArray(aEntries[i], 2), + key = _aEntries$i[0], + item1 = _aEntries$i[1]; + + if (_typeof(key) === 'object' && key !== null) { + if (set === null) { + set = new Set(); + } + + set.add(key); + } else { + // By directly retrieving the value we prevent another b.has(key) check in + // almost all possible cases. + var item2 = b.get(key); + + if (item2 === undefined && !b.has(key) || !innerDeepEqual(item1, item2, strict, memo)) { + if (strict) return false; // Fast path to detect missing string, symbol, undefined and null + // keys. + + if (!mapMightHaveLoosePrim(a, b, key, item1, memo)) return false; + + if (set === null) { + set = new Set(); + } + + set.add(key); + } + } + } + + if (set !== null) { + var bEntries = arrayFromMap(b); + + for (var _i2 = 0; _i2 < bEntries.length; _i2++) { + var _bEntries$_i = _slicedToArray(bEntries[_i2], 2), + key = _bEntries$_i[0], + item = _bEntries$_i[1]; + + if (_typeof(key) === 'object' && key !== null) { + if (!mapHasEqualEntry(set, a, key, item, strict, memo)) return false; + } else if (!strict && (!a.has(key) || !innerDeepEqual(a.get(key), item, false, memo)) && !mapHasEqualEntry(set, a, key, item, false, memo)) { + return false; + } + } + + return set.size === 0; + } + + return true; +} + +function objEquiv(a, b, strict, keys, memos, iterationType) { + // Sets and maps don't have their entries accessible via normal object + // properties. + var i = 0; + + if (iterationType === kIsSet) { + if (!setEquiv(a, b, strict, memos)) { + return false; + } + } else if (iterationType === kIsMap) { + if (!mapEquiv(a, b, strict, memos)) { + return false; + } + } else if (iterationType === kIsArray) { + for (; i < a.length; i++) { + if (hasOwnProperty(a, i)) { + if (!hasOwnProperty(b, i) || !innerDeepEqual(a[i], b[i], strict, memos)) { + return false; + } + } else if (hasOwnProperty(b, i)) { + return false; + } else { + // Array is sparse. + var keysA = Object.keys(a); + + for (; i < keysA.length; i++) { + var key = keysA[i]; + + if (!hasOwnProperty(b, key) || !innerDeepEqual(a[key], b[key], strict, memos)) { + return false; + } + } + + if (keysA.length !== Object.keys(b).length) { + return false; + } + + return true; + } + } + } // The pair must have equivalent values for every corresponding key. + // Possibly expensive deep test: + + + for (i = 0; i < keys.length; i++) { + var _key = keys[i]; + + if (!innerDeepEqual(a[_key], b[_key], strict, memos)) { + return false; + } + } + + return true; +} + +function isDeepEqual(val1, val2) { + return innerDeepEqual(val1, val2, kLoose); +} + +function isDeepStrictEqual(val1, val2) { + return innerDeepEqual(val1, val2, kStrict); +} + +module.exports = { + isDeepEqual: isDeepEqual, + isDeepStrictEqual: isDeepStrictEqual +}; + +/***/ }), + +/***/ 1924: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var GetIntrinsic = __webpack_require__(210); + +var callBind = __webpack_require__(5559); + +var $indexOf = callBind(GetIntrinsic('String.prototype.indexOf')); + +module.exports = function callBoundIntrinsic(name, allowMissing) { + var intrinsic = GetIntrinsic(name, !!allowMissing); + if (typeof intrinsic === 'function' && $indexOf(name, '.prototype.') > -1) { + return callBind(intrinsic); + } + return intrinsic; +}; + + +/***/ }), + +/***/ 5559: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var bind = __webpack_require__(8612); +var GetIntrinsic = __webpack_require__(210); + +var $apply = GetIntrinsic('%Function.prototype.apply%'); +var $call = GetIntrinsic('%Function.prototype.call%'); +var $reflectApply = GetIntrinsic('%Reflect.apply%', true) || bind.call($call, $apply); + +var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true); +var $max = GetIntrinsic('%Math.max%'); + +if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + } catch (e) { + // IE 8 has a broken defineProperty + $defineProperty = null; + } +} + +module.exports = function callBind(originalFunction) { + var func = $reflectApply(bind, $call, arguments); + if ($gOPD && $defineProperty) { + var desc = $gOPD(func, 'length'); + if (desc.configurable) { + // original length, plus the receiver, minus any additional arguments (after the receiver) + $defineProperty( + func, + 'length', + { value: 1 + $max(0, originalFunction.length - (arguments.length - 1)) } + ); + } + } + return func; +}; + +var applyBind = function applyBind() { + return $reflectApply(bind, $apply, arguments); +}; + +if ($defineProperty) { + $defineProperty(module.exports, 'apply', { value: applyBind }); +} else { + module.exports.apply = applyBind; +} + + +/***/ }), + +/***/ 4061: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + +const ansiStyles = __webpack_require__(6434); +const {stdout: stdoutColor, stderr: stderrColor} = __webpack_require__(8555); +const { + stringReplaceAll, + stringEncaseCRLFWithFirstIndex +} = __webpack_require__(3559); + +const {isArray} = Array; + +// `supportsColor.level` → `ansiStyles.color[name]` mapping +const levelMapping = [ + 'ansi', + 'ansi', + 'ansi256', + 'ansi16m' +]; + +const styles = Object.create(null); + +const applyOptions = (object, options = {}) => { + if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) { + throw new Error('The `level` option should be an integer from 0 to 3'); + } + + // Detect level if not set manually + const colorLevel = stdoutColor ? stdoutColor.level : 0; + object.level = options.level === undefined ? colorLevel : options.level; +}; + +class ChalkClass { + constructor(options) { + // eslint-disable-next-line no-constructor-return + return chalkFactory(options); + } +} + +const chalkFactory = options => { + const chalk = {}; + applyOptions(chalk, options); + + chalk.template = (...arguments_) => chalkTag(chalk.template, ...arguments_); + + Object.setPrototypeOf(chalk, Chalk.prototype); + Object.setPrototypeOf(chalk.template, chalk); + + chalk.template.constructor = () => { + throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.'); + }; + + chalk.template.Instance = ChalkClass; + + return chalk.template; +}; + +function Chalk(options) { + return chalkFactory(options); +} + +for (const [styleName, style] of Object.entries(ansiStyles)) { + styles[styleName] = { + get() { + const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty); + Object.defineProperty(this, styleName, {value: builder}); + return builder; + } + }; +} + +styles.visible = { + get() { + const builder = createBuilder(this, this._styler, true); + Object.defineProperty(this, 'visible', {value: builder}); + return builder; + } +}; + +const usedModels = ['rgb', 'hex', 'keyword', 'hsl', 'hsv', 'hwb', 'ansi', 'ansi256']; + +for (const model of usedModels) { + styles[model] = { + get() { + const {level} = this; + return function (...arguments_) { + const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler); + return createBuilder(this, styler, this._isEmpty); + }; + } + }; +} + +for (const model of usedModels) { + const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1); + styles[bgModel] = { + get() { + const {level} = this; + return function (...arguments_) { + const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler); + return createBuilder(this, styler, this._isEmpty); + }; + } + }; +} + +const proto = Object.defineProperties(() => {}, { + ...styles, + level: { + enumerable: true, + get() { + return this._generator.level; + }, + set(level) { + this._generator.level = level; + } + } +}); + +const createStyler = (open, close, parent) => { + let openAll; + let closeAll; + if (parent === undefined) { + openAll = open; + closeAll = close; + } else { + openAll = parent.openAll + open; + closeAll = close + parent.closeAll; + } + + return { + open, + close, + openAll, + closeAll, + parent + }; +}; + +const createBuilder = (self, _styler, _isEmpty) => { + const builder = (...arguments_) => { + if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) { + // Called as a template literal, for example: chalk.red`2 + 3 = {bold ${2+3}}` + return applyStyle(builder, chalkTag(builder, ...arguments_)); + } + + // Single argument is hot path, implicit coercion is faster than anything + // eslint-disable-next-line no-implicit-coercion + return applyStyle(builder, (arguments_.length === 1) ? ('' + arguments_[0]) : arguments_.join(' ')); + }; + + // We alter the prototype because we must return a function, but there is + // no way to create a function with a different prototype + Object.setPrototypeOf(builder, proto); + + builder._generator = self; + builder._styler = _styler; + builder._isEmpty = _isEmpty; + + return builder; +}; + +const applyStyle = (self, string) => { + if (self.level <= 0 || !string) { + return self._isEmpty ? '' : string; + } + + let styler = self._styler; + + if (styler === undefined) { + return string; + } + + const {openAll, closeAll} = styler; + if (string.indexOf('\u001B') !== -1) { + while (styler !== undefined) { + // Replace any instances already present with a re-opening code + // otherwise only the part of the string until said closing code + // will be colored, and the rest will simply be 'plain'. + string = stringReplaceAll(string, styler.close, styler.open); + + styler = styler.parent; + } + } + + // We can move both next actions out of loop, because remaining actions in loop won't have + // any/visible effect on parts we add here. Close the styling before a linebreak and reopen + // after next line to fix a bleed issue on macOS: https://github.com/chalk/chalk/pull/92 + const lfIndex = string.indexOf('\n'); + if (lfIndex !== -1) { + string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex); + } + + return openAll + string + closeAll; +}; + +let template; +const chalkTag = (chalk, ...strings) => { + const [firstString] = strings; + + if (!isArray(firstString) || !isArray(firstString.raw)) { + // If chalk() was called by itself or with a string, + // return the string itself as a string. + return strings.join(' '); + } + + const arguments_ = strings.slice(1); + const parts = [firstString.raw[0]]; + + for (let i = 1; i < firstString.length; i++) { + parts.push( + String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), + String(firstString.raw[i]) + ); + } + + if (template === undefined) { + template = __webpack_require__(9515); + } + + return template(chalk, parts.join('')); +}; + +Object.defineProperties(Chalk.prototype, styles); + +const chalk = Chalk(); // eslint-disable-line new-cap +chalk.supportsColor = stdoutColor; +chalk.stderr = Chalk({level: stderrColor ? stderrColor.level : 0}); // eslint-disable-line new-cap +chalk.stderr.supportsColor = stderrColor; + +module.exports = chalk; + + +/***/ }), + +/***/ 9515: +/***/ ((module) => { + +"use strict"; + +const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi; +const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g; +const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/; +const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi; + +const ESCAPES = new Map([ + ['n', '\n'], + ['r', '\r'], + ['t', '\t'], + ['b', '\b'], + ['f', '\f'], + ['v', '\v'], + ['0', '\0'], + ['\\', '\\'], + ['e', '\u001B'], + ['a', '\u0007'] +]); + +function unescape(c) { + const u = c[0] === 'u'; + const bracket = c[1] === '{'; + + if ((u && !bracket && c.length === 5) || (c[0] === 'x' && c.length === 3)) { + return String.fromCharCode(parseInt(c.slice(1), 16)); + } + + if (u && bracket) { + return String.fromCodePoint(parseInt(c.slice(2, -1), 16)); + } + + return ESCAPES.get(c) || c; +} + +function parseArguments(name, arguments_) { + const results = []; + const chunks = arguments_.trim().split(/\s*,\s*/g); + let matches; + + for (const chunk of chunks) { + const number = Number(chunk); + if (!Number.isNaN(number)) { + results.push(number); + } else if ((matches = chunk.match(STRING_REGEX))) { + results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character) => escape ? unescape(escape) : character)); + } else { + throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`); + } + } + + return results; +} + +function parseStyle(style) { + STYLE_REGEX.lastIndex = 0; + + const results = []; + let matches; + + while ((matches = STYLE_REGEX.exec(style)) !== null) { + const name = matches[1]; + + if (matches[2]) { + const args = parseArguments(name, matches[2]); + results.push([name].concat(args)); + } else { + results.push([name]); + } + } + + return results; +} + +function buildStyle(chalk, styles) { + const enabled = {}; + + for (const layer of styles) { + for (const style of layer.styles) { + enabled[style[0]] = layer.inverse ? null : style.slice(1); + } + } + + let current = chalk; + for (const [styleName, styles] of Object.entries(enabled)) { + if (!Array.isArray(styles)) { + continue; + } + + if (!(styleName in current)) { + throw new Error(`Unknown Chalk style: ${styleName}`); + } + + current = styles.length > 0 ? current[styleName](...styles) : current[styleName]; + } + + return current; +} + +module.exports = (chalk, temporary) => { + const styles = []; + const chunks = []; + let chunk = []; + + // eslint-disable-next-line max-params + temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character) => { + if (escapeCharacter) { + chunk.push(unescape(escapeCharacter)); + } else if (style) { + const string = chunk.join(''); + chunk = []; + chunks.push(styles.length === 0 ? string : buildStyle(chalk, styles)(string)); + styles.push({inverse, styles: parseStyle(style)}); + } else if (close) { + if (styles.length === 0) { + throw new Error('Found extraneous } in Chalk template literal'); + } + + chunks.push(buildStyle(chalk, styles)(chunk.join(''))); + chunk = []; + styles.pop(); + } else { + chunk.push(character); + } + }); + + chunks.push(chunk.join('')); + + if (styles.length > 0) { + const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${styles.length === 1 ? '' : 's'} (\`}\`)`; + throw new Error(errMessage); + } + + return chunks.join(''); +}; + + +/***/ }), + +/***/ 3559: +/***/ ((module) => { + +"use strict"; + + +const stringReplaceAll = (string, substring, replacer) => { + let index = string.indexOf(substring); + if (index === -1) { + return string; + } + + const substringLength = substring.length; + let endIndex = 0; + let returnValue = ''; + do { + returnValue += string.substr(endIndex, index - endIndex) + substring + replacer; + endIndex = index + substringLength; + index = string.indexOf(substring, endIndex); + } while (index !== -1); + + returnValue += string.substr(endIndex); + return returnValue; +}; + +const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index) => { + let endIndex = 0; + let returnValue = ''; + do { + const gotCR = string[index - 1] === '\r'; + returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix; + endIndex = index + 1; + index = string.indexOf('\n', endIndex); + } while (index !== -1); + + returnValue += string.substr(endIndex); + return returnValue; +}; + +module.exports = { + stringReplaceAll, + stringEncaseCRLFWithFirstIndex +}; + + +/***/ }), + +/***/ 8168: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/* MIT license */ +/* eslint-disable no-mixed-operators */ +const cssKeywords = __webpack_require__(8874); + +// NOTE: conversions should only return primitive values (i.e. arrays, or +// values that give correct `typeof` results). +// do not use box values types (i.e. Number(), String(), etc.) + +const reverseKeywords = {}; +for (const key of Object.keys(cssKeywords)) { + reverseKeywords[cssKeywords[key]] = key; +} + +const convert = { + rgb: {channels: 3, labels: 'rgb'}, + hsl: {channels: 3, labels: 'hsl'}, + hsv: {channels: 3, labels: 'hsv'}, + hwb: {channels: 3, labels: 'hwb'}, + cmyk: {channels: 4, labels: 'cmyk'}, + xyz: {channels: 3, labels: 'xyz'}, + lab: {channels: 3, labels: 'lab'}, + lch: {channels: 3, labels: 'lch'}, + hex: {channels: 1, labels: ['hex']}, + keyword: {channels: 1, labels: ['keyword']}, + ansi16: {channels: 1, labels: ['ansi16']}, + ansi256: {channels: 1, labels: ['ansi256']}, + hcg: {channels: 3, labels: ['h', 'c', 'g']}, + apple: {channels: 3, labels: ['r16', 'g16', 'b16']}, + gray: {channels: 1, labels: ['gray']} +}; + +module.exports = convert; + +// Hide .channels and .labels properties +for (const model of Object.keys(convert)) { + if (!('channels' in convert[model])) { + throw new Error('missing channels property: ' + model); + } + + if (!('labels' in convert[model])) { + throw new Error('missing channel labels property: ' + model); + } + + if (convert[model].labels.length !== convert[model].channels) { + throw new Error('channel and label counts mismatch: ' + model); + } + + const {channels, labels} = convert[model]; + delete convert[model].channels; + delete convert[model].labels; + Object.defineProperty(convert[model], 'channels', {value: channels}); + Object.defineProperty(convert[model], 'labels', {value: labels}); +} + +convert.rgb.hsl = function (rgb) { + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + const min = Math.min(r, g, b); + const max = Math.max(r, g, b); + const delta = max - min; + let h; + let s; + + if (max === min) { + h = 0; + } else if (r === max) { + h = (g - b) / delta; + } else if (g === max) { + h = 2 + (b - r) / delta; + } else if (b === max) { + h = 4 + (r - g) / delta; + } + + h = Math.min(h * 60, 360); + + if (h < 0) { + h += 360; + } + + const l = (min + max) / 2; + + if (max === min) { + s = 0; + } else if (l <= 0.5) { + s = delta / (max + min); + } else { + s = delta / (2 - max - min); + } + + return [h, s * 100, l * 100]; +}; + +convert.rgb.hsv = function (rgb) { + let rdif; + let gdif; + let bdif; + let h; + let s; + + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + const v = Math.max(r, g, b); + const diff = v - Math.min(r, g, b); + const diffc = function (c) { + return (v - c) / 6 / diff + 1 / 2; + }; + + if (diff === 0) { + h = 0; + s = 0; + } else { + s = diff / v; + rdif = diffc(r); + gdif = diffc(g); + bdif = diffc(b); + + if (r === v) { + h = bdif - gdif; + } else if (g === v) { + h = (1 / 3) + rdif - bdif; + } else if (b === v) { + h = (2 / 3) + gdif - rdif; + } + + if (h < 0) { + h += 1; + } else if (h > 1) { + h -= 1; + } + } + + return [ + h * 360, + s * 100, + v * 100 + ]; +}; + +convert.rgb.hwb = function (rgb) { + const r = rgb[0]; + const g = rgb[1]; + let b = rgb[2]; + const h = convert.rgb.hsl(rgb)[0]; + const w = 1 / 255 * Math.min(r, Math.min(g, b)); + + b = 1 - 1 / 255 * Math.max(r, Math.max(g, b)); + + return [h, w * 100, b * 100]; +}; + +convert.rgb.cmyk = function (rgb) { + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + + const k = Math.min(1 - r, 1 - g, 1 - b); + const c = (1 - r - k) / (1 - k) || 0; + const m = (1 - g - k) / (1 - k) || 0; + const y = (1 - b - k) / (1 - k) || 0; + + return [c * 100, m * 100, y * 100, k * 100]; +}; + +function comparativeDistance(x, y) { + /* + See https://en.m.wikipedia.org/wiki/Euclidean_distance#Squared_Euclidean_distance + */ + return ( + ((x[0] - y[0]) ** 2) + + ((x[1] - y[1]) ** 2) + + ((x[2] - y[2]) ** 2) + ); +} + +convert.rgb.keyword = function (rgb) { + const reversed = reverseKeywords[rgb]; + if (reversed) { + return reversed; + } + + let currentClosestDistance = Infinity; + let currentClosestKeyword; + + for (const keyword of Object.keys(cssKeywords)) { + const value = cssKeywords[keyword]; + + // Compute comparative distance + const distance = comparativeDistance(rgb, value); + + // Check if its less, if so set as closest + if (distance < currentClosestDistance) { + currentClosestDistance = distance; + currentClosestKeyword = keyword; + } + } + + return currentClosestKeyword; +}; + +convert.keyword.rgb = function (keyword) { + return cssKeywords[keyword]; +}; + +convert.rgb.xyz = function (rgb) { + let r = rgb[0] / 255; + let g = rgb[1] / 255; + let b = rgb[2] / 255; + + // Assume sRGB + r = r > 0.04045 ? (((r + 0.055) / 1.055) ** 2.4) : (r / 12.92); + g = g > 0.04045 ? (((g + 0.055) / 1.055) ** 2.4) : (g / 12.92); + b = b > 0.04045 ? (((b + 0.055) / 1.055) ** 2.4) : (b / 12.92); + + const x = (r * 0.4124) + (g * 0.3576) + (b * 0.1805); + const y = (r * 0.2126) + (g * 0.7152) + (b * 0.0722); + const z = (r * 0.0193) + (g * 0.1192) + (b * 0.9505); + + return [x * 100, y * 100, z * 100]; +}; + +convert.rgb.lab = function (rgb) { + const xyz = convert.rgb.xyz(rgb); + let x = xyz[0]; + let y = xyz[1]; + let z = xyz[2]; + + x /= 95.047; + y /= 100; + z /= 108.883; + + x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116); + + const l = (116 * y) - 16; + const a = 500 * (x - y); + const b = 200 * (y - z); + + return [l, a, b]; +}; + +convert.hsl.rgb = function (hsl) { + const h = hsl[0] / 360; + const s = hsl[1] / 100; + const l = hsl[2] / 100; + let t2; + let t3; + let val; + + if (s === 0) { + val = l * 255; + return [val, val, val]; + } + + if (l < 0.5) { + t2 = l * (1 + s); + } else { + t2 = l + s - l * s; + } + + const t1 = 2 * l - t2; + + const rgb = [0, 0, 0]; + for (let i = 0; i < 3; i++) { + t3 = h + 1 / 3 * -(i - 1); + if (t3 < 0) { + t3++; + } + + if (t3 > 1) { + t3--; + } + + if (6 * t3 < 1) { + val = t1 + (t2 - t1) * 6 * t3; + } else if (2 * t3 < 1) { + val = t2; + } else if (3 * t3 < 2) { + val = t1 + (t2 - t1) * (2 / 3 - t3) * 6; + } else { + val = t1; + } + + rgb[i] = val * 255; + } + + return rgb; +}; + +convert.hsl.hsv = function (hsl) { + const h = hsl[0]; + let s = hsl[1] / 100; + let l = hsl[2] / 100; + let smin = s; + const lmin = Math.max(l, 0.01); + + l *= 2; + s *= (l <= 1) ? l : 2 - l; + smin *= lmin <= 1 ? lmin : 2 - lmin; + const v = (l + s) / 2; + const sv = l === 0 ? (2 * smin) / (lmin + smin) : (2 * s) / (l + s); + + return [h, sv * 100, v * 100]; +}; + +convert.hsv.rgb = function (hsv) { + const h = hsv[0] / 60; + const s = hsv[1] / 100; + let v = hsv[2] / 100; + const hi = Math.floor(h) % 6; + + const f = h - Math.floor(h); + const p = 255 * v * (1 - s); + const q = 255 * v * (1 - (s * f)); + const t = 255 * v * (1 - (s * (1 - f))); + v *= 255; + + switch (hi) { + case 0: + return [v, t, p]; + case 1: + return [q, v, p]; + case 2: + return [p, v, t]; + case 3: + return [p, q, v]; + case 4: + return [t, p, v]; + case 5: + return [v, p, q]; + } +}; + +convert.hsv.hsl = function (hsv) { + const h = hsv[0]; + const s = hsv[1] / 100; + const v = hsv[2] / 100; + const vmin = Math.max(v, 0.01); + let sl; + let l; + + l = (2 - s) * v; + const lmin = (2 - s) * vmin; + sl = s * vmin; + sl /= (lmin <= 1) ? lmin : 2 - lmin; + sl = sl || 0; + l /= 2; + + return [h, sl * 100, l * 100]; +}; + +// http://dev.w3.org/csswg/css-color/#hwb-to-rgb +convert.hwb.rgb = function (hwb) { + const h = hwb[0] / 360; + let wh = hwb[1] / 100; + let bl = hwb[2] / 100; + const ratio = wh + bl; + let f; + + // Wh + bl cant be > 1 + if (ratio > 1) { + wh /= ratio; + bl /= ratio; + } + + const i = Math.floor(6 * h); + const v = 1 - bl; + f = 6 * h - i; + + if ((i & 0x01) !== 0) { + f = 1 - f; + } + + const n = wh + f * (v - wh); // Linear interpolation + + let r; + let g; + let b; + /* eslint-disable max-statements-per-line,no-multi-spaces */ + switch (i) { + default: + case 6: + case 0: r = v; g = n; b = wh; break; + case 1: r = n; g = v; b = wh; break; + case 2: r = wh; g = v; b = n; break; + case 3: r = wh; g = n; b = v; break; + case 4: r = n; g = wh; b = v; break; + case 5: r = v; g = wh; b = n; break; + } + /* eslint-enable max-statements-per-line,no-multi-spaces */ + + return [r * 255, g * 255, b * 255]; +}; + +convert.cmyk.rgb = function (cmyk) { + const c = cmyk[0] / 100; + const m = cmyk[1] / 100; + const y = cmyk[2] / 100; + const k = cmyk[3] / 100; + + const r = 1 - Math.min(1, c * (1 - k) + k); + const g = 1 - Math.min(1, m * (1 - k) + k); + const b = 1 - Math.min(1, y * (1 - k) + k); + + return [r * 255, g * 255, b * 255]; +}; + +convert.xyz.rgb = function (xyz) { + const x = xyz[0] / 100; + const y = xyz[1] / 100; + const z = xyz[2] / 100; + let r; + let g; + let b; + + r = (x * 3.2406) + (y * -1.5372) + (z * -0.4986); + g = (x * -0.9689) + (y * 1.8758) + (z * 0.0415); + b = (x * 0.0557) + (y * -0.2040) + (z * 1.0570); + + // Assume sRGB + r = r > 0.0031308 + ? ((1.055 * (r ** (1.0 / 2.4))) - 0.055) + : r * 12.92; + + g = g > 0.0031308 + ? ((1.055 * (g ** (1.0 / 2.4))) - 0.055) + : g * 12.92; + + b = b > 0.0031308 + ? ((1.055 * (b ** (1.0 / 2.4))) - 0.055) + : b * 12.92; + + r = Math.min(Math.max(0, r), 1); + g = Math.min(Math.max(0, g), 1); + b = Math.min(Math.max(0, b), 1); + + return [r * 255, g * 255, b * 255]; +}; + +convert.xyz.lab = function (xyz) { + let x = xyz[0]; + let y = xyz[1]; + let z = xyz[2]; + + x /= 95.047; + y /= 100; + z /= 108.883; + + x = x > 0.008856 ? (x ** (1 / 3)) : (7.787 * x) + (16 / 116); + y = y > 0.008856 ? (y ** (1 / 3)) : (7.787 * y) + (16 / 116); + z = z > 0.008856 ? (z ** (1 / 3)) : (7.787 * z) + (16 / 116); + + const l = (116 * y) - 16; + const a = 500 * (x - y); + const b = 200 * (y - z); + + return [l, a, b]; +}; + +convert.lab.xyz = function (lab) { + const l = lab[0]; + const a = lab[1]; + const b = lab[2]; + let x; + let y; + let z; + + y = (l + 16) / 116; + x = a / 500 + y; + z = y - b / 200; + + const y2 = y ** 3; + const x2 = x ** 3; + const z2 = z ** 3; + y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787; + x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787; + z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787; + + x *= 95.047; + y *= 100; + z *= 108.883; + + return [x, y, z]; +}; + +convert.lab.lch = function (lab) { + const l = lab[0]; + const a = lab[1]; + const b = lab[2]; + let h; + + const hr = Math.atan2(b, a); + h = hr * 360 / 2 / Math.PI; + + if (h < 0) { + h += 360; + } + + const c = Math.sqrt(a * a + b * b); + + return [l, c, h]; +}; + +convert.lch.lab = function (lch) { + const l = lch[0]; + const c = lch[1]; + const h = lch[2]; + + const hr = h / 360 * 2 * Math.PI; + const a = c * Math.cos(hr); + const b = c * Math.sin(hr); + + return [l, a, b]; +}; + +convert.rgb.ansi16 = function (args, saturation = null) { + const [r, g, b] = args; + let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation; // Hsv -> ansi16 optimization + + value = Math.round(value / 50); + + if (value === 0) { + return 30; + } + + let ansi = 30 + + ((Math.round(b / 255) << 2) + | (Math.round(g / 255) << 1) + | Math.round(r / 255)); + + if (value === 2) { + ansi += 60; + } + + return ansi; +}; + +convert.hsv.ansi16 = function (args) { + // Optimization here; we already know the value and don't need to get + // it converted for us. + return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]); +}; + +convert.rgb.ansi256 = function (args) { + const r = args[0]; + const g = args[1]; + const b = args[2]; + + // We use the extended greyscale palette here, with the exception of + // black and white. normal palette only has 4 greyscale shades. + if (r === g && g === b) { + if (r < 8) { + return 16; + } + + if (r > 248) { + return 231; + } + + return Math.round(((r - 8) / 247) * 24) + 232; + } + + const ansi = 16 + + (36 * Math.round(r / 255 * 5)) + + (6 * Math.round(g / 255 * 5)) + + Math.round(b / 255 * 5); + + return ansi; +}; + +convert.ansi16.rgb = function (args) { + let color = args % 10; + + // Handle greyscale + if (color === 0 || color === 7) { + if (args > 50) { + color += 3.5; + } + + color = color / 10.5 * 255; + + return [color, color, color]; + } + + const mult = (~~(args > 50) + 1) * 0.5; + const r = ((color & 1) * mult) * 255; + const g = (((color >> 1) & 1) * mult) * 255; + const b = (((color >> 2) & 1) * mult) * 255; + + return [r, g, b]; +}; + +convert.ansi256.rgb = function (args) { + // Handle greyscale + if (args >= 232) { + const c = (args - 232) * 10 + 8; + return [c, c, c]; + } + + args -= 16; + + let rem; + const r = Math.floor(args / 36) / 5 * 255; + const g = Math.floor((rem = args % 36) / 6) / 5 * 255; + const b = (rem % 6) / 5 * 255; + + return [r, g, b]; +}; + +convert.rgb.hex = function (args) { + const integer = ((Math.round(args[0]) & 0xFF) << 16) + + ((Math.round(args[1]) & 0xFF) << 8) + + (Math.round(args[2]) & 0xFF); + + const string = integer.toString(16).toUpperCase(); + return '000000'.substring(string.length) + string; +}; + +convert.hex.rgb = function (args) { + const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i); + if (!match) { + return [0, 0, 0]; + } + + let colorString = match[0]; + + if (match[0].length === 3) { + colorString = colorString.split('').map(char => { + return char + char; + }).join(''); + } + + const integer = parseInt(colorString, 16); + const r = (integer >> 16) & 0xFF; + const g = (integer >> 8) & 0xFF; + const b = integer & 0xFF; + + return [r, g, b]; +}; + +convert.rgb.hcg = function (rgb) { + const r = rgb[0] / 255; + const g = rgb[1] / 255; + const b = rgb[2] / 255; + const max = Math.max(Math.max(r, g), b); + const min = Math.min(Math.min(r, g), b); + const chroma = (max - min); + let grayscale; + let hue; + + if (chroma < 1) { + grayscale = min / (1 - chroma); + } else { + grayscale = 0; + } + + if (chroma <= 0) { + hue = 0; + } else + if (max === r) { + hue = ((g - b) / chroma) % 6; + } else + if (max === g) { + hue = 2 + (b - r) / chroma; + } else { + hue = 4 + (r - g) / chroma; + } + + hue /= 6; + hue %= 1; + + return [hue * 360, chroma * 100, grayscale * 100]; +}; + +convert.hsl.hcg = function (hsl) { + const s = hsl[1] / 100; + const l = hsl[2] / 100; + + const c = l < 0.5 ? (2.0 * s * l) : (2.0 * s * (1.0 - l)); + + let f = 0; + if (c < 1.0) { + f = (l - 0.5 * c) / (1.0 - c); + } + + return [hsl[0], c * 100, f * 100]; +}; + +convert.hsv.hcg = function (hsv) { + const s = hsv[1] / 100; + const v = hsv[2] / 100; + + const c = s * v; + let f = 0; + + if (c < 1.0) { + f = (v - c) / (1 - c); + } + + return [hsv[0], c * 100, f * 100]; +}; + +convert.hcg.rgb = function (hcg) { + const h = hcg[0] / 360; + const c = hcg[1] / 100; + const g = hcg[2] / 100; + + if (c === 0.0) { + return [g * 255, g * 255, g * 255]; + } + + const pure = [0, 0, 0]; + const hi = (h % 1) * 6; + const v = hi % 1; + const w = 1 - v; + let mg = 0; + + /* eslint-disable max-statements-per-line */ + switch (Math.floor(hi)) { + case 0: + pure[0] = 1; pure[1] = v; pure[2] = 0; break; + case 1: + pure[0] = w; pure[1] = 1; pure[2] = 0; break; + case 2: + pure[0] = 0; pure[1] = 1; pure[2] = v; break; + case 3: + pure[0] = 0; pure[1] = w; pure[2] = 1; break; + case 4: + pure[0] = v; pure[1] = 0; pure[2] = 1; break; + default: + pure[0] = 1; pure[1] = 0; pure[2] = w; + } + /* eslint-enable max-statements-per-line */ + + mg = (1.0 - c) * g; + + return [ + (c * pure[0] + mg) * 255, + (c * pure[1] + mg) * 255, + (c * pure[2] + mg) * 255 + ]; +}; + +convert.hcg.hsv = function (hcg) { + const c = hcg[1] / 100; + const g = hcg[2] / 100; + + const v = c + g * (1.0 - c); + let f = 0; + + if (v > 0.0) { + f = c / v; + } + + return [hcg[0], f * 100, v * 100]; +}; + +convert.hcg.hsl = function (hcg) { + const c = hcg[1] / 100; + const g = hcg[2] / 100; + + const l = g * (1.0 - c) + 0.5 * c; + let s = 0; + + if (l > 0.0 && l < 0.5) { + s = c / (2 * l); + } else + if (l >= 0.5 && l < 1.0) { + s = c / (2 * (1 - l)); + } + + return [hcg[0], s * 100, l * 100]; +}; + +convert.hcg.hwb = function (hcg) { + const c = hcg[1] / 100; + const g = hcg[2] / 100; + const v = c + g * (1.0 - c); + return [hcg[0], (v - c) * 100, (1 - v) * 100]; +}; + +convert.hwb.hcg = function (hwb) { + const w = hwb[1] / 100; + const b = hwb[2] / 100; + const v = 1 - b; + const c = v - w; + let g = 0; + + if (c < 1) { + g = (v - c) / (1 - c); + } + + return [hwb[0], c * 100, g * 100]; +}; + +convert.apple.rgb = function (apple) { + return [(apple[0] / 65535) * 255, (apple[1] / 65535) * 255, (apple[2] / 65535) * 255]; +}; + +convert.rgb.apple = function (rgb) { + return [(rgb[0] / 255) * 65535, (rgb[1] / 255) * 65535, (rgb[2] / 255) * 65535]; +}; + +convert.gray.rgb = function (args) { + return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255]; +}; + +convert.gray.hsl = function (args) { + return [0, 0, args[0]]; +}; + +convert.gray.hsv = convert.gray.hsl; + +convert.gray.hwb = function (gray) { + return [0, 100, gray[0]]; +}; + +convert.gray.cmyk = function (gray) { + return [0, 0, 0, gray[0]]; +}; + +convert.gray.lab = function (gray) { + return [gray[0], 0, 0]; +}; + +convert.gray.hex = function (gray) { + const val = Math.round(gray[0] / 100 * 255) & 0xFF; + const integer = (val << 16) + (val << 8) + val; + + const string = integer.toString(16).toUpperCase(); + return '000000'.substring(string.length) + string; +}; + +convert.rgb.gray = function (rgb) { + const val = (rgb[0] + rgb[1] + rgb[2]) / 3; + return [val / 255 * 100]; +}; + + +/***/ }), + +/***/ 2085: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +const conversions = __webpack_require__(8168); +const route = __webpack_require__(4111); + +const convert = {}; + +const models = Object.keys(conversions); + +function wrapRaw(fn) { + const wrappedFn = function (...args) { + const arg0 = args[0]; + if (arg0 === undefined || arg0 === null) { + return arg0; + } + + if (arg0.length > 1) { + args = arg0; + } + + return fn(args); + }; + + // Preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } + + return wrappedFn; +} + +function wrapRounded(fn) { + const wrappedFn = function (...args) { + const arg0 = args[0]; + + if (arg0 === undefined || arg0 === null) { + return arg0; + } + + if (arg0.length > 1) { + args = arg0; + } + + const result = fn(args); + + // We're assuming the result is an array here. + // see notice in conversions.js; don't use box types + // in conversion functions. + if (typeof result === 'object') { + for (let len = result.length, i = 0; i < len; i++) { + result[i] = Math.round(result[i]); + } + } + + return result; + }; + + // Preserve .conversion property if there is one + if ('conversion' in fn) { + wrappedFn.conversion = fn.conversion; + } + + return wrappedFn; +} + +models.forEach(fromModel => { + convert[fromModel] = {}; + + Object.defineProperty(convert[fromModel], 'channels', {value: conversions[fromModel].channels}); + Object.defineProperty(convert[fromModel], 'labels', {value: conversions[fromModel].labels}); + + const routes = route(fromModel); + const routeModels = Object.keys(routes); + + routeModels.forEach(toModel => { + const fn = routes[toModel]; + + convert[fromModel][toModel] = wrapRounded(fn); + convert[fromModel][toModel].raw = wrapRaw(fn); + }); +}); + +module.exports = convert; + + +/***/ }), + +/***/ 4111: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +const conversions = __webpack_require__(8168); + +/* + This function routes a model to all other models. + + all functions that are routed have a property `.conversion` attached + to the returned synthetic function. This property is an array + of strings, each with the steps in between the 'from' and 'to' + color models (inclusive). + + conversions that are not possible simply are not included. +*/ + +function buildGraph() { + const graph = {}; + // https://jsperf.com/object-keys-vs-for-in-with-closure/3 + const models = Object.keys(conversions); + + for (let len = models.length, i = 0; i < len; i++) { + graph[models[i]] = { + // http://jsperf.com/1-vs-infinity + // micro-opt, but this is simple. + distance: -1, + parent: null + }; + } + + return graph; +} + +// https://en.wikipedia.org/wiki/Breadth-first_search +function deriveBFS(fromModel) { + const graph = buildGraph(); + const queue = [fromModel]; // Unshift -> queue -> pop + + graph[fromModel].distance = 0; + + while (queue.length) { + const current = queue.pop(); + const adjacents = Object.keys(conversions[current]); + + for (let len = adjacents.length, i = 0; i < len; i++) { + const adjacent = adjacents[i]; + const node = graph[adjacent]; + + if (node.distance === -1) { + node.distance = graph[current].distance + 1; + node.parent = current; + queue.unshift(adjacent); + } + } + } + + return graph; +} + +function link(from, to) { + return function (args) { + return to(from(args)); + }; +} + +function wrapConversion(toModel, graph) { + const path = [graph[toModel].parent, toModel]; + let fn = conversions[graph[toModel].parent][toModel]; + + let cur = graph[toModel].parent; + while (graph[cur].parent) { + path.unshift(graph[cur].parent); + fn = link(conversions[graph[cur].parent][cur], fn); + cur = graph[cur].parent; + } + + fn.conversion = path; + return fn; +} + +module.exports = function (fromModel) { + const graph = deriveBFS(fromModel); + const conversion = {}; + + const models = Object.keys(graph); + for (let len = models.length, i = 0; i < len; i++) { + const toModel = models[i]; + const node = graph[toModel]; + + if (node.parent === null) { + // No possible conversion, or this node is the source model. + continue; + } + + conversion[toModel] = wrapConversion(toModel, graph); + } + + return conversion; +}; + + + +/***/ }), + +/***/ 8874: +/***/ ((module) => { + +"use strict"; + + +module.exports = { + "aliceblue": [240, 248, 255], + "antiquewhite": [250, 235, 215], + "aqua": [0, 255, 255], + "aquamarine": [127, 255, 212], + "azure": [240, 255, 255], + "beige": [245, 245, 220], + "bisque": [255, 228, 196], + "black": [0, 0, 0], + "blanchedalmond": [255, 235, 205], + "blue": [0, 0, 255], + "blueviolet": [138, 43, 226], + "brown": [165, 42, 42], + "burlywood": [222, 184, 135], + "cadetblue": [95, 158, 160], + "chartreuse": [127, 255, 0], + "chocolate": [210, 105, 30], + "coral": [255, 127, 80], + "cornflowerblue": [100, 149, 237], + "cornsilk": [255, 248, 220], + "crimson": [220, 20, 60], + "cyan": [0, 255, 255], + "darkblue": [0, 0, 139], + "darkcyan": [0, 139, 139], + "darkgoldenrod": [184, 134, 11], + "darkgray": [169, 169, 169], + "darkgreen": [0, 100, 0], + "darkgrey": [169, 169, 169], + "darkkhaki": [189, 183, 107], + "darkmagenta": [139, 0, 139], + "darkolivegreen": [85, 107, 47], + "darkorange": [255, 140, 0], + "darkorchid": [153, 50, 204], + "darkred": [139, 0, 0], + "darksalmon": [233, 150, 122], + "darkseagreen": [143, 188, 143], + "darkslateblue": [72, 61, 139], + "darkslategray": [47, 79, 79], + "darkslategrey": [47, 79, 79], + "darkturquoise": [0, 206, 209], + "darkviolet": [148, 0, 211], + "deeppink": [255, 20, 147], + "deepskyblue": [0, 191, 255], + "dimgray": [105, 105, 105], + "dimgrey": [105, 105, 105], + "dodgerblue": [30, 144, 255], + "firebrick": [178, 34, 34], + "floralwhite": [255, 250, 240], + "forestgreen": [34, 139, 34], + "fuchsia": [255, 0, 255], + "gainsboro": [220, 220, 220], + "ghostwhite": [248, 248, 255], + "gold": [255, 215, 0], + "goldenrod": [218, 165, 32], + "gray": [128, 128, 128], + "green": [0, 128, 0], + "greenyellow": [173, 255, 47], + "grey": [128, 128, 128], + "honeydew": [240, 255, 240], + "hotpink": [255, 105, 180], + "indianred": [205, 92, 92], + "indigo": [75, 0, 130], + "ivory": [255, 255, 240], + "khaki": [240, 230, 140], + "lavender": [230, 230, 250], + "lavenderblush": [255, 240, 245], + "lawngreen": [124, 252, 0], + "lemonchiffon": [255, 250, 205], + "lightblue": [173, 216, 230], + "lightcoral": [240, 128, 128], + "lightcyan": [224, 255, 255], + "lightgoldenrodyellow": [250, 250, 210], + "lightgray": [211, 211, 211], + "lightgreen": [144, 238, 144], + "lightgrey": [211, 211, 211], + "lightpink": [255, 182, 193], + "lightsalmon": [255, 160, 122], + "lightseagreen": [32, 178, 170], + "lightskyblue": [135, 206, 250], + "lightslategray": [119, 136, 153], + "lightslategrey": [119, 136, 153], + "lightsteelblue": [176, 196, 222], + "lightyellow": [255, 255, 224], + "lime": [0, 255, 0], + "limegreen": [50, 205, 50], + "linen": [250, 240, 230], + "magenta": [255, 0, 255], + "maroon": [128, 0, 0], + "mediumaquamarine": [102, 205, 170], + "mediumblue": [0, 0, 205], + "mediumorchid": [186, 85, 211], + "mediumpurple": [147, 112, 219], + "mediumseagreen": [60, 179, 113], + "mediumslateblue": [123, 104, 238], + "mediumspringgreen": [0, 250, 154], + "mediumturquoise": [72, 209, 204], + "mediumvioletred": [199, 21, 133], + "midnightblue": [25, 25, 112], + "mintcream": [245, 255, 250], + "mistyrose": [255, 228, 225], + "moccasin": [255, 228, 181], + "navajowhite": [255, 222, 173], + "navy": [0, 0, 128], + "oldlace": [253, 245, 230], + "olive": [128, 128, 0], + "olivedrab": [107, 142, 35], + "orange": [255, 165, 0], + "orangered": [255, 69, 0], + "orchid": [218, 112, 214], + "palegoldenrod": [238, 232, 170], + "palegreen": [152, 251, 152], + "paleturquoise": [175, 238, 238], + "palevioletred": [219, 112, 147], + "papayawhip": [255, 239, 213], + "peachpuff": [255, 218, 185], + "peru": [205, 133, 63], + "pink": [255, 192, 203], + "plum": [221, 160, 221], + "powderblue": [176, 224, 230], + "purple": [128, 0, 128], + "rebeccapurple": [102, 51, 153], + "red": [255, 0, 0], + "rosybrown": [188, 143, 143], + "royalblue": [65, 105, 225], + "saddlebrown": [139, 69, 19], + "salmon": [250, 128, 114], + "sandybrown": [244, 164, 96], + "seagreen": [46, 139, 87], + "seashell": [255, 245, 238], + "sienna": [160, 82, 45], + "silver": [192, 192, 192], + "skyblue": [135, 206, 235], + "slateblue": [106, 90, 205], + "slategray": [112, 128, 144], + "slategrey": [112, 128, 144], + "snow": [255, 250, 250], + "springgreen": [0, 255, 127], + "steelblue": [70, 130, 180], + "tan": [210, 180, 140], + "teal": [0, 128, 128], + "thistle": [216, 191, 216], + "tomato": [255, 99, 71], + "turquoise": [64, 224, 208], + "violet": [238, 130, 238], + "wheat": [245, 222, 179], + "white": [255, 255, 255], + "whitesmoke": [245, 245, 245], + "yellow": [255, 255, 0], + "yellowgreen": [154, 205, 50] +}; + + +/***/ }), + +/***/ 5108: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +/*global window, global*/ +var util = __webpack_require__(9539) +var assert = __webpack_require__(9282) +function now() { return new Date().getTime() } + +var slice = Array.prototype.slice +var console +var times = {} + +if (typeof __webpack_require__.g !== "undefined" && __webpack_require__.g.console) { + console = __webpack_require__.g.console +} else if (typeof window !== "undefined" && window.console) { + console = window.console +} else { + console = {} +} + +var functions = [ + [log, "log"], + [info, "info"], + [warn, "warn"], + [error, "error"], + [time, "time"], + [timeEnd, "timeEnd"], + [trace, "trace"], + [dir, "dir"], + [consoleAssert, "assert"] +] + +for (var i = 0; i < functions.length; i++) { + var tuple = functions[i] + var f = tuple[0] + var name = tuple[1] + + if (!console[name]) { + console[name] = f + } +} + +module.exports = console + +function log() {} + +function info() { + console.log.apply(console, arguments) +} + +function warn() { + console.log.apply(console, arguments) +} + +function error() { + console.warn.apply(console, arguments) +} + +function time(label) { + times[label] = now() +} + +function timeEnd(label) { + var time = times[label] + if (!time) { + throw new Error("No such label: " + label) + } + + delete times[label] + var duration = now() - time + console.log(label + ": " + duration + "ms") +} + +function trace() { + var err = new Error() + err.name = "Trace" + err.message = util.format.apply(null, arguments) + console.error(err.stack) +} + +function dir(object) { + console.log(util.inspect(object) + "\n") +} + +function consoleAssert(expression) { + if (!expression) { + var arr = slice.call(arguments, 1) + assert.ok(false, util.format.apply(null, arr)) + } +} + + +/***/ }), + +/***/ 4289: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var keys = __webpack_require__(2215); +var hasSymbols = typeof Symbol === 'function' && typeof Symbol('foo') === 'symbol'; + +var toStr = Object.prototype.toString; +var concat = Array.prototype.concat; +var origDefineProperty = Object.defineProperty; + +var isFunction = function (fn) { + return typeof fn === 'function' && toStr.call(fn) === '[object Function]'; +}; + +var hasPropertyDescriptors = __webpack_require__(1044)(); + +var supportsDescriptors = origDefineProperty && hasPropertyDescriptors; + +var defineProperty = function (object, name, value, predicate) { + if (name in object && (!isFunction(predicate) || !predicate())) { + return; + } + if (supportsDescriptors) { + origDefineProperty(object, name, { + configurable: true, + enumerable: false, + value: value, + writable: true + }); + } else { + object[name] = value; // eslint-disable-line no-param-reassign + } +}; + +var defineProperties = function (object, map) { + var predicates = arguments.length > 2 ? arguments[2] : {}; + var props = keys(map); + if (hasSymbols) { + props = concat.call(props, Object.getOwnPropertySymbols(map)); + } + for (var i = 0; i < props.length; i += 1) { + defineProperty(object, props[i], map[props[i]], predicates[props[i]]); + } +}; + +defineProperties.supportsDescriptors = !!supportsDescriptors; + +module.exports = defineProperties; + + +/***/ }), + +/***/ 8091: +/***/ ((module) => { + +"use strict"; +/** + * Code refactored from Mozilla Developer Network: + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign + */ + + + +function assign(target, firstSource) { + if (target === undefined || target === null) { + throw new TypeError('Cannot convert first argument to object'); + } + + var to = Object(target); + for (var i = 1; i < arguments.length; i++) { + var nextSource = arguments[i]; + if (nextSource === undefined || nextSource === null) { + continue; + } + + var keysArray = Object.keys(Object(nextSource)); + for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) { + var nextKey = keysArray[nextIndex]; + var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); + if (desc !== undefined && desc.enumerable) { + to[nextKey] = nextSource[nextKey]; + } + } + } + return to; +} + +function polyfill() { + if (!Object.assign) { + Object.defineProperty(Object, 'assign', { + enumerable: false, + configurable: true, + writable: true, + value: assign + }); + } +} + +module.exports = { + assign: assign, + polyfill: polyfill +}; + + +/***/ }), + +/***/ 4029: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var isCallable = __webpack_require__(5320); + +var toStr = Object.prototype.toString; +var hasOwnProperty = Object.prototype.hasOwnProperty; + +var forEachArray = function forEachArray(array, iterator, receiver) { + for (var i = 0, len = array.length; i < len; i++) { + if (hasOwnProperty.call(array, i)) { + if (receiver == null) { + iterator(array[i], i, array); + } else { + iterator.call(receiver, array[i], i, array); + } + } + } +}; + +var forEachString = function forEachString(string, iterator, receiver) { + for (var i = 0, len = string.length; i < len; i++) { + // no such thing as a sparse string. + if (receiver == null) { + iterator(string.charAt(i), i, string); + } else { + iterator.call(receiver, string.charAt(i), i, string); + } + } +}; + +var forEachObject = function forEachObject(object, iterator, receiver) { + for (var k in object) { + if (hasOwnProperty.call(object, k)) { + if (receiver == null) { + iterator(object[k], k, object); + } else { + iterator.call(receiver, object[k], k, object); + } + } + } +}; + +var forEach = function forEach(list, iterator, thisArg) { + if (!isCallable(iterator)) { + throw new TypeError('iterator must be a function'); + } + + var receiver; + if (arguments.length >= 3) { + receiver = thisArg; + } + + if (toStr.call(list) === '[object Array]') { + forEachArray(list, iterator, receiver); + } else if (typeof list === 'string') { + forEachString(list, iterator, receiver); + } else { + forEachObject(list, iterator, receiver); + } +}; + +module.exports = forEach; + + +/***/ }), + +/***/ 7648: +/***/ ((module) => { + +"use strict"; + + +/* eslint no-invalid-this: 1 */ + +var ERROR_MESSAGE = 'Function.prototype.bind called on incompatible '; +var slice = Array.prototype.slice; +var toStr = Object.prototype.toString; +var funcType = '[object Function]'; + +module.exports = function bind(that) { + var target = this; + if (typeof target !== 'function' || toStr.call(target) !== funcType) { + throw new TypeError(ERROR_MESSAGE + target); + } + var args = slice.call(arguments, 1); + + var bound; + var binder = function () { + if (this instanceof bound) { + var result = target.apply( + this, + args.concat(slice.call(arguments)) + ); + if (Object(result) === result) { + return result; + } + return this; + } else { + return target.apply( + that, + args.concat(slice.call(arguments)) + ); + } + }; + + var boundLength = Math.max(0, target.length - args.length); + var boundArgs = []; + for (var i = 0; i < boundLength; i++) { + boundArgs.push('$' + i); + } + + bound = Function('binder', 'return function (' + boundArgs.join(',') + '){ return binder.apply(this,arguments); }')(binder); + + if (target.prototype) { + var Empty = function Empty() {}; + Empty.prototype = target.prototype; + bound.prototype = new Empty(); + Empty.prototype = null; + } + + return bound; +}; + + +/***/ }), + +/***/ 8612: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var implementation = __webpack_require__(7648); + +module.exports = Function.prototype.bind || implementation; + + +/***/ }), + +/***/ 210: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var undefined; + +var $SyntaxError = SyntaxError; +var $Function = Function; +var $TypeError = TypeError; + +// eslint-disable-next-line consistent-return +var getEvalledConstructor = function (expressionSyntax) { + try { + return $Function('"use strict"; return (' + expressionSyntax + ').constructor;')(); + } catch (e) {} +}; + +var $gOPD = Object.getOwnPropertyDescriptor; +if ($gOPD) { + try { + $gOPD({}, ''); + } catch (e) { + $gOPD = null; // this is IE 8, which has a broken gOPD + } +} + +var throwTypeError = function () { + throw new $TypeError(); +}; +var ThrowTypeError = $gOPD + ? (function () { + try { + // eslint-disable-next-line no-unused-expressions, no-caller, no-restricted-properties + arguments.callee; // IE 8 does not throw here + return throwTypeError; + } catch (calleeThrows) { + try { + // IE 8 throws on Object.getOwnPropertyDescriptor(arguments, '') + return $gOPD(arguments, 'callee').get; + } catch (gOPDthrows) { + return throwTypeError; + } + } + }()) + : throwTypeError; + +var hasSymbols = __webpack_require__(1405)(); + +var getProto = Object.getPrototypeOf || function (x) { return x.__proto__; }; // eslint-disable-line no-proto + +var needsEval = {}; + +var TypedArray = typeof Uint8Array === 'undefined' ? undefined : getProto(Uint8Array); + +var INTRINSICS = { + '%AggregateError%': typeof AggregateError === 'undefined' ? undefined : AggregateError, + '%Array%': Array, + '%ArrayBuffer%': typeof ArrayBuffer === 'undefined' ? undefined : ArrayBuffer, + '%ArrayIteratorPrototype%': hasSymbols ? getProto([][Symbol.iterator]()) : undefined, + '%AsyncFromSyncIteratorPrototype%': undefined, + '%AsyncFunction%': needsEval, + '%AsyncGenerator%': needsEval, + '%AsyncGeneratorFunction%': needsEval, + '%AsyncIteratorPrototype%': needsEval, + '%Atomics%': typeof Atomics === 'undefined' ? undefined : Atomics, + '%BigInt%': typeof BigInt === 'undefined' ? undefined : BigInt, + '%Boolean%': Boolean, + '%DataView%': typeof DataView === 'undefined' ? undefined : DataView, + '%Date%': Date, + '%decodeURI%': decodeURI, + '%decodeURIComponent%': decodeURIComponent, + '%encodeURI%': encodeURI, + '%encodeURIComponent%': encodeURIComponent, + '%Error%': Error, + '%eval%': eval, // eslint-disable-line no-eval + '%EvalError%': EvalError, + '%Float32Array%': typeof Float32Array === 'undefined' ? undefined : Float32Array, + '%Float64Array%': typeof Float64Array === 'undefined' ? undefined : Float64Array, + '%FinalizationRegistry%': typeof FinalizationRegistry === 'undefined' ? undefined : FinalizationRegistry, + '%Function%': $Function, + '%GeneratorFunction%': needsEval, + '%Int8Array%': typeof Int8Array === 'undefined' ? undefined : Int8Array, + '%Int16Array%': typeof Int16Array === 'undefined' ? undefined : Int16Array, + '%Int32Array%': typeof Int32Array === 'undefined' ? undefined : Int32Array, + '%isFinite%': isFinite, + '%isNaN%': isNaN, + '%IteratorPrototype%': hasSymbols ? getProto(getProto([][Symbol.iterator]())) : undefined, + '%JSON%': typeof JSON === 'object' ? JSON : undefined, + '%Map%': typeof Map === 'undefined' ? undefined : Map, + '%MapIteratorPrototype%': typeof Map === 'undefined' || !hasSymbols ? undefined : getProto(new Map()[Symbol.iterator]()), + '%Math%': Math, + '%Number%': Number, + '%Object%': Object, + '%parseFloat%': parseFloat, + '%parseInt%': parseInt, + '%Promise%': typeof Promise === 'undefined' ? undefined : Promise, + '%Proxy%': typeof Proxy === 'undefined' ? undefined : Proxy, + '%RangeError%': RangeError, + '%ReferenceError%': ReferenceError, + '%Reflect%': typeof Reflect === 'undefined' ? undefined : Reflect, + '%RegExp%': RegExp, + '%Set%': typeof Set === 'undefined' ? undefined : Set, + '%SetIteratorPrototype%': typeof Set === 'undefined' || !hasSymbols ? undefined : getProto(new Set()[Symbol.iterator]()), + '%SharedArrayBuffer%': typeof SharedArrayBuffer === 'undefined' ? undefined : SharedArrayBuffer, + '%String%': String, + '%StringIteratorPrototype%': hasSymbols ? getProto(''[Symbol.iterator]()) : undefined, + '%Symbol%': hasSymbols ? Symbol : undefined, + '%SyntaxError%': $SyntaxError, + '%ThrowTypeError%': ThrowTypeError, + '%TypedArray%': TypedArray, + '%TypeError%': $TypeError, + '%Uint8Array%': typeof Uint8Array === 'undefined' ? undefined : Uint8Array, + '%Uint8ClampedArray%': typeof Uint8ClampedArray === 'undefined' ? undefined : Uint8ClampedArray, + '%Uint16Array%': typeof Uint16Array === 'undefined' ? undefined : Uint16Array, + '%Uint32Array%': typeof Uint32Array === 'undefined' ? undefined : Uint32Array, + '%URIError%': URIError, + '%WeakMap%': typeof WeakMap === 'undefined' ? undefined : WeakMap, + '%WeakRef%': typeof WeakRef === 'undefined' ? undefined : WeakRef, + '%WeakSet%': typeof WeakSet === 'undefined' ? undefined : WeakSet +}; + +var doEval = function doEval(name) { + var value; + if (name === '%AsyncFunction%') { + value = getEvalledConstructor('async function () {}'); + } else if (name === '%GeneratorFunction%') { + value = getEvalledConstructor('function* () {}'); + } else if (name === '%AsyncGeneratorFunction%') { + value = getEvalledConstructor('async function* () {}'); + } else if (name === '%AsyncGenerator%') { + var fn = doEval('%AsyncGeneratorFunction%'); + if (fn) { + value = fn.prototype; + } + } else if (name === '%AsyncIteratorPrototype%') { + var gen = doEval('%AsyncGenerator%'); + if (gen) { + value = getProto(gen.prototype); + } + } + + INTRINSICS[name] = value; + + return value; +}; + +var LEGACY_ALIASES = { + '%ArrayBufferPrototype%': ['ArrayBuffer', 'prototype'], + '%ArrayPrototype%': ['Array', 'prototype'], + '%ArrayProto_entries%': ['Array', 'prototype', 'entries'], + '%ArrayProto_forEach%': ['Array', 'prototype', 'forEach'], + '%ArrayProto_keys%': ['Array', 'prototype', 'keys'], + '%ArrayProto_values%': ['Array', 'prototype', 'values'], + '%AsyncFunctionPrototype%': ['AsyncFunction', 'prototype'], + '%AsyncGenerator%': ['AsyncGeneratorFunction', 'prototype'], + '%AsyncGeneratorPrototype%': ['AsyncGeneratorFunction', 'prototype', 'prototype'], + '%BooleanPrototype%': ['Boolean', 'prototype'], + '%DataViewPrototype%': ['DataView', 'prototype'], + '%DatePrototype%': ['Date', 'prototype'], + '%ErrorPrototype%': ['Error', 'prototype'], + '%EvalErrorPrototype%': ['EvalError', 'prototype'], + '%Float32ArrayPrototype%': ['Float32Array', 'prototype'], + '%Float64ArrayPrototype%': ['Float64Array', 'prototype'], + '%FunctionPrototype%': ['Function', 'prototype'], + '%Generator%': ['GeneratorFunction', 'prototype'], + '%GeneratorPrototype%': ['GeneratorFunction', 'prototype', 'prototype'], + '%Int8ArrayPrototype%': ['Int8Array', 'prototype'], + '%Int16ArrayPrototype%': ['Int16Array', 'prototype'], + '%Int32ArrayPrototype%': ['Int32Array', 'prototype'], + '%JSONParse%': ['JSON', 'parse'], + '%JSONStringify%': ['JSON', 'stringify'], + '%MapPrototype%': ['Map', 'prototype'], + '%NumberPrototype%': ['Number', 'prototype'], + '%ObjectPrototype%': ['Object', 'prototype'], + '%ObjProto_toString%': ['Object', 'prototype', 'toString'], + '%ObjProto_valueOf%': ['Object', 'prototype', 'valueOf'], + '%PromisePrototype%': ['Promise', 'prototype'], + '%PromiseProto_then%': ['Promise', 'prototype', 'then'], + '%Promise_all%': ['Promise', 'all'], + '%Promise_reject%': ['Promise', 'reject'], + '%Promise_resolve%': ['Promise', 'resolve'], + '%RangeErrorPrototype%': ['RangeError', 'prototype'], + '%ReferenceErrorPrototype%': ['ReferenceError', 'prototype'], + '%RegExpPrototype%': ['RegExp', 'prototype'], + '%SetPrototype%': ['Set', 'prototype'], + '%SharedArrayBufferPrototype%': ['SharedArrayBuffer', 'prototype'], + '%StringPrototype%': ['String', 'prototype'], + '%SymbolPrototype%': ['Symbol', 'prototype'], + '%SyntaxErrorPrototype%': ['SyntaxError', 'prototype'], + '%TypedArrayPrototype%': ['TypedArray', 'prototype'], + '%TypeErrorPrototype%': ['TypeError', 'prototype'], + '%Uint8ArrayPrototype%': ['Uint8Array', 'prototype'], + '%Uint8ClampedArrayPrototype%': ['Uint8ClampedArray', 'prototype'], + '%Uint16ArrayPrototype%': ['Uint16Array', 'prototype'], + '%Uint32ArrayPrototype%': ['Uint32Array', 'prototype'], + '%URIErrorPrototype%': ['URIError', 'prototype'], + '%WeakMapPrototype%': ['WeakMap', 'prototype'], + '%WeakSetPrototype%': ['WeakSet', 'prototype'] +}; + +var bind = __webpack_require__(8612); +var hasOwn = __webpack_require__(7642); +var $concat = bind.call(Function.call, Array.prototype.concat); +var $spliceApply = bind.call(Function.apply, Array.prototype.splice); +var $replace = bind.call(Function.call, String.prototype.replace); +var $strSlice = bind.call(Function.call, String.prototype.slice); +var $exec = bind.call(Function.call, RegExp.prototype.exec); + +/* adapted from https://github.com/lodash/lodash/blob/4.17.15/dist/lodash.js#L6735-L6744 */ +var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g; +var reEscapeChar = /\\(\\)?/g; /** Used to match backslashes in property paths. */ +var stringToPath = function stringToPath(string) { + var first = $strSlice(string, 0, 1); + var last = $strSlice(string, -1); + if (first === '%' && last !== '%') { + throw new $SyntaxError('invalid intrinsic syntax, expected closing `%`'); + } else if (last === '%' && first !== '%') { + throw new $SyntaxError('invalid intrinsic syntax, expected opening `%`'); + } + var result = []; + $replace(string, rePropName, function (match, number, quote, subString) { + result[result.length] = quote ? $replace(subString, reEscapeChar, '$1') : number || match; + }); + return result; +}; +/* end adaptation */ + +var getBaseIntrinsic = function getBaseIntrinsic(name, allowMissing) { + var intrinsicName = name; + var alias; + if (hasOwn(LEGACY_ALIASES, intrinsicName)) { + alias = LEGACY_ALIASES[intrinsicName]; + intrinsicName = '%' + alias[0] + '%'; + } + + if (hasOwn(INTRINSICS, intrinsicName)) { + var value = INTRINSICS[intrinsicName]; + if (value === needsEval) { + value = doEval(intrinsicName); + } + if (typeof value === 'undefined' && !allowMissing) { + throw new $TypeError('intrinsic ' + name + ' exists, but is not available. Please file an issue!'); + } + + return { + alias: alias, + name: intrinsicName, + value: value + }; + } + + throw new $SyntaxError('intrinsic ' + name + ' does not exist!'); +}; + +module.exports = function GetIntrinsic(name, allowMissing) { + if (typeof name !== 'string' || name.length === 0) { + throw new $TypeError('intrinsic name must be a non-empty string'); + } + if (arguments.length > 1 && typeof allowMissing !== 'boolean') { + throw new $TypeError('"allowMissing" argument must be a boolean'); + } + + if ($exec(/^%?[^%]*%?$/, name) === null) { + throw new $SyntaxError('`%` may not be present anywhere but at the beginning and end of the intrinsic name'); + } + var parts = stringToPath(name); + var intrinsicBaseName = parts.length > 0 ? parts[0] : ''; + + var intrinsic = getBaseIntrinsic('%' + intrinsicBaseName + '%', allowMissing); + var intrinsicRealName = intrinsic.name; + var value = intrinsic.value; + var skipFurtherCaching = false; + + var alias = intrinsic.alias; + if (alias) { + intrinsicBaseName = alias[0]; + $spliceApply(parts, $concat([0, 1], alias)); + } + + for (var i = 1, isOwn = true; i < parts.length; i += 1) { + var part = parts[i]; + var first = $strSlice(part, 0, 1); + var last = $strSlice(part, -1); + if ( + ( + (first === '"' || first === "'" || first === '`') + || (last === '"' || last === "'" || last === '`') + ) + && first !== last + ) { + throw new $SyntaxError('property names with quotes must have matching quotes'); + } + if (part === 'constructor' || !isOwn) { + skipFurtherCaching = true; + } + + intrinsicBaseName += '.' + part; + intrinsicRealName = '%' + intrinsicBaseName + '%'; + + if (hasOwn(INTRINSICS, intrinsicRealName)) { + value = INTRINSICS[intrinsicRealName]; + } else if (value != null) { + if (!(part in value)) { + if (!allowMissing) { + throw new $TypeError('base intrinsic for ' + name + ' exists, but the property is not available.'); + } + return void undefined; + } + if ($gOPD && (i + 1) >= parts.length) { + var desc = $gOPD(value, part); + isOwn = !!desc; + + // By convention, when a data property is converted to an accessor + // property to emulate a data property that does not suffer from + // the override mistake, that accessor's getter is marked with + // an `originalValue` property. Here, when we detect this, we + // uphold the illusion by pretending to see that original data + // property, i.e., returning the value rather than the getter + // itself. + if (isOwn && 'get' in desc && !('originalValue' in desc.get)) { + value = desc.get; + } else { + value = value[part]; + } + } else { + isOwn = hasOwn(value, part); + value = value[part]; + } + + if (isOwn && !skipFurtherCaching) { + INTRINSICS[intrinsicRealName] = value; + } + } + } + return value; +}; + + +/***/ }), + +/***/ 7296: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var GetIntrinsic = __webpack_require__(210); + +var $gOPD = GetIntrinsic('%Object.getOwnPropertyDescriptor%', true); + +if ($gOPD) { + try { + $gOPD([], 'length'); + } catch (e) { + // IE 8 has a broken gOPD + $gOPD = null; + } +} + +module.exports = $gOPD; + + +/***/ }), + +/***/ 5822: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.GraphQLError = void 0; +exports.formatError = formatError; +exports.printError = printError; + +var _isObjectLike = __webpack_require__(5690); + +var _location = __webpack_require__(9016); + +var _printLocation = __webpack_require__(8038); + +function toNormalizedOptions(args) { + const firstArg = args[0]; + + if (firstArg == null || 'kind' in firstArg || 'length' in firstArg) { + return { + nodes: firstArg, + source: args[1], + positions: args[2], + path: args[3], + originalError: args[4], + extensions: args[5], + }; + } + + return firstArg; +} +/** + * A GraphQLError describes an Error found during the parse, validate, or + * execute phases of performing a GraphQL operation. In addition to a message + * and stack trace, it also includes information about the locations in a + * GraphQL document and/or execution result that correspond to the Error. + */ + +class GraphQLError extends Error { + /** + * An array of `{ line, column }` locations within the source GraphQL document + * which correspond to this error. + * + * Errors during validation often contain multiple locations, for example to + * point out two things with the same name. Errors during execution include a + * single location, the field which produced the error. + * + * Enumerable, and appears in the result of JSON.stringify(). + */ + + /** + * An array describing the JSON-path into the execution response which + * corresponds to this error. Only included for errors during execution. + * + * Enumerable, and appears in the result of JSON.stringify(). + */ + + /** + * An array of GraphQL AST Nodes corresponding to this error. + */ + + /** + * The source GraphQL document for the first location of this error. + * + * Note that if this Error represents more than one node, the source may not + * represent nodes after the first node. + */ + + /** + * An array of character offsets within the source GraphQL document + * which correspond to this error. + */ + + /** + * The original error thrown from a field resolver during execution. + */ + + /** + * Extension fields to add to the formatted error. + */ + + /** + * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead. + */ + constructor(message, ...rawArgs) { + var _this$nodes, _nodeLocations$, _ref; + + const { nodes, source, positions, path, originalError, extensions } = + toNormalizedOptions(rawArgs); + super(message); + this.name = 'GraphQLError'; + this.path = path !== null && path !== void 0 ? path : undefined; + this.originalError = + originalError !== null && originalError !== void 0 + ? originalError + : undefined; // Compute list of blame nodes. + + this.nodes = undefinedIfEmpty( + Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined, + ); + const nodeLocations = undefinedIfEmpty( + (_this$nodes = this.nodes) === null || _this$nodes === void 0 + ? void 0 + : _this$nodes.map((node) => node.loc).filter((loc) => loc != null), + ); // Compute locations in the source for the given nodes/positions. + + this.source = + source !== null && source !== void 0 + ? source + : nodeLocations === null || nodeLocations === void 0 + ? void 0 + : (_nodeLocations$ = nodeLocations[0]) === null || + _nodeLocations$ === void 0 + ? void 0 + : _nodeLocations$.source; + this.positions = + positions !== null && positions !== void 0 + ? positions + : nodeLocations === null || nodeLocations === void 0 + ? void 0 + : nodeLocations.map((loc) => loc.start); + this.locations = + positions && source + ? positions.map((pos) => (0, _location.getLocation)(source, pos)) + : nodeLocations === null || nodeLocations === void 0 + ? void 0 + : nodeLocations.map((loc) => + (0, _location.getLocation)(loc.source, loc.start), + ); + const originalExtensions = (0, _isObjectLike.isObjectLike)( + originalError === null || originalError === void 0 + ? void 0 + : originalError.extensions, + ) + ? originalError === null || originalError === void 0 + ? void 0 + : originalError.extensions + : undefined; + this.extensions = + (_ref = + extensions !== null && extensions !== void 0 + ? extensions + : originalExtensions) !== null && _ref !== void 0 + ? _ref + : Object.create(null); // Only properties prescribed by the spec should be enumerable. + // Keep the rest as non-enumerable. + + Object.defineProperties(this, { + message: { + writable: true, + enumerable: true, + }, + name: { + enumerable: false, + }, + nodes: { + enumerable: false, + }, + source: { + enumerable: false, + }, + positions: { + enumerable: false, + }, + originalError: { + enumerable: false, + }, + }); // Include (non-enumerable) stack trace. + + /* c8 ignore start */ + // FIXME: https://github.com/graphql/graphql-js/issues/2317 + + if ( + originalError !== null && + originalError !== void 0 && + originalError.stack + ) { + Object.defineProperty(this, 'stack', { + value: originalError.stack, + writable: true, + configurable: true, + }); + } else if (Error.captureStackTrace) { + Error.captureStackTrace(this, GraphQLError); + } else { + Object.defineProperty(this, 'stack', { + value: Error().stack, + writable: true, + configurable: true, + }); + } + /* c8 ignore stop */ + } + + get [Symbol.toStringTag]() { + return 'GraphQLError'; + } + + toString() { + let output = this.message; + + if (this.nodes) { + for (const node of this.nodes) { + if (node.loc) { + output += '\n\n' + (0, _printLocation.printLocation)(node.loc); + } + } + } else if (this.source && this.locations) { + for (const location of this.locations) { + output += + '\n\n' + + (0, _printLocation.printSourceLocation)(this.source, location); + } + } + + return output; + } + + toJSON() { + const formattedError = { + message: this.message, + }; + + if (this.locations != null) { + formattedError.locations = this.locations; + } + + if (this.path != null) { + formattedError.path = this.path; + } + + if (this.extensions != null && Object.keys(this.extensions).length > 0) { + formattedError.extensions = this.extensions; + } + + return formattedError; + } +} + +exports.GraphQLError = GraphQLError; + +function undefinedIfEmpty(array) { + return array === undefined || array.length === 0 ? undefined : array; +} +/** + * See: https://spec.graphql.org/draft/#sec-Errors + */ + +/** + * Prints a GraphQLError to a string, representing useful location information + * about the error's position in the source. + * + * @deprecated Please use `error.toString` instead. Will be removed in v17 + */ +function printError(error) { + return error.toString(); +} +/** + * Given a GraphQLError, format it according to the rules described by the + * Response Format, Errors section of the GraphQL Specification. + * + * @deprecated Please use `error.toJSON` instead. Will be removed in v17 + */ + +function formatError(error) { + return error.toJSON(); +} + + +/***/ }), + +/***/ 8950: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.collectFields = collectFields; +exports.collectSubfields = collectSubfields; + +var _kinds = __webpack_require__(2828); + +var _definition = __webpack_require__(5003); + +var _directives = __webpack_require__(7197); + +var _typeFromAST = __webpack_require__(5115); + +var _values = __webpack_require__(8840); + +/** + * Given a selectionSet, collects all of the fields and returns them. + * + * CollectFields requires the "runtime type" of an object. For a field that + * returns an Interface or Union type, the "runtime type" will be the actual + * object type returned by that field. + * + * @internal + */ +function collectFields( + schema, + fragments, + variableValues, + runtimeType, + selectionSet, +) { + const fields = new Map(); + collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + selectionSet, + fields, + new Set(), + ); + return fields; +} +/** + * Given an array of field nodes, collects all of the subfields of the passed + * in fields, and returns them at the end. + * + * CollectSubFields requires the "return type" of an object. For a field that + * returns an Interface or Union type, the "return type" will be the actual + * object type returned by that field. + * + * @internal + */ + +function collectSubfields( + schema, + fragments, + variableValues, + returnType, + fieldNodes, +) { + const subFieldNodes = new Map(); + const visitedFragmentNames = new Set(); + + for (const node of fieldNodes) { + if (node.selectionSet) { + collectFieldsImpl( + schema, + fragments, + variableValues, + returnType, + node.selectionSet, + subFieldNodes, + visitedFragmentNames, + ); + } + } + + return subFieldNodes; +} + +function collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + selectionSet, + fields, + visitedFragmentNames, +) { + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case _kinds.Kind.FIELD: { + if (!shouldIncludeNode(variableValues, selection)) { + continue; + } + + const name = getFieldEntryKey(selection); + const fieldList = fields.get(name); + + if (fieldList !== undefined) { + fieldList.push(selection); + } else { + fields.set(name, [selection]); + } + + break; + } + + case _kinds.Kind.INLINE_FRAGMENT: { + if ( + !shouldIncludeNode(variableValues, selection) || + !doesFragmentConditionMatch(schema, selection, runtimeType) + ) { + continue; + } + + collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + selection.selectionSet, + fields, + visitedFragmentNames, + ); + break; + } + + case _kinds.Kind.FRAGMENT_SPREAD: { + const fragName = selection.name.value; + + if ( + visitedFragmentNames.has(fragName) || + !shouldIncludeNode(variableValues, selection) + ) { + continue; + } + + visitedFragmentNames.add(fragName); + const fragment = fragments[fragName]; + + if ( + !fragment || + !doesFragmentConditionMatch(schema, fragment, runtimeType) + ) { + continue; + } + + collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + fragment.selectionSet, + fields, + visitedFragmentNames, + ); + break; + } + } + } +} +/** + * Determines if a field should be included based on the `@include` and `@skip` + * directives, where `@skip` has higher precedence than `@include`. + */ + +function shouldIncludeNode(variableValues, node) { + const skip = (0, _values.getDirectiveValues)( + _directives.GraphQLSkipDirective, + node, + variableValues, + ); + + if ((skip === null || skip === void 0 ? void 0 : skip.if) === true) { + return false; + } + + const include = (0, _values.getDirectiveValues)( + _directives.GraphQLIncludeDirective, + node, + variableValues, + ); + + if ( + (include === null || include === void 0 ? void 0 : include.if) === false + ) { + return false; + } + + return true; +} +/** + * Determines if a fragment is applicable to the given type. + */ + +function doesFragmentConditionMatch(schema, fragment, type) { + const typeConditionNode = fragment.typeCondition; + + if (!typeConditionNode) { + return true; + } + + const conditionalType = (0, _typeFromAST.typeFromAST)( + schema, + typeConditionNode, + ); + + if (conditionalType === type) { + return true; + } + + if ((0, _definition.isAbstractType)(conditionalType)) { + return schema.isSubType(conditionalType, type); + } + + return false; +} +/** + * Implements the logic to compute the key of a given field's entry + */ + +function getFieldEntryKey(node) { + return node.alias ? node.alias.value : node.name.value; +} + + +/***/ }), + +/***/ 8840: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.getArgumentValues = getArgumentValues; +exports.getDirectiveValues = getDirectiveValues; +exports.getVariableValues = getVariableValues; + +var _inspect = __webpack_require__(8002); + +var _keyMap = __webpack_require__(2863); + +var _printPathArray = __webpack_require__(737); + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _printer = __webpack_require__(3033); + +var _definition = __webpack_require__(5003); + +var _coerceInputValue = __webpack_require__(3679); + +var _typeFromAST = __webpack_require__(5115); + +var _valueFromAST = __webpack_require__(3770); + +/** + * Prepares an object map of variableValues of the correct type based on the + * provided variable definitions and arbitrary input. If the input cannot be + * parsed to match the variable definitions, a GraphQLError will be thrown. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +function getVariableValues(schema, varDefNodes, inputs, options) { + const errors = []; + const maxErrors = + options === null || options === void 0 ? void 0 : options.maxErrors; + + try { + const coerced = coerceVariableValues( + schema, + varDefNodes, + inputs, + (error) => { + if (maxErrors != null && errors.length >= maxErrors) { + throw new _GraphQLError.GraphQLError( + 'Too many errors processing variables, error limit reached. Execution aborted.', + ); + } + + errors.push(error); + }, + ); + + if (errors.length === 0) { + return { + coerced, + }; + } + } catch (error) { + errors.push(error); + } + + return { + errors, + }; +} + +function coerceVariableValues(schema, varDefNodes, inputs, onError) { + const coercedValues = {}; + + for (const varDefNode of varDefNodes) { + const varName = varDefNode.variable.name.value; + const varType = (0, _typeFromAST.typeFromAST)(schema, varDefNode.type); + + if (!(0, _definition.isInputType)(varType)) { + // Must use input types for variables. This should be caught during + // validation, however is checked again here for safety. + const varTypeStr = (0, _printer.print)(varDefNode.type); + onError( + new _GraphQLError.GraphQLError( + `Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, + { + nodes: varDefNode.type, + }, + ), + ); + continue; + } + + if (!hasOwnProperty(inputs, varName)) { + if (varDefNode.defaultValue) { + coercedValues[varName] = (0, _valueFromAST.valueFromAST)( + varDefNode.defaultValue, + varType, + ); + } else if ((0, _definition.isNonNullType)(varType)) { + const varTypeStr = (0, _inspect.inspect)(varType); + onError( + new _GraphQLError.GraphQLError( + `Variable "$${varName}" of required type "${varTypeStr}" was not provided.`, + { + nodes: varDefNode, + }, + ), + ); + } + + continue; + } + + const value = inputs[varName]; + + if (value === null && (0, _definition.isNonNullType)(varType)) { + const varTypeStr = (0, _inspect.inspect)(varType); + onError( + new _GraphQLError.GraphQLError( + `Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`, + { + nodes: varDefNode, + }, + ), + ); + continue; + } + + coercedValues[varName] = (0, _coerceInputValue.coerceInputValue)( + value, + varType, + (path, invalidValue, error) => { + let prefix = + `Variable "$${varName}" got invalid value ` + + (0, _inspect.inspect)(invalidValue); + + if (path.length > 0) { + prefix += ` at "${varName}${(0, _printPathArray.printPathArray)( + path, + )}"`; + } + + onError( + new _GraphQLError.GraphQLError(prefix + '; ' + error.message, { + nodes: varDefNode, + originalError: error.originalError, + }), + ); + }, + ); + } + + return coercedValues; +} +/** + * Prepares an object map of argument values given a list of argument + * definitions and list of argument AST nodes. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ + +function getArgumentValues(def, node, variableValues) { + var _node$arguments; + + const coercedValues = {}; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const argumentNodes = + (_node$arguments = node.arguments) !== null && _node$arguments !== void 0 + ? _node$arguments + : []; + const argNodeMap = (0, _keyMap.keyMap)( + argumentNodes, + (arg) => arg.name.value, + ); + + for (const argDef of def.args) { + const name = argDef.name; + const argType = argDef.type; + const argumentNode = argNodeMap[name]; + + if (!argumentNode) { + if (argDef.defaultValue !== undefined) { + coercedValues[name] = argDef.defaultValue; + } else if ((0, _definition.isNonNullType)(argType)) { + throw new _GraphQLError.GraphQLError( + `Argument "${name}" of required type "${(0, _inspect.inspect)( + argType, + )}" ` + 'was not provided.', + { + nodes: node, + }, + ); + } + + continue; + } + + const valueNode = argumentNode.value; + let isNull = valueNode.kind === _kinds.Kind.NULL; + + if (valueNode.kind === _kinds.Kind.VARIABLE) { + const variableName = valueNode.name.value; + + if ( + variableValues == null || + !hasOwnProperty(variableValues, variableName) + ) { + if (argDef.defaultValue !== undefined) { + coercedValues[name] = argDef.defaultValue; + } else if ((0, _definition.isNonNullType)(argType)) { + throw new _GraphQLError.GraphQLError( + `Argument "${name}" of required type "${(0, _inspect.inspect)( + argType, + )}" ` + + `was provided the variable "$${variableName}" which was not provided a runtime value.`, + { + nodes: valueNode, + }, + ); + } + + continue; + } + + isNull = variableValues[variableName] == null; + } + + if (isNull && (0, _definition.isNonNullType)(argType)) { + throw new _GraphQLError.GraphQLError( + `Argument "${name}" of non-null type "${(0, _inspect.inspect)( + argType, + )}" ` + 'must not be null.', + { + nodes: valueNode, + }, + ); + } + + const coercedValue = (0, _valueFromAST.valueFromAST)( + valueNode, + argType, + variableValues, + ); + + if (coercedValue === undefined) { + // Note: ValuesOfCorrectTypeRule validation should catch this before + // execution. This is a runtime check to ensure execution does not + // continue with an invalid argument value. + throw new _GraphQLError.GraphQLError( + `Argument "${name}" has invalid value ${(0, _printer.print)( + valueNode, + )}.`, + { + nodes: valueNode, + }, + ); + } + + coercedValues[name] = coercedValue; + } + + return coercedValues; +} +/** + * Prepares an object map of argument values given a directive definition + * and a AST node which may contain directives. Optionally also accepts a map + * of variable values. + * + * If the directive does not exist on the node, returns undefined. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ + +function getDirectiveValues(directiveDef, node, variableValues) { + var _node$directives; + + const directiveNode = + (_node$directives = node.directives) === null || _node$directives === void 0 + ? void 0 + : _node$directives.find( + (directive) => directive.name.value === directiveDef.name, + ); + + if (directiveNode) { + return getArgumentValues(directiveDef, directiveNode, variableValues); + } +} + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + + +/***/ }), + +/***/ 7059: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.addPath = addPath; +exports.pathToArray = pathToArray; + +/** + * Given a Path and a key, return a new Path containing the new key. + */ +function addPath(prev, key, typename) { + return { + prev, + key, + typename, + }; +} +/** + * Given a Path, return an Array of the path keys. + */ + +function pathToArray(path) { + const flattened = []; + let curr = path; + + while (curr) { + flattened.push(curr.key); + curr = curr.prev; + } + + return flattened.reverse(); +} + + +/***/ }), + +/***/ 7242: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.devAssert = devAssert; + +function devAssert(condition, message) { + const booleanCondition = Boolean(condition); + + if (!booleanCondition) { + throw new Error(message); + } +} + + +/***/ }), + +/***/ 100: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.didYouMean = didYouMean; +const MAX_SUGGESTIONS = 5; +/** + * Given [ A, B, C ] return ' Did you mean A, B, or C?'. + */ + +function didYouMean(firstArg, secondArg) { + const [subMessage, suggestionsArg] = secondArg + ? [firstArg, secondArg] + : [undefined, firstArg]; + let message = ' Did you mean '; + + if (subMessage) { + message += subMessage + ' '; + } + + const suggestions = suggestionsArg.map((x) => `"${x}"`); + + switch (suggestions.length) { + case 0: + return ''; + + case 1: + return message + suggestions[0] + '?'; + + case 2: + return message + suggestions[0] + ' or ' + suggestions[1] + '?'; + } + + const selected = suggestions.slice(0, MAX_SUGGESTIONS); + const lastItem = selected.pop(); + return message + selected.join(', ') + ', or ' + lastItem + '?'; +} + + +/***/ }), + +/***/ 4620: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.groupBy = groupBy; + +/** + * Groups array items into a Map, given a function to produce grouping key. + */ +function groupBy(list, keyFn) { + const result = new Map(); + + for (const item of list) { + const key = keyFn(item); + const group = result.get(key); + + if (group === undefined) { + result.set(key, [item]); + } else { + group.push(item); + } + } + + return result; +} + + +/***/ }), + +/***/ 3317: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.identityFunc = identityFunc; + +/** + * Returns the first argument it receives. + */ +function identityFunc(x) { + return x; +} + + +/***/ }), + +/***/ 8002: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.inspect = inspect; +const MAX_ARRAY_LENGTH = 10; +const MAX_RECURSIVE_DEPTH = 2; +/** + * Used to print values in error messages. + */ + +function inspect(value) { + return formatValue(value, []); +} + +function formatValue(value, seenValues) { + switch (typeof value) { + case 'string': + return JSON.stringify(value); + + case 'function': + return value.name ? `[function ${value.name}]` : '[function]'; + + case 'object': + return formatObjectValue(value, seenValues); + + default: + return String(value); + } +} + +function formatObjectValue(value, previouslySeenValues) { + if (value === null) { + return 'null'; + } + + if (previouslySeenValues.includes(value)) { + return '[Circular]'; + } + + const seenValues = [...previouslySeenValues, value]; + + if (isJSONable(value)) { + const jsonValue = value.toJSON(); // check for infinite recursion + + if (jsonValue !== value) { + return typeof jsonValue === 'string' + ? jsonValue + : formatValue(jsonValue, seenValues); + } + } else if (Array.isArray(value)) { + return formatArray(value, seenValues); + } + + return formatObject(value, seenValues); +} + +function isJSONable(value) { + return typeof value.toJSON === 'function'; +} + +function formatObject(object, seenValues) { + const entries = Object.entries(object); + + if (entries.length === 0) { + return '{}'; + } + + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[' + getObjectTag(object) + ']'; + } + + const properties = entries.map( + ([key, value]) => key + ': ' + formatValue(value, seenValues), + ); + return '{ ' + properties.join(', ') + ' }'; +} + +function formatArray(array, seenValues) { + if (array.length === 0) { + return '[]'; + } + + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[Array]'; + } + + const len = Math.min(MAX_ARRAY_LENGTH, array.length); + const remaining = array.length - len; + const items = []; + + for (let i = 0; i < len; ++i) { + items.push(formatValue(array[i], seenValues)); + } + + if (remaining === 1) { + items.push('... 1 more item'); + } else if (remaining > 1) { + items.push(`... ${remaining} more items`); + } + + return '[' + items.join(', ') + ']'; +} + +function getObjectTag(object) { + const tag = Object.prototype.toString + .call(object) + .replace(/^\[object /, '') + .replace(/]$/, ''); + + if (tag === 'Object' && typeof object.constructor === 'function') { + const name = object.constructor.name; + + if (typeof name === 'string' && name !== '') { + return name; + } + } + + return tag; +} + + +/***/ }), + +/***/ 5752: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.instanceOf = void 0; + +var _inspect = __webpack_require__(8002); + +/** + * A replacement for instanceof which includes an error warning when multi-realm + * constructors are detected. + * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production + * See: https://webpack.js.org/guides/production/ + */ +const instanceOf = + /* c8 ignore next 6 */ + // FIXME: https://github.com/graphql/graphql-js/issues/2317 + // eslint-disable-next-line no-undef + true + ? function instanceOf(value, constructor) { + return value instanceof constructor; + } + : 0; +exports.instanceOf = instanceOf; + + +/***/ }), + +/***/ 7706: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.invariant = invariant; + +function invariant(condition, message) { + const booleanCondition = Boolean(condition); + + if (!booleanCondition) { + throw new Error( + message != null ? message : 'Unexpected invariant triggered.', + ); + } +} + + +/***/ }), + +/***/ 6609: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.isIterableObject = isIterableObject; + +/** + * Returns true if the provided object is an Object (i.e. not a string literal) + * and implements the Iterator protocol. + * + * This may be used in place of [Array.isArray()][isArray] to determine if + * an object should be iterated-over e.g. Array, Map, Set, Int8Array, + * TypedArray, etc. but excludes string literals. + * + * @example + * ```ts + * isIterableObject([ 1, 2, 3 ]) // true + * isIterableObject(new Map()) // true + * isIterableObject('ABC') // false + * isIterableObject({ key: 'value' }) // false + * isIterableObject({ length: 1, 0: 'Alpha' }) // false + * ``` + */ +function isIterableObject(maybeIterable) { + return ( + typeof maybeIterable === 'object' && + typeof (maybeIterable === null || maybeIterable === void 0 + ? void 0 + : maybeIterable[Symbol.iterator]) === 'function' + ); +} + + +/***/ }), + +/***/ 5690: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.isObjectLike = isObjectLike; + +/** + * Return true if `value` is object-like. A value is object-like if it's not + * `null` and has a `typeof` result of "object". + */ +function isObjectLike(value) { + return typeof value == 'object' && value !== null; +} + + +/***/ }), + +/***/ 2863: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.keyMap = keyMap; + +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * for each value in the array. + * + * This provides a convenient lookup for the array items if the key function + * produces unique results. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * const entriesByName = keyMap( + * phoneBook, + * entry => entry.name + * ) + * + * // { + * // Jon: { name: 'Jon', num: '555-1234' }, + * // Jenny: { name: 'Jenny', num: '867-5309' } + * // } + * + * const jennyEntry = entriesByName['Jenny'] + * + * // { name: 'Jenny', num: '857-6309' } + * ``` + */ +function keyMap(list, keyFn) { + const result = Object.create(null); + + for (const item of list) { + result[keyFn(item)] = item; + } + + return result; +} + + +/***/ }), + +/***/ 7154: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.keyValMap = keyValMap; + +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * and a function to produce the values from each item in the array. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * // { Jon: '555-1234', Jenny: '867-5309' } + * const phonesByName = keyValMap( + * phoneBook, + * entry => entry.name, + * entry => entry.num + * ) + * ``` + */ +function keyValMap(list, keyFn, valFn) { + const result = Object.create(null); + + for (const item of list) { + result[keyFn(item)] = valFn(item); + } + + return result; +} + + +/***/ }), + +/***/ 6124: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.mapValue = mapValue; + +/** + * Creates an object map with the same keys as `map` and values generated by + * running each value of `map` thru `fn`. + */ +function mapValue(map, fn) { + const result = Object.create(null); + + for (const key of Object.keys(map)) { + result[key] = fn(map[key], key); + } + + return result; +} + + +/***/ }), + +/***/ 5250: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.naturalCompare = naturalCompare; + +/** + * Returns a number indicating whether a reference string comes before, or after, + * or is the same as the given string in natural sort order. + * + * See: https://en.wikipedia.org/wiki/Natural_sort_order + * + */ +function naturalCompare(aStr, bStr) { + let aIndex = 0; + let bIndex = 0; + + while (aIndex < aStr.length && bIndex < bStr.length) { + let aChar = aStr.charCodeAt(aIndex); + let bChar = bStr.charCodeAt(bIndex); + + if (isDigit(aChar) && isDigit(bChar)) { + let aNum = 0; + + do { + ++aIndex; + aNum = aNum * 10 + aChar - DIGIT_0; + aChar = aStr.charCodeAt(aIndex); + } while (isDigit(aChar) && aNum > 0); + + let bNum = 0; + + do { + ++bIndex; + bNum = bNum * 10 + bChar - DIGIT_0; + bChar = bStr.charCodeAt(bIndex); + } while (isDigit(bChar) && bNum > 0); + + if (aNum < bNum) { + return -1; + } + + if (aNum > bNum) { + return 1; + } + } else { + if (aChar < bChar) { + return -1; + } + + if (aChar > bChar) { + return 1; + } + + ++aIndex; + ++bIndex; + } + } + + return aStr.length - bStr.length; +} + +const DIGIT_0 = 48; +const DIGIT_9 = 57; + +function isDigit(code) { + return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9; +} + + +/***/ }), + +/***/ 737: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.printPathArray = printPathArray; + +/** + * Build a string describing the path. + */ +function printPathArray(path) { + return path + .map((key) => + typeof key === 'number' ? '[' + key.toString() + ']' : '.' + key, + ) + .join(''); +} + + +/***/ }), + +/***/ 8070: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.suggestionList = suggestionList; + +var _naturalCompare = __webpack_require__(5250); + +/** + * Given an invalid input string and a list of valid options, returns a filtered + * list of valid options sorted based on their similarity with the input. + */ +function suggestionList(input, options) { + const optionsByDistance = Object.create(null); + const lexicalDistance = new LexicalDistance(input); + const threshold = Math.floor(input.length * 0.4) + 1; + + for (const option of options) { + const distance = lexicalDistance.measure(option, threshold); + + if (distance !== undefined) { + optionsByDistance[option] = distance; + } + } + + return Object.keys(optionsByDistance).sort((a, b) => { + const distanceDiff = optionsByDistance[a] - optionsByDistance[b]; + return distanceDiff !== 0 + ? distanceDiff + : (0, _naturalCompare.naturalCompare)(a, b); + }); +} +/** + * Computes the lexical distance between strings A and B. + * + * The "distance" between two strings is given by counting the minimum number + * of edits needed to transform string A into string B. An edit can be an + * insertion, deletion, or substitution of a single character, or a swap of two + * adjacent characters. + * + * Includes a custom alteration from Damerau-Levenshtein to treat case changes + * as a single edit which helps identify mis-cased values with an edit distance + * of 1. + * + * This distance can be useful for detecting typos in input or sorting + */ + +class LexicalDistance { + constructor(input) { + this._input = input; + this._inputLowerCase = input.toLowerCase(); + this._inputArray = stringToArray(this._inputLowerCase); + this._rows = [ + new Array(input.length + 1).fill(0), + new Array(input.length + 1).fill(0), + new Array(input.length + 1).fill(0), + ]; + } + + measure(option, threshold) { + if (this._input === option) { + return 0; + } + + const optionLowerCase = option.toLowerCase(); // Any case change counts as a single edit + + if (this._inputLowerCase === optionLowerCase) { + return 1; + } + + let a = stringToArray(optionLowerCase); + let b = this._inputArray; + + if (a.length < b.length) { + const tmp = a; + a = b; + b = tmp; + } + + const aLength = a.length; + const bLength = b.length; + + if (aLength - bLength > threshold) { + return undefined; + } + + const rows = this._rows; + + for (let j = 0; j <= bLength; j++) { + rows[0][j] = j; + } + + for (let i = 1; i <= aLength; i++) { + const upRow = rows[(i - 1) % 3]; + const currentRow = rows[i % 3]; + let smallestCell = (currentRow[0] = i); + + for (let j = 1; j <= bLength; j++) { + const cost = a[i - 1] === b[j - 1] ? 0 : 1; + let currentCell = Math.min( + upRow[j] + 1, // delete + currentRow[j - 1] + 1, // insert + upRow[j - 1] + cost, // substitute + ); + + if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) { + // transposition + const doubleDiagonalCell = rows[(i - 2) % 3][j - 2]; + currentCell = Math.min(currentCell, doubleDiagonalCell + 1); + } + + if (currentCell < smallestCell) { + smallestCell = currentCell; + } + + currentRow[j] = currentCell; + } // Early exit, since distance can't go smaller than smallest element of the previous row. + + if (smallestCell > threshold) { + return undefined; + } + } + + const distance = rows[aLength % 3][bLength]; + return distance <= threshold ? distance : undefined; + } +} + +function stringToArray(str) { + const strLength = str.length; + const array = new Array(strLength); + + for (let i = 0; i < strLength; ++i) { + array[i] = str.charCodeAt(i); + } + + return array; +} + + +/***/ }), + +/***/ 7690: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.toObjMap = toObjMap; + +function toObjMap(obj) { + if (obj == null) { + return Object.create(null); + } + + if (Object.getPrototypeOf(obj) === null) { + return obj; + } + + const map = Object.create(null); + + for (const [key, value] of Object.entries(obj)) { + map[key] = value; + } + + return map; +} + + +/***/ }), + +/***/ 1807: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.Token = + exports.QueryDocumentKeys = + exports.OperationTypeNode = + exports.Location = + void 0; +exports.isNode = isNode; + +/** + * Contains a range of UTF-8 character offsets and token references that + * identify the region of the source from which the AST derived. + */ +class Location { + /** + * The character offset at which this Node begins. + */ + + /** + * The character offset at which this Node ends. + */ + + /** + * The Token at which this Node begins. + */ + + /** + * The Token at which this Node ends. + */ + + /** + * The Source document the AST represents. + */ + constructor(startToken, endToken, source) { + this.start = startToken.start; + this.end = endToken.end; + this.startToken = startToken; + this.endToken = endToken; + this.source = source; + } + + get [Symbol.toStringTag]() { + return 'Location'; + } + + toJSON() { + return { + start: this.start, + end: this.end, + }; + } +} +/** + * Represents a range of characters represented by a lexical token + * within a Source. + */ + +exports.Location = Location; + +class Token { + /** + * The kind of Token. + */ + + /** + * The character offset at which this Node begins. + */ + + /** + * The character offset at which this Node ends. + */ + + /** + * The 1-indexed line number on which this Token appears. + */ + + /** + * The 1-indexed column number at which this Token begins. + */ + + /** + * For non-punctuation tokens, represents the interpreted value of the token. + * + * Note: is undefined for punctuation tokens, but typed as string for + * convenience in the parser. + */ + + /** + * Tokens exist as nodes in a double-linked-list amongst all tokens + * including ignored tokens. is always the first node and + * the last. + */ + constructor(kind, start, end, line, column, value) { + this.kind = kind; + this.start = start; + this.end = end; + this.line = line; + this.column = column; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + + this.value = value; + this.prev = null; + this.next = null; + } + + get [Symbol.toStringTag]() { + return 'Token'; + } + + toJSON() { + return { + kind: this.kind, + value: this.value, + line: this.line, + column: this.column, + }; + } +} +/** + * The list of all possible AST node types. + */ + +exports.Token = Token; + +/** + * @internal + */ +const QueryDocumentKeys = { + Name: [], + Document: ['definitions'], + OperationDefinition: [ + 'name', + 'variableDefinitions', + 'directives', + 'selectionSet', + ], + VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'], + Variable: ['name'], + SelectionSet: ['selections'], + Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'], + Argument: ['name', 'value'], + FragmentSpread: ['name', 'directives'], + InlineFragment: ['typeCondition', 'directives', 'selectionSet'], + FragmentDefinition: [ + 'name', // Note: fragment variable definitions are deprecated and will removed in v17.0.0 + 'variableDefinitions', + 'typeCondition', + 'directives', + 'selectionSet', + ], + IntValue: [], + FloatValue: [], + StringValue: [], + BooleanValue: [], + NullValue: [], + EnumValue: [], + ListValue: ['values'], + ObjectValue: ['fields'], + ObjectField: ['name', 'value'], + Directive: ['name', 'arguments'], + NamedType: ['name'], + ListType: ['type'], + NonNullType: ['type'], + SchemaDefinition: ['description', 'directives', 'operationTypes'], + OperationTypeDefinition: ['type'], + ScalarTypeDefinition: ['description', 'name', 'directives'], + ObjectTypeDefinition: [ + 'description', + 'name', + 'interfaces', + 'directives', + 'fields', + ], + FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'], + InputValueDefinition: [ + 'description', + 'name', + 'type', + 'defaultValue', + 'directives', + ], + InterfaceTypeDefinition: [ + 'description', + 'name', + 'interfaces', + 'directives', + 'fields', + ], + UnionTypeDefinition: ['description', 'name', 'directives', 'types'], + EnumTypeDefinition: ['description', 'name', 'directives', 'values'], + EnumValueDefinition: ['description', 'name', 'directives'], + InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'], + DirectiveDefinition: ['description', 'name', 'arguments', 'locations'], + SchemaExtension: ['directives', 'operationTypes'], + ScalarTypeExtension: ['name', 'directives'], + ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + UnionTypeExtension: ['name', 'directives', 'types'], + EnumTypeExtension: ['name', 'directives', 'values'], + InputObjectTypeExtension: ['name', 'directives', 'fields'], +}; +exports.QueryDocumentKeys = QueryDocumentKeys; +const kindValues = new Set(Object.keys(QueryDocumentKeys)); +/** + * @internal + */ + +function isNode(maybeNode) { + const maybeKind = + maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.kind; + return typeof maybeKind === 'string' && kindValues.has(maybeKind); +} +/** Name */ + +var OperationTypeNode; +exports.OperationTypeNode = OperationTypeNode; + +(function (OperationTypeNode) { + OperationTypeNode['QUERY'] = 'query'; + OperationTypeNode['MUTATION'] = 'mutation'; + OperationTypeNode['SUBSCRIPTION'] = 'subscription'; +})(OperationTypeNode || (exports.OperationTypeNode = OperationTypeNode = {})); + + +/***/ }), + +/***/ 849: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.dedentBlockStringLines = dedentBlockStringLines; +exports.isPrintableAsBlockString = isPrintableAsBlockString; +exports.printBlockString = printBlockString; + +var _characterClasses = __webpack_require__(2591); + +/** + * Produces the value of a block string from its parsed raw value, similar to + * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc. + * + * This implements the GraphQL spec's BlockStringValue() static algorithm. + * + * @internal + */ +function dedentBlockStringLines(lines) { + var _firstNonEmptyLine2; + + let commonIndent = Number.MAX_SAFE_INTEGER; + let firstNonEmptyLine = null; + let lastNonEmptyLine = -1; + + for (let i = 0; i < lines.length; ++i) { + var _firstNonEmptyLine; + + const line = lines[i]; + const indent = leadingWhitespace(line); + + if (indent === line.length) { + continue; // skip empty lines + } + + firstNonEmptyLine = + (_firstNonEmptyLine = firstNonEmptyLine) !== null && + _firstNonEmptyLine !== void 0 + ? _firstNonEmptyLine + : i; + lastNonEmptyLine = i; + + if (i !== 0 && indent < commonIndent) { + commonIndent = indent; + } + } + + return lines // Remove common indentation from all lines but first. + .map((line, i) => (i === 0 ? line : line.slice(commonIndent))) // Remove leading and trailing blank lines. + .slice( + (_firstNonEmptyLine2 = firstNonEmptyLine) !== null && + _firstNonEmptyLine2 !== void 0 + ? _firstNonEmptyLine2 + : 0, + lastNonEmptyLine + 1, + ); +} + +function leadingWhitespace(str) { + let i = 0; + + while ( + i < str.length && + (0, _characterClasses.isWhiteSpace)(str.charCodeAt(i)) + ) { + ++i; + } + + return i; +} +/** + * @internal + */ + +function isPrintableAsBlockString(value) { + if (value === '') { + return true; // empty string is printable + } + + let isEmptyLine = true; + let hasIndent = false; + let hasCommonIndent = true; + let seenNonEmptyLine = false; + + for (let i = 0; i < value.length; ++i) { + switch (value.codePointAt(i)) { + case 0x0000: + case 0x0001: + case 0x0002: + case 0x0003: + case 0x0004: + case 0x0005: + case 0x0006: + case 0x0007: + case 0x0008: + case 0x000b: + case 0x000c: + case 0x000e: + case 0x000f: + return false; + // Has non-printable characters + + case 0x000d: + // \r + return false; + // Has \r or \r\n which will be replaced as \n + + case 10: + // \n + if (isEmptyLine && !seenNonEmptyLine) { + return false; // Has leading new line + } + + seenNonEmptyLine = true; + isEmptyLine = true; + hasIndent = false; + break; + + case 9: // \t + + case 32: + // + hasIndent || (hasIndent = isEmptyLine); + break; + + default: + hasCommonIndent && (hasCommonIndent = hasIndent); + isEmptyLine = false; + } + } + + if (isEmptyLine) { + return false; // Has trailing empty lines + } + + if (hasCommonIndent && seenNonEmptyLine) { + return false; // Has internal indent + } + + return true; +} +/** + * Print a block string in the indented block form by adding a leading and + * trailing blank line. However, if a block string starts with whitespace and is + * a single-line, adding a leading blank line would strip that whitespace. + * + * @internal + */ + +function printBlockString(value, options) { + const escapedValue = value.replace(/"""/g, '\\"""'); // Expand a block string's raw value into independent lines. + + const lines = escapedValue.split(/\r\n|[\n\r]/g); + const isSingleLine = lines.length === 1; // If common indentation is found we can fix some of those cases by adding leading new line + + const forceLeadingNewLine = + lines.length > 1 && + lines + .slice(1) + .every( + (line) => + line.length === 0 || + (0, _characterClasses.isWhiteSpace)(line.charCodeAt(0)), + ); // Trailing triple quotes just looks confusing but doesn't force trailing new line + + const hasTrailingTripleQuotes = escapedValue.endsWith('\\"""'); // Trailing quote (single or double) or slash forces trailing new line + + const hasTrailingQuote = value.endsWith('"') && !hasTrailingTripleQuotes; + const hasTrailingSlash = value.endsWith('\\'); + const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash; + const printAsMultipleLines = + !(options !== null && options !== void 0 && options.minimize) && // add leading and trailing new lines only if it improves readability + (!isSingleLine || + value.length > 70 || + forceTrailingNewline || + forceLeadingNewLine || + hasTrailingTripleQuotes); + let result = ''; // Format a multi-line block quote to account for leading space. + + const skipLeadingNewLine = + isSingleLine && (0, _characterClasses.isWhiteSpace)(value.charCodeAt(0)); + + if ((printAsMultipleLines && !skipLeadingNewLine) || forceLeadingNewLine) { + result += '\n'; + } + + result += escapedValue; + + if (printAsMultipleLines || forceTrailingNewline) { + result += '\n'; + } + + return '"""' + result + '"""'; +} + + +/***/ }), + +/***/ 2591: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.isDigit = isDigit; +exports.isLetter = isLetter; +exports.isNameContinue = isNameContinue; +exports.isNameStart = isNameStart; +exports.isWhiteSpace = isWhiteSpace; + +/** + * ``` + * WhiteSpace :: + * - "Horizontal Tab (U+0009)" + * - "Space (U+0020)" + * ``` + * @internal + */ +function isWhiteSpace(code) { + return code === 0x0009 || code === 0x0020; +} +/** + * ``` + * Digit :: one of + * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + * ``` + * @internal + */ + +function isDigit(code) { + return code >= 0x0030 && code <= 0x0039; +} +/** + * ``` + * Letter :: one of + * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M` + * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z` + * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m` + * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z` + * ``` + * @internal + */ + +function isLetter(code) { + return ( + (code >= 0x0061 && code <= 0x007a) || // A-Z + (code >= 0x0041 && code <= 0x005a) // a-z + ); +} +/** + * ``` + * NameStart :: + * - Letter + * - `_` + * ``` + * @internal + */ + +function isNameStart(code) { + return isLetter(code) || code === 0x005f; +} +/** + * ``` + * NameContinue :: + * - Letter + * - Digit + * - `_` + * ``` + * @internal + */ + +function isNameContinue(code) { + return isLetter(code) || isDigit(code) || code === 0x005f; +} + + +/***/ }), + +/***/ 8333: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.DirectiveLocation = void 0; + +/** + * The set of allowed directive location values. + */ +var DirectiveLocation; +exports.DirectiveLocation = DirectiveLocation; + +(function (DirectiveLocation) { + DirectiveLocation['QUERY'] = 'QUERY'; + DirectiveLocation['MUTATION'] = 'MUTATION'; + DirectiveLocation['SUBSCRIPTION'] = 'SUBSCRIPTION'; + DirectiveLocation['FIELD'] = 'FIELD'; + DirectiveLocation['FRAGMENT_DEFINITION'] = 'FRAGMENT_DEFINITION'; + DirectiveLocation['FRAGMENT_SPREAD'] = 'FRAGMENT_SPREAD'; + DirectiveLocation['INLINE_FRAGMENT'] = 'INLINE_FRAGMENT'; + DirectiveLocation['VARIABLE_DEFINITION'] = 'VARIABLE_DEFINITION'; + DirectiveLocation['SCHEMA'] = 'SCHEMA'; + DirectiveLocation['SCALAR'] = 'SCALAR'; + DirectiveLocation['OBJECT'] = 'OBJECT'; + DirectiveLocation['FIELD_DEFINITION'] = 'FIELD_DEFINITION'; + DirectiveLocation['ARGUMENT_DEFINITION'] = 'ARGUMENT_DEFINITION'; + DirectiveLocation['INTERFACE'] = 'INTERFACE'; + DirectiveLocation['UNION'] = 'UNION'; + DirectiveLocation['ENUM'] = 'ENUM'; + DirectiveLocation['ENUM_VALUE'] = 'ENUM_VALUE'; + DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT'; + DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION'; +})(DirectiveLocation || (exports.DirectiveLocation = DirectiveLocation = {})); +/** + * The enum type representing the directive location values. + * + * @deprecated Please use `DirectiveLocation`. Will be remove in v17. + */ + + +/***/ }), + +/***/ 2828: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.Kind = void 0; + +/** + * The set of allowed kind values for AST nodes. + */ +var Kind; +exports.Kind = Kind; + +(function (Kind) { + Kind['NAME'] = 'Name'; + Kind['DOCUMENT'] = 'Document'; + Kind['OPERATION_DEFINITION'] = 'OperationDefinition'; + Kind['VARIABLE_DEFINITION'] = 'VariableDefinition'; + Kind['SELECTION_SET'] = 'SelectionSet'; + Kind['FIELD'] = 'Field'; + Kind['ARGUMENT'] = 'Argument'; + Kind['FRAGMENT_SPREAD'] = 'FragmentSpread'; + Kind['INLINE_FRAGMENT'] = 'InlineFragment'; + Kind['FRAGMENT_DEFINITION'] = 'FragmentDefinition'; + Kind['VARIABLE'] = 'Variable'; + Kind['INT'] = 'IntValue'; + Kind['FLOAT'] = 'FloatValue'; + Kind['STRING'] = 'StringValue'; + Kind['BOOLEAN'] = 'BooleanValue'; + Kind['NULL'] = 'NullValue'; + Kind['ENUM'] = 'EnumValue'; + Kind['LIST'] = 'ListValue'; + Kind['OBJECT'] = 'ObjectValue'; + Kind['OBJECT_FIELD'] = 'ObjectField'; + Kind['DIRECTIVE'] = 'Directive'; + Kind['NAMED_TYPE'] = 'NamedType'; + Kind['LIST_TYPE'] = 'ListType'; + Kind['NON_NULL_TYPE'] = 'NonNullType'; + Kind['SCHEMA_DEFINITION'] = 'SchemaDefinition'; + Kind['OPERATION_TYPE_DEFINITION'] = 'OperationTypeDefinition'; + Kind['SCALAR_TYPE_DEFINITION'] = 'ScalarTypeDefinition'; + Kind['OBJECT_TYPE_DEFINITION'] = 'ObjectTypeDefinition'; + Kind['FIELD_DEFINITION'] = 'FieldDefinition'; + Kind['INPUT_VALUE_DEFINITION'] = 'InputValueDefinition'; + Kind['INTERFACE_TYPE_DEFINITION'] = 'InterfaceTypeDefinition'; + Kind['UNION_TYPE_DEFINITION'] = 'UnionTypeDefinition'; + Kind['ENUM_TYPE_DEFINITION'] = 'EnumTypeDefinition'; + Kind['ENUM_VALUE_DEFINITION'] = 'EnumValueDefinition'; + Kind['INPUT_OBJECT_TYPE_DEFINITION'] = 'InputObjectTypeDefinition'; + Kind['DIRECTIVE_DEFINITION'] = 'DirectiveDefinition'; + Kind['SCHEMA_EXTENSION'] = 'SchemaExtension'; + Kind['SCALAR_TYPE_EXTENSION'] = 'ScalarTypeExtension'; + Kind['OBJECT_TYPE_EXTENSION'] = 'ObjectTypeExtension'; + Kind['INTERFACE_TYPE_EXTENSION'] = 'InterfaceTypeExtension'; + Kind['UNION_TYPE_EXTENSION'] = 'UnionTypeExtension'; + Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension'; + Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension'; +})(Kind || (exports.Kind = Kind = {})); +/** + * The enum type representing the possible kind values of AST nodes. + * + * @deprecated Please use `Kind`. Will be remove in v17. + */ + + +/***/ }), + +/***/ 9016: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.getLocation = getLocation; + +var _invariant = __webpack_require__(7706); + +const LineRegExp = /\r\n|[\n\r]/g; +/** + * Represents a location in a Source. + */ + +/** + * Takes a Source and a UTF-8 character offset, and returns the corresponding + * line and column as a SourceLocation. + */ +function getLocation(source, position) { + let lastLineStart = 0; + let line = 1; + + for (const match of source.body.matchAll(LineRegExp)) { + typeof match.index === 'number' || (0, _invariant.invariant)(false); + + if (match.index >= position) { + break; + } + + lastLineStart = match.index + match[0].length; + line += 1; + } + + return { + line, + column: position + 1 - lastLineStart, + }; +} + + +/***/ }), + +/***/ 1352: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.isConstValueNode = isConstValueNode; +exports.isDefinitionNode = isDefinitionNode; +exports.isExecutableDefinitionNode = isExecutableDefinitionNode; +exports.isSelectionNode = isSelectionNode; +exports.isTypeDefinitionNode = isTypeDefinitionNode; +exports.isTypeExtensionNode = isTypeExtensionNode; +exports.isTypeNode = isTypeNode; +exports.isTypeSystemDefinitionNode = isTypeSystemDefinitionNode; +exports.isTypeSystemExtensionNode = isTypeSystemExtensionNode; +exports.isValueNode = isValueNode; + +var _kinds = __webpack_require__(2828); + +function isDefinitionNode(node) { + return ( + isExecutableDefinitionNode(node) || + isTypeSystemDefinitionNode(node) || + isTypeSystemExtensionNode(node) + ); +} + +function isExecutableDefinitionNode(node) { + return ( + node.kind === _kinds.Kind.OPERATION_DEFINITION || + node.kind === _kinds.Kind.FRAGMENT_DEFINITION + ); +} + +function isSelectionNode(node) { + return ( + node.kind === _kinds.Kind.FIELD || + node.kind === _kinds.Kind.FRAGMENT_SPREAD || + node.kind === _kinds.Kind.INLINE_FRAGMENT + ); +} + +function isValueNode(node) { + return ( + node.kind === _kinds.Kind.VARIABLE || + node.kind === _kinds.Kind.INT || + node.kind === _kinds.Kind.FLOAT || + node.kind === _kinds.Kind.STRING || + node.kind === _kinds.Kind.BOOLEAN || + node.kind === _kinds.Kind.NULL || + node.kind === _kinds.Kind.ENUM || + node.kind === _kinds.Kind.LIST || + node.kind === _kinds.Kind.OBJECT + ); +} + +function isConstValueNode(node) { + return ( + isValueNode(node) && + (node.kind === _kinds.Kind.LIST + ? node.values.some(isConstValueNode) + : node.kind === _kinds.Kind.OBJECT + ? node.fields.some((field) => isConstValueNode(field.value)) + : node.kind !== _kinds.Kind.VARIABLE) + ); +} + +function isTypeNode(node) { + return ( + node.kind === _kinds.Kind.NAMED_TYPE || + node.kind === _kinds.Kind.LIST_TYPE || + node.kind === _kinds.Kind.NON_NULL_TYPE + ); +} + +function isTypeSystemDefinitionNode(node) { + return ( + node.kind === _kinds.Kind.SCHEMA_DEFINITION || + isTypeDefinitionNode(node) || + node.kind === _kinds.Kind.DIRECTIVE_DEFINITION + ); +} + +function isTypeDefinitionNode(node) { + return ( + node.kind === _kinds.Kind.SCALAR_TYPE_DEFINITION || + node.kind === _kinds.Kind.OBJECT_TYPE_DEFINITION || + node.kind === _kinds.Kind.INTERFACE_TYPE_DEFINITION || + node.kind === _kinds.Kind.UNION_TYPE_DEFINITION || + node.kind === _kinds.Kind.ENUM_TYPE_DEFINITION || + node.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION + ); +} + +function isTypeSystemExtensionNode(node) { + return ( + node.kind === _kinds.Kind.SCHEMA_EXTENSION || isTypeExtensionNode(node) + ); +} + +function isTypeExtensionNode(node) { + return ( + node.kind === _kinds.Kind.SCALAR_TYPE_EXTENSION || + node.kind === _kinds.Kind.OBJECT_TYPE_EXTENSION || + node.kind === _kinds.Kind.INTERFACE_TYPE_EXTENSION || + node.kind === _kinds.Kind.UNION_TYPE_EXTENSION || + node.kind === _kinds.Kind.ENUM_TYPE_EXTENSION || + node.kind === _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION + ); +} + + +/***/ }), + +/***/ 8038: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.printLocation = printLocation; +exports.printSourceLocation = printSourceLocation; + +var _location = __webpack_require__(9016); + +/** + * Render a helpful description of the location in the GraphQL Source document. + */ +function printLocation(location) { + return printSourceLocation( + location.source, + (0, _location.getLocation)(location.source, location.start), + ); +} +/** + * Render a helpful description of the location in the GraphQL Source document. + */ + +function printSourceLocation(source, sourceLocation) { + const firstLineColumnOffset = source.locationOffset.column - 1; + const body = ''.padStart(firstLineColumnOffset) + source.body; + const lineIndex = sourceLocation.line - 1; + const lineOffset = source.locationOffset.line - 1; + const lineNum = sourceLocation.line + lineOffset; + const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0; + const columnNum = sourceLocation.column + columnOffset; + const locationStr = `${source.name}:${lineNum}:${columnNum}\n`; + const lines = body.split(/\r\n|[\n\r]/g); + const locationLine = lines[lineIndex]; // Special case for minified documents + + if (locationLine.length > 120) { + const subLineIndex = Math.floor(columnNum / 80); + const subLineColumnNum = columnNum % 80; + const subLines = []; + + for (let i = 0; i < locationLine.length; i += 80) { + subLines.push(locationLine.slice(i, i + 80)); + } + + return ( + locationStr + + printPrefixedLines([ + [`${lineNum} |`, subLines[0]], + ...subLines.slice(1, subLineIndex + 1).map((subLine) => ['|', subLine]), + ['|', '^'.padStart(subLineColumnNum)], + ['|', subLines[subLineIndex + 1]], + ]) + ); + } + + return ( + locationStr + + printPrefixedLines([ + // Lines specified like this: ["prefix", "string"], + [`${lineNum - 1} |`, lines[lineIndex - 1]], + [`${lineNum} |`, locationLine], + ['|', '^'.padStart(columnNum)], + [`${lineNum + 1} |`, lines[lineIndex + 1]], + ]) + ); +} + +function printPrefixedLines(lines) { + const existingLines = lines.filter(([_, line]) => line !== undefined); + const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length)); + return existingLines + .map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : '')) + .join('\n'); +} + + +/***/ }), + +/***/ 8942: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.printString = printString; + +/** + * Prints a string as a GraphQL StringValue literal. Replaces control characters + * and excluded characters (" U+0022 and \\ U+005C) with escape sequences. + */ +function printString(str) { + return `"${str.replace(escapedRegExp, escapedReplacer)}"`; +} // eslint-disable-next-line no-control-regex + +const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g; + +function escapedReplacer(str) { + return escapeSequences[str.charCodeAt(0)]; +} // prettier-ignore + +const escapeSequences = [ + '\\u0000', + '\\u0001', + '\\u0002', + '\\u0003', + '\\u0004', + '\\u0005', + '\\u0006', + '\\u0007', + '\\b', + '\\t', + '\\n', + '\\u000B', + '\\f', + '\\r', + '\\u000E', + '\\u000F', + '\\u0010', + '\\u0011', + '\\u0012', + '\\u0013', + '\\u0014', + '\\u0015', + '\\u0016', + '\\u0017', + '\\u0018', + '\\u0019', + '\\u001A', + '\\u001B', + '\\u001C', + '\\u001D', + '\\u001E', + '\\u001F', + '', + '', + '\\"', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 2F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 3F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 4F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '\\\\', + '', + '', + '', // 5F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 6F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '\\u007F', + '\\u0080', + '\\u0081', + '\\u0082', + '\\u0083', + '\\u0084', + '\\u0085', + '\\u0086', + '\\u0087', + '\\u0088', + '\\u0089', + '\\u008A', + '\\u008B', + '\\u008C', + '\\u008D', + '\\u008E', + '\\u008F', + '\\u0090', + '\\u0091', + '\\u0092', + '\\u0093', + '\\u0094', + '\\u0095', + '\\u0096', + '\\u0097', + '\\u0098', + '\\u0099', + '\\u009A', + '\\u009B', + '\\u009C', + '\\u009D', + '\\u009E', + '\\u009F', +]; + + +/***/ }), + +/***/ 3033: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.print = print; + +var _blockString = __webpack_require__(849); + +var _printString = __webpack_require__(8942); + +var _visitor = __webpack_require__(285); + +/** + * Converts an AST into a string, using one set of reasonable + * formatting rules. + */ +function print(ast) { + return (0, _visitor.visit)(ast, printDocASTReducer); +} + +const MAX_LINE_LENGTH = 80; +const printDocASTReducer = { + Name: { + leave: (node) => node.value, + }, + Variable: { + leave: (node) => '$' + node.name, + }, + // Document + Document: { + leave: (node) => join(node.definitions, '\n\n'), + }, + OperationDefinition: { + leave(node) { + const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')'); + const prefix = join( + [ + node.operation, + join([node.name, varDefs]), + join(node.directives, ' '), + ], + ' ', + ); // Anonymous queries with no directives or variable definitions can use + // the query short form. + + return (prefix === 'query' ? '' : prefix + ' ') + node.selectionSet; + }, + }, + VariableDefinition: { + leave: ({ variable, type, defaultValue, directives }) => + variable + + ': ' + + type + + wrap(' = ', defaultValue) + + wrap(' ', join(directives, ' ')), + }, + SelectionSet: { + leave: ({ selections }) => block(selections), + }, + Field: { + leave({ alias, name, arguments: args, directives, selectionSet }) { + const prefix = wrap('', alias, ': ') + name; + let argsLine = prefix + wrap('(', join(args, ', '), ')'); + + if (argsLine.length > MAX_LINE_LENGTH) { + argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)'); + } + + return join([argsLine, join(directives, ' '), selectionSet], ' '); + }, + }, + Argument: { + leave: ({ name, value }) => name + ': ' + value, + }, + // Fragments + FragmentSpread: { + leave: ({ name, directives }) => + '...' + name + wrap(' ', join(directives, ' ')), + }, + InlineFragment: { + leave: ({ typeCondition, directives, selectionSet }) => + join( + [ + '...', + wrap('on ', typeCondition), + join(directives, ' '), + selectionSet, + ], + ' ', + ), + }, + FragmentDefinition: { + leave: ( + { name, typeCondition, variableDefinitions, directives, selectionSet }, // Note: fragment variable definitions are experimental and may be changed + ) => + // or removed in the future. + `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` + + `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` + + selectionSet, + }, + // Value + IntValue: { + leave: ({ value }) => value, + }, + FloatValue: { + leave: ({ value }) => value, + }, + StringValue: { + leave: ({ value, block: isBlockString }) => + isBlockString + ? (0, _blockString.printBlockString)(value) + : (0, _printString.printString)(value), + }, + BooleanValue: { + leave: ({ value }) => (value ? 'true' : 'false'), + }, + NullValue: { + leave: () => 'null', + }, + EnumValue: { + leave: ({ value }) => value, + }, + ListValue: { + leave: ({ values }) => '[' + join(values, ', ') + ']', + }, + ObjectValue: { + leave: ({ fields }) => '{' + join(fields, ', ') + '}', + }, + ObjectField: { + leave: ({ name, value }) => name + ': ' + value, + }, + // Directive + Directive: { + leave: ({ name, arguments: args }) => + '@' + name + wrap('(', join(args, ', '), ')'), + }, + // Type + NamedType: { + leave: ({ name }) => name, + }, + ListType: { + leave: ({ type }) => '[' + type + ']', + }, + NonNullType: { + leave: ({ type }) => type + '!', + }, + // Type System Definitions + SchemaDefinition: { + leave: ({ description, directives, operationTypes }) => + wrap('', description, '\n') + + join(['schema', join(directives, ' '), block(operationTypes)], ' '), + }, + OperationTypeDefinition: { + leave: ({ operation, type }) => operation + ': ' + type, + }, + ScalarTypeDefinition: { + leave: ({ description, name, directives }) => + wrap('', description, '\n') + + join(['scalar', name, join(directives, ' ')], ' '), + }, + ObjectTypeDefinition: { + leave: ({ description, name, interfaces, directives, fields }) => + wrap('', description, '\n') + + join( + [ + 'type', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + FieldDefinition: { + leave: ({ description, name, arguments: args, type, directives }) => + wrap('', description, '\n') + + name + + (hasMultilineItems(args) + ? wrap('(\n', indent(join(args, '\n')), '\n)') + : wrap('(', join(args, ', '), ')')) + + ': ' + + type + + wrap(' ', join(directives, ' ')), + }, + InputValueDefinition: { + leave: ({ description, name, type, defaultValue, directives }) => + wrap('', description, '\n') + + join( + [name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], + ' ', + ), + }, + InterfaceTypeDefinition: { + leave: ({ description, name, interfaces, directives, fields }) => + wrap('', description, '\n') + + join( + [ + 'interface', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + UnionTypeDefinition: { + leave: ({ description, name, directives, types }) => + wrap('', description, '\n') + + join( + ['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], + ' ', + ), + }, + EnumTypeDefinition: { + leave: ({ description, name, directives, values }) => + wrap('', description, '\n') + + join(['enum', name, join(directives, ' '), block(values)], ' '), + }, + EnumValueDefinition: { + leave: ({ description, name, directives }) => + wrap('', description, '\n') + join([name, join(directives, ' ')], ' '), + }, + InputObjectTypeDefinition: { + leave: ({ description, name, directives, fields }) => + wrap('', description, '\n') + + join(['input', name, join(directives, ' '), block(fields)], ' '), + }, + DirectiveDefinition: { + leave: ({ description, name, arguments: args, repeatable, locations }) => + wrap('', description, '\n') + + 'directive @' + + name + + (hasMultilineItems(args) + ? wrap('(\n', indent(join(args, '\n')), '\n)') + : wrap('(', join(args, ', '), ')')) + + (repeatable ? ' repeatable' : '') + + ' on ' + + join(locations, ' | '), + }, + SchemaExtension: { + leave: ({ directives, operationTypes }) => + join( + ['extend schema', join(directives, ' '), block(operationTypes)], + ' ', + ), + }, + ScalarTypeExtension: { + leave: ({ name, directives }) => + join(['extend scalar', name, join(directives, ' ')], ' '), + }, + ObjectTypeExtension: { + leave: ({ name, interfaces, directives, fields }) => + join( + [ + 'extend type', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + InterfaceTypeExtension: { + leave: ({ name, interfaces, directives, fields }) => + join( + [ + 'extend interface', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + UnionTypeExtension: { + leave: ({ name, directives, types }) => + join( + [ + 'extend union', + name, + join(directives, ' '), + wrap('= ', join(types, ' | ')), + ], + ' ', + ), + }, + EnumTypeExtension: { + leave: ({ name, directives, values }) => + join(['extend enum', name, join(directives, ' '), block(values)], ' '), + }, + InputObjectTypeExtension: { + leave: ({ name, directives, fields }) => + join(['extend input', name, join(directives, ' '), block(fields)], ' '), + }, +}; +/** + * Given maybeArray, print an empty string if it is null or empty, otherwise + * print all items together separated by separator if provided + */ + +function join(maybeArray, separator = '') { + var _maybeArray$filter$jo; + + return (_maybeArray$filter$jo = + maybeArray === null || maybeArray === void 0 + ? void 0 + : maybeArray.filter((x) => x).join(separator)) !== null && + _maybeArray$filter$jo !== void 0 + ? _maybeArray$filter$jo + : ''; +} +/** + * Given array, print each item on its own line, wrapped in an indented `{ }` block. + */ + +function block(array) { + return wrap('{\n', indent(join(array, '\n')), '\n}'); +} +/** + * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string. + */ + +function wrap(start, maybeString, end = '') { + return maybeString != null && maybeString !== '' + ? start + maybeString + end + : ''; +} + +function indent(str) { + return wrap(' ', str.replace(/\n/g, '\n ')); +} + +function hasMultilineItems(maybeArray) { + var _maybeArray$some; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + return (_maybeArray$some = + maybeArray === null || maybeArray === void 0 + ? void 0 + : maybeArray.some((str) => str.includes('\n'))) !== null && + _maybeArray$some !== void 0 + ? _maybeArray$some + : false; +} + + +/***/ }), + +/***/ 285: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.BREAK = void 0; +exports.getEnterLeaveForKind = getEnterLeaveForKind; +exports.getVisitFn = getVisitFn; +exports.visit = visit; +exports.visitInParallel = visitInParallel; + +var _devAssert = __webpack_require__(7242); + +var _inspect = __webpack_require__(8002); + +var _ast = __webpack_require__(1807); + +var _kinds = __webpack_require__(2828); + +const BREAK = Object.freeze({}); +/** + * visit() will walk through an AST using a depth-first traversal, calling + * the visitor's enter function at each node in the traversal, and calling the + * leave function after visiting that node and all of its child nodes. + * + * By returning different values from the enter and leave functions, the + * behavior of the visitor can be altered, including skipping over a sub-tree of + * the AST (by returning false), editing the AST by returning a value or null + * to remove the value, or to stop the whole traversal by returning BREAK. + * + * When using visit() to edit an AST, the original AST will not be modified, and + * a new version of the AST with the changes applied will be returned from the + * visit function. + * + * ```ts + * const editedAST = visit(ast, { + * enter(node, key, parent, path, ancestors) { + * // @return + * // undefined: no action + * // false: skip visiting this node + * // visitor.BREAK: stop visiting altogether + * // null: delete this node + * // any value: replace this node with the returned value + * }, + * leave(node, key, parent, path, ancestors) { + * // @return + * // undefined: no action + * // false: no action + * // visitor.BREAK: stop visiting altogether + * // null: delete this node + * // any value: replace this node with the returned value + * } + * }); + * ``` + * + * Alternatively to providing enter() and leave() functions, a visitor can + * instead provide functions named the same as the kinds of AST nodes, or + * enter/leave visitors at a named key, leading to three permutations of the + * visitor API: + * + * 1) Named visitors triggered when entering a node of a specific kind. + * + * ```ts + * visit(ast, { + * Kind(node) { + * // enter the "Kind" node + * } + * }) + * ``` + * + * 2) Named visitors that trigger upon entering and leaving a node of a specific kind. + * + * ```ts + * visit(ast, { + * Kind: { + * enter(node) { + * // enter the "Kind" node + * } + * leave(node) { + * // leave the "Kind" node + * } + * } + * }) + * ``` + * + * 3) Generic visitors that trigger upon entering and leaving any node. + * + * ```ts + * visit(ast, { + * enter(node) { + * // enter any node + * }, + * leave(node) { + * // leave any node + * } + * }) + * ``` + */ + +exports.BREAK = BREAK; + +function visit(root, visitor, visitorKeys = _ast.QueryDocumentKeys) { + const enterLeaveMap = new Map(); + + for (const kind of Object.values(_kinds.Kind)) { + enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind)); + } + /* eslint-disable no-undef-init */ + + let stack = undefined; + let inArray = Array.isArray(root); + let keys = [root]; + let index = -1; + let edits = []; + let node = root; + let key = undefined; + let parent = undefined; + const path = []; + const ancestors = []; + /* eslint-enable no-undef-init */ + + do { + index++; + const isLeaving = index === keys.length; + const isEdited = isLeaving && edits.length !== 0; + + if (isLeaving) { + key = ancestors.length === 0 ? undefined : path[path.length - 1]; + node = parent; + parent = ancestors.pop(); + + if (isEdited) { + if (inArray) { + node = node.slice(); + let editOffset = 0; + + for (const [editKey, editValue] of edits) { + const arrayKey = editKey - editOffset; + + if (editValue === null) { + node.splice(arrayKey, 1); + editOffset++; + } else { + node[arrayKey] = editValue; + } + } + } else { + node = Object.defineProperties( + {}, + Object.getOwnPropertyDescriptors(node), + ); + + for (const [editKey, editValue] of edits) { + node[editKey] = editValue; + } + } + } + + index = stack.index; + keys = stack.keys; + edits = stack.edits; + inArray = stack.inArray; + stack = stack.prev; + } else if (parent) { + key = inArray ? index : keys[index]; + node = parent[key]; + + if (node === null || node === undefined) { + continue; + } + + path.push(key); + } + + let result; + + if (!Array.isArray(node)) { + var _enterLeaveMap$get, _enterLeaveMap$get2; + + (0, _ast.isNode)(node) || + (0, _devAssert.devAssert)( + false, + `Invalid AST Node: ${(0, _inspect.inspect)(node)}.`, + ); + const visitFn = isLeaving + ? (_enterLeaveMap$get = enterLeaveMap.get(node.kind)) === null || + _enterLeaveMap$get === void 0 + ? void 0 + : _enterLeaveMap$get.leave + : (_enterLeaveMap$get2 = enterLeaveMap.get(node.kind)) === null || + _enterLeaveMap$get2 === void 0 + ? void 0 + : _enterLeaveMap$get2.enter; + result = + visitFn === null || visitFn === void 0 + ? void 0 + : visitFn.call(visitor, node, key, parent, path, ancestors); + + if (result === BREAK) { + break; + } + + if (result === false) { + if (!isLeaving) { + path.pop(); + continue; + } + } else if (result !== undefined) { + edits.push([key, result]); + + if (!isLeaving) { + if ((0, _ast.isNode)(result)) { + node = result; + } else { + path.pop(); + continue; + } + } + } + } + + if (result === undefined && isEdited) { + edits.push([key, node]); + } + + if (isLeaving) { + path.pop(); + } else { + var _node$kind; + + stack = { + inArray, + index, + keys, + edits, + prev: stack, + }; + inArray = Array.isArray(node); + keys = inArray + ? node + : (_node$kind = visitorKeys[node.kind]) !== null && + _node$kind !== void 0 + ? _node$kind + : []; + index = -1; + edits = []; + + if (parent) { + ancestors.push(parent); + } + + parent = node; + } + } while (stack !== undefined); + + if (edits.length !== 0) { + // New root + return edits[edits.length - 1][1]; + } + + return root; +} +/** + * Creates a new visitor instance which delegates to many visitors to run in + * parallel. Each visitor will be visited for each node before moving on. + * + * If a prior visitor edits a node, no following visitors will see that node. + */ + +function visitInParallel(visitors) { + const skipping = new Array(visitors.length).fill(null); + const mergedVisitor = Object.create(null); + + for (const kind of Object.values(_kinds.Kind)) { + let hasVisitor = false; + const enterList = new Array(visitors.length).fill(undefined); + const leaveList = new Array(visitors.length).fill(undefined); + + for (let i = 0; i < visitors.length; ++i) { + const { enter, leave } = getEnterLeaveForKind(visitors[i], kind); + hasVisitor || (hasVisitor = enter != null || leave != null); + enterList[i] = enter; + leaveList[i] = leave; + } + + if (!hasVisitor) { + continue; + } + + const mergedEnterLeave = { + enter(...args) { + const node = args[0]; + + for (let i = 0; i < visitors.length; i++) { + if (skipping[i] === null) { + var _enterList$i; + + const result = + (_enterList$i = enterList[i]) === null || _enterList$i === void 0 + ? void 0 + : _enterList$i.apply(visitors[i], args); + + if (result === false) { + skipping[i] = node; + } else if (result === BREAK) { + skipping[i] = BREAK; + } else if (result !== undefined) { + return result; + } + } + } + }, + + leave(...args) { + const node = args[0]; + + for (let i = 0; i < visitors.length; i++) { + if (skipping[i] === null) { + var _leaveList$i; + + const result = + (_leaveList$i = leaveList[i]) === null || _leaveList$i === void 0 + ? void 0 + : _leaveList$i.apply(visitors[i], args); + + if (result === BREAK) { + skipping[i] = BREAK; + } else if (result !== undefined && result !== false) { + return result; + } + } else if (skipping[i] === node) { + skipping[i] = null; + } + } + }, + }; + mergedVisitor[kind] = mergedEnterLeave; + } + + return mergedVisitor; +} +/** + * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind. + */ + +function getEnterLeaveForKind(visitor, kind) { + const kindVisitor = visitor[kind]; + + if (typeof kindVisitor === 'object') { + // { Kind: { enter() {}, leave() {} } } + return kindVisitor; + } else if (typeof kindVisitor === 'function') { + // { Kind() {} } + return { + enter: kindVisitor, + leave: undefined, + }; + } // { enter() {}, leave() {} } + + return { + enter: visitor.enter, + leave: visitor.leave, + }; +} +/** + * Given a visitor instance, if it is leaving or not, and a node kind, return + * the function the visitor runtime should call. + * + * @deprecated Please use `getEnterLeaveForKind` instead. Will be removed in v17 + */ + +/* c8 ignore next 8 */ + +function getVisitFn(visitor, kind, isLeaving) { + const { enter, leave } = getEnterLeaveForKind(visitor, kind); + return isLeaving ? leave : enter; +} + + +/***/ }), + +/***/ 3058: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.assertEnumValueName = assertEnumValueName; +exports.assertName = assertName; + +var _devAssert = __webpack_require__(7242); + +var _GraphQLError = __webpack_require__(5822); + +var _characterClasses = __webpack_require__(2591); + +/** + * Upholds the spec rules about naming. + */ +function assertName(name) { + name != null || (0, _devAssert.devAssert)(false, 'Must provide name.'); + typeof name === 'string' || + (0, _devAssert.devAssert)(false, 'Expected name to be a string.'); + + if (name.length === 0) { + throw new _GraphQLError.GraphQLError( + 'Expected name to be a non-empty string.', + ); + } + + for (let i = 1; i < name.length; ++i) { + if (!(0, _characterClasses.isNameContinue)(name.charCodeAt(i))) { + throw new _GraphQLError.GraphQLError( + `Names must only contain [_a-zA-Z0-9] but "${name}" does not.`, + ); + } + } + + if (!(0, _characterClasses.isNameStart)(name.charCodeAt(0))) { + throw new _GraphQLError.GraphQLError( + `Names must start with [_a-zA-Z] but "${name}" does not.`, + ); + } + + return name; +} +/** + * Upholds the spec rules about naming enum values. + * + * @internal + */ + +function assertEnumValueName(name) { + if (name === 'true' || name === 'false' || name === 'null') { + throw new _GraphQLError.GraphQLError( + `Enum values cannot be named: ${name}`, + ); + } + + return assertName(name); +} + + +/***/ }), + +/***/ 5003: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.GraphQLUnionType = + exports.GraphQLScalarType = + exports.GraphQLObjectType = + exports.GraphQLNonNull = + exports.GraphQLList = + exports.GraphQLInterfaceType = + exports.GraphQLInputObjectType = + exports.GraphQLEnumType = + void 0; +exports.argsToArgsConfig = argsToArgsConfig; +exports.assertAbstractType = assertAbstractType; +exports.assertCompositeType = assertCompositeType; +exports.assertEnumType = assertEnumType; +exports.assertInputObjectType = assertInputObjectType; +exports.assertInputType = assertInputType; +exports.assertInterfaceType = assertInterfaceType; +exports.assertLeafType = assertLeafType; +exports.assertListType = assertListType; +exports.assertNamedType = assertNamedType; +exports.assertNonNullType = assertNonNullType; +exports.assertNullableType = assertNullableType; +exports.assertObjectType = assertObjectType; +exports.assertOutputType = assertOutputType; +exports.assertScalarType = assertScalarType; +exports.assertType = assertType; +exports.assertUnionType = assertUnionType; +exports.assertWrappingType = assertWrappingType; +exports.defineArguments = defineArguments; +exports.getNamedType = getNamedType; +exports.getNullableType = getNullableType; +exports.isAbstractType = isAbstractType; +exports.isCompositeType = isCompositeType; +exports.isEnumType = isEnumType; +exports.isInputObjectType = isInputObjectType; +exports.isInputType = isInputType; +exports.isInterfaceType = isInterfaceType; +exports.isLeafType = isLeafType; +exports.isListType = isListType; +exports.isNamedType = isNamedType; +exports.isNonNullType = isNonNullType; +exports.isNullableType = isNullableType; +exports.isObjectType = isObjectType; +exports.isOutputType = isOutputType; +exports.isRequiredArgument = isRequiredArgument; +exports.isRequiredInputField = isRequiredInputField; +exports.isScalarType = isScalarType; +exports.isType = isType; +exports.isUnionType = isUnionType; +exports.isWrappingType = isWrappingType; +exports.resolveObjMapThunk = resolveObjMapThunk; +exports.resolveReadonlyArrayThunk = resolveReadonlyArrayThunk; + +var _devAssert = __webpack_require__(7242); + +var _didYouMean = __webpack_require__(100); + +var _identityFunc = __webpack_require__(3317); + +var _inspect = __webpack_require__(8002); + +var _instanceOf = __webpack_require__(5752); + +var _isObjectLike = __webpack_require__(5690); + +var _keyMap = __webpack_require__(2863); + +var _keyValMap = __webpack_require__(7154); + +var _mapValue = __webpack_require__(6124); + +var _suggestionList = __webpack_require__(8070); + +var _toObjMap = __webpack_require__(7690); + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _printer = __webpack_require__(3033); + +var _valueFromASTUntyped = __webpack_require__(7784); + +var _assertName = __webpack_require__(3058); + +function isType(type) { + return ( + isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + isInputObjectType(type) || + isListType(type) || + isNonNullType(type) + ); +} + +function assertType(type) { + if (!isType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL type.`, + ); + } + + return type; +} +/** + * There are predicates for each kind of GraphQL type. + */ + +function isScalarType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLScalarType); +} + +function assertScalarType(type) { + if (!isScalarType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Scalar type.`, + ); + } + + return type; +} + +function isObjectType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLObjectType); +} + +function assertObjectType(type) { + if (!isObjectType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Object type.`, + ); + } + + return type; +} + +function isInterfaceType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLInterfaceType); +} + +function assertInterfaceType(type) { + if (!isInterfaceType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Interface type.`, + ); + } + + return type; +} + +function isUnionType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLUnionType); +} + +function assertUnionType(type) { + if (!isUnionType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Union type.`, + ); + } + + return type; +} + +function isEnumType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLEnumType); +} + +function assertEnumType(type) { + if (!isEnumType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Enum type.`, + ); + } + + return type; +} + +function isInputObjectType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLInputObjectType); +} + +function assertInputObjectType(type) { + if (!isInputObjectType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)( + type, + )} to be a GraphQL Input Object type.`, + ); + } + + return type; +} + +function isListType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLList); +} + +function assertListType(type) { + if (!isListType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL List type.`, + ); + } + + return type; +} + +function isNonNullType(type) { + return (0, _instanceOf.instanceOf)(type, GraphQLNonNull); +} + +function assertNonNullType(type) { + if (!isNonNullType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL Non-Null type.`, + ); + } + + return type; +} +/** + * These types may be used as input types for arguments and directives. + */ + +function isInputType(type) { + return ( + isScalarType(type) || + isEnumType(type) || + isInputObjectType(type) || + (isWrappingType(type) && isInputType(type.ofType)) + ); +} + +function assertInputType(type) { + if (!isInputType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL input type.`, + ); + } + + return type; +} +/** + * These types may be used as output types as the result of fields. + */ + +function isOutputType(type) { + return ( + isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + (isWrappingType(type) && isOutputType(type.ofType)) + ); +} + +function assertOutputType(type) { + if (!isOutputType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL output type.`, + ); + } + + return type; +} +/** + * These types may describe types which may be leaf values. + */ + +function isLeafType(type) { + return isScalarType(type) || isEnumType(type); +} + +function assertLeafType(type) { + if (!isLeafType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL leaf type.`, + ); + } + + return type; +} +/** + * These types may describe the parent context of a selection set. + */ + +function isCompositeType(type) { + return isObjectType(type) || isInterfaceType(type) || isUnionType(type); +} + +function assertCompositeType(type) { + if (!isCompositeType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL composite type.`, + ); + } + + return type; +} +/** + * These types may describe the parent context of a selection set. + */ + +function isAbstractType(type) { + return isInterfaceType(type) || isUnionType(type); +} + +function assertAbstractType(type) { + if (!isAbstractType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL abstract type.`, + ); + } + + return type; +} +/** + * List Type Wrapper + * + * A list is a wrapping type which points to another type. + * Lists are often created within the context of defining the fields of + * an object type. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * parents: { type: new GraphQLList(PersonType) }, + * children: { type: new GraphQLList(PersonType) }, + * }) + * }) + * ``` + */ + +class GraphQLList { + constructor(ofType) { + isType(ofType) || + (0, _devAssert.devAssert)( + false, + `Expected ${(0, _inspect.inspect)(ofType)} to be a GraphQL type.`, + ); + this.ofType = ofType; + } + + get [Symbol.toStringTag]() { + return 'GraphQLList'; + } + + toString() { + return '[' + String(this.ofType) + ']'; + } + + toJSON() { + return this.toString(); + } +} +/** + * Non-Null Type Wrapper + * + * A non-null is a wrapping type which points to another type. + * Non-null types enforce that their values are never null and can ensure + * an error is raised if this ever occurs during a request. It is useful for + * fields which you can make a strong guarantee on non-nullability, for example + * usually the id field of a database row will never be null. + * + * Example: + * + * ```ts + * const RowType = new GraphQLObjectType({ + * name: 'Row', + * fields: () => ({ + * id: { type: new GraphQLNonNull(GraphQLString) }, + * }) + * }) + * ``` + * Note: the enforcement of non-nullability occurs within the executor. + */ + +exports.GraphQLList = GraphQLList; + +class GraphQLNonNull { + constructor(ofType) { + isNullableType(ofType) || + (0, _devAssert.devAssert)( + false, + `Expected ${(0, _inspect.inspect)( + ofType, + )} to be a GraphQL nullable type.`, + ); + this.ofType = ofType; + } + + get [Symbol.toStringTag]() { + return 'GraphQLNonNull'; + } + + toString() { + return String(this.ofType) + '!'; + } + + toJSON() { + return this.toString(); + } +} +/** + * These types wrap and modify other types + */ + +exports.GraphQLNonNull = GraphQLNonNull; + +function isWrappingType(type) { + return isListType(type) || isNonNullType(type); +} + +function assertWrappingType(type) { + if (!isWrappingType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL wrapping type.`, + ); + } + + return type; +} +/** + * These types can all accept null as a value. + */ + +function isNullableType(type) { + return isType(type) && !isNonNullType(type); +} + +function assertNullableType(type) { + if (!isNullableType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL nullable type.`, + ); + } + + return type; +} + +function getNullableType(type) { + if (type) { + return isNonNullType(type) ? type.ofType : type; + } +} +/** + * These named types do not include modifiers like List or NonNull. + */ + +function isNamedType(type) { + return ( + isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + isInputObjectType(type) + ); +} + +function assertNamedType(type) { + if (!isNamedType(type)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(type)} to be a GraphQL named type.`, + ); + } + + return type; +} + +function getNamedType(type) { + if (type) { + let unwrappedType = type; + + while (isWrappingType(unwrappedType)) { + unwrappedType = unwrappedType.ofType; + } + + return unwrappedType; + } +} +/** + * Used while defining GraphQL types to allow for circular references in + * otherwise immutable type definitions. + */ + +function resolveReadonlyArrayThunk(thunk) { + return typeof thunk === 'function' ? thunk() : thunk; +} + +function resolveObjMapThunk(thunk) { + return typeof thunk === 'function' ? thunk() : thunk; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ + +/** + * Scalar Type Definition + * + * The leaf values of any request and input values to arguments are + * Scalars (or Enums) and are defined with a name and a series of functions + * used to parse input from ast or variables and to ensure validity. + * + * If a type's serialize function returns `null` or does not return a value + * (i.e. it returns `undefined`) then an error will be raised and a `null` + * value will be returned in the response. It is always better to validate + * + * Example: + * + * ```ts + * const OddType = new GraphQLScalarType({ + * name: 'Odd', + * serialize(value) { + * if (!Number.isFinite(value)) { + * throw new Error( + * `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`, + * ); + * } + * + * if (value % 2 === 0) { + * throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`); + * } + * return value; + * } + * }); + * ``` + */ +class GraphQLScalarType { + constructor(config) { + var _config$parseValue, + _config$serialize, + _config$parseLiteral, + _config$extensionASTN; + + const parseValue = + (_config$parseValue = config.parseValue) !== null && + _config$parseValue !== void 0 + ? _config$parseValue + : _identityFunc.identityFunc; + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.specifiedByURL = config.specifiedByURL; + this.serialize = + (_config$serialize = config.serialize) !== null && + _config$serialize !== void 0 + ? _config$serialize + : _identityFunc.identityFunc; + this.parseValue = parseValue; + this.parseLiteral = + (_config$parseLiteral = config.parseLiteral) !== null && + _config$parseLiteral !== void 0 + ? _config$parseLiteral + : (node, variables) => + parseValue( + (0, _valueFromASTUntyped.valueFromASTUntyped)(node, variables), + ); + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN = config.extensionASTNodes) !== null && + _config$extensionASTN !== void 0 + ? _config$extensionASTN + : []; + config.specifiedByURL == null || + typeof config.specifiedByURL === 'string' || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide "specifiedByURL" as a string, ` + + `but got: ${(0, _inspect.inspect)(config.specifiedByURL)}.`, + ); + config.serialize == null || + typeof config.serialize === 'function' || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`, + ); + + if (config.parseLiteral) { + (typeof config.parseValue === 'function' && + typeof config.parseLiteral === 'function') || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide both "parseValue" and "parseLiteral" functions.`, + ); + } + } + + get [Symbol.toStringTag]() { + return 'GraphQLScalarType'; + } + + toConfig() { + return { + name: this.name, + description: this.description, + specifiedByURL: this.specifiedByURL, + serialize: this.serialize, + parseValue: this.parseValue, + parseLiteral: this.parseLiteral, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLScalarType = GraphQLScalarType; + +/** + * Object Type Definition + * + * Almost all of the GraphQL types you define will be object types. Object types + * have a name, but most importantly describe their fields. + * + * Example: + * + * ```ts + * const AddressType = new GraphQLObjectType({ + * name: 'Address', + * fields: { + * street: { type: GraphQLString }, + * number: { type: GraphQLInt }, + * formatted: { + * type: GraphQLString, + * resolve(obj) { + * return obj.number + ' ' + obj.street + * } + * } + * } + * }); + * ``` + * + * When two types need to refer to each other, or a type needs to refer to + * itself in a field, you can use a function expression (aka a closure or a + * thunk) to supply the fields lazily. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * name: { type: GraphQLString }, + * bestFriend: { type: PersonType }, + * }) + * }); + * ``` + */ +class GraphQLObjectType { + constructor(config) { + var _config$extensionASTN2; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.isTypeOf = config.isTypeOf; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN2 = config.extensionASTNodes) !== null && + _config$extensionASTN2 !== void 0 + ? _config$extensionASTN2 + : []; + + this._fields = () => defineFieldMap(config); + + this._interfaces = () => defineInterfaces(config); + + config.isTypeOf == null || + typeof config.isTypeOf === 'function' || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide "isTypeOf" as a function, ` + + `but got: ${(0, _inspect.inspect)(config.isTypeOf)}.`, + ); + } + + get [Symbol.toStringTag]() { + return 'GraphQLObjectType'; + } + + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + + return this._fields; + } + + getInterfaces() { + if (typeof this._interfaces === 'function') { + this._interfaces = this._interfaces(); + } + + return this._interfaces; + } + + toConfig() { + return { + name: this.name, + description: this.description, + interfaces: this.getInterfaces(), + fields: fieldsToFieldsConfig(this.getFields()), + isTypeOf: this.isTypeOf, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLObjectType = GraphQLObjectType; + +function defineInterfaces(config) { + var _config$interfaces; + + const interfaces = resolveReadonlyArrayThunk( + (_config$interfaces = config.interfaces) !== null && + _config$interfaces !== void 0 + ? _config$interfaces + : [], + ); + Array.isArray(interfaces) || + (0, _devAssert.devAssert)( + false, + `${config.name} interfaces must be an Array or a function which returns an Array.`, + ); + return interfaces; +} + +function defineFieldMap(config) { + const fieldMap = resolveObjMapThunk(config.fields); + isPlainObj(fieldMap) || + (0, _devAssert.devAssert)( + false, + `${config.name} fields must be an object with field names as keys or a function which returns such an object.`, + ); + return (0, _mapValue.mapValue)(fieldMap, (fieldConfig, fieldName) => { + var _fieldConfig$args; + + isPlainObj(fieldConfig) || + (0, _devAssert.devAssert)( + false, + `${config.name}.${fieldName} field config must be an object.`, + ); + fieldConfig.resolve == null || + typeof fieldConfig.resolve === 'function' || + (0, _devAssert.devAssert)( + false, + `${config.name}.${fieldName} field resolver must be a function if ` + + `provided, but got: ${(0, _inspect.inspect)(fieldConfig.resolve)}.`, + ); + const argsConfig = + (_fieldConfig$args = fieldConfig.args) !== null && + _fieldConfig$args !== void 0 + ? _fieldConfig$args + : {}; + isPlainObj(argsConfig) || + (0, _devAssert.devAssert)( + false, + `${config.name}.${fieldName} args must be an object with argument names as keys.`, + ); + return { + name: (0, _assertName.assertName)(fieldName), + description: fieldConfig.description, + type: fieldConfig.type, + args: defineArguments(argsConfig), + resolve: fieldConfig.resolve, + subscribe: fieldConfig.subscribe, + deprecationReason: fieldConfig.deprecationReason, + extensions: (0, _toObjMap.toObjMap)(fieldConfig.extensions), + astNode: fieldConfig.astNode, + }; + }); +} + +function defineArguments(config) { + return Object.entries(config).map(([argName, argConfig]) => ({ + name: (0, _assertName.assertName)(argName), + description: argConfig.description, + type: argConfig.type, + defaultValue: argConfig.defaultValue, + deprecationReason: argConfig.deprecationReason, + extensions: (0, _toObjMap.toObjMap)(argConfig.extensions), + astNode: argConfig.astNode, + })); +} + +function isPlainObj(obj) { + return (0, _isObjectLike.isObjectLike)(obj) && !Array.isArray(obj); +} + +function fieldsToFieldsConfig(fields) { + return (0, _mapValue.mapValue)(fields, (field) => ({ + description: field.description, + type: field.type, + args: argsToArgsConfig(field.args), + resolve: field.resolve, + subscribe: field.subscribe, + deprecationReason: field.deprecationReason, + extensions: field.extensions, + astNode: field.astNode, + })); +} +/** + * @internal + */ + +function argsToArgsConfig(args) { + return (0, _keyValMap.keyValMap)( + args, + (arg) => arg.name, + (arg) => ({ + description: arg.description, + type: arg.type, + defaultValue: arg.defaultValue, + deprecationReason: arg.deprecationReason, + extensions: arg.extensions, + astNode: arg.astNode, + }), + ); +} + +function isRequiredArgument(arg) { + return isNonNullType(arg.type) && arg.defaultValue === undefined; +} + +/** + * Interface Type Definition + * + * When a field can return one of a heterogeneous set of types, a Interface type + * is used to describe what types are possible, what fields are in common across + * all types, as well as a function to determine which type is actually used + * when the field is resolved. + * + * Example: + * + * ```ts + * const EntityType = new GraphQLInterfaceType({ + * name: 'Entity', + * fields: { + * name: { type: GraphQLString } + * } + * }); + * ``` + */ +class GraphQLInterfaceType { + constructor(config) { + var _config$extensionASTN3; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.resolveType = config.resolveType; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN3 = config.extensionASTNodes) !== null && + _config$extensionASTN3 !== void 0 + ? _config$extensionASTN3 + : []; + this._fields = defineFieldMap.bind(undefined, config); + this._interfaces = defineInterfaces.bind(undefined, config); + config.resolveType == null || + typeof config.resolveType === 'function' || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide "resolveType" as a function, ` + + `but got: ${(0, _inspect.inspect)(config.resolveType)}.`, + ); + } + + get [Symbol.toStringTag]() { + return 'GraphQLInterfaceType'; + } + + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + + return this._fields; + } + + getInterfaces() { + if (typeof this._interfaces === 'function') { + this._interfaces = this._interfaces(); + } + + return this._interfaces; + } + + toConfig() { + return { + name: this.name, + description: this.description, + interfaces: this.getInterfaces(), + fields: fieldsToFieldsConfig(this.getFields()), + resolveType: this.resolveType, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLInterfaceType = GraphQLInterfaceType; + +/** + * Union Type Definition + * + * When a field can return one of a heterogeneous set of types, a Union type + * is used to describe what types are possible as well as providing a function + * to determine which type is actually used when the field is resolved. + * + * Example: + * + * ```ts + * const PetType = new GraphQLUnionType({ + * name: 'Pet', + * types: [ DogType, CatType ], + * resolveType(value) { + * if (value instanceof Dog) { + * return DogType; + * } + * if (value instanceof Cat) { + * return CatType; + * } + * } + * }); + * ``` + */ +class GraphQLUnionType { + constructor(config) { + var _config$extensionASTN4; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.resolveType = config.resolveType; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN4 = config.extensionASTNodes) !== null && + _config$extensionASTN4 !== void 0 + ? _config$extensionASTN4 + : []; + this._types = defineTypes.bind(undefined, config); + config.resolveType == null || + typeof config.resolveType === 'function' || + (0, _devAssert.devAssert)( + false, + `${this.name} must provide "resolveType" as a function, ` + + `but got: ${(0, _inspect.inspect)(config.resolveType)}.`, + ); + } + + get [Symbol.toStringTag]() { + return 'GraphQLUnionType'; + } + + getTypes() { + if (typeof this._types === 'function') { + this._types = this._types(); + } + + return this._types; + } + + toConfig() { + return { + name: this.name, + description: this.description, + types: this.getTypes(), + resolveType: this.resolveType, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLUnionType = GraphQLUnionType; + +function defineTypes(config) { + const types = resolveReadonlyArrayThunk(config.types); + Array.isArray(types) || + (0, _devAssert.devAssert)( + false, + `Must provide Array of types or a function which returns such an array for Union ${config.name}.`, + ); + return types; +} + +/** + * Enum Type Definition + * + * Some leaf values of requests and input values are Enums. GraphQL serializes + * Enum values as strings, however internally Enums can be represented by any + * kind of type, often integers. + * + * Example: + * + * ```ts + * const RGBType = new GraphQLEnumType({ + * name: 'RGB', + * values: { + * RED: { value: 0 }, + * GREEN: { value: 1 }, + * BLUE: { value: 2 } + * } + * }); + * ``` + * + * Note: If a value is not provided in a definition, the name of the enum value + * will be used as its internal value. + */ +class GraphQLEnumType { + /* */ + constructor(config) { + var _config$extensionASTN5; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN5 = config.extensionASTNodes) !== null && + _config$extensionASTN5 !== void 0 + ? _config$extensionASTN5 + : []; + this._values = defineEnumValues(this.name, config.values); + this._valueLookup = new Map( + this._values.map((enumValue) => [enumValue.value, enumValue]), + ); + this._nameLookup = (0, _keyMap.keyMap)(this._values, (value) => value.name); + } + + get [Symbol.toStringTag]() { + return 'GraphQLEnumType'; + } + + getValues() { + return this._values; + } + + getValue(name) { + return this._nameLookup[name]; + } + + serialize(outputValue) { + const enumValue = this._valueLookup.get(outputValue); + + if (enumValue === undefined) { + throw new _GraphQLError.GraphQLError( + `Enum "${this.name}" cannot represent value: ${(0, _inspect.inspect)( + outputValue, + )}`, + ); + } + + return enumValue.name; + } + + parseValue(inputValue) /* T */ + { + if (typeof inputValue !== 'string') { + const valueStr = (0, _inspect.inspect)(inputValue); + throw new _GraphQLError.GraphQLError( + `Enum "${this.name}" cannot represent non-string value: ${valueStr}.` + + didYouMeanEnumValue(this, valueStr), + ); + } + + const enumValue = this.getValue(inputValue); + + if (enumValue == null) { + throw new _GraphQLError.GraphQLError( + `Value "${inputValue}" does not exist in "${this.name}" enum.` + + didYouMeanEnumValue(this, inputValue), + ); + } + + return enumValue.value; + } + + parseLiteral(valueNode, _variables) /* T */ + { + // Note: variables will be resolved to a value before calling this function. + if (valueNode.kind !== _kinds.Kind.ENUM) { + const valueStr = (0, _printer.print)(valueNode); + throw new _GraphQLError.GraphQLError( + `Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` + + didYouMeanEnumValue(this, valueStr), + { + nodes: valueNode, + }, + ); + } + + const enumValue = this.getValue(valueNode.value); + + if (enumValue == null) { + const valueStr = (0, _printer.print)(valueNode); + throw new _GraphQLError.GraphQLError( + `Value "${valueStr}" does not exist in "${this.name}" enum.` + + didYouMeanEnumValue(this, valueStr), + { + nodes: valueNode, + }, + ); + } + + return enumValue.value; + } + + toConfig() { + const values = (0, _keyValMap.keyValMap)( + this.getValues(), + (value) => value.name, + (value) => ({ + description: value.description, + value: value.value, + deprecationReason: value.deprecationReason, + extensions: value.extensions, + astNode: value.astNode, + }), + ); + return { + name: this.name, + description: this.description, + values, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLEnumType = GraphQLEnumType; + +function didYouMeanEnumValue(enumType, unknownValueStr) { + const allNames = enumType.getValues().map((value) => value.name); + const suggestedValues = (0, _suggestionList.suggestionList)( + unknownValueStr, + allNames, + ); + return (0, _didYouMean.didYouMean)('the enum value', suggestedValues); +} + +function defineEnumValues(typeName, valueMap) { + isPlainObj(valueMap) || + (0, _devAssert.devAssert)( + false, + `${typeName} values must be an object with value names as keys.`, + ); + return Object.entries(valueMap).map(([valueName, valueConfig]) => { + isPlainObj(valueConfig) || + (0, _devAssert.devAssert)( + false, + `${typeName}.${valueName} must refer to an object with a "value" key ` + + `representing an internal value but got: ${(0, _inspect.inspect)( + valueConfig, + )}.`, + ); + return { + name: (0, _assertName.assertEnumValueName)(valueName), + description: valueConfig.description, + value: valueConfig.value !== undefined ? valueConfig.value : valueName, + deprecationReason: valueConfig.deprecationReason, + extensions: (0, _toObjMap.toObjMap)(valueConfig.extensions), + astNode: valueConfig.astNode, + }; + }); +} + +/** + * Input Object Type Definition + * + * An input object defines a structured collection of fields which may be + * supplied to a field argument. + * + * Using `NonNull` will ensure that a value must be provided by the query + * + * Example: + * + * ```ts + * const GeoPoint = new GraphQLInputObjectType({ + * name: 'GeoPoint', + * fields: { + * lat: { type: new GraphQLNonNull(GraphQLFloat) }, + * lon: { type: new GraphQLNonNull(GraphQLFloat) }, + * alt: { type: GraphQLFloat, defaultValue: 0 }, + * } + * }); + * ``` + */ +class GraphQLInputObjectType { + constructor(config) { + var _config$extensionASTN6; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN6 = config.extensionASTNodes) !== null && + _config$extensionASTN6 !== void 0 + ? _config$extensionASTN6 + : []; + this._fields = defineInputFieldMap.bind(undefined, config); + } + + get [Symbol.toStringTag]() { + return 'GraphQLInputObjectType'; + } + + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + + return this._fields; + } + + toConfig() { + const fields = (0, _mapValue.mapValue)(this.getFields(), (field) => ({ + description: field.description, + type: field.type, + defaultValue: field.defaultValue, + deprecationReason: field.deprecationReason, + extensions: field.extensions, + astNode: field.astNode, + })); + return { + name: this.name, + description: this.description, + fields, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLInputObjectType = GraphQLInputObjectType; + +function defineInputFieldMap(config) { + const fieldMap = resolveObjMapThunk(config.fields); + isPlainObj(fieldMap) || + (0, _devAssert.devAssert)( + false, + `${config.name} fields must be an object with field names as keys or a function which returns such an object.`, + ); + return (0, _mapValue.mapValue)(fieldMap, (fieldConfig, fieldName) => { + !('resolve' in fieldConfig) || + (0, _devAssert.devAssert)( + false, + `${config.name}.${fieldName} field has a resolve property, but Input Types cannot define resolvers.`, + ); + return { + name: (0, _assertName.assertName)(fieldName), + description: fieldConfig.description, + type: fieldConfig.type, + defaultValue: fieldConfig.defaultValue, + deprecationReason: fieldConfig.deprecationReason, + extensions: (0, _toObjMap.toObjMap)(fieldConfig.extensions), + astNode: fieldConfig.astNode, + }; + }); +} + +function isRequiredInputField(field) { + return isNonNullType(field.type) && field.defaultValue === undefined; +} + + +/***/ }), + +/***/ 7197: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.GraphQLSpecifiedByDirective = + exports.GraphQLSkipDirective = + exports.GraphQLIncludeDirective = + exports.GraphQLDirective = + exports.GraphQLDeprecatedDirective = + exports.DEFAULT_DEPRECATION_REASON = + void 0; +exports.assertDirective = assertDirective; +exports.isDirective = isDirective; +exports.isSpecifiedDirective = isSpecifiedDirective; +exports.specifiedDirectives = void 0; + +var _devAssert = __webpack_require__(7242); + +var _inspect = __webpack_require__(8002); + +var _instanceOf = __webpack_require__(5752); + +var _isObjectLike = __webpack_require__(5690); + +var _toObjMap = __webpack_require__(7690); + +var _directiveLocation = __webpack_require__(8333); + +var _assertName = __webpack_require__(3058); + +var _definition = __webpack_require__(5003); + +var _scalars = __webpack_require__(2229); + +/** + * Test if the given value is a GraphQL directive. + */ +function isDirective(directive) { + return (0, _instanceOf.instanceOf)(directive, GraphQLDirective); +} + +function assertDirective(directive) { + if (!isDirective(directive)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(directive)} to be a GraphQL directive.`, + ); + } + + return directive; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ + +/** + * Directives are used by the GraphQL runtime as a way of modifying execution + * behavior. Type system creators will usually not create these directly. + */ +class GraphQLDirective { + constructor(config) { + var _config$isRepeatable, _config$args; + + this.name = (0, _assertName.assertName)(config.name); + this.description = config.description; + this.locations = config.locations; + this.isRepeatable = + (_config$isRepeatable = config.isRepeatable) !== null && + _config$isRepeatable !== void 0 + ? _config$isRepeatable + : false; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + Array.isArray(config.locations) || + (0, _devAssert.devAssert)( + false, + `@${config.name} locations must be an Array.`, + ); + const args = + (_config$args = config.args) !== null && _config$args !== void 0 + ? _config$args + : {}; + ((0, _isObjectLike.isObjectLike)(args) && !Array.isArray(args)) || + (0, _devAssert.devAssert)( + false, + `@${config.name} args must be an object with argument names as keys.`, + ); + this.args = (0, _definition.defineArguments)(args); + } + + get [Symbol.toStringTag]() { + return 'GraphQLDirective'; + } + + toConfig() { + return { + name: this.name, + description: this.description, + locations: this.locations, + args: (0, _definition.argsToArgsConfig)(this.args), + isRepeatable: this.isRepeatable, + extensions: this.extensions, + astNode: this.astNode, + }; + } + + toString() { + return '@' + this.name; + } + + toJSON() { + return this.toString(); + } +} + +exports.GraphQLDirective = GraphQLDirective; + +/** + * Used to conditionally include fields or fragments. + */ +const GraphQLIncludeDirective = new GraphQLDirective({ + name: 'include', + description: + 'Directs the executor to include this field or fragment only when the `if` argument is true.', + locations: [ + _directiveLocation.DirectiveLocation.FIELD, + _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, + _directiveLocation.DirectiveLocation.INLINE_FRAGMENT, + ], + args: { + if: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + description: 'Included when true.', + }, + }, +}); +/** + * Used to conditionally skip (exclude) fields or fragments. + */ + +exports.GraphQLIncludeDirective = GraphQLIncludeDirective; +const GraphQLSkipDirective = new GraphQLDirective({ + name: 'skip', + description: + 'Directs the executor to skip this field or fragment when the `if` argument is true.', + locations: [ + _directiveLocation.DirectiveLocation.FIELD, + _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, + _directiveLocation.DirectiveLocation.INLINE_FRAGMENT, + ], + args: { + if: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + description: 'Skipped when true.', + }, + }, +}); +/** + * Constant string used for default reason for a deprecation. + */ + +exports.GraphQLSkipDirective = GraphQLSkipDirective; +const DEFAULT_DEPRECATION_REASON = 'No longer supported'; +/** + * Used to declare element of a GraphQL schema as deprecated. + */ + +exports.DEFAULT_DEPRECATION_REASON = DEFAULT_DEPRECATION_REASON; +const GraphQLDeprecatedDirective = new GraphQLDirective({ + name: 'deprecated', + description: 'Marks an element of a GraphQL schema as no longer supported.', + locations: [ + _directiveLocation.DirectiveLocation.FIELD_DEFINITION, + _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION, + _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION, + _directiveLocation.DirectiveLocation.ENUM_VALUE, + ], + args: { + reason: { + type: _scalars.GraphQLString, + description: + 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).', + defaultValue: DEFAULT_DEPRECATION_REASON, + }, + }, +}); +/** + * Used to provide a URL for specifying the behavior of custom scalar definitions. + */ + +exports.GraphQLDeprecatedDirective = GraphQLDeprecatedDirective; +const GraphQLSpecifiedByDirective = new GraphQLDirective({ + name: 'specifiedBy', + description: 'Exposes a URL that specifies the behavior of this scalar.', + locations: [_directiveLocation.DirectiveLocation.SCALAR], + args: { + url: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + description: 'The URL that specifies the behavior of this scalar.', + }, + }, +}); +/** + * The full list of specified directives. + */ + +exports.GraphQLSpecifiedByDirective = GraphQLSpecifiedByDirective; +const specifiedDirectives = Object.freeze([ + GraphQLIncludeDirective, + GraphQLSkipDirective, + GraphQLDeprecatedDirective, + GraphQLSpecifiedByDirective, +]); +exports.specifiedDirectives = specifiedDirectives; + +function isSpecifiedDirective(directive) { + return specifiedDirectives.some(({ name }) => name === directive.name); +} + + +/***/ }), + +/***/ 8155: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.introspectionTypes = + exports.__TypeKind = + exports.__Type = + exports.__Schema = + exports.__InputValue = + exports.__Field = + exports.__EnumValue = + exports.__DirectiveLocation = + exports.__Directive = + exports.TypeNameMetaFieldDef = + exports.TypeMetaFieldDef = + exports.TypeKind = + exports.SchemaMetaFieldDef = + void 0; +exports.isIntrospectionType = isIntrospectionType; + +var _inspect = __webpack_require__(8002); + +var _invariant = __webpack_require__(7706); + +var _directiveLocation = __webpack_require__(8333); + +var _printer = __webpack_require__(3033); + +var _astFromValue = __webpack_require__(8115); + +var _definition = __webpack_require__(5003); + +var _scalars = __webpack_require__(2229); + +const __Schema = new _definition.GraphQLObjectType({ + name: '__Schema', + description: + 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.', + fields: () => ({ + description: { + type: _scalars.GraphQLString, + resolve: (schema) => schema.description, + }, + types: { + description: 'A list of all types supported by this server.', + type: new _definition.GraphQLNonNull( + new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)), + ), + + resolve(schema) { + return Object.values(schema.getTypeMap()); + }, + }, + queryType: { + description: 'The type that query operations will be rooted at.', + type: new _definition.GraphQLNonNull(__Type), + resolve: (schema) => schema.getQueryType(), + }, + mutationType: { + description: + 'If this server supports mutation, the type that mutation operations will be rooted at.', + type: __Type, + resolve: (schema) => schema.getMutationType(), + }, + subscriptionType: { + description: + 'If this server support subscription, the type that subscription operations will be rooted at.', + type: __Type, + resolve: (schema) => schema.getSubscriptionType(), + }, + directives: { + description: 'A list of all directives supported by this server.', + type: new _definition.GraphQLNonNull( + new _definition.GraphQLList( + new _definition.GraphQLNonNull(__Directive), + ), + ), + resolve: (schema) => schema.getDirectives(), + }, + }), +}); + +exports.__Schema = __Schema; + +const __Directive = new _definition.GraphQLObjectType({ + name: '__Directive', + description: + "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", + fields: () => ({ + name: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + resolve: (directive) => directive.name, + }, + description: { + type: _scalars.GraphQLString, + resolve: (directive) => directive.description, + }, + isRepeatable: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + resolve: (directive) => directive.isRepeatable, + }, + locations: { + type: new _definition.GraphQLNonNull( + new _definition.GraphQLList( + new _definition.GraphQLNonNull(__DirectiveLocation), + ), + ), + resolve: (directive) => directive.locations, + }, + args: { + type: new _definition.GraphQLNonNull( + new _definition.GraphQLList( + new _definition.GraphQLNonNull(__InputValue), + ), + ), + args: { + includeDeprecated: { + type: _scalars.GraphQLBoolean, + defaultValue: false, + }, + }, + + resolve(field, { includeDeprecated }) { + return includeDeprecated + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, + }, + }), +}); + +exports.__Directive = __Directive; + +const __DirectiveLocation = new _definition.GraphQLEnumType({ + name: '__DirectiveLocation', + description: + 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.', + values: { + QUERY: { + value: _directiveLocation.DirectiveLocation.QUERY, + description: 'Location adjacent to a query operation.', + }, + MUTATION: { + value: _directiveLocation.DirectiveLocation.MUTATION, + description: 'Location adjacent to a mutation operation.', + }, + SUBSCRIPTION: { + value: _directiveLocation.DirectiveLocation.SUBSCRIPTION, + description: 'Location adjacent to a subscription operation.', + }, + FIELD: { + value: _directiveLocation.DirectiveLocation.FIELD, + description: 'Location adjacent to a field.', + }, + FRAGMENT_DEFINITION: { + value: _directiveLocation.DirectiveLocation.FRAGMENT_DEFINITION, + description: 'Location adjacent to a fragment definition.', + }, + FRAGMENT_SPREAD: { + value: _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD, + description: 'Location adjacent to a fragment spread.', + }, + INLINE_FRAGMENT: { + value: _directiveLocation.DirectiveLocation.INLINE_FRAGMENT, + description: 'Location adjacent to an inline fragment.', + }, + VARIABLE_DEFINITION: { + value: _directiveLocation.DirectiveLocation.VARIABLE_DEFINITION, + description: 'Location adjacent to a variable definition.', + }, + SCHEMA: { + value: _directiveLocation.DirectiveLocation.SCHEMA, + description: 'Location adjacent to a schema definition.', + }, + SCALAR: { + value: _directiveLocation.DirectiveLocation.SCALAR, + description: 'Location adjacent to a scalar definition.', + }, + OBJECT: { + value: _directiveLocation.DirectiveLocation.OBJECT, + description: 'Location adjacent to an object type definition.', + }, + FIELD_DEFINITION: { + value: _directiveLocation.DirectiveLocation.FIELD_DEFINITION, + description: 'Location adjacent to a field definition.', + }, + ARGUMENT_DEFINITION: { + value: _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION, + description: 'Location adjacent to an argument definition.', + }, + INTERFACE: { + value: _directiveLocation.DirectiveLocation.INTERFACE, + description: 'Location adjacent to an interface definition.', + }, + UNION: { + value: _directiveLocation.DirectiveLocation.UNION, + description: 'Location adjacent to a union definition.', + }, + ENUM: { + value: _directiveLocation.DirectiveLocation.ENUM, + description: 'Location adjacent to an enum definition.', + }, + ENUM_VALUE: { + value: _directiveLocation.DirectiveLocation.ENUM_VALUE, + description: 'Location adjacent to an enum value definition.', + }, + INPUT_OBJECT: { + value: _directiveLocation.DirectiveLocation.INPUT_OBJECT, + description: 'Location adjacent to an input object type definition.', + }, + INPUT_FIELD_DEFINITION: { + value: _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION, + description: 'Location adjacent to an input object field definition.', + }, + }, +}); + +exports.__DirectiveLocation = __DirectiveLocation; + +const __Type = new _definition.GraphQLObjectType({ + name: '__Type', + description: + 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', + fields: () => ({ + kind: { + type: new _definition.GraphQLNonNull(__TypeKind), + + resolve(type) { + if ((0, _definition.isScalarType)(type)) { + return TypeKind.SCALAR; + } + + if ((0, _definition.isObjectType)(type)) { + return TypeKind.OBJECT; + } + + if ((0, _definition.isInterfaceType)(type)) { + return TypeKind.INTERFACE; + } + + if ((0, _definition.isUnionType)(type)) { + return TypeKind.UNION; + } + + if ((0, _definition.isEnumType)(type)) { + return TypeKind.ENUM; + } + + if ((0, _definition.isInputObjectType)(type)) { + return TypeKind.INPUT_OBJECT; + } + + if ((0, _definition.isListType)(type)) { + return TypeKind.LIST; + } + + if ((0, _definition.isNonNullType)(type)) { + return TypeKind.NON_NULL; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered) + + false || + (0, _invariant.invariant)( + false, + `Unexpected type: "${(0, _inspect.inspect)(type)}".`, + ); + }, + }, + name: { + type: _scalars.GraphQLString, + resolve: (type) => ('name' in type ? type.name : undefined), + }, + description: { + type: _scalars.GraphQLString, + resolve: ( + type, // FIXME: add test case + ) => + /* c8 ignore next */ + 'description' in type ? type.description : undefined, + }, + specifiedByURL: { + type: _scalars.GraphQLString, + resolve: (obj) => + 'specifiedByURL' in obj ? obj.specifiedByURL : undefined, + }, + fields: { + type: new _definition.GraphQLList( + new _definition.GraphQLNonNull(__Field), + ), + args: { + includeDeprecated: { + type: _scalars.GraphQLBoolean, + defaultValue: false, + }, + }, + + resolve(type, { includeDeprecated }) { + if ( + (0, _definition.isObjectType)(type) || + (0, _definition.isInterfaceType)(type) + ) { + const fields = Object.values(type.getFields()); + return includeDeprecated + ? fields + : fields.filter((field) => field.deprecationReason == null); + } + }, + }, + interfaces: { + type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)), + + resolve(type) { + if ( + (0, _definition.isObjectType)(type) || + (0, _definition.isInterfaceType)(type) + ) { + return type.getInterfaces(); + } + }, + }, + possibleTypes: { + type: new _definition.GraphQLList(new _definition.GraphQLNonNull(__Type)), + + resolve(type, _args, _context, { schema }) { + if ((0, _definition.isAbstractType)(type)) { + return schema.getPossibleTypes(type); + } + }, + }, + enumValues: { + type: new _definition.GraphQLList( + new _definition.GraphQLNonNull(__EnumValue), + ), + args: { + includeDeprecated: { + type: _scalars.GraphQLBoolean, + defaultValue: false, + }, + }, + + resolve(type, { includeDeprecated }) { + if ((0, _definition.isEnumType)(type)) { + const values = type.getValues(); + return includeDeprecated + ? values + : values.filter((field) => field.deprecationReason == null); + } + }, + }, + inputFields: { + type: new _definition.GraphQLList( + new _definition.GraphQLNonNull(__InputValue), + ), + args: { + includeDeprecated: { + type: _scalars.GraphQLBoolean, + defaultValue: false, + }, + }, + + resolve(type, { includeDeprecated }) { + if ((0, _definition.isInputObjectType)(type)) { + const values = Object.values(type.getFields()); + return includeDeprecated + ? values + : values.filter((field) => field.deprecationReason == null); + } + }, + }, + ofType: { + type: __Type, + resolve: (type) => ('ofType' in type ? type.ofType : undefined), + }, + }), +}); + +exports.__Type = __Type; + +const __Field = new _definition.GraphQLObjectType({ + name: '__Field', + description: + 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.', + fields: () => ({ + name: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + resolve: (field) => field.name, + }, + description: { + type: _scalars.GraphQLString, + resolve: (field) => field.description, + }, + args: { + type: new _definition.GraphQLNonNull( + new _definition.GraphQLList( + new _definition.GraphQLNonNull(__InputValue), + ), + ), + args: { + includeDeprecated: { + type: _scalars.GraphQLBoolean, + defaultValue: false, + }, + }, + + resolve(field, { includeDeprecated }) { + return includeDeprecated + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, + }, + type: { + type: new _definition.GraphQLNonNull(__Type), + resolve: (field) => field.type, + }, + isDeprecated: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + resolve: (field) => field.deprecationReason != null, + }, + deprecationReason: { + type: _scalars.GraphQLString, + resolve: (field) => field.deprecationReason, + }, + }), +}); + +exports.__Field = __Field; + +const __InputValue = new _definition.GraphQLObjectType({ + name: '__InputValue', + description: + 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.', + fields: () => ({ + name: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + resolve: (inputValue) => inputValue.name, + }, + description: { + type: _scalars.GraphQLString, + resolve: (inputValue) => inputValue.description, + }, + type: { + type: new _definition.GraphQLNonNull(__Type), + resolve: (inputValue) => inputValue.type, + }, + defaultValue: { + type: _scalars.GraphQLString, + description: + 'A GraphQL-formatted string representing the default value for this input value.', + + resolve(inputValue) { + const { type, defaultValue } = inputValue; + const valueAST = (0, _astFromValue.astFromValue)(defaultValue, type); + return valueAST ? (0, _printer.print)(valueAST) : null; + }, + }, + isDeprecated: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + resolve: (field) => field.deprecationReason != null, + }, + deprecationReason: { + type: _scalars.GraphQLString, + resolve: (obj) => obj.deprecationReason, + }, + }), +}); + +exports.__InputValue = __InputValue; + +const __EnumValue = new _definition.GraphQLObjectType({ + name: '__EnumValue', + description: + 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.', + fields: () => ({ + name: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + resolve: (enumValue) => enumValue.name, + }, + description: { + type: _scalars.GraphQLString, + resolve: (enumValue) => enumValue.description, + }, + isDeprecated: { + type: new _definition.GraphQLNonNull(_scalars.GraphQLBoolean), + resolve: (enumValue) => enumValue.deprecationReason != null, + }, + deprecationReason: { + type: _scalars.GraphQLString, + resolve: (enumValue) => enumValue.deprecationReason, + }, + }), +}); + +exports.__EnumValue = __EnumValue; +var TypeKind; +exports.TypeKind = TypeKind; + +(function (TypeKind) { + TypeKind['SCALAR'] = 'SCALAR'; + TypeKind['OBJECT'] = 'OBJECT'; + TypeKind['INTERFACE'] = 'INTERFACE'; + TypeKind['UNION'] = 'UNION'; + TypeKind['ENUM'] = 'ENUM'; + TypeKind['INPUT_OBJECT'] = 'INPUT_OBJECT'; + TypeKind['LIST'] = 'LIST'; + TypeKind['NON_NULL'] = 'NON_NULL'; +})(TypeKind || (exports.TypeKind = TypeKind = {})); + +const __TypeKind = new _definition.GraphQLEnumType({ + name: '__TypeKind', + description: 'An enum describing what kind of type a given `__Type` is.', + values: { + SCALAR: { + value: TypeKind.SCALAR, + description: 'Indicates this type is a scalar.', + }, + OBJECT: { + value: TypeKind.OBJECT, + description: + 'Indicates this type is an object. `fields` and `interfaces` are valid fields.', + }, + INTERFACE: { + value: TypeKind.INTERFACE, + description: + 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.', + }, + UNION: { + value: TypeKind.UNION, + description: + 'Indicates this type is a union. `possibleTypes` is a valid field.', + }, + ENUM: { + value: TypeKind.ENUM, + description: + 'Indicates this type is an enum. `enumValues` is a valid field.', + }, + INPUT_OBJECT: { + value: TypeKind.INPUT_OBJECT, + description: + 'Indicates this type is an input object. `inputFields` is a valid field.', + }, + LIST: { + value: TypeKind.LIST, + description: 'Indicates this type is a list. `ofType` is a valid field.', + }, + NON_NULL: { + value: TypeKind.NON_NULL, + description: + 'Indicates this type is a non-null. `ofType` is a valid field.', + }, + }, +}); +/** + * Note that these are GraphQLField and not GraphQLFieldConfig, + * so the format for args is different. + */ + +exports.__TypeKind = __TypeKind; +const SchemaMetaFieldDef = { + name: '__schema', + type: new _definition.GraphQLNonNull(__Schema), + description: 'Access the current type schema of this server.', + args: [], + resolve: (_source, _args, _context, { schema }) => schema, + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, +}; +exports.SchemaMetaFieldDef = SchemaMetaFieldDef; +const TypeMetaFieldDef = { + name: '__type', + type: __Type, + description: 'Request the type information of a single type.', + args: [ + { + name: 'name', + description: undefined, + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + defaultValue: undefined, + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, + }, + ], + resolve: (_source, { name }, _context, { schema }) => schema.getType(name), + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, +}; +exports.TypeMetaFieldDef = TypeMetaFieldDef; +const TypeNameMetaFieldDef = { + name: '__typename', + type: new _definition.GraphQLNonNull(_scalars.GraphQLString), + description: 'The name of the current Object type at runtime.', + args: [], + resolve: (_source, _args, _context, { parentType }) => parentType.name, + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, +}; +exports.TypeNameMetaFieldDef = TypeNameMetaFieldDef; +const introspectionTypes = Object.freeze([ + __Schema, + __Directive, + __DirectiveLocation, + __Type, + __Field, + __InputValue, + __EnumValue, + __TypeKind, +]); +exports.introspectionTypes = introspectionTypes; + +function isIntrospectionType(type) { + return introspectionTypes.some(({ name }) => type.name === name); +} + + +/***/ }), + +/***/ 2229: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.GraphQLString = + exports.GraphQLInt = + exports.GraphQLID = + exports.GraphQLFloat = + exports.GraphQLBoolean = + exports.GRAPHQL_MIN_INT = + exports.GRAPHQL_MAX_INT = + void 0; +exports.isSpecifiedScalarType = isSpecifiedScalarType; +exports.specifiedScalarTypes = void 0; + +var _inspect = __webpack_require__(8002); + +var _isObjectLike = __webpack_require__(5690); + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _printer = __webpack_require__(3033); + +var _definition = __webpack_require__(5003); + +/** + * Maximum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe up-to 2^53 - 1 + * */ +const GRAPHQL_MAX_INT = 2147483647; +/** + * Minimum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe starting at -(2^53 - 1) + * */ + +exports.GRAPHQL_MAX_INT = GRAPHQL_MAX_INT; +const GRAPHQL_MIN_INT = -2147483648; +exports.GRAPHQL_MIN_INT = GRAPHQL_MIN_INT; +const GraphQLInt = new _definition.GraphQLScalarType({ + name: 'Int', + description: + 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'boolean') { + return coercedValue ? 1 : 0; + } + + let num = coercedValue; + + if (typeof coercedValue === 'string' && coercedValue !== '') { + num = Number(coercedValue); + } + + if (typeof num !== 'number' || !Number.isInteger(num)) { + throw new _GraphQLError.GraphQLError( + `Int cannot represent non-integer value: ${(0, _inspect.inspect)( + coercedValue, + )}`, + ); + } + + if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) { + throw new _GraphQLError.GraphQLError( + 'Int cannot represent non 32-bit signed integer value: ' + + (0, _inspect.inspect)(coercedValue), + ); + } + + return num; + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'number' || !Number.isInteger(inputValue)) { + throw new _GraphQLError.GraphQLError( + `Int cannot represent non-integer value: ${(0, _inspect.inspect)( + inputValue, + )}`, + ); + } + + if (inputValue > GRAPHQL_MAX_INT || inputValue < GRAPHQL_MIN_INT) { + throw new _GraphQLError.GraphQLError( + `Int cannot represent non 32-bit signed integer value: ${inputValue}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _kinds.Kind.INT) { + throw new _GraphQLError.GraphQLError( + `Int cannot represent non-integer value: ${(0, _printer.print)( + valueNode, + )}`, + { + nodes: valueNode, + }, + ); + } + + const num = parseInt(valueNode.value, 10); + + if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) { + throw new _GraphQLError.GraphQLError( + `Int cannot represent non 32-bit signed integer value: ${valueNode.value}`, + { + nodes: valueNode, + }, + ); + } + + return num; + }, +}); +exports.GraphQLInt = GraphQLInt; +const GraphQLFloat = new _definition.GraphQLScalarType({ + name: 'Float', + description: + 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'boolean') { + return coercedValue ? 1 : 0; + } + + let num = coercedValue; + + if (typeof coercedValue === 'string' && coercedValue !== '') { + num = Number(coercedValue); + } + + if (typeof num !== 'number' || !Number.isFinite(num)) { + throw new _GraphQLError.GraphQLError( + `Float cannot represent non numeric value: ${(0, _inspect.inspect)( + coercedValue, + )}`, + ); + } + + return num; + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'number' || !Number.isFinite(inputValue)) { + throw new _GraphQLError.GraphQLError( + `Float cannot represent non numeric value: ${(0, _inspect.inspect)( + inputValue, + )}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if ( + valueNode.kind !== _kinds.Kind.FLOAT && + valueNode.kind !== _kinds.Kind.INT + ) { + throw new _GraphQLError.GraphQLError( + `Float cannot represent non numeric value: ${(0, _printer.print)( + valueNode, + )}`, + valueNode, + ); + } + + return parseFloat(valueNode.value); + }, +}); +exports.GraphQLFloat = GraphQLFloat; +const GraphQLString = new _definition.GraphQLScalarType({ + name: 'String', + description: + 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); // Serialize string, boolean and number values to a string, but do not + // attempt to coerce object, function, symbol, or other types as strings. + + if (typeof coercedValue === 'string') { + return coercedValue; + } + + if (typeof coercedValue === 'boolean') { + return coercedValue ? 'true' : 'false'; + } + + if (typeof coercedValue === 'number' && Number.isFinite(coercedValue)) { + return coercedValue.toString(); + } + + throw new _GraphQLError.GraphQLError( + `String cannot represent value: ${(0, _inspect.inspect)(outputValue)}`, + ); + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'string') { + throw new _GraphQLError.GraphQLError( + `String cannot represent a non string value: ${(0, _inspect.inspect)( + inputValue, + )}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _kinds.Kind.STRING) { + throw new _GraphQLError.GraphQLError( + `String cannot represent a non string value: ${(0, _printer.print)( + valueNode, + )}`, + { + nodes: valueNode, + }, + ); + } + + return valueNode.value; + }, +}); +exports.GraphQLString = GraphQLString; +const GraphQLBoolean = new _definition.GraphQLScalarType({ + name: 'Boolean', + description: 'The `Boolean` scalar type represents `true` or `false`.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'boolean') { + return coercedValue; + } + + if (Number.isFinite(coercedValue)) { + return coercedValue !== 0; + } + + throw new _GraphQLError.GraphQLError( + `Boolean cannot represent a non boolean value: ${(0, _inspect.inspect)( + coercedValue, + )}`, + ); + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'boolean') { + throw new _GraphQLError.GraphQLError( + `Boolean cannot represent a non boolean value: ${(0, _inspect.inspect)( + inputValue, + )}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _kinds.Kind.BOOLEAN) { + throw new _GraphQLError.GraphQLError( + `Boolean cannot represent a non boolean value: ${(0, _printer.print)( + valueNode, + )}`, + { + nodes: valueNode, + }, + ); + } + + return valueNode.value; + }, +}); +exports.GraphQLBoolean = GraphQLBoolean; +const GraphQLID = new _definition.GraphQLScalarType({ + name: 'ID', + description: + 'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'string') { + return coercedValue; + } + + if (Number.isInteger(coercedValue)) { + return String(coercedValue); + } + + throw new _GraphQLError.GraphQLError( + `ID cannot represent value: ${(0, _inspect.inspect)(outputValue)}`, + ); + }, + + parseValue(inputValue) { + if (typeof inputValue === 'string') { + return inputValue; + } + + if (typeof inputValue === 'number' && Number.isInteger(inputValue)) { + return inputValue.toString(); + } + + throw new _GraphQLError.GraphQLError( + `ID cannot represent value: ${(0, _inspect.inspect)(inputValue)}`, + ); + }, + + parseLiteral(valueNode) { + if ( + valueNode.kind !== _kinds.Kind.STRING && + valueNode.kind !== _kinds.Kind.INT + ) { + throw new _GraphQLError.GraphQLError( + 'ID cannot represent a non-string and non-integer value: ' + + (0, _printer.print)(valueNode), + { + nodes: valueNode, + }, + ); + } + + return valueNode.value; + }, +}); +exports.GraphQLID = GraphQLID; +const specifiedScalarTypes = Object.freeze([ + GraphQLString, + GraphQLInt, + GraphQLFloat, + GraphQLBoolean, + GraphQLID, +]); +exports.specifiedScalarTypes = specifiedScalarTypes; + +function isSpecifiedScalarType(type) { + return specifiedScalarTypes.some(({ name }) => type.name === name); +} // Support serializing objects with custom valueOf() or toJSON() functions - +// a common way to represent a complex value which can be represented as +// a string (ex: MongoDB id objects). + +function serializeObject(outputValue) { + if ((0, _isObjectLike.isObjectLike)(outputValue)) { + if (typeof outputValue.valueOf === 'function') { + const valueOfResult = outputValue.valueOf(); + + if (!(0, _isObjectLike.isObjectLike)(valueOfResult)) { + return valueOfResult; + } + } + + if (typeof outputValue.toJSON === 'function') { + return outputValue.toJSON(); + } + } + + return outputValue; +} + + +/***/ }), + +/***/ 6829: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.GraphQLSchema = void 0; +exports.assertSchema = assertSchema; +exports.isSchema = isSchema; + +var _devAssert = __webpack_require__(7242); + +var _inspect = __webpack_require__(8002); + +var _instanceOf = __webpack_require__(5752); + +var _isObjectLike = __webpack_require__(5690); + +var _toObjMap = __webpack_require__(7690); + +var _ast = __webpack_require__(1807); + +var _definition = __webpack_require__(5003); + +var _directives = __webpack_require__(7197); + +var _introspection = __webpack_require__(8155); + +/** + * Test if the given value is a GraphQL schema. + */ +function isSchema(schema) { + return (0, _instanceOf.instanceOf)(schema, GraphQLSchema); +} + +function assertSchema(schema) { + if (!isSchema(schema)) { + throw new Error( + `Expected ${(0, _inspect.inspect)(schema)} to be a GraphQL schema.`, + ); + } + + return schema; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ + +/** + * Schema Definition + * + * A Schema is created by supplying the root types of each type of operation, + * query and mutation (optional). A schema definition is then supplied to the + * validator and executor. + * + * Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * query: MyAppQueryRootType, + * mutation: MyAppMutationRootType, + * }) + * ``` + * + * Note: When the schema is constructed, by default only the types that are + * reachable by traversing the root types are included, other types must be + * explicitly referenced. + * + * Example: + * + * ```ts + * const characterInterface = new GraphQLInterfaceType({ + * name: 'Character', + * ... + * }); + * + * const humanType = new GraphQLObjectType({ + * name: 'Human', + * interfaces: [characterInterface], + * ... + * }); + * + * const droidType = new GraphQLObjectType({ + * name: 'Droid', + * interfaces: [characterInterface], + * ... + * }); + * + * const schema = new GraphQLSchema({ + * query: new GraphQLObjectType({ + * name: 'Query', + * fields: { + * hero: { type: characterInterface, ... }, + * } + * }), + * ... + * // Since this schema references only the `Character` interface it's + * // necessary to explicitly list the types that implement it if + * // you want them to be included in the final schema. + * types: [humanType, droidType], + * }) + * ``` + * + * Note: If an array of `directives` are provided to GraphQLSchema, that will be + * the exact list of directives represented and allowed. If `directives` is not + * provided then a default set of the specified directives (e.g. `@include` and + * `@skip`) will be used. If you wish to provide *additional* directives to these + * specified directives, you must explicitly declare them. Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * ... + * directives: specifiedDirectives.concat([ myCustomDirective ]), + * }) + * ``` + */ +class GraphQLSchema { + // Used as a cache for validateSchema(). + constructor(config) { + var _config$extensionASTN, _config$directives; + + // If this schema was built from a source known to be valid, then it may be + // marked with assumeValid to avoid an additional type system validation. + this.__validationErrors = config.assumeValid === true ? [] : undefined; // Check for common mistakes during construction to produce early errors. + + (0, _isObjectLike.isObjectLike)(config) || + (0, _devAssert.devAssert)(false, 'Must provide configuration object.'); + !config.types || + Array.isArray(config.types) || + (0, _devAssert.devAssert)( + false, + `"types" must be Array if provided but got: ${(0, _inspect.inspect)( + config.types, + )}.`, + ); + !config.directives || + Array.isArray(config.directives) || + (0, _devAssert.devAssert)( + false, + '"directives" must be Array if provided but got: ' + + `${(0, _inspect.inspect)(config.directives)}.`, + ); + this.description = config.description; + this.extensions = (0, _toObjMap.toObjMap)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN = config.extensionASTNodes) !== null && + _config$extensionASTN !== void 0 + ? _config$extensionASTN + : []; + this._queryType = config.query; + this._mutationType = config.mutation; + this._subscriptionType = config.subscription; // Provide specified directives (e.g. @include and @skip) by default. + + this._directives = + (_config$directives = config.directives) !== null && + _config$directives !== void 0 + ? _config$directives + : _directives.specifiedDirectives; // To preserve order of user-provided types, we add first to add them to + // the set of "collected" types, so `collectReferencedTypes` ignore them. + + const allReferencedTypes = new Set(config.types); + + if (config.types != null) { + for (const type of config.types) { + // When we ready to process this type, we remove it from "collected" types + // and then add it together with all dependent types in the correct position. + allReferencedTypes.delete(type); + collectReferencedTypes(type, allReferencedTypes); + } + } + + if (this._queryType != null) { + collectReferencedTypes(this._queryType, allReferencedTypes); + } + + if (this._mutationType != null) { + collectReferencedTypes(this._mutationType, allReferencedTypes); + } + + if (this._subscriptionType != null) { + collectReferencedTypes(this._subscriptionType, allReferencedTypes); + } + + for (const directive of this._directives) { + // Directives are not validated until validateSchema() is called. + if ((0, _directives.isDirective)(directive)) { + for (const arg of directive.args) { + collectReferencedTypes(arg.type, allReferencedTypes); + } + } + } + + collectReferencedTypes(_introspection.__Schema, allReferencedTypes); // Storing the resulting map for reference by the schema. + + this._typeMap = Object.create(null); + this._subTypeMap = Object.create(null); // Keep track of all implementations by interface name. + + this._implementationsMap = Object.create(null); + + for (const namedType of allReferencedTypes) { + if (namedType == null) { + continue; + } + + const typeName = namedType.name; + typeName || + (0, _devAssert.devAssert)( + false, + 'One of the provided types for building the Schema is missing a name.', + ); + + if (this._typeMap[typeName] !== undefined) { + throw new Error( + `Schema must contain uniquely named types but contains multiple types named "${typeName}".`, + ); + } + + this._typeMap[typeName] = namedType; + + if ((0, _definition.isInterfaceType)(namedType)) { + // Store implementations by interface. + for (const iface of namedType.getInterfaces()) { + if ((0, _definition.isInterfaceType)(iface)) { + let implementations = this._implementationsMap[iface.name]; + + if (implementations === undefined) { + implementations = this._implementationsMap[iface.name] = { + objects: [], + interfaces: [], + }; + } + + implementations.interfaces.push(namedType); + } + } + } else if ((0, _definition.isObjectType)(namedType)) { + // Store implementations by objects. + for (const iface of namedType.getInterfaces()) { + if ((0, _definition.isInterfaceType)(iface)) { + let implementations = this._implementationsMap[iface.name]; + + if (implementations === undefined) { + implementations = this._implementationsMap[iface.name] = { + objects: [], + interfaces: [], + }; + } + + implementations.objects.push(namedType); + } + } + } + } + } + + get [Symbol.toStringTag]() { + return 'GraphQLSchema'; + } + + getQueryType() { + return this._queryType; + } + + getMutationType() { + return this._mutationType; + } + + getSubscriptionType() { + return this._subscriptionType; + } + + getRootType(operation) { + switch (operation) { + case _ast.OperationTypeNode.QUERY: + return this.getQueryType(); + + case _ast.OperationTypeNode.MUTATION: + return this.getMutationType(); + + case _ast.OperationTypeNode.SUBSCRIPTION: + return this.getSubscriptionType(); + } + } + + getTypeMap() { + return this._typeMap; + } + + getType(name) { + return this.getTypeMap()[name]; + } + + getPossibleTypes(abstractType) { + return (0, _definition.isUnionType)(abstractType) + ? abstractType.getTypes() + : this.getImplementations(abstractType).objects; + } + + getImplementations(interfaceType) { + const implementations = this._implementationsMap[interfaceType.name]; + return implementations !== null && implementations !== void 0 + ? implementations + : { + objects: [], + interfaces: [], + }; + } + + isSubType(abstractType, maybeSubType) { + let map = this._subTypeMap[abstractType.name]; + + if (map === undefined) { + map = Object.create(null); + + if ((0, _definition.isUnionType)(abstractType)) { + for (const type of abstractType.getTypes()) { + map[type.name] = true; + } + } else { + const implementations = this.getImplementations(abstractType); + + for (const type of implementations.objects) { + map[type.name] = true; + } + + for (const type of implementations.interfaces) { + map[type.name] = true; + } + } + + this._subTypeMap[abstractType.name] = map; + } + + return map[maybeSubType.name] !== undefined; + } + + getDirectives() { + return this._directives; + } + + getDirective(name) { + return this.getDirectives().find((directive) => directive.name === name); + } + + toConfig() { + return { + description: this.description, + query: this.getQueryType(), + mutation: this.getMutationType(), + subscription: this.getSubscriptionType(), + types: Object.values(this.getTypeMap()), + directives: this.getDirectives(), + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + assumeValid: this.__validationErrors !== undefined, + }; + } +} + +exports.GraphQLSchema = GraphQLSchema; + +function collectReferencedTypes(type, typeSet) { + const namedType = (0, _definition.getNamedType)(type); + + if (!typeSet.has(namedType)) { + typeSet.add(namedType); + + if ((0, _definition.isUnionType)(namedType)) { + for (const memberType of namedType.getTypes()) { + collectReferencedTypes(memberType, typeSet); + } + } else if ( + (0, _definition.isObjectType)(namedType) || + (0, _definition.isInterfaceType)(namedType) + ) { + for (const interfaceType of namedType.getInterfaces()) { + collectReferencedTypes(interfaceType, typeSet); + } + + for (const field of Object.values(namedType.getFields())) { + collectReferencedTypes(field.type, typeSet); + + for (const arg of field.args) { + collectReferencedTypes(arg.type, typeSet); + } + } + } else if ((0, _definition.isInputObjectType)(namedType)) { + for (const field of Object.values(namedType.getFields())) { + collectReferencedTypes(field.type, typeSet); + } + } + } + + return typeSet; +} + + +/***/ }), + +/***/ 1671: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.assertValidSchema = assertValidSchema; +exports.validateSchema = validateSchema; + +var _inspect = __webpack_require__(8002); + +var _GraphQLError = __webpack_require__(5822); + +var _ast = __webpack_require__(1807); + +var _typeComparators = __webpack_require__(298); + +var _definition = __webpack_require__(5003); + +var _directives = __webpack_require__(7197); + +var _introspection = __webpack_require__(8155); + +var _schema = __webpack_require__(6829); + +/** + * Implements the "Type Validation" sub-sections of the specification's + * "Type System" section. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the Schema is valid. + */ +function validateSchema(schema) { + // First check to ensure the provided value is in fact a GraphQLSchema. + (0, _schema.assertSchema)(schema); // If this Schema has already been validated, return the previous results. + + if (schema.__validationErrors) { + return schema.__validationErrors; + } // Validate the schema, producing a list of errors. + + const context = new SchemaValidationContext(schema); + validateRootTypes(context); + validateDirectives(context); + validateTypes(context); // Persist the results of validation before returning to ensure validation + // does not run multiple times for this schema. + + const errors = context.getErrors(); + schema.__validationErrors = errors; + return errors; +} +/** + * Utility function which asserts a schema is valid by throwing an error if + * it is invalid. + */ + +function assertValidSchema(schema) { + const errors = validateSchema(schema); + + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} + +class SchemaValidationContext { + constructor(schema) { + this._errors = []; + this.schema = schema; + } + + reportError(message, nodes) { + const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes; + + this._errors.push( + new _GraphQLError.GraphQLError(message, { + nodes: _nodes, + }), + ); + } + + getErrors() { + return this._errors; + } +} + +function validateRootTypes(context) { + const schema = context.schema; + const queryType = schema.getQueryType(); + + if (!queryType) { + context.reportError('Query root type must be provided.', schema.astNode); + } else if (!(0, _definition.isObjectType)(queryType)) { + var _getOperationTypeNode; + + context.reportError( + `Query root type must be Object type, it cannot be ${(0, + _inspect.inspect)(queryType)}.`, + (_getOperationTypeNode = getOperationTypeNode( + schema, + _ast.OperationTypeNode.QUERY, + )) !== null && _getOperationTypeNode !== void 0 + ? _getOperationTypeNode + : queryType.astNode, + ); + } + + const mutationType = schema.getMutationType(); + + if (mutationType && !(0, _definition.isObjectType)(mutationType)) { + var _getOperationTypeNode2; + + context.reportError( + 'Mutation root type must be Object type if provided, it cannot be ' + + `${(0, _inspect.inspect)(mutationType)}.`, + (_getOperationTypeNode2 = getOperationTypeNode( + schema, + _ast.OperationTypeNode.MUTATION, + )) !== null && _getOperationTypeNode2 !== void 0 + ? _getOperationTypeNode2 + : mutationType.astNode, + ); + } + + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType && !(0, _definition.isObjectType)(subscriptionType)) { + var _getOperationTypeNode3; + + context.reportError( + 'Subscription root type must be Object type if provided, it cannot be ' + + `${(0, _inspect.inspect)(subscriptionType)}.`, + (_getOperationTypeNode3 = getOperationTypeNode( + schema, + _ast.OperationTypeNode.SUBSCRIPTION, + )) !== null && _getOperationTypeNode3 !== void 0 + ? _getOperationTypeNode3 + : subscriptionType.astNode, + ); + } +} + +function getOperationTypeNode(schema, operation) { + var _flatMap$find; + + return (_flatMap$find = [schema.astNode, ...schema.extensionASTNodes] + .flatMap( + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + (schemaNode) => { + var _schemaNode$operation; + + return ( + /* c8 ignore next */ + (_schemaNode$operation = + schemaNode === null || schemaNode === void 0 + ? void 0 + : schemaNode.operationTypes) !== null && + _schemaNode$operation !== void 0 + ? _schemaNode$operation + : [] + ); + }, + ) + .find((operationNode) => operationNode.operation === operation)) === null || + _flatMap$find === void 0 + ? void 0 + : _flatMap$find.type; +} + +function validateDirectives(context) { + for (const directive of context.schema.getDirectives()) { + // Ensure all directives are in fact GraphQL directives. + if (!(0, _directives.isDirective)(directive)) { + context.reportError( + `Expected directive but got: ${(0, _inspect.inspect)(directive)}.`, + directive === null || directive === void 0 ? void 0 : directive.astNode, + ); + continue; + } // Ensure they are named correctly. + + validateName(context, directive); // TODO: Ensure proper locations. + // Ensure the arguments are valid. + + for (const arg of directive.args) { + // Ensure they are named correctly. + validateName(context, arg); // Ensure the type is an input type. + + if (!(0, _definition.isInputType)(arg.type)) { + context.reportError( + `The type of @${directive.name}(${arg.name}:) must be Input Type ` + + `but got: ${(0, _inspect.inspect)(arg.type)}.`, + arg.astNode, + ); + } + + if ( + (0, _definition.isRequiredArgument)(arg) && + arg.deprecationReason != null + ) { + var _arg$astNode; + + context.reportError( + `Required argument @${directive.name}(${arg.name}:) cannot be deprecated.`, + [ + getDeprecatedDirectiveNode(arg.astNode), + (_arg$astNode = arg.astNode) === null || _arg$astNode === void 0 + ? void 0 + : _arg$astNode.type, + ], + ); + } + } + } +} + +function validateName(context, node) { + // Ensure names are valid, however introspection types opt out. + if (node.name.startsWith('__')) { + context.reportError( + `Name "${node.name}" must not begin with "__", which is reserved by GraphQL introspection.`, + node.astNode, + ); + } +} + +function validateTypes(context) { + const validateInputObjectCircularRefs = + createInputObjectCircularRefsValidator(context); + const typeMap = context.schema.getTypeMap(); + + for (const type of Object.values(typeMap)) { + // Ensure all provided types are in fact GraphQL type. + if (!(0, _definition.isNamedType)(type)) { + context.reportError( + `Expected GraphQL named type but got: ${(0, _inspect.inspect)(type)}.`, + type.astNode, + ); + continue; + } // Ensure it is named correctly (excluding introspection types). + + if (!(0, _introspection.isIntrospectionType)(type)) { + validateName(context, type); + } + + if ((0, _definition.isObjectType)(type)) { + // Ensure fields are valid + validateFields(context, type); // Ensure objects implement the interfaces they claim to. + + validateInterfaces(context, type); + } else if ((0, _definition.isInterfaceType)(type)) { + // Ensure fields are valid. + validateFields(context, type); // Ensure interfaces implement the interfaces they claim to. + + validateInterfaces(context, type); + } else if ((0, _definition.isUnionType)(type)) { + // Ensure Unions include valid member types. + validateUnionMembers(context, type); + } else if ((0, _definition.isEnumType)(type)) { + // Ensure Enums have valid values. + validateEnumValues(context, type); + } else if ((0, _definition.isInputObjectType)(type)) { + // Ensure Input Object fields are valid. + validateInputFields(context, type); // Ensure Input Objects do not contain non-nullable circular references + + validateInputObjectCircularRefs(type); + } + } +} + +function validateFields(context, type) { + const fields = Object.values(type.getFields()); // Objects and Interfaces both must define one or more fields. + + if (fields.length === 0) { + context.reportError(`Type ${type.name} must define one or more fields.`, [ + type.astNode, + ...type.extensionASTNodes, + ]); + } + + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); // Ensure the type is an output type + + if (!(0, _definition.isOutputType)(field.type)) { + var _field$astNode; + + context.reportError( + `The type of ${type.name}.${field.name} must be Output Type ` + + `but got: ${(0, _inspect.inspect)(field.type)}.`, + (_field$astNode = field.astNode) === null || _field$astNode === void 0 + ? void 0 + : _field$astNode.type, + ); + } // Ensure the arguments are valid + + for (const arg of field.args) { + const argName = arg.name; // Ensure they are named correctly. + + validateName(context, arg); // Ensure the type is an input type + + if (!(0, _definition.isInputType)(arg.type)) { + var _arg$astNode2; + + context.reportError( + `The type of ${type.name}.${field.name}(${argName}:) must be Input ` + + `Type but got: ${(0, _inspect.inspect)(arg.type)}.`, + (_arg$astNode2 = arg.astNode) === null || _arg$astNode2 === void 0 + ? void 0 + : _arg$astNode2.type, + ); + } + + if ( + (0, _definition.isRequiredArgument)(arg) && + arg.deprecationReason != null + ) { + var _arg$astNode3; + + context.reportError( + `Required argument ${type.name}.${field.name}(${argName}:) cannot be deprecated.`, + [ + getDeprecatedDirectiveNode(arg.astNode), + (_arg$astNode3 = arg.astNode) === null || _arg$astNode3 === void 0 + ? void 0 + : _arg$astNode3.type, + ], + ); + } + } + } +} + +function validateInterfaces(context, type) { + const ifaceTypeNames = Object.create(null); + + for (const iface of type.getInterfaces()) { + if (!(0, _definition.isInterfaceType)(iface)) { + context.reportError( + `Type ${(0, _inspect.inspect)( + type, + )} must only implement Interface types, ` + + `it cannot implement ${(0, _inspect.inspect)(iface)}.`, + getAllImplementsInterfaceNodes(type, iface), + ); + continue; + } + + if (type === iface) { + context.reportError( + `Type ${type.name} cannot implement itself because it would create a circular reference.`, + getAllImplementsInterfaceNodes(type, iface), + ); + continue; + } + + if (ifaceTypeNames[iface.name]) { + context.reportError( + `Type ${type.name} can only implement ${iface.name} once.`, + getAllImplementsInterfaceNodes(type, iface), + ); + continue; + } + + ifaceTypeNames[iface.name] = true; + validateTypeImplementsAncestors(context, type, iface); + validateTypeImplementsInterface(context, type, iface); + } +} + +function validateTypeImplementsInterface(context, type, iface) { + const typeFieldMap = type.getFields(); // Assert each interface field is implemented. + + for (const ifaceField of Object.values(iface.getFields())) { + const fieldName = ifaceField.name; + const typeField = typeFieldMap[fieldName]; // Assert interface field exists on type. + + if (!typeField) { + context.reportError( + `Interface field ${iface.name}.${fieldName} expected but ${type.name} does not provide it.`, + [ifaceField.astNode, type.astNode, ...type.extensionASTNodes], + ); + continue; + } // Assert interface field type is satisfied by type field type, by being + // a valid subtype. (covariant) + + if ( + !(0, _typeComparators.isTypeSubTypeOf)( + context.schema, + typeField.type, + ifaceField.type, + ) + ) { + var _ifaceField$astNode, _typeField$astNode; + + context.reportError( + `Interface field ${iface.name}.${fieldName} expects type ` + + `${(0, _inspect.inspect)(ifaceField.type)} but ${ + type.name + }.${fieldName} ` + + `is type ${(0, _inspect.inspect)(typeField.type)}.`, + [ + (_ifaceField$astNode = ifaceField.astNode) === null || + _ifaceField$astNode === void 0 + ? void 0 + : _ifaceField$astNode.type, + (_typeField$astNode = typeField.astNode) === null || + _typeField$astNode === void 0 + ? void 0 + : _typeField$astNode.type, + ], + ); + } // Assert each interface field arg is implemented. + + for (const ifaceArg of ifaceField.args) { + const argName = ifaceArg.name; + const typeArg = typeField.args.find((arg) => arg.name === argName); // Assert interface field arg exists on object field. + + if (!typeArg) { + context.reportError( + `Interface field argument ${iface.name}.${fieldName}(${argName}:) expected but ${type.name}.${fieldName} does not provide it.`, + [ifaceArg.astNode, typeField.astNode], + ); + continue; + } // Assert interface field arg type matches object field arg type. + // (invariant) + // TODO: change to contravariant? + + if (!(0, _typeComparators.isEqualType)(ifaceArg.type, typeArg.type)) { + var _ifaceArg$astNode, _typeArg$astNode; + + context.reportError( + `Interface field argument ${iface.name}.${fieldName}(${argName}:) ` + + `expects type ${(0, _inspect.inspect)(ifaceArg.type)} but ` + + `${type.name}.${fieldName}(${argName}:) is type ` + + `${(0, _inspect.inspect)(typeArg.type)}.`, + [ + (_ifaceArg$astNode = ifaceArg.astNode) === null || + _ifaceArg$astNode === void 0 + ? void 0 + : _ifaceArg$astNode.type, + (_typeArg$astNode = typeArg.astNode) === null || + _typeArg$astNode === void 0 + ? void 0 + : _typeArg$astNode.type, + ], + ); + } // TODO: validate default values? + } // Assert additional arguments must not be required. + + for (const typeArg of typeField.args) { + const argName = typeArg.name; + const ifaceArg = ifaceField.args.find((arg) => arg.name === argName); + + if (!ifaceArg && (0, _definition.isRequiredArgument)(typeArg)) { + context.reportError( + `Object field ${type.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${iface.name}.${fieldName}.`, + [typeArg.astNode, ifaceField.astNode], + ); + } + } + } +} + +function validateTypeImplementsAncestors(context, type, iface) { + const ifaceInterfaces = type.getInterfaces(); + + for (const transitive of iface.getInterfaces()) { + if (!ifaceInterfaces.includes(transitive)) { + context.reportError( + transitive === type + ? `Type ${type.name} cannot implement ${iface.name} because it would create a circular reference.` + : `Type ${type.name} must implement ${transitive.name} because it is implemented by ${iface.name}.`, + [ + ...getAllImplementsInterfaceNodes(iface, transitive), + ...getAllImplementsInterfaceNodes(type, iface), + ], + ); + } + } +} + +function validateUnionMembers(context, union) { + const memberTypes = union.getTypes(); + + if (memberTypes.length === 0) { + context.reportError( + `Union type ${union.name} must define one or more member types.`, + [union.astNode, ...union.extensionASTNodes], + ); + } + + const includedTypeNames = Object.create(null); + + for (const memberType of memberTypes) { + if (includedTypeNames[memberType.name]) { + context.reportError( + `Union type ${union.name} can only include type ${memberType.name} once.`, + getUnionMemberTypeNodes(union, memberType.name), + ); + continue; + } + + includedTypeNames[memberType.name] = true; + + if (!(0, _definition.isObjectType)(memberType)) { + context.reportError( + `Union type ${union.name} can only include Object types, ` + + `it cannot include ${(0, _inspect.inspect)(memberType)}.`, + getUnionMemberTypeNodes(union, String(memberType)), + ); + } + } +} + +function validateEnumValues(context, enumType) { + const enumValues = enumType.getValues(); + + if (enumValues.length === 0) { + context.reportError( + `Enum type ${enumType.name} must define one or more values.`, + [enumType.astNode, ...enumType.extensionASTNodes], + ); + } + + for (const enumValue of enumValues) { + // Ensure valid name. + validateName(context, enumValue); + } +} + +function validateInputFields(context, inputObj) { + const fields = Object.values(inputObj.getFields()); + + if (fields.length === 0) { + context.reportError( + `Input Object type ${inputObj.name} must define one or more fields.`, + [inputObj.astNode, ...inputObj.extensionASTNodes], + ); + } // Ensure the arguments are valid + + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); // Ensure the type is an input type + + if (!(0, _definition.isInputType)(field.type)) { + var _field$astNode2; + + context.reportError( + `The type of ${inputObj.name}.${field.name} must be Input Type ` + + `but got: ${(0, _inspect.inspect)(field.type)}.`, + (_field$astNode2 = field.astNode) === null || _field$astNode2 === void 0 + ? void 0 + : _field$astNode2.type, + ); + } + + if ( + (0, _definition.isRequiredInputField)(field) && + field.deprecationReason != null + ) { + var _field$astNode3; + + context.reportError( + `Required input field ${inputObj.name}.${field.name} cannot be deprecated.`, + [ + getDeprecatedDirectiveNode(field.astNode), + (_field$astNode3 = field.astNode) === null || + _field$astNode3 === void 0 + ? void 0 + : _field$astNode3.type, + ], + ); + } + } +} + +function createInputObjectCircularRefsValidator(context) { + // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'. + // Tracks already visited types to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedTypes = Object.create(null); // Array of types nodes used to produce meaningful errors + + const fieldPath = []; // Position in the type path + + const fieldPathIndexByTypeName = Object.create(null); + return detectCycleRecursive; // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + + function detectCycleRecursive(inputObj) { + if (visitedTypes[inputObj.name]) { + return; + } + + visitedTypes[inputObj.name] = true; + fieldPathIndexByTypeName[inputObj.name] = fieldPath.length; + const fields = Object.values(inputObj.getFields()); + + for (const field of fields) { + if ( + (0, _definition.isNonNullType)(field.type) && + (0, _definition.isInputObjectType)(field.type.ofType) + ) { + const fieldType = field.type.ofType; + const cycleIndex = fieldPathIndexByTypeName[fieldType.name]; + fieldPath.push(field); + + if (cycleIndex === undefined) { + detectCycleRecursive(fieldType); + } else { + const cyclePath = fieldPath.slice(cycleIndex); + const pathStr = cyclePath.map((fieldObj) => fieldObj.name).join('.'); + context.reportError( + `Cannot reference Input Object "${fieldType.name}" within itself through a series of non-null fields: "${pathStr}".`, + cyclePath.map((fieldObj) => fieldObj.astNode), + ); + } + + fieldPath.pop(); + } + } + + fieldPathIndexByTypeName[inputObj.name] = undefined; + } +} + +function getAllImplementsInterfaceNodes(type, iface) { + const { astNode, extensionASTNodes } = type; + const nodes = + astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + return nodes + .flatMap((typeNode) => { + var _typeNode$interfaces; + + return ( + /* c8 ignore next */ + (_typeNode$interfaces = typeNode.interfaces) !== null && + _typeNode$interfaces !== void 0 + ? _typeNode$interfaces + : [] + ); + }) + .filter((ifaceNode) => ifaceNode.name.value === iface.name); +} + +function getUnionMemberTypeNodes(union, typeName) { + const { astNode, extensionASTNodes } = union; + const nodes = + astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + return nodes + .flatMap((unionNode) => { + var _unionNode$types; + + return ( + /* c8 ignore next */ + (_unionNode$types = unionNode.types) !== null && + _unionNode$types !== void 0 + ? _unionNode$types + : [] + ); + }) + .filter((typeNode) => typeNode.name.value === typeName); +} + +function getDeprecatedDirectiveNode(definitionNode) { + var _definitionNode$direc; + + return definitionNode === null || definitionNode === void 0 + ? void 0 + : (_definitionNode$direc = definitionNode.directives) === null || + _definitionNode$direc === void 0 + ? void 0 + : _definitionNode$direc.find( + (node) => + node.name.value === _directives.GraphQLDeprecatedDirective.name, + ); +} + + +/***/ }), + +/***/ 6226: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.TypeInfo = void 0; +exports.visitWithTypeInfo = visitWithTypeInfo; + +var _ast = __webpack_require__(1807); + +var _kinds = __webpack_require__(2828); + +var _visitor = __webpack_require__(285); + +var _definition = __webpack_require__(5003); + +var _introspection = __webpack_require__(8155); + +var _typeFromAST = __webpack_require__(5115); + +/** + * TypeInfo is a utility class which, given a GraphQL schema, can keep track + * of the current field and type definitions at any point in a GraphQL document + * AST during a recursive descent by calling `enter(node)` and `leave(node)`. + */ +class TypeInfo { + constructor( + schema, + /** + * Initial type may be provided in rare cases to facilitate traversals + * beginning somewhere other than documents. + */ + initialType, + /** @deprecated will be removed in 17.0.0 */ + getFieldDefFn, + ) { + this._schema = schema; + this._typeStack = []; + this._parentTypeStack = []; + this._inputTypeStack = []; + this._fieldDefStack = []; + this._defaultValueStack = []; + this._directive = null; + this._argument = null; + this._enumValue = null; + this._getFieldDef = + getFieldDefFn !== null && getFieldDefFn !== void 0 + ? getFieldDefFn + : getFieldDef; + + if (initialType) { + if ((0, _definition.isInputType)(initialType)) { + this._inputTypeStack.push(initialType); + } + + if ((0, _definition.isCompositeType)(initialType)) { + this._parentTypeStack.push(initialType); + } + + if ((0, _definition.isOutputType)(initialType)) { + this._typeStack.push(initialType); + } + } + } + + get [Symbol.toStringTag]() { + return 'TypeInfo'; + } + + getType() { + if (this._typeStack.length > 0) { + return this._typeStack[this._typeStack.length - 1]; + } + } + + getParentType() { + if (this._parentTypeStack.length > 0) { + return this._parentTypeStack[this._parentTypeStack.length - 1]; + } + } + + getInputType() { + if (this._inputTypeStack.length > 0) { + return this._inputTypeStack[this._inputTypeStack.length - 1]; + } + } + + getParentInputType() { + if (this._inputTypeStack.length > 1) { + return this._inputTypeStack[this._inputTypeStack.length - 2]; + } + } + + getFieldDef() { + if (this._fieldDefStack.length > 0) { + return this._fieldDefStack[this._fieldDefStack.length - 1]; + } + } + + getDefaultValue() { + if (this._defaultValueStack.length > 0) { + return this._defaultValueStack[this._defaultValueStack.length - 1]; + } + } + + getDirective() { + return this._directive; + } + + getArgument() { + return this._argument; + } + + getEnumValue() { + return this._enumValue; + } + + enter(node) { + const schema = this._schema; // Note: many of the types below are explicitly typed as "unknown" to drop + // any assumptions of a valid schema to ensure runtime types are properly + // checked before continuing since TypeInfo is used as part of validation + // which occurs before guarantees of schema and document validity. + + switch (node.kind) { + case _kinds.Kind.SELECTION_SET: { + const namedType = (0, _definition.getNamedType)(this.getType()); + + this._parentTypeStack.push( + (0, _definition.isCompositeType)(namedType) ? namedType : undefined, + ); + + break; + } + + case _kinds.Kind.FIELD: { + const parentType = this.getParentType(); + let fieldDef; + let fieldType; + + if (parentType) { + fieldDef = this._getFieldDef(schema, parentType, node); + + if (fieldDef) { + fieldType = fieldDef.type; + } + } + + this._fieldDefStack.push(fieldDef); + + this._typeStack.push( + (0, _definition.isOutputType)(fieldType) ? fieldType : undefined, + ); + + break; + } + + case _kinds.Kind.DIRECTIVE: + this._directive = schema.getDirective(node.name.value); + break; + + case _kinds.Kind.OPERATION_DEFINITION: { + const rootType = schema.getRootType(node.operation); + + this._typeStack.push( + (0, _definition.isObjectType)(rootType) ? rootType : undefined, + ); + + break; + } + + case _kinds.Kind.INLINE_FRAGMENT: + case _kinds.Kind.FRAGMENT_DEFINITION: { + const typeConditionAST = node.typeCondition; + const outputType = typeConditionAST + ? (0, _typeFromAST.typeFromAST)(schema, typeConditionAST) + : (0, _definition.getNamedType)(this.getType()); + + this._typeStack.push( + (0, _definition.isOutputType)(outputType) ? outputType : undefined, + ); + + break; + } + + case _kinds.Kind.VARIABLE_DEFINITION: { + const inputType = (0, _typeFromAST.typeFromAST)(schema, node.type); + + this._inputTypeStack.push( + (0, _definition.isInputType)(inputType) ? inputType : undefined, + ); + + break; + } + + case _kinds.Kind.ARGUMENT: { + var _this$getDirective; + + let argDef; + let argType; + const fieldOrDirective = + (_this$getDirective = this.getDirective()) !== null && + _this$getDirective !== void 0 + ? _this$getDirective + : this.getFieldDef(); + + if (fieldOrDirective) { + argDef = fieldOrDirective.args.find( + (arg) => arg.name === node.name.value, + ); + + if (argDef) { + argType = argDef.type; + } + } + + this._argument = argDef; + + this._defaultValueStack.push(argDef ? argDef.defaultValue : undefined); + + this._inputTypeStack.push( + (0, _definition.isInputType)(argType) ? argType : undefined, + ); + + break; + } + + case _kinds.Kind.LIST: { + const listType = (0, _definition.getNullableType)(this.getInputType()); + const itemType = (0, _definition.isListType)(listType) + ? listType.ofType + : listType; // List positions never have a default value. + + this._defaultValueStack.push(undefined); + + this._inputTypeStack.push( + (0, _definition.isInputType)(itemType) ? itemType : undefined, + ); + + break; + } + + case _kinds.Kind.OBJECT_FIELD: { + const objectType = (0, _definition.getNamedType)(this.getInputType()); + let inputFieldType; + let inputField; + + if ((0, _definition.isInputObjectType)(objectType)) { + inputField = objectType.getFields()[node.name.value]; + + if (inputField) { + inputFieldType = inputField.type; + } + } + + this._defaultValueStack.push( + inputField ? inputField.defaultValue : undefined, + ); + + this._inputTypeStack.push( + (0, _definition.isInputType)(inputFieldType) + ? inputFieldType + : undefined, + ); + + break; + } + + case _kinds.Kind.ENUM: { + const enumType = (0, _definition.getNamedType)(this.getInputType()); + let enumValue; + + if ((0, _definition.isEnumType)(enumType)) { + enumValue = enumType.getValue(node.value); + } + + this._enumValue = enumValue; + break; + } + + default: // Ignore other nodes + } + } + + leave(node) { + switch (node.kind) { + case _kinds.Kind.SELECTION_SET: + this._parentTypeStack.pop(); + + break; + + case _kinds.Kind.FIELD: + this._fieldDefStack.pop(); + + this._typeStack.pop(); + + break; + + case _kinds.Kind.DIRECTIVE: + this._directive = null; + break; + + case _kinds.Kind.OPERATION_DEFINITION: + case _kinds.Kind.INLINE_FRAGMENT: + case _kinds.Kind.FRAGMENT_DEFINITION: + this._typeStack.pop(); + + break; + + case _kinds.Kind.VARIABLE_DEFINITION: + this._inputTypeStack.pop(); + + break; + + case _kinds.Kind.ARGUMENT: + this._argument = null; + + this._defaultValueStack.pop(); + + this._inputTypeStack.pop(); + + break; + + case _kinds.Kind.LIST: + case _kinds.Kind.OBJECT_FIELD: + this._defaultValueStack.pop(); + + this._inputTypeStack.pop(); + + break; + + case _kinds.Kind.ENUM: + this._enumValue = null; + break; + + default: // Ignore other nodes + } + } +} + +exports.TypeInfo = TypeInfo; + +/** + * Not exactly the same as the executor's definition of getFieldDef, in this + * statically evaluated environment we do not always have an Object type, + * and need to handle Interface and Union types. + */ +function getFieldDef(schema, parentType, fieldNode) { + const name = fieldNode.name.value; + + if ( + name === _introspection.SchemaMetaFieldDef.name && + schema.getQueryType() === parentType + ) { + return _introspection.SchemaMetaFieldDef; + } + + if ( + name === _introspection.TypeMetaFieldDef.name && + schema.getQueryType() === parentType + ) { + return _introspection.TypeMetaFieldDef; + } + + if ( + name === _introspection.TypeNameMetaFieldDef.name && + (0, _definition.isCompositeType)(parentType) + ) { + return _introspection.TypeNameMetaFieldDef; + } + + if ( + (0, _definition.isObjectType)(parentType) || + (0, _definition.isInterfaceType)(parentType) + ) { + return parentType.getFields()[name]; + } +} +/** + * Creates a new visitor instance which maintains a provided TypeInfo instance + * along with visiting visitor. + */ + +function visitWithTypeInfo(typeInfo, visitor) { + return { + enter(...args) { + const node = args[0]; + typeInfo.enter(node); + const fn = (0, _visitor.getEnterLeaveForKind)(visitor, node.kind).enter; + + if (fn) { + const result = fn.apply(visitor, args); + + if (result !== undefined) { + typeInfo.leave(node); + + if ((0, _ast.isNode)(result)) { + typeInfo.enter(result); + } + } + + return result; + } + }, + + leave(...args) { + const node = args[0]; + const fn = (0, _visitor.getEnterLeaveForKind)(visitor, node.kind).leave; + let result; + + if (fn) { + result = fn.apply(visitor, args); + } + + typeInfo.leave(node); + return result; + }, + }; +} + + +/***/ }), + +/***/ 8115: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.astFromValue = astFromValue; + +var _inspect = __webpack_require__(8002); + +var _invariant = __webpack_require__(7706); + +var _isIterableObject = __webpack_require__(6609); + +var _isObjectLike = __webpack_require__(5690); + +var _kinds = __webpack_require__(2828); + +var _definition = __webpack_require__(5003); + +var _scalars = __webpack_require__(2229); + +/** + * Produces a GraphQL Value AST given a JavaScript object. + * Function will match JavaScript/JSON values to GraphQL AST schema format + * by using suggested GraphQLInputType. For example: + * + * astFromValue("value", GraphQLString) + * + * A GraphQL type must be provided, which will be used to interpret different + * JavaScript values. + * + * | JSON Value | GraphQL Value | + * | ------------- | -------------------- | + * | Object | Input Object | + * | Array | List | + * | Boolean | Boolean | + * | String | String / Enum Value | + * | Number | Int / Float | + * | Unknown | Enum Value | + * | null | NullValue | + * + */ +function astFromValue(value, type) { + if ((0, _definition.isNonNullType)(type)) { + const astValue = astFromValue(value, type.ofType); + + if ( + (astValue === null || astValue === void 0 ? void 0 : astValue.kind) === + _kinds.Kind.NULL + ) { + return null; + } + + return astValue; + } // only explicit null, not undefined, NaN + + if (value === null) { + return { + kind: _kinds.Kind.NULL, + }; + } // undefined + + if (value === undefined) { + return null; + } // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but + // the value is not an array, convert the value using the list's item type. + + if ((0, _definition.isListType)(type)) { + const itemType = type.ofType; + + if ((0, _isIterableObject.isIterableObject)(value)) { + const valuesNodes = []; + + for (const item of value) { + const itemNode = astFromValue(item, itemType); + + if (itemNode != null) { + valuesNodes.push(itemNode); + } + } + + return { + kind: _kinds.Kind.LIST, + values: valuesNodes, + }; + } + + return astFromValue(value, itemType); + } // Populate the fields of the input object by creating ASTs from each value + // in the JavaScript object according to the fields in the input type. + + if ((0, _definition.isInputObjectType)(type)) { + if (!(0, _isObjectLike.isObjectLike)(value)) { + return null; + } + + const fieldNodes = []; + + for (const field of Object.values(type.getFields())) { + const fieldValue = astFromValue(value[field.name], field.type); + + if (fieldValue) { + fieldNodes.push({ + kind: _kinds.Kind.OBJECT_FIELD, + name: { + kind: _kinds.Kind.NAME, + value: field.name, + }, + value: fieldValue, + }); + } + } + + return { + kind: _kinds.Kind.OBJECT, + fields: fieldNodes, + }; + } + + if ((0, _definition.isLeafType)(type)) { + // Since value is an internally represented value, it must be serialized + // to an externally represented value before converting into an AST. + const serialized = type.serialize(value); + + if (serialized == null) { + return null; + } // Others serialize based on their corresponding JavaScript scalar types. + + if (typeof serialized === 'boolean') { + return { + kind: _kinds.Kind.BOOLEAN, + value: serialized, + }; + } // JavaScript numbers can be Int or Float values. + + if (typeof serialized === 'number' && Number.isFinite(serialized)) { + const stringNum = String(serialized); + return integerStringRegExp.test(stringNum) + ? { + kind: _kinds.Kind.INT, + value: stringNum, + } + : { + kind: _kinds.Kind.FLOAT, + value: stringNum, + }; + } + + if (typeof serialized === 'string') { + // Enum types use Enum literals. + if ((0, _definition.isEnumType)(type)) { + return { + kind: _kinds.Kind.ENUM, + value: serialized, + }; + } // ID types can use Int literals. + + if (type === _scalars.GraphQLID && integerStringRegExp.test(serialized)) { + return { + kind: _kinds.Kind.INT, + value: serialized, + }; + } + + return { + kind: _kinds.Kind.STRING, + value: serialized, + }; + } + + throw new TypeError( + `Cannot convert value to AST: ${(0, _inspect.inspect)(serialized)}.`, + ); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected input type: ' + (0, _inspect.inspect)(type), + ); +} +/** + * IntValue: + * - NegativeSign? 0 + * - NegativeSign? NonZeroDigit ( Digit+ )? + */ + +const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/; + + +/***/ }), + +/***/ 3679: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.coerceInputValue = coerceInputValue; + +var _didYouMean = __webpack_require__(100); + +var _inspect = __webpack_require__(8002); + +var _invariant = __webpack_require__(7706); + +var _isIterableObject = __webpack_require__(6609); + +var _isObjectLike = __webpack_require__(5690); + +var _Path = __webpack_require__(7059); + +var _printPathArray = __webpack_require__(737); + +var _suggestionList = __webpack_require__(8070); + +var _GraphQLError = __webpack_require__(5822); + +var _definition = __webpack_require__(5003); + +/** + * Coerces a JavaScript value given a GraphQL Input Type. + */ +function coerceInputValue(inputValue, type, onError = defaultOnError) { + return coerceInputValueImpl(inputValue, type, onError, undefined); +} + +function defaultOnError(path, invalidValue, error) { + let errorPrefix = 'Invalid value ' + (0, _inspect.inspect)(invalidValue); + + if (path.length > 0) { + errorPrefix += ` at "value${(0, _printPathArray.printPathArray)(path)}"`; + } + + error.message = errorPrefix + ': ' + error.message; + throw error; +} + +function coerceInputValueImpl(inputValue, type, onError, path) { + if ((0, _definition.isNonNullType)(type)) { + if (inputValue != null) { + return coerceInputValueImpl(inputValue, type.ofType, onError, path); + } + + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Expected non-nullable type "${(0, _inspect.inspect)( + type, + )}" not to be null.`, + ), + ); + return; + } + + if (inputValue == null) { + // Explicitly return the value null. + return null; + } + + if ((0, _definition.isListType)(type)) { + const itemType = type.ofType; + + if ((0, _isIterableObject.isIterableObject)(inputValue)) { + return Array.from(inputValue, (itemValue, index) => { + const itemPath = (0, _Path.addPath)(path, index, undefined); + return coerceInputValueImpl(itemValue, itemType, onError, itemPath); + }); + } // Lists accept a non-list value as a list of one. + + return [coerceInputValueImpl(inputValue, itemType, onError, path)]; + } + + if ((0, _definition.isInputObjectType)(type)) { + if (!(0, _isObjectLike.isObjectLike)(inputValue)) { + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Expected type "${type.name}" to be an object.`, + ), + ); + return; + } + + const coercedValue = {}; + const fieldDefs = type.getFields(); + + for (const field of Object.values(fieldDefs)) { + const fieldValue = inputValue[field.name]; + + if (fieldValue === undefined) { + if (field.defaultValue !== undefined) { + coercedValue[field.name] = field.defaultValue; + } else if ((0, _definition.isNonNullType)(field.type)) { + const typeStr = (0, _inspect.inspect)(field.type); + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Field "${field.name}" of required type "${typeStr}" was not provided.`, + ), + ); + } + + continue; + } + + coercedValue[field.name] = coerceInputValueImpl( + fieldValue, + field.type, + onError, + (0, _Path.addPath)(path, field.name, type.name), + ); + } // Ensure every provided field is defined. + + for (const fieldName of Object.keys(inputValue)) { + if (!fieldDefs[fieldName]) { + const suggestions = (0, _suggestionList.suggestionList)( + fieldName, + Object.keys(type.getFields()), + ); + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Field "${fieldName}" is not defined by type "${type.name}".` + + (0, _didYouMean.didYouMean)(suggestions), + ), + ); + } + } + + return coercedValue; + } + + if ((0, _definition.isLeafType)(type)) { + let parseResult; // Scalars and Enums determine if a input value is valid via parseValue(), + // which can throw to indicate failure. If it throws, maintain a reference + // to the original error. + + try { + parseResult = type.parseValue(inputValue); + } catch (error) { + if (error instanceof _GraphQLError.GraphQLError) { + onError((0, _Path.pathToArray)(path), inputValue, error); + } else { + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError( + `Expected type "${type.name}". ` + error.message, + { + originalError: error, + }, + ), + ); + } + + return; + } + + if (parseResult === undefined) { + onError( + (0, _Path.pathToArray)(path), + inputValue, + new _GraphQLError.GraphQLError(`Expected type "${type.name}".`), + ); + } + + return parseResult; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected input type: ' + (0, _inspect.inspect)(type), + ); +} + + +/***/ }), + +/***/ 6830: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.sortValueNode = sortValueNode; + +var _naturalCompare = __webpack_require__(5250); + +var _kinds = __webpack_require__(2828); + +/** + * Sort ValueNode. + * + * This function returns a sorted copy of the given ValueNode. + * + * @internal + */ +function sortValueNode(valueNode) { + switch (valueNode.kind) { + case _kinds.Kind.OBJECT: + return { ...valueNode, fields: sortFields(valueNode.fields) }; + + case _kinds.Kind.LIST: + return { ...valueNode, values: valueNode.values.map(sortValueNode) }; + + case _kinds.Kind.INT: + case _kinds.Kind.FLOAT: + case _kinds.Kind.STRING: + case _kinds.Kind.BOOLEAN: + case _kinds.Kind.NULL: + case _kinds.Kind.ENUM: + case _kinds.Kind.VARIABLE: + return valueNode; + } +} + +function sortFields(fields) { + return fields + .map((fieldNode) => ({ + ...fieldNode, + value: sortValueNode(fieldNode.value), + })) + .sort((fieldA, fieldB) => + (0, _naturalCompare.naturalCompare)(fieldA.name.value, fieldB.name.value), + ); +} + + +/***/ }), + +/***/ 298: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.doTypesOverlap = doTypesOverlap; +exports.isEqualType = isEqualType; +exports.isTypeSubTypeOf = isTypeSubTypeOf; + +var _definition = __webpack_require__(5003); + +/** + * Provided two types, return true if the types are equal (invariant). + */ +function isEqualType(typeA, typeB) { + // Equivalent types are equal. + if (typeA === typeB) { + return true; + } // If either type is non-null, the other must also be non-null. + + if ( + (0, _definition.isNonNullType)(typeA) && + (0, _definition.isNonNullType)(typeB) + ) { + return isEqualType(typeA.ofType, typeB.ofType); + } // If either type is a list, the other must also be a list. + + if ( + (0, _definition.isListType)(typeA) && + (0, _definition.isListType)(typeB) + ) { + return isEqualType(typeA.ofType, typeB.ofType); + } // Otherwise the types are not equal. + + return false; +} +/** + * Provided a type and a super type, return true if the first type is either + * equal or a subset of the second super type (covariant). + */ + +function isTypeSubTypeOf(schema, maybeSubType, superType) { + // Equivalent type is a valid subtype + if (maybeSubType === superType) { + return true; + } // If superType is non-null, maybeSubType must also be non-null. + + if ((0, _definition.isNonNullType)(superType)) { + if ((0, _definition.isNonNullType)(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } + + return false; + } + + if ((0, _definition.isNonNullType)(maybeSubType)) { + // If superType is nullable, maybeSubType may be non-null or nullable. + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType); + } // If superType type is a list, maybeSubType type must also be a list. + + if ((0, _definition.isListType)(superType)) { + if ((0, _definition.isListType)(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } + + return false; + } + + if ((0, _definition.isListType)(maybeSubType)) { + // If superType is not a list, maybeSubType must also be not a list. + return false; + } // If superType type is an abstract type, check if it is super type of maybeSubType. + // Otherwise, the child type is not a valid subtype of the parent type. + + return ( + (0, _definition.isAbstractType)(superType) && + ((0, _definition.isInterfaceType)(maybeSubType) || + (0, _definition.isObjectType)(maybeSubType)) && + schema.isSubType(superType, maybeSubType) + ); +} +/** + * Provided two composite types, determine if they "overlap". Two composite + * types overlap when the Sets of possible concrete types for each intersect. + * + * This is often used to determine if a fragment of a given type could possibly + * be visited in a context of another type. + * + * This function is commutative. + */ + +function doTypesOverlap(schema, typeA, typeB) { + // Equivalent types overlap + if (typeA === typeB) { + return true; + } + + if ((0, _definition.isAbstractType)(typeA)) { + if ((0, _definition.isAbstractType)(typeB)) { + // If both types are abstract, then determine if there is any intersection + // between possible concrete types of each. + return schema + .getPossibleTypes(typeA) + .some((type) => schema.isSubType(typeB, type)); + } // Determine if the latter type is a possible concrete type of the former. + + return schema.isSubType(typeA, typeB); + } + + if ((0, _definition.isAbstractType)(typeB)) { + // Determine if the former type is a possible concrete type of the latter. + return schema.isSubType(typeB, typeA); + } // Otherwise the types do not overlap. + + return false; +} + + +/***/ }), + +/***/ 5115: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.typeFromAST = typeFromAST; + +var _kinds = __webpack_require__(2828); + +var _definition = __webpack_require__(5003); + +function typeFromAST(schema, typeNode) { + switch (typeNode.kind) { + case _kinds.Kind.LIST_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new _definition.GraphQLList(innerType); + } + + case _kinds.Kind.NON_NULL_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new _definition.GraphQLNonNull(innerType); + } + + case _kinds.Kind.NAMED_TYPE: + return schema.getType(typeNode.name.value); + } +} + + +/***/ }), + +/***/ 3770: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.valueFromAST = valueFromAST; + +var _inspect = __webpack_require__(8002); + +var _invariant = __webpack_require__(7706); + +var _keyMap = __webpack_require__(2863); + +var _kinds = __webpack_require__(2828); + +var _definition = __webpack_require__(5003); + +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * A GraphQL type must be provided, which will be used to interpret different + * GraphQL Value literals. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + * + * | GraphQL Value | JSON Value | + * | -------------------- | ------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String | String | + * | Int / Float | Number | + * | Enum Value | Unknown | + * | NullValue | null | + * + */ +function valueFromAST(valueNode, type, variables) { + if (!valueNode) { + // When there is no node, then there is also no value. + // Importantly, this is different from returning the value null. + return; + } + + if (valueNode.kind === _kinds.Kind.VARIABLE) { + const variableName = valueNode.name.value; + + if (variables == null || variables[variableName] === undefined) { + // No valid return value. + return; + } + + const variableValue = variables[variableName]; + + if (variableValue === null && (0, _definition.isNonNullType)(type)) { + return; // Invalid: intentionally return no value. + } // Note: This does no further checking that this variable is correct. + // This assumes that this query has been validated and the variable + // usage here is of the correct type. + + return variableValue; + } + + if ((0, _definition.isNonNullType)(type)) { + if (valueNode.kind === _kinds.Kind.NULL) { + return; // Invalid: intentionally return no value. + } + + return valueFromAST(valueNode, type.ofType, variables); + } + + if (valueNode.kind === _kinds.Kind.NULL) { + // This is explicitly returning the value null. + return null; + } + + if ((0, _definition.isListType)(type)) { + const itemType = type.ofType; + + if (valueNode.kind === _kinds.Kind.LIST) { + const coercedValues = []; + + for (const itemNode of valueNode.values) { + if (isMissingVariable(itemNode, variables)) { + // If an array contains a missing variable, it is either coerced to + // null or if the item type is non-null, it considered invalid. + if ((0, _definition.isNonNullType)(itemType)) { + return; // Invalid: intentionally return no value. + } + + coercedValues.push(null); + } else { + const itemValue = valueFromAST(itemNode, itemType, variables); + + if (itemValue === undefined) { + return; // Invalid: intentionally return no value. + } + + coercedValues.push(itemValue); + } + } + + return coercedValues; + } + + const coercedValue = valueFromAST(valueNode, itemType, variables); + + if (coercedValue === undefined) { + return; // Invalid: intentionally return no value. + } + + return [coercedValue]; + } + + if ((0, _definition.isInputObjectType)(type)) { + if (valueNode.kind !== _kinds.Kind.OBJECT) { + return; // Invalid: intentionally return no value. + } + + const coercedObj = Object.create(null); + const fieldNodes = (0, _keyMap.keyMap)( + valueNode.fields, + (field) => field.name.value, + ); + + for (const field of Object.values(type.getFields())) { + const fieldNode = fieldNodes[field.name]; + + if (!fieldNode || isMissingVariable(fieldNode.value, variables)) { + if (field.defaultValue !== undefined) { + coercedObj[field.name] = field.defaultValue; + } else if ((0, _definition.isNonNullType)(field.type)) { + return; // Invalid: intentionally return no value. + } + + continue; + } + + const fieldValue = valueFromAST(fieldNode.value, field.type, variables); + + if (fieldValue === undefined) { + return; // Invalid: intentionally return no value. + } + + coercedObj[field.name] = fieldValue; + } + + return coercedObj; + } + + if ((0, _definition.isLeafType)(type)) { + // Scalars and Enums fulfill parsing a literal value via parseLiteral(). + // Invalid values represent a failure to parse correctly, in which case + // no value is returned. + let result; + + try { + result = type.parseLiteral(valueNode, variables); + } catch (_error) { + return; // Invalid: intentionally return no value. + } + + if (result === undefined) { + return; // Invalid: intentionally return no value. + } + + return result; + } + /* c8 ignore next 3 */ + // Not reachable, all possible input types have been considered. + + false || + (0, _invariant.invariant)( + false, + 'Unexpected input type: ' + (0, _inspect.inspect)(type), + ); +} // Returns true if the provided valueNode is a variable which is not defined +// in the set of variables. + +function isMissingVariable(valueNode, variables) { + return ( + valueNode.kind === _kinds.Kind.VARIABLE && + (variables == null || variables[valueNode.name.value] === undefined) + ); +} + + +/***/ }), + +/***/ 7784: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.valueFromASTUntyped = valueFromASTUntyped; + +var _keyValMap = __webpack_require__(7154); + +var _kinds = __webpack_require__(2828); + +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value + * will reflect the provided GraphQL value AST. + * + * | GraphQL Value | JavaScript Value | + * | -------------------- | ---------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String / Enum | String | + * | Int / Float | Number | + * | Null | null | + * + */ +function valueFromASTUntyped(valueNode, variables) { + switch (valueNode.kind) { + case _kinds.Kind.NULL: + return null; + + case _kinds.Kind.INT: + return parseInt(valueNode.value, 10); + + case _kinds.Kind.FLOAT: + return parseFloat(valueNode.value); + + case _kinds.Kind.STRING: + case _kinds.Kind.ENUM: + case _kinds.Kind.BOOLEAN: + return valueNode.value; + + case _kinds.Kind.LIST: + return valueNode.values.map((node) => + valueFromASTUntyped(node, variables), + ); + + case _kinds.Kind.OBJECT: + return (0, _keyValMap.keyValMap)( + valueNode.fields, + (field) => field.name.value, + (field) => valueFromASTUntyped(field.value, variables), + ); + + case _kinds.Kind.VARIABLE: + return variables === null || variables === void 0 + ? void 0 + : variables[valueNode.name.value]; + } +} + + +/***/ }), + +/***/ 3955: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ValidationContext = + exports.SDLValidationContext = + exports.ASTValidationContext = + void 0; + +var _kinds = __webpack_require__(2828); + +var _visitor = __webpack_require__(285); + +var _TypeInfo = __webpack_require__(6226); + +/** + * An instance of this class is passed as the "this" context to all validators, + * allowing access to commonly useful contextual information from within a + * validation rule. + */ +class ASTValidationContext { + constructor(ast, onError) { + this._ast = ast; + this._fragments = undefined; + this._fragmentSpreads = new Map(); + this._recursivelyReferencedFragments = new Map(); + this._onError = onError; + } + + get [Symbol.toStringTag]() { + return 'ASTValidationContext'; + } + + reportError(error) { + this._onError(error); + } + + getDocument() { + return this._ast; + } + + getFragment(name) { + let fragments; + + if (this._fragments) { + fragments = this._fragments; + } else { + fragments = Object.create(null); + + for (const defNode of this.getDocument().definitions) { + if (defNode.kind === _kinds.Kind.FRAGMENT_DEFINITION) { + fragments[defNode.name.value] = defNode; + } + } + + this._fragments = fragments; + } + + return fragments[name]; + } + + getFragmentSpreads(node) { + let spreads = this._fragmentSpreads.get(node); + + if (!spreads) { + spreads = []; + const setsToVisit = [node]; + let set; + + while ((set = setsToVisit.pop())) { + for (const selection of set.selections) { + if (selection.kind === _kinds.Kind.FRAGMENT_SPREAD) { + spreads.push(selection); + } else if (selection.selectionSet) { + setsToVisit.push(selection.selectionSet); + } + } + } + + this._fragmentSpreads.set(node, spreads); + } + + return spreads; + } + + getRecursivelyReferencedFragments(operation) { + let fragments = this._recursivelyReferencedFragments.get(operation); + + if (!fragments) { + fragments = []; + const collectedNames = Object.create(null); + const nodesToVisit = [operation.selectionSet]; + let node; + + while ((node = nodesToVisit.pop())) { + for (const spread of this.getFragmentSpreads(node)) { + const fragName = spread.name.value; + + if (collectedNames[fragName] !== true) { + collectedNames[fragName] = true; + const fragment = this.getFragment(fragName); + + if (fragment) { + fragments.push(fragment); + nodesToVisit.push(fragment.selectionSet); + } + } + } + } + + this._recursivelyReferencedFragments.set(operation, fragments); + } + + return fragments; + } +} + +exports.ASTValidationContext = ASTValidationContext; + +class SDLValidationContext extends ASTValidationContext { + constructor(ast, schema, onError) { + super(ast, onError); + this._schema = schema; + } + + get [Symbol.toStringTag]() { + return 'SDLValidationContext'; + } + + getSchema() { + return this._schema; + } +} + +exports.SDLValidationContext = SDLValidationContext; + +class ValidationContext extends ASTValidationContext { + constructor(schema, ast, typeInfo, onError) { + super(ast, onError); + this._schema = schema; + this._typeInfo = typeInfo; + this._variableUsages = new Map(); + this._recursiveVariableUsages = new Map(); + } + + get [Symbol.toStringTag]() { + return 'ValidationContext'; + } + + getSchema() { + return this._schema; + } + + getVariableUsages(node) { + let usages = this._variableUsages.get(node); + + if (!usages) { + const newUsages = []; + const typeInfo = new _TypeInfo.TypeInfo(this._schema); + (0, _visitor.visit)( + node, + (0, _TypeInfo.visitWithTypeInfo)(typeInfo, { + VariableDefinition: () => false, + + Variable(variable) { + newUsages.push({ + node: variable, + type: typeInfo.getInputType(), + defaultValue: typeInfo.getDefaultValue(), + }); + }, + }), + ); + usages = newUsages; + + this._variableUsages.set(node, usages); + } + + return usages; + } + + getRecursiveVariableUsages(operation) { + let usages = this._recursiveVariableUsages.get(operation); + + if (!usages) { + usages = this.getVariableUsages(operation); + + for (const frag of this.getRecursivelyReferencedFragments(operation)) { + usages = usages.concat(this.getVariableUsages(frag)); + } + + this._recursiveVariableUsages.set(operation, usages); + } + + return usages; + } + + getType() { + return this._typeInfo.getType(); + } + + getParentType() { + return this._typeInfo.getParentType(); + } + + getInputType() { + return this._typeInfo.getInputType(); + } + + getParentInputType() { + return this._typeInfo.getParentInputType(); + } + + getFieldDef() { + return this._typeInfo.getFieldDef(); + } + + getDirective() { + return this._typeInfo.getDirective(); + } + + getArgument() { + return this._typeInfo.getArgument(); + } + + getEnumValue() { + return this._typeInfo.getEnumValue(); + } +} + +exports.ValidationContext = ValidationContext; + + +/***/ }), + +/***/ 1122: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +Object.defineProperty(exports, "ExecutableDefinitionsRule", ({ + enumerable: true, + get: function () { + return _ExecutableDefinitionsRule.ExecutableDefinitionsRule; + }, +})); +Object.defineProperty(exports, "FieldsOnCorrectTypeRule", ({ + enumerable: true, + get: function () { + return _FieldsOnCorrectTypeRule.FieldsOnCorrectTypeRule; + }, +})); +Object.defineProperty(exports, "FragmentsOnCompositeTypesRule", ({ + enumerable: true, + get: function () { + return _FragmentsOnCompositeTypesRule.FragmentsOnCompositeTypesRule; + }, +})); +Object.defineProperty(exports, "KnownArgumentNamesRule", ({ + enumerable: true, + get: function () { + return _KnownArgumentNamesRule.KnownArgumentNamesRule; + }, +})); +Object.defineProperty(exports, "KnownDirectivesRule", ({ + enumerable: true, + get: function () { + return _KnownDirectivesRule.KnownDirectivesRule; + }, +})); +Object.defineProperty(exports, "KnownFragmentNamesRule", ({ + enumerable: true, + get: function () { + return _KnownFragmentNamesRule.KnownFragmentNamesRule; + }, +})); +Object.defineProperty(exports, "KnownTypeNamesRule", ({ + enumerable: true, + get: function () { + return _KnownTypeNamesRule.KnownTypeNamesRule; + }, +})); +Object.defineProperty(exports, "LoneAnonymousOperationRule", ({ + enumerable: true, + get: function () { + return _LoneAnonymousOperationRule.LoneAnonymousOperationRule; + }, +})); +Object.defineProperty(exports, "LoneSchemaDefinitionRule", ({ + enumerable: true, + get: function () { + return _LoneSchemaDefinitionRule.LoneSchemaDefinitionRule; + }, +})); +Object.defineProperty(exports, "NoDeprecatedCustomRule", ({ + enumerable: true, + get: function () { + return _NoDeprecatedCustomRule.NoDeprecatedCustomRule; + }, +})); +Object.defineProperty(exports, "NoFragmentCyclesRule", ({ + enumerable: true, + get: function () { + return _NoFragmentCyclesRule.NoFragmentCyclesRule; + }, +})); +Object.defineProperty(exports, "NoSchemaIntrospectionCustomRule", ({ + enumerable: true, + get: function () { + return _NoSchemaIntrospectionCustomRule.NoSchemaIntrospectionCustomRule; + }, +})); +Object.defineProperty(exports, "NoUndefinedVariablesRule", ({ + enumerable: true, + get: function () { + return _NoUndefinedVariablesRule.NoUndefinedVariablesRule; + }, +})); +Object.defineProperty(exports, "NoUnusedFragmentsRule", ({ + enumerable: true, + get: function () { + return _NoUnusedFragmentsRule.NoUnusedFragmentsRule; + }, +})); +Object.defineProperty(exports, "NoUnusedVariablesRule", ({ + enumerable: true, + get: function () { + return _NoUnusedVariablesRule.NoUnusedVariablesRule; + }, +})); +Object.defineProperty(exports, "OverlappingFieldsCanBeMergedRule", ({ + enumerable: true, + get: function () { + return _OverlappingFieldsCanBeMergedRule.OverlappingFieldsCanBeMergedRule; + }, +})); +Object.defineProperty(exports, "PossibleFragmentSpreadsRule", ({ + enumerable: true, + get: function () { + return _PossibleFragmentSpreadsRule.PossibleFragmentSpreadsRule; + }, +})); +Object.defineProperty(exports, "PossibleTypeExtensionsRule", ({ + enumerable: true, + get: function () { + return _PossibleTypeExtensionsRule.PossibleTypeExtensionsRule; + }, +})); +Object.defineProperty(exports, "ProvidedRequiredArgumentsRule", ({ + enumerable: true, + get: function () { + return _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsRule; + }, +})); +Object.defineProperty(exports, "ScalarLeafsRule", ({ + enumerable: true, + get: function () { + return _ScalarLeafsRule.ScalarLeafsRule; + }, +})); +Object.defineProperty(exports, "SingleFieldSubscriptionsRule", ({ + enumerable: true, + get: function () { + return _SingleFieldSubscriptionsRule.SingleFieldSubscriptionsRule; + }, +})); +Object.defineProperty(exports, "UniqueArgumentDefinitionNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueArgumentDefinitionNamesRule.UniqueArgumentDefinitionNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueArgumentNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueArgumentNamesRule.UniqueArgumentNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueDirectiveNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueDirectiveNamesRule.UniqueDirectiveNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueDirectivesPerLocationRule", ({ + enumerable: true, + get: function () { + return _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule; + }, +})); +Object.defineProperty(exports, "UniqueEnumValueNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueEnumValueNamesRule.UniqueEnumValueNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueFieldDefinitionNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueFieldDefinitionNamesRule.UniqueFieldDefinitionNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueFragmentNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueFragmentNamesRule.UniqueFragmentNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueInputFieldNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueOperationNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueOperationNamesRule.UniqueOperationNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueOperationTypesRule", ({ + enumerable: true, + get: function () { + return _UniqueOperationTypesRule.UniqueOperationTypesRule; + }, +})); +Object.defineProperty(exports, "UniqueTypeNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueTypeNamesRule.UniqueTypeNamesRule; + }, +})); +Object.defineProperty(exports, "UniqueVariableNamesRule", ({ + enumerable: true, + get: function () { + return _UniqueVariableNamesRule.UniqueVariableNamesRule; + }, +})); +Object.defineProperty(exports, "ValidationContext", ({ + enumerable: true, + get: function () { + return _ValidationContext.ValidationContext; + }, +})); +Object.defineProperty(exports, "ValuesOfCorrectTypeRule", ({ + enumerable: true, + get: function () { + return _ValuesOfCorrectTypeRule.ValuesOfCorrectTypeRule; + }, +})); +Object.defineProperty(exports, "VariablesAreInputTypesRule", ({ + enumerable: true, + get: function () { + return _VariablesAreInputTypesRule.VariablesAreInputTypesRule; + }, +})); +Object.defineProperty(exports, "VariablesInAllowedPositionRule", ({ + enumerable: true, + get: function () { + return _VariablesInAllowedPositionRule.VariablesInAllowedPositionRule; + }, +})); +Object.defineProperty(exports, "specifiedRules", ({ + enumerable: true, + get: function () { + return _specifiedRules.specifiedRules; + }, +})); +Object.defineProperty(exports, "validate", ({ + enumerable: true, + get: function () { + return _validate.validate; + }, +})); + +var _validate = __webpack_require__(9504); + +var _ValidationContext = __webpack_require__(3955); + +var _specifiedRules = __webpack_require__(4710); + +var _ExecutableDefinitionsRule = __webpack_require__(5285); + +var _FieldsOnCorrectTypeRule = __webpack_require__(9426); + +var _FragmentsOnCompositeTypesRule = __webpack_require__(3558); + +var _KnownArgumentNamesRule = __webpack_require__(9989); + +var _KnownDirectivesRule = __webpack_require__(2826); + +var _KnownFragmentNamesRule = __webpack_require__(1843); + +var _KnownTypeNamesRule = __webpack_require__(5961); + +var _LoneAnonymousOperationRule = __webpack_require__(870); + +var _NoFragmentCyclesRule = __webpack_require__(658); + +var _NoUndefinedVariablesRule = __webpack_require__(7459); + +var _NoUnusedFragmentsRule = __webpack_require__(7317); + +var _NoUnusedVariablesRule = __webpack_require__(8769); + +var _OverlappingFieldsCanBeMergedRule = __webpack_require__(4331); + +var _PossibleFragmentSpreadsRule = __webpack_require__(5904); + +var _ProvidedRequiredArgumentsRule = __webpack_require__(4312); + +var _ScalarLeafsRule = __webpack_require__(7168); + +var _SingleFieldSubscriptionsRule = __webpack_require__(4666); + +var _UniqueArgumentNamesRule = __webpack_require__(4986); + +var _UniqueDirectivesPerLocationRule = __webpack_require__(3576); + +var _UniqueFragmentNamesRule = __webpack_require__(5883); + +var _UniqueInputFieldNamesRule = __webpack_require__(4313); + +var _UniqueOperationNamesRule = __webpack_require__(2139); + +var _UniqueVariableNamesRule = __webpack_require__(4243); + +var _ValuesOfCorrectTypeRule = __webpack_require__(6869); + +var _VariablesAreInputTypesRule = __webpack_require__(4942); + +var _VariablesInAllowedPositionRule = __webpack_require__(8034); + +var _LoneSchemaDefinitionRule = __webpack_require__(3411); + +var _UniqueOperationTypesRule = __webpack_require__(856); + +var _UniqueTypeNamesRule = __webpack_require__(1686); + +var _UniqueEnumValueNamesRule = __webpack_require__(6400); + +var _UniqueFieldDefinitionNamesRule = __webpack_require__(4046); + +var _UniqueArgumentDefinitionNamesRule = __webpack_require__(3878); + +var _UniqueDirectiveNamesRule = __webpack_require__(6753); + +var _PossibleTypeExtensionsRule = __webpack_require__(5715); + +var _NoDeprecatedCustomRule = __webpack_require__(2860); + +var _NoSchemaIntrospectionCustomRule = __webpack_require__(2276); + + +/***/ }), + +/***/ 5285: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ExecutableDefinitionsRule = ExecutableDefinitionsRule; + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _predicates = __webpack_require__(1352); + +/** + * Executable definitions + * + * A GraphQL document is only valid for execution if all definitions are either + * operation or fragment definitions. + * + * See https://spec.graphql.org/draft/#sec-Executable-Definitions + */ +function ExecutableDefinitionsRule(context) { + return { + Document(node) { + for (const definition of node.definitions) { + if (!(0, _predicates.isExecutableDefinitionNode)(definition)) { + const defName = + definition.kind === _kinds.Kind.SCHEMA_DEFINITION || + definition.kind === _kinds.Kind.SCHEMA_EXTENSION + ? 'schema' + : '"' + definition.name.value + '"'; + context.reportError( + new _GraphQLError.GraphQLError( + `The ${defName} definition is not executable.`, + { + nodes: definition, + }, + ), + ); + } + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 9426: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.FieldsOnCorrectTypeRule = FieldsOnCorrectTypeRule; + +var _didYouMean = __webpack_require__(100); + +var _naturalCompare = __webpack_require__(5250); + +var _suggestionList = __webpack_require__(8070); + +var _GraphQLError = __webpack_require__(5822); + +var _definition = __webpack_require__(5003); + +/** + * Fields on correct type + * + * A GraphQL document is only valid if all fields selected are defined by the + * parent type, or are an allowed meta field such as __typename. + * + * See https://spec.graphql.org/draft/#sec-Field-Selections + */ +function FieldsOnCorrectTypeRule(context) { + return { + Field(node) { + const type = context.getParentType(); + + if (type) { + const fieldDef = context.getFieldDef(); + + if (!fieldDef) { + // This field doesn't exist, lets look for suggestions. + const schema = context.getSchema(); + const fieldName = node.name.value; // First determine if there are any suggested types to condition on. + + let suggestion = (0, _didYouMean.didYouMean)( + 'to use an inline fragment on', + getSuggestedTypeNames(schema, type, fieldName), + ); // If there are no suggested types, then perhaps this was a typo? + + if (suggestion === '') { + suggestion = (0, _didYouMean.didYouMean)( + getSuggestedFieldNames(type, fieldName), + ); + } // Report an error, including helpful suggestions. + + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot query field "${fieldName}" on type "${type.name}".` + + suggestion, + { + nodes: node, + }, + ), + ); + } + } + }, + }; +} +/** + * Go through all of the implementations of type, as well as the interfaces that + * they implement. If any of those types include the provided field, suggest them, + * sorted by how often the type is referenced. + */ + +function getSuggestedTypeNames(schema, type, fieldName) { + if (!(0, _definition.isAbstractType)(type)) { + // Must be an Object type, which does not have possible fields. + return []; + } + + const suggestedTypes = new Set(); + const usageCount = Object.create(null); + + for (const possibleType of schema.getPossibleTypes(type)) { + if (!possibleType.getFields()[fieldName]) { + continue; + } // This object type defines this field. + + suggestedTypes.add(possibleType); + usageCount[possibleType.name] = 1; + + for (const possibleInterface of possibleType.getInterfaces()) { + var _usageCount$possibleI; + + if (!possibleInterface.getFields()[fieldName]) { + continue; + } // This interface type defines this field. + + suggestedTypes.add(possibleInterface); + usageCount[possibleInterface.name] = + ((_usageCount$possibleI = usageCount[possibleInterface.name]) !== + null && _usageCount$possibleI !== void 0 + ? _usageCount$possibleI + : 0) + 1; + } + } + + return [...suggestedTypes] + .sort((typeA, typeB) => { + // Suggest both interface and object types based on how common they are. + const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name]; + + if (usageCountDiff !== 0) { + return usageCountDiff; + } // Suggest super types first followed by subtypes + + if ( + (0, _definition.isInterfaceType)(typeA) && + schema.isSubType(typeA, typeB) + ) { + return -1; + } + + if ( + (0, _definition.isInterfaceType)(typeB) && + schema.isSubType(typeB, typeA) + ) { + return 1; + } + + return (0, _naturalCompare.naturalCompare)(typeA.name, typeB.name); + }) + .map((x) => x.name); +} +/** + * For the field name provided, determine if there are any similar field names + * that may be the result of a typo. + */ + +function getSuggestedFieldNames(type, fieldName) { + if ( + (0, _definition.isObjectType)(type) || + (0, _definition.isInterfaceType)(type) + ) { + const possibleFieldNames = Object.keys(type.getFields()); + return (0, _suggestionList.suggestionList)(fieldName, possibleFieldNames); + } // Otherwise, must be a Union type, which does not define fields. + + return []; +} + + +/***/ }), + +/***/ 3558: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.FragmentsOnCompositeTypesRule = FragmentsOnCompositeTypesRule; + +var _GraphQLError = __webpack_require__(5822); + +var _printer = __webpack_require__(3033); + +var _definition = __webpack_require__(5003); + +var _typeFromAST = __webpack_require__(5115); + +/** + * Fragments on composite type + * + * Fragments use a type condition to determine if they apply, since fragments + * can only be spread into a composite type (object, interface, or union), the + * type condition must also be a composite type. + * + * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types + */ +function FragmentsOnCompositeTypesRule(context) { + return { + InlineFragment(node) { + const typeCondition = node.typeCondition; + + if (typeCondition) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + typeCondition, + ); + + if (type && !(0, _definition.isCompositeType)(type)) { + const typeStr = (0, _printer.print)(typeCondition); + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment cannot condition on non composite type "${typeStr}".`, + { + nodes: typeCondition, + }, + ), + ); + } + } + }, + + FragmentDefinition(node) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + node.typeCondition, + ); + + if (type && !(0, _definition.isCompositeType)(type)) { + const typeStr = (0, _printer.print)(node.typeCondition); + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment "${node.name.value}" cannot condition on non composite type "${typeStr}".`, + { + nodes: node.typeCondition, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 9989: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.KnownArgumentNamesOnDirectivesRule = KnownArgumentNamesOnDirectivesRule; +exports.KnownArgumentNamesRule = KnownArgumentNamesRule; + +var _didYouMean = __webpack_require__(100); + +var _suggestionList = __webpack_require__(8070); + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _directives = __webpack_require__(7197); + +/** + * Known argument names + * + * A GraphQL field is only valid if all supplied arguments are defined by + * that field. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations + */ +function KnownArgumentNamesRule(context) { + return { + // eslint-disable-next-line new-cap + ...KnownArgumentNamesOnDirectivesRule(context), + + Argument(argNode) { + const argDef = context.getArgument(); + const fieldDef = context.getFieldDef(); + const parentType = context.getParentType(); + + if (!argDef && fieldDef && parentType) { + const argName = argNode.name.value; + const knownArgsNames = fieldDef.args.map((arg) => arg.name); + const suggestions = (0, _suggestionList.suggestionList)( + argName, + knownArgsNames, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown argument "${argName}" on field "${parentType.name}.${fieldDef.name}".` + + (0, _didYouMean.didYouMean)(suggestions), + { + nodes: argNode, + }, + ), + ); + } + }, + }; +} +/** + * @internal + */ + +function KnownArgumentNamesOnDirectivesRule(context) { + const directiveArgs = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _directives.specifiedDirectives; + + for (const directive of definedDirectives) { + directiveArgs[directive.name] = directive.args.map((arg) => arg.name); + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + var _def$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argsNodes = + (_def$arguments = def.arguments) !== null && _def$arguments !== void 0 + ? _def$arguments + : []; + directiveArgs[def.name.value] = argsNodes.map((arg) => arg.name.value); + } + } + + return { + Directive(directiveNode) { + const directiveName = directiveNode.name.value; + const knownArgs = directiveArgs[directiveName]; + + if (directiveNode.arguments && knownArgs) { + for (const argNode of directiveNode.arguments) { + const argName = argNode.name.value; + + if (!knownArgs.includes(argName)) { + const suggestions = (0, _suggestionList.suggestionList)( + argName, + knownArgs, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown argument "${argName}" on directive "@${directiveName}".` + + (0, _didYouMean.didYouMean)(suggestions), + { + nodes: argNode, + }, + ), + ); + } + } + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 2826: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.KnownDirectivesRule = KnownDirectivesRule; + +var _inspect = __webpack_require__(8002); + +var _invariant = __webpack_require__(7706); + +var _GraphQLError = __webpack_require__(5822); + +var _ast = __webpack_require__(1807); + +var _directiveLocation = __webpack_require__(8333); + +var _kinds = __webpack_require__(2828); + +var _directives = __webpack_require__(7197); + +/** + * Known directives + * + * A GraphQL document is only valid if all `@directives` are known by the + * schema and legally positioned. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined + */ +function KnownDirectivesRule(context) { + const locationsMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _directives.specifiedDirectives; + + for (const directive of definedDirectives) { + locationsMap[directive.name] = directive.locations; + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + locationsMap[def.name.value] = def.locations.map((name) => name.value); + } + } + + return { + Directive(node, _key, _parent, _path, ancestors) { + const name = node.name.value; + const locations = locationsMap[name]; + + if (!locations) { + context.reportError( + new _GraphQLError.GraphQLError(`Unknown directive "@${name}".`, { + nodes: node, + }), + ); + return; + } + + const candidateLocation = getDirectiveLocationForASTPath(ancestors); + + if (candidateLocation && !locations.includes(candidateLocation)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${name}" may not be used on ${candidateLocation}.`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +function getDirectiveLocationForASTPath(ancestors) { + const appliedTo = ancestors[ancestors.length - 1]; + 'kind' in appliedTo || (0, _invariant.invariant)(false); + + switch (appliedTo.kind) { + case _kinds.Kind.OPERATION_DEFINITION: + return getDirectiveLocationForOperation(appliedTo.operation); + + case _kinds.Kind.FIELD: + return _directiveLocation.DirectiveLocation.FIELD; + + case _kinds.Kind.FRAGMENT_SPREAD: + return _directiveLocation.DirectiveLocation.FRAGMENT_SPREAD; + + case _kinds.Kind.INLINE_FRAGMENT: + return _directiveLocation.DirectiveLocation.INLINE_FRAGMENT; + + case _kinds.Kind.FRAGMENT_DEFINITION: + return _directiveLocation.DirectiveLocation.FRAGMENT_DEFINITION; + + case _kinds.Kind.VARIABLE_DEFINITION: + return _directiveLocation.DirectiveLocation.VARIABLE_DEFINITION; + + case _kinds.Kind.SCHEMA_DEFINITION: + case _kinds.Kind.SCHEMA_EXTENSION: + return _directiveLocation.DirectiveLocation.SCHEMA; + + case _kinds.Kind.SCALAR_TYPE_DEFINITION: + case _kinds.Kind.SCALAR_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.SCALAR; + + case _kinds.Kind.OBJECT_TYPE_DEFINITION: + case _kinds.Kind.OBJECT_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.OBJECT; + + case _kinds.Kind.FIELD_DEFINITION: + return _directiveLocation.DirectiveLocation.FIELD_DEFINITION; + + case _kinds.Kind.INTERFACE_TYPE_DEFINITION: + case _kinds.Kind.INTERFACE_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.INTERFACE; + + case _kinds.Kind.UNION_TYPE_DEFINITION: + case _kinds.Kind.UNION_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.UNION; + + case _kinds.Kind.ENUM_TYPE_DEFINITION: + case _kinds.Kind.ENUM_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.ENUM; + + case _kinds.Kind.ENUM_VALUE_DEFINITION: + return _directiveLocation.DirectiveLocation.ENUM_VALUE; + + case _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION: + case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION: + return _directiveLocation.DirectiveLocation.INPUT_OBJECT; + + case _kinds.Kind.INPUT_VALUE_DEFINITION: { + const parentNode = ancestors[ancestors.length - 3]; + 'kind' in parentNode || (0, _invariant.invariant)(false); + return parentNode.kind === _kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION + ? _directiveLocation.DirectiveLocation.INPUT_FIELD_DEFINITION + : _directiveLocation.DirectiveLocation.ARGUMENT_DEFINITION; + } + // Not reachable, all possible types have been considered. + + /* c8 ignore next */ + + default: + false || + (0, _invariant.invariant)( + false, + 'Unexpected kind: ' + (0, _inspect.inspect)(appliedTo.kind), + ); + } +} + +function getDirectiveLocationForOperation(operation) { + switch (operation) { + case _ast.OperationTypeNode.QUERY: + return _directiveLocation.DirectiveLocation.QUERY; + + case _ast.OperationTypeNode.MUTATION: + return _directiveLocation.DirectiveLocation.MUTATION; + + case _ast.OperationTypeNode.SUBSCRIPTION: + return _directiveLocation.DirectiveLocation.SUBSCRIPTION; + } +} + + +/***/ }), + +/***/ 1843: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.KnownFragmentNamesRule = KnownFragmentNamesRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * Known fragment names + * + * A GraphQL document is only valid if all `...Fragment` fragment spreads refer + * to fragments defined in the same document. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined + */ +function KnownFragmentNamesRule(context) { + return { + FragmentSpread(node) { + const fragmentName = node.name.value; + const fragment = context.getFragment(fragmentName); + + if (!fragment) { + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown fragment "${fragmentName}".`, + { + nodes: node.name, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 5961: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.KnownTypeNamesRule = KnownTypeNamesRule; + +var _didYouMean = __webpack_require__(100); + +var _suggestionList = __webpack_require__(8070); + +var _GraphQLError = __webpack_require__(5822); + +var _predicates = __webpack_require__(1352); + +var _introspection = __webpack_require__(8155); + +var _scalars = __webpack_require__(2229); + +/** + * Known type names + * + * A GraphQL document is only valid if referenced types (specifically + * variable definitions and fragment conditions) are defined by the type schema. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence + */ +function KnownTypeNamesRule(context) { + const schema = context.getSchema(); + const existingTypesMap = schema ? schema.getTypeMap() : Object.create(null); + const definedTypes = Object.create(null); + + for (const def of context.getDocument().definitions) { + if ((0, _predicates.isTypeDefinitionNode)(def)) { + definedTypes[def.name.value] = true; + } + } + + const typeNames = [ + ...Object.keys(existingTypesMap), + ...Object.keys(definedTypes), + ]; + return { + NamedType(node, _1, parent, _2, ancestors) { + const typeName = node.name.value; + + if (!existingTypesMap[typeName] && !definedTypes[typeName]) { + var _ancestors$; + + const definitionNode = + (_ancestors$ = ancestors[2]) !== null && _ancestors$ !== void 0 + ? _ancestors$ + : parent; + const isSDL = definitionNode != null && isSDLNode(definitionNode); + + if (isSDL && standardTypeNames.includes(typeName)) { + return; + } + + const suggestedTypes = (0, _suggestionList.suggestionList)( + typeName, + isSDL ? standardTypeNames.concat(typeNames) : typeNames, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Unknown type "${typeName}".` + + (0, _didYouMean.didYouMean)(suggestedTypes), + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +const standardTypeNames = [ + ..._scalars.specifiedScalarTypes, + ..._introspection.introspectionTypes, +].map((type) => type.name); + +function isSDLNode(value) { + return ( + 'kind' in value && + ((0, _predicates.isTypeSystemDefinitionNode)(value) || + (0, _predicates.isTypeSystemExtensionNode)(value)) + ); +} + + +/***/ }), + +/***/ 870: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.LoneAnonymousOperationRule = LoneAnonymousOperationRule; + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +/** + * Lone anonymous operation + * + * A GraphQL document is only valid if when it contains an anonymous operation + * (the query short-hand) that it contains only that one operation definition. + * + * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation + */ +function LoneAnonymousOperationRule(context) { + let operationCount = 0; + return { + Document(node) { + operationCount = node.definitions.filter( + (definition) => definition.kind === _kinds.Kind.OPERATION_DEFINITION, + ).length; + }, + + OperationDefinition(node) { + if (!node.name && operationCount > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + 'This anonymous operation must be the only defined operation.', + { + nodes: node, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 3411: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.LoneSchemaDefinitionRule = LoneSchemaDefinitionRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * Lone Schema definition + * + * A GraphQL document is only valid if it contains only one schema definition. + */ +function LoneSchemaDefinitionRule(context) { + var _ref, _ref2, _oldSchema$astNode; + + const oldSchema = context.getSchema(); + const alreadyDefined = + (_ref = + (_ref2 = + (_oldSchema$astNode = + oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.astNode) !== null && _oldSchema$astNode !== void 0 + ? _oldSchema$astNode + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getQueryType()) !== null && _ref2 !== void 0 + ? _ref2 + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getMutationType()) !== null && _ref !== void 0 + ? _ref + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getSubscriptionType(); + let schemaDefinitionsCount = 0; + return { + SchemaDefinition(node) { + if (alreadyDefined) { + context.reportError( + new _GraphQLError.GraphQLError( + 'Cannot define a new schema within a schema extension.', + { + nodes: node, + }, + ), + ); + return; + } + + if (schemaDefinitionsCount > 0) { + context.reportError( + new _GraphQLError.GraphQLError( + 'Must provide only one schema definition.', + { + nodes: node, + }, + ), + ); + } + + ++schemaDefinitionsCount; + }, + }; +} + + +/***/ }), + +/***/ 658: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoFragmentCyclesRule = NoFragmentCyclesRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * No fragment cycles + * + * The graph of fragment spreads must not form any cycles including spreading itself. + * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles + */ +function NoFragmentCyclesRule(context) { + // Tracks already visited fragments to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedFrags = Object.create(null); // Array of AST nodes used to produce meaningful errors + + const spreadPath = []; // Position in the spread path + + const spreadPathIndexByName = Object.create(null); + return { + OperationDefinition: () => false, + + FragmentDefinition(node) { + detectCycleRecursive(node); + return false; + }, + }; // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + + function detectCycleRecursive(fragment) { + if (visitedFrags[fragment.name.value]) { + return; + } + + const fragmentName = fragment.name.value; + visitedFrags[fragmentName] = true; + const spreadNodes = context.getFragmentSpreads(fragment.selectionSet); + + if (spreadNodes.length === 0) { + return; + } + + spreadPathIndexByName[fragmentName] = spreadPath.length; + + for (const spreadNode of spreadNodes) { + const spreadName = spreadNode.name.value; + const cycleIndex = spreadPathIndexByName[spreadName]; + spreadPath.push(spreadNode); + + if (cycleIndex === undefined) { + const spreadFragment = context.getFragment(spreadName); + + if (spreadFragment) { + detectCycleRecursive(spreadFragment); + } + } else { + const cyclePath = spreadPath.slice(cycleIndex); + const viaPath = cyclePath + .slice(0, -1) + .map((s) => '"' + s.name.value + '"') + .join(', '); + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot spread fragment "${spreadName}" within itself` + + (viaPath !== '' ? ` via ${viaPath}.` : '.'), + { + nodes: cyclePath, + }, + ), + ); + } + + spreadPath.pop(); + } + + spreadPathIndexByName[fragmentName] = undefined; + } +} + + +/***/ }), + +/***/ 7459: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoUndefinedVariablesRule = NoUndefinedVariablesRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * No undefined variables + * + * A GraphQL operation is only valid if all variables encountered, both directly + * and via fragment spreads, are defined by that operation. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined + */ +function NoUndefinedVariablesRule(context) { + let variableNameDefined = Object.create(null); + return { + OperationDefinition: { + enter() { + variableNameDefined = Object.create(null); + }, + + leave(operation) { + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node } of usages) { + const varName = node.name.value; + + if (variableNameDefined[varName] !== true) { + context.reportError( + new _GraphQLError.GraphQLError( + operation.name + ? `Variable "$${varName}" is not defined by operation "${operation.name.value}".` + : `Variable "$${varName}" is not defined.`, + { + nodes: [node, operation], + }, + ), + ); + } + } + }, + }, + + VariableDefinition(node) { + variableNameDefined[node.variable.name.value] = true; + }, + }; +} + + +/***/ }), + +/***/ 7317: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoUnusedFragmentsRule = NoUnusedFragmentsRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * No unused fragments + * + * A GraphQL document is only valid if all fragment definitions are spread + * within operations, or spread within other fragments spread within operations. + * + * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used + */ +function NoUnusedFragmentsRule(context) { + const operationDefs = []; + const fragmentDefs = []; + return { + OperationDefinition(node) { + operationDefs.push(node); + return false; + }, + + FragmentDefinition(node) { + fragmentDefs.push(node); + return false; + }, + + Document: { + leave() { + const fragmentNameUsed = Object.create(null); + + for (const operation of operationDefs) { + for (const fragment of context.getRecursivelyReferencedFragments( + operation, + )) { + fragmentNameUsed[fragment.name.value] = true; + } + } + + for (const fragmentDef of fragmentDefs) { + const fragName = fragmentDef.name.value; + + if (fragmentNameUsed[fragName] !== true) { + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment "${fragName}" is never used.`, + { + nodes: fragmentDef, + }, + ), + ); + } + } + }, + }, + }; +} + + +/***/ }), + +/***/ 8769: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoUnusedVariablesRule = NoUnusedVariablesRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * No unused variables + * + * A GraphQL operation is only valid if all variables defined by an operation + * are used, either directly or within a spread fragment. + * + * See https://spec.graphql.org/draft/#sec-All-Variables-Used + */ +function NoUnusedVariablesRule(context) { + let variableDefs = []; + return { + OperationDefinition: { + enter() { + variableDefs = []; + }, + + leave(operation) { + const variableNameUsed = Object.create(null); + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node } of usages) { + variableNameUsed[node.name.value] = true; + } + + for (const variableDef of variableDefs) { + const variableName = variableDef.variable.name.value; + + if (variableNameUsed[variableName] !== true) { + context.reportError( + new _GraphQLError.GraphQLError( + operation.name + ? `Variable "$${variableName}" is never used in operation "${operation.name.value}".` + : `Variable "$${variableName}" is never used.`, + { + nodes: variableDef, + }, + ), + ); + } + } + }, + }, + + VariableDefinition(def) { + variableDefs.push(def); + }, + }; +} + + +/***/ }), + +/***/ 4331: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.OverlappingFieldsCanBeMergedRule = OverlappingFieldsCanBeMergedRule; + +var _inspect = __webpack_require__(8002); + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _printer = __webpack_require__(3033); + +var _definition = __webpack_require__(5003); + +var _sortValueNode = __webpack_require__(6830); + +var _typeFromAST = __webpack_require__(5115); + +function reasonMessage(reason) { + if (Array.isArray(reason)) { + return reason + .map( + ([responseName, subReason]) => + `subfields "${responseName}" conflict because ` + + reasonMessage(subReason), + ) + .join(' and '); + } + + return reason; +} +/** + * Overlapping fields can be merged + * + * A selection set is only valid if all fields (including spreading any + * fragments) either correspond to distinct response names or can be merged + * without ambiguity. + * + * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging + */ + +function OverlappingFieldsCanBeMergedRule(context) { + // A memoization for when two fragments are compared "between" each other for + // conflicts. Two fragments may be compared many times, so memoizing this can + // dramatically improve the performance of this validator. + const comparedFragmentPairs = new PairSet(); // A cache for the "field map" and list of fragment names found in any given + // selection set. Selection sets may be asked for this information multiple + // times, so this improves the performance of this validator. + + const cachedFieldsAndFragmentNames = new Map(); + return { + SelectionSet(selectionSet) { + const conflicts = findConflictsWithinSelectionSet( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + context.getParentType(), + selectionSet, + ); + + for (const [[responseName, reason], fields1, fields2] of conflicts) { + const reasonMsg = reasonMessage(reason); + context.reportError( + new _GraphQLError.GraphQLError( + `Fields "${responseName}" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`, + { + nodes: fields1.concat(fields2), + }, + ), + ); + } + }, + }; +} + +/** + * Algorithm: + * + * Conflicts occur when two fields exist in a query which will produce the same + * response name, but represent differing values, thus creating a conflict. + * The algorithm below finds all conflicts via making a series of comparisons + * between fields. In order to compare as few fields as possible, this makes + * a series of comparisons "within" sets of fields and "between" sets of fields. + * + * Given any selection set, a collection produces both a set of fields by + * also including all inline fragments, as well as a list of fragments + * referenced by fragment spreads. + * + * A) Each selection set represented in the document first compares "within" its + * collected set of fields, finding any conflicts between every pair of + * overlapping fields. + * Note: This is the *only time* that a the fields "within" a set are compared + * to each other. After this only fields "between" sets are compared. + * + * B) Also, if any fragment is referenced in a selection set, then a + * comparison is made "between" the original set of fields and the + * referenced fragment. + * + * C) Also, if multiple fragments are referenced, then comparisons + * are made "between" each referenced fragment. + * + * D) When comparing "between" a set of fields and a referenced fragment, first + * a comparison is made between each field in the original set of fields and + * each field in the the referenced set of fields. + * + * E) Also, if any fragment is referenced in the referenced selection set, + * then a comparison is made "between" the original set of fields and the + * referenced fragment (recursively referring to step D). + * + * F) When comparing "between" two fragments, first a comparison is made between + * each field in the first referenced set of fields and each field in the the + * second referenced set of fields. + * + * G) Also, any fragments referenced by the first must be compared to the + * second, and any fragments referenced by the second must be compared to the + * first (recursively referring to step F). + * + * H) When comparing two fields, if both have selection sets, then a comparison + * is made "between" both selection sets, first comparing the set of fields in + * the first selection set with the set of fields in the second. + * + * I) Also, if any fragment is referenced in either selection set, then a + * comparison is made "between" the other set of fields and the + * referenced fragment. + * + * J) Also, if two fragments are referenced in both selection sets, then a + * comparison is made "between" the two fragments. + * + */ +// Find all conflicts found "within" a selection set, including those found +// via spreading in fragments. Called when visiting each SelectionSet in the +// GraphQL Document. +function findConflictsWithinSelectionSet( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentType, + selectionSet, +) { + const conflicts = []; + const [fieldMap, fragmentNames] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType, + selectionSet, + ); // (A) Find find all conflicts "within" the fields of this selection set. + // Note: this is the *only place* `collectConflictsWithin` is called. + + collectConflictsWithin( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + fieldMap, + ); + + if (fragmentNames.length !== 0) { + // (B) Then collect conflicts between these fields and those represented by + // each spread fragment name found. + for (let i = 0; i < fragmentNames.length; i++) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, + fieldMap, + fragmentNames[i], + ); // (C) Then compare this fragment with all other fragments found in this + // selection set to collect conflicts between fragments spread together. + // This compares each item in the list of fragment names to every other + // item in that same list (except for itself). + + for (let j = i + 1; j < fragmentNames.length; j++) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, + fragmentNames[i], + fragmentNames[j], + ); + } + } + } + + return conflicts; +} // Collect all conflicts found between a set of fields and a fragment reference +// including via spreading in any nested fragments. + +function collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + fragmentName, +) { + const fragment = context.getFragment(fragmentName); + + if (!fragment) { + return; + } + + const [fieldMap2, referencedFragmentNames] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment, + ); // Do not compare a fragment's fieldMap to itself. + + if (fieldMap === fieldMap2) { + return; + } // (D) First collect any conflicts between the provided collection of fields + // and the collection of fields represented by the given fragment. + + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + fieldMap2, + ); // (E) Then collect any conflicts between the provided collection of fields + // and any fragment names found in the given fragment. + + for (const referencedFragmentName of referencedFragmentNames) { + // Memoize so two fragments are not compared for conflicts more than once. + if ( + comparedFragmentPairs.has( + referencedFragmentName, + fragmentName, + areMutuallyExclusive, + ) + ) { + continue; + } + + comparedFragmentPairs.add( + referencedFragmentName, + fragmentName, + areMutuallyExclusive, + ); + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + referencedFragmentName, + ); + } +} // Collect all conflicts found between two fragments, including via spreading in +// any nested fragments. + +function collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + fragmentName2, +) { + // No need to compare a fragment to itself. + if (fragmentName1 === fragmentName2) { + return; + } // Memoize so two fragments are not compared for conflicts more than once. + + if ( + comparedFragmentPairs.has( + fragmentName1, + fragmentName2, + areMutuallyExclusive, + ) + ) { + return; + } + + comparedFragmentPairs.add(fragmentName1, fragmentName2, areMutuallyExclusive); + const fragment1 = context.getFragment(fragmentName1); + const fragment2 = context.getFragment(fragmentName2); + + if (!fragment1 || !fragment2) { + return; + } + + const [fieldMap1, referencedFragmentNames1] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment1, + ); + const [fieldMap2, referencedFragmentNames2] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment2, + ); // (F) First, collect all conflicts between these two collections of fields + // (not including any nested fragments). + + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fieldMap2, + ); // (G) Then collect conflicts between the first fragment and any nested + // fragments spread in the second fragment. + + for (const referencedFragmentName2 of referencedFragmentNames2) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + referencedFragmentName2, + ); + } // (G) Then collect conflicts between the second fragment and any nested + // fragments spread in the first fragment. + + for (const referencedFragmentName1 of referencedFragmentNames1) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + referencedFragmentName1, + fragmentName2, + ); + } +} // Find all conflicts found between two selection sets, including those found +// via spreading in fragments. Called when determining if conflicts exist +// between the sub-fields of two overlapping fields. + +function findConflictsBetweenSubSelectionSets( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + parentType1, + selectionSet1, + parentType2, + selectionSet2, +) { + const conflicts = []; + const [fieldMap1, fragmentNames1] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType1, + selectionSet1, + ); + const [fieldMap2, fragmentNames2] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType2, + selectionSet2, + ); // (H) First, collect all conflicts between these two collections of field. + + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fieldMap2, + ); // (I) Then collect conflicts between the first collection of fields and + // those referenced by each fragment name associated with the second. + + for (const fragmentName2 of fragmentNames2) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fragmentName2, + ); + } // (I) Then collect conflicts between the second collection of fields and + // those referenced by each fragment name associated with the first. + + for (const fragmentName1 of fragmentNames1) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap2, + fragmentName1, + ); + } // (J) Also collect conflicts between any fragment names by the first and + // fragment names by the second. This compares each item in the first set of + // names to each item in the second set of names. + + for (const fragmentName1 of fragmentNames1) { + for (const fragmentName2 of fragmentNames2) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + fragmentName2, + ); + } + } + + return conflicts; +} // Collect all Conflicts "within" one collection of fields. + +function collectConflictsWithin( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + fieldMap, +) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For every response name, if there are multiple fields, they + // must be compared to find a potential conflict. + for (const [responseName, fields] of Object.entries(fieldMap)) { + // This compares every field in the list to every other field in this list + // (except to itself). If the list only has one item, nothing needs to + // be compared. + if (fields.length > 1) { + for (let i = 0; i < fields.length; i++) { + for (let j = i + 1; j < fields.length; j++) { + const conflict = findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, // within one collection is never mutually exclusive + responseName, + fields[i], + fields[j], + ); + + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} // Collect all Conflicts between two collections of fields. This is similar to, +// but different from the `collectConflictsWithin` function above. This check +// assumes that `collectConflictsWithin` has already been called on each +// provided collection of fields. This is true because this validator traverses +// each individual selection set. + +function collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + fieldMap1, + fieldMap2, +) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For any response name which appears in both provided field + // maps, each field from the first field map must be compared to every field + // in the second field map to find potential conflicts. + for (const [responseName, fields1] of Object.entries(fieldMap1)) { + const fields2 = fieldMap2[responseName]; + + if (fields2) { + for (const field1 of fields1) { + for (const field2 of fields2) { + const conflict = findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + responseName, + field1, + field2, + ); + + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} // Determines if there is a conflict between two particular fields, including +// comparing their sub-fields. + +function findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + responseName, + field1, + field2, +) { + const [parentType1, node1, def1] = field1; + const [parentType2, node2, def2] = field2; // If it is known that two fields could not possibly apply at the same + // time, due to the parent types, then it is safe to permit them to diverge + // in aliased field or arguments used as they will not present any ambiguity + // by differing. + // It is known that two parent types could never overlap if they are + // different Object types. Interface or Union types might overlap - if not + // in the current state of the schema, then perhaps in some future version, + // thus may not safely diverge. + + const areMutuallyExclusive = + parentFieldsAreMutuallyExclusive || + (parentType1 !== parentType2 && + (0, _definition.isObjectType)(parentType1) && + (0, _definition.isObjectType)(parentType2)); + + if (!areMutuallyExclusive) { + // Two aliases must refer to the same field. + const name1 = node1.name.value; + const name2 = node2.name.value; + + if (name1 !== name2) { + return [ + [responseName, `"${name1}" and "${name2}" are different fields`], + [node1], + [node2], + ]; + } // Two field calls must have the same arguments. + + if (stringifyArguments(node1) !== stringifyArguments(node2)) { + return [ + [responseName, 'they have differing arguments'], + [node1], + [node2], + ]; + } + } // The return type for each field. + + const type1 = def1 === null || def1 === void 0 ? void 0 : def1.type; + const type2 = def2 === null || def2 === void 0 ? void 0 : def2.type; + + if (type1 && type2 && doTypesConflict(type1, type2)) { + return [ + [ + responseName, + `they return conflicting types "${(0, _inspect.inspect)( + type1, + )}" and "${(0, _inspect.inspect)(type2)}"`, + ], + [node1], + [node2], + ]; + } // Collect and compare sub-fields. Use the same "visited fragment names" list + // for both collections so fields in a fragment reference are never + // compared to themselves. + + const selectionSet1 = node1.selectionSet; + const selectionSet2 = node2.selectionSet; + + if (selectionSet1 && selectionSet2) { + const conflicts = findConflictsBetweenSubSelectionSets( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + (0, _definition.getNamedType)(type1), + selectionSet1, + (0, _definition.getNamedType)(type2), + selectionSet2, + ); + return subfieldConflicts(conflicts, responseName, node1, node2); + } +} + +function stringifyArguments(fieldNode) { + var _fieldNode$arguments; + + // FIXME https://github.com/graphql/graphql-js/issues/2203 + const args = + /* c8 ignore next */ + (_fieldNode$arguments = fieldNode.arguments) !== null && + _fieldNode$arguments !== void 0 + ? _fieldNode$arguments + : []; + const inputObjectWithArgs = { + kind: _kinds.Kind.OBJECT, + fields: args.map((argNode) => ({ + kind: _kinds.Kind.OBJECT_FIELD, + name: argNode.name, + value: argNode.value, + })), + }; + return (0, _printer.print)( + (0, _sortValueNode.sortValueNode)(inputObjectWithArgs), + ); +} // Two types conflict if both types could not apply to a value simultaneously. +// Composite types are ignored as their individual field types will be compared +// later recursively. However List and Non-Null types must match. + +function doTypesConflict(type1, type2) { + if ((0, _definition.isListType)(type1)) { + return (0, _definition.isListType)(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } + + if ((0, _definition.isListType)(type2)) { + return true; + } + + if ((0, _definition.isNonNullType)(type1)) { + return (0, _definition.isNonNullType)(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } + + if ((0, _definition.isNonNullType)(type2)) { + return true; + } + + if ( + (0, _definition.isLeafType)(type1) || + (0, _definition.isLeafType)(type2) + ) { + return type1 !== type2; + } + + return false; +} // Given a selection set, return the collection of fields (a mapping of response +// name to field nodes and definitions) as well as a list of fragment names +// referenced via fragment spreads. + +function getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType, + selectionSet, +) { + const cached = cachedFieldsAndFragmentNames.get(selectionSet); + + if (cached) { + return cached; + } + + const nodeAndDefs = Object.create(null); + const fragmentNames = Object.create(null); + + _collectFieldsAndFragmentNames( + context, + parentType, + selectionSet, + nodeAndDefs, + fragmentNames, + ); + + const result = [nodeAndDefs, Object.keys(fragmentNames)]; + cachedFieldsAndFragmentNames.set(selectionSet, result); + return result; +} // Given a reference to a fragment, return the represented collection of fields +// as well as a list of nested fragment names referenced via fragment spreads. + +function getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment, +) { + // Short-circuit building a type from the node if possible. + const cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet); + + if (cached) { + return cached; + } + + const fragmentType = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + fragment.typeCondition, + ); + return getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragmentType, + fragment.selectionSet, + ); +} + +function _collectFieldsAndFragmentNames( + context, + parentType, + selectionSet, + nodeAndDefs, + fragmentNames, +) { + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case _kinds.Kind.FIELD: { + const fieldName = selection.name.value; + let fieldDef; + + if ( + (0, _definition.isObjectType)(parentType) || + (0, _definition.isInterfaceType)(parentType) + ) { + fieldDef = parentType.getFields()[fieldName]; + } + + const responseName = selection.alias + ? selection.alias.value + : fieldName; + + if (!nodeAndDefs[responseName]) { + nodeAndDefs[responseName] = []; + } + + nodeAndDefs[responseName].push([parentType, selection, fieldDef]); + break; + } + + case _kinds.Kind.FRAGMENT_SPREAD: + fragmentNames[selection.name.value] = true; + break; + + case _kinds.Kind.INLINE_FRAGMENT: { + const typeCondition = selection.typeCondition; + const inlineFragmentType = typeCondition + ? (0, _typeFromAST.typeFromAST)(context.getSchema(), typeCondition) + : parentType; + + _collectFieldsAndFragmentNames( + context, + inlineFragmentType, + selection.selectionSet, + nodeAndDefs, + fragmentNames, + ); + + break; + } + } + } +} // Given a series of Conflicts which occurred between two sub-fields, generate +// a single Conflict. + +function subfieldConflicts(conflicts, responseName, node1, node2) { + if (conflicts.length > 0) { + return [ + [responseName, conflicts.map(([reason]) => reason)], + [node1, ...conflicts.map(([, fields1]) => fields1).flat()], + [node2, ...conflicts.map(([, , fields2]) => fields2).flat()], + ]; + } +} +/** + * A way to keep track of pairs of things when the ordering of the pair does not matter. + */ + +class PairSet { + constructor() { + this._data = new Map(); + } + + has(a, b, areMutuallyExclusive) { + var _this$_data$get; + + const [key1, key2] = a < b ? [a, b] : [b, a]; + const result = + (_this$_data$get = this._data.get(key1)) === null || + _this$_data$get === void 0 + ? void 0 + : _this$_data$get.get(key2); + + if (result === undefined) { + return false; + } // areMutuallyExclusive being false is a superset of being true, hence if + // we want to know if this PairSet "has" these two with no exclusivity, + // we have to ensure it was added as such. + + return areMutuallyExclusive ? true : areMutuallyExclusive === result; + } + + add(a, b, areMutuallyExclusive) { + const [key1, key2] = a < b ? [a, b] : [b, a]; + + const map = this._data.get(key1); + + if (map === undefined) { + this._data.set(key1, new Map([[key2, areMutuallyExclusive]])); + } else { + map.set(key2, areMutuallyExclusive); + } + } +} + + +/***/ }), + +/***/ 5904: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.PossibleFragmentSpreadsRule = PossibleFragmentSpreadsRule; + +var _inspect = __webpack_require__(8002); + +var _GraphQLError = __webpack_require__(5822); + +var _definition = __webpack_require__(5003); + +var _typeComparators = __webpack_require__(298); + +var _typeFromAST = __webpack_require__(5115); + +/** + * Possible fragment spread + * + * A fragment spread is only valid if the type condition could ever possibly + * be true: if there is a non-empty intersection of the possible parent types, + * and possible types which pass the type condition. + */ +function PossibleFragmentSpreadsRule(context) { + return { + InlineFragment(node) { + const fragType = context.getType(); + const parentType = context.getParentType(); + + if ( + (0, _definition.isCompositeType)(fragType) && + (0, _definition.isCompositeType)(parentType) && + !(0, _typeComparators.doTypesOverlap)( + context.getSchema(), + fragType, + parentType, + ) + ) { + const parentTypeStr = (0, _inspect.inspect)(parentType); + const fragTypeStr = (0, _inspect.inspect)(fragType); + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, + { + nodes: node, + }, + ), + ); + } + }, + + FragmentSpread(node) { + const fragName = node.name.value; + const fragType = getFragmentType(context, fragName); + const parentType = context.getParentType(); + + if ( + fragType && + parentType && + !(0, _typeComparators.doTypesOverlap)( + context.getSchema(), + fragType, + parentType, + ) + ) { + const parentTypeStr = (0, _inspect.inspect)(parentType); + const fragTypeStr = (0, _inspect.inspect)(fragType); + context.reportError( + new _GraphQLError.GraphQLError( + `Fragment "${fragName}" cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +function getFragmentType(context, name) { + const frag = context.getFragment(name); + + if (frag) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + frag.typeCondition, + ); + + if ((0, _definition.isCompositeType)(type)) { + return type; + } + } +} + + +/***/ }), + +/***/ 5715: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.PossibleTypeExtensionsRule = PossibleTypeExtensionsRule; + +var _didYouMean = __webpack_require__(100); + +var _inspect = __webpack_require__(8002); + +var _invariant = __webpack_require__(7706); + +var _suggestionList = __webpack_require__(8070); + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _predicates = __webpack_require__(1352); + +var _definition = __webpack_require__(5003); + +/** + * Possible type extension + * + * A type extension is only valid if the type is defined and has the same kind. + */ +function PossibleTypeExtensionsRule(context) { + const schema = context.getSchema(); + const definedTypes = Object.create(null); + + for (const def of context.getDocument().definitions) { + if ((0, _predicates.isTypeDefinitionNode)(def)) { + definedTypes[def.name.value] = def; + } + } + + return { + ScalarTypeExtension: checkExtension, + ObjectTypeExtension: checkExtension, + InterfaceTypeExtension: checkExtension, + UnionTypeExtension: checkExtension, + EnumTypeExtension: checkExtension, + InputObjectTypeExtension: checkExtension, + }; + + function checkExtension(node) { + const typeName = node.name.value; + const defNode = definedTypes[typeName]; + const existingType = + schema === null || schema === void 0 ? void 0 : schema.getType(typeName); + let expectedKind; + + if (defNode) { + expectedKind = defKindToExtKind[defNode.kind]; + } else if (existingType) { + expectedKind = typeToExtKind(existingType); + } + + if (expectedKind) { + if (expectedKind !== node.kind) { + const kindStr = extensionKindToTypeName(node.kind); + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot extend non-${kindStr} type "${typeName}".`, + { + nodes: defNode ? [defNode, node] : node, + }, + ), + ); + } + } else { + const allTypeNames = Object.keys({ + ...definedTypes, + ...(schema === null || schema === void 0 + ? void 0 + : schema.getTypeMap()), + }); + const suggestedTypes = (0, _suggestionList.suggestionList)( + typeName, + allTypeNames, + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Cannot extend type "${typeName}" because it is not defined.` + + (0, _didYouMean.didYouMean)(suggestedTypes), + { + nodes: node.name, + }, + ), + ); + } + } +} + +const defKindToExtKind = { + [_kinds.Kind.SCALAR_TYPE_DEFINITION]: _kinds.Kind.SCALAR_TYPE_EXTENSION, + [_kinds.Kind.OBJECT_TYPE_DEFINITION]: _kinds.Kind.OBJECT_TYPE_EXTENSION, + [_kinds.Kind.INTERFACE_TYPE_DEFINITION]: _kinds.Kind.INTERFACE_TYPE_EXTENSION, + [_kinds.Kind.UNION_TYPE_DEFINITION]: _kinds.Kind.UNION_TYPE_EXTENSION, + [_kinds.Kind.ENUM_TYPE_DEFINITION]: _kinds.Kind.ENUM_TYPE_EXTENSION, + [_kinds.Kind.INPUT_OBJECT_TYPE_DEFINITION]: + _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION, +}; + +function typeToExtKind(type) { + if ((0, _definition.isScalarType)(type)) { + return _kinds.Kind.SCALAR_TYPE_EXTENSION; + } + + if ((0, _definition.isObjectType)(type)) { + return _kinds.Kind.OBJECT_TYPE_EXTENSION; + } + + if ((0, _definition.isInterfaceType)(type)) { + return _kinds.Kind.INTERFACE_TYPE_EXTENSION; + } + + if ((0, _definition.isUnionType)(type)) { + return _kinds.Kind.UNION_TYPE_EXTENSION; + } + + if ((0, _definition.isEnumType)(type)) { + return _kinds.Kind.ENUM_TYPE_EXTENSION; + } + + if ((0, _definition.isInputObjectType)(type)) { + return _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION; + } + /* c8 ignore next 3 */ + // Not reachable. All possible types have been considered + + false || + (0, _invariant.invariant)( + false, + 'Unexpected type: ' + (0, _inspect.inspect)(type), + ); +} + +function extensionKindToTypeName(kind) { + switch (kind) { + case _kinds.Kind.SCALAR_TYPE_EXTENSION: + return 'scalar'; + + case _kinds.Kind.OBJECT_TYPE_EXTENSION: + return 'object'; + + case _kinds.Kind.INTERFACE_TYPE_EXTENSION: + return 'interface'; + + case _kinds.Kind.UNION_TYPE_EXTENSION: + return 'union'; + + case _kinds.Kind.ENUM_TYPE_EXTENSION: + return 'enum'; + + case _kinds.Kind.INPUT_OBJECT_TYPE_EXTENSION: + return 'input object'; + // Not reachable. All possible types have been considered + + /* c8 ignore next */ + + default: + false || + (0, _invariant.invariant)( + false, + 'Unexpected kind: ' + (0, _inspect.inspect)(kind), + ); + } +} + + +/***/ }), + +/***/ 4312: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ProvidedRequiredArgumentsOnDirectivesRule = + ProvidedRequiredArgumentsOnDirectivesRule; +exports.ProvidedRequiredArgumentsRule = ProvidedRequiredArgumentsRule; + +var _inspect = __webpack_require__(8002); + +var _keyMap = __webpack_require__(2863); + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _printer = __webpack_require__(3033); + +var _definition = __webpack_require__(5003); + +var _directives = __webpack_require__(7197); + +/** + * Provided required arguments + * + * A field or directive is only valid if all required (non-null without a + * default value) field arguments have been provided. + */ +function ProvidedRequiredArgumentsRule(context) { + return { + // eslint-disable-next-line new-cap + ...ProvidedRequiredArgumentsOnDirectivesRule(context), + Field: { + // Validate on leave to allow for deeper errors to appear first. + leave(fieldNode) { + var _fieldNode$arguments; + + const fieldDef = context.getFieldDef(); + + if (!fieldDef) { + return false; + } + + const providedArgs = new Set( // FIXME: https://github.com/graphql/graphql-js/issues/2203 + /* c8 ignore next */ + (_fieldNode$arguments = fieldNode.arguments) === null || + _fieldNode$arguments === void 0 + ? void 0 + : _fieldNode$arguments.map((arg) => arg.name.value), + ); + + for (const argDef of fieldDef.args) { + if ( + !providedArgs.has(argDef.name) && + (0, _definition.isRequiredArgument)(argDef) + ) { + const argTypeStr = (0, _inspect.inspect)(argDef.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${fieldDef.name}" argument "${argDef.name}" of type "${argTypeStr}" is required, but it was not provided.`, + { + nodes: fieldNode, + }, + ), + ); + } + } + }, + }, + }; +} +/** + * @internal + */ + +function ProvidedRequiredArgumentsOnDirectivesRule(context) { + var _schema$getDirectives; + + const requiredArgsMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = + (_schema$getDirectives = + schema === null || schema === void 0 + ? void 0 + : schema.getDirectives()) !== null && _schema$getDirectives !== void 0 + ? _schema$getDirectives + : _directives.specifiedDirectives; + + for (const directive of definedDirectives) { + requiredArgsMap[directive.name] = (0, _keyMap.keyMap)( + directive.args.filter(_definition.isRequiredArgument), + (arg) => arg.name, + ); + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + var _def$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argNodes = + (_def$arguments = def.arguments) !== null && _def$arguments !== void 0 + ? _def$arguments + : []; + requiredArgsMap[def.name.value] = (0, _keyMap.keyMap)( + argNodes.filter(isRequiredArgumentNode), + (arg) => arg.name.value, + ); + } + } + + return { + Directive: { + // Validate on leave to allow for deeper errors to appear first. + leave(directiveNode) { + const directiveName = directiveNode.name.value; + const requiredArgs = requiredArgsMap[directiveName]; + + if (requiredArgs) { + var _directiveNode$argume; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argNodes = + (_directiveNode$argume = directiveNode.arguments) !== null && + _directiveNode$argume !== void 0 + ? _directiveNode$argume + : []; + const argNodeMap = new Set(argNodes.map((arg) => arg.name.value)); + + for (const [argName, argDef] of Object.entries(requiredArgs)) { + if (!argNodeMap.has(argName)) { + const argType = (0, _definition.isType)(argDef.type) + ? (0, _inspect.inspect)(argDef.type) + : (0, _printer.print)(argDef.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${directiveName}" argument "${argName}" of type "${argType}" is required, but it was not provided.`, + { + nodes: directiveNode, + }, + ), + ); + } + } + } + }, + }, + }; +} + +function isRequiredArgumentNode(arg) { + return ( + arg.type.kind === _kinds.Kind.NON_NULL_TYPE && arg.defaultValue == null + ); +} + + +/***/ }), + +/***/ 7168: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ScalarLeafsRule = ScalarLeafsRule; + +var _inspect = __webpack_require__(8002); + +var _GraphQLError = __webpack_require__(5822); + +var _definition = __webpack_require__(5003); + +/** + * Scalar leafs + * + * A GraphQL document is valid only if all leaf fields (fields without + * sub selections) are of scalar or enum types. + */ +function ScalarLeafsRule(context) { + return { + Field(node) { + const type = context.getType(); + const selectionSet = node.selectionSet; + + if (type) { + if ((0, _definition.isLeafType)((0, _definition.getNamedType)(type))) { + if (selectionSet) { + const fieldName = node.name.value; + const typeStr = (0, _inspect.inspect)(type); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${fieldName}" must not have a selection since type "${typeStr}" has no subfields.`, + { + nodes: selectionSet, + }, + ), + ); + } + } else if (!selectionSet) { + const fieldName = node.name.value; + const typeStr = (0, _inspect.inspect)(type); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${fieldName}" of type "${typeStr}" must have a selection of subfields. Did you mean "${fieldName} { ... }"?`, + { + nodes: node, + }, + ), + ); + } + } + }, + }; +} + + +/***/ }), + +/***/ 4666: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.SingleFieldSubscriptionsRule = SingleFieldSubscriptionsRule; + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _collectFields = __webpack_require__(8950); + +/** + * Subscriptions must only include a non-introspection field. + * + * A GraphQL subscription is valid only if it contains a single root field and + * that root field is not an introspection field. + * + * See https://spec.graphql.org/draft/#sec-Single-root-field + */ +function SingleFieldSubscriptionsRule(context) { + return { + OperationDefinition(node) { + if (node.operation === 'subscription') { + const schema = context.getSchema(); + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType) { + const operationName = node.name ? node.name.value : null; + const variableValues = Object.create(null); + const document = context.getDocument(); + const fragments = Object.create(null); + + for (const definition of document.definitions) { + if (definition.kind === _kinds.Kind.FRAGMENT_DEFINITION) { + fragments[definition.name.value] = definition; + } + } + + const fields = (0, _collectFields.collectFields)( + schema, + fragments, + variableValues, + subscriptionType, + node.selectionSet, + ); + + if (fields.size > 1) { + const fieldSelectionLists = [...fields.values()]; + const extraFieldSelectionLists = fieldSelectionLists.slice(1); + const extraFieldSelections = extraFieldSelectionLists.flat(); + context.reportError( + new _GraphQLError.GraphQLError( + operationName != null + ? `Subscription "${operationName}" must select only one top level field.` + : 'Anonymous Subscription must select only one top level field.', + { + nodes: extraFieldSelections, + }, + ), + ); + } + + for (const fieldNodes of fields.values()) { + const field = fieldNodes[0]; + const fieldName = field.name.value; + + if (fieldName.startsWith('__')) { + context.reportError( + new _GraphQLError.GraphQLError( + operationName != null + ? `Subscription "${operationName}" must not select an introspection top level field.` + : 'Anonymous Subscription must not select an introspection top level field.', + { + nodes: fieldNodes, + }, + ), + ); + } + } + } + } + }, + }; +} + + +/***/ }), + +/***/ 3878: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueArgumentDefinitionNamesRule = UniqueArgumentDefinitionNamesRule; + +var _groupBy = __webpack_require__(4620); + +var _GraphQLError = __webpack_require__(5822); + +/** + * Unique argument definition names + * + * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. + * A GraphQL Directive is only valid if all its arguments are uniquely named. + */ +function UniqueArgumentDefinitionNamesRule(context) { + return { + DirectiveDefinition(directiveNode) { + var _directiveNode$argume; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argumentNodes = + (_directiveNode$argume = directiveNode.arguments) !== null && + _directiveNode$argume !== void 0 + ? _directiveNode$argume + : []; + return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes); + }, + + InterfaceTypeDefinition: checkArgUniquenessPerField, + InterfaceTypeExtension: checkArgUniquenessPerField, + ObjectTypeDefinition: checkArgUniquenessPerField, + ObjectTypeExtension: checkArgUniquenessPerField, + }; + + function checkArgUniquenessPerField(typeNode) { + var _typeNode$fields; + + const typeName = typeNode.name.value; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const fieldNodes = + (_typeNode$fields = typeNode.fields) !== null && + _typeNode$fields !== void 0 + ? _typeNode$fields + : []; + + for (const fieldDef of fieldNodes) { + var _fieldDef$arguments; + + const fieldName = fieldDef.name.value; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const argumentNodes = + (_fieldDef$arguments = fieldDef.arguments) !== null && + _fieldDef$arguments !== void 0 + ? _fieldDef$arguments + : []; + checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes); + } + + return false; + } + + function checkArgUniqueness(parentName, argumentNodes) { + const seenArgs = (0, _groupBy.groupBy)( + argumentNodes, + (arg) => arg.name.value, + ); + + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + `Argument "${parentName}(${argName}:)" can only be defined once.`, + { + nodes: argNodes.map((node) => node.name), + }, + ), + ); + } + } + + return false; + } +} + + +/***/ }), + +/***/ 4986: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueArgumentNamesRule = UniqueArgumentNamesRule; + +var _groupBy = __webpack_require__(4620); + +var _GraphQLError = __webpack_require__(5822); + +/** + * Unique argument names + * + * A GraphQL field or directive is only valid if all supplied arguments are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + */ +function UniqueArgumentNamesRule(context) { + return { + Field: checkArgUniqueness, + Directive: checkArgUniqueness, + }; + + function checkArgUniqueness(parentNode) { + var _parentNode$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argumentNodes = + (_parentNode$arguments = parentNode.arguments) !== null && + _parentNode$arguments !== void 0 + ? _parentNode$arguments + : []; + const seenArgs = (0, _groupBy.groupBy)( + argumentNodes, + (arg) => arg.name.value, + ); + + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one argument named "${argName}".`, + { + nodes: argNodes.map((node) => node.name), + }, + ), + ); + } + } + } +} + + +/***/ }), + +/***/ 6753: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueDirectiveNamesRule = UniqueDirectiveNamesRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * Unique directive names + * + * A GraphQL document is only valid if all defined directives have unique names. + */ +function UniqueDirectiveNamesRule(context) { + const knownDirectiveNames = Object.create(null); + const schema = context.getSchema(); + return { + DirectiveDefinition(node) { + const directiveName = node.name.value; + + if ( + schema !== null && + schema !== void 0 && + schema.getDirective(directiveName) + ) { + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${directiveName}" already exists in the schema. It cannot be redefined.`, + { + nodes: node.name, + }, + ), + ); + return; + } + + if (knownDirectiveNames[directiveName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one directive named "@${directiveName}".`, + { + nodes: [knownDirectiveNames[directiveName], node.name], + }, + ), + ); + } else { + knownDirectiveNames[directiveName] = node.name; + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 3576: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueDirectivesPerLocationRule = UniqueDirectivesPerLocationRule; + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _predicates = __webpack_require__(1352); + +var _directives = __webpack_require__(7197); + +/** + * Unique directive names per location + * + * A GraphQL document is only valid if all non-repeatable directives at + * a given location are uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location + */ +function UniqueDirectivesPerLocationRule(context) { + const uniqueDirectiveMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _directives.specifiedDirectives; + + for (const directive of definedDirectives) { + uniqueDirectiveMap[directive.name] = !directive.isRepeatable; + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _kinds.Kind.DIRECTIVE_DEFINITION) { + uniqueDirectiveMap[def.name.value] = !def.repeatable; + } + } + + const schemaDirectives = Object.create(null); + const typeDirectivesMap = Object.create(null); + return { + // Many different AST nodes may contain directives. Rather than listing + // them all, just listen for entering any node, and check to see if it + // defines any directives. + enter(node) { + if (!('directives' in node) || !node.directives) { + return; + } + + let seenDirectives; + + if ( + node.kind === _kinds.Kind.SCHEMA_DEFINITION || + node.kind === _kinds.Kind.SCHEMA_EXTENSION + ) { + seenDirectives = schemaDirectives; + } else if ( + (0, _predicates.isTypeDefinitionNode)(node) || + (0, _predicates.isTypeExtensionNode)(node) + ) { + const typeName = node.name.value; + seenDirectives = typeDirectivesMap[typeName]; + + if (seenDirectives === undefined) { + typeDirectivesMap[typeName] = seenDirectives = Object.create(null); + } + } else { + seenDirectives = Object.create(null); + } + + for (const directive of node.directives) { + const directiveName = directive.name.value; + + if (uniqueDirectiveMap[directiveName]) { + if (seenDirectives[directiveName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `The directive "@${directiveName}" can only be used once at this location.`, + { + nodes: [seenDirectives[directiveName], directive], + }, + ), + ); + } else { + seenDirectives[directiveName] = directive; + } + } + } + }, + }; +} + + +/***/ }), + +/***/ 6400: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueEnumValueNamesRule = UniqueEnumValueNamesRule; + +var _GraphQLError = __webpack_require__(5822); + +var _definition = __webpack_require__(5003); + +/** + * Unique enum value names + * + * A GraphQL enum type is only valid if all its values are uniquely named. + */ +function UniqueEnumValueNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownValueNames = Object.create(null); + return { + EnumTypeDefinition: checkValueUniqueness, + EnumTypeExtension: checkValueUniqueness, + }; + + function checkValueUniqueness(node) { + var _node$values; + + const typeName = node.name.value; + + if (!knownValueNames[typeName]) { + knownValueNames[typeName] = Object.create(null); + } // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const valueNodes = + (_node$values = node.values) !== null && _node$values !== void 0 + ? _node$values + : []; + const valueNames = knownValueNames[typeName]; + + for (const valueDef of valueNodes) { + const valueName = valueDef.name.value; + const existingType = existingTypeMap[typeName]; + + if ( + (0, _definition.isEnumType)(existingType) && + existingType.getValue(valueName) + ) { + context.reportError( + new _GraphQLError.GraphQLError( + `Enum value "${typeName}.${valueName}" already exists in the schema. It cannot also be defined in this type extension.`, + { + nodes: valueDef.name, + }, + ), + ); + } else if (valueNames[valueName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `Enum value "${typeName}.${valueName}" can only be defined once.`, + { + nodes: [valueNames[valueName], valueDef.name], + }, + ), + ); + } else { + valueNames[valueName] = valueDef.name; + } + } + + return false; + } +} + + +/***/ }), + +/***/ 4046: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueFieldDefinitionNamesRule = UniqueFieldDefinitionNamesRule; + +var _GraphQLError = __webpack_require__(5822); + +var _definition = __webpack_require__(5003); + +/** + * Unique field definition names + * + * A GraphQL complex type is only valid if all its fields are uniquely named. + */ +function UniqueFieldDefinitionNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownFieldNames = Object.create(null); + return { + InputObjectTypeDefinition: checkFieldUniqueness, + InputObjectTypeExtension: checkFieldUniqueness, + InterfaceTypeDefinition: checkFieldUniqueness, + InterfaceTypeExtension: checkFieldUniqueness, + ObjectTypeDefinition: checkFieldUniqueness, + ObjectTypeExtension: checkFieldUniqueness, + }; + + function checkFieldUniqueness(node) { + var _node$fields; + + const typeName = node.name.value; + + if (!knownFieldNames[typeName]) { + knownFieldNames[typeName] = Object.create(null); + } // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const fieldNodes = + (_node$fields = node.fields) !== null && _node$fields !== void 0 + ? _node$fields + : []; + const fieldNames = knownFieldNames[typeName]; + + for (const fieldDef of fieldNodes) { + const fieldName = fieldDef.name.value; + + if (hasField(existingTypeMap[typeName], fieldName)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${typeName}.${fieldName}" already exists in the schema. It cannot also be defined in this type extension.`, + { + nodes: fieldDef.name, + }, + ), + ); + } else if (fieldNames[fieldName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${typeName}.${fieldName}" can only be defined once.`, + { + nodes: [fieldNames[fieldName], fieldDef.name], + }, + ), + ); + } else { + fieldNames[fieldName] = fieldDef.name; + } + } + + return false; + } +} + +function hasField(type, fieldName) { + if ( + (0, _definition.isObjectType)(type) || + (0, _definition.isInterfaceType)(type) || + (0, _definition.isInputObjectType)(type) + ) { + return type.getFields()[fieldName] != null; + } + + return false; +} + + +/***/ }), + +/***/ 5883: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueFragmentNamesRule = UniqueFragmentNamesRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * Unique fragment names + * + * A GraphQL document is only valid if all defined fragments have unique names. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness + */ +function UniqueFragmentNamesRule(context) { + const knownFragmentNames = Object.create(null); + return { + OperationDefinition: () => false, + + FragmentDefinition(node) { + const fragmentName = node.name.value; + + if (knownFragmentNames[fragmentName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one fragment named "${fragmentName}".`, + { + nodes: [knownFragmentNames[fragmentName], node.name], + }, + ), + ); + } else { + knownFragmentNames[fragmentName] = node.name; + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 4313: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueInputFieldNamesRule = UniqueInputFieldNamesRule; + +var _invariant = __webpack_require__(7706); + +var _GraphQLError = __webpack_require__(5822); + +/** + * Unique input field names + * + * A GraphQL input object value is only valid if all supplied fields are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness + */ +function UniqueInputFieldNamesRule(context) { + const knownNameStack = []; + let knownNames = Object.create(null); + return { + ObjectValue: { + enter() { + knownNameStack.push(knownNames); + knownNames = Object.create(null); + }, + + leave() { + const prevKnownNames = knownNameStack.pop(); + prevKnownNames || (0, _invariant.invariant)(false); + knownNames = prevKnownNames; + }, + }, + + ObjectField(node) { + const fieldName = node.name.value; + + if (knownNames[fieldName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one input field named "${fieldName}".`, + { + nodes: [knownNames[fieldName], node.name], + }, + ), + ); + } else { + knownNames[fieldName] = node.name; + } + }, + }; +} + + +/***/ }), + +/***/ 2139: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueOperationNamesRule = UniqueOperationNamesRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * Unique operation names + * + * A GraphQL document is only valid if all defined operations have unique names. + * + * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness + */ +function UniqueOperationNamesRule(context) { + const knownOperationNames = Object.create(null); + return { + OperationDefinition(node) { + const operationName = node.name; + + if (operationName) { + if (knownOperationNames[operationName.value]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one operation named "${operationName.value}".`, + { + nodes: [ + knownOperationNames[operationName.value], + operationName, + ], + }, + ), + ); + } else { + knownOperationNames[operationName.value] = operationName; + } + } + + return false; + }, + + FragmentDefinition: () => false, + }; +} + + +/***/ }), + +/***/ 856: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueOperationTypesRule = UniqueOperationTypesRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * Unique operation types + * + * A GraphQL document is only valid if it has only one type per operation. + */ +function UniqueOperationTypesRule(context) { + const schema = context.getSchema(); + const definedOperationTypes = Object.create(null); + const existingOperationTypes = schema + ? { + query: schema.getQueryType(), + mutation: schema.getMutationType(), + subscription: schema.getSubscriptionType(), + } + : {}; + return { + SchemaDefinition: checkOperationTypes, + SchemaExtension: checkOperationTypes, + }; + + function checkOperationTypes(node) { + var _node$operationTypes; + + // See: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const operationTypesNodes = + (_node$operationTypes = node.operationTypes) !== null && + _node$operationTypes !== void 0 + ? _node$operationTypes + : []; + + for (const operationType of operationTypesNodes) { + const operation = operationType.operation; + const alreadyDefinedOperationType = definedOperationTypes[operation]; + + if (existingOperationTypes[operation]) { + context.reportError( + new _GraphQLError.GraphQLError( + `Type for ${operation} already defined in the schema. It cannot be redefined.`, + { + nodes: operationType, + }, + ), + ); + } else if (alreadyDefinedOperationType) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one ${operation} type in schema.`, + { + nodes: [alreadyDefinedOperationType, operationType], + }, + ), + ); + } else { + definedOperationTypes[operation] = operationType; + } + } + + return false; + } +} + + +/***/ }), + +/***/ 1686: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueTypeNamesRule = UniqueTypeNamesRule; + +var _GraphQLError = __webpack_require__(5822); + +/** + * Unique type names + * + * A GraphQL document is only valid if all defined types have unique names. + */ +function UniqueTypeNamesRule(context) { + const knownTypeNames = Object.create(null); + const schema = context.getSchema(); + return { + ScalarTypeDefinition: checkTypeName, + ObjectTypeDefinition: checkTypeName, + InterfaceTypeDefinition: checkTypeName, + UnionTypeDefinition: checkTypeName, + EnumTypeDefinition: checkTypeName, + InputObjectTypeDefinition: checkTypeName, + }; + + function checkTypeName(node) { + const typeName = node.name.value; + + if (schema !== null && schema !== void 0 && schema.getType(typeName)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Type "${typeName}" already exists in the schema. It cannot also be defined in this type definition.`, + { + nodes: node.name, + }, + ), + ); + return; + } + + if (knownTypeNames[typeName]) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one type named "${typeName}".`, + { + nodes: [knownTypeNames[typeName], node.name], + }, + ), + ); + } else { + knownTypeNames[typeName] = node.name; + } + + return false; + } +} + + +/***/ }), + +/***/ 4243: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.UniqueVariableNamesRule = UniqueVariableNamesRule; + +var _groupBy = __webpack_require__(4620); + +var _GraphQLError = __webpack_require__(5822); + +/** + * Unique variable names + * + * A GraphQL operation is only valid if all its variables are uniquely named. + */ +function UniqueVariableNamesRule(context) { + return { + OperationDefinition(operationNode) { + var _operationNode$variab; + + // See: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const variableDefinitions = + (_operationNode$variab = operationNode.variableDefinitions) !== null && + _operationNode$variab !== void 0 + ? _operationNode$variab + : []; + const seenVariableDefinitions = (0, _groupBy.groupBy)( + variableDefinitions, + (node) => node.variable.name.value, + ); + + for (const [variableName, variableNodes] of seenVariableDefinitions) { + if (variableNodes.length > 1) { + context.reportError( + new _GraphQLError.GraphQLError( + `There can be only one variable named "$${variableName}".`, + { + nodes: variableNodes.map((node) => node.variable.name), + }, + ), + ); + } + } + }, + }; +} + + +/***/ }), + +/***/ 6869: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.ValuesOfCorrectTypeRule = ValuesOfCorrectTypeRule; + +var _didYouMean = __webpack_require__(100); + +var _inspect = __webpack_require__(8002); + +var _keyMap = __webpack_require__(2863); + +var _suggestionList = __webpack_require__(8070); + +var _GraphQLError = __webpack_require__(5822); + +var _printer = __webpack_require__(3033); + +var _definition = __webpack_require__(5003); + +/** + * Value literals of correct type + * + * A GraphQL document is only valid if all value literals are of the type + * expected at their position. + * + * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type + */ +function ValuesOfCorrectTypeRule(context) { + return { + ListValue(node) { + // Note: TypeInfo will traverse into a list's item type, so look to the + // parent input type to check if it is a list. + const type = (0, _definition.getNullableType)( + context.getParentInputType(), + ); + + if (!(0, _definition.isListType)(type)) { + isValidValueNode(context, node); + return false; // Don't traverse further. + } + }, + + ObjectValue(node) { + const type = (0, _definition.getNamedType)(context.getInputType()); + + if (!(0, _definition.isInputObjectType)(type)) { + isValidValueNode(context, node); + return false; // Don't traverse further. + } // Ensure every required field exists. + + const fieldNodeMap = (0, _keyMap.keyMap)( + node.fields, + (field) => field.name.value, + ); + + for (const fieldDef of Object.values(type.getFields())) { + const fieldNode = fieldNodeMap[fieldDef.name]; + + if (!fieldNode && (0, _definition.isRequiredInputField)(fieldDef)) { + const typeStr = (0, _inspect.inspect)(fieldDef.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${type.name}.${fieldDef.name}" of required type "${typeStr}" was not provided.`, + { + nodes: node, + }, + ), + ); + } + } + }, + + ObjectField(node) { + const parentType = (0, _definition.getNamedType)( + context.getParentInputType(), + ); + const fieldType = context.getInputType(); + + if (!fieldType && (0, _definition.isInputObjectType)(parentType)) { + const suggestions = (0, _suggestionList.suggestionList)( + node.name.value, + Object.keys(parentType.getFields()), + ); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${node.name.value}" is not defined by type "${parentType.name}".` + + (0, _didYouMean.didYouMean)(suggestions), + { + nodes: node, + }, + ), + ); + } + }, + + NullValue(node) { + const type = context.getInputType(); + + if ((0, _definition.isNonNullType)(type)) { + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${(0, _inspect.inspect)( + type, + )}", found ${(0, _printer.print)(node)}.`, + { + nodes: node, + }, + ), + ); + } + }, + + EnumValue: (node) => isValidValueNode(context, node), + IntValue: (node) => isValidValueNode(context, node), + FloatValue: (node) => isValidValueNode(context, node), + StringValue: (node) => isValidValueNode(context, node), + BooleanValue: (node) => isValidValueNode(context, node), + }; +} +/** + * Any value literal may be a valid representation of a Scalar, depending on + * that scalar type. + */ + +function isValidValueNode(context, node) { + // Report any error at the full type expected by the location. + const locationType = context.getInputType(); + + if (!locationType) { + return; + } + + const type = (0, _definition.getNamedType)(locationType); + + if (!(0, _definition.isLeafType)(type)) { + const typeStr = (0, _inspect.inspect)(locationType); + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${typeStr}", found ${(0, _printer.print)( + node, + )}.`, + { + nodes: node, + }, + ), + ); + return; + } // Scalars and Enums determine if a literal value is valid via parseLiteral(), + // which may throw or return an invalid value to indicate failure. + + try { + const parseResult = type.parseLiteral( + node, + undefined, + /* variables */ + ); + + if (parseResult === undefined) { + const typeStr = (0, _inspect.inspect)(locationType); + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${typeStr}", found ${(0, _printer.print)( + node, + )}.`, + { + nodes: node, + }, + ), + ); + } + } catch (error) { + const typeStr = (0, _inspect.inspect)(locationType); + + if (error instanceof _GraphQLError.GraphQLError) { + context.reportError(error); + } else { + context.reportError( + new _GraphQLError.GraphQLError( + `Expected value of type "${typeStr}", found ${(0, _printer.print)( + node, + )}; ` + error.message, + { + nodes: node, + originalError: error, + }, + ), + ); + } + } +} + + +/***/ }), + +/***/ 4942: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.VariablesAreInputTypesRule = VariablesAreInputTypesRule; + +var _GraphQLError = __webpack_require__(5822); + +var _printer = __webpack_require__(3033); + +var _definition = __webpack_require__(5003); + +var _typeFromAST = __webpack_require__(5115); + +/** + * Variables are input types + * + * A GraphQL operation is only valid if all the variables it defines are of + * input types (scalar, enum, or input object). + * + * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types + */ +function VariablesAreInputTypesRule(context) { + return { + VariableDefinition(node) { + const type = (0, _typeFromAST.typeFromAST)( + context.getSchema(), + node.type, + ); + + if (type !== undefined && !(0, _definition.isInputType)(type)) { + const variableName = node.variable.name.value; + const typeName = (0, _printer.print)(node.type); + context.reportError( + new _GraphQLError.GraphQLError( + `Variable "$${variableName}" cannot be non-input type "${typeName}".`, + { + nodes: node.type, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 8034: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.VariablesInAllowedPositionRule = VariablesInAllowedPositionRule; + +var _inspect = __webpack_require__(8002); + +var _GraphQLError = __webpack_require__(5822); + +var _kinds = __webpack_require__(2828); + +var _definition = __webpack_require__(5003); + +var _typeComparators = __webpack_require__(298); + +var _typeFromAST = __webpack_require__(5115); + +/** + * Variables in allowed position + * + * Variable usages must be compatible with the arguments they are passed to. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed + */ +function VariablesInAllowedPositionRule(context) { + let varDefMap = Object.create(null); + return { + OperationDefinition: { + enter() { + varDefMap = Object.create(null); + }, + + leave(operation) { + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node, type, defaultValue } of usages) { + const varName = node.name.value; + const varDef = varDefMap[varName]; + + if (varDef && type) { + // A var type is allowed if it is the same or more strict (e.g. is + // a subtype of) than the expected type. It can be more strict if + // the variable type is non-null when the expected type is nullable. + // If both are list types, the variable item type can be more strict + // than the expected item type (contravariant). + const schema = context.getSchema(); + const varType = (0, _typeFromAST.typeFromAST)(schema, varDef.type); + + if ( + varType && + !allowedVariableUsage( + schema, + varType, + varDef.defaultValue, + type, + defaultValue, + ) + ) { + const varTypeStr = (0, _inspect.inspect)(varType); + const typeStr = (0, _inspect.inspect)(type); + context.reportError( + new _GraphQLError.GraphQLError( + `Variable "$${varName}" of type "${varTypeStr}" used in position expecting type "${typeStr}".`, + { + nodes: [varDef, node], + }, + ), + ); + } + } + } + }, + }, + + VariableDefinition(node) { + varDefMap[node.variable.name.value] = node; + }, + }; +} +/** + * Returns true if the variable is allowed in the location it was found, + * which includes considering if default values exist for either the variable + * or the location at which it is located. + */ + +function allowedVariableUsage( + schema, + varType, + varDefaultValue, + locationType, + locationDefaultValue, +) { + if ( + (0, _definition.isNonNullType)(locationType) && + !(0, _definition.isNonNullType)(varType) + ) { + const hasNonNullVariableDefaultValue = + varDefaultValue != null && varDefaultValue.kind !== _kinds.Kind.NULL; + const hasLocationDefaultValue = locationDefaultValue !== undefined; + + if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) { + return false; + } + + const nullableLocationType = locationType.ofType; + return (0, _typeComparators.isTypeSubTypeOf)( + schema, + varType, + nullableLocationType, + ); + } + + return (0, _typeComparators.isTypeSubTypeOf)(schema, varType, locationType); +} + + +/***/ }), + +/***/ 2860: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoDeprecatedCustomRule = NoDeprecatedCustomRule; + +var _invariant = __webpack_require__(7706); + +var _GraphQLError = __webpack_require__(5822); + +var _definition = __webpack_require__(5003); + +/** + * No deprecated + * + * A GraphQL document is only valid if all selected fields and all used enum values have not been + * deprecated. + * + * Note: This rule is optional and is not part of the Validation section of the GraphQL + * Specification. The main purpose of this rule is detection of deprecated usages and not + * necessarily to forbid their use when querying a service. + */ +function NoDeprecatedCustomRule(context) { + return { + Field(node) { + const fieldDef = context.getFieldDef(); + const deprecationReason = + fieldDef === null || fieldDef === void 0 + ? void 0 + : fieldDef.deprecationReason; + + if (fieldDef && deprecationReason != null) { + const parentType = context.getParentType(); + parentType != null || (0, _invariant.invariant)(false); + context.reportError( + new _GraphQLError.GraphQLError( + `The field ${parentType.name}.${fieldDef.name} is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + }, + + Argument(node) { + const argDef = context.getArgument(); + const deprecationReason = + argDef === null || argDef === void 0 + ? void 0 + : argDef.deprecationReason; + + if (argDef && deprecationReason != null) { + const directiveDef = context.getDirective(); + + if (directiveDef != null) { + context.reportError( + new _GraphQLError.GraphQLError( + `Directive "@${directiveDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } else { + const parentType = context.getParentType(); + const fieldDef = context.getFieldDef(); + (parentType != null && fieldDef != null) || + (0, _invariant.invariant)(false); + context.reportError( + new _GraphQLError.GraphQLError( + `Field "${parentType.name}.${fieldDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + } + }, + + ObjectField(node) { + const inputObjectDef = (0, _definition.getNamedType)( + context.getParentInputType(), + ); + + if ((0, _definition.isInputObjectType)(inputObjectDef)) { + const inputFieldDef = inputObjectDef.getFields()[node.name.value]; + const deprecationReason = + inputFieldDef === null || inputFieldDef === void 0 + ? void 0 + : inputFieldDef.deprecationReason; + + if (deprecationReason != null) { + context.reportError( + new _GraphQLError.GraphQLError( + `The input field ${inputObjectDef.name}.${inputFieldDef.name} is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + } + }, + + EnumValue(node) { + const enumValueDef = context.getEnumValue(); + const deprecationReason = + enumValueDef === null || enumValueDef === void 0 + ? void 0 + : enumValueDef.deprecationReason; + + if (enumValueDef && deprecationReason != null) { + const enumTypeDef = (0, _definition.getNamedType)( + context.getInputType(), + ); + enumTypeDef != null || (0, _invariant.invariant)(false); + context.reportError( + new _GraphQLError.GraphQLError( + `The enum value "${enumTypeDef.name}.${enumValueDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 2276: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.NoSchemaIntrospectionCustomRule = NoSchemaIntrospectionCustomRule; + +var _GraphQLError = __webpack_require__(5822); + +var _definition = __webpack_require__(5003); + +var _introspection = __webpack_require__(8155); + +/** + * Prohibit introspection queries + * + * A GraphQL document is only valid if all fields selected are not fields that + * return an introspection type. + * + * Note: This rule is optional and is not part of the Validation section of the + * GraphQL Specification. This rule effectively disables introspection, which + * does not reflect best practices and should only be done if absolutely necessary. + */ +function NoSchemaIntrospectionCustomRule(context) { + return { + Field(node) { + const type = (0, _definition.getNamedType)(context.getType()); + + if (type && (0, _introspection.isIntrospectionType)(type)) { + context.reportError( + new _GraphQLError.GraphQLError( + `GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 4710: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.specifiedSDLRules = exports.specifiedRules = void 0; + +var _ExecutableDefinitionsRule = __webpack_require__(5285); + +var _FieldsOnCorrectTypeRule = __webpack_require__(9426); + +var _FragmentsOnCompositeTypesRule = __webpack_require__(3558); + +var _KnownArgumentNamesRule = __webpack_require__(9989); + +var _KnownDirectivesRule = __webpack_require__(2826); + +var _KnownFragmentNamesRule = __webpack_require__(1843); + +var _KnownTypeNamesRule = __webpack_require__(5961); + +var _LoneAnonymousOperationRule = __webpack_require__(870); + +var _LoneSchemaDefinitionRule = __webpack_require__(3411); + +var _NoFragmentCyclesRule = __webpack_require__(658); + +var _NoUndefinedVariablesRule = __webpack_require__(7459); + +var _NoUnusedFragmentsRule = __webpack_require__(7317); + +var _NoUnusedVariablesRule = __webpack_require__(8769); + +var _OverlappingFieldsCanBeMergedRule = __webpack_require__(4331); + +var _PossibleFragmentSpreadsRule = __webpack_require__(5904); + +var _PossibleTypeExtensionsRule = __webpack_require__(5715); + +var _ProvidedRequiredArgumentsRule = __webpack_require__(4312); + +var _ScalarLeafsRule = __webpack_require__(7168); + +var _SingleFieldSubscriptionsRule = __webpack_require__(4666); + +var _UniqueArgumentDefinitionNamesRule = __webpack_require__(3878); + +var _UniqueArgumentNamesRule = __webpack_require__(4986); + +var _UniqueDirectiveNamesRule = __webpack_require__(6753); + +var _UniqueDirectivesPerLocationRule = __webpack_require__(3576); + +var _UniqueEnumValueNamesRule = __webpack_require__(6400); + +var _UniqueFieldDefinitionNamesRule = __webpack_require__(4046); + +var _UniqueFragmentNamesRule = __webpack_require__(5883); + +var _UniqueInputFieldNamesRule = __webpack_require__(4313); + +var _UniqueOperationNamesRule = __webpack_require__(2139); + +var _UniqueOperationTypesRule = __webpack_require__(856); + +var _UniqueTypeNamesRule = __webpack_require__(1686); + +var _UniqueVariableNamesRule = __webpack_require__(4243); + +var _ValuesOfCorrectTypeRule = __webpack_require__(6869); + +var _VariablesAreInputTypesRule = __webpack_require__(4942); + +var _VariablesInAllowedPositionRule = __webpack_require__(8034); + +// Spec Section: "Executable Definitions" +// Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" +// Spec Section: "Fragments on Composite Types" +// Spec Section: "Argument Names" +// Spec Section: "Directives Are Defined" +// Spec Section: "Fragment spread target defined" +// Spec Section: "Fragment Spread Type Existence" +// Spec Section: "Lone Anonymous Operation" +// SDL-specific validation rules +// Spec Section: "Fragments must not form cycles" +// Spec Section: "All Variable Used Defined" +// Spec Section: "Fragments must be used" +// Spec Section: "All Variables Used" +// Spec Section: "Field Selection Merging" +// Spec Section: "Fragment spread is possible" +// Spec Section: "Argument Optionality" +// Spec Section: "Leaf Field Selections" +// Spec Section: "Subscriptions with Single Root Field" +// Spec Section: "Argument Uniqueness" +// Spec Section: "Directives Are Unique Per Location" +// Spec Section: "Fragment Name Uniqueness" +// Spec Section: "Input Object Field Uniqueness" +// Spec Section: "Operation Name Uniqueness" +// Spec Section: "Variable Uniqueness" +// Spec Section: "Value Type Correctness" +// Spec Section: "Variables are Input Types" +// Spec Section: "All Variable Usages Are Allowed" + +/** + * This set includes all validation rules defined by the GraphQL spec. + * + * The order of the rules in this list has been adjusted to lead to the + * most clear output when encountering multiple validation errors. + */ +const specifiedRules = Object.freeze([ + _ExecutableDefinitionsRule.ExecutableDefinitionsRule, + _UniqueOperationNamesRule.UniqueOperationNamesRule, + _LoneAnonymousOperationRule.LoneAnonymousOperationRule, + _SingleFieldSubscriptionsRule.SingleFieldSubscriptionsRule, + _KnownTypeNamesRule.KnownTypeNamesRule, + _FragmentsOnCompositeTypesRule.FragmentsOnCompositeTypesRule, + _VariablesAreInputTypesRule.VariablesAreInputTypesRule, + _ScalarLeafsRule.ScalarLeafsRule, + _FieldsOnCorrectTypeRule.FieldsOnCorrectTypeRule, + _UniqueFragmentNamesRule.UniqueFragmentNamesRule, + _KnownFragmentNamesRule.KnownFragmentNamesRule, + _NoUnusedFragmentsRule.NoUnusedFragmentsRule, + _PossibleFragmentSpreadsRule.PossibleFragmentSpreadsRule, + _NoFragmentCyclesRule.NoFragmentCyclesRule, + _UniqueVariableNamesRule.UniqueVariableNamesRule, + _NoUndefinedVariablesRule.NoUndefinedVariablesRule, + _NoUnusedVariablesRule.NoUnusedVariablesRule, + _KnownDirectivesRule.KnownDirectivesRule, + _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule, + _KnownArgumentNamesRule.KnownArgumentNamesRule, + _UniqueArgumentNamesRule.UniqueArgumentNamesRule, + _ValuesOfCorrectTypeRule.ValuesOfCorrectTypeRule, + _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsRule, + _VariablesInAllowedPositionRule.VariablesInAllowedPositionRule, + _OverlappingFieldsCanBeMergedRule.OverlappingFieldsCanBeMergedRule, + _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule, +]); +/** + * @internal + */ + +exports.specifiedRules = specifiedRules; +const specifiedSDLRules = Object.freeze([ + _LoneSchemaDefinitionRule.LoneSchemaDefinitionRule, + _UniqueOperationTypesRule.UniqueOperationTypesRule, + _UniqueTypeNamesRule.UniqueTypeNamesRule, + _UniqueEnumValueNamesRule.UniqueEnumValueNamesRule, + _UniqueFieldDefinitionNamesRule.UniqueFieldDefinitionNamesRule, + _UniqueArgumentDefinitionNamesRule.UniqueArgumentDefinitionNamesRule, + _UniqueDirectiveNamesRule.UniqueDirectiveNamesRule, + _KnownTypeNamesRule.KnownTypeNamesRule, + _KnownDirectivesRule.KnownDirectivesRule, + _UniqueDirectivesPerLocationRule.UniqueDirectivesPerLocationRule, + _PossibleTypeExtensionsRule.PossibleTypeExtensionsRule, + _KnownArgumentNamesRule.KnownArgumentNamesOnDirectivesRule, + _UniqueArgumentNamesRule.UniqueArgumentNamesRule, + _UniqueInputFieldNamesRule.UniqueInputFieldNamesRule, + _ProvidedRequiredArgumentsRule.ProvidedRequiredArgumentsOnDirectivesRule, +]); +exports.specifiedSDLRules = specifiedSDLRules; + + +/***/ }), + +/***/ 9504: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", ({ + value: true, +})); +exports.assertValidSDL = assertValidSDL; +exports.assertValidSDLExtension = assertValidSDLExtension; +exports.validate = validate; +exports.validateSDL = validateSDL; + +var _devAssert = __webpack_require__(7242); + +var _GraphQLError = __webpack_require__(5822); + +var _visitor = __webpack_require__(285); + +var _validate = __webpack_require__(1671); + +var _TypeInfo = __webpack_require__(6226); + +var _specifiedRules = __webpack_require__(4710); + +var _ValidationContext = __webpack_require__(3955); + +/** + * Implements the "Validation" section of the spec. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the document is valid. + * + * A list of specific validation rules may be provided. If not provided, the + * default list of rules defined by the GraphQL specification will be used. + * + * Each validation rules is a function which returns a visitor + * (see the language/visitor API). Visitor methods are expected to return + * GraphQLErrors, or Arrays of GraphQLErrors when invalid. + * + * Validate will stop validation after a `maxErrors` limit has been reached. + * Attackers can send pathologically invalid queries to induce a DoS attack, + * so by default `maxErrors` set to 100 errors. + * + * Optionally a custom TypeInfo instance may be provided. If not provided, one + * will be created from the provided schema. + */ +function validate( + schema, + documentAST, + rules = _specifiedRules.specifiedRules, + options, + /** @deprecated will be removed in 17.0.0 */ + typeInfo = new _TypeInfo.TypeInfo(schema), +) { + var _options$maxErrors; + + const maxErrors = + (_options$maxErrors = + options === null || options === void 0 ? void 0 : options.maxErrors) !== + null && _options$maxErrors !== void 0 + ? _options$maxErrors + : 100; + documentAST || (0, _devAssert.devAssert)(false, 'Must provide document.'); // If the schema used for validation is invalid, throw an error. + + (0, _validate.assertValidSchema)(schema); + const abortObj = Object.freeze({}); + const errors = []; + const context = new _ValidationContext.ValidationContext( + schema, + documentAST, + typeInfo, + (error) => { + if (errors.length >= maxErrors) { + errors.push( + new _GraphQLError.GraphQLError( + 'Too many validation errors, error limit reached. Validation aborted.', + ), + ); // eslint-disable-next-line @typescript-eslint/no-throw-literal + + throw abortObj; + } + + errors.push(error); + }, + ); // This uses a specialized visitor which runs multiple visitors in parallel, + // while maintaining the visitor skip and break API. + + const visitor = (0, _visitor.visitInParallel)( + rules.map((rule) => rule(context)), + ); // Visit the whole document with each instance of all provided rules. + + try { + (0, _visitor.visit)( + documentAST, + (0, _TypeInfo.visitWithTypeInfo)(typeInfo, visitor), + ); + } catch (e) { + if (e !== abortObj) { + throw e; + } + } + + return errors; +} +/** + * @internal + */ + +function validateSDL( + documentAST, + schemaToExtend, + rules = _specifiedRules.specifiedSDLRules, +) { + const errors = []; + const context = new _ValidationContext.SDLValidationContext( + documentAST, + schemaToExtend, + (error) => { + errors.push(error); + }, + ); + const visitors = rules.map((rule) => rule(context)); + (0, _visitor.visit)(documentAST, (0, _visitor.visitInParallel)(visitors)); + return errors; +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ + +function assertValidSDL(documentAST) { + const errors = validateSDL(documentAST); + + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ + +function assertValidSDLExtension(documentAST, schema) { + const errors = validateSDL(documentAST, schema); + + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} + + +/***/ }), + +/***/ 1044: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var GetIntrinsic = __webpack_require__(210); + +var $defineProperty = GetIntrinsic('%Object.defineProperty%', true); + +var hasPropertyDescriptors = function hasPropertyDescriptors() { + if ($defineProperty) { + try { + $defineProperty({}, 'a', { value: 1 }); + return true; + } catch (e) { + // IE 8 has a broken defineProperty + return false; + } + } + return false; +}; + +hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() { + // node v0.6 has a bug where array lengths can be Set but not Defined + if (!hasPropertyDescriptors()) { + return null; + } + try { + return $defineProperty([], 'length', { value: 1 }).length !== 1; + } catch (e) { + // In Firefox 4-22, defining length on an array throws an exception. + return true; + } +}; + +module.exports = hasPropertyDescriptors; + + +/***/ }), + +/***/ 1405: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var origSymbol = typeof Symbol !== 'undefined' && Symbol; +var hasSymbolSham = __webpack_require__(5419); + +module.exports = function hasNativeSymbols() { + if (typeof origSymbol !== 'function') { return false; } + if (typeof Symbol !== 'function') { return false; } + if (typeof origSymbol('foo') !== 'symbol') { return false; } + if (typeof Symbol('bar') !== 'symbol') { return false; } + + return hasSymbolSham(); +}; + + +/***/ }), + +/***/ 5419: +/***/ ((module) => { + +"use strict"; + + +/* eslint complexity: [2, 18], max-statements: [2, 33] */ +module.exports = function hasSymbols() { + if (typeof Symbol !== 'function' || typeof Object.getOwnPropertySymbols !== 'function') { return false; } + if (typeof Symbol.iterator === 'symbol') { return true; } + + var obj = {}; + var sym = Symbol('test'); + var symObj = Object(sym); + if (typeof sym === 'string') { return false; } + + if (Object.prototype.toString.call(sym) !== '[object Symbol]') { return false; } + if (Object.prototype.toString.call(symObj) !== '[object Symbol]') { return false; } + + // temp disabled per https://github.com/ljharb/object.assign/issues/17 + // if (sym instanceof Symbol) { return false; } + // temp disabled per https://github.com/WebReflection/get-own-property-symbols/issues/4 + // if (!(symObj instanceof Symbol)) { return false; } + + // if (typeof Symbol.prototype.toString !== 'function') { return false; } + // if (String(sym) !== Symbol.prototype.toString.call(sym)) { return false; } + + var symVal = 42; + obj[sym] = symVal; + for (sym in obj) { return false; } // eslint-disable-line no-restricted-syntax, no-unreachable-loop + if (typeof Object.keys === 'function' && Object.keys(obj).length !== 0) { return false; } + + if (typeof Object.getOwnPropertyNames === 'function' && Object.getOwnPropertyNames(obj).length !== 0) { return false; } + + var syms = Object.getOwnPropertySymbols(obj); + if (syms.length !== 1 || syms[0] !== sym) { return false; } + + if (!Object.prototype.propertyIsEnumerable.call(obj, sym)) { return false; } + + if (typeof Object.getOwnPropertyDescriptor === 'function') { + var descriptor = Object.getOwnPropertyDescriptor(obj, sym); + if (descriptor.value !== symVal || descriptor.enumerable !== true) { return false; } + } + + return true; +}; + + +/***/ }), + +/***/ 6410: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var hasSymbols = __webpack_require__(5419); + +module.exports = function hasToStringTagShams() { + return hasSymbols() && !!Symbol.toStringTag; +}; + + +/***/ }), + +/***/ 7642: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var bind = __webpack_require__(8612); + +module.exports = bind.call(Function.call, Object.prototype.hasOwnProperty); + + +/***/ }), + +/***/ 5717: +/***/ ((module) => { + +if (typeof Object.create === 'function') { + // implementation from standard node.js 'util' module + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + ctor.prototype = Object.create(superCtor.prototype, { + constructor: { + value: ctor, + enumerable: false, + writable: true, + configurable: true + } + }) + } + }; +} else { + // old school shim for old browsers + module.exports = function inherits(ctor, superCtor) { + if (superCtor) { + ctor.super_ = superCtor + var TempCtor = function () {} + TempCtor.prototype = superCtor.prototype + ctor.prototype = new TempCtor() + ctor.prototype.constructor = ctor + } + } +} + + +/***/ }), + +/***/ 2584: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var hasToStringTag = __webpack_require__(6410)(); +var callBound = __webpack_require__(1924); + +var $toString = callBound('Object.prototype.toString'); + +var isStandardArguments = function isArguments(value) { + if (hasToStringTag && value && typeof value === 'object' && Symbol.toStringTag in value) { + return false; + } + return $toString(value) === '[object Arguments]'; +}; + +var isLegacyArguments = function isArguments(value) { + if (isStandardArguments(value)) { + return true; + } + return value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + $toString(value) !== '[object Array]' && + $toString(value.callee) === '[object Function]'; +}; + +var supportsStandardArguments = (function () { + return isStandardArguments(arguments); +}()); + +isStandardArguments.isLegacyArguments = isLegacyArguments; // for tests + +module.exports = supportsStandardArguments ? isStandardArguments : isLegacyArguments; + + +/***/ }), + +/***/ 5320: +/***/ ((module) => { + +"use strict"; + + +var fnToStr = Function.prototype.toString; +var reflectApply = typeof Reflect === 'object' && Reflect !== null && Reflect.apply; +var badArrayLike; +var isCallableMarker; +if (typeof reflectApply === 'function' && typeof Object.defineProperty === 'function') { + try { + badArrayLike = Object.defineProperty({}, 'length', { + get: function () { + throw isCallableMarker; + } + }); + isCallableMarker = {}; + // eslint-disable-next-line no-throw-literal + reflectApply(function () { throw 42; }, null, badArrayLike); + } catch (_) { + if (_ !== isCallableMarker) { + reflectApply = null; + } + } +} else { + reflectApply = null; +} + +var constructorRegex = /^\s*class\b/; +var isES6ClassFn = function isES6ClassFunction(value) { + try { + var fnStr = fnToStr.call(value); + return constructorRegex.test(fnStr); + } catch (e) { + return false; // not a function + } +}; + +var tryFunctionObject = function tryFunctionToStr(value) { + try { + if (isES6ClassFn(value)) { return false; } + fnToStr.call(value); + return true; + } catch (e) { + return false; + } +}; +var toStr = Object.prototype.toString; +var objectClass = '[object Object]'; +var fnClass = '[object Function]'; +var genClass = '[object GeneratorFunction]'; +var ddaClass = '[object HTMLAllCollection]'; // IE 11 +var ddaClass2 = '[object HTML document.all class]'; +var ddaClass3 = '[object HTMLCollection]'; // IE 9-10 +var hasToStringTag = typeof Symbol === 'function' && !!Symbol.toStringTag; // better: use `has-tostringtag` + +var isIE68 = !(0 in [,]); // eslint-disable-line no-sparse-arrays, comma-spacing + +var isDDA = function isDocumentDotAll() { return false; }; +if (typeof document === 'object') { + // Firefox 3 canonicalizes DDA to undefined when it's not accessed directly + var all = document.all; + if (toStr.call(all) === toStr.call(document.all)) { + isDDA = function isDocumentDotAll(value) { + /* globals document: false */ + // in IE 6-8, typeof document.all is "object" and it's truthy + if ((isIE68 || !value) && (typeof value === 'undefined' || typeof value === 'object')) { + try { + var str = toStr.call(value); + return ( + str === ddaClass + || str === ddaClass2 + || str === ddaClass3 // opera 12.16 + || str === objectClass // IE 6-8 + ) && value('') == null; // eslint-disable-line eqeqeq + } catch (e) { /**/ } + } + return false; + }; + } +} + +module.exports = reflectApply + ? function isCallable(value) { + if (isDDA(value)) { return true; } + if (!value) { return false; } + if (typeof value !== 'function' && typeof value !== 'object') { return false; } + try { + reflectApply(value, null, badArrayLike); + } catch (e) { + if (e !== isCallableMarker) { return false; } + } + return !isES6ClassFn(value) && tryFunctionObject(value); + } + : function isCallable(value) { + if (isDDA(value)) { return true; } + if (!value) { return false; } + if (typeof value !== 'function' && typeof value !== 'object') { return false; } + if (hasToStringTag) { return tryFunctionObject(value); } + if (isES6ClassFn(value)) { return false; } + var strClass = toStr.call(value); + if (strClass !== fnClass && strClass !== genClass && !(/^\[object HTML/).test(strClass)) { return false; } + return tryFunctionObject(value); + }; + + +/***/ }), + +/***/ 8662: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var toStr = Object.prototype.toString; +var fnToStr = Function.prototype.toString; +var isFnRegex = /^\s*(?:function)?\*/; +var hasToStringTag = __webpack_require__(6410)(); +var getProto = Object.getPrototypeOf; +var getGeneratorFunc = function () { // eslint-disable-line consistent-return + if (!hasToStringTag) { + return false; + } + try { + return Function('return function*() {}')(); + } catch (e) { + } +}; +var GeneratorFunction; + +module.exports = function isGeneratorFunction(fn) { + if (typeof fn !== 'function') { + return false; + } + if (isFnRegex.test(fnToStr.call(fn))) { + return true; + } + if (!hasToStringTag) { + var str = toStr.call(fn); + return str === '[object GeneratorFunction]'; + } + if (!getProto) { + return false; + } + if (typeof GeneratorFunction === 'undefined') { + var generatorFunc = getGeneratorFunc(); + GeneratorFunction = generatorFunc ? getProto(generatorFunc) : false; + } + return getProto(fn) === GeneratorFunction; +}; + + +/***/ }), + +/***/ 8611: +/***/ ((module) => { + +"use strict"; + + +/* http://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan */ + +module.exports = function isNaN(value) { + return value !== value; +}; + + +/***/ }), + +/***/ 360: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var callBind = __webpack_require__(5559); +var define = __webpack_require__(4289); + +var implementation = __webpack_require__(8611); +var getPolyfill = __webpack_require__(9415); +var shim = __webpack_require__(3194); + +var polyfill = callBind(getPolyfill(), Number); + +/* http://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan */ + +define(polyfill, { + getPolyfill: getPolyfill, + implementation: implementation, + shim: shim +}); + +module.exports = polyfill; + + +/***/ }), + +/***/ 9415: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var implementation = __webpack_require__(8611); + +module.exports = function getPolyfill() { + if (Number.isNaN && Number.isNaN(NaN) && !Number.isNaN('a')) { + return Number.isNaN; + } + return implementation; +}; + + +/***/ }), + +/***/ 3194: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var define = __webpack_require__(4289); +var getPolyfill = __webpack_require__(9415); + +/* http://www.ecma-international.org/ecma-262/6.0/#sec-number.isnan */ + +module.exports = function shimNumberIsNaN() { + var polyfill = getPolyfill(); + define(Number, { isNaN: polyfill }, { + isNaN: function testIsNaN() { + return Number.isNaN !== polyfill; + } + }); + return polyfill; +}; + + +/***/ }), + +/***/ 5692: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var forEach = __webpack_require__(4029); +var availableTypedArrays = __webpack_require__(3083); +var callBound = __webpack_require__(1924); + +var $toString = callBound('Object.prototype.toString'); +var hasToStringTag = __webpack_require__(6410)(); +var gOPD = __webpack_require__(7296); + +var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis; +var typedArrays = availableTypedArrays(); + +var $indexOf = callBound('Array.prototype.indexOf', true) || function indexOf(array, value) { + for (var i = 0; i < array.length; i += 1) { + if (array[i] === value) { + return i; + } + } + return -1; +}; +var $slice = callBound('String.prototype.slice'); +var toStrTags = {}; +var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof'); +if (hasToStringTag && gOPD && getPrototypeOf) { + forEach(typedArrays, function (typedArray) { + var arr = new g[typedArray](); + if (Symbol.toStringTag in arr) { + var proto = getPrototypeOf(arr); + var descriptor = gOPD(proto, Symbol.toStringTag); + if (!descriptor) { + var superProto = getPrototypeOf(proto); + descriptor = gOPD(superProto, Symbol.toStringTag); + } + toStrTags[typedArray] = descriptor.get; + } + }); +} + +var tryTypedArrays = function tryAllTypedArrays(value) { + var anyTrue = false; + forEach(toStrTags, function (getter, typedArray) { + if (!anyTrue) { + try { + anyTrue = getter.call(value) === typedArray; + } catch (e) { /**/ } + } + }); + return anyTrue; +}; + +module.exports = function isTypedArray(value) { + if (!value || typeof value !== 'object') { return false; } + if (!hasToStringTag || !(Symbol.toStringTag in value)) { + var tag = $slice($toString(value), 8, -1); + return $indexOf(typedArrays, tag) > -1; + } + if (!gOPD) { return false; } + return tryTypedArrays(value); +}; + + +/***/ }), + +/***/ 9991: +/***/ ((module) => { + +"use strict"; + +module.exports = (function() +{ + function _min(d0, d1, d2, bx, ay) + { + return d0 < d1 || d2 < d1 + ? d0 > d2 + ? d2 + 1 + : d0 + 1 + : bx === ay + ? d1 + : d1 + 1; + } + + return function(a, b) + { + if (a === b) { + return 0; + } + + if (a.length > b.length) { + var tmp = a; + a = b; + b = tmp; + } + + var la = a.length; + var lb = b.length; + + while (la > 0 && (a.charCodeAt(la - 1) === b.charCodeAt(lb - 1))) { + la--; + lb--; + } + + var offset = 0; + + while (offset < la && (a.charCodeAt(offset) === b.charCodeAt(offset))) { + offset++; + } + + la -= offset; + lb -= offset; + + if (la === 0 || lb < 3) { + return lb; + } + + var x = 0; + var y; + var d0; + var d1; + var d2; + var d3; + var dd; + var dy; + var ay; + var bx0; + var bx1; + var bx2; + var bx3; + + var vector = []; + + for (y = 0; y < la; y++) { + vector.push(y + 1); + vector.push(a.charCodeAt(offset + y)); + } + + var len = vector.length - 1; + + for (; x < lb - 3;) { + bx0 = b.charCodeAt(offset + (d0 = x)); + bx1 = b.charCodeAt(offset + (d1 = x + 1)); + bx2 = b.charCodeAt(offset + (d2 = x + 2)); + bx3 = b.charCodeAt(offset + (d3 = x + 3)); + dd = (x += 4); + for (y = 0; y < len; y += 2) { + dy = vector[y]; + ay = vector[y + 1]; + d0 = _min(dy, d0, d1, bx0, ay); + d1 = _min(d0, d1, d2, bx1, ay); + d2 = _min(d1, d2, d3, bx2, ay); + dd = _min(d2, d3, dd, bx3, ay); + vector[y] = dd; + d3 = d2; + d2 = d1; + d1 = d0; + d0 = dy; + } + } + + for (; x < lb;) { + bx0 = b.charCodeAt(offset + (d0 = x)); + dd = ++x; + for (y = 0; y < len; y += 2) { + dy = vector[y]; + vector[y] = dd = _min(dy, d0, dd, bx0, vector[y + 1]); + d0 = dy; + } + } + + return dd; + }; +})(); + + + +/***/ }), + +/***/ 3339: +/***/ ((module) => { + +"use strict"; + + +var numberIsNaN = function (value) { + return value !== value; +}; + +module.exports = function is(a, b) { + if (a === 0 && b === 0) { + return 1 / a === 1 / b; + } + if (a === b) { + return true; + } + if (numberIsNaN(a) && numberIsNaN(b)) { + return true; + } + return false; +}; + + + +/***/ }), + +/***/ 609: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var define = __webpack_require__(4289); +var callBind = __webpack_require__(5559); + +var implementation = __webpack_require__(3339); +var getPolyfill = __webpack_require__(5624); +var shim = __webpack_require__(2281); + +var polyfill = callBind(getPolyfill(), Object); + +define(polyfill, { + getPolyfill: getPolyfill, + implementation: implementation, + shim: shim +}); + +module.exports = polyfill; + + +/***/ }), + +/***/ 5624: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var implementation = __webpack_require__(3339); + +module.exports = function getPolyfill() { + return typeof Object.is === 'function' ? Object.is : implementation; +}; + + +/***/ }), + +/***/ 2281: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var getPolyfill = __webpack_require__(5624); +var define = __webpack_require__(4289); + +module.exports = function shimObjectIs() { + var polyfill = getPolyfill(); + define(Object, { is: polyfill }, { + is: function testObjectIs() { + return Object.is !== polyfill; + } + }); + return polyfill; +}; + + +/***/ }), + +/***/ 8987: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var keysShim; +if (!Object.keys) { + // modified from https://github.com/es-shims/es5-shim + var has = Object.prototype.hasOwnProperty; + var toStr = Object.prototype.toString; + var isArgs = __webpack_require__(1414); // eslint-disable-line global-require + var isEnumerable = Object.prototype.propertyIsEnumerable; + var hasDontEnumBug = !isEnumerable.call({ toString: null }, 'toString'); + var hasProtoEnumBug = isEnumerable.call(function () {}, 'prototype'); + var dontEnums = [ + 'toString', + 'toLocaleString', + 'valueOf', + 'hasOwnProperty', + 'isPrototypeOf', + 'propertyIsEnumerable', + 'constructor' + ]; + var equalsConstructorPrototype = function (o) { + var ctor = o.constructor; + return ctor && ctor.prototype === o; + }; + var excludedKeys = { + $applicationCache: true, + $console: true, + $external: true, + $frame: true, + $frameElement: true, + $frames: true, + $innerHeight: true, + $innerWidth: true, + $onmozfullscreenchange: true, + $onmozfullscreenerror: true, + $outerHeight: true, + $outerWidth: true, + $pageXOffset: true, + $pageYOffset: true, + $parent: true, + $scrollLeft: true, + $scrollTop: true, + $scrollX: true, + $scrollY: true, + $self: true, + $webkitIndexedDB: true, + $webkitStorageInfo: true, + $window: true + }; + var hasAutomationEqualityBug = (function () { + /* global window */ + if (typeof window === 'undefined') { return false; } + for (var k in window) { + try { + if (!excludedKeys['$' + k] && has.call(window, k) && window[k] !== null && typeof window[k] === 'object') { + try { + equalsConstructorPrototype(window[k]); + } catch (e) { + return true; + } + } + } catch (e) { + return true; + } + } + return false; + }()); + var equalsConstructorPrototypeIfNotBuggy = function (o) { + /* global window */ + if (typeof window === 'undefined' || !hasAutomationEqualityBug) { + return equalsConstructorPrototype(o); + } + try { + return equalsConstructorPrototype(o); + } catch (e) { + return false; + } + }; + + keysShim = function keys(object) { + var isObject = object !== null && typeof object === 'object'; + var isFunction = toStr.call(object) === '[object Function]'; + var isArguments = isArgs(object); + var isString = isObject && toStr.call(object) === '[object String]'; + var theKeys = []; + + if (!isObject && !isFunction && !isArguments) { + throw new TypeError('Object.keys called on a non-object'); + } + + var skipProto = hasProtoEnumBug && isFunction; + if (isString && object.length > 0 && !has.call(object, 0)) { + for (var i = 0; i < object.length; ++i) { + theKeys.push(String(i)); + } + } + + if (isArguments && object.length > 0) { + for (var j = 0; j < object.length; ++j) { + theKeys.push(String(j)); + } + } else { + for (var name in object) { + if (!(skipProto && name === 'prototype') && has.call(object, name)) { + theKeys.push(String(name)); + } + } + } + + if (hasDontEnumBug) { + var skipConstructor = equalsConstructorPrototypeIfNotBuggy(object); + + for (var k = 0; k < dontEnums.length; ++k) { + if (!(skipConstructor && dontEnums[k] === 'constructor') && has.call(object, dontEnums[k])) { + theKeys.push(dontEnums[k]); + } + } + } + return theKeys; + }; +} +module.exports = keysShim; + + +/***/ }), + +/***/ 2215: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var slice = Array.prototype.slice; +var isArgs = __webpack_require__(1414); + +var origKeys = Object.keys; +var keysShim = origKeys ? function keys(o) { return origKeys(o); } : __webpack_require__(8987); + +var originalKeys = Object.keys; + +keysShim.shim = function shimObjectKeys() { + if (Object.keys) { + var keysWorksWithArguments = (function () { + // Safari 5.0 bug + var args = Object.keys(arguments); + return args && args.length === arguments.length; + }(1, 2)); + if (!keysWorksWithArguments) { + Object.keys = function keys(object) { // eslint-disable-line func-name-matching + if (isArgs(object)) { + return originalKeys(slice.call(object)); + } + return originalKeys(object); + }; + } + } else { + Object.keys = keysShim; + } + return Object.keys || keysShim; +}; + +module.exports = keysShim; + + +/***/ }), + +/***/ 1414: +/***/ ((module) => { + +"use strict"; + + +var toStr = Object.prototype.toString; + +module.exports = function isArguments(value) { + var str = toStr.call(value); + var isArgs = str === '[object Arguments]'; + if (!isArgs) { + isArgs = str !== '[object Array]' && + value !== null && + typeof value === 'object' && + typeof value.length === 'number' && + value.length >= 0 && + toStr.call(value.callee) === '[object Function]'; + } + return isArgs; +}; + + +/***/ }), + +/***/ 6470: +/***/ ((module) => { + +"use strict"; +// 'path' module extracted from Node.js v8.11.1 (only the posix part) +// transplited with Babel + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + + + +function assertPath(path) { + if (typeof path !== 'string') { + throw new TypeError('Path must be a string. Received ' + JSON.stringify(path)); + } +} + +// Resolves . and .. elements in a path with directory names +function normalizeStringPosix(path, allowAboveRoot) { + var res = ''; + var lastSegmentLength = 0; + var lastSlash = -1; + var dots = 0; + var code; + for (var i = 0; i <= path.length; ++i) { + if (i < path.length) + code = path.charCodeAt(i); + else if (code === 47 /*/*/) + break; + else + code = 47 /*/*/; + if (code === 47 /*/*/) { + if (lastSlash === i - 1 || dots === 1) { + // NOOP + } else if (lastSlash !== i - 1 && dots === 2) { + if (res.length < 2 || lastSegmentLength !== 2 || res.charCodeAt(res.length - 1) !== 46 /*.*/ || res.charCodeAt(res.length - 2) !== 46 /*.*/) { + if (res.length > 2) { + var lastSlashIndex = res.lastIndexOf('/'); + if (lastSlashIndex !== res.length - 1) { + if (lastSlashIndex === -1) { + res = ''; + lastSegmentLength = 0; + } else { + res = res.slice(0, lastSlashIndex); + lastSegmentLength = res.length - 1 - res.lastIndexOf('/'); + } + lastSlash = i; + dots = 0; + continue; + } + } else if (res.length === 2 || res.length === 1) { + res = ''; + lastSegmentLength = 0; + lastSlash = i; + dots = 0; + continue; + } + } + if (allowAboveRoot) { + if (res.length > 0) + res += '/..'; + else + res = '..'; + lastSegmentLength = 2; + } + } else { + if (res.length > 0) + res += '/' + path.slice(lastSlash + 1, i); + else + res = path.slice(lastSlash + 1, i); + lastSegmentLength = i - lastSlash - 1; + } + lastSlash = i; + dots = 0; + } else if (code === 46 /*.*/ && dots !== -1) { + ++dots; + } else { + dots = -1; + } + } + return res; +} + +function _format(sep, pathObject) { + var dir = pathObject.dir || pathObject.root; + var base = pathObject.base || (pathObject.name || '') + (pathObject.ext || ''); + if (!dir) { + return base; + } + if (dir === pathObject.root) { + return dir + base; + } + return dir + sep + base; +} + +var posix = { + // path.resolve([from ...], to) + resolve: function resolve() { + var resolvedPath = ''; + var resolvedAbsolute = false; + var cwd; + + for (var i = arguments.length - 1; i >= -1 && !resolvedAbsolute; i--) { + var path; + if (i >= 0) + path = arguments[i]; + else { + if (cwd === undefined) + cwd = process.cwd(); + path = cwd; + } + + assertPath(path); + + // Skip empty entries + if (path.length === 0) { + continue; + } + + resolvedPath = path + '/' + resolvedPath; + resolvedAbsolute = path.charCodeAt(0) === 47 /*/*/; + } + + // At this point the path should be resolved to a full absolute path, but + // handle relative paths to be safe (might happen when process.cwd() fails) + + // Normalize the path + resolvedPath = normalizeStringPosix(resolvedPath, !resolvedAbsolute); + + if (resolvedAbsolute) { + if (resolvedPath.length > 0) + return '/' + resolvedPath; + else + return '/'; + } else if (resolvedPath.length > 0) { + return resolvedPath; + } else { + return '.'; + } + }, + + normalize: function normalize(path) { + assertPath(path); + + if (path.length === 0) return '.'; + + var isAbsolute = path.charCodeAt(0) === 47 /*/*/; + var trailingSeparator = path.charCodeAt(path.length - 1) === 47 /*/*/; + + // Normalize the path + path = normalizeStringPosix(path, !isAbsolute); + + if (path.length === 0 && !isAbsolute) path = '.'; + if (path.length > 0 && trailingSeparator) path += '/'; + + if (isAbsolute) return '/' + path; + return path; + }, + + isAbsolute: function isAbsolute(path) { + assertPath(path); + return path.length > 0 && path.charCodeAt(0) === 47 /*/*/; + }, + + join: function join() { + if (arguments.length === 0) + return '.'; + var joined; + for (var i = 0; i < arguments.length; ++i) { + var arg = arguments[i]; + assertPath(arg); + if (arg.length > 0) { + if (joined === undefined) + joined = arg; + else + joined += '/' + arg; + } + } + if (joined === undefined) + return '.'; + return posix.normalize(joined); + }, + + relative: function relative(from, to) { + assertPath(from); + assertPath(to); + + if (from === to) return ''; + + from = posix.resolve(from); + to = posix.resolve(to); + + if (from === to) return ''; + + // Trim any leading backslashes + var fromStart = 1; + for (; fromStart < from.length; ++fromStart) { + if (from.charCodeAt(fromStart) !== 47 /*/*/) + break; + } + var fromEnd = from.length; + var fromLen = fromEnd - fromStart; + + // Trim any leading backslashes + var toStart = 1; + for (; toStart < to.length; ++toStart) { + if (to.charCodeAt(toStart) !== 47 /*/*/) + break; + } + var toEnd = to.length; + var toLen = toEnd - toStart; + + // Compare paths to find the longest common path from root + var length = fromLen < toLen ? fromLen : toLen; + var lastCommonSep = -1; + var i = 0; + for (; i <= length; ++i) { + if (i === length) { + if (toLen > length) { + if (to.charCodeAt(toStart + i) === 47 /*/*/) { + // We get here if `from` is the exact base path for `to`. + // For example: from='/foo/bar'; to='/foo/bar/baz' + return to.slice(toStart + i + 1); + } else if (i === 0) { + // We get here if `from` is the root + // For example: from='/'; to='/foo' + return to.slice(toStart + i); + } + } else if (fromLen > length) { + if (from.charCodeAt(fromStart + i) === 47 /*/*/) { + // We get here if `to` is the exact base path for `from`. + // For example: from='/foo/bar/baz'; to='/foo/bar' + lastCommonSep = i; + } else if (i === 0) { + // We get here if `to` is the root. + // For example: from='/foo'; to='/' + lastCommonSep = 0; + } + } + break; + } + var fromCode = from.charCodeAt(fromStart + i); + var toCode = to.charCodeAt(toStart + i); + if (fromCode !== toCode) + break; + else if (fromCode === 47 /*/*/) + lastCommonSep = i; + } + + var out = ''; + // Generate the relative path based on the path difference between `to` + // and `from` + for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) { + if (i === fromEnd || from.charCodeAt(i) === 47 /*/*/) { + if (out.length === 0) + out += '..'; + else + out += '/..'; + } + } + + // Lastly, append the rest of the destination (`to`) path that comes after + // the common path parts + if (out.length > 0) + return out + to.slice(toStart + lastCommonSep); + else { + toStart += lastCommonSep; + if (to.charCodeAt(toStart) === 47 /*/*/) + ++toStart; + return to.slice(toStart); + } + }, + + _makeLong: function _makeLong(path) { + return path; + }, + + dirname: function dirname(path) { + assertPath(path); + if (path.length === 0) return '.'; + var code = path.charCodeAt(0); + var hasRoot = code === 47 /*/*/; + var end = -1; + var matchedSlash = true; + for (var i = path.length - 1; i >= 1; --i) { + code = path.charCodeAt(i); + if (code === 47 /*/*/) { + if (!matchedSlash) { + end = i; + break; + } + } else { + // We saw the first non-path separator + matchedSlash = false; + } + } + + if (end === -1) return hasRoot ? '/' : '.'; + if (hasRoot && end === 1) return '//'; + return path.slice(0, end); + }, + + basename: function basename(path, ext) { + if (ext !== undefined && typeof ext !== 'string') throw new TypeError('"ext" argument must be a string'); + assertPath(path); + + var start = 0; + var end = -1; + var matchedSlash = true; + var i; + + if (ext !== undefined && ext.length > 0 && ext.length <= path.length) { + if (ext.length === path.length && ext === path) return ''; + var extIdx = ext.length - 1; + var firstNonSlashEnd = -1; + for (i = path.length - 1; i >= 0; --i) { + var code = path.charCodeAt(i); + if (code === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + start = i + 1; + break; + } + } else { + if (firstNonSlashEnd === -1) { + // We saw the first non-path separator, remember this index in case + // we need it if the extension ends up not matching + matchedSlash = false; + firstNonSlashEnd = i + 1; + } + if (extIdx >= 0) { + // Try to match the explicit extension + if (code === ext.charCodeAt(extIdx)) { + if (--extIdx === -1) { + // We matched the extension, so mark this as the end of our path + // component + end = i; + } + } else { + // Extension does not match, so our result is the entire path + // component + extIdx = -1; + end = firstNonSlashEnd; + } + } + } + } + + if (start === end) end = firstNonSlashEnd;else if (end === -1) end = path.length; + return path.slice(start, end); + } else { + for (i = path.length - 1; i >= 0; --i) { + if (path.charCodeAt(i) === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + start = i + 1; + break; + } + } else if (end === -1) { + // We saw the first non-path separator, mark this as the end of our + // path component + matchedSlash = false; + end = i + 1; + } + } + + if (end === -1) return ''; + return path.slice(start, end); + } + }, + + extname: function extname(path) { + assertPath(path); + var startDot = -1; + var startPart = 0; + var end = -1; + var matchedSlash = true; + // Track the state of characters (if any) we see before our first dot and + // after any path separator we find + var preDotState = 0; + for (var i = path.length - 1; i >= 0; --i) { + var code = path.charCodeAt(i); + if (code === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + startPart = i + 1; + break; + } + continue; + } + if (end === -1) { + // We saw the first non-path separator, mark this as the end of our + // extension + matchedSlash = false; + end = i + 1; + } + if (code === 46 /*.*/) { + // If this is our first dot, mark it as the start of our extension + if (startDot === -1) + startDot = i; + else if (preDotState !== 1) + preDotState = 1; + } else if (startDot !== -1) { + // We saw a non-dot and non-path separator before our dot, so we should + // have a good chance at having a non-empty extension + preDotState = -1; + } + } + + if (startDot === -1 || end === -1 || + // We saw a non-dot character immediately before the dot + preDotState === 0 || + // The (right-most) trimmed path component is exactly '..' + preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + return ''; + } + return path.slice(startDot, end); + }, + + format: function format(pathObject) { + if (pathObject === null || typeof pathObject !== 'object') { + throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof pathObject); + } + return _format('/', pathObject); + }, + + parse: function parse(path) { + assertPath(path); + + var ret = { root: '', dir: '', base: '', ext: '', name: '' }; + if (path.length === 0) return ret; + var code = path.charCodeAt(0); + var isAbsolute = code === 47 /*/*/; + var start; + if (isAbsolute) { + ret.root = '/'; + start = 1; + } else { + start = 0; + } + var startDot = -1; + var startPart = 0; + var end = -1; + var matchedSlash = true; + var i = path.length - 1; + + // Track the state of characters (if any) we see before our first dot and + // after any path separator we find + var preDotState = 0; + + // Get non-dir info + for (; i >= start; --i) { + code = path.charCodeAt(i); + if (code === 47 /*/*/) { + // If we reached a path separator that was not part of a set of path + // separators at the end of the string, stop now + if (!matchedSlash) { + startPart = i + 1; + break; + } + continue; + } + if (end === -1) { + // We saw the first non-path separator, mark this as the end of our + // extension + matchedSlash = false; + end = i + 1; + } + if (code === 46 /*.*/) { + // If this is our first dot, mark it as the start of our extension + if (startDot === -1) startDot = i;else if (preDotState !== 1) preDotState = 1; + } else if (startDot !== -1) { + // We saw a non-dot and non-path separator before our dot, so we should + // have a good chance at having a non-empty extension + preDotState = -1; + } + } + + if (startDot === -1 || end === -1 || + // We saw a non-dot character immediately before the dot + preDotState === 0 || + // The (right-most) trimmed path component is exactly '..' + preDotState === 1 && startDot === end - 1 && startDot === startPart + 1) { + if (end !== -1) { + if (startPart === 0 && isAbsolute) ret.base = ret.name = path.slice(1, end);else ret.base = ret.name = path.slice(startPart, end); + } + } else { + if (startPart === 0 && isAbsolute) { + ret.name = path.slice(1, startDot); + ret.base = path.slice(1, end); + } else { + ret.name = path.slice(startPart, startDot); + ret.base = path.slice(startPart, end); + } + ret.ext = path.slice(startDot, end); + } + + if (startPart > 0) ret.dir = path.slice(0, startPart - 1);else if (isAbsolute) ret.dir = '/'; + + return ret; + }, + + sep: '/', + delimiter: ':', + win32: null, + posix: null +}; + +posix.posix = posix; + +module.exports = posix; + + +/***/ }), + +/***/ 7129: +/***/ ((__unused_webpack_module, exports) => { + +"use strict"; + + +var has = Object.prototype.hasOwnProperty + , undef; + +/** + * Decode a URI encoded string. + * + * @param {String} input The URI encoded string. + * @returns {String|Null} The decoded string. + * @api private + */ +function decode(input) { + try { + return decodeURIComponent(input.replace(/\+/g, ' ')); + } catch (e) { + return null; + } +} + +/** + * Attempts to encode a given input. + * + * @param {String} input The string that needs to be encoded. + * @returns {String|Null} The encoded string. + * @api private + */ +function encode(input) { + try { + return encodeURIComponent(input); + } catch (e) { + return null; + } +} + +/** + * Simple query string parser. + * + * @param {String} query The query string that needs to be parsed. + * @returns {Object} + * @api public + */ +function querystring(query) { + var parser = /([^=?#&]+)=?([^&]*)/g + , result = {} + , part; + + while (part = parser.exec(query)) { + var key = decode(part[1]) + , value = decode(part[2]); + + // + // Prevent overriding of existing properties. This ensures that build-in + // methods like `toString` or __proto__ are not overriden by malicious + // querystrings. + // + // In the case if failed decoding, we want to omit the key/value pairs + // from the result. + // + if (key === null || value === null || key in result) continue; + result[key] = value; + } + + return result; +} + +/** + * Transform a query string to an object. + * + * @param {Object} obj Object that should be transformed. + * @param {String} prefix Optional prefix. + * @returns {String} + * @api public + */ +function querystringify(obj, prefix) { + prefix = prefix || ''; + + var pairs = [] + , value + , key; + + // + // Optionally prefix with a '?' if needed + // + if ('string' !== typeof prefix) prefix = '?'; + + for (key in obj) { + if (has.call(obj, key)) { + value = obj[key]; + + // + // Edge cases where we actually want to encode the value to an empty + // string instead of the stringified value. + // + if (!value && (value === null || value === undef || isNaN(value))) { + value = ''; + } + + key = encode(key); + value = encode(value); + + // + // If we failed to encode the strings, we should bail out as we don't + // want to add invalid strings to the query. + // + if (key === null || value === null) continue; + pairs.push(key +'='+ value); + } + } + + return pairs.length ? prefix + pairs.join('&') : ''; +} + +// +// Expose the module. +// +exports.stringify = querystringify; +exports.parse = querystring; + + +/***/ }), + +/***/ 7418: +/***/ ((module) => { + +"use strict"; + + +/** + * Check if we're required to add a port number. + * + * @see https://url.spec.whatwg.org/#default-port + * @param {Number|String} port Port number we need to check + * @param {String} protocol Protocol we need to check against. + * @returns {Boolean} Is it a default port for the given protocol + * @api private + */ +module.exports = function required(port, protocol) { + protocol = protocol.split(':')[0]; + port = +port; + + if (!port) return false; + + switch (protocol) { + case 'http': + case 'ws': + return port !== 80; + + case 'https': + case 'wss': + return port !== 443; + + case 'ftp': + return port !== 21; + + case 'gopher': + return port !== 70; + + case 'file': + return false; + } + + return port !== 0; +}; + + +/***/ }), + +/***/ 8555: +/***/ ((module) => { + +"use strict"; + +module.exports = { + stdout: false, + stderr: false +}; + + +/***/ }), + +/***/ 4564: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var required = __webpack_require__(7418) + , qs = __webpack_require__(7129) + , controlOrWhitespace = /^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/ + , CRHTLF = /[\n\r\t]/g + , slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\/\// + , port = /:\d+$/ + , protocolre = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i + , windowsDriveLetter = /^[a-zA-Z]:/; + +/** + * Remove control characters and whitespace from the beginning of a string. + * + * @param {Object|String} str String to trim. + * @returns {String} A new string representing `str` stripped of control + * characters and whitespace from its beginning. + * @public + */ +function trimLeft(str) { + return (str ? str : '').toString().replace(controlOrWhitespace, ''); +} + +/** + * These are the parse rules for the URL parser, it informs the parser + * about: + * + * 0. The char it Needs to parse, if it's a string it should be done using + * indexOf, RegExp using exec and NaN means set as current value. + * 1. The property we should set when parsing this value. + * 2. Indication if it's backwards or forward parsing, when set as number it's + * the value of extra chars that should be split off. + * 3. Inherit from location if non existing in the parser. + * 4. `toLowerCase` the resulting value. + */ +var rules = [ + ['#', 'hash'], // Extract from the back. + ['?', 'query'], // Extract from the back. + function sanitize(address, url) { // Sanitize what is left of the address + return isSpecial(url.protocol) ? address.replace(/\\/g, '/') : address; + }, + ['/', 'pathname'], // Extract from the back. + ['@', 'auth', 1], // Extract from the front. + [NaN, 'host', undefined, 1, 1], // Set left over value. + [/:(\d*)$/, 'port', undefined, 1], // RegExp the back. + [NaN, 'hostname', undefined, 1, 1] // Set left over. +]; + +/** + * These properties should not be copied or inherited from. This is only needed + * for all non blob URL's as a blob URL does not include a hash, only the + * origin. + * + * @type {Object} + * @private + */ +var ignore = { hash: 1, query: 1 }; + +/** + * The location object differs when your code is loaded through a normal page, + * Worker or through a worker using a blob. And with the blobble begins the + * trouble as the location object will contain the URL of the blob, not the + * location of the page where our code is loaded in. The actual origin is + * encoded in the `pathname` so we can thankfully generate a good "default" + * location from it so we can generate proper relative URL's again. + * + * @param {Object|String} loc Optional default location object. + * @returns {Object} lolcation object. + * @public + */ +function lolcation(loc) { + var globalVar; + + if (typeof window !== 'undefined') globalVar = window; + else if (typeof __webpack_require__.g !== 'undefined') globalVar = __webpack_require__.g; + else if (typeof self !== 'undefined') globalVar = self; + else globalVar = {}; + + var location = globalVar.location || {}; + loc = loc || location; + + var finaldestination = {} + , type = typeof loc + , key; + + if ('blob:' === loc.protocol) { + finaldestination = new Url(unescape(loc.pathname), {}); + } else if ('string' === type) { + finaldestination = new Url(loc, {}); + for (key in ignore) delete finaldestination[key]; + } else if ('object' === type) { + for (key in loc) { + if (key in ignore) continue; + finaldestination[key] = loc[key]; + } + + if (finaldestination.slashes === undefined) { + finaldestination.slashes = slashes.test(loc.href); + } + } + + return finaldestination; +} + +/** + * Check whether a protocol scheme is special. + * + * @param {String} The protocol scheme of the URL + * @return {Boolean} `true` if the protocol scheme is special, else `false` + * @private + */ +function isSpecial(scheme) { + return ( + scheme === 'file:' || + scheme === 'ftp:' || + scheme === 'http:' || + scheme === 'https:' || + scheme === 'ws:' || + scheme === 'wss:' + ); +} + +/** + * @typedef ProtocolExtract + * @type Object + * @property {String} protocol Protocol matched in the URL, in lowercase. + * @property {Boolean} slashes `true` if protocol is followed by "//", else `false`. + * @property {String} rest Rest of the URL that is not part of the protocol. + */ + +/** + * Extract protocol information from a URL with/without double slash ("//"). + * + * @param {String} address URL we want to extract from. + * @param {Object} location + * @return {ProtocolExtract} Extracted information. + * @private + */ +function extractProtocol(address, location) { + address = trimLeft(address); + address = address.replace(CRHTLF, ''); + location = location || {}; + + var match = protocolre.exec(address); + var protocol = match[1] ? match[1].toLowerCase() : ''; + var forwardSlashes = !!match[2]; + var otherSlashes = !!match[3]; + var slashesCount = 0; + var rest; + + if (forwardSlashes) { + if (otherSlashes) { + rest = match[2] + match[3] + match[4]; + slashesCount = match[2].length + match[3].length; + } else { + rest = match[2] + match[4]; + slashesCount = match[2].length; + } + } else { + if (otherSlashes) { + rest = match[3] + match[4]; + slashesCount = match[3].length; + } else { + rest = match[4] + } + } + + if (protocol === 'file:') { + if (slashesCount >= 2) { + rest = rest.slice(2); + } + } else if (isSpecial(protocol)) { + rest = match[4]; + } else if (protocol) { + if (forwardSlashes) { + rest = rest.slice(2); + } + } else if (slashesCount >= 2 && isSpecial(location.protocol)) { + rest = match[4]; + } + + return { + protocol: protocol, + slashes: forwardSlashes || isSpecial(protocol), + slashesCount: slashesCount, + rest: rest + }; +} + +/** + * Resolve a relative URL pathname against a base URL pathname. + * + * @param {String} relative Pathname of the relative URL. + * @param {String} base Pathname of the base URL. + * @return {String} Resolved pathname. + * @private + */ +function resolve(relative, base) { + if (relative === '') return base; + + var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/')) + , i = path.length + , last = path[i - 1] + , unshift = false + , up = 0; + + while (i--) { + if (path[i] === '.') { + path.splice(i, 1); + } else if (path[i] === '..') { + path.splice(i, 1); + up++; + } else if (up) { + if (i === 0) unshift = true; + path.splice(i, 1); + up--; + } + } + + if (unshift) path.unshift(''); + if (last === '.' || last === '..') path.push(''); + + return path.join('/'); +} + +/** + * The actual URL instance. Instead of returning an object we've opted-in to + * create an actual constructor as it's much more memory efficient and + * faster and it pleases my OCD. + * + * It is worth noting that we should not use `URL` as class name to prevent + * clashes with the global URL instance that got introduced in browsers. + * + * @constructor + * @param {String} address URL we want to parse. + * @param {Object|String} [location] Location defaults for relative paths. + * @param {Boolean|Function} [parser] Parser for the query string. + * @private + */ +function Url(address, location, parser) { + address = trimLeft(address); + address = address.replace(CRHTLF, ''); + + if (!(this instanceof Url)) { + return new Url(address, location, parser); + } + + var relative, extracted, parse, instruction, index, key + , instructions = rules.slice() + , type = typeof location + , url = this + , i = 0; + + // + // The following if statements allows this module two have compatibility with + // 2 different API: + // + // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments + // where the boolean indicates that the query string should also be parsed. + // + // 2. The `URL` interface of the browser which accepts a URL, object as + // arguments. The supplied object will be used as default values / fall-back + // for relative paths. + // + if ('object' !== type && 'string' !== type) { + parser = location; + location = null; + } + + if (parser && 'function' !== typeof parser) parser = qs.parse; + + location = lolcation(location); + + // + // Extract protocol information before running the instructions. + // + extracted = extractProtocol(address || '', location); + relative = !extracted.protocol && !extracted.slashes; + url.slashes = extracted.slashes || relative && location.slashes; + url.protocol = extracted.protocol || location.protocol || ''; + address = extracted.rest; + + // + // When the authority component is absent the URL starts with a path + // component. + // + if ( + extracted.protocol === 'file:' && ( + extracted.slashesCount !== 2 || windowsDriveLetter.test(address)) || + (!extracted.slashes && + (extracted.protocol || + extracted.slashesCount < 2 || + !isSpecial(url.protocol))) + ) { + instructions[3] = [/(.*)/, 'pathname']; + } + + for (; i < instructions.length; i++) { + instruction = instructions[i]; + + if (typeof instruction === 'function') { + address = instruction(address, url); + continue; + } + + parse = instruction[0]; + key = instruction[1]; + + if (parse !== parse) { + url[key] = address; + } else if ('string' === typeof parse) { + index = parse === '@' + ? address.lastIndexOf(parse) + : address.indexOf(parse); + + if (~index) { + if ('number' === typeof instruction[2]) { + url[key] = address.slice(0, index); + address = address.slice(index + instruction[2]); + } else { + url[key] = address.slice(index); + address = address.slice(0, index); + } + } + } else if ((index = parse.exec(address))) { + url[key] = index[1]; + address = address.slice(0, index.index); + } + + url[key] = url[key] || ( + relative && instruction[3] ? location[key] || '' : '' + ); + + // + // Hostname, host and protocol should be lowercased so they can be used to + // create a proper `origin`. + // + if (instruction[4]) url[key] = url[key].toLowerCase(); + } + + // + // Also parse the supplied query string in to an object. If we're supplied + // with a custom parser as function use that instead of the default build-in + // parser. + // + if (parser) url.query = parser(url.query); + + // + // If the URL is relative, resolve the pathname against the base URL. + // + if ( + relative + && location.slashes + && url.pathname.charAt(0) !== '/' + && (url.pathname !== '' || location.pathname !== '') + ) { + url.pathname = resolve(url.pathname, location.pathname); + } + + // + // Default to a / for pathname if none exists. This normalizes the URL + // to always have a / + // + if (url.pathname.charAt(0) !== '/' && isSpecial(url.protocol)) { + url.pathname = '/' + url.pathname; + } + + // + // We should not add port numbers if they are already the default port number + // for a given protocol. As the host also contains the port number we're going + // override it with the hostname which contains no port number. + // + if (!required(url.port, url.protocol)) { + url.host = url.hostname; + url.port = ''; + } + + // + // Parse down the `auth` for the username and password. + // + url.username = url.password = ''; + + if (url.auth) { + index = url.auth.indexOf(':'); + + if (~index) { + url.username = url.auth.slice(0, index); + url.username = encodeURIComponent(decodeURIComponent(url.username)); + + url.password = url.auth.slice(index + 1); + url.password = encodeURIComponent(decodeURIComponent(url.password)) + } else { + url.username = encodeURIComponent(decodeURIComponent(url.auth)); + } + + url.auth = url.password ? url.username +':'+ url.password : url.username; + } + + url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host + ? url.protocol +'//'+ url.host + : 'null'; + + // + // The href is just the compiled result. + // + url.href = url.toString(); +} + +/** + * This is convenience method for changing properties in the URL instance to + * insure that they all propagate correctly. + * + * @param {String} part Property we need to adjust. + * @param {Mixed} value The newly assigned value. + * @param {Boolean|Function} fn When setting the query, it will be the function + * used to parse the query. + * When setting the protocol, double slash will be + * removed from the final url if it is true. + * @returns {URL} URL instance for chaining. + * @public + */ +function set(part, value, fn) { + var url = this; + + switch (part) { + case 'query': + if ('string' === typeof value && value.length) { + value = (fn || qs.parse)(value); + } + + url[part] = value; + break; + + case 'port': + url[part] = value; + + if (!required(value, url.protocol)) { + url.host = url.hostname; + url[part] = ''; + } else if (value) { + url.host = url.hostname +':'+ value; + } + + break; + + case 'hostname': + url[part] = value; + + if (url.port) value += ':'+ url.port; + url.host = value; + break; + + case 'host': + url[part] = value; + + if (port.test(value)) { + value = value.split(':'); + url.port = value.pop(); + url.hostname = value.join(':'); + } else { + url.hostname = value; + url.port = ''; + } + + break; + + case 'protocol': + url.protocol = value.toLowerCase(); + url.slashes = !fn; + break; + + case 'pathname': + case 'hash': + if (value) { + var char = part === 'pathname' ? '/' : '#'; + url[part] = value.charAt(0) !== char ? char + value : value; + } else { + url[part] = value; + } + break; + + case 'username': + case 'password': + url[part] = encodeURIComponent(value); + break; + + case 'auth': + var index = value.indexOf(':'); + + if (~index) { + url.username = value.slice(0, index); + url.username = encodeURIComponent(decodeURIComponent(url.username)); + + url.password = value.slice(index + 1); + url.password = encodeURIComponent(decodeURIComponent(url.password)); + } else { + url.username = encodeURIComponent(decodeURIComponent(value)); + } + } + + for (var i = 0; i < rules.length; i++) { + var ins = rules[i]; + + if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase(); + } + + url.auth = url.password ? url.username +':'+ url.password : url.username; + + url.origin = url.protocol !== 'file:' && isSpecial(url.protocol) && url.host + ? url.protocol +'//'+ url.host + : 'null'; + + url.href = url.toString(); + + return url; +} + +/** + * Transform the properties back in to a valid and full URL string. + * + * @param {Function} stringify Optional query stringify function. + * @returns {String} Compiled version of the URL. + * @public + */ +function toString(stringify) { + if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify; + + var query + , url = this + , host = url.host + , protocol = url.protocol; + + if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':'; + + var result = + protocol + + ((url.protocol && url.slashes) || isSpecial(url.protocol) ? '//' : ''); + + if (url.username) { + result += url.username; + if (url.password) result += ':'+ url.password; + result += '@'; + } else if (url.password) { + result += ':'+ url.password; + result += '@'; + } else if ( + url.protocol !== 'file:' && + isSpecial(url.protocol) && + !host && + url.pathname !== '/' + ) { + // + // Add back the empty userinfo, otherwise the original invalid URL + // might be transformed into a valid one with `url.pathname` as host. + // + result += '@'; + } + + // + // Trailing colon is removed from `url.host` when it is parsed. If it still + // ends with a colon, then add back the trailing colon that was removed. This + // prevents an invalid URL from being transformed into a valid one. + // + if (host[host.length - 1] === ':' || (port.test(url.hostname) && !url.port)) { + host += ':'; + } + + result += host + url.pathname; + + query = 'object' === typeof url.query ? stringify(url.query) : url.query; + if (query) result += '?' !== query.charAt(0) ? '?'+ query : query; + + if (url.hash) result += url.hash; + + return result; +} + +Url.prototype = { set: set, toString: toString }; + +// +// Expose the URL parser and some additional properties that might be useful for +// others or testing. +// +Url.extractProtocol = extractProtocol; +Url.location = lolcation; +Url.trimLeft = trimLeft; +Url.qs = qs; + +module.exports = Url; + + +/***/ }), + +/***/ 384: +/***/ ((module) => { + +module.exports = function isBuffer(arg) { + return arg && typeof arg === 'object' + && typeof arg.copy === 'function' + && typeof arg.fill === 'function' + && typeof arg.readUInt8 === 'function'; +} + +/***/ }), + +/***/ 5955: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +"use strict"; +// Currently in sync with Node.js lib/internal/util/types.js +// https://github.com/nodejs/node/commit/112cc7c27551254aa2b17098fb774867f05ed0d9 + + + +var isArgumentsObject = __webpack_require__(2584); +var isGeneratorFunction = __webpack_require__(8662); +var whichTypedArray = __webpack_require__(6430); +var isTypedArray = __webpack_require__(5692); + +function uncurryThis(f) { + return f.call.bind(f); +} + +var BigIntSupported = typeof BigInt !== 'undefined'; +var SymbolSupported = typeof Symbol !== 'undefined'; + +var ObjectToString = uncurryThis(Object.prototype.toString); + +var numberValue = uncurryThis(Number.prototype.valueOf); +var stringValue = uncurryThis(String.prototype.valueOf); +var booleanValue = uncurryThis(Boolean.prototype.valueOf); + +if (BigIntSupported) { + var bigIntValue = uncurryThis(BigInt.prototype.valueOf); +} + +if (SymbolSupported) { + var symbolValue = uncurryThis(Symbol.prototype.valueOf); +} + +function checkBoxedPrimitive(value, prototypeValueOf) { + if (typeof value !== 'object') { + return false; + } + try { + prototypeValueOf(value); + return true; + } catch(e) { + return false; + } +} + +exports.isArgumentsObject = isArgumentsObject; +exports.isGeneratorFunction = isGeneratorFunction; +exports.isTypedArray = isTypedArray; + +// Taken from here and modified for better browser support +// https://github.com/sindresorhus/p-is-promise/blob/cda35a513bda03f977ad5cde3a079d237e82d7ef/index.js +function isPromise(input) { + return ( + ( + typeof Promise !== 'undefined' && + input instanceof Promise + ) || + ( + input !== null && + typeof input === 'object' && + typeof input.then === 'function' && + typeof input.catch === 'function' + ) + ); +} +exports.isPromise = isPromise; + +function isArrayBufferView(value) { + if (typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView) { + return ArrayBuffer.isView(value); + } + + return ( + isTypedArray(value) || + isDataView(value) + ); +} +exports.isArrayBufferView = isArrayBufferView; + + +function isUint8Array(value) { + return whichTypedArray(value) === 'Uint8Array'; +} +exports.isUint8Array = isUint8Array; + +function isUint8ClampedArray(value) { + return whichTypedArray(value) === 'Uint8ClampedArray'; +} +exports.isUint8ClampedArray = isUint8ClampedArray; + +function isUint16Array(value) { + return whichTypedArray(value) === 'Uint16Array'; +} +exports.isUint16Array = isUint16Array; + +function isUint32Array(value) { + return whichTypedArray(value) === 'Uint32Array'; +} +exports.isUint32Array = isUint32Array; + +function isInt8Array(value) { + return whichTypedArray(value) === 'Int8Array'; +} +exports.isInt8Array = isInt8Array; + +function isInt16Array(value) { + return whichTypedArray(value) === 'Int16Array'; +} +exports.isInt16Array = isInt16Array; + +function isInt32Array(value) { + return whichTypedArray(value) === 'Int32Array'; +} +exports.isInt32Array = isInt32Array; + +function isFloat32Array(value) { + return whichTypedArray(value) === 'Float32Array'; +} +exports.isFloat32Array = isFloat32Array; + +function isFloat64Array(value) { + return whichTypedArray(value) === 'Float64Array'; +} +exports.isFloat64Array = isFloat64Array; + +function isBigInt64Array(value) { + return whichTypedArray(value) === 'BigInt64Array'; +} +exports.isBigInt64Array = isBigInt64Array; + +function isBigUint64Array(value) { + return whichTypedArray(value) === 'BigUint64Array'; +} +exports.isBigUint64Array = isBigUint64Array; + +function isMapToString(value) { + return ObjectToString(value) === '[object Map]'; +} +isMapToString.working = ( + typeof Map !== 'undefined' && + isMapToString(new Map()) +); + +function isMap(value) { + if (typeof Map === 'undefined') { + return false; + } + + return isMapToString.working + ? isMapToString(value) + : value instanceof Map; +} +exports.isMap = isMap; + +function isSetToString(value) { + return ObjectToString(value) === '[object Set]'; +} +isSetToString.working = ( + typeof Set !== 'undefined' && + isSetToString(new Set()) +); +function isSet(value) { + if (typeof Set === 'undefined') { + return false; + } + + return isSetToString.working + ? isSetToString(value) + : value instanceof Set; +} +exports.isSet = isSet; + +function isWeakMapToString(value) { + return ObjectToString(value) === '[object WeakMap]'; +} +isWeakMapToString.working = ( + typeof WeakMap !== 'undefined' && + isWeakMapToString(new WeakMap()) +); +function isWeakMap(value) { + if (typeof WeakMap === 'undefined') { + return false; + } + + return isWeakMapToString.working + ? isWeakMapToString(value) + : value instanceof WeakMap; +} +exports.isWeakMap = isWeakMap; + +function isWeakSetToString(value) { + return ObjectToString(value) === '[object WeakSet]'; +} +isWeakSetToString.working = ( + typeof WeakSet !== 'undefined' && + isWeakSetToString(new WeakSet()) +); +function isWeakSet(value) { + return isWeakSetToString(value); +} +exports.isWeakSet = isWeakSet; + +function isArrayBufferToString(value) { + return ObjectToString(value) === '[object ArrayBuffer]'; +} +isArrayBufferToString.working = ( + typeof ArrayBuffer !== 'undefined' && + isArrayBufferToString(new ArrayBuffer()) +); +function isArrayBuffer(value) { + if (typeof ArrayBuffer === 'undefined') { + return false; + } + + return isArrayBufferToString.working + ? isArrayBufferToString(value) + : value instanceof ArrayBuffer; +} +exports.isArrayBuffer = isArrayBuffer; + +function isDataViewToString(value) { + return ObjectToString(value) === '[object DataView]'; +} +isDataViewToString.working = ( + typeof ArrayBuffer !== 'undefined' && + typeof DataView !== 'undefined' && + isDataViewToString(new DataView(new ArrayBuffer(1), 0, 1)) +); +function isDataView(value) { + if (typeof DataView === 'undefined') { + return false; + } + + return isDataViewToString.working + ? isDataViewToString(value) + : value instanceof DataView; +} +exports.isDataView = isDataView; + +// Store a copy of SharedArrayBuffer in case it's deleted elsewhere +var SharedArrayBufferCopy = typeof SharedArrayBuffer !== 'undefined' ? SharedArrayBuffer : undefined; +function isSharedArrayBufferToString(value) { + return ObjectToString(value) === '[object SharedArrayBuffer]'; +} +function isSharedArrayBuffer(value) { + if (typeof SharedArrayBufferCopy === 'undefined') { + return false; + } + + if (typeof isSharedArrayBufferToString.working === 'undefined') { + isSharedArrayBufferToString.working = isSharedArrayBufferToString(new SharedArrayBufferCopy()); + } + + return isSharedArrayBufferToString.working + ? isSharedArrayBufferToString(value) + : value instanceof SharedArrayBufferCopy; +} +exports.isSharedArrayBuffer = isSharedArrayBuffer; + +function isAsyncFunction(value) { + return ObjectToString(value) === '[object AsyncFunction]'; +} +exports.isAsyncFunction = isAsyncFunction; + +function isMapIterator(value) { + return ObjectToString(value) === '[object Map Iterator]'; +} +exports.isMapIterator = isMapIterator; + +function isSetIterator(value) { + return ObjectToString(value) === '[object Set Iterator]'; +} +exports.isSetIterator = isSetIterator; + +function isGeneratorObject(value) { + return ObjectToString(value) === '[object Generator]'; +} +exports.isGeneratorObject = isGeneratorObject; + +function isWebAssemblyCompiledModule(value) { + return ObjectToString(value) === '[object WebAssembly.Module]'; +} +exports.isWebAssemblyCompiledModule = isWebAssemblyCompiledModule; + +function isNumberObject(value) { + return checkBoxedPrimitive(value, numberValue); +} +exports.isNumberObject = isNumberObject; + +function isStringObject(value) { + return checkBoxedPrimitive(value, stringValue); +} +exports.isStringObject = isStringObject; + +function isBooleanObject(value) { + return checkBoxedPrimitive(value, booleanValue); +} +exports.isBooleanObject = isBooleanObject; + +function isBigIntObject(value) { + return BigIntSupported && checkBoxedPrimitive(value, bigIntValue); +} +exports.isBigIntObject = isBigIntObject; + +function isSymbolObject(value) { + return SymbolSupported && checkBoxedPrimitive(value, symbolValue); +} +exports.isSymbolObject = isSymbolObject; + +function isBoxedPrimitive(value) { + return ( + isNumberObject(value) || + isStringObject(value) || + isBooleanObject(value) || + isBigIntObject(value) || + isSymbolObject(value) + ); +} +exports.isBoxedPrimitive = isBoxedPrimitive; + +function isAnyArrayBuffer(value) { + return typeof Uint8Array !== 'undefined' && ( + isArrayBuffer(value) || + isSharedArrayBuffer(value) + ); +} +exports.isAnyArrayBuffer = isAnyArrayBuffer; + +['isProxy', 'isExternal', 'isModuleNamespaceObject'].forEach(function(method) { + Object.defineProperty(exports, method, { + enumerable: false, + value: function() { + throw new Error(method + ' is not supported in userland'); + } + }); +}); + + +/***/ }), + +/***/ 9539: +/***/ ((__unused_webpack_module, exports, __webpack_require__) => { + +// Copyright Joyent, Inc. and other Node contributors. +// +// Permission is hereby granted, free of charge, to any person obtaining a +// copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to permit +// persons to whom the Software is furnished to do so, subject to the +// following conditions: +// +// The above copyright notice and this permission notice shall be included +// in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN +// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, +// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE +// USE OR OTHER DEALINGS IN THE SOFTWARE. + +var getOwnPropertyDescriptors = Object.getOwnPropertyDescriptors || + function getOwnPropertyDescriptors(obj) { + var keys = Object.keys(obj); + var descriptors = {}; + for (var i = 0; i < keys.length; i++) { + descriptors[keys[i]] = Object.getOwnPropertyDescriptor(obj, keys[i]); + } + return descriptors; + }; + +var formatRegExp = /%[sdj%]/g; +exports.format = function(f) { + if (!isString(f)) { + var objects = []; + for (var i = 0; i < arguments.length; i++) { + objects.push(inspect(arguments[i])); + } + return objects.join(' '); + } + + var i = 1; + var args = arguments; + var len = args.length; + var str = String(f).replace(formatRegExp, function(x) { + if (x === '%%') return '%'; + if (i >= len) return x; + switch (x) { + case '%s': return String(args[i++]); + case '%d': return Number(args[i++]); + case '%j': + try { + return JSON.stringify(args[i++]); + } catch (_) { + return '[Circular]'; + } + default: + return x; + } + }); + for (var x = args[i]; i < len; x = args[++i]) { + if (isNull(x) || !isObject(x)) { + str += ' ' + x; + } else { + str += ' ' + inspect(x); + } + } + return str; +}; + + +// Mark that a method should not be used. +// Returns a modified function which warns once by default. +// If --no-deprecation is set, then it is a no-op. +exports.deprecate = function(fn, msg) { + if (typeof process !== 'undefined' && process.noDeprecation === true) { + return fn; + } + + // Allow for deprecating things in the process of starting up. + if (typeof process === 'undefined') { + return function() { + return exports.deprecate(fn, msg).apply(this, arguments); + }; + } + + var warned = false; + function deprecated() { + if (!warned) { + if (process.throwDeprecation) { + throw new Error(msg); + } else if (process.traceDeprecation) { + console.trace(msg); + } else { + console.error(msg); + } + warned = true; + } + return fn.apply(this, arguments); + } + + return deprecated; +}; + + +var debugs = {}; +var debugEnvRegex = /^$/; + +if (process.env.NODE_DEBUG) { + var debugEnv = process.env.NODE_DEBUG; + debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, '\\$&') + .replace(/\*/g, '.*') + .replace(/,/g, '$|^') + .toUpperCase(); + debugEnvRegex = new RegExp('^' + debugEnv + '$', 'i'); +} +exports.debuglog = function(set) { + set = set.toUpperCase(); + if (!debugs[set]) { + if (debugEnvRegex.test(set)) { + var pid = process.pid; + debugs[set] = function() { + var msg = exports.format.apply(exports, arguments); + console.error('%s %d: %s', set, pid, msg); + }; + } else { + debugs[set] = function() {}; + } + } + return debugs[set]; +}; + + +/** + * Echos the value of a value. Trys to print the value out + * in the best way possible given the different types. + * + * @param {Object} obj The object to print out. + * @param {Object} opts Optional options object that alters the output. + */ +/* legacy: obj, showHidden, depth, colors*/ +function inspect(obj, opts) { + // default options + var ctx = { + seen: [], + stylize: stylizeNoColor + }; + // legacy... + if (arguments.length >= 3) ctx.depth = arguments[2]; + if (arguments.length >= 4) ctx.colors = arguments[3]; + if (isBoolean(opts)) { + // legacy... + ctx.showHidden = opts; + } else if (opts) { + // got an "options" object + exports._extend(ctx, opts); + } + // set default options + if (isUndefined(ctx.showHidden)) ctx.showHidden = false; + if (isUndefined(ctx.depth)) ctx.depth = 2; + if (isUndefined(ctx.colors)) ctx.colors = false; + if (isUndefined(ctx.customInspect)) ctx.customInspect = true; + if (ctx.colors) ctx.stylize = stylizeWithColor; + return formatValue(ctx, obj, ctx.depth); +} +exports.inspect = inspect; + + +// http://en.wikipedia.org/wiki/ANSI_escape_code#graphics +inspect.colors = { + 'bold' : [1, 22], + 'italic' : [3, 23], + 'underline' : [4, 24], + 'inverse' : [7, 27], + 'white' : [37, 39], + 'grey' : [90, 39], + 'black' : [30, 39], + 'blue' : [34, 39], + 'cyan' : [36, 39], + 'green' : [32, 39], + 'magenta' : [35, 39], + 'red' : [31, 39], + 'yellow' : [33, 39] +}; + +// Don't use 'blue' not visible on cmd.exe +inspect.styles = { + 'special': 'cyan', + 'number': 'yellow', + 'boolean': 'yellow', + 'undefined': 'grey', + 'null': 'bold', + 'string': 'green', + 'date': 'magenta', + // "name": intentionally not styling + 'regexp': 'red' +}; + + +function stylizeWithColor(str, styleType) { + var style = inspect.styles[styleType]; + + if (style) { + return '\u001b[' + inspect.colors[style][0] + 'm' + str + + '\u001b[' + inspect.colors[style][1] + 'm'; + } else { + return str; + } +} + + +function stylizeNoColor(str, styleType) { + return str; +} + + +function arrayToHash(array) { + var hash = {}; + + array.forEach(function(val, idx) { + hash[val] = true; + }); + + return hash; +} + + +function formatValue(ctx, value, recurseTimes) { + // Provide a hook for user-specified inspect functions. + // Check that value is an object with an inspect function on it + if (ctx.customInspect && + value && + isFunction(value.inspect) && + // Filter out the util module, it's inspect function is special + value.inspect !== exports.inspect && + // Also filter out any prototype objects using the circular check. + !(value.constructor && value.constructor.prototype === value)) { + var ret = value.inspect(recurseTimes, ctx); + if (!isString(ret)) { + ret = formatValue(ctx, ret, recurseTimes); + } + return ret; + } + + // Primitive types cannot have properties + var primitive = formatPrimitive(ctx, value); + if (primitive) { + return primitive; + } + + // Look up the keys of the object. + var keys = Object.keys(value); + var visibleKeys = arrayToHash(keys); + + if (ctx.showHidden) { + keys = Object.getOwnPropertyNames(value); + } + + // IE doesn't make error fields non-enumerable + // http://msdn.microsoft.com/en-us/library/ie/dww52sbt(v=vs.94).aspx + if (isError(value) + && (keys.indexOf('message') >= 0 || keys.indexOf('description') >= 0)) { + return formatError(value); + } + + // Some type of object without properties can be shortcutted. + if (keys.length === 0) { + if (isFunction(value)) { + var name = value.name ? ': ' + value.name : ''; + return ctx.stylize('[Function' + name + ']', 'special'); + } + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } + if (isDate(value)) { + return ctx.stylize(Date.prototype.toString.call(value), 'date'); + } + if (isError(value)) { + return formatError(value); + } + } + + var base = '', array = false, braces = ['{', '}']; + + // Make Array say that they are Array + if (isArray(value)) { + array = true; + braces = ['[', ']']; + } + + // Make functions say that they are functions + if (isFunction(value)) { + var n = value.name ? ': ' + value.name : ''; + base = ' [Function' + n + ']'; + } + + // Make RegExps say that they are RegExps + if (isRegExp(value)) { + base = ' ' + RegExp.prototype.toString.call(value); + } + + // Make dates with properties first say the date + if (isDate(value)) { + base = ' ' + Date.prototype.toUTCString.call(value); + } + + // Make error with message first say the error + if (isError(value)) { + base = ' ' + formatError(value); + } + + if (keys.length === 0 && (!array || value.length == 0)) { + return braces[0] + base + braces[1]; + } + + if (recurseTimes < 0) { + if (isRegExp(value)) { + return ctx.stylize(RegExp.prototype.toString.call(value), 'regexp'); + } else { + return ctx.stylize('[Object]', 'special'); + } + } + + ctx.seen.push(value); + + var output; + if (array) { + output = formatArray(ctx, value, recurseTimes, visibleKeys, keys); + } else { + output = keys.map(function(key) { + return formatProperty(ctx, value, recurseTimes, visibleKeys, key, array); + }); + } + + ctx.seen.pop(); + + return reduceToSingleString(output, base, braces); +} + + +function formatPrimitive(ctx, value) { + if (isUndefined(value)) + return ctx.stylize('undefined', 'undefined'); + if (isString(value)) { + var simple = '\'' + JSON.stringify(value).replace(/^"|"$/g, '') + .replace(/'/g, "\\'") + .replace(/\\"/g, '"') + '\''; + return ctx.stylize(simple, 'string'); + } + if (isNumber(value)) + return ctx.stylize('' + value, 'number'); + if (isBoolean(value)) + return ctx.stylize('' + value, 'boolean'); + // For some reason typeof null is "object", so special case here. + if (isNull(value)) + return ctx.stylize('null', 'null'); +} + + +function formatError(value) { + return '[' + Error.prototype.toString.call(value) + ']'; +} + + +function formatArray(ctx, value, recurseTimes, visibleKeys, keys) { + var output = []; + for (var i = 0, l = value.length; i < l; ++i) { + if (hasOwnProperty(value, String(i))) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + String(i), true)); + } else { + output.push(''); + } + } + keys.forEach(function(key) { + if (!key.match(/^\d+$/)) { + output.push(formatProperty(ctx, value, recurseTimes, visibleKeys, + key, true)); + } + }); + return output; +} + + +function formatProperty(ctx, value, recurseTimes, visibleKeys, key, array) { + var name, str, desc; + desc = Object.getOwnPropertyDescriptor(value, key) || { value: value[key] }; + if (desc.get) { + if (desc.set) { + str = ctx.stylize('[Getter/Setter]', 'special'); + } else { + str = ctx.stylize('[Getter]', 'special'); + } + } else { + if (desc.set) { + str = ctx.stylize('[Setter]', 'special'); + } + } + if (!hasOwnProperty(visibleKeys, key)) { + name = '[' + key + ']'; + } + if (!str) { + if (ctx.seen.indexOf(desc.value) < 0) { + if (isNull(recurseTimes)) { + str = formatValue(ctx, desc.value, null); + } else { + str = formatValue(ctx, desc.value, recurseTimes - 1); + } + if (str.indexOf('\n') > -1) { + if (array) { + str = str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n').slice(2); + } else { + str = '\n' + str.split('\n').map(function(line) { + return ' ' + line; + }).join('\n'); + } + } + } else { + str = ctx.stylize('[Circular]', 'special'); + } + } + if (isUndefined(name)) { + if (array && key.match(/^\d+$/)) { + return str; + } + name = JSON.stringify('' + key); + if (name.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)) { + name = name.slice(1, -1); + name = ctx.stylize(name, 'name'); + } else { + name = name.replace(/'/g, "\\'") + .replace(/\\"/g, '"') + .replace(/(^"|"$)/g, "'"); + name = ctx.stylize(name, 'string'); + } + } + + return name + ': ' + str; +} + + +function reduceToSingleString(output, base, braces) { + var numLinesEst = 0; + var length = output.reduce(function(prev, cur) { + numLinesEst++; + if (cur.indexOf('\n') >= 0) numLinesEst++; + return prev + cur.replace(/\u001b\[\d\d?m/g, '').length + 1; + }, 0); + + if (length > 60) { + return braces[0] + + (base === '' ? '' : base + '\n ') + + ' ' + + output.join(',\n ') + + ' ' + + braces[1]; + } + + return braces[0] + base + ' ' + output.join(', ') + ' ' + braces[1]; +} + + +// NOTE: These type checking functions intentionally don't use `instanceof` +// because it is fragile and can be easily faked with `Object.create()`. +exports.types = __webpack_require__(5955); + +function isArray(ar) { + return Array.isArray(ar); +} +exports.isArray = isArray; + +function isBoolean(arg) { + return typeof arg === 'boolean'; +} +exports.isBoolean = isBoolean; + +function isNull(arg) { + return arg === null; +} +exports.isNull = isNull; + +function isNullOrUndefined(arg) { + return arg == null; +} +exports.isNullOrUndefined = isNullOrUndefined; + +function isNumber(arg) { + return typeof arg === 'number'; +} +exports.isNumber = isNumber; + +function isString(arg) { + return typeof arg === 'string'; +} +exports.isString = isString; + +function isSymbol(arg) { + return typeof arg === 'symbol'; +} +exports.isSymbol = isSymbol; + +function isUndefined(arg) { + return arg === void 0; +} +exports.isUndefined = isUndefined; + +function isRegExp(re) { + return isObject(re) && objectToString(re) === '[object RegExp]'; +} +exports.isRegExp = isRegExp; +exports.types.isRegExp = isRegExp; + +function isObject(arg) { + return typeof arg === 'object' && arg !== null; +} +exports.isObject = isObject; + +function isDate(d) { + return isObject(d) && objectToString(d) === '[object Date]'; +} +exports.isDate = isDate; +exports.types.isDate = isDate; + +function isError(e) { + return isObject(e) && + (objectToString(e) === '[object Error]' || e instanceof Error); +} +exports.isError = isError; +exports.types.isNativeError = isError; + +function isFunction(arg) { + return typeof arg === 'function'; +} +exports.isFunction = isFunction; + +function isPrimitive(arg) { + return arg === null || + typeof arg === 'boolean' || + typeof arg === 'number' || + typeof arg === 'string' || + typeof arg === 'symbol' || // ES6 symbol + typeof arg === 'undefined'; +} +exports.isPrimitive = isPrimitive; + +exports.isBuffer = __webpack_require__(384); + +function objectToString(o) { + return Object.prototype.toString.call(o); +} + + +function pad(n) { + return n < 10 ? '0' + n.toString(10) : n.toString(10); +} + + +var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', + 'Oct', 'Nov', 'Dec']; + +// 26 Feb 16:19:34 +function timestamp() { + var d = new Date(); + var time = [pad(d.getHours()), + pad(d.getMinutes()), + pad(d.getSeconds())].join(':'); + return [d.getDate(), months[d.getMonth()], time].join(' '); +} + + +// log is just a thin wrapper to console.log that prepends a timestamp +exports.log = function() { + console.log('%s - %s', timestamp(), exports.format.apply(exports, arguments)); +}; + + +/** + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). + * + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + */ +exports.inherits = __webpack_require__(5717); + +exports._extend = function(origin, add) { + // Don't do anything if add isn't an object + if (!add || !isObject(add)) return origin; + + var keys = Object.keys(add); + var i = keys.length; + while (i--) { + origin[keys[i]] = add[keys[i]]; + } + return origin; +}; + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +var kCustomPromisifiedSymbol = typeof Symbol !== 'undefined' ? Symbol('util.promisify.custom') : undefined; + +exports.promisify = function promisify(original) { + if (typeof original !== 'function') + throw new TypeError('The "original" argument must be of type Function'); + + if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) { + var fn = original[kCustomPromisifiedSymbol]; + if (typeof fn !== 'function') { + throw new TypeError('The "util.promisify.custom" argument must be of type Function'); + } + Object.defineProperty(fn, kCustomPromisifiedSymbol, { + value: fn, enumerable: false, writable: false, configurable: true + }); + return fn; + } + + function fn() { + var promiseResolve, promiseReject; + var promise = new Promise(function (resolve, reject) { + promiseResolve = resolve; + promiseReject = reject; + }); + + var args = []; + for (var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + args.push(function (err, value) { + if (err) { + promiseReject(err); + } else { + promiseResolve(value); + } + }); + + try { + original.apply(this, args); + } catch (err) { + promiseReject(err); + } + + return promise; + } + + Object.setPrototypeOf(fn, Object.getPrototypeOf(original)); + + if (kCustomPromisifiedSymbol) Object.defineProperty(fn, kCustomPromisifiedSymbol, { + value: fn, enumerable: false, writable: false, configurable: true + }); + return Object.defineProperties( + fn, + getOwnPropertyDescriptors(original) + ); +} + +exports.promisify.custom = kCustomPromisifiedSymbol + +function callbackifyOnRejected(reason, cb) { + // `!reason` guard inspired by bluebird (Ref: https://goo.gl/t5IS6M). + // Because `null` is a special error value in callbacks which means "no error + // occurred", we error-wrap so the callback consumer can distinguish between + // "the promise rejected with null" or "the promise fulfilled with undefined". + if (!reason) { + var newReason = new Error('Promise was rejected with a falsy value'); + newReason.reason = reason; + reason = newReason; + } + return cb(reason); +} + +function callbackify(original) { + if (typeof original !== 'function') { + throw new TypeError('The "original" argument must be of type Function'); + } + + // We DO NOT return the promise as it gives the user a false sense that + // the promise is actually somehow related to the callback's execution + // and that the callback throwing will reject the promise. + function callbackified() { + var args = []; + for (var i = 0; i < arguments.length; i++) { + args.push(arguments[i]); + } + + var maybeCb = args.pop(); + if (typeof maybeCb !== 'function') { + throw new TypeError('The last argument must be of type Function'); + } + var self = this; + var cb = function() { + return maybeCb.apply(self, arguments); + }; + // In true node style we process the callback on `nextTick` with all the + // implications (stack, `uncaughtException`, `async_hooks`) + original.apply(this, args) + .then(function(ret) { process.nextTick(cb.bind(null, null, ret)) }, + function(rej) { process.nextTick(callbackifyOnRejected.bind(null, rej, cb)) }); + } + + Object.setPrototypeOf(callbackified, Object.getPrototypeOf(original)); + Object.defineProperties(callbackified, + getOwnPropertyDescriptors(original)); + return callbackified; +} +exports.callbackify = callbackify; + + +/***/ }), + +/***/ 6430: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var forEach = __webpack_require__(4029); +var availableTypedArrays = __webpack_require__(3083); +var callBound = __webpack_require__(1924); +var gOPD = __webpack_require__(7296); + +var $toString = callBound('Object.prototype.toString'); +var hasToStringTag = __webpack_require__(6410)(); + +var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis; +var typedArrays = availableTypedArrays(); + +var $slice = callBound('String.prototype.slice'); +var toStrTags = {}; +var getPrototypeOf = Object.getPrototypeOf; // require('getprototypeof'); +if (hasToStringTag && gOPD && getPrototypeOf) { + forEach(typedArrays, function (typedArray) { + if (typeof g[typedArray] === 'function') { + var arr = new g[typedArray](); + if (Symbol.toStringTag in arr) { + var proto = getPrototypeOf(arr); + var descriptor = gOPD(proto, Symbol.toStringTag); + if (!descriptor) { + var superProto = getPrototypeOf(proto); + descriptor = gOPD(superProto, Symbol.toStringTag); + } + toStrTags[typedArray] = descriptor.get; + } + } + }); +} + +var tryTypedArrays = function tryAllTypedArrays(value) { + var foundName = false; + forEach(toStrTags, function (getter, typedArray) { + if (!foundName) { + try { + var name = getter.call(value); + if (name === typedArray) { + foundName = name; + } + } catch (e) {} + } + }); + return foundName; +}; + +var isTypedArray = __webpack_require__(5692); + +module.exports = function whichTypedArray(value) { + if (!isTypedArray(value)) { return false; } + if (!hasToStringTag || !(Symbol.toStringTag in value)) { return $slice($toString(value), 8, -1); } + return tryTypedArrays(value); +}; + + +/***/ }), + +/***/ 4888: +/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "URL": () => (/* binding */ URL) +/* harmony export */ }); +/* harmony import */ var url_parse__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4564); +/* harmony import */ var url_parse__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(url_parse__WEBPACK_IMPORTED_MODULE_0__); +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +// Apollo's library imports the URL class from Node's `url` package. +// Unfortunately there isn't a polyfill library that works exactly like this. +// The `url-parse` comes close, but the class is its default export, not a name. +// So this little adapter just re-exports it under the name `URL`. + + + +let URL = url_parse__WEBPACK_IMPORTED_MODULE_0__; + + +/***/ }), + +/***/ 8222: +/***/ (() => { + +/* (ignored) */ + +/***/ }), + +/***/ 3083: +/***/ ((module, __unused_webpack_exports, __webpack_require__) => { + +"use strict"; + + +var possibleNames = [ + 'BigInt64Array', + 'BigUint64Array', + 'Float32Array', + 'Float64Array', + 'Int16Array', + 'Int32Array', + 'Int8Array', + 'Uint16Array', + 'Uint32Array', + 'Uint8Array', + 'Uint8ClampedArray' +]; + +var g = typeof globalThis === 'undefined' ? __webpack_require__.g : globalThis; + +module.exports = function availableTypedArrays() { + var out = []; + for (var i = 0; i < possibleNames.length; i++) { + if (typeof g[possibleNames[i]] === 'function') { + out[out.length] = possibleNames[i]; + } + } + return out; +}; + + +/***/ }), + +/***/ 8087: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "OS": () => (/* binding */ printError), +/* harmony export */ "Z": () => (/* binding */ formatError), +/* harmony export */ "__": () => (/* binding */ GraphQLError) +/* harmony export */ }); +/* harmony import */ var _jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8495); +/* harmony import */ var _language_location_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7867); +/* harmony import */ var _language_printLocation_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(850); + + + + +function toNormalizedOptions(args) { + const firstArg = args[0]; + + if (firstArg == null || 'kind' in firstArg || 'length' in firstArg) { + return { + nodes: firstArg, + source: args[1], + positions: args[2], + path: args[3], + originalError: args[4], + extensions: args[5], + }; + } + + return firstArg; +} +/** + * A GraphQLError describes an Error found during the parse, validate, or + * execute phases of performing a GraphQL operation. In addition to a message + * and stack trace, it also includes information about the locations in a + * GraphQL document and/or execution result that correspond to the Error. + */ + +class GraphQLError extends Error { + /** + * An array of `{ line, column }` locations within the source GraphQL document + * which correspond to this error. + * + * Errors during validation often contain multiple locations, for example to + * point out two things with the same name. Errors during execution include a + * single location, the field which produced the error. + * + * Enumerable, and appears in the result of JSON.stringify(). + */ + + /** + * An array describing the JSON-path into the execution response which + * corresponds to this error. Only included for errors during execution. + * + * Enumerable, and appears in the result of JSON.stringify(). + */ + + /** + * An array of GraphQL AST Nodes corresponding to this error. + */ + + /** + * The source GraphQL document for the first location of this error. + * + * Note that if this Error represents more than one node, the source may not + * represent nodes after the first node. + */ + + /** + * An array of character offsets within the source GraphQL document + * which correspond to this error. + */ + + /** + * The original error thrown from a field resolver during execution. + */ + + /** + * Extension fields to add to the formatted error. + */ + + /** + * @deprecated Please use the `GraphQLErrorOptions` constructor overload instead. + */ + constructor(message, ...rawArgs) { + var _this$nodes, _nodeLocations$, _ref; + + const { nodes, source, positions, path, originalError, extensions } = + toNormalizedOptions(rawArgs); + super(message); + this.name = 'GraphQLError'; + this.path = path !== null && path !== void 0 ? path : undefined; + this.originalError = + originalError !== null && originalError !== void 0 + ? originalError + : undefined; // Compute list of blame nodes. + + this.nodes = undefinedIfEmpty( + Array.isArray(nodes) ? nodes : nodes ? [nodes] : undefined, + ); + const nodeLocations = undefinedIfEmpty( + (_this$nodes = this.nodes) === null || _this$nodes === void 0 + ? void 0 + : _this$nodes.map((node) => node.loc).filter((loc) => loc != null), + ); // Compute locations in the source for the given nodes/positions. + + this.source = + source !== null && source !== void 0 + ? source + : nodeLocations === null || nodeLocations === void 0 + ? void 0 + : (_nodeLocations$ = nodeLocations[0]) === null || + _nodeLocations$ === void 0 + ? void 0 + : _nodeLocations$.source; + this.positions = + positions !== null && positions !== void 0 + ? positions + : nodeLocations === null || nodeLocations === void 0 + ? void 0 + : nodeLocations.map((loc) => loc.start); + this.locations = + positions && source + ? positions.map((pos) => (0,_language_location_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getLocation */ .k)(source, pos)) + : nodeLocations === null || nodeLocations === void 0 + ? void 0 + : nodeLocations.map((loc) => (0,_language_location_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getLocation */ .k)(loc.source, loc.start)); + const originalExtensions = (0,_jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isObjectLike */ .y)( + originalError === null || originalError === void 0 + ? void 0 + : originalError.extensions, + ) + ? originalError === null || originalError === void 0 + ? void 0 + : originalError.extensions + : undefined; + this.extensions = + (_ref = + extensions !== null && extensions !== void 0 + ? extensions + : originalExtensions) !== null && _ref !== void 0 + ? _ref + : Object.create(null); // Only properties prescribed by the spec should be enumerable. + // Keep the rest as non-enumerable. + + Object.defineProperties(this, { + message: { + writable: true, + enumerable: true, + }, + name: { + enumerable: false, + }, + nodes: { + enumerable: false, + }, + source: { + enumerable: false, + }, + positions: { + enumerable: false, + }, + originalError: { + enumerable: false, + }, + }); // Include (non-enumerable) stack trace. + + /* c8 ignore start */ + // FIXME: https://github.com/graphql/graphql-js/issues/2317 + + if ( + originalError !== null && + originalError !== void 0 && + originalError.stack + ) { + Object.defineProperty(this, 'stack', { + value: originalError.stack, + writable: true, + configurable: true, + }); + } else if (Error.captureStackTrace) { + Error.captureStackTrace(this, GraphQLError); + } else { + Object.defineProperty(this, 'stack', { + value: Error().stack, + writable: true, + configurable: true, + }); + } + /* c8 ignore stop */ + } + + get [Symbol.toStringTag]() { + return 'GraphQLError'; + } + + toString() { + let output = this.message; + + if (this.nodes) { + for (const node of this.nodes) { + if (node.loc) { + output += '\n\n' + (0,_language_printLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .printLocation */ .Q)(node.loc); + } + } + } else if (this.source && this.locations) { + for (const location of this.locations) { + output += '\n\n' + (0,_language_printLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .printSourceLocation */ .z)(this.source, location); + } + } + + return output; + } + + toJSON() { + const formattedError = { + message: this.message, + }; + + if (this.locations != null) { + formattedError.locations = this.locations; + } + + if (this.path != null) { + formattedError.path = this.path; + } + + if (this.extensions != null && Object.keys(this.extensions).length > 0) { + formattedError.extensions = this.extensions; + } + + return formattedError; + } +} + +function undefinedIfEmpty(array) { + return array === undefined || array.length === 0 ? undefined : array; +} +/** + * See: https://spec.graphql.org/draft/#sec-Errors + */ + +/** + * Prints a GraphQLError to a string, representing useful location information + * about the error's position in the source. + * + * @deprecated Please use `error.toString` instead. Will be removed in v17 + */ +function printError(error) { + return error.toString(); +} +/** + * Given a GraphQLError, format it according to the rules described by the + * Response Format, Errors section of the GraphQL Specification. + * + * @deprecated Please use `error.toJSON` instead. Will be removed in v17 + */ + +function formatError(error) { + return error.toJSON(); +} + + +/***/ }), + +/***/ 4181: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "y": () => (/* binding */ locatedError) +}); + +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/inspect.mjs +var inspect = __webpack_require__(5821); +;// CONCATENATED MODULE: ./node_modules/graphql/jsutils/toError.mjs + +/** + * Sometimes a non-error is thrown, wrap it as an Error instance to ensure a consistent Error interface. + */ + +function toError(thrownValue) { + return thrownValue instanceof Error + ? thrownValue + : new NonErrorThrown(thrownValue); +} + +class NonErrorThrown extends Error { + constructor(thrownValue) { + super('Unexpected error value: ' + (0,inspect/* inspect */.X)(thrownValue)); + this.name = 'NonErrorThrown'; + this.thrownValue = thrownValue; + } +} + +// EXTERNAL MODULE: ./node_modules/graphql/error/GraphQLError.mjs +var GraphQLError = __webpack_require__(8087); +;// CONCATENATED MODULE: ./node_modules/graphql/error/locatedError.mjs + + +/** + * Given an arbitrary value, presumably thrown while attempting to execute a + * GraphQL operation, produce a new GraphQLError aware of the location in the + * document responsible for the original Error. + */ + +function locatedError(rawOriginalError, nodes, path) { + var _nodes; + + const originalError = toError(rawOriginalError); // Note: this uses a brand-check to support GraphQL errors originating from other contexts. + + if (isLocatedGraphQLError(originalError)) { + return originalError; + } + + return new GraphQLError/* GraphQLError */.__(originalError.message, { + nodes: + (_nodes = originalError.nodes) !== null && _nodes !== void 0 + ? _nodes + : nodes, + source: originalError.source, + positions: originalError.positions, + path, + originalError, + }); +} + +function isLocatedGraphQLError(error) { + return Array.isArray(error.path); +} + + +/***/ }), + +/***/ 5219: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "h": () => (/* binding */ syntaxError) +/* harmony export */ }); +/* harmony import */ var _GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + +/** + * Produces a GraphQLError representing a syntax error, containing useful + * descriptive information about the syntax error's position in the source. + */ + +function syntaxError(source, position, description) { + return new _GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__(`Syntax Error: ${description}`, { + source, + positions: [position], + }); +} + + +/***/ }), + +/***/ 7677: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "g": () => (/* binding */ collectFields), +/* harmony export */ "w": () => (/* binding */ collectSubfields) +/* harmony export */ }); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7359); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(398); +/* harmony import */ var _type_directives_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8238); +/* harmony import */ var _utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(77); +/* harmony import */ var _values_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(6422); + + + + + +/** + * Given a selectionSet, collects all of the fields and returns them. + * + * CollectFields requires the "runtime type" of an object. For a field that + * returns an Interface or Union type, the "runtime type" will be the actual + * object type returned by that field. + * + * @internal + */ + +function collectFields( + schema, + fragments, + variableValues, + runtimeType, + selectionSet, +) { + const fields = new Map(); + collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + selectionSet, + fields, + new Set(), + ); + return fields; +} +/** + * Given an array of field nodes, collects all of the subfields of the passed + * in fields, and returns them at the end. + * + * CollectSubFields requires the "return type" of an object. For a field that + * returns an Interface or Union type, the "return type" will be the actual + * object type returned by that field. + * + * @internal + */ + +function collectSubfields( + schema, + fragments, + variableValues, + returnType, + fieldNodes, +) { + const subFieldNodes = new Map(); + const visitedFragmentNames = new Set(); + + for (const node of fieldNodes) { + if (node.selectionSet) { + collectFieldsImpl( + schema, + fragments, + variableValues, + returnType, + node.selectionSet, + subFieldNodes, + visitedFragmentNames, + ); + } + } + + return subFieldNodes; +} + +function collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + selectionSet, + fields, + visitedFragmentNames, +) { + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FIELD */ .h.FIELD: { + if (!shouldIncludeNode(variableValues, selection)) { + continue; + } + + const name = getFieldEntryKey(selection); + const fieldList = fields.get(name); + + if (fieldList !== undefined) { + fieldList.push(selection); + } else { + fields.set(name, [selection]); + } + + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.INLINE_FRAGMENT */ .h.INLINE_FRAGMENT: { + if ( + !shouldIncludeNode(variableValues, selection) || + !doesFragmentConditionMatch(schema, selection, runtimeType) + ) { + continue; + } + + collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + selection.selectionSet, + fields, + visitedFragmentNames, + ); + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FRAGMENT_SPREAD */ .h.FRAGMENT_SPREAD: { + const fragName = selection.name.value; + + if ( + visitedFragmentNames.has(fragName) || + !shouldIncludeNode(variableValues, selection) + ) { + continue; + } + + visitedFragmentNames.add(fragName); + const fragment = fragments[fragName]; + + if ( + !fragment || + !doesFragmentConditionMatch(schema, fragment, runtimeType) + ) { + continue; + } + + collectFieldsImpl( + schema, + fragments, + variableValues, + runtimeType, + fragment.selectionSet, + fields, + visitedFragmentNames, + ); + break; + } + } + } +} +/** + * Determines if a field should be included based on the `@include` and `@skip` + * directives, where `@skip` has higher precedence than `@include`. + */ + +function shouldIncludeNode(variableValues, node) { + const skip = (0,_values_mjs__WEBPACK_IMPORTED_MODULE_1__/* .getDirectiveValues */ .zu)(_type_directives_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLSkipDirective */ .QE, node, variableValues); + + if ((skip === null || skip === void 0 ? void 0 : skip.if) === true) { + return false; + } + + const include = (0,_values_mjs__WEBPACK_IMPORTED_MODULE_1__/* .getDirectiveValues */ .zu)( + _type_directives_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLIncludeDirective */ .Yf, + node, + variableValues, + ); + + if ( + (include === null || include === void 0 ? void 0 : include.if) === false + ) { + return false; + } + + return true; +} +/** + * Determines if a fragment is applicable to the given type. + */ + +function doesFragmentConditionMatch(schema, fragment, type) { + const typeConditionNode = fragment.typeCondition; + + if (!typeConditionNode) { + return true; + } + + const conditionalType = (0,_utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_3__/* .typeFromAST */ ._)(schema, typeConditionNode); + + if (conditionalType === type) { + return true; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_4__/* .isAbstractType */ .m0)(conditionalType)) { + return schema.isSubType(conditionalType, type); + } + + return false; +} +/** + * Implements the logic to compute the key of a given field's entry + */ + +function getFieldEntryKey(node) { + return node.alias ? node.alias.value : node.name.value; +} + + +/***/ }), + +/***/ 5329: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "td": () => (/* binding */ assertValidExecutionArguments), + "VZ": () => (/* binding */ buildExecutionContext), + "p$": () => (/* binding */ buildResolveInfo), + "El": () => (/* binding */ defaultFieldResolver), + "mn": () => (/* binding */ defaultTypeResolver), + "ht": () => (/* binding */ execute), + "p0": () => (/* binding */ executeSync), + "Vm": () => (/* binding */ getFieldDef) +}); + +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/devAssert.mjs +var devAssert = __webpack_require__(7826); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/inspect.mjs +var inspect = __webpack_require__(5821); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/invariant.mjs +var invariant = __webpack_require__(9551); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/isIterableObject.mjs +var isIterableObject = __webpack_require__(3831); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/isObjectLike.mjs +var isObjectLike = __webpack_require__(8495); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/isPromise.mjs +var isPromise = __webpack_require__(8659); +;// CONCATENATED MODULE: ./node_modules/graphql/jsutils/memoize3.mjs +/** + * Memoizes the provided three-argument function. + */ +function memoize3(fn) { + let cache0; + return function memoized(a1, a2, a3) { + if (cache0 === undefined) { + cache0 = new WeakMap(); + } + + let cache1 = cache0.get(a1); + + if (cache1 === undefined) { + cache1 = new WeakMap(); + cache0.set(a1, cache1); + } + + let cache2 = cache1.get(a2); + + if (cache2 === undefined) { + cache2 = new WeakMap(); + cache1.set(a2, cache2); + } + + let fnResult = cache2.get(a3); + + if (fnResult === undefined) { + fnResult = fn(a1, a2, a3); + cache2.set(a3, fnResult); + } + + return fnResult; + }; +} + +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/Path.mjs +var Path = __webpack_require__(9380); +;// CONCATENATED MODULE: ./node_modules/graphql/jsutils/promiseForObject.mjs +/** + * This function transforms a JS object `ObjMap>` into + * a `Promise>` + * + * This is akin to bluebird's `Promise.props`, but implemented only using + * `Promise.all` so it will work with any implementation of ES6 promises. + */ +function promiseForObject(object) { + return Promise.all(Object.values(object)).then((resolvedValues) => { + const resolvedObject = Object.create(null); + + for (const [i, key] of Object.keys(object).entries()) { + resolvedObject[key] = resolvedValues[i]; + } + + return resolvedObject; + }); +} + +;// CONCATENATED MODULE: ./node_modules/graphql/jsutils/promiseReduce.mjs + + +/** + * Similar to Array.prototype.reduce(), however the reducing callback may return + * a Promise, in which case reduction will continue after each promise resolves. + * + * If the callback does not return a Promise, then this function will also not + * return a Promise. + */ +function promiseReduce(values, callbackFn, initialValue) { + let accumulator = initialValue; + + for (const value of values) { + accumulator = (0,isPromise/* isPromise */.t)(accumulator) + ? accumulator.then((resolved) => callbackFn(resolved, value)) + : callbackFn(accumulator, value); + } + + return accumulator; +} + +// EXTERNAL MODULE: ./node_modules/graphql/error/GraphQLError.mjs +var GraphQLError = __webpack_require__(8087); +// EXTERNAL MODULE: ./node_modules/graphql/error/locatedError.mjs + 1 modules +var locatedError = __webpack_require__(4181); +// EXTERNAL MODULE: ./node_modules/graphql/language/ast.mjs +var ast = __webpack_require__(2380); +// EXTERNAL MODULE: ./node_modules/graphql/language/kinds.mjs +var kinds = __webpack_require__(7359); +// EXTERNAL MODULE: ./node_modules/graphql/type/definition.mjs + 1 modules +var definition = __webpack_require__(398); +// EXTERNAL MODULE: ./node_modules/graphql/type/introspection.mjs +var introspection = __webpack_require__(2433); +// EXTERNAL MODULE: ./node_modules/graphql/type/validate.mjs +var validate = __webpack_require__(9655); +// EXTERNAL MODULE: ./node_modules/graphql/execution/collectFields.mjs +var collectFields = __webpack_require__(7677); +// EXTERNAL MODULE: ./node_modules/graphql/execution/values.mjs +var values = __webpack_require__(6422); +;// CONCATENATED MODULE: ./node_modules/graphql/execution/execute.mjs + + + + + + + + + + + + + + + + + + + +/** + * A memoized collection of relevant subfields with regard to the return + * type. Memoizing ensures the subfields are not repeatedly calculated, which + * saves overhead when resolving lists of values. + */ + +const collectSubfields = memoize3((exeContext, returnType, fieldNodes) => + (0,collectFields/* collectSubfields */.w)( + exeContext.schema, + exeContext.fragments, + exeContext.variableValues, + returnType, + fieldNodes, + ), +); +/** + * Terminology + * + * "Definitions" are the generic name for top-level statements in the document. + * Examples of this include: + * 1) Operations (such as a query) + * 2) Fragments + * + * "Operations" are a generic name for requests in the document. + * Examples of this include: + * 1) query, + * 2) mutation + * + * "Selections" are the definitions that can appear legally and at + * single level of the query. These include: + * 1) field references e.g `a` + * 2) fragment "spreads" e.g. `...c` + * 3) inline fragment "spreads" e.g. `...on Type { a }` + */ + +/** + * Data that must be available at all points during query execution. + * + * Namely, schema of the type system that is currently executing, + * and the fragments defined in the query document + */ + +/** + * Implements the "Executing requests" section of the GraphQL specification. + * + * Returns either a synchronous ExecutionResult (if all encountered resolvers + * are synchronous), or a Promise of an ExecutionResult that will eventually be + * resolved and never rejected. + * + * If the arguments to this function do not result in a legal execution context, + * a GraphQLError will be thrown immediately explaining the invalid input. + */ +function execute(args) { + // Temporary for v15 to v16 migration. Remove in v17 + arguments.length < 2 || + (0,devAssert/* devAssert */.a)( + false, + 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', + ); + const { schema, document, variableValues, rootValue } = args; // If arguments are missing or incorrect, throw an error. + + assertValidExecutionArguments(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments, + // a "Response" with only errors is returned. + + const exeContext = buildExecutionContext(args); // Return early errors if execution context failed. + + if (!('schema' in exeContext)) { + return { + errors: exeContext, + }; + } // Return a Promise that will eventually resolve to the data described by + // The "Response" section of the GraphQL specification. + // + // If errors are encountered while executing a GraphQL field, only that + // field and its descendants will be omitted, and sibling fields will still + // be executed. An execution which encounters errors will still result in a + // resolved Promise. + // + // Errors from sub-fields of a NonNull type may propagate to the top level, + // at which point we still log the error and null the parent field, which + // in this case is the entire response. + + try { + const { operation } = exeContext; + const result = executeOperation(exeContext, operation, rootValue); + + if ((0,isPromise/* isPromise */.t)(result)) { + return result.then( + (data) => buildResponse(data, exeContext.errors), + (error) => { + exeContext.errors.push(error); + return buildResponse(null, exeContext.errors); + }, + ); + } + + return buildResponse(result, exeContext.errors); + } catch (error) { + exeContext.errors.push(error); + return buildResponse(null, exeContext.errors); + } +} +/** + * Also implements the "Executing requests" section of the GraphQL specification. + * However, it guarantees to complete synchronously (or throw an error) assuming + * that all field resolvers are also synchronous. + */ + +function executeSync(args) { + const result = execute(args); // Assert that the execution was synchronous. + + if ((0,isPromise/* isPromise */.t)(result)) { + throw new Error('GraphQL execution failed to complete synchronously.'); + } + + return result; +} +/** + * Given a completed execution context and data, build the `{ errors, data }` + * response defined by the "Response" section of the GraphQL specification. + */ + +function buildResponse(data, errors) { + return errors.length === 0 + ? { + data, + } + : { + errors, + data, + }; +} +/** + * Essential assertions before executing to provide developer feedback for + * improper use of the GraphQL library. + * + * @internal + */ + +function assertValidExecutionArguments( + schema, + document, + rawVariableValues, +) { + document || (0,devAssert/* devAssert */.a)(false, 'Must provide document.'); // If the schema used for execution is invalid, throw an error. + + (0,validate/* assertValidSchema */.J)(schema); // Variables, if provided, must be an object. + + rawVariableValues == null || + (0,isObjectLike/* isObjectLike */.y)(rawVariableValues) || + (0,devAssert/* devAssert */.a)( + false, + 'Variables must be provided as an Object where each property is a variable value. Perhaps look to see if an unparsed JSON string was provided.', + ); +} +/** + * Constructs a ExecutionContext object from the arguments passed to + * execute, which we will pass throughout the other execution methods. + * + * Throws a GraphQLError if a valid execution context cannot be created. + * + * @internal + */ + +function buildExecutionContext(args) { + var _definition$name, _operation$variableDe; + + const { + schema, + document, + rootValue, + contextValue, + variableValues: rawVariableValues, + operationName, + fieldResolver, + typeResolver, + subscribeFieldResolver, + } = args; + let operation; + const fragments = Object.create(null); + + for (const definition of document.definitions) { + switch (definition.kind) { + case kinds/* Kind.OPERATION_DEFINITION */.h.OPERATION_DEFINITION: + if (operationName == null) { + if (operation !== undefined) { + return [ + new GraphQLError/* GraphQLError */.__( + 'Must provide operation name if query contains multiple operations.', + ), + ]; + } + + operation = definition; + } else if ( + ((_definition$name = definition.name) === null || + _definition$name === void 0 + ? void 0 + : _definition$name.value) === operationName + ) { + operation = definition; + } + + break; + + case kinds/* Kind.FRAGMENT_DEFINITION */.h.FRAGMENT_DEFINITION: + fragments[definition.name.value] = definition; + break; + + default: // ignore non-executable definitions + } + } + + if (!operation) { + if (operationName != null) { + return [new GraphQLError/* GraphQLError */.__(`Unknown operation named "${operationName}".`)]; + } + + return [new GraphQLError/* GraphQLError */.__('Must provide an operation.')]; + } // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const variableDefinitions = + (_operation$variableDe = operation.variableDefinitions) !== null && + _operation$variableDe !== void 0 + ? _operation$variableDe + : []; + const coercedVariableValues = (0,values/* getVariableValues */.QF)( + schema, + variableDefinitions, + rawVariableValues !== null && rawVariableValues !== void 0 + ? rawVariableValues + : {}, + { + maxErrors: 50, + }, + ); + + if (coercedVariableValues.errors) { + return coercedVariableValues.errors; + } + + return { + schema, + fragments, + rootValue, + contextValue, + operation, + variableValues: coercedVariableValues.coerced, + fieldResolver: + fieldResolver !== null && fieldResolver !== void 0 + ? fieldResolver + : defaultFieldResolver, + typeResolver: + typeResolver !== null && typeResolver !== void 0 + ? typeResolver + : defaultTypeResolver, + subscribeFieldResolver: + subscribeFieldResolver !== null && subscribeFieldResolver !== void 0 + ? subscribeFieldResolver + : defaultFieldResolver, + errors: [], + }; +} +/** + * Implements the "Executing operations" section of the spec. + */ + +function executeOperation(exeContext, operation, rootValue) { + const rootType = exeContext.schema.getRootType(operation.operation); + + if (rootType == null) { + throw new GraphQLError/* GraphQLError */.__( + `Schema is not configured to execute ${operation.operation} operation.`, + { + nodes: operation, + }, + ); + } + + const rootFields = (0,collectFields/* collectFields */.g)( + exeContext.schema, + exeContext.fragments, + exeContext.variableValues, + rootType, + operation.selectionSet, + ); + const path = undefined; + + switch (operation.operation) { + case ast/* OperationTypeNode.QUERY */.ku.QUERY: + return executeFields(exeContext, rootType, rootValue, path, rootFields); + + case ast/* OperationTypeNode.MUTATION */.ku.MUTATION: + return executeFieldsSerially( + exeContext, + rootType, + rootValue, + path, + rootFields, + ); + + case ast/* OperationTypeNode.SUBSCRIPTION */.ku.SUBSCRIPTION: + // TODO: deprecate `subscribe` and move all logic here + // Temporary solution until we finish merging execute and subscribe together + return executeFields(exeContext, rootType, rootValue, path, rootFields); + } +} +/** + * Implements the "Executing selection sets" section of the spec + * for fields that must be executed serially. + */ + +function executeFieldsSerially( + exeContext, + parentType, + sourceValue, + path, + fields, +) { + return promiseReduce( + fields.entries(), + (results, [responseName, fieldNodes]) => { + const fieldPath = (0,Path/* addPath */.Q)(path, responseName, parentType.name); + const result = executeField( + exeContext, + parentType, + sourceValue, + fieldNodes, + fieldPath, + ); + + if (result === undefined) { + return results; + } + + if ((0,isPromise/* isPromise */.t)(result)) { + return result.then((resolvedResult) => { + results[responseName] = resolvedResult; + return results; + }); + } + + results[responseName] = result; + return results; + }, + Object.create(null), + ); +} +/** + * Implements the "Executing selection sets" section of the spec + * for fields that may be executed in parallel. + */ + +function executeFields(exeContext, parentType, sourceValue, path, fields) { + const results = Object.create(null); + let containsPromise = false; + + for (const [responseName, fieldNodes] of fields.entries()) { + const fieldPath = (0,Path/* addPath */.Q)(path, responseName, parentType.name); + const result = executeField( + exeContext, + parentType, + sourceValue, + fieldNodes, + fieldPath, + ); + + if (result !== undefined) { + results[responseName] = result; + + if ((0,isPromise/* isPromise */.t)(result)) { + containsPromise = true; + } + } + } // If there are no promises, we can just return the object + + if (!containsPromise) { + return results; + } // Otherwise, results is a map from field name to the result of resolving that + // field, which is possibly a promise. Return a promise that will return this + // same map, but with any promises replaced with the values they resolved to. + + return promiseForObject(results); +} +/** + * Implements the "Executing fields" section of the spec + * In particular, this function figures out the value that the field returns by + * calling its resolve function, then calls completeValue to complete promises, + * serialize scalars, or execute the sub-selection-set for objects. + */ + +function executeField(exeContext, parentType, source, fieldNodes, path) { + var _fieldDef$resolve; + + const fieldDef = getFieldDef(exeContext.schema, parentType, fieldNodes[0]); + + if (!fieldDef) { + return; + } + + const returnType = fieldDef.type; + const resolveFn = + (_fieldDef$resolve = fieldDef.resolve) !== null && + _fieldDef$resolve !== void 0 + ? _fieldDef$resolve + : exeContext.fieldResolver; + const info = buildResolveInfo( + exeContext, + fieldDef, + fieldNodes, + parentType, + path, + ); // Get the resolve function, regardless of if its result is normal or abrupt (error). + + try { + // Build a JS object of arguments from the field.arguments AST, using the + // variables scope to fulfill any variable references. + // TODO: find a way to memoize, in case this field is within a List type. + const args = (0,values/* getArgumentValues */.LX)( + fieldDef, + fieldNodes[0], + exeContext.variableValues, + ); // The resolve function's optional third argument is a context value that + // is provided to every resolve function within an execution. It is commonly + // used to represent an authenticated user, or request-specific caches. + + const contextValue = exeContext.contextValue; + const result = resolveFn(source, args, contextValue, info); + let completed; + + if ((0,isPromise/* isPromise */.t)(result)) { + completed = result.then((resolved) => + completeValue(exeContext, returnType, fieldNodes, info, path, resolved), + ); + } else { + completed = completeValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, + ); + } + + if ((0,isPromise/* isPromise */.t)(completed)) { + // Note: we don't rely on a `catch` method, but we do expect "thenable" + // to take a second callback for the error case. + return completed.then(undefined, (rawError) => { + const error = (0,locatedError/* locatedError */.y)(rawError, fieldNodes, (0,Path/* pathToArray */.N)(path)); + return handleFieldError(error, returnType, exeContext); + }); + } + + return completed; + } catch (rawError) { + const error = (0,locatedError/* locatedError */.y)(rawError, fieldNodes, (0,Path/* pathToArray */.N)(path)); + return handleFieldError(error, returnType, exeContext); + } +} +/** + * @internal + */ + +function buildResolveInfo( + exeContext, + fieldDef, + fieldNodes, + parentType, + path, +) { + // The resolve function's optional fourth argument is a collection of + // information about the current execution state. + return { + fieldName: fieldDef.name, + fieldNodes, + returnType: fieldDef.type, + parentType, + path, + schema: exeContext.schema, + fragments: exeContext.fragments, + rootValue: exeContext.rootValue, + operation: exeContext.operation, + variableValues: exeContext.variableValues, + }; +} + +function handleFieldError(error, returnType, exeContext) { + // If the field type is non-nullable, then it is resolved without any + // protection from errors, however it still properly locates the error. + if ((0,definition/* isNonNullType */.zM)(returnType)) { + throw error; + } // Otherwise, error protection is applied, logging the error and resolving + // a null value for this field if one is encountered. + + exeContext.errors.push(error); + return null; +} +/** + * Implements the instructions for completeValue as defined in the + * "Value Completion" section of the spec. + * + * If the field type is Non-Null, then this recursively completes the value + * for the inner type. It throws a field error if that completion returns null, + * as per the "Nullability" section of the spec. + * + * If the field type is a List, then this recursively completes the value + * for the inner type on each item in the list. + * + * If the field type is a Scalar or Enum, ensures the completed value is a legal + * value of the type by calling the `serialize` method of GraphQL type + * definition. + * + * If the field is an abstract type, determine the runtime type of the value + * and then complete based on that type + * + * Otherwise, the field type expects a sub-selection set, and will complete the + * value by executing all sub-selections. + */ + +function completeValue(exeContext, returnType, fieldNodes, info, path, result) { + // If result is an Error, throw a located error. + if (result instanceof Error) { + throw result; + } // If field type is NonNull, complete for inner type, and throw field error + // if result is null. + + if ((0,definition/* isNonNullType */.zM)(returnType)) { + const completed = completeValue( + exeContext, + returnType.ofType, + fieldNodes, + info, + path, + result, + ); + + if (completed === null) { + throw new Error( + `Cannot return null for non-nullable field ${info.parentType.name}.${info.fieldName}.`, + ); + } + + return completed; + } // If result value is null or undefined then return null. + + if (result == null) { + return null; + } // If field type is List, complete each item in the list with the inner type + + if ((0,definition/* isListType */.HG)(returnType)) { + return completeListValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, + ); + } // If field type is a leaf type, Scalar or Enum, serialize to a valid value, + // returning null if serialization is not possible. + + if ((0,definition/* isLeafType */.UT)(returnType)) { + return completeLeafValue(returnType, result); + } // If field type is an abstract type, Interface or Union, determine the + // runtime Object type and complete for that type. + + if ((0,definition/* isAbstractType */.m0)(returnType)) { + return completeAbstractValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, + ); + } // If field type is Object, execute and complete all sub-selections. + + if ((0,definition/* isObjectType */.lp)(returnType)) { + return completeObjectValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, + ); + } + /* c8 ignore next 6 */ + // Not reachable, all possible output types have been considered. + + false || + (0,invariant/* invariant */.k)( + false, + 'Cannot complete value of unexpected output type: ' + (0,inspect/* inspect */.X)(returnType), + ); +} +/** + * Complete a list value by completing each item in the list with the + * inner type + */ + +function completeListValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, +) { + if (!(0,isIterableObject/* isIterableObject */.i)(result)) { + throw new GraphQLError/* GraphQLError */.__( + `Expected Iterable, but did not find one for field "${info.parentType.name}.${info.fieldName}".`, + ); + } // This is specified as a simple map, however we're optimizing the path + // where the list contains no Promises by avoiding creating another Promise. + + const itemType = returnType.ofType; + let containsPromise = false; + const completedResults = Array.from(result, (item, index) => { + // No need to modify the info object containing the path, + // since from here on it is not ever accessed by resolver functions. + const itemPath = (0,Path/* addPath */.Q)(path, index, undefined); + + try { + let completedItem; + + if ((0,isPromise/* isPromise */.t)(item)) { + completedItem = item.then((resolved) => + completeValue( + exeContext, + itemType, + fieldNodes, + info, + itemPath, + resolved, + ), + ); + } else { + completedItem = completeValue( + exeContext, + itemType, + fieldNodes, + info, + itemPath, + item, + ); + } + + if ((0,isPromise/* isPromise */.t)(completedItem)) { + containsPromise = true; // Note: we don't rely on a `catch` method, but we do expect "thenable" + // to take a second callback for the error case. + + return completedItem.then(undefined, (rawError) => { + const error = (0,locatedError/* locatedError */.y)( + rawError, + fieldNodes, + (0,Path/* pathToArray */.N)(itemPath), + ); + return handleFieldError(error, itemType, exeContext); + }); + } + + return completedItem; + } catch (rawError) { + const error = (0,locatedError/* locatedError */.y)(rawError, fieldNodes, (0,Path/* pathToArray */.N)(itemPath)); + return handleFieldError(error, itemType, exeContext); + } + }); + return containsPromise ? Promise.all(completedResults) : completedResults; +} +/** + * Complete a Scalar or Enum by serializing to a valid value, returning + * null if serialization is not possible. + */ + +function completeLeafValue(returnType, result) { + const serializedResult = returnType.serialize(result); + + if (serializedResult == null) { + throw new Error( + `Expected \`${(0,inspect/* inspect */.X)(returnType)}.serialize(${(0,inspect/* inspect */.X)(result)})\` to ` + + `return non-nullable value, returned: ${(0,inspect/* inspect */.X)(serializedResult)}`, + ); + } + + return serializedResult; +} +/** + * Complete a value of an abstract type by determining the runtime object type + * of that value, then complete the value for that type. + */ + +function completeAbstractValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, +) { + var _returnType$resolveTy; + + const resolveTypeFn = + (_returnType$resolveTy = returnType.resolveType) !== null && + _returnType$resolveTy !== void 0 + ? _returnType$resolveTy + : exeContext.typeResolver; + const contextValue = exeContext.contextValue; + const runtimeType = resolveTypeFn(result, contextValue, info, returnType); + + if ((0,isPromise/* isPromise */.t)(runtimeType)) { + return runtimeType.then((resolvedRuntimeType) => + completeObjectValue( + exeContext, + ensureValidRuntimeType( + resolvedRuntimeType, + exeContext, + returnType, + fieldNodes, + info, + result, + ), + fieldNodes, + info, + path, + result, + ), + ); + } + + return completeObjectValue( + exeContext, + ensureValidRuntimeType( + runtimeType, + exeContext, + returnType, + fieldNodes, + info, + result, + ), + fieldNodes, + info, + path, + result, + ); +} + +function ensureValidRuntimeType( + runtimeTypeName, + exeContext, + returnType, + fieldNodes, + info, + result, +) { + if (runtimeTypeName == null) { + throw new GraphQLError/* GraphQLError */.__( + `Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}". Either the "${returnType.name}" type should provide a "resolveType" function or each possible type should provide an "isTypeOf" function.`, + fieldNodes, + ); + } // releases before 16.0.0 supported returning `GraphQLObjectType` from `resolveType` + // TODO: remove in 17.0.0 release + + if ((0,definition/* isObjectType */.lp)(runtimeTypeName)) { + throw new GraphQLError/* GraphQLError */.__( + 'Support for returning GraphQLObjectType from resolveType was removed in graphql-js@16.0.0 please return type name instead.', + ); + } + + if (typeof runtimeTypeName !== 'string') { + throw new GraphQLError/* GraphQLError */.__( + `Abstract type "${returnType.name}" must resolve to an Object type at runtime for field "${info.parentType.name}.${info.fieldName}" with ` + + `value ${(0,inspect/* inspect */.X)(result)}, received "${(0,inspect/* inspect */.X)(runtimeTypeName)}".`, + ); + } + + const runtimeType = exeContext.schema.getType(runtimeTypeName); + + if (runtimeType == null) { + throw new GraphQLError/* GraphQLError */.__( + `Abstract type "${returnType.name}" was resolved to a type "${runtimeTypeName}" that does not exist inside the schema.`, + { + nodes: fieldNodes, + }, + ); + } + + if (!(0,definition/* isObjectType */.lp)(runtimeType)) { + throw new GraphQLError/* GraphQLError */.__( + `Abstract type "${returnType.name}" was resolved to a non-object type "${runtimeTypeName}".`, + { + nodes: fieldNodes, + }, + ); + } + + if (!exeContext.schema.isSubType(returnType, runtimeType)) { + throw new GraphQLError/* GraphQLError */.__( + `Runtime Object type "${runtimeType.name}" is not a possible type for "${returnType.name}".`, + { + nodes: fieldNodes, + }, + ); + } + + return runtimeType; +} +/** + * Complete an Object value by executing all sub-selections. + */ + +function completeObjectValue( + exeContext, + returnType, + fieldNodes, + info, + path, + result, +) { + // Collect sub-fields to execute to complete this value. + const subFieldNodes = collectSubfields(exeContext, returnType, fieldNodes); // If there is an isTypeOf predicate function, call it with the + // current result. If isTypeOf returns false, then raise an error rather + // than continuing execution. + + if (returnType.isTypeOf) { + const isTypeOf = returnType.isTypeOf(result, exeContext.contextValue, info); + + if ((0,isPromise/* isPromise */.t)(isTypeOf)) { + return isTypeOf.then((resolvedIsTypeOf) => { + if (!resolvedIsTypeOf) { + throw invalidReturnTypeError(returnType, result, fieldNodes); + } + + return executeFields( + exeContext, + returnType, + result, + path, + subFieldNodes, + ); + }); + } + + if (!isTypeOf) { + throw invalidReturnTypeError(returnType, result, fieldNodes); + } + } + + return executeFields(exeContext, returnType, result, path, subFieldNodes); +} + +function invalidReturnTypeError(returnType, result, fieldNodes) { + return new GraphQLError/* GraphQLError */.__( + `Expected value of type "${returnType.name}" but got: ${(0,inspect/* inspect */.X)(result)}.`, + { + nodes: fieldNodes, + }, + ); +} +/** + * If a resolveType function is not given, then a default resolve behavior is + * used which attempts two strategies: + * + * First, See if the provided value has a `__typename` field defined, if so, use + * that value as name of the resolved type. + * + * Otherwise, test each possible type for the abstract type by calling + * isTypeOf for the object being coerced, returning the first type that matches. + */ + +const defaultTypeResolver = function ( + value, + contextValue, + info, + abstractType, +) { + // First, look for `__typename`. + if ((0,isObjectLike/* isObjectLike */.y)(value) && typeof value.__typename === 'string') { + return value.__typename; + } // Otherwise, test each possible type. + + const possibleTypes = info.schema.getPossibleTypes(abstractType); + const promisedIsTypeOfResults = []; + + for (let i = 0; i < possibleTypes.length; i++) { + const type = possibleTypes[i]; + + if (type.isTypeOf) { + const isTypeOfResult = type.isTypeOf(value, contextValue, info); + + if ((0,isPromise/* isPromise */.t)(isTypeOfResult)) { + promisedIsTypeOfResults[i] = isTypeOfResult; + } else if (isTypeOfResult) { + return type.name; + } + } + } + + if (promisedIsTypeOfResults.length) { + return Promise.all(promisedIsTypeOfResults).then((isTypeOfResults) => { + for (let i = 0; i < isTypeOfResults.length; i++) { + if (isTypeOfResults[i]) { + return possibleTypes[i].name; + } + } + }); + } +}; +/** + * If a resolve function is not given, then a default resolve behavior is used + * which takes the property of the source object of the same name as the field + * and returns it as the result, or if it's a function, returns the result + * of calling that function while passing along args and context value. + */ + +const defaultFieldResolver = function ( + source, + args, + contextValue, + info, +) { + // ensure source is a value for which property access is acceptable. + if ((0,isObjectLike/* isObjectLike */.y)(source) || typeof source === 'function') { + const property = source[info.fieldName]; + + if (typeof property === 'function') { + return source[info.fieldName](args, contextValue, info); + } + + return property; + } +}; +/** + * This method looks up the field on the given type definition. + * It has special casing for the three introspection fields, + * __schema, __type and __typename. __typename is special because + * it can always be queried as a field, even in situations where no + * other fields are allowed, like on a Union. __schema and __type + * could get automatically added to the query type, but that would + * require mutating type definitions, which would cause issues. + * + * @internal + */ + +function getFieldDef(schema, parentType, fieldNode) { + const fieldName = fieldNode.name.value; + + if ( + fieldName === introspection/* SchemaMetaFieldDef.name */.Az.name && + schema.getQueryType() === parentType + ) { + return introspection/* SchemaMetaFieldDef */.Az; + } else if ( + fieldName === introspection/* TypeMetaFieldDef.name */.tF.name && + schema.getQueryType() === parentType + ) { + return introspection/* TypeMetaFieldDef */.tF; + } else if (fieldName === introspection/* TypeNameMetaFieldDef.name */.hU.name) { + return introspection/* TypeNameMetaFieldDef */.hU; + } + + return parentType.getFields()[fieldName]; +} + + +/***/ }), + +/***/ 6422: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "LX": () => (/* binding */ getArgumentValues), +/* harmony export */ "QF": () => (/* binding */ getVariableValues), +/* harmony export */ "zu": () => (/* binding */ getDirectiveValues) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(3498); +/* harmony import */ var _jsutils_printPathArray_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(4244); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(7359); +/* harmony import */ var _language_printer_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3486); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(398); +/* harmony import */ var _utilities_coerceInputValue_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7816); +/* harmony import */ var _utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(77); +/* harmony import */ var _utilities_valueFromAST_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2221); + + + + + + + + + + + +/** + * Prepares an object map of variableValues of the correct type based on the + * provided variable definitions and arbitrary input. If the input cannot be + * parsed to match the variable definitions, a GraphQLError will be thrown. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ +function getVariableValues(schema, varDefNodes, inputs, options) { + const errors = []; + const maxErrors = + options === null || options === void 0 ? void 0 : options.maxErrors; + + try { + const coerced = coerceVariableValues( + schema, + varDefNodes, + inputs, + (error) => { + if (maxErrors != null && errors.length >= maxErrors) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + 'Too many errors processing variables, error limit reached. Execution aborted.', + ); + } + + errors.push(error); + }, + ); + + if (errors.length === 0) { + return { + coerced, + }; + } + } catch (error) { + errors.push(error); + } + + return { + errors, + }; +} + +function coerceVariableValues(schema, varDefNodes, inputs, onError) { + const coercedValues = {}; + + for (const varDefNode of varDefNodes) { + const varName = varDefNode.variable.name.value; + const varType = (0,_utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_1__/* .typeFromAST */ ._)(schema, varDefNode.type); + + if (!(0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInputType */ .j$)(varType)) { + // Must use input types for variables. This should be caught during + // validation, however is checked again here for safety. + const varTypeStr = (0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_3__/* .print */ .S)(varDefNode.type); + onError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Variable "$${varName}" expected value of type "${varTypeStr}" which cannot be used as an input type.`, + { + nodes: varDefNode.type, + }, + ), + ); + continue; + } + + if (!hasOwnProperty(inputs, varName)) { + if (varDefNode.defaultValue) { + coercedValues[varName] = (0,_utilities_valueFromAST_mjs__WEBPACK_IMPORTED_MODULE_4__/* .valueFromAST */ .u)(varDefNode.defaultValue, varType); + } else if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNonNullType */ .zM)(varType)) { + const varTypeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__/* .inspect */ .X)(varType); + onError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Variable "$${varName}" of required type "${varTypeStr}" was not provided.`, + { + nodes: varDefNode, + }, + ), + ); + } + + continue; + } + + const value = inputs[varName]; + + if (value === null && (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNonNullType */ .zM)(varType)) { + const varTypeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__/* .inspect */ .X)(varType); + onError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Variable "$${varName}" of non-null type "${varTypeStr}" must not be null.`, + { + nodes: varDefNode, + }, + ), + ); + continue; + } + + coercedValues[varName] = (0,_utilities_coerceInputValue_mjs__WEBPACK_IMPORTED_MODULE_6__/* .coerceInputValue */ .K)( + value, + varType, + (path, invalidValue, error) => { + let prefix = + `Variable "$${varName}" got invalid value ` + (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__/* .inspect */ .X)(invalidValue); + + if (path.length > 0) { + prefix += ` at "${varName}${(0,_jsutils_printPathArray_mjs__WEBPACK_IMPORTED_MODULE_7__/* .printPathArray */ .F)(path)}"`; + } + + onError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__(prefix + '; ' + error.message, { + nodes: varDefNode, + originalError: error.originalError, + }), + ); + }, + ); + } + + return coercedValues; +} +/** + * Prepares an object map of argument values given a list of argument + * definitions and list of argument AST nodes. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ + +function getArgumentValues(def, node, variableValues) { + var _node$arguments; + + const coercedValues = {}; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const argumentNodes = + (_node$arguments = node.arguments) !== null && _node$arguments !== void 0 + ? _node$arguments + : []; + const argNodeMap = (0,_jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_8__/* .keyMap */ .P)(argumentNodes, (arg) => arg.name.value); + + for (const argDef of def.args) { + const name = argDef.name; + const argType = argDef.type; + const argumentNode = argNodeMap[name]; + + if (!argumentNode) { + if (argDef.defaultValue !== undefined) { + coercedValues[name] = argDef.defaultValue; + } else if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNonNullType */ .zM)(argType)) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Argument "${name}" of required type "${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__/* .inspect */ .X)(argType)}" ` + + 'was not provided.', + { + nodes: node, + }, + ); + } + + continue; + } + + const valueNode = argumentNode.value; + let isNull = valueNode.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_9__/* .Kind.NULL */ .h.NULL; + + if (valueNode.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_9__/* .Kind.VARIABLE */ .h.VARIABLE) { + const variableName = valueNode.name.value; + + if ( + variableValues == null || + !hasOwnProperty(variableValues, variableName) + ) { + if (argDef.defaultValue !== undefined) { + coercedValues[name] = argDef.defaultValue; + } else if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNonNullType */ .zM)(argType)) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Argument "${name}" of required type "${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__/* .inspect */ .X)(argType)}" ` + + `was provided the variable "$${variableName}" which was not provided a runtime value.`, + { + nodes: valueNode, + }, + ); + } + + continue; + } + + isNull = variableValues[variableName] == null; + } + + if (isNull && (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNonNullType */ .zM)(argType)) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Argument "${name}" of non-null type "${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__/* .inspect */ .X)(argType)}" ` + + 'must not be null.', + { + nodes: valueNode, + }, + ); + } + + const coercedValue = (0,_utilities_valueFromAST_mjs__WEBPACK_IMPORTED_MODULE_4__/* .valueFromAST */ .u)(valueNode, argType, variableValues); + + if (coercedValue === undefined) { + // Note: ValuesOfCorrectTypeRule validation should catch this before + // execution. This is a runtime check to ensure execution does not + // continue with an invalid argument value. + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Argument "${name}" has invalid value ${(0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_3__/* .print */ .S)(valueNode)}.`, + { + nodes: valueNode, + }, + ); + } + + coercedValues[name] = coercedValue; + } + + return coercedValues; +} +/** + * Prepares an object map of argument values given a directive definition + * and a AST node which may contain directives. Optionally also accepts a map + * of variable values. + * + * If the directive does not exist on the node, returns undefined. + * + * Note: The returned value is a plain Object with a prototype, since it is + * exposed to user code. Care should be taken to not pull values from the + * Object prototype. + */ + +function getDirectiveValues(directiveDef, node, variableValues) { + var _node$directives; + + const directiveNode = + (_node$directives = node.directives) === null || _node$directives === void 0 + ? void 0 + : _node$directives.find( + (directive) => directive.name.value === directiveDef.name, + ); + + if (directiveNode) { + return getArgumentValues(directiveDef, directiveNode, variableValues); + } +} + +function hasOwnProperty(obj, prop) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + + +/***/ }), + +/***/ 2244: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "B": () => (/* binding */ graphql), +/* harmony export */ "V": () => (/* binding */ graphqlSync) +/* harmony export */ }); +/* harmony import */ var _jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7826); +/* harmony import */ var _jsutils_isPromise_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8659); +/* harmony import */ var _language_parser_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(4275); +/* harmony import */ var _type_validate_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9655); +/* harmony import */ var _validation_validate_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(6584); +/* harmony import */ var _execution_execute_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5329); + + + + + + +/** + * This is the primary entry point function for fulfilling GraphQL operations + * by parsing, validating, and executing a GraphQL document along side a + * GraphQL schema. + * + * More sophisticated GraphQL servers, such as those which persist queries, + * may wish to separate the validation and execution phases to a static time + * tooling step, and a server runtime step. + * + * Accepts either an object with named arguments, or individual arguments: + * + * schema: + * The GraphQL type system to use when validating and executing a query. + * source: + * A GraphQL language formatted string representing the requested operation. + * rootValue: + * The value provided as the first argument to resolver functions on the top + * level type (e.g. the query object type). + * contextValue: + * The context value is provided as an argument to resolver functions after + * field arguments. It is used to pass shared information useful at any point + * during executing this query, for example the currently logged in user and + * connections to databases or other services. + * variableValues: + * A mapping of variable name to runtime value to use for all variables + * defined in the requestString. + * operationName: + * The name of the operation to use if requestString contains multiple + * possible operations. Can be omitted if requestString contains only + * one operation. + * fieldResolver: + * A resolver function to use when one is not provided by the schema. + * If not provided, the default field resolver is used (which looks for a + * value or method on the source value with the field's name). + * typeResolver: + * A type resolver function to use when none is provided by the schema. + * If not provided, the default type resolver is used (which looks for a + * `__typename` field or alternatively calls the `isTypeOf` method). + */ + +function graphql(args) { + // Always return a Promise for a consistent API. + return new Promise((resolve) => resolve(graphqlImpl(args))); +} +/** + * The graphqlSync function also fulfills GraphQL operations by parsing, + * validating, and executing a GraphQL document along side a GraphQL schema. + * However, it guarantees to complete synchronously (or throw an error) assuming + * that all field resolvers are also synchronous. + */ + +function graphqlSync(args) { + const result = graphqlImpl(args); // Assert that the execution was synchronous. + + if ((0,_jsutils_isPromise_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isPromise */ .t)(result)) { + throw new Error('GraphQL execution failed to complete synchronously.'); + } + + return result; +} + +function graphqlImpl(args) { + // Temporary for v15 to v16 migration. Remove in v17 + arguments.length < 2 || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_1__/* .devAssert */ .a)( + false, + 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', + ); + const { + schema, + source, + rootValue, + contextValue, + variableValues, + operationName, + fieldResolver, + typeResolver, + } = args; // Validate Schema + + const schemaValidationErrors = (0,_type_validate_mjs__WEBPACK_IMPORTED_MODULE_2__/* .validateSchema */ .F)(schema); + + if (schemaValidationErrors.length > 0) { + return { + errors: schemaValidationErrors, + }; + } // Parse + + let document; + + try { + document = (0,_language_parser_mjs__WEBPACK_IMPORTED_MODULE_3__/* .parse */ .Qc)(source); + } catch (syntaxError) { + return { + errors: [syntaxError], + }; + } // Validate + + const validationErrors = (0,_validation_validate_mjs__WEBPACK_IMPORTED_MODULE_4__/* .validate */ .Gu)(schema, document); + + if (validationErrors.length > 0) { + return { + errors: validationErrors, + }; + } // Execute + + return (0,_execution_execute_mjs__WEBPACK_IMPORTED_MODULE_5__/* .execute */ .ht)({ + schema, + document, + rootValue, + contextValue, + variableValues, + operationName, + fieldResolver, + typeResolver, + }); +} + + +/***/ }), + +/***/ 8929: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +// ESM COMPAT FLAG +__webpack_require__.r(__webpack_exports__); + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "BREAK": () => (/* reexport */ visitor/* BREAK */.$_), + "BreakingChangeType": () => (/* reexport */ BreakingChangeType), + "DEFAULT_DEPRECATION_REASON": () => (/* reexport */ type_directives/* DEFAULT_DEPRECATION_REASON */.SY), + "DangerousChangeType": () => (/* reexport */ DangerousChangeType), + "DirectiveLocation": () => (/* reexport */ directiveLocation/* DirectiveLocation */.B), + "ExecutableDefinitionsRule": () => (/* reexport */ ExecutableDefinitionsRule/* ExecutableDefinitionsRule */.i), + "FieldsOnCorrectTypeRule": () => (/* reexport */ FieldsOnCorrectTypeRule/* FieldsOnCorrectTypeRule */.A), + "FragmentsOnCompositeTypesRule": () => (/* reexport */ FragmentsOnCompositeTypesRule/* FragmentsOnCompositeTypesRule */.T), + "GRAPHQL_MAX_INT": () => (/* reexport */ scalars/* GRAPHQL_MAX_INT */.HI), + "GRAPHQL_MIN_INT": () => (/* reexport */ scalars/* GRAPHQL_MIN_INT */.st), + "GraphQLBoolean": () => (/* reexport */ scalars/* GraphQLBoolean */.EZ), + "GraphQLDeprecatedDirective": () => (/* reexport */ type_directives/* GraphQLDeprecatedDirective */.fg), + "GraphQLDirective": () => (/* reexport */ type_directives/* GraphQLDirective */.NZ), + "GraphQLEnumType": () => (/* reexport */ definition/* GraphQLEnumType */.mR), + "GraphQLError": () => (/* reexport */ GraphQLError/* GraphQLError */.__), + "GraphQLFloat": () => (/* reexport */ scalars/* GraphQLFloat */.av), + "GraphQLID": () => (/* reexport */ scalars/* GraphQLID */.km), + "GraphQLIncludeDirective": () => (/* reexport */ type_directives/* GraphQLIncludeDirective */.Yf), + "GraphQLInputObjectType": () => (/* reexport */ definition/* GraphQLInputObjectType */.sR), + "GraphQLInt": () => (/* reexport */ scalars/* GraphQLInt */._o), + "GraphQLInterfaceType": () => (/* reexport */ definition/* GraphQLInterfaceType */.oW), + "GraphQLList": () => (/* reexport */ definition/* GraphQLList */.p2), + "GraphQLNonNull": () => (/* reexport */ definition/* GraphQLNonNull */.bM), + "GraphQLObjectType": () => (/* reexport */ definition/* GraphQLObjectType */.h6), + "GraphQLScalarType": () => (/* reexport */ definition/* GraphQLScalarType */.n2), + "GraphQLSchema": () => (/* reexport */ type_schema/* GraphQLSchema */.XO), + "GraphQLSkipDirective": () => (/* reexport */ type_directives/* GraphQLSkipDirective */.QE), + "GraphQLSpecifiedByDirective": () => (/* reexport */ type_directives/* GraphQLSpecifiedByDirective */.df), + "GraphQLString": () => (/* reexport */ scalars/* GraphQLString */.kH), + "GraphQLUnionType": () => (/* reexport */ definition/* GraphQLUnionType */.Gp), + "Kind": () => (/* reexport */ kinds/* Kind */.h), + "KnownArgumentNamesRule": () => (/* reexport */ KnownArgumentNamesRule/* KnownArgumentNamesRule */.e), + "KnownDirectivesRule": () => (/* reexport */ KnownDirectivesRule/* KnownDirectivesRule */.J), + "KnownFragmentNamesRule": () => (/* reexport */ KnownFragmentNamesRule/* KnownFragmentNamesRule */.a), + "KnownTypeNamesRule": () => (/* reexport */ KnownTypeNamesRule/* KnownTypeNamesRule */.I), + "Lexer": () => (/* reexport */ language_lexer/* Lexer */.h), + "Location": () => (/* reexport */ ast/* Location */.Ye), + "LoneAnonymousOperationRule": () => (/* reexport */ LoneAnonymousOperationRule/* LoneAnonymousOperationRule */.F), + "LoneSchemaDefinitionRule": () => (/* reexport */ LoneSchemaDefinitionRule/* LoneSchemaDefinitionRule */.t), + "NoDeprecatedCustomRule": () => (/* reexport */ NoDeprecatedCustomRule), + "NoFragmentCyclesRule": () => (/* reexport */ NoFragmentCyclesRule/* NoFragmentCyclesRule */.H), + "NoSchemaIntrospectionCustomRule": () => (/* reexport */ NoSchemaIntrospectionCustomRule), + "NoUndefinedVariablesRule": () => (/* reexport */ NoUndefinedVariablesRule/* NoUndefinedVariablesRule */.$), + "NoUnusedFragmentsRule": () => (/* reexport */ NoUnusedFragmentsRule/* NoUnusedFragmentsRule */.J), + "NoUnusedVariablesRule": () => (/* reexport */ NoUnusedVariablesRule/* NoUnusedVariablesRule */.p), + "OperationTypeNode": () => (/* reexport */ ast/* OperationTypeNode */.ku), + "OverlappingFieldsCanBeMergedRule": () => (/* reexport */ OverlappingFieldsCanBeMergedRule/* OverlappingFieldsCanBeMergedRule */.y), + "PossibleFragmentSpreadsRule": () => (/* reexport */ PossibleFragmentSpreadsRule/* PossibleFragmentSpreadsRule */.a), + "PossibleTypeExtensionsRule": () => (/* reexport */ PossibleTypeExtensionsRule/* PossibleTypeExtensionsRule */.g), + "ProvidedRequiredArgumentsRule": () => (/* reexport */ ProvidedRequiredArgumentsRule/* ProvidedRequiredArgumentsRule */.s), + "ScalarLeafsRule": () => (/* reexport */ ScalarLeafsRule/* ScalarLeafsRule */.O), + "SchemaMetaFieldDef": () => (/* reexport */ type_introspection/* SchemaMetaFieldDef */.Az), + "SingleFieldSubscriptionsRule": () => (/* reexport */ SingleFieldSubscriptionsRule/* SingleFieldSubscriptionsRule */.Z), + "Source": () => (/* reexport */ language_source/* Source */.H), + "Token": () => (/* reexport */ ast/* Token */.WU), + "TokenKind": () => (/* reexport */ language_tokenKind/* TokenKind */.T), + "TypeInfo": () => (/* reexport */ TypeInfo/* TypeInfo */.a), + "TypeKind": () => (/* reexport */ type_introspection/* TypeKind */.zU), + "TypeMetaFieldDef": () => (/* reexport */ type_introspection/* TypeMetaFieldDef */.tF), + "TypeNameMetaFieldDef": () => (/* reexport */ type_introspection/* TypeNameMetaFieldDef */.hU), + "UniqueArgumentDefinitionNamesRule": () => (/* reexport */ UniqueArgumentDefinitionNamesRule/* UniqueArgumentDefinitionNamesRule */.L), + "UniqueArgumentNamesRule": () => (/* reexport */ UniqueArgumentNamesRule/* UniqueArgumentNamesRule */.L), + "UniqueDirectiveNamesRule": () => (/* reexport */ UniqueDirectiveNamesRule/* UniqueDirectiveNamesRule */.o), + "UniqueDirectivesPerLocationRule": () => (/* reexport */ UniqueDirectivesPerLocationRule/* UniqueDirectivesPerLocationRule */.k), + "UniqueEnumValueNamesRule": () => (/* reexport */ UniqueEnumValueNamesRule/* UniqueEnumValueNamesRule */.L), + "UniqueFieldDefinitionNamesRule": () => (/* reexport */ UniqueFieldDefinitionNamesRule/* UniqueFieldDefinitionNamesRule */.y), + "UniqueFragmentNamesRule": () => (/* reexport */ UniqueFragmentNamesRule/* UniqueFragmentNamesRule */.N), + "UniqueInputFieldNamesRule": () => (/* reexport */ UniqueInputFieldNamesRule/* UniqueInputFieldNamesRule */.P), + "UniqueOperationNamesRule": () => (/* reexport */ UniqueOperationNamesRule/* UniqueOperationNamesRule */.H), + "UniqueOperationTypesRule": () => (/* reexport */ UniqueOperationTypesRule/* UniqueOperationTypesRule */.q), + "UniqueTypeNamesRule": () => (/* reexport */ UniqueTypeNamesRule/* UniqueTypeNamesRule */.P), + "UniqueVariableNamesRule": () => (/* reexport */ UniqueVariableNamesRule/* UniqueVariableNamesRule */.H), + "ValidationContext": () => (/* reexport */ ValidationContext/* ValidationContext */._t), + "ValuesOfCorrectTypeRule": () => (/* reexport */ ValuesOfCorrectTypeRule/* ValuesOfCorrectTypeRule */.j), + "VariablesAreInputTypesRule": () => (/* reexport */ VariablesAreInputTypesRule/* VariablesAreInputTypesRule */.I), + "VariablesInAllowedPositionRule": () => (/* reexport */ VariablesInAllowedPositionRule/* VariablesInAllowedPositionRule */.w), + "__Directive": () => (/* reexport */ type_introspection/* __Directive */.l3), + "__DirectiveLocation": () => (/* reexport */ type_introspection/* __DirectiveLocation */.x2), + "__EnumValue": () => (/* reexport */ type_introspection/* __EnumValue */.jT), + "__Field": () => (/* reexport */ type_introspection/* __Field */.e_), + "__InputValue": () => (/* reexport */ type_introspection/* __InputValue */.XQ), + "__Schema": () => (/* reexport */ type_introspection/* __Schema */.TK), + "__Type": () => (/* reexport */ type_introspection/* __Type */.qz), + "__TypeKind": () => (/* reexport */ type_introspection/* __TypeKind */.PX), + "assertAbstractType": () => (/* reexport */ definition/* assertAbstractType */.fU), + "assertCompositeType": () => (/* reexport */ definition/* assertCompositeType */.M_), + "assertDirective": () => (/* reexport */ type_directives/* assertDirective */.CO), + "assertEnumType": () => (/* reexport */ definition/* assertEnumType */.Zu), + "assertEnumValueName": () => (/* reexport */ assertName/* assertEnumValueName */.g), + "assertInputObjectType": () => (/* reexport */ definition/* assertInputObjectType */.U8), + "assertInputType": () => (/* reexport */ definition/* assertInputType */.qT), + "assertInterfaceType": () => (/* reexport */ definition/* assertInterfaceType */.k2), + "assertLeafType": () => (/* reexport */ definition/* assertLeafType */.H5), + "assertListType": () => (/* reexport */ definition/* assertListType */.kS), + "assertName": () => (/* reexport */ assertName/* assertName */.i), + "assertNamedType": () => (/* reexport */ definition/* assertNamedType */.rM), + "assertNonNullType": () => (/* reexport */ definition/* assertNonNullType */.E$), + "assertNullableType": () => (/* reexport */ definition/* assertNullableType */.i_), + "assertObjectType": () => (/* reexport */ definition/* assertObjectType */.Z6), + "assertOutputType": () => (/* reexport */ definition/* assertOutputType */.Gt), + "assertScalarType": () => (/* reexport */ definition/* assertScalarType */.Pt), + "assertSchema": () => (/* reexport */ type_schema/* assertSchema */.EO), + "assertType": () => (/* reexport */ definition/* assertType */.p_), + "assertUnionType": () => (/* reexport */ definition/* assertUnionType */.rc), + "assertValidName": () => (/* reexport */ assertValidName), + "assertValidSchema": () => (/* reexport */ validate/* assertValidSchema */.J), + "assertWrappingType": () => (/* reexport */ definition/* assertWrappingType */.vX), + "astFromValue": () => (/* reexport */ astFromValue/* astFromValue */.J), + "buildASTSchema": () => (/* reexport */ buildASTSchema/* buildASTSchema */.M), + "buildClientSchema": () => (/* reexport */ buildClientSchema), + "buildSchema": () => (/* reexport */ buildASTSchema/* buildSchema */.I), + "coerceInputValue": () => (/* reexport */ coerceInputValue/* coerceInputValue */.K), + "concatAST": () => (/* reexport */ concatAST), + "createSourceEventStream": () => (/* reexport */ createSourceEventStream), + "defaultFieldResolver": () => (/* reexport */ execute/* defaultFieldResolver */.El), + "defaultTypeResolver": () => (/* reexport */ execute/* defaultTypeResolver */.mn), + "doTypesOverlap": () => (/* reexport */ typeComparators/* doTypesOverlap */.zR), + "execute": () => (/* reexport */ execute/* execute */.ht), + "executeSync": () => (/* reexport */ execute/* executeSync */.p0), + "extendSchema": () => (/* reexport */ extendSchema/* extendSchema */.a), + "findBreakingChanges": () => (/* reexport */ findBreakingChanges), + "findDangerousChanges": () => (/* reexport */ findDangerousChanges), + "formatError": () => (/* reexport */ GraphQLError/* formatError */.Z), + "getArgumentValues": () => (/* reexport */ values/* getArgumentValues */.LX), + "getDirectiveValues": () => (/* reexport */ values/* getDirectiveValues */.zu), + "getEnterLeaveForKind": () => (/* reexport */ visitor/* getEnterLeaveForKind */.Eu), + "getIntrospectionQuery": () => (/* reexport */ getIntrospectionQuery), + "getLocation": () => (/* reexport */ language_location/* getLocation */.k), + "getNamedType": () => (/* reexport */ definition/* getNamedType */.xC), + "getNullableType": () => (/* reexport */ definition/* getNullableType */.tf), + "getOperationAST": () => (/* reexport */ getOperationAST), + "getOperationRootType": () => (/* reexport */ getOperationRootType), + "getVariableValues": () => (/* reexport */ values/* getVariableValues */.QF), + "getVisitFn": () => (/* reexport */ visitor/* getVisitFn */.CK), + "graphql": () => (/* reexport */ graphql/* graphql */.B), + "graphqlSync": () => (/* reexport */ graphql/* graphqlSync */.V), + "introspectionFromSchema": () => (/* reexport */ introspectionFromSchema), + "introspectionTypes": () => (/* reexport */ type_introspection/* introspectionTypes */.nL), + "isAbstractType": () => (/* reexport */ definition/* isAbstractType */.m0), + "isCompositeType": () => (/* reexport */ definition/* isCompositeType */.Gv), + "isConstValueNode": () => (/* reexport */ predicates/* isConstValueNode */.Of), + "isDefinitionNode": () => (/* reexport */ predicates/* isDefinitionNode */.Ir), + "isDirective": () => (/* reexport */ type_directives/* isDirective */.wX), + "isEnumType": () => (/* reexport */ definition/* isEnumType */.EM), + "isEqualType": () => (/* reexport */ typeComparators/* isEqualType */._7), + "isExecutableDefinitionNode": () => (/* reexport */ predicates/* isExecutableDefinitionNode */.Wk), + "isInputObjectType": () => (/* reexport */ definition/* isInputObjectType */.hL), + "isInputType": () => (/* reexport */ definition/* isInputType */.j$), + "isInterfaceType": () => (/* reexport */ definition/* isInterfaceType */.oT), + "isIntrospectionType": () => (/* reexport */ type_introspection/* isIntrospectionType */.s9), + "isLeafType": () => (/* reexport */ definition/* isLeafType */.UT), + "isListType": () => (/* reexport */ definition/* isListType */.HG), + "isNamedType": () => (/* reexport */ definition/* isNamedType */.Zs), + "isNonNullType": () => (/* reexport */ definition/* isNonNullType */.zM), + "isNullableType": () => (/* reexport */ definition/* isNullableType */.zP), + "isObjectType": () => (/* reexport */ definition/* isObjectType */.lp), + "isOutputType": () => (/* reexport */ definition/* isOutputType */.SZ), + "isRequiredArgument": () => (/* reexport */ definition/* isRequiredArgument */.dK), + "isRequiredInputField": () => (/* reexport */ definition/* isRequiredInputField */.Wd), + "isScalarType": () => (/* reexport */ definition/* isScalarType */.KA), + "isSchema": () => (/* reexport */ type_schema/* isSchema */.nN), + "isSelectionNode": () => (/* reexport */ predicates/* isSelectionNode */.pO), + "isSpecifiedDirective": () => (/* reexport */ type_directives/* isSpecifiedDirective */.xg), + "isSpecifiedScalarType": () => (/* reexport */ scalars/* isSpecifiedScalarType */.u1), + "isType": () => (/* reexport */ definition/* isType */.P9), + "isTypeDefinitionNode": () => (/* reexport */ predicates/* isTypeDefinitionNode */.zT), + "isTypeExtensionNode": () => (/* reexport */ predicates/* isTypeExtensionNode */.D$), + "isTypeNode": () => (/* reexport */ predicates/* isTypeNode */.VB), + "isTypeSubTypeOf": () => (/* reexport */ typeComparators/* isTypeSubTypeOf */.uJ), + "isTypeSystemDefinitionNode": () => (/* reexport */ predicates/* isTypeSystemDefinitionNode */.G4), + "isTypeSystemExtensionNode": () => (/* reexport */ predicates/* isTypeSystemExtensionNode */.aU), + "isUnionType": () => (/* reexport */ definition/* isUnionType */.EN), + "isValidNameError": () => (/* reexport */ isValidNameError), + "isValueNode": () => (/* reexport */ predicates/* isValueNode */.nr), + "isWrappingType": () => (/* reexport */ definition/* isWrappingType */.fw), + "lexicographicSortSchema": () => (/* reexport */ lexicographicSortSchema), + "locatedError": () => (/* reexport */ locatedError/* locatedError */.y), + "parse": () => (/* reexport */ parser/* parse */.Qc), + "parseConstValue": () => (/* reexport */ parser/* parseConstValue */.tl), + "parseType": () => (/* reexport */ parser/* parseType */.gZ), + "parseValue": () => (/* reexport */ parser/* parseValue */.H2), + "print": () => (/* reexport */ printer/* print */.S), + "printError": () => (/* reexport */ GraphQLError/* printError */.OS), + "printIntrospectionSchema": () => (/* reexport */ printIntrospectionSchema), + "printLocation": () => (/* reexport */ printLocation/* printLocation */.Q), + "printSchema": () => (/* reexport */ printSchema), + "printSourceLocation": () => (/* reexport */ printLocation/* printSourceLocation */.z), + "printType": () => (/* reexport */ printType), + "resolveObjMapThunk": () => (/* reexport */ definition/* resolveObjMapThunk */.WB), + "resolveReadonlyArrayThunk": () => (/* reexport */ definition/* resolveReadonlyArrayThunk */._9), + "responsePathAsArray": () => (/* reexport */ Path/* pathToArray */.N), + "separateOperations": () => (/* reexport */ separateOperations), + "specifiedDirectives": () => (/* reexport */ type_directives/* specifiedDirectives */.V4), + "specifiedRules": () => (/* reexport */ specifiedRules/* specifiedRules */.i), + "specifiedScalarTypes": () => (/* reexport */ scalars/* specifiedScalarTypes */.HS), + "stripIgnoredCharacters": () => (/* reexport */ stripIgnoredCharacters), + "subscribe": () => (/* reexport */ subscribe), + "syntaxError": () => (/* reexport */ syntaxError/* syntaxError */.h), + "typeFromAST": () => (/* reexport */ typeFromAST/* typeFromAST */._), + "validate": () => (/* reexport */ validation_validate/* validate */.Gu), + "validateSchema": () => (/* reexport */ validate/* validateSchema */.F), + "valueFromAST": () => (/* reexport */ valueFromAST/* valueFromAST */.u), + "valueFromASTUntyped": () => (/* reexport */ valueFromASTUntyped/* valueFromASTUntyped */.M), + "version": () => (/* reexport */ version), + "versionInfo": () => (/* reexport */ versionInfo), + "visit": () => (/* reexport */ visitor/* visit */.Vn), + "visitInParallel": () => (/* reexport */ visitor/* visitInParallel */.j1), + "visitWithTypeInfo": () => (/* reexport */ TypeInfo/* visitWithTypeInfo */.y) +}); + +;// CONCATENATED MODULE: ./node_modules/graphql/version.mjs +// Note: This file is autogenerated using "resources/gen-version.js" script and +// automatically updated by "npm version" command. + +/** + * A string containing the version of the GraphQL.js library + */ +const version = '16.6.0'; +/** + * An object containing the components of the GraphQL.js version string + */ + +const versionInfo = Object.freeze({ + major: 16, + minor: 6, + patch: 0, + preReleaseTag: null, +}); + +// EXTERNAL MODULE: ./node_modules/graphql/graphql.mjs +var graphql = __webpack_require__(2244); +// EXTERNAL MODULE: ./node_modules/graphql/type/definition.mjs + 1 modules +var definition = __webpack_require__(398); +// EXTERNAL MODULE: ./node_modules/graphql/type/schema.mjs +var type_schema = __webpack_require__(9678); +// EXTERNAL MODULE: ./node_modules/graphql/type/directives.mjs +var type_directives = __webpack_require__(8238); +// EXTERNAL MODULE: ./node_modules/graphql/type/scalars.mjs +var scalars = __webpack_require__(3801); +// EXTERNAL MODULE: ./node_modules/graphql/type/introspection.mjs +var type_introspection = __webpack_require__(2433); +// EXTERNAL MODULE: ./node_modules/graphql/type/validate.mjs +var validate = __webpack_require__(9655); +// EXTERNAL MODULE: ./node_modules/graphql/type/assertName.mjs +var assertName = __webpack_require__(6303); +// EXTERNAL MODULE: ./node_modules/graphql/language/ast.mjs +var ast = __webpack_require__(2380); +// EXTERNAL MODULE: ./node_modules/graphql/language/source.mjs +var language_source = __webpack_require__(7926); +// EXTERNAL MODULE: ./node_modules/graphql/language/location.mjs +var language_location = __webpack_require__(7867); +// EXTERNAL MODULE: ./node_modules/graphql/language/printLocation.mjs +var printLocation = __webpack_require__(850); +// EXTERNAL MODULE: ./node_modules/graphql/language/lexer.mjs +var language_lexer = __webpack_require__(2105); +// EXTERNAL MODULE: ./node_modules/graphql/language/tokenKind.mjs +var language_tokenKind = __webpack_require__(4635); +// EXTERNAL MODULE: ./node_modules/graphql/language/parser.mjs +var parser = __webpack_require__(4275); +// EXTERNAL MODULE: ./node_modules/graphql/language/printer.mjs + 1 modules +var printer = __webpack_require__(3486); +// EXTERNAL MODULE: ./node_modules/graphql/language/visitor.mjs +var visitor = __webpack_require__(7304); +// EXTERNAL MODULE: ./node_modules/graphql/language/kinds.mjs +var kinds = __webpack_require__(7359); +// EXTERNAL MODULE: ./node_modules/graphql/language/directiveLocation.mjs +var directiveLocation = __webpack_require__(9878); +// EXTERNAL MODULE: ./node_modules/graphql/language/predicates.mjs +var predicates = __webpack_require__(5844); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/devAssert.mjs +var devAssert = __webpack_require__(7826); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/inspect.mjs +var inspect = __webpack_require__(5821); +;// CONCATENATED MODULE: ./node_modules/graphql/jsutils/isAsyncIterable.mjs +/** + * Returns true if the provided object implements the AsyncIterator protocol via + * implementing a `Symbol.asyncIterator` method. + */ +function isAsyncIterable(maybeAsyncIterable) { + return ( + typeof (maybeAsyncIterable === null || maybeAsyncIterable === void 0 + ? void 0 + : maybeAsyncIterable[Symbol.asyncIterator]) === 'function' + ); +} + +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/Path.mjs +var Path = __webpack_require__(9380); +// EXTERNAL MODULE: ./node_modules/graphql/error/GraphQLError.mjs +var GraphQLError = __webpack_require__(8087); +// EXTERNAL MODULE: ./node_modules/graphql/error/locatedError.mjs + 1 modules +var locatedError = __webpack_require__(4181); +// EXTERNAL MODULE: ./node_modules/graphql/execution/collectFields.mjs +var collectFields = __webpack_require__(7677); +// EXTERNAL MODULE: ./node_modules/graphql/execution/execute.mjs + 3 modules +var execute = __webpack_require__(5329); +;// CONCATENATED MODULE: ./node_modules/graphql/execution/mapAsyncIterator.mjs +/** + * Given an AsyncIterable and a callback function, return an AsyncIterator + * which produces values mapped via calling the callback function. + */ +function mapAsyncIterator(iterable, callback) { + const iterator = iterable[Symbol.asyncIterator](); + + async function mapResult(result) { + if (result.done) { + return result; + } + + try { + return { + value: await callback(result.value), + done: false, + }; + } catch (error) { + /* c8 ignore start */ + // FIXME: add test case + if (typeof iterator.return === 'function') { + try { + await iterator.return(); + } catch (_e) { + /* ignore error */ + } + } + + throw error; + /* c8 ignore stop */ + } + } + + return { + async next() { + return mapResult(await iterator.next()); + }, + + async return() { + // If iterator.return() does not exist, then type R must be undefined. + return typeof iterator.return === 'function' + ? mapResult(await iterator.return()) + : { + value: undefined, + done: true, + }; + }, + + async throw(error) { + if (typeof iterator.throw === 'function') { + return mapResult(await iterator.throw(error)); + } + + throw error; + }, + + [Symbol.asyncIterator]() { + return this; + }, + }; +} + +// EXTERNAL MODULE: ./node_modules/graphql/execution/values.mjs +var values = __webpack_require__(6422); +;// CONCATENATED MODULE: ./node_modules/graphql/execution/subscribe.mjs + + + + + + + + + + +/** + * Implements the "Subscribe" algorithm described in the GraphQL specification. + * + * Returns a Promise which resolves to either an AsyncIterator (if successful) + * or an ExecutionResult (error). The promise will be rejected if the schema or + * other arguments to this function are invalid, or if the resolved event stream + * is not an async iterable. + * + * If the client-provided arguments to this function do not result in a + * compliant subscription, a GraphQL Response (ExecutionResult) with + * descriptive errors and no data will be returned. + * + * If the source stream could not be created due to faulty subscription + * resolver logic or underlying systems, the promise will resolve to a single + * ExecutionResult containing `errors` and no `data`. + * + * If the operation succeeded, the promise resolves to an AsyncIterator, which + * yields a stream of ExecutionResults representing the response stream. + * + * Accepts either an object with named arguments, or individual arguments. + */ + +async function subscribe(args) { + // Temporary for v15 to v16 migration. Remove in v17 + arguments.length < 2 || + (0,devAssert/* devAssert */.a)( + false, + 'graphql@16 dropped long-deprecated support for positional arguments, please pass an object instead.', + ); + const resultOrStream = await createSourceEventStream(args); + + if (!isAsyncIterable(resultOrStream)) { + return resultOrStream; + } // For each payload yielded from a subscription, map it over the normal + // GraphQL `execute` function, with `payload` as the rootValue. + // This implements the "MapSourceToResponseEvent" algorithm described in + // the GraphQL specification. The `execute` function provides the + // "ExecuteSubscriptionEvent" algorithm, as it is nearly identical to the + // "ExecuteQuery" algorithm, for which `execute` is also used. + + const mapSourceToResponse = (payload) => + (0,execute/* execute */.ht)({ ...args, rootValue: payload }); // Map every source value to a ExecutionResult value as described above. + + return mapAsyncIterator(resultOrStream, mapSourceToResponse); +} + +function toNormalizedArgs(args) { + const firstArg = args[0]; + + if (firstArg && 'document' in firstArg) { + return firstArg; + } + + return { + schema: firstArg, + // FIXME: when underlying TS bug fixed, see https://github.com/microsoft/TypeScript/issues/31613 + document: args[1], + rootValue: args[2], + contextValue: args[3], + variableValues: args[4], + operationName: args[5], + subscribeFieldResolver: args[6], + }; +} +/** + * Implements the "CreateSourceEventStream" algorithm described in the + * GraphQL specification, resolving the subscription source event stream. + * + * Returns a Promise which resolves to either an AsyncIterable (if successful) + * or an ExecutionResult (error). The promise will be rejected if the schema or + * other arguments to this function are invalid, or if the resolved event stream + * is not an async iterable. + * + * If the client-provided arguments to this function do not result in a + * compliant subscription, a GraphQL Response (ExecutionResult) with + * descriptive errors and no data will be returned. + * + * If the the source stream could not be created due to faulty subscription + * resolver logic or underlying systems, the promise will resolve to a single + * ExecutionResult containing `errors` and no `data`. + * + * If the operation succeeded, the promise resolves to the AsyncIterable for the + * event stream returned by the resolver. + * + * A Source Event Stream represents a sequence of events, each of which triggers + * a GraphQL execution for that event. + * + * This may be useful when hosting the stateful subscription service in a + * different process or machine than the stateless GraphQL execution engine, + * or otherwise separating these two steps. For more on this, see the + * "Supporting Subscriptions at Scale" information in the GraphQL specification. + */ + +async function createSourceEventStream(...rawArgs) { + const args = toNormalizedArgs(rawArgs); + const { schema, document, variableValues } = args; // If arguments are missing or incorrectly typed, this is an internal + // developer mistake which should throw an early error. + + (0,execute/* assertValidExecutionArguments */.td)(schema, document, variableValues); // If a valid execution context cannot be created due to incorrect arguments, + // a "Response" with only errors is returned. + + const exeContext = (0,execute/* buildExecutionContext */.VZ)(args); // Return early errors if execution context failed. + + if (!('schema' in exeContext)) { + return { + errors: exeContext, + }; + } + + try { + const eventStream = await executeSubscription(exeContext); // Assert field returned an event stream, otherwise yield an error. + + if (!isAsyncIterable(eventStream)) { + throw new Error( + 'Subscription field must return Async Iterable. ' + + `Received: ${(0,inspect/* inspect */.X)(eventStream)}.`, + ); + } + + return eventStream; + } catch (error) { + // If it GraphQLError, report it as an ExecutionResult, containing only errors and no data. + // Otherwise treat the error as a system-class error and re-throw it. + if (error instanceof GraphQLError/* GraphQLError */.__) { + return { + errors: [error], + }; + } + + throw error; + } +} + +async function executeSubscription(exeContext) { + const { schema, fragments, operation, variableValues, rootValue } = + exeContext; + const rootType = schema.getSubscriptionType(); + + if (rootType == null) { + throw new GraphQLError/* GraphQLError */.__( + 'Schema is not configured to execute subscription operation.', + { + nodes: operation, + }, + ); + } + + const rootFields = (0,collectFields/* collectFields */.g)( + schema, + fragments, + variableValues, + rootType, + operation.selectionSet, + ); + const [responseName, fieldNodes] = [...rootFields.entries()][0]; + const fieldDef = (0,execute/* getFieldDef */.Vm)(schema, rootType, fieldNodes[0]); + + if (!fieldDef) { + const fieldName = fieldNodes[0].name.value; + throw new GraphQLError/* GraphQLError */.__( + `The subscription field "${fieldName}" is not defined.`, + { + nodes: fieldNodes, + }, + ); + } + + const path = (0,Path/* addPath */.Q)(undefined, responseName, rootType.name); + const info = (0,execute/* buildResolveInfo */.p$)( + exeContext, + fieldDef, + fieldNodes, + rootType, + path, + ); + + try { + var _fieldDef$subscribe; + + // Implements the "ResolveFieldEventStream" algorithm from GraphQL specification. + // It differs from "ResolveFieldValue" due to providing a different `resolveFn`. + // Build a JS object of arguments from the field.arguments AST, using the + // variables scope to fulfill any variable references. + const args = (0,values/* getArgumentValues */.LX)(fieldDef, fieldNodes[0], variableValues); // The resolve function's optional third argument is a context value that + // is provided to every resolve function within an execution. It is commonly + // used to represent an authenticated user, or request-specific caches. + + const contextValue = exeContext.contextValue; // Call the `subscribe()` resolver or the default resolver to produce an + // AsyncIterable yielding raw payloads. + + const resolveFn = + (_fieldDef$subscribe = fieldDef.subscribe) !== null && + _fieldDef$subscribe !== void 0 + ? _fieldDef$subscribe + : exeContext.subscribeFieldResolver; + const eventStream = await resolveFn(rootValue, args, contextValue, info); + + if (eventStream instanceof Error) { + throw eventStream; + } + + return eventStream; + } catch (error) { + throw (0,locatedError/* locatedError */.y)(error, fieldNodes, (0,Path/* pathToArray */.N)(path)); + } +} + +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/invariant.mjs +var invariant = __webpack_require__(9551); +;// CONCATENATED MODULE: ./node_modules/graphql/validation/rules/custom/NoDeprecatedCustomRule.mjs + + + + +/** + * No deprecated + * + * A GraphQL document is only valid if all selected fields and all used enum values have not been + * deprecated. + * + * Note: This rule is optional and is not part of the Validation section of the GraphQL + * Specification. The main purpose of this rule is detection of deprecated usages and not + * necessarily to forbid their use when querying a service. + */ +function NoDeprecatedCustomRule(context) { + return { + Field(node) { + const fieldDef = context.getFieldDef(); + const deprecationReason = + fieldDef === null || fieldDef === void 0 + ? void 0 + : fieldDef.deprecationReason; + + if (fieldDef && deprecationReason != null) { + const parentType = context.getParentType(); + parentType != null || (0,invariant/* invariant */.k)(false); + context.reportError( + new GraphQLError/* GraphQLError */.__( + `The field ${parentType.name}.${fieldDef.name} is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + }, + + Argument(node) { + const argDef = context.getArgument(); + const deprecationReason = + argDef === null || argDef === void 0 + ? void 0 + : argDef.deprecationReason; + + if (argDef && deprecationReason != null) { + const directiveDef = context.getDirective(); + + if (directiveDef != null) { + context.reportError( + new GraphQLError/* GraphQLError */.__( + `Directive "@${directiveDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } else { + const parentType = context.getParentType(); + const fieldDef = context.getFieldDef(); + (parentType != null && fieldDef != null) || (0,invariant/* invariant */.k)(false); + context.reportError( + new GraphQLError/* GraphQLError */.__( + `Field "${parentType.name}.${fieldDef.name}" argument "${argDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + } + }, + + ObjectField(node) { + const inputObjectDef = (0,definition/* getNamedType */.xC)(context.getParentInputType()); + + if ((0,definition/* isInputObjectType */.hL)(inputObjectDef)) { + const inputFieldDef = inputObjectDef.getFields()[node.name.value]; + const deprecationReason = + inputFieldDef === null || inputFieldDef === void 0 + ? void 0 + : inputFieldDef.deprecationReason; + + if (deprecationReason != null) { + context.reportError( + new GraphQLError/* GraphQLError */.__( + `The input field ${inputObjectDef.name}.${inputFieldDef.name} is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + } + }, + + EnumValue(node) { + const enumValueDef = context.getEnumValue(); + const deprecationReason = + enumValueDef === null || enumValueDef === void 0 + ? void 0 + : enumValueDef.deprecationReason; + + if (enumValueDef && deprecationReason != null) { + const enumTypeDef = (0,definition/* getNamedType */.xC)(context.getInputType()); + enumTypeDef != null || (0,invariant/* invariant */.k)(false); + context.reportError( + new GraphQLError/* GraphQLError */.__( + `The enum value "${enumTypeDef.name}.${enumValueDef.name}" is deprecated. ${deprecationReason}`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +;// CONCATENATED MODULE: ./node_modules/graphql/validation/rules/custom/NoSchemaIntrospectionCustomRule.mjs + + + + +/** + * Prohibit introspection queries + * + * A GraphQL document is only valid if all fields selected are not fields that + * return an introspection type. + * + * Note: This rule is optional and is not part of the Validation section of the + * GraphQL Specification. This rule effectively disables introspection, which + * does not reflect best practices and should only be done if absolutely necessary. + */ +function NoSchemaIntrospectionCustomRule(context) { + return { + Field(node) { + const type = (0,definition/* getNamedType */.xC)(context.getType()); + + if (type && (0,type_introspection/* isIntrospectionType */.s9)(type)) { + context.reportError( + new GraphQLError/* GraphQLError */.__( + `GraphQL introspection has been disabled, but the requested query contained the field "${node.name.value}".`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +// EXTERNAL MODULE: ./node_modules/graphql/validation/validate.mjs +var validation_validate = __webpack_require__(6584); +// EXTERNAL MODULE: ./node_modules/graphql/validation/ValidationContext.mjs +var ValidationContext = __webpack_require__(2734); +// EXTERNAL MODULE: ./node_modules/graphql/validation/specifiedRules.mjs +var specifiedRules = __webpack_require__(4196); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/ExecutableDefinitionsRule.mjs +var ExecutableDefinitionsRule = __webpack_require__(8081); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/FieldsOnCorrectTypeRule.mjs +var FieldsOnCorrectTypeRule = __webpack_require__(8741); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/FragmentsOnCompositeTypesRule.mjs +var FragmentsOnCompositeTypesRule = __webpack_require__(7143); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/KnownArgumentNamesRule.mjs +var KnownArgumentNamesRule = __webpack_require__(7815); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/KnownDirectivesRule.mjs +var KnownDirectivesRule = __webpack_require__(4873); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/KnownFragmentNamesRule.mjs +var KnownFragmentNamesRule = __webpack_require__(5311); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/KnownTypeNamesRule.mjs +var KnownTypeNamesRule = __webpack_require__(5580); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/LoneAnonymousOperationRule.mjs +var LoneAnonymousOperationRule = __webpack_require__(7898); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/NoFragmentCyclesRule.mjs +var NoFragmentCyclesRule = __webpack_require__(1422); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/NoUndefinedVariablesRule.mjs +var NoUndefinedVariablesRule = __webpack_require__(4790); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/NoUnusedFragmentsRule.mjs +var NoUnusedFragmentsRule = __webpack_require__(1294); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/NoUnusedVariablesRule.mjs +var NoUnusedVariablesRule = __webpack_require__(2283); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/OverlappingFieldsCanBeMergedRule.mjs +var OverlappingFieldsCanBeMergedRule = __webpack_require__(4203); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/PossibleFragmentSpreadsRule.mjs +var PossibleFragmentSpreadsRule = __webpack_require__(3259); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/ProvidedRequiredArgumentsRule.mjs +var ProvidedRequiredArgumentsRule = __webpack_require__(1967); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/ScalarLeafsRule.mjs +var ScalarLeafsRule = __webpack_require__(1954); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/SingleFieldSubscriptionsRule.mjs +var SingleFieldSubscriptionsRule = __webpack_require__(423); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueArgumentNamesRule.mjs +var UniqueArgumentNamesRule = __webpack_require__(2266); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueDirectivesPerLocationRule.mjs +var UniqueDirectivesPerLocationRule = __webpack_require__(6300); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueFragmentNamesRule.mjs +var UniqueFragmentNamesRule = __webpack_require__(5591); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueInputFieldNamesRule.mjs +var UniqueInputFieldNamesRule = __webpack_require__(2767); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueOperationNamesRule.mjs +var UniqueOperationNamesRule = __webpack_require__(2621); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueVariableNamesRule.mjs +var UniqueVariableNamesRule = __webpack_require__(1564); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/ValuesOfCorrectTypeRule.mjs +var ValuesOfCorrectTypeRule = __webpack_require__(9831); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/VariablesAreInputTypesRule.mjs +var VariablesAreInputTypesRule = __webpack_require__(5972); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/VariablesInAllowedPositionRule.mjs +var VariablesInAllowedPositionRule = __webpack_require__(9701); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/LoneSchemaDefinitionRule.mjs +var LoneSchemaDefinitionRule = __webpack_require__(2877); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueOperationTypesRule.mjs +var UniqueOperationTypesRule = __webpack_require__(7990); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueTypeNamesRule.mjs +var UniqueTypeNamesRule = __webpack_require__(9538); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueEnumValueNamesRule.mjs +var UniqueEnumValueNamesRule = __webpack_require__(3201); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueFieldDefinitionNamesRule.mjs +var UniqueFieldDefinitionNamesRule = __webpack_require__(2618); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueArgumentDefinitionNamesRule.mjs +var UniqueArgumentDefinitionNamesRule = __webpack_require__(2337); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/UniqueDirectiveNamesRule.mjs +var UniqueDirectiveNamesRule = __webpack_require__(3274); +// EXTERNAL MODULE: ./node_modules/graphql/validation/rules/PossibleTypeExtensionsRule.mjs +var PossibleTypeExtensionsRule = __webpack_require__(4800); +// EXTERNAL MODULE: ./node_modules/graphql/error/syntaxError.mjs +var syntaxError = __webpack_require__(5219); +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/getIntrospectionQuery.mjs +/** + * Produce the GraphQL query recommended for a full schema introspection. + * Accepts optional IntrospectionOptions. + */ +function getIntrospectionQuery(options) { + const optionsWithDefault = { + descriptions: true, + specifiedByUrl: false, + directiveIsRepeatable: false, + schemaDescription: false, + inputValueDeprecation: false, + ...options, + }; + const descriptions = optionsWithDefault.descriptions ? 'description' : ''; + const specifiedByUrl = optionsWithDefault.specifiedByUrl + ? 'specifiedByURL' + : ''; + const directiveIsRepeatable = optionsWithDefault.directiveIsRepeatable + ? 'isRepeatable' + : ''; + const schemaDescription = optionsWithDefault.schemaDescription + ? descriptions + : ''; + + function inputDeprecation(str) { + return optionsWithDefault.inputValueDeprecation ? str : ''; + } + + return ` + query IntrospectionQuery { + __schema { + ${schemaDescription} + queryType { name } + mutationType { name } + subscriptionType { name } + types { + ...FullType + } + directives { + name + ${descriptions} + ${directiveIsRepeatable} + locations + args${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + } + } + } + + fragment FullType on __Type { + kind + name + ${descriptions} + ${specifiedByUrl} + fields(includeDeprecated: true) { + name + ${descriptions} + args${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + type { + ...TypeRef + } + isDeprecated + deprecationReason + } + inputFields${inputDeprecation('(includeDeprecated: true)')} { + ...InputValue + } + interfaces { + ...TypeRef + } + enumValues(includeDeprecated: true) { + name + ${descriptions} + isDeprecated + deprecationReason + } + possibleTypes { + ...TypeRef + } + } + + fragment InputValue on __InputValue { + name + ${descriptions} + type { ...TypeRef } + defaultValue + ${inputDeprecation('isDeprecated')} + ${inputDeprecation('deprecationReason')} + } + + fragment TypeRef on __Type { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + ofType { + kind + name + } + } + } + } + } + } + } + } + `; +} + +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/getOperationAST.mjs + +/** + * Returns an operation AST given a document AST and optionally an operation + * name. If a name is not provided, an operation is only returned if only one is + * provided in the document. + */ + +function getOperationAST(documentAST, operationName) { + let operation = null; + + for (const definition of documentAST.definitions) { + if (definition.kind === kinds/* Kind.OPERATION_DEFINITION */.h.OPERATION_DEFINITION) { + var _definition$name; + + if (operationName == null) { + // If no operation name was provided, only return an Operation if there + // is one defined in the document. Upon encountering the second, return + // null. + if (operation) { + return null; + } + + operation = definition; + } else if ( + ((_definition$name = definition.name) === null || + _definition$name === void 0 + ? void 0 + : _definition$name.value) === operationName + ) { + return definition; + } + } + } + + return operation; +} + +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/getOperationRootType.mjs + + +/** + * Extracts the root type of the operation from the schema. + * + * @deprecated Please use `GraphQLSchema.getRootType` instead. Will be removed in v17 + */ +function getOperationRootType(schema, operation) { + if (operation.operation === 'query') { + const queryType = schema.getQueryType(); + + if (!queryType) { + throw new GraphQLError/* GraphQLError */.__( + 'Schema does not define the required query root type.', + { + nodes: operation, + }, + ); + } + + return queryType; + } + + if (operation.operation === 'mutation') { + const mutationType = schema.getMutationType(); + + if (!mutationType) { + throw new GraphQLError/* GraphQLError */.__('Schema is not configured for mutations.', { + nodes: operation, + }); + } + + return mutationType; + } + + if (operation.operation === 'subscription') { + const subscriptionType = schema.getSubscriptionType(); + + if (!subscriptionType) { + throw new GraphQLError/* GraphQLError */.__('Schema is not configured for subscriptions.', { + nodes: operation, + }); + } + + return subscriptionType; + } + + throw new GraphQLError/* GraphQLError */.__( + 'Can only have query, mutation and subscription operations.', + { + nodes: operation, + }, + ); +} + +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/introspectionFromSchema.mjs + + + + +/** + * Build an IntrospectionQuery from a GraphQLSchema + * + * IntrospectionQuery is useful for utilities that care about type and field + * relationships, but do not need to traverse through those relationships. + * + * This is the inverse of buildClientSchema. The primary use case is outside + * of the server context, for instance when doing schema comparisons. + */ + +function introspectionFromSchema(schema, options) { + const optionsWithDefaults = { + specifiedByUrl: true, + directiveIsRepeatable: true, + schemaDescription: true, + inputValueDeprecation: true, + ...options, + }; + const document = (0,parser/* parse */.Qc)(getIntrospectionQuery(optionsWithDefaults)); + const result = (0,execute/* executeSync */.p0)({ + schema, + document, + }); + (!result.errors && result.data) || (0,invariant/* invariant */.k)(false); + return result.data; +} + +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/isObjectLike.mjs +var isObjectLike = __webpack_require__(8495); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/keyValMap.mjs +var keyValMap = __webpack_require__(4950); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/valueFromAST.mjs +var valueFromAST = __webpack_require__(2221); +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/buildClientSchema.mjs + + + + + + + + + + + +/** + * Build a GraphQLSchema for use by client tools. + * + * Given the result of a client running the introspection query, creates and + * returns a GraphQLSchema instance which can be then used with all graphql-js + * tools, but cannot be used to execute a query, as introspection does not + * represent the "resolver", "parse" or "serialize" functions or any other + * server-internal mechanisms. + * + * This function expects a complete introspection result. Don't forget to check + * the "errors" field of a server response before calling this function. + */ + +function buildClientSchema(introspection, options) { + ((0,isObjectLike/* isObjectLike */.y)(introspection) && (0,isObjectLike/* isObjectLike */.y)(introspection.__schema)) || + (0,devAssert/* devAssert */.a)( + false, + `Invalid or incomplete introspection result. Ensure that you are passing "data" property of introspection response and no "errors" was returned alongside: ${(0,inspect/* inspect */.X)( + introspection, + )}.`, + ); // Get the schema from the introspection result. + + const schemaIntrospection = introspection.__schema; // Iterate through all types, getting the type definition for each. + + const typeMap = (0,keyValMap/* keyValMap */.w)( + schemaIntrospection.types, + (typeIntrospection) => typeIntrospection.name, + (typeIntrospection) => buildType(typeIntrospection), + ); // Include standard types only if they are used. + + for (const stdType of [...scalars/* specifiedScalarTypes */.HS, ...type_introspection/* introspectionTypes */.nL]) { + if (typeMap[stdType.name]) { + typeMap[stdType.name] = stdType; + } + } // Get the root Query, Mutation, and Subscription types. + + const queryType = schemaIntrospection.queryType + ? getObjectType(schemaIntrospection.queryType) + : null; + const mutationType = schemaIntrospection.mutationType + ? getObjectType(schemaIntrospection.mutationType) + : null; + const subscriptionType = schemaIntrospection.subscriptionType + ? getObjectType(schemaIntrospection.subscriptionType) + : null; // Get the directives supported by Introspection, assuming empty-set if + // directives were not queried for. + + const directives = schemaIntrospection.directives + ? schemaIntrospection.directives.map(buildDirective) + : []; // Then produce and return a Schema with these types. + + return new type_schema/* GraphQLSchema */.XO({ + description: schemaIntrospection.description, + query: queryType, + mutation: mutationType, + subscription: subscriptionType, + types: Object.values(typeMap), + directives, + assumeValid: + options === null || options === void 0 ? void 0 : options.assumeValid, + }); // Given a type reference in introspection, return the GraphQLType instance. + // preferring cached instances before building new instances. + + function getType(typeRef) { + if (typeRef.kind === type_introspection/* TypeKind.LIST */.zU.LIST) { + const itemRef = typeRef.ofType; + + if (!itemRef) { + throw new Error('Decorated type deeper than introspection query.'); + } + + return new definition/* GraphQLList */.p2(getType(itemRef)); + } + + if (typeRef.kind === type_introspection/* TypeKind.NON_NULL */.zU.NON_NULL) { + const nullableRef = typeRef.ofType; + + if (!nullableRef) { + throw new Error('Decorated type deeper than introspection query.'); + } + + const nullableType = getType(nullableRef); + return new definition/* GraphQLNonNull */.bM((0,definition/* assertNullableType */.i_)(nullableType)); + } + + return getNamedType(typeRef); + } + + function getNamedType(typeRef) { + const typeName = typeRef.name; + + if (!typeName) { + throw new Error(`Unknown type reference: ${(0,inspect/* inspect */.X)(typeRef)}.`); + } + + const type = typeMap[typeName]; + + if (!type) { + throw new Error( + `Invalid or incomplete schema, unknown type: ${typeName}. Ensure that a full introspection query is used in order to build a client schema.`, + ); + } + + return type; + } + + function getObjectType(typeRef) { + return (0,definition/* assertObjectType */.Z6)(getNamedType(typeRef)); + } + + function getInterfaceType(typeRef) { + return (0,definition/* assertInterfaceType */.k2)(getNamedType(typeRef)); + } // Given a type's introspection result, construct the correct + // GraphQLType instance. + + function buildType(type) { + // eslint-disable-next-line @typescript-eslint/prefer-optional-chain + if (type != null && type.name != null && type.kind != null) { + // FIXME: Properly type IntrospectionType, it's a breaking change so fix in v17 + // eslint-disable-next-line @typescript-eslint/switch-exhaustiveness-check + switch (type.kind) { + case type_introspection/* TypeKind.SCALAR */.zU.SCALAR: + return buildScalarDef(type); + + case type_introspection/* TypeKind.OBJECT */.zU.OBJECT: + return buildObjectDef(type); + + case type_introspection/* TypeKind.INTERFACE */.zU.INTERFACE: + return buildInterfaceDef(type); + + case type_introspection/* TypeKind.UNION */.zU.UNION: + return buildUnionDef(type); + + case type_introspection/* TypeKind.ENUM */.zU.ENUM: + return buildEnumDef(type); + + case type_introspection/* TypeKind.INPUT_OBJECT */.zU.INPUT_OBJECT: + return buildInputObjectDef(type); + } + } + + const typeStr = (0,inspect/* inspect */.X)(type); + throw new Error( + `Invalid or incomplete introspection result. Ensure that a full introspection query is used in order to build a client schema: ${typeStr}.`, + ); + } + + function buildScalarDef(scalarIntrospection) { + return new definition/* GraphQLScalarType */.n2({ + name: scalarIntrospection.name, + description: scalarIntrospection.description, + specifiedByURL: scalarIntrospection.specifiedByURL, + }); + } + + function buildImplementationsList(implementingIntrospection) { + // TODO: Temporary workaround until GraphQL ecosystem will fully support + // 'interfaces' on interface types. + if ( + implementingIntrospection.interfaces === null && + implementingIntrospection.kind === type_introspection/* TypeKind.INTERFACE */.zU.INTERFACE + ) { + return []; + } + + if (!implementingIntrospection.interfaces) { + const implementingIntrospectionStr = (0,inspect/* inspect */.X)(implementingIntrospection); + throw new Error( + `Introspection result missing interfaces: ${implementingIntrospectionStr}.`, + ); + } + + return implementingIntrospection.interfaces.map(getInterfaceType); + } + + function buildObjectDef(objectIntrospection) { + return new definition/* GraphQLObjectType */.h6({ + name: objectIntrospection.name, + description: objectIntrospection.description, + interfaces: () => buildImplementationsList(objectIntrospection), + fields: () => buildFieldDefMap(objectIntrospection), + }); + } + + function buildInterfaceDef(interfaceIntrospection) { + return new definition/* GraphQLInterfaceType */.oW({ + name: interfaceIntrospection.name, + description: interfaceIntrospection.description, + interfaces: () => buildImplementationsList(interfaceIntrospection), + fields: () => buildFieldDefMap(interfaceIntrospection), + }); + } + + function buildUnionDef(unionIntrospection) { + if (!unionIntrospection.possibleTypes) { + const unionIntrospectionStr = (0,inspect/* inspect */.X)(unionIntrospection); + throw new Error( + `Introspection result missing possibleTypes: ${unionIntrospectionStr}.`, + ); + } + + return new definition/* GraphQLUnionType */.Gp({ + name: unionIntrospection.name, + description: unionIntrospection.description, + types: () => unionIntrospection.possibleTypes.map(getObjectType), + }); + } + + function buildEnumDef(enumIntrospection) { + if (!enumIntrospection.enumValues) { + const enumIntrospectionStr = (0,inspect/* inspect */.X)(enumIntrospection); + throw new Error( + `Introspection result missing enumValues: ${enumIntrospectionStr}.`, + ); + } + + return new definition/* GraphQLEnumType */.mR({ + name: enumIntrospection.name, + description: enumIntrospection.description, + values: (0,keyValMap/* keyValMap */.w)( + enumIntrospection.enumValues, + (valueIntrospection) => valueIntrospection.name, + (valueIntrospection) => ({ + description: valueIntrospection.description, + deprecationReason: valueIntrospection.deprecationReason, + }), + ), + }); + } + + function buildInputObjectDef(inputObjectIntrospection) { + if (!inputObjectIntrospection.inputFields) { + const inputObjectIntrospectionStr = (0,inspect/* inspect */.X)(inputObjectIntrospection); + throw new Error( + `Introspection result missing inputFields: ${inputObjectIntrospectionStr}.`, + ); + } + + return new definition/* GraphQLInputObjectType */.sR({ + name: inputObjectIntrospection.name, + description: inputObjectIntrospection.description, + fields: () => buildInputValueDefMap(inputObjectIntrospection.inputFields), + }); + } + + function buildFieldDefMap(typeIntrospection) { + if (!typeIntrospection.fields) { + throw new Error( + `Introspection result missing fields: ${(0,inspect/* inspect */.X)(typeIntrospection)}.`, + ); + } + + return (0,keyValMap/* keyValMap */.w)( + typeIntrospection.fields, + (fieldIntrospection) => fieldIntrospection.name, + buildField, + ); + } + + function buildField(fieldIntrospection) { + const type = getType(fieldIntrospection.type); + + if (!(0,definition/* isOutputType */.SZ)(type)) { + const typeStr = (0,inspect/* inspect */.X)(type); + throw new Error( + `Introspection must provide output type for fields, but received: ${typeStr}.`, + ); + } + + if (!fieldIntrospection.args) { + const fieldIntrospectionStr = (0,inspect/* inspect */.X)(fieldIntrospection); + throw new Error( + `Introspection result missing field args: ${fieldIntrospectionStr}.`, + ); + } + + return { + description: fieldIntrospection.description, + deprecationReason: fieldIntrospection.deprecationReason, + type, + args: buildInputValueDefMap(fieldIntrospection.args), + }; + } + + function buildInputValueDefMap(inputValueIntrospections) { + return (0,keyValMap/* keyValMap */.w)( + inputValueIntrospections, + (inputValue) => inputValue.name, + buildInputValue, + ); + } + + function buildInputValue(inputValueIntrospection) { + const type = getType(inputValueIntrospection.type); + + if (!(0,definition/* isInputType */.j$)(type)) { + const typeStr = (0,inspect/* inspect */.X)(type); + throw new Error( + `Introspection must provide input type for arguments, but received: ${typeStr}.`, + ); + } + + const defaultValue = + inputValueIntrospection.defaultValue != null + ? (0,valueFromAST/* valueFromAST */.u)((0,parser/* parseValue */.H2)(inputValueIntrospection.defaultValue), type) + : undefined; + return { + description: inputValueIntrospection.description, + type, + defaultValue, + deprecationReason: inputValueIntrospection.deprecationReason, + }; + } + + function buildDirective(directiveIntrospection) { + if (!directiveIntrospection.args) { + const directiveIntrospectionStr = (0,inspect/* inspect */.X)(directiveIntrospection); + throw new Error( + `Introspection result missing directive args: ${directiveIntrospectionStr}.`, + ); + } + + if (!directiveIntrospection.locations) { + const directiveIntrospectionStr = (0,inspect/* inspect */.X)(directiveIntrospection); + throw new Error( + `Introspection result missing directive locations: ${directiveIntrospectionStr}.`, + ); + } + + return new type_directives/* GraphQLDirective */.NZ({ + name: directiveIntrospection.name, + description: directiveIntrospection.description, + isRepeatable: directiveIntrospection.isRepeatable, + locations: directiveIntrospection.locations.slice(), + args: buildInputValueDefMap(directiveIntrospection.args), + }); + } +} + +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/naturalCompare.mjs +var naturalCompare = __webpack_require__(8224); +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/lexicographicSortSchema.mjs + + + + + + + + +/** + * Sort GraphQLSchema. + * + * This function returns a sorted copy of the given GraphQLSchema. + */ + +function lexicographicSortSchema(schema) { + const schemaConfig = schema.toConfig(); + const typeMap = (0,keyValMap/* keyValMap */.w)( + sortByName(schemaConfig.types), + (type) => type.name, + sortNamedType, + ); + return new type_schema/* GraphQLSchema */.XO({ + ...schemaConfig, + types: Object.values(typeMap), + directives: sortByName(schemaConfig.directives).map(sortDirective), + query: replaceMaybeType(schemaConfig.query), + mutation: replaceMaybeType(schemaConfig.mutation), + subscription: replaceMaybeType(schemaConfig.subscription), + }); + + function replaceType(type) { + if ((0,definition/* isListType */.HG)(type)) { + // @ts-expect-error + return new definition/* GraphQLList */.p2(replaceType(type.ofType)); + } else if ((0,definition/* isNonNullType */.zM)(type)) { + // @ts-expect-error + return new definition/* GraphQLNonNull */.bM(replaceType(type.ofType)); + } // @ts-expect-error FIXME: TS Conversion + + return replaceNamedType(type); + } + + function replaceNamedType(type) { + return typeMap[type.name]; + } + + function replaceMaybeType(maybeType) { + return maybeType && replaceNamedType(maybeType); + } + + function sortDirective(directive) { + const config = directive.toConfig(); + return new type_directives/* GraphQLDirective */.NZ({ + ...config, + locations: sortBy(config.locations, (x) => x), + args: sortArgs(config.args), + }); + } + + function sortArgs(args) { + return sortObjMap(args, (arg) => ({ ...arg, type: replaceType(arg.type) })); + } + + function sortFields(fieldsMap) { + return sortObjMap(fieldsMap, (field) => ({ + ...field, + type: replaceType(field.type), + args: field.args && sortArgs(field.args), + })); + } + + function sortInputFields(fieldsMap) { + return sortObjMap(fieldsMap, (field) => ({ + ...field, + type: replaceType(field.type), + })); + } + + function sortTypes(array) { + return sortByName(array).map(replaceNamedType); + } + + function sortNamedType(type) { + if ((0,definition/* isScalarType */.KA)(type) || (0,type_introspection/* isIntrospectionType */.s9)(type)) { + return type; + } + + if ((0,definition/* isObjectType */.lp)(type)) { + const config = type.toConfig(); + return new definition/* GraphQLObjectType */.h6({ + ...config, + interfaces: () => sortTypes(config.interfaces), + fields: () => sortFields(config.fields), + }); + } + + if ((0,definition/* isInterfaceType */.oT)(type)) { + const config = type.toConfig(); + return new definition/* GraphQLInterfaceType */.oW({ + ...config, + interfaces: () => sortTypes(config.interfaces), + fields: () => sortFields(config.fields), + }); + } + + if ((0,definition/* isUnionType */.EN)(type)) { + const config = type.toConfig(); + return new definition/* GraphQLUnionType */.Gp({ + ...config, + types: () => sortTypes(config.types), + }); + } + + if ((0,definition/* isEnumType */.EM)(type)) { + const config = type.toConfig(); + return new definition/* GraphQLEnumType */.mR({ + ...config, + values: sortObjMap(config.values, (value) => value), + }); + } + + if ((0,definition/* isInputObjectType */.hL)(type)) { + const config = type.toConfig(); + return new definition/* GraphQLInputObjectType */.sR({ + ...config, + fields: () => sortInputFields(config.fields), + }); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || (0,invariant/* invariant */.k)(false, 'Unexpected type: ' + (0,inspect/* inspect */.X)(type)); + } +} + +function sortObjMap(map, sortValueFn) { + const sortedMap = Object.create(null); + + for (const key of Object.keys(map).sort(naturalCompare/* naturalCompare */.K)) { + sortedMap[key] = sortValueFn(map[key]); + } + + return sortedMap; +} + +function sortByName(array) { + return sortBy(array, (obj) => obj.name); +} + +function sortBy(array, mapToKey) { + return array.slice().sort((obj1, obj2) => { + const key1 = mapToKey(obj1); + const key2 = mapToKey(obj2); + return (0,naturalCompare/* naturalCompare */.K)(key1, key2); + }); +} + +// EXTERNAL MODULE: ./node_modules/graphql/language/blockString.mjs +var language_blockString = __webpack_require__(7392); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/astFromValue.mjs +var astFromValue = __webpack_require__(8631); +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/printSchema.mjs + + + + + + + + + + +function printSchema(schema) { + return printFilteredSchema( + schema, + (n) => !(0,type_directives/* isSpecifiedDirective */.xg)(n), + isDefinedType, + ); +} +function printIntrospectionSchema(schema) { + return printFilteredSchema(schema, type_directives/* isSpecifiedDirective */.xg, type_introspection/* isIntrospectionType */.s9); +} + +function isDefinedType(type) { + return !(0,scalars/* isSpecifiedScalarType */.u1)(type) && !(0,type_introspection/* isIntrospectionType */.s9)(type); +} + +function printFilteredSchema(schema, directiveFilter, typeFilter) { + const directives = schema.getDirectives().filter(directiveFilter); + const types = Object.values(schema.getTypeMap()).filter(typeFilter); + return [ + printSchemaDefinition(schema), + ...directives.map((directive) => printDirective(directive)), + ...types.map((type) => printType(type)), + ] + .filter(Boolean) + .join('\n\n'); +} + +function printSchemaDefinition(schema) { + if (schema.description == null && isSchemaOfCommonNames(schema)) { + return; + } + + const operationTypes = []; + const queryType = schema.getQueryType(); + + if (queryType) { + operationTypes.push(` query: ${queryType.name}`); + } + + const mutationType = schema.getMutationType(); + + if (mutationType) { + operationTypes.push(` mutation: ${mutationType.name}`); + } + + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType) { + operationTypes.push(` subscription: ${subscriptionType.name}`); + } + + return printDescription(schema) + `schema {\n${operationTypes.join('\n')}\n}`; +} +/** + * GraphQL schema define root types for each type of operation. These types are + * the same as any other type and can be named in any manner, however there is + * a common naming convention: + * + * ```graphql + * schema { + * query: Query + * mutation: Mutation + * subscription: Subscription + * } + * ``` + * + * When using this naming convention, the schema description can be omitted. + */ + +function isSchemaOfCommonNames(schema) { + const queryType = schema.getQueryType(); + + if (queryType && queryType.name !== 'Query') { + return false; + } + + const mutationType = schema.getMutationType(); + + if (mutationType && mutationType.name !== 'Mutation') { + return false; + } + + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType && subscriptionType.name !== 'Subscription') { + return false; + } + + return true; +} + +function printType(type) { + if ((0,definition/* isScalarType */.KA)(type)) { + return printScalar(type); + } + + if ((0,definition/* isObjectType */.lp)(type)) { + return printObject(type); + } + + if ((0,definition/* isInterfaceType */.oT)(type)) { + return printInterface(type); + } + + if ((0,definition/* isUnionType */.EN)(type)) { + return printUnion(type); + } + + if ((0,definition/* isEnumType */.EM)(type)) { + return printEnum(type); + } + + if ((0,definition/* isInputObjectType */.hL)(type)) { + return printInputObject(type); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || (0,invariant/* invariant */.k)(false, 'Unexpected type: ' + (0,inspect/* inspect */.X)(type)); +} + +function printScalar(type) { + return ( + printDescription(type) + `scalar ${type.name}` + printSpecifiedByURL(type) + ); +} + +function printImplementedInterfaces(type) { + const interfaces = type.getInterfaces(); + return interfaces.length + ? ' implements ' + interfaces.map((i) => i.name).join(' & ') + : ''; +} + +function printObject(type) { + return ( + printDescription(type) + + `type ${type.name}` + + printImplementedInterfaces(type) + + printFields(type) + ); +} + +function printInterface(type) { + return ( + printDescription(type) + + `interface ${type.name}` + + printImplementedInterfaces(type) + + printFields(type) + ); +} + +function printUnion(type) { + const types = type.getTypes(); + const possibleTypes = types.length ? ' = ' + types.join(' | ') : ''; + return printDescription(type) + 'union ' + type.name + possibleTypes; +} + +function printEnum(type) { + const values = type + .getValues() + .map( + (value, i) => + printDescription(value, ' ', !i) + + ' ' + + value.name + + printDeprecated(value.deprecationReason), + ); + return printDescription(type) + `enum ${type.name}` + printBlock(values); +} + +function printInputObject(type) { + const fields = Object.values(type.getFields()).map( + (f, i) => printDescription(f, ' ', !i) + ' ' + printInputValue(f), + ); + return printDescription(type) + `input ${type.name}` + printBlock(fields); +} + +function printFields(type) { + const fields = Object.values(type.getFields()).map( + (f, i) => + printDescription(f, ' ', !i) + + ' ' + + f.name + + printArgs(f.args, ' ') + + ': ' + + String(f.type) + + printDeprecated(f.deprecationReason), + ); + return printBlock(fields); +} + +function printBlock(items) { + return items.length !== 0 ? ' {\n' + items.join('\n') + '\n}' : ''; +} + +function printArgs(args, indentation = '') { + if (args.length === 0) { + return ''; + } // If every arg does not have a description, print them on one line. + + if (args.every((arg) => !arg.description)) { + return '(' + args.map(printInputValue).join(', ') + ')'; + } + + return ( + '(\n' + + args + .map( + (arg, i) => + printDescription(arg, ' ' + indentation, !i) + + ' ' + + indentation + + printInputValue(arg), + ) + .join('\n') + + '\n' + + indentation + + ')' + ); +} + +function printInputValue(arg) { + const defaultAST = (0,astFromValue/* astFromValue */.J)(arg.defaultValue, arg.type); + let argDecl = arg.name + ': ' + String(arg.type); + + if (defaultAST) { + argDecl += ` = ${(0,printer/* print */.S)(defaultAST)}`; + } + + return argDecl + printDeprecated(arg.deprecationReason); +} + +function printDirective(directive) { + return ( + printDescription(directive) + + 'directive @' + + directive.name + + printArgs(directive.args) + + (directive.isRepeatable ? ' repeatable' : '') + + ' on ' + + directive.locations.join(' | ') + ); +} + +function printDeprecated(reason) { + if (reason == null) { + return ''; + } + + if (reason !== type_directives/* DEFAULT_DEPRECATION_REASON */.SY) { + const astValue = (0,printer/* print */.S)({ + kind: kinds/* Kind.STRING */.h.STRING, + value: reason, + }); + return ` @deprecated(reason: ${astValue})`; + } + + return ' @deprecated'; +} + +function printSpecifiedByURL(scalar) { + if (scalar.specifiedByURL == null) { + return ''; + } + + const astValue = (0,printer/* print */.S)({ + kind: kinds/* Kind.STRING */.h.STRING, + value: scalar.specifiedByURL, + }); + return ` @specifiedBy(url: ${astValue})`; +} + +function printDescription(def, indentation = '', firstInBlock = true) { + const { description } = def; + + if (description == null) { + return ''; + } + + const blockString = (0,printer/* print */.S)({ + kind: kinds/* Kind.STRING */.h.STRING, + value: description, + block: (0,language_blockString/* isPrintableAsBlockString */.MZ)(description), + }); + const prefix = + indentation && !firstInBlock ? '\n' + indentation : indentation; + return prefix + blockString.replace(/\n/g, '\n' + indentation) + '\n'; +} + +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/concatAST.mjs + +/** + * Provided a collection of ASTs, presumably each from different files, + * concatenate the ASTs together into batched AST, useful for validating many + * GraphQL source files which together represent one conceptual application. + */ + +function concatAST(documents) { + const definitions = []; + + for (const doc of documents) { + definitions.push(...doc.definitions); + } + + return { + kind: kinds/* Kind.DOCUMENT */.h.DOCUMENT, + definitions, + }; +} + +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/separateOperations.mjs + + +/** + * separateOperations accepts a single AST document which may contain many + * operations and fragments and returns a collection of AST documents each of + * which contains a single operation as well the fragment definitions it + * refers to. + */ + +function separateOperations(documentAST) { + const operations = []; + const depGraph = Object.create(null); // Populate metadata and build a dependency graph. + + for (const definitionNode of documentAST.definitions) { + switch (definitionNode.kind) { + case kinds/* Kind.OPERATION_DEFINITION */.h.OPERATION_DEFINITION: + operations.push(definitionNode); + break; + + case kinds/* Kind.FRAGMENT_DEFINITION */.h.FRAGMENT_DEFINITION: + depGraph[definitionNode.name.value] = collectDependencies( + definitionNode.selectionSet, + ); + break; + + default: // ignore non-executable definitions + } + } // For each operation, produce a new synthesized AST which includes only what + // is necessary for completing that operation. + + const separatedDocumentASTs = Object.create(null); + + for (const operation of operations) { + const dependencies = new Set(); + + for (const fragmentName of collectDependencies(operation.selectionSet)) { + collectTransitiveDependencies(dependencies, depGraph, fragmentName); + } // Provides the empty string for anonymous operations. + + const operationName = operation.name ? operation.name.value : ''; // The list of definition nodes to be included for this operation, sorted + // to retain the same order as the original document. + + separatedDocumentASTs[operationName] = { + kind: kinds/* Kind.DOCUMENT */.h.DOCUMENT, + definitions: documentAST.definitions.filter( + (node) => + node === operation || + (node.kind === kinds/* Kind.FRAGMENT_DEFINITION */.h.FRAGMENT_DEFINITION && + dependencies.has(node.name.value)), + ), + }; + } + + return separatedDocumentASTs; +} + +// From a dependency graph, collects a list of transitive dependencies by +// recursing through a dependency graph. +function collectTransitiveDependencies(collected, depGraph, fromName) { + if (!collected.has(fromName)) { + collected.add(fromName); + const immediateDeps = depGraph[fromName]; + + if (immediateDeps !== undefined) { + for (const toName of immediateDeps) { + collectTransitiveDependencies(collected, depGraph, toName); + } + } + } +} + +function collectDependencies(selectionSet) { + const dependencies = []; + (0,visitor/* visit */.Vn)(selectionSet, { + FragmentSpread(node) { + dependencies.push(node.name.value); + }, + }); + return dependencies; +} + +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/stripIgnoredCharacters.mjs + + + + +/** + * Strips characters that are not significant to the validity or execution + * of a GraphQL document: + * - UnicodeBOM + * - WhiteSpace + * - LineTerminator + * - Comment + * - Comma + * - BlockString indentation + * + * Note: It is required to have a delimiter character between neighboring + * non-punctuator tokens and this function always uses single space as delimiter. + * + * It is guaranteed that both input and output documents if parsed would result + * in the exact same AST except for nodes location. + * + * Warning: It is guaranteed that this function will always produce stable results. + * However, it's not guaranteed that it will stay the same between different + * releases due to bugfixes or changes in the GraphQL specification. + * + * Query example: + * + * ```graphql + * query SomeQuery($foo: String!, $bar: String) { + * someField(foo: $foo, bar: $bar) { + * a + * b { + * c + * d + * } + * } + * } + * ``` + * + * Becomes: + * + * ```graphql + * query SomeQuery($foo:String!$bar:String){someField(foo:$foo bar:$bar){a b{c d}}} + * ``` + * + * SDL example: + * + * ```graphql + * """ + * Type description + * """ + * type Foo { + * """ + * Field description + * """ + * bar: String + * } + * ``` + * + * Becomes: + * + * ```graphql + * """Type description""" type Foo{"""Field description""" bar:String} + * ``` + */ + +function stripIgnoredCharacters(source) { + const sourceObj = (0,language_source/* isSource */.T)(source) ? source : new language_source/* Source */.H(source); + const body = sourceObj.body; + const lexer = new language_lexer/* Lexer */.h(sourceObj); + let strippedBody = ''; + let wasLastAddedTokenNonPunctuator = false; + + while (lexer.advance().kind !== language_tokenKind/* TokenKind.EOF */.T.EOF) { + const currentToken = lexer.token; + const tokenKind = currentToken.kind; + /** + * Every two non-punctuator tokens should have space between them. + * Also prevent case of non-punctuator token following by spread resulting + * in invalid token (e.g. `1...` is invalid Float token). + */ + + const isNonPunctuator = !(0,language_lexer/* isPunctuatorTokenKind */.u)(currentToken.kind); + + if (wasLastAddedTokenNonPunctuator) { + if (isNonPunctuator || currentToken.kind === language_tokenKind/* TokenKind.SPREAD */.T.SPREAD) { + strippedBody += ' '; + } + } + + const tokenBody = body.slice(currentToken.start, currentToken.end); + + if (tokenKind === language_tokenKind/* TokenKind.BLOCK_STRING */.T.BLOCK_STRING) { + strippedBody += (0,language_blockString/* printBlockString */.LZ)(currentToken.value, { + minimize: true, + }); + } else { + strippedBody += tokenBody; + } + + wasLastAddedTokenNonPunctuator = isNonPunctuator; + } + + return strippedBody; +} + +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/assertValidName.mjs + + + +/* c8 ignore start */ + +/** + * Upholds the spec rules about naming. + * @deprecated Please use `assertName` instead. Will be removed in v17 + */ + +function assertValidName(name) { + const error = isValidNameError(name); + + if (error) { + throw error; + } + + return name; +} +/** + * Returns an Error if a name is invalid. + * @deprecated Please use `assertName` instead. Will be removed in v17 + */ + +function isValidNameError(name) { + typeof name === 'string' || (0,devAssert/* devAssert */.a)(false, 'Expected name to be a string.'); + + if (name.startsWith('__')) { + return new GraphQLError/* GraphQLError */.__( + `Name "${name}" must not begin with "__", which is reserved by GraphQL introspection.`, + ); + } + + try { + (0,assertName/* assertName */.i)(name); + } catch (error) { + return error; + } +} +/* c8 ignore stop */ + +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/keyMap.mjs +var keyMap = __webpack_require__(3498); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/sortValueNode.mjs +var sortValueNode = __webpack_require__(8360); +;// CONCATENATED MODULE: ./node_modules/graphql/utilities/findBreakingChanges.mjs + + + + + + + + +var BreakingChangeType; + +(function (BreakingChangeType) { + BreakingChangeType['TYPE_REMOVED'] = 'TYPE_REMOVED'; + BreakingChangeType['TYPE_CHANGED_KIND'] = 'TYPE_CHANGED_KIND'; + BreakingChangeType['TYPE_REMOVED_FROM_UNION'] = 'TYPE_REMOVED_FROM_UNION'; + BreakingChangeType['VALUE_REMOVED_FROM_ENUM'] = 'VALUE_REMOVED_FROM_ENUM'; + BreakingChangeType['REQUIRED_INPUT_FIELD_ADDED'] = + 'REQUIRED_INPUT_FIELD_ADDED'; + BreakingChangeType['IMPLEMENTED_INTERFACE_REMOVED'] = + 'IMPLEMENTED_INTERFACE_REMOVED'; + BreakingChangeType['FIELD_REMOVED'] = 'FIELD_REMOVED'; + BreakingChangeType['FIELD_CHANGED_KIND'] = 'FIELD_CHANGED_KIND'; + BreakingChangeType['REQUIRED_ARG_ADDED'] = 'REQUIRED_ARG_ADDED'; + BreakingChangeType['ARG_REMOVED'] = 'ARG_REMOVED'; + BreakingChangeType['ARG_CHANGED_KIND'] = 'ARG_CHANGED_KIND'; + BreakingChangeType['DIRECTIVE_REMOVED'] = 'DIRECTIVE_REMOVED'; + BreakingChangeType['DIRECTIVE_ARG_REMOVED'] = 'DIRECTIVE_ARG_REMOVED'; + BreakingChangeType['REQUIRED_DIRECTIVE_ARG_ADDED'] = + 'REQUIRED_DIRECTIVE_ARG_ADDED'; + BreakingChangeType['DIRECTIVE_REPEATABLE_REMOVED'] = + 'DIRECTIVE_REPEATABLE_REMOVED'; + BreakingChangeType['DIRECTIVE_LOCATION_REMOVED'] = + 'DIRECTIVE_LOCATION_REMOVED'; +})(BreakingChangeType || (BreakingChangeType = {})); + + +var DangerousChangeType; + +(function (DangerousChangeType) { + DangerousChangeType['VALUE_ADDED_TO_ENUM'] = 'VALUE_ADDED_TO_ENUM'; + DangerousChangeType['TYPE_ADDED_TO_UNION'] = 'TYPE_ADDED_TO_UNION'; + DangerousChangeType['OPTIONAL_INPUT_FIELD_ADDED'] = + 'OPTIONAL_INPUT_FIELD_ADDED'; + DangerousChangeType['OPTIONAL_ARG_ADDED'] = 'OPTIONAL_ARG_ADDED'; + DangerousChangeType['IMPLEMENTED_INTERFACE_ADDED'] = + 'IMPLEMENTED_INTERFACE_ADDED'; + DangerousChangeType['ARG_DEFAULT_VALUE_CHANGE'] = 'ARG_DEFAULT_VALUE_CHANGE'; +})(DangerousChangeType || (DangerousChangeType = {})); + + + +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of breaking changes covered by the other functions down below. + */ +function findBreakingChanges(oldSchema, newSchema) { + // @ts-expect-error + return findSchemaChanges(oldSchema, newSchema).filter( + (change) => change.type in BreakingChangeType, + ); +} +/** + * Given two schemas, returns an Array containing descriptions of all the types + * of potentially dangerous changes covered by the other functions down below. + */ + +function findDangerousChanges(oldSchema, newSchema) { + // @ts-expect-error + return findSchemaChanges(oldSchema, newSchema).filter( + (change) => change.type in DangerousChangeType, + ); +} + +function findSchemaChanges(oldSchema, newSchema) { + return [ + ...findTypeChanges(oldSchema, newSchema), + ...findDirectiveChanges(oldSchema, newSchema), + ]; +} + +function findDirectiveChanges(oldSchema, newSchema) { + const schemaChanges = []; + const directivesDiff = diff( + oldSchema.getDirectives(), + newSchema.getDirectives(), + ); + + for (const oldDirective of directivesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_REMOVED, + description: `${oldDirective.name} was removed.`, + }); + } + + for (const [oldDirective, newDirective] of directivesDiff.persisted) { + const argsDiff = diff(oldDirective.args, newDirective.args); + + for (const newArg of argsDiff.added) { + if ((0,definition/* isRequiredArgument */.dK)(newArg)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_DIRECTIVE_ARG_ADDED, + description: `A required arg ${newArg.name} on directive ${oldDirective.name} was added.`, + }); + } + } + + for (const oldArg of argsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_ARG_REMOVED, + description: `${oldArg.name} was removed from ${oldDirective.name}.`, + }); + } + + if (oldDirective.isRepeatable && !newDirective.isRepeatable) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_REPEATABLE_REMOVED, + description: `Repeatable flag was removed from ${oldDirective.name}.`, + }); + } + + for (const location of oldDirective.locations) { + if (!newDirective.locations.includes(location)) { + schemaChanges.push({ + type: BreakingChangeType.DIRECTIVE_LOCATION_REMOVED, + description: `${location} was removed from ${oldDirective.name}.`, + }); + } + } + } + + return schemaChanges; +} + +function findTypeChanges(oldSchema, newSchema) { + const schemaChanges = []; + const typesDiff = diff( + Object.values(oldSchema.getTypeMap()), + Object.values(newSchema.getTypeMap()), + ); + + for (const oldType of typesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_REMOVED, + description: (0,scalars/* isSpecifiedScalarType */.u1)(oldType) + ? `Standard scalar ${oldType.name} was removed because it is not referenced anymore.` + : `${oldType.name} was removed.`, + }); + } + + for (const [oldType, newType] of typesDiff.persisted) { + if ((0,definition/* isEnumType */.EM)(oldType) && (0,definition/* isEnumType */.EM)(newType)) { + schemaChanges.push(...findEnumTypeChanges(oldType, newType)); + } else if ((0,definition/* isUnionType */.EN)(oldType) && (0,definition/* isUnionType */.EN)(newType)) { + schemaChanges.push(...findUnionTypeChanges(oldType, newType)); + } else if ((0,definition/* isInputObjectType */.hL)(oldType) && (0,definition/* isInputObjectType */.hL)(newType)) { + schemaChanges.push(...findInputObjectTypeChanges(oldType, newType)); + } else if ((0,definition/* isObjectType */.lp)(oldType) && (0,definition/* isObjectType */.lp)(newType)) { + schemaChanges.push( + ...findFieldChanges(oldType, newType), + ...findImplementedInterfacesChanges(oldType, newType), + ); + } else if ((0,definition/* isInterfaceType */.oT)(oldType) && (0,definition/* isInterfaceType */.oT)(newType)) { + schemaChanges.push( + ...findFieldChanges(oldType, newType), + ...findImplementedInterfacesChanges(oldType, newType), + ); + } else if (oldType.constructor !== newType.constructor) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_CHANGED_KIND, + description: + `${oldType.name} changed from ` + + `${typeKindName(oldType)} to ${typeKindName(newType)}.`, + }); + } + } + + return schemaChanges; +} + +function findInputObjectTypeChanges(oldType, newType) { + const schemaChanges = []; + const fieldsDiff = diff( + Object.values(oldType.getFields()), + Object.values(newType.getFields()), + ); + + for (const newField of fieldsDiff.added) { + if ((0,definition/* isRequiredInputField */.Wd)(newField)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_INPUT_FIELD_ADDED, + description: `A required field ${newField.name} on input type ${oldType.name} was added.`, + }); + } else { + schemaChanges.push({ + type: DangerousChangeType.OPTIONAL_INPUT_FIELD_ADDED, + description: `An optional field ${newField.name} on input type ${oldType.name} was added.`, + }); + } + } + + for (const oldField of fieldsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_REMOVED, + description: `${oldType.name}.${oldField.name} was removed.`, + }); + } + + for (const [oldField, newField] of fieldsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg( + oldField.type, + newField.type, + ); + + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_CHANGED_KIND, + description: + `${oldType.name}.${oldField.name} changed type from ` + + `${String(oldField.type)} to ${String(newField.type)}.`, + }); + } + } + + return schemaChanges; +} + +function findUnionTypeChanges(oldType, newType) { + const schemaChanges = []; + const possibleTypesDiff = diff(oldType.getTypes(), newType.getTypes()); + + for (const newPossibleType of possibleTypesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.TYPE_ADDED_TO_UNION, + description: `${newPossibleType.name} was added to union type ${oldType.name}.`, + }); + } + + for (const oldPossibleType of possibleTypesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.TYPE_REMOVED_FROM_UNION, + description: `${oldPossibleType.name} was removed from union type ${oldType.name}.`, + }); + } + + return schemaChanges; +} + +function findEnumTypeChanges(oldType, newType) { + const schemaChanges = []; + const valuesDiff = diff(oldType.getValues(), newType.getValues()); + + for (const newValue of valuesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.VALUE_ADDED_TO_ENUM, + description: `${newValue.name} was added to enum type ${oldType.name}.`, + }); + } + + for (const oldValue of valuesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.VALUE_REMOVED_FROM_ENUM, + description: `${oldValue.name} was removed from enum type ${oldType.name}.`, + }); + } + + return schemaChanges; +} + +function findImplementedInterfacesChanges(oldType, newType) { + const schemaChanges = []; + const interfacesDiff = diff(oldType.getInterfaces(), newType.getInterfaces()); + + for (const newInterface of interfacesDiff.added) { + schemaChanges.push({ + type: DangerousChangeType.IMPLEMENTED_INTERFACE_ADDED, + description: `${newInterface.name} added to interfaces implemented by ${oldType.name}.`, + }); + } + + for (const oldInterface of interfacesDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.IMPLEMENTED_INTERFACE_REMOVED, + description: `${oldType.name} no longer implements interface ${oldInterface.name}.`, + }); + } + + return schemaChanges; +} + +function findFieldChanges(oldType, newType) { + const schemaChanges = []; + const fieldsDiff = diff( + Object.values(oldType.getFields()), + Object.values(newType.getFields()), + ); + + for (const oldField of fieldsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_REMOVED, + description: `${oldType.name}.${oldField.name} was removed.`, + }); + } + + for (const [oldField, newField] of fieldsDiff.persisted) { + schemaChanges.push(...findArgChanges(oldType, oldField, newField)); + const isSafe = isChangeSafeForObjectOrInterfaceField( + oldField.type, + newField.type, + ); + + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.FIELD_CHANGED_KIND, + description: + `${oldType.name}.${oldField.name} changed type from ` + + `${String(oldField.type)} to ${String(newField.type)}.`, + }); + } + } + + return schemaChanges; +} + +function findArgChanges(oldType, oldField, newField) { + const schemaChanges = []; + const argsDiff = diff(oldField.args, newField.args); + + for (const oldArg of argsDiff.removed) { + schemaChanges.push({ + type: BreakingChangeType.ARG_REMOVED, + description: `${oldType.name}.${oldField.name} arg ${oldArg.name} was removed.`, + }); + } + + for (const [oldArg, newArg] of argsDiff.persisted) { + const isSafe = isChangeSafeForInputObjectFieldOrFieldArg( + oldArg.type, + newArg.type, + ); + + if (!isSafe) { + schemaChanges.push({ + type: BreakingChangeType.ARG_CHANGED_KIND, + description: + `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed type from ` + + `${String(oldArg.type)} to ${String(newArg.type)}.`, + }); + } else if (oldArg.defaultValue !== undefined) { + if (newArg.defaultValue === undefined) { + schemaChanges.push({ + type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `${oldType.name}.${oldField.name} arg ${oldArg.name} defaultValue was removed.`, + }); + } else { + // Since we looking only for client's observable changes we should + // compare default values in the same representation as they are + // represented inside introspection. + const oldValueStr = stringifyValue(oldArg.defaultValue, oldArg.type); + const newValueStr = stringifyValue(newArg.defaultValue, newArg.type); + + if (oldValueStr !== newValueStr) { + schemaChanges.push({ + type: DangerousChangeType.ARG_DEFAULT_VALUE_CHANGE, + description: `${oldType.name}.${oldField.name} arg ${oldArg.name} has changed defaultValue from ${oldValueStr} to ${newValueStr}.`, + }); + } + } + } + } + + for (const newArg of argsDiff.added) { + if ((0,definition/* isRequiredArgument */.dK)(newArg)) { + schemaChanges.push({ + type: BreakingChangeType.REQUIRED_ARG_ADDED, + description: `A required arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`, + }); + } else { + schemaChanges.push({ + type: DangerousChangeType.OPTIONAL_ARG_ADDED, + description: `An optional arg ${newArg.name} on ${oldType.name}.${oldField.name} was added.`, + }); + } + } + + return schemaChanges; +} + +function isChangeSafeForObjectOrInterfaceField(oldType, newType) { + if ((0,definition/* isListType */.HG)(oldType)) { + return ( + // if they're both lists, make sure the underlying types are compatible + ((0,definition/* isListType */.HG)(newType) && + isChangeSafeForObjectOrInterfaceField( + oldType.ofType, + newType.ofType, + )) || // moving from nullable to non-null of the same underlying type is safe + ((0,definition/* isNonNullType */.zM)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) + ); + } + + if ((0,definition/* isNonNullType */.zM)(oldType)) { + // if they're both non-null, make sure the underlying types are compatible + return ( + (0,definition/* isNonNullType */.zM)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType.ofType, newType.ofType) + ); + } + + return ( + // if they're both named types, see if their names are equivalent + ((0,definition/* isNamedType */.Zs)(newType) && oldType.name === newType.name) || // moving from nullable to non-null of the same underlying type is safe + ((0,definition/* isNonNullType */.zM)(newType) && + isChangeSafeForObjectOrInterfaceField(oldType, newType.ofType)) + ); +} + +function isChangeSafeForInputObjectFieldOrFieldArg(oldType, newType) { + if ((0,definition/* isListType */.HG)(oldType)) { + // if they're both lists, make sure the underlying types are compatible + return ( + (0,definition/* isListType */.HG)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType.ofType) + ); + } + + if ((0,definition/* isNonNullType */.zM)(oldType)) { + return ( + // if they're both non-null, make sure the underlying types are + // compatible + ((0,definition/* isNonNullType */.zM)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg( + oldType.ofType, + newType.ofType, + )) || // moving from non-null to nullable of the same underlying type is safe + (!(0,definition/* isNonNullType */.zM)(newType) && + isChangeSafeForInputObjectFieldOrFieldArg(oldType.ofType, newType)) + ); + } // if they're both named types, see if their names are equivalent + + return (0,definition/* isNamedType */.Zs)(newType) && oldType.name === newType.name; +} + +function typeKindName(type) { + if ((0,definition/* isScalarType */.KA)(type)) { + return 'a Scalar type'; + } + + if ((0,definition/* isObjectType */.lp)(type)) { + return 'an Object type'; + } + + if ((0,definition/* isInterfaceType */.oT)(type)) { + return 'an Interface type'; + } + + if ((0,definition/* isUnionType */.EN)(type)) { + return 'a Union type'; + } + + if ((0,definition/* isEnumType */.EM)(type)) { + return 'an Enum type'; + } + + if ((0,definition/* isInputObjectType */.hL)(type)) { + return 'an Input type'; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || (0,invariant/* invariant */.k)(false, 'Unexpected type: ' + (0,inspect/* inspect */.X)(type)); +} + +function stringifyValue(value, type) { + const ast = (0,astFromValue/* astFromValue */.J)(value, type); + ast != null || (0,invariant/* invariant */.k)(false); + return (0,printer/* print */.S)((0,sortValueNode/* sortValueNode */.n)(ast)); +} + +function diff(oldArray, newArray) { + const added = []; + const removed = []; + const persisted = []; + const oldMap = (0,keyMap/* keyMap */.P)(oldArray, ({ name }) => name); + const newMap = (0,keyMap/* keyMap */.P)(newArray, ({ name }) => name); + + for (const oldItem of oldArray) { + const newItem = newMap[oldItem.name]; + + if (newItem === undefined) { + removed.push(oldItem); + } else { + persisted.push([oldItem, newItem]); + } + } + + for (const newItem of newArray) { + if (oldMap[newItem.name] === undefined) { + added.push(newItem); + } + } + + return { + added, + persisted, + removed, + }; +} + +// EXTERNAL MODULE: ./node_modules/graphql/utilities/buildASTSchema.mjs +var buildASTSchema = __webpack_require__(6535); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/extendSchema.mjs +var extendSchema = __webpack_require__(9557); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/typeFromAST.mjs +var typeFromAST = __webpack_require__(77); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/valueFromASTUntyped.mjs +var valueFromASTUntyped = __webpack_require__(2319); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/TypeInfo.mjs +var TypeInfo = __webpack_require__(2676); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/coerceInputValue.mjs +var coerceInputValue = __webpack_require__(7816); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/typeComparators.mjs +var typeComparators = __webpack_require__(316); +;// CONCATENATED MODULE: ./node_modules/graphql/index.mjs +/** + * GraphQL.js provides a reference implementation for the GraphQL specification + * but is also a useful utility for operating on GraphQL files and building + * sophisticated tools. + * + * This primary module exports a general purpose function for fulfilling all + * steps of the GraphQL specification in a single operation, but also includes + * utilities for every part of the GraphQL specification: + * + * - Parsing the GraphQL language. + * - Building a GraphQL type schema. + * - Validating a GraphQL request against a type schema. + * - Executing a GraphQL request against a type schema. + * + * This also includes utility functions for operating on GraphQL types and + * GraphQL documents to facilitate building tools. + * + * You may also import from each sub-directory directly. For example, the + * following two import statements are equivalent: + * + * ```ts + * import { parse } from 'graphql'; + * import { parse } from 'graphql/language'; + * ``` + * + * @packageDocumentation + */ +// The GraphQL.js version info. + // The primary entry point into fulfilling a GraphQL request. + + // Create and operate on GraphQL type definitions and schema. + + +// Parse and operate on GraphQL language source files. + +// Execute GraphQL queries. + +// Validate GraphQL documents. + +// Create, format, and print GraphQL errors. + +// Utilities for operating on GraphQL type schema and parsed sources. + + + +/***/ }), + +/***/ 9380: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "N": () => (/* binding */ pathToArray), +/* harmony export */ "Q": () => (/* binding */ addPath) +/* harmony export */ }); +/** + * Given a Path and a key, return a new Path containing the new key. + */ +function addPath(prev, key, typename) { + return { + prev, + key, + typename, + }; +} +/** + * Given a Path, return an Array of the path keys. + */ + +function pathToArray(path) { + const flattened = []; + let curr = path; + + while (curr) { + flattened.push(curr.key); + curr = curr.prev; + } + + return flattened.reverse(); +} + + +/***/ }), + +/***/ 7826: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "a": () => (/* binding */ devAssert) +/* harmony export */ }); +function devAssert(condition, message) { + const booleanCondition = Boolean(condition); + + if (!booleanCondition) { + throw new Error(message); + } +} + + +/***/ }), + +/***/ 3177: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "l": () => (/* binding */ didYouMean) +/* harmony export */ }); +const MAX_SUGGESTIONS = 5; +/** + * Given [ A, B, C ] return ' Did you mean A, B, or C?'. + */ + +function didYouMean(firstArg, secondArg) { + const [subMessage, suggestionsArg] = secondArg + ? [firstArg, secondArg] + : [undefined, firstArg]; + let message = ' Did you mean '; + + if (subMessage) { + message += subMessage + ' '; + } + + const suggestions = suggestionsArg.map((x) => `"${x}"`); + + switch (suggestions.length) { + case 0: + return ''; + + case 1: + return message + suggestions[0] + '?'; + + case 2: + return message + suggestions[0] + ' or ' + suggestions[1] + '?'; + } + + const selected = suggestions.slice(0, MAX_SUGGESTIONS); + const lastItem = selected.pop(); + return message + selected.join(', ') + ', or ' + lastItem + '?'; +} + + +/***/ }), + +/***/ 3231: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "v": () => (/* binding */ groupBy) +/* harmony export */ }); +/** + * Groups array items into a Map, given a function to produce grouping key. + */ +function groupBy(list, keyFn) { + const result = new Map(); + + for (const item of list) { + const key = keyFn(item); + const group = result.get(key); + + if (group === undefined) { + result.set(key, [item]); + } else { + group.push(item); + } + } + + return result; +} + + +/***/ }), + +/***/ 5821: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "X": () => (/* binding */ inspect) +/* harmony export */ }); +const MAX_ARRAY_LENGTH = 10; +const MAX_RECURSIVE_DEPTH = 2; +/** + * Used to print values in error messages. + */ + +function inspect(value) { + return formatValue(value, []); +} + +function formatValue(value, seenValues) { + switch (typeof value) { + case 'string': + return JSON.stringify(value); + + case 'function': + return value.name ? `[function ${value.name}]` : '[function]'; + + case 'object': + return formatObjectValue(value, seenValues); + + default: + return String(value); + } +} + +function formatObjectValue(value, previouslySeenValues) { + if (value === null) { + return 'null'; + } + + if (previouslySeenValues.includes(value)) { + return '[Circular]'; + } + + const seenValues = [...previouslySeenValues, value]; + + if (isJSONable(value)) { + const jsonValue = value.toJSON(); // check for infinite recursion + + if (jsonValue !== value) { + return typeof jsonValue === 'string' + ? jsonValue + : formatValue(jsonValue, seenValues); + } + } else if (Array.isArray(value)) { + return formatArray(value, seenValues); + } + + return formatObject(value, seenValues); +} + +function isJSONable(value) { + return typeof value.toJSON === 'function'; +} + +function formatObject(object, seenValues) { + const entries = Object.entries(object); + + if (entries.length === 0) { + return '{}'; + } + + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[' + getObjectTag(object) + ']'; + } + + const properties = entries.map( + ([key, value]) => key + ': ' + formatValue(value, seenValues), + ); + return '{ ' + properties.join(', ') + ' }'; +} + +function formatArray(array, seenValues) { + if (array.length === 0) { + return '[]'; + } + + if (seenValues.length > MAX_RECURSIVE_DEPTH) { + return '[Array]'; + } + + const len = Math.min(MAX_ARRAY_LENGTH, array.length); + const remaining = array.length - len; + const items = []; + + for (let i = 0; i < len; ++i) { + items.push(formatValue(array[i], seenValues)); + } + + if (remaining === 1) { + items.push('... 1 more item'); + } else if (remaining > 1) { + items.push(`... ${remaining} more items`); + } + + return '[' + items.join(', ') + ']'; +} + +function getObjectTag(object) { + const tag = Object.prototype.toString + .call(object) + .replace(/^\[object /, '') + .replace(/]$/, ''); + + if (tag === 'Object' && typeof object.constructor === 'function') { + const name = object.constructor.name; + + if (typeof name === 'string' && name !== '') { + return name; + } + } + + return tag; +} + + +/***/ }), + +/***/ 8306: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "n": () => (/* binding */ instanceOf) +/* harmony export */ }); + +/** + * A replacement for instanceof which includes an error warning when multi-realm + * constructors are detected. + * See: https://expressjs.com/en/advanced/best-practice-performance.html#set-node_env-to-production + * See: https://webpack.js.org/guides/production/ + */ + +const instanceOf = + /* c8 ignore next 6 */ + // FIXME: https://github.com/graphql/graphql-js/issues/2317 + // eslint-disable-next-line no-undef + true + ? function instanceOf(value, constructor) { + return value instanceof constructor; + } + : 0; + + +/***/ }), + +/***/ 9551: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "k": () => (/* binding */ invariant) +/* harmony export */ }); +function invariant(condition, message) { + const booleanCondition = Boolean(condition); + + if (!booleanCondition) { + throw new Error( + message != null ? message : 'Unexpected invariant triggered.', + ); + } +} + + +/***/ }), + +/***/ 3831: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "i": () => (/* binding */ isIterableObject) +/* harmony export */ }); +/** + * Returns true if the provided object is an Object (i.e. not a string literal) + * and implements the Iterator protocol. + * + * This may be used in place of [Array.isArray()][isArray] to determine if + * an object should be iterated-over e.g. Array, Map, Set, Int8Array, + * TypedArray, etc. but excludes string literals. + * + * @example + * ```ts + * isIterableObject([ 1, 2, 3 ]) // true + * isIterableObject(new Map()) // true + * isIterableObject('ABC') // false + * isIterableObject({ key: 'value' }) // false + * isIterableObject({ length: 1, 0: 'Alpha' }) // false + * ``` + */ +function isIterableObject(maybeIterable) { + return ( + typeof maybeIterable === 'object' && + typeof (maybeIterable === null || maybeIterable === void 0 + ? void 0 + : maybeIterable[Symbol.iterator]) === 'function' + ); +} + + +/***/ }), + +/***/ 8495: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "y": () => (/* binding */ isObjectLike) +/* harmony export */ }); +/** + * Return true if `value` is object-like. A value is object-like if it's not + * `null` and has a `typeof` result of "object". + */ +function isObjectLike(value) { + return typeof value == 'object' && value !== null; +} + + +/***/ }), + +/***/ 8659: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "t": () => (/* binding */ isPromise) +/* harmony export */ }); +/** + * Returns true if the value acts like a Promise, i.e. has a "then" function, + * otherwise returns false. + */ +function isPromise(value) { + return ( + typeof (value === null || value === void 0 ? void 0 : value.then) === + 'function' + ); +} + + +/***/ }), + +/***/ 3498: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "P": () => (/* binding */ keyMap) +/* harmony export */ }); +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * for each value in the array. + * + * This provides a convenient lookup for the array items if the key function + * produces unique results. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * const entriesByName = keyMap( + * phoneBook, + * entry => entry.name + * ) + * + * // { + * // Jon: { name: 'Jon', num: '555-1234' }, + * // Jenny: { name: 'Jenny', num: '867-5309' } + * // } + * + * const jennyEntry = entriesByName['Jenny'] + * + * // { name: 'Jenny', num: '857-6309' } + * ``` + */ +function keyMap(list, keyFn) { + const result = Object.create(null); + + for (const item of list) { + result[keyFn(item)] = item; + } + + return result; +} + + +/***/ }), + +/***/ 4950: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "w": () => (/* binding */ keyValMap) +/* harmony export */ }); +/** + * Creates a keyed JS object from an array, given a function to produce the keys + * and a function to produce the values from each item in the array. + * ```ts + * const phoneBook = [ + * { name: 'Jon', num: '555-1234' }, + * { name: 'Jenny', num: '867-5309' } + * ] + * + * // { Jon: '555-1234', Jenny: '867-5309' } + * const phonesByName = keyValMap( + * phoneBook, + * entry => entry.name, + * entry => entry.num + * ) + * ``` + */ +function keyValMap(list, keyFn, valFn) { + const result = Object.create(null); + + for (const item of list) { + result[keyFn(item)] = valFn(item); + } + + return result; +} + + +/***/ }), + +/***/ 5723: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "j": () => (/* binding */ mapValue) +/* harmony export */ }); +/** + * Creates an object map with the same keys as `map` and values generated by + * running each value of `map` thru `fn`. + */ +function mapValue(map, fn) { + const result = Object.create(null); + + for (const key of Object.keys(map)) { + result[key] = fn(map[key], key); + } + + return result; +} + + +/***/ }), + +/***/ 8224: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "K": () => (/* binding */ naturalCompare) +/* harmony export */ }); +/** + * Returns a number indicating whether a reference string comes before, or after, + * or is the same as the given string in natural sort order. + * + * See: https://en.wikipedia.org/wiki/Natural_sort_order + * + */ +function naturalCompare(aStr, bStr) { + let aIndex = 0; + let bIndex = 0; + + while (aIndex < aStr.length && bIndex < bStr.length) { + let aChar = aStr.charCodeAt(aIndex); + let bChar = bStr.charCodeAt(bIndex); + + if (isDigit(aChar) && isDigit(bChar)) { + let aNum = 0; + + do { + ++aIndex; + aNum = aNum * 10 + aChar - DIGIT_0; + aChar = aStr.charCodeAt(aIndex); + } while (isDigit(aChar) && aNum > 0); + + let bNum = 0; + + do { + ++bIndex; + bNum = bNum * 10 + bChar - DIGIT_0; + bChar = bStr.charCodeAt(bIndex); + } while (isDigit(bChar) && bNum > 0); + + if (aNum < bNum) { + return -1; + } + + if (aNum > bNum) { + return 1; + } + } else { + if (aChar < bChar) { + return -1; + } + + if (aChar > bChar) { + return 1; + } + + ++aIndex; + ++bIndex; + } + } + + return aStr.length - bStr.length; +} +const DIGIT_0 = 48; +const DIGIT_9 = 57; + +function isDigit(code) { + return !isNaN(code) && DIGIT_0 <= code && code <= DIGIT_9; +} + + +/***/ }), + +/***/ 4244: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "F": () => (/* binding */ printPathArray) +/* harmony export */ }); +/** + * Build a string describing the path. + */ +function printPathArray(path) { + return path + .map((key) => + typeof key === 'number' ? '[' + key.toString() + ']' : '.' + key, + ) + .join(''); +} + + +/***/ }), + +/***/ 3294: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "D": () => (/* binding */ suggestionList) +/* harmony export */ }); +/* harmony import */ var _naturalCompare_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8224); + +/** + * Given an invalid input string and a list of valid options, returns a filtered + * list of valid options sorted based on their similarity with the input. + */ + +function suggestionList(input, options) { + const optionsByDistance = Object.create(null); + const lexicalDistance = new LexicalDistance(input); + const threshold = Math.floor(input.length * 0.4) + 1; + + for (const option of options) { + const distance = lexicalDistance.measure(option, threshold); + + if (distance !== undefined) { + optionsByDistance[option] = distance; + } + } + + return Object.keys(optionsByDistance).sort((a, b) => { + const distanceDiff = optionsByDistance[a] - optionsByDistance[b]; + return distanceDiff !== 0 ? distanceDiff : (0,_naturalCompare_mjs__WEBPACK_IMPORTED_MODULE_0__/* .naturalCompare */ .K)(a, b); + }); +} +/** + * Computes the lexical distance between strings A and B. + * + * The "distance" between two strings is given by counting the minimum number + * of edits needed to transform string A into string B. An edit can be an + * insertion, deletion, or substitution of a single character, or a swap of two + * adjacent characters. + * + * Includes a custom alteration from Damerau-Levenshtein to treat case changes + * as a single edit which helps identify mis-cased values with an edit distance + * of 1. + * + * This distance can be useful for detecting typos in input or sorting + */ + +class LexicalDistance { + constructor(input) { + this._input = input; + this._inputLowerCase = input.toLowerCase(); + this._inputArray = stringToArray(this._inputLowerCase); + this._rows = [ + new Array(input.length + 1).fill(0), + new Array(input.length + 1).fill(0), + new Array(input.length + 1).fill(0), + ]; + } + + measure(option, threshold) { + if (this._input === option) { + return 0; + } + + const optionLowerCase = option.toLowerCase(); // Any case change counts as a single edit + + if (this._inputLowerCase === optionLowerCase) { + return 1; + } + + let a = stringToArray(optionLowerCase); + let b = this._inputArray; + + if (a.length < b.length) { + const tmp = a; + a = b; + b = tmp; + } + + const aLength = a.length; + const bLength = b.length; + + if (aLength - bLength > threshold) { + return undefined; + } + + const rows = this._rows; + + for (let j = 0; j <= bLength; j++) { + rows[0][j] = j; + } + + for (let i = 1; i <= aLength; i++) { + const upRow = rows[(i - 1) % 3]; + const currentRow = rows[i % 3]; + let smallestCell = (currentRow[0] = i); + + for (let j = 1; j <= bLength; j++) { + const cost = a[i - 1] === b[j - 1] ? 0 : 1; + let currentCell = Math.min( + upRow[j] + 1, // delete + currentRow[j - 1] + 1, // insert + upRow[j - 1] + cost, // substitute + ); + + if (i > 1 && j > 1 && a[i - 1] === b[j - 2] && a[i - 2] === b[j - 1]) { + // transposition + const doubleDiagonalCell = rows[(i - 2) % 3][j - 2]; + currentCell = Math.min(currentCell, doubleDiagonalCell + 1); + } + + if (currentCell < smallestCell) { + smallestCell = currentCell; + } + + currentRow[j] = currentCell; + } // Early exit, since distance can't go smaller than smallest element of the previous row. + + if (smallestCell > threshold) { + return undefined; + } + } + + const distance = rows[aLength % 3][bLength]; + return distance <= threshold ? distance : undefined; + } +} + +function stringToArray(str) { + const strLength = str.length; + const array = new Array(strLength); + + for (let i = 0; i < strLength; ++i) { + array[i] = str.charCodeAt(i); + } + + return array; +} + + +/***/ }), + +/***/ 8824: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "u": () => (/* binding */ toObjMap) +/* harmony export */ }); +function toObjMap(obj) { + if (obj == null) { + return Object.create(null); + } + + if (Object.getPrototypeOf(obj) === null) { + return obj; + } + + const map = Object.create(null); + + for (const [key, value] of Object.entries(obj)) { + map[key] = value; + } + + return map; +} + + +/***/ }), + +/***/ 2380: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "UG": () => (/* binding */ isNode), +/* harmony export */ "WU": () => (/* binding */ Token), +/* harmony export */ "Ye": () => (/* binding */ Location), +/* harmony export */ "h8": () => (/* binding */ QueryDocumentKeys), +/* harmony export */ "ku": () => (/* binding */ OperationTypeNode) +/* harmony export */ }); +/** + * Contains a range of UTF-8 character offsets and token references that + * identify the region of the source from which the AST derived. + */ +class Location { + /** + * The character offset at which this Node begins. + */ + + /** + * The character offset at which this Node ends. + */ + + /** + * The Token at which this Node begins. + */ + + /** + * The Token at which this Node ends. + */ + + /** + * The Source document the AST represents. + */ + constructor(startToken, endToken, source) { + this.start = startToken.start; + this.end = endToken.end; + this.startToken = startToken; + this.endToken = endToken; + this.source = source; + } + + get [Symbol.toStringTag]() { + return 'Location'; + } + + toJSON() { + return { + start: this.start, + end: this.end, + }; + } +} +/** + * Represents a range of characters represented by a lexical token + * within a Source. + */ + +class Token { + /** + * The kind of Token. + */ + + /** + * The character offset at which this Node begins. + */ + + /** + * The character offset at which this Node ends. + */ + + /** + * The 1-indexed line number on which this Token appears. + */ + + /** + * The 1-indexed column number at which this Token begins. + */ + + /** + * For non-punctuation tokens, represents the interpreted value of the token. + * + * Note: is undefined for punctuation tokens, but typed as string for + * convenience in the parser. + */ + + /** + * Tokens exist as nodes in a double-linked-list amongst all tokens + * including ignored tokens. is always the first node and + * the last. + */ + constructor(kind, start, end, line, column, value) { + this.kind = kind; + this.start = start; + this.end = end; + this.line = line; + this.column = column; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + + this.value = value; + this.prev = null; + this.next = null; + } + + get [Symbol.toStringTag]() { + return 'Token'; + } + + toJSON() { + return { + kind: this.kind, + value: this.value, + line: this.line, + column: this.column, + }; + } +} +/** + * The list of all possible AST node types. + */ + +/** + * @internal + */ +const QueryDocumentKeys = { + Name: [], + Document: ['definitions'], + OperationDefinition: [ + 'name', + 'variableDefinitions', + 'directives', + 'selectionSet', + ], + VariableDefinition: ['variable', 'type', 'defaultValue', 'directives'], + Variable: ['name'], + SelectionSet: ['selections'], + Field: ['alias', 'name', 'arguments', 'directives', 'selectionSet'], + Argument: ['name', 'value'], + FragmentSpread: ['name', 'directives'], + InlineFragment: ['typeCondition', 'directives', 'selectionSet'], + FragmentDefinition: [ + 'name', // Note: fragment variable definitions are deprecated and will removed in v17.0.0 + 'variableDefinitions', + 'typeCondition', + 'directives', + 'selectionSet', + ], + IntValue: [], + FloatValue: [], + StringValue: [], + BooleanValue: [], + NullValue: [], + EnumValue: [], + ListValue: ['values'], + ObjectValue: ['fields'], + ObjectField: ['name', 'value'], + Directive: ['name', 'arguments'], + NamedType: ['name'], + ListType: ['type'], + NonNullType: ['type'], + SchemaDefinition: ['description', 'directives', 'operationTypes'], + OperationTypeDefinition: ['type'], + ScalarTypeDefinition: ['description', 'name', 'directives'], + ObjectTypeDefinition: [ + 'description', + 'name', + 'interfaces', + 'directives', + 'fields', + ], + FieldDefinition: ['description', 'name', 'arguments', 'type', 'directives'], + InputValueDefinition: [ + 'description', + 'name', + 'type', + 'defaultValue', + 'directives', + ], + InterfaceTypeDefinition: [ + 'description', + 'name', + 'interfaces', + 'directives', + 'fields', + ], + UnionTypeDefinition: ['description', 'name', 'directives', 'types'], + EnumTypeDefinition: ['description', 'name', 'directives', 'values'], + EnumValueDefinition: ['description', 'name', 'directives'], + InputObjectTypeDefinition: ['description', 'name', 'directives', 'fields'], + DirectiveDefinition: ['description', 'name', 'arguments', 'locations'], + SchemaExtension: ['directives', 'operationTypes'], + ScalarTypeExtension: ['name', 'directives'], + ObjectTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + InterfaceTypeExtension: ['name', 'interfaces', 'directives', 'fields'], + UnionTypeExtension: ['name', 'directives', 'types'], + EnumTypeExtension: ['name', 'directives', 'values'], + InputObjectTypeExtension: ['name', 'directives', 'fields'], +}; +const kindValues = new Set(Object.keys(QueryDocumentKeys)); +/** + * @internal + */ + +function isNode(maybeNode) { + const maybeKind = + maybeNode === null || maybeNode === void 0 ? void 0 : maybeNode.kind; + return typeof maybeKind === 'string' && kindValues.has(maybeKind); +} +/** Name */ + +var OperationTypeNode; + +(function (OperationTypeNode) { + OperationTypeNode['QUERY'] = 'query'; + OperationTypeNode['MUTATION'] = 'mutation'; + OperationTypeNode['SUBSCRIPTION'] = 'subscription'; +})(OperationTypeNode || (OperationTypeNode = {})); + + + + +/***/ }), + +/***/ 7392: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "LZ": () => (/* binding */ printBlockString), +/* harmony export */ "MZ": () => (/* binding */ isPrintableAsBlockString), +/* harmony export */ "wv": () => (/* binding */ dedentBlockStringLines) +/* harmony export */ }); +/* harmony import */ var _characterClasses_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8297); + +/** + * Produces the value of a block string from its parsed raw value, similar to + * CoffeeScript's block string, Python's docstring trim or Ruby's strip_heredoc. + * + * This implements the GraphQL spec's BlockStringValue() static algorithm. + * + * @internal + */ + +function dedentBlockStringLines(lines) { + var _firstNonEmptyLine2; + + let commonIndent = Number.MAX_SAFE_INTEGER; + let firstNonEmptyLine = null; + let lastNonEmptyLine = -1; + + for (let i = 0; i < lines.length; ++i) { + var _firstNonEmptyLine; + + const line = lines[i]; + const indent = leadingWhitespace(line); + + if (indent === line.length) { + continue; // skip empty lines + } + + firstNonEmptyLine = + (_firstNonEmptyLine = firstNonEmptyLine) !== null && + _firstNonEmptyLine !== void 0 + ? _firstNonEmptyLine + : i; + lastNonEmptyLine = i; + + if (i !== 0 && indent < commonIndent) { + commonIndent = indent; + } + } + + return lines // Remove common indentation from all lines but first. + .map((line, i) => (i === 0 ? line : line.slice(commonIndent))) // Remove leading and trailing blank lines. + .slice( + (_firstNonEmptyLine2 = firstNonEmptyLine) !== null && + _firstNonEmptyLine2 !== void 0 + ? _firstNonEmptyLine2 + : 0, + lastNonEmptyLine + 1, + ); +} + +function leadingWhitespace(str) { + let i = 0; + + while (i < str.length && (0,_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isWhiteSpace */ .FD)(str.charCodeAt(i))) { + ++i; + } + + return i; +} +/** + * @internal + */ + +function isPrintableAsBlockString(value) { + if (value === '') { + return true; // empty string is printable + } + + let isEmptyLine = true; + let hasIndent = false; + let hasCommonIndent = true; + let seenNonEmptyLine = false; + + for (let i = 0; i < value.length; ++i) { + switch (value.codePointAt(i)) { + case 0x0000: + case 0x0001: + case 0x0002: + case 0x0003: + case 0x0004: + case 0x0005: + case 0x0006: + case 0x0007: + case 0x0008: + case 0x000b: + case 0x000c: + case 0x000e: + case 0x000f: + return false; + // Has non-printable characters + + case 0x000d: + // \r + return false; + // Has \r or \r\n which will be replaced as \n + + case 10: + // \n + if (isEmptyLine && !seenNonEmptyLine) { + return false; // Has leading new line + } + + seenNonEmptyLine = true; + isEmptyLine = true; + hasIndent = false; + break; + + case 9: // \t + + case 32: + // + hasIndent || (hasIndent = isEmptyLine); + break; + + default: + hasCommonIndent && (hasCommonIndent = hasIndent); + isEmptyLine = false; + } + } + + if (isEmptyLine) { + return false; // Has trailing empty lines + } + + if (hasCommonIndent && seenNonEmptyLine) { + return false; // Has internal indent + } + + return true; +} +/** + * Print a block string in the indented block form by adding a leading and + * trailing blank line. However, if a block string starts with whitespace and is + * a single-line, adding a leading blank line would strip that whitespace. + * + * @internal + */ + +function printBlockString(value, options) { + const escapedValue = value.replace(/"""/g, '\\"""'); // Expand a block string's raw value into independent lines. + + const lines = escapedValue.split(/\r\n|[\n\r]/g); + const isSingleLine = lines.length === 1; // If common indentation is found we can fix some of those cases by adding leading new line + + const forceLeadingNewLine = + lines.length > 1 && + lines + .slice(1) + .every((line) => line.length === 0 || (0,_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isWhiteSpace */ .FD)(line.charCodeAt(0))); // Trailing triple quotes just looks confusing but doesn't force trailing new line + + const hasTrailingTripleQuotes = escapedValue.endsWith('\\"""'); // Trailing quote (single or double) or slash forces trailing new line + + const hasTrailingQuote = value.endsWith('"') && !hasTrailingTripleQuotes; + const hasTrailingSlash = value.endsWith('\\'); + const forceTrailingNewline = hasTrailingQuote || hasTrailingSlash; + const printAsMultipleLines = + !(options !== null && options !== void 0 && options.minimize) && // add leading and trailing new lines only if it improves readability + (!isSingleLine || + value.length > 70 || + forceTrailingNewline || + forceLeadingNewLine || + hasTrailingTripleQuotes); + let result = ''; // Format a multi-line block quote to account for leading space. + + const skipLeadingNewLine = isSingleLine && (0,_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isWhiteSpace */ .FD)(value.charCodeAt(0)); + + if ((printAsMultipleLines && !skipLeadingNewLine) || forceLeadingNewLine) { + result += '\n'; + } + + result += escapedValue; + + if (printAsMultipleLines || forceTrailingNewline) { + result += '\n'; + } + + return '"""' + result + '"""'; +} + + +/***/ }), + +/***/ 8297: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "FD": () => (/* binding */ isWhiteSpace), +/* harmony export */ "HQ": () => (/* binding */ isNameContinue), +/* harmony export */ "LQ": () => (/* binding */ isNameStart), +/* harmony export */ "X1": () => (/* binding */ isDigit) +/* harmony export */ }); +/* unused harmony export isLetter */ +/** + * ``` + * WhiteSpace :: + * - "Horizontal Tab (U+0009)" + * - "Space (U+0020)" + * ``` + * @internal + */ +function isWhiteSpace(code) { + return code === 0x0009 || code === 0x0020; +} +/** + * ``` + * Digit :: one of + * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + * ``` + * @internal + */ + +function isDigit(code) { + return code >= 0x0030 && code <= 0x0039; +} +/** + * ``` + * Letter :: one of + * - `A` `B` `C` `D` `E` `F` `G` `H` `I` `J` `K` `L` `M` + * - `N` `O` `P` `Q` `R` `S` `T` `U` `V` `W` `X` `Y` `Z` + * - `a` `b` `c` `d` `e` `f` `g` `h` `i` `j` `k` `l` `m` + * - `n` `o` `p` `q` `r` `s` `t` `u` `v` `w` `x` `y` `z` + * ``` + * @internal + */ + +function isLetter(code) { + return ( + (code >= 0x0061 && code <= 0x007a) || // A-Z + (code >= 0x0041 && code <= 0x005a) // a-z + ); +} +/** + * ``` + * NameStart :: + * - Letter + * - `_` + * ``` + * @internal + */ + +function isNameStart(code) { + return isLetter(code) || code === 0x005f; +} +/** + * ``` + * NameContinue :: + * - Letter + * - Digit + * - `_` + * ``` + * @internal + */ + +function isNameContinue(code) { + return isLetter(code) || isDigit(code) || code === 0x005f; +} + + +/***/ }), + +/***/ 9878: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "B": () => (/* binding */ DirectiveLocation) +/* harmony export */ }); +/** + * The set of allowed directive location values. + */ +var DirectiveLocation; + +(function (DirectiveLocation) { + DirectiveLocation['QUERY'] = 'QUERY'; + DirectiveLocation['MUTATION'] = 'MUTATION'; + DirectiveLocation['SUBSCRIPTION'] = 'SUBSCRIPTION'; + DirectiveLocation['FIELD'] = 'FIELD'; + DirectiveLocation['FRAGMENT_DEFINITION'] = 'FRAGMENT_DEFINITION'; + DirectiveLocation['FRAGMENT_SPREAD'] = 'FRAGMENT_SPREAD'; + DirectiveLocation['INLINE_FRAGMENT'] = 'INLINE_FRAGMENT'; + DirectiveLocation['VARIABLE_DEFINITION'] = 'VARIABLE_DEFINITION'; + DirectiveLocation['SCHEMA'] = 'SCHEMA'; + DirectiveLocation['SCALAR'] = 'SCALAR'; + DirectiveLocation['OBJECT'] = 'OBJECT'; + DirectiveLocation['FIELD_DEFINITION'] = 'FIELD_DEFINITION'; + DirectiveLocation['ARGUMENT_DEFINITION'] = 'ARGUMENT_DEFINITION'; + DirectiveLocation['INTERFACE'] = 'INTERFACE'; + DirectiveLocation['UNION'] = 'UNION'; + DirectiveLocation['ENUM'] = 'ENUM'; + DirectiveLocation['ENUM_VALUE'] = 'ENUM_VALUE'; + DirectiveLocation['INPUT_OBJECT'] = 'INPUT_OBJECT'; + DirectiveLocation['INPUT_FIELD_DEFINITION'] = 'INPUT_FIELD_DEFINITION'; +})(DirectiveLocation || (DirectiveLocation = {})); + + +/** + * The enum type representing the directive location values. + * + * @deprecated Please use `DirectiveLocation`. Will be remove in v17. + */ + + +/***/ }), + +/***/ 7359: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "h": () => (/* binding */ Kind) +/* harmony export */ }); +/** + * The set of allowed kind values for AST nodes. + */ +var Kind; + +(function (Kind) { + Kind['NAME'] = 'Name'; + Kind['DOCUMENT'] = 'Document'; + Kind['OPERATION_DEFINITION'] = 'OperationDefinition'; + Kind['VARIABLE_DEFINITION'] = 'VariableDefinition'; + Kind['SELECTION_SET'] = 'SelectionSet'; + Kind['FIELD'] = 'Field'; + Kind['ARGUMENT'] = 'Argument'; + Kind['FRAGMENT_SPREAD'] = 'FragmentSpread'; + Kind['INLINE_FRAGMENT'] = 'InlineFragment'; + Kind['FRAGMENT_DEFINITION'] = 'FragmentDefinition'; + Kind['VARIABLE'] = 'Variable'; + Kind['INT'] = 'IntValue'; + Kind['FLOAT'] = 'FloatValue'; + Kind['STRING'] = 'StringValue'; + Kind['BOOLEAN'] = 'BooleanValue'; + Kind['NULL'] = 'NullValue'; + Kind['ENUM'] = 'EnumValue'; + Kind['LIST'] = 'ListValue'; + Kind['OBJECT'] = 'ObjectValue'; + Kind['OBJECT_FIELD'] = 'ObjectField'; + Kind['DIRECTIVE'] = 'Directive'; + Kind['NAMED_TYPE'] = 'NamedType'; + Kind['LIST_TYPE'] = 'ListType'; + Kind['NON_NULL_TYPE'] = 'NonNullType'; + Kind['SCHEMA_DEFINITION'] = 'SchemaDefinition'; + Kind['OPERATION_TYPE_DEFINITION'] = 'OperationTypeDefinition'; + Kind['SCALAR_TYPE_DEFINITION'] = 'ScalarTypeDefinition'; + Kind['OBJECT_TYPE_DEFINITION'] = 'ObjectTypeDefinition'; + Kind['FIELD_DEFINITION'] = 'FieldDefinition'; + Kind['INPUT_VALUE_DEFINITION'] = 'InputValueDefinition'; + Kind['INTERFACE_TYPE_DEFINITION'] = 'InterfaceTypeDefinition'; + Kind['UNION_TYPE_DEFINITION'] = 'UnionTypeDefinition'; + Kind['ENUM_TYPE_DEFINITION'] = 'EnumTypeDefinition'; + Kind['ENUM_VALUE_DEFINITION'] = 'EnumValueDefinition'; + Kind['INPUT_OBJECT_TYPE_DEFINITION'] = 'InputObjectTypeDefinition'; + Kind['DIRECTIVE_DEFINITION'] = 'DirectiveDefinition'; + Kind['SCHEMA_EXTENSION'] = 'SchemaExtension'; + Kind['SCALAR_TYPE_EXTENSION'] = 'ScalarTypeExtension'; + Kind['OBJECT_TYPE_EXTENSION'] = 'ObjectTypeExtension'; + Kind['INTERFACE_TYPE_EXTENSION'] = 'InterfaceTypeExtension'; + Kind['UNION_TYPE_EXTENSION'] = 'UnionTypeExtension'; + Kind['ENUM_TYPE_EXTENSION'] = 'EnumTypeExtension'; + Kind['INPUT_OBJECT_TYPE_EXTENSION'] = 'InputObjectTypeExtension'; +})(Kind || (Kind = {})); + + +/** + * The enum type representing the possible kind values of AST nodes. + * + * @deprecated Please use `Kind`. Will be remove in v17. + */ + + +/***/ }), + +/***/ 2105: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "h": () => (/* binding */ Lexer), +/* harmony export */ "u": () => (/* binding */ isPunctuatorTokenKind) +/* harmony export */ }); +/* harmony import */ var _error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5219); +/* harmony import */ var _ast_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2380); +/* harmony import */ var _blockString_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7392); +/* harmony import */ var _characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8297); +/* harmony import */ var _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4635); + + + + + +/** + * Given a Source object, creates a Lexer for that source. + * A Lexer is a stateful stream generator in that every time + * it is advanced, it returns the next token in the Source. Assuming the + * source lexes, the final Token emitted by the lexer will be of kind + * EOF, after which the lexer will repeatedly return the same EOF token + * whenever called. + */ + +class Lexer { + /** + * The previously focused non-ignored token. + */ + + /** + * The currently focused non-ignored token. + */ + + /** + * The (1-indexed) line containing the current token. + */ + + /** + * The character offset at which the current line begins. + */ + constructor(source) { + const startOfFileToken = new _ast_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Token */ .WU(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.SOF */ .T.SOF, 0, 0, 0, 0); + this.source = source; + this.lastToken = startOfFileToken; + this.token = startOfFileToken; + this.line = 1; + this.lineStart = 0; + } + + get [Symbol.toStringTag]() { + return 'Lexer'; + } + /** + * Advances the token stream to the next non-ignored token. + */ + + advance() { + this.lastToken = this.token; + const token = (this.token = this.lookahead()); + return token; + } + /** + * Looks ahead and returns the next non-ignored token, but does not change + * the state of Lexer. + */ + + lookahead() { + let token = this.token; + + if (token.kind !== _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.EOF */ .T.EOF) { + do { + if (token.next) { + token = token.next; + } else { + // Read the next token and form a link in the token linked-list. + const nextToken = readNextToken(this, token.end); // @ts-expect-error next is only mutable during parsing. + + token.next = nextToken; // @ts-expect-error prev is only mutable during parsing. + + nextToken.prev = token; + token = nextToken; + } + } while (token.kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.COMMENT */ .T.COMMENT); + } + + return token; + } +} +/** + * @internal + */ + +function isPunctuatorTokenKind(kind) { + return ( + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BANG */ .T.BANG || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.DOLLAR */ .T.DOLLAR || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.AMP */ .T.AMP || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.PAREN_L */ .T.PAREN_L || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.PAREN_R */ .T.PAREN_R || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.SPREAD */ .T.SPREAD || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.COLON */ .T.COLON || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.EQUALS */ .T.EQUALS || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.AT */ .T.AT || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BRACKET_L */ .T.BRACKET_L || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BRACKET_R */ .T.BRACKET_R || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BRACE_L */ .T.BRACE_L || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.PIPE */ .T.PIPE || + kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BRACE_R */ .T.BRACE_R + ); +} +/** + * A Unicode scalar value is any Unicode code point except surrogate code + * points. In other words, the inclusive ranges of values 0x0000 to 0xD7FF and + * 0xE000 to 0x10FFFF. + * + * SourceCharacter :: + * - "Any Unicode scalar value" + */ + +function isUnicodeScalarValue(code) { + return ( + (code >= 0x0000 && code <= 0xd7ff) || (code >= 0xe000 && code <= 0x10ffff) + ); +} +/** + * The GraphQL specification defines source text as a sequence of unicode scalar + * values (which Unicode defines to exclude surrogate code points). However + * JavaScript defines strings as a sequence of UTF-16 code units which may + * include surrogates. A surrogate pair is a valid source character as it + * encodes a supplementary code point (above U+FFFF), but unpaired surrogate + * code points are not valid source characters. + */ + +function isSupplementaryCodePoint(body, location) { + return ( + isLeadingSurrogate(body.charCodeAt(location)) && + isTrailingSurrogate(body.charCodeAt(location + 1)) + ); +} + +function isLeadingSurrogate(code) { + return code >= 0xd800 && code <= 0xdbff; +} + +function isTrailingSurrogate(code) { + return code >= 0xdc00 && code <= 0xdfff; +} +/** + * Prints the code point (or end of file reference) at a given location in a + * source for use in error messages. + * + * Printable ASCII is printed quoted, while other points are printed in Unicode + * code point form (ie. U+1234). + */ + +function printCodePointAt(lexer, location) { + const code = lexer.source.body.codePointAt(location); + + if (code === undefined) { + return _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.EOF */ .T.EOF; + } else if (code >= 0x0020 && code <= 0x007e) { + // Printable ASCII + const char = String.fromCodePoint(code); + return char === '"' ? "'\"'" : `"${char}"`; + } // Unicode code point + + return 'U+' + code.toString(16).toUpperCase().padStart(4, '0'); +} +/** + * Create a token with line and column location information. + */ + +function createToken(lexer, kind, start, end, value) { + const line = lexer.line; + const col = 1 + start - lexer.lineStart; + return new _ast_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Token */ .WU(kind, start, end, line, col, value); +} +/** + * Gets the next token from the source starting at the given position. + * + * This skips over whitespace until it finds the next lexable token, then lexes + * punctuators immediately or calls the appropriate helper function for more + * complicated tokens. + */ + +function readNextToken(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start; + + while (position < bodyLength) { + const code = body.charCodeAt(position); // SourceCharacter + + switch (code) { + // Ignored :: + // - UnicodeBOM + // - WhiteSpace + // - LineTerminator + // - Comment + // - Comma + // + // UnicodeBOM :: "Byte Order Mark (U+FEFF)" + // + // WhiteSpace :: + // - "Horizontal Tab (U+0009)" + // - "Space (U+0020)" + // + // Comma :: , + case 0xfeff: // + + case 0x0009: // \t + + case 0x0020: // + + case 0x002c: + // , + ++position; + continue; + // LineTerminator :: + // - "New Line (U+000A)" + // - "Carriage Return (U+000D)" [lookahead != "New Line (U+000A)"] + // - "Carriage Return (U+000D)" "New Line (U+000A)" + + case 0x000a: + // \n + ++position; + ++lexer.line; + lexer.lineStart = position; + continue; + + case 0x000d: + // \r + if (body.charCodeAt(position + 1) === 0x000a) { + position += 2; + } else { + ++position; + } + + ++lexer.line; + lexer.lineStart = position; + continue; + // Comment + + case 0x0023: + // # + return readComment(lexer, position); + // Token :: + // - Punctuator + // - Name + // - IntValue + // - FloatValue + // - StringValue + // + // Punctuator :: one of ! $ & ( ) ... : = @ [ ] { | } + + case 0x0021: + // ! + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BANG */ .T.BANG, position, position + 1); + + case 0x0024: + // $ + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.DOLLAR */ .T.DOLLAR, position, position + 1); + + case 0x0026: + // & + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.AMP */ .T.AMP, position, position + 1); + + case 0x0028: + // ( + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.PAREN_L */ .T.PAREN_L, position, position + 1); + + case 0x0029: + // ) + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.PAREN_R */ .T.PAREN_R, position, position + 1); + + case 0x002e: + // . + if ( + body.charCodeAt(position + 1) === 0x002e && + body.charCodeAt(position + 2) === 0x002e + ) { + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.SPREAD */ .T.SPREAD, position, position + 3); + } + + break; + + case 0x003a: + // : + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.COLON */ .T.COLON, position, position + 1); + + case 0x003d: + // = + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.EQUALS */ .T.EQUALS, position, position + 1); + + case 0x0040: + // @ + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.AT */ .T.AT, position, position + 1); + + case 0x005b: + // [ + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BRACKET_L */ .T.BRACKET_L, position, position + 1); + + case 0x005d: + // ] + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BRACKET_R */ .T.BRACKET_R, position, position + 1); + + case 0x007b: + // { + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BRACE_L */ .T.BRACE_L, position, position + 1); + + case 0x007c: + // | + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.PIPE */ .T.PIPE, position, position + 1); + + case 0x007d: + // } + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BRACE_R */ .T.BRACE_R, position, position + 1); + // StringValue + + case 0x0022: + // " + if ( + body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022 + ) { + return readBlockString(lexer, position); + } + + return readString(lexer, position); + } // IntValue | FloatValue (Digit | -) + + if ((0,_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isDigit */ .X1)(code) || code === 0x002d) { + return readNumber(lexer, position, code); + } // Name + + if ((0,_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNameStart */ .LQ)(code)) { + return readName(lexer, position); + } + + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)( + lexer.source, + position, + code === 0x0027 + ? 'Unexpected single quote character (\'), did you mean to use a double quote (")?' + : isUnicodeScalarValue(code) || isSupplementaryCodePoint(body, position) + ? `Unexpected character: ${printCodePointAt(lexer, position)}.` + : `Invalid character: ${printCodePointAt(lexer, position)}.`, + ); + } + + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.EOF */ .T.EOF, bodyLength, bodyLength); +} +/** + * Reads a comment token from the source file. + * + * ``` + * Comment :: # CommentChar* [lookahead != CommentChar] + * + * CommentChar :: SourceCharacter but not LineTerminator + * ``` + */ + +function readComment(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + + while (position < bodyLength) { + const code = body.charCodeAt(position); // LineTerminator (\n | \r) + + if (code === 0x000a || code === 0x000d) { + break; + } // SourceCharacter + + if (isUnicodeScalarValue(code)) { + ++position; + } else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } else { + break; + } + } + + return createToken( + lexer, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.COMMENT */ .T.COMMENT, + start, + position, + body.slice(start + 1, position), + ); +} +/** + * Reads a number token from the source file, either a FloatValue or an IntValue + * depending on whether a FractionalPart or ExponentPart is encountered. + * + * ``` + * IntValue :: IntegerPart [lookahead != {Digit, `.`, NameStart}] + * + * IntegerPart :: + * - NegativeSign? 0 + * - NegativeSign? NonZeroDigit Digit* + * + * NegativeSign :: - + * + * NonZeroDigit :: Digit but not `0` + * + * FloatValue :: + * - IntegerPart FractionalPart ExponentPart [lookahead != {Digit, `.`, NameStart}] + * - IntegerPart FractionalPart [lookahead != {Digit, `.`, NameStart}] + * - IntegerPart ExponentPart [lookahead != {Digit, `.`, NameStart}] + * + * FractionalPart :: . Digit+ + * + * ExponentPart :: ExponentIndicator Sign? Digit+ + * + * ExponentIndicator :: one of `e` `E` + * + * Sign :: one of + - + * ``` + */ + +function readNumber(lexer, start, firstCode) { + const body = lexer.source.body; + let position = start; + let code = firstCode; + let isFloat = false; // NegativeSign (-) + + if (code === 0x002d) { + code = body.charCodeAt(++position); + } // Zero (0) + + if (code === 0x0030) { + code = body.charCodeAt(++position); + + if ((0,_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isDigit */ .X1)(code)) { + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)( + lexer.source, + position, + `Invalid number, unexpected digit after 0: ${printCodePointAt( + lexer, + position, + )}.`, + ); + } + } else { + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } // Full stop (.) + + if (code === 0x002e) { + isFloat = true; + code = body.charCodeAt(++position); + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } // E e + + if (code === 0x0045 || code === 0x0065) { + isFloat = true; + code = body.charCodeAt(++position); // + - + + if (code === 0x002b || code === 0x002d) { + code = body.charCodeAt(++position); + } + + position = readDigits(lexer, position, code); + code = body.charCodeAt(position); + } // Numbers cannot be followed by . or NameStart + + if (code === 0x002e || (0,_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNameStart */ .LQ)(code)) { + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)( + lexer.source, + position, + `Invalid number, expected digit but got: ${printCodePointAt( + lexer, + position, + )}.`, + ); + } + + return createToken( + lexer, + isFloat ? _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.FLOAT */ .T.FLOAT : _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.INT */ .T.INT, + start, + position, + body.slice(start, position), + ); +} +/** + * Returns the new position in the source after reading one or more digits. + */ + +function readDigits(lexer, start, firstCode) { + if (!(0,_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isDigit */ .X1)(firstCode)) { + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)( + lexer.source, + start, + `Invalid number, expected digit but got: ${printCodePointAt( + lexer, + start, + )}.`, + ); + } + + const body = lexer.source.body; + let position = start + 1; // +1 to skip first firstCode + + while ((0,_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isDigit */ .X1)(body.charCodeAt(position))) { + ++position; + } + + return position; +} +/** + * Reads a single-quote string token from the source file. + * + * ``` + * StringValue :: + * - `""` [lookahead != `"`] + * - `"` StringCharacter+ `"` + * + * StringCharacter :: + * - SourceCharacter but not `"` or `\` or LineTerminator + * - `\u` EscapedUnicode + * - `\` EscapedCharacter + * + * EscapedUnicode :: + * - `{` HexDigit+ `}` + * - HexDigit HexDigit HexDigit HexDigit + * + * EscapedCharacter :: one of `"` `\` `/` `b` `f` `n` `r` `t` + * ``` + */ + +function readString(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + let chunkStart = position; + let value = ''; + + while (position < bodyLength) { + const code = body.charCodeAt(position); // Closing Quote (") + + if (code === 0x0022) { + value += body.slice(chunkStart, position); + return createToken(lexer, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.STRING */ .T.STRING, start, position + 1, value); + } // Escape Sequence (\) + + if (code === 0x005c) { + value += body.slice(chunkStart, position); + const escape = + body.charCodeAt(position + 1) === 0x0075 // u + ? body.charCodeAt(position + 2) === 0x007b // { + ? readEscapedUnicodeVariableWidth(lexer, position) + : readEscapedUnicodeFixedWidth(lexer, position) + : readEscapedCharacter(lexer, position); + value += escape.value; + position += escape.size; + chunkStart = position; + continue; + } // LineTerminator (\n | \r) + + if (code === 0x000a || code === 0x000d) { + break; + } // SourceCharacter + + if (isUnicodeScalarValue(code)) { + ++position; + } else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } else { + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)( + lexer.source, + position, + `Invalid character within String: ${printCodePointAt( + lexer, + position, + )}.`, + ); + } + } + + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)(lexer.source, position, 'Unterminated string.'); +} // The string value and lexed size of an escape sequence. + +function readEscapedUnicodeVariableWidth(lexer, position) { + const body = lexer.source.body; + let point = 0; + let size = 3; // Cannot be larger than 12 chars (\u{00000000}). + + while (size < 12) { + const code = body.charCodeAt(position + size++); // Closing Brace (}) + + if (code === 0x007d) { + // Must be at least 5 chars (\u{0}) and encode a Unicode scalar value. + if (size < 5 || !isUnicodeScalarValue(point)) { + break; + } + + return { + value: String.fromCodePoint(point), + size, + }; + } // Append this hex digit to the code point. + + point = (point << 4) | readHexDigit(code); + + if (point < 0) { + break; + } + } + + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)( + lexer.source, + position, + `Invalid Unicode escape sequence: "${body.slice( + position, + position + size, + )}".`, + ); +} + +function readEscapedUnicodeFixedWidth(lexer, position) { + const body = lexer.source.body; + const code = read16BitHexCode(body, position + 2); + + if (isUnicodeScalarValue(code)) { + return { + value: String.fromCodePoint(code), + size: 6, + }; + } // GraphQL allows JSON-style surrogate pair escape sequences, but only when + // a valid pair is formed. + + if (isLeadingSurrogate(code)) { + // \u + if ( + body.charCodeAt(position + 6) === 0x005c && + body.charCodeAt(position + 7) === 0x0075 + ) { + const trailingCode = read16BitHexCode(body, position + 8); + + if (isTrailingSurrogate(trailingCode)) { + // JavaScript defines strings as a sequence of UTF-16 code units and + // encodes Unicode code points above U+FFFF using a surrogate pair of + // code units. Since this is a surrogate pair escape sequence, just + // include both codes into the JavaScript string value. Had JavaScript + // not been internally based on UTF-16, then this surrogate pair would + // be decoded to retrieve the supplementary code point. + return { + value: String.fromCodePoint(code, trailingCode), + size: 12, + }; + } + } + } + + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)( + lexer.source, + position, + `Invalid Unicode escape sequence: "${body.slice(position, position + 6)}".`, + ); +} +/** + * Reads four hexadecimal characters and returns the positive integer that 16bit + * hexadecimal string represents. For example, "000f" will return 15, and "dead" + * will return 57005. + * + * Returns a negative number if any char was not a valid hexadecimal digit. + */ + +function read16BitHexCode(body, position) { + // readHexDigit() returns -1 on error. ORing a negative value with any other + // value always produces a negative value. + return ( + (readHexDigit(body.charCodeAt(position)) << 12) | + (readHexDigit(body.charCodeAt(position + 1)) << 8) | + (readHexDigit(body.charCodeAt(position + 2)) << 4) | + readHexDigit(body.charCodeAt(position + 3)) + ); +} +/** + * Reads a hexadecimal character and returns its positive integer value (0-15). + * + * '0' becomes 0, '9' becomes 9 + * 'A' becomes 10, 'F' becomes 15 + * 'a' becomes 10, 'f' becomes 15 + * + * Returns -1 if the provided character code was not a valid hexadecimal digit. + * + * HexDigit :: one of + * - `0` `1` `2` `3` `4` `5` `6` `7` `8` `9` + * - `A` `B` `C` `D` `E` `F` + * - `a` `b` `c` `d` `e` `f` + */ + +function readHexDigit(code) { + return code >= 0x0030 && code <= 0x0039 // 0-9 + ? code - 0x0030 + : code >= 0x0041 && code <= 0x0046 // A-F + ? code - 0x0037 + : code >= 0x0061 && code <= 0x0066 // a-f + ? code - 0x0057 + : -1; +} +/** + * | Escaped Character | Code Point | Character Name | + * | ----------------- | ---------- | ---------------------------- | + * | `"` | U+0022 | double quote | + * | `\` | U+005C | reverse solidus (back slash) | + * | `/` | U+002F | solidus (forward slash) | + * | `b` | U+0008 | backspace | + * | `f` | U+000C | form feed | + * | `n` | U+000A | line feed (new line) | + * | `r` | U+000D | carriage return | + * | `t` | U+0009 | horizontal tab | + */ + +function readEscapedCharacter(lexer, position) { + const body = lexer.source.body; + const code = body.charCodeAt(position + 1); + + switch (code) { + case 0x0022: + // " + return { + value: '\u0022', + size: 2, + }; + + case 0x005c: + // \ + return { + value: '\u005c', + size: 2, + }; + + case 0x002f: + // / + return { + value: '\u002f', + size: 2, + }; + + case 0x0062: + // b + return { + value: '\u0008', + size: 2, + }; + + case 0x0066: + // f + return { + value: '\u000c', + size: 2, + }; + + case 0x006e: + // n + return { + value: '\u000a', + size: 2, + }; + + case 0x0072: + // r + return { + value: '\u000d', + size: 2, + }; + + case 0x0074: + // t + return { + value: '\u0009', + size: 2, + }; + } + + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)( + lexer.source, + position, + `Invalid character escape sequence: "${body.slice( + position, + position + 2, + )}".`, + ); +} +/** + * Reads a block string token from the source file. + * + * ``` + * StringValue :: + * - `"""` BlockStringCharacter* `"""` + * + * BlockStringCharacter :: + * - SourceCharacter but not `"""` or `\"""` + * - `\"""` + * ``` + */ + +function readBlockString(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let lineStart = lexer.lineStart; + let position = start + 3; + let chunkStart = position; + let currentLine = ''; + const blockLines = []; + + while (position < bodyLength) { + const code = body.charCodeAt(position); // Closing Triple-Quote (""") + + if ( + code === 0x0022 && + body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022 + ) { + currentLine += body.slice(chunkStart, position); + blockLines.push(currentLine); + const token = createToken( + lexer, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.BLOCK_STRING */ .T.BLOCK_STRING, + start, + position + 3, // Return a string of the lines joined with U+000A. + (0,_blockString_mjs__WEBPACK_IMPORTED_MODULE_4__/* .dedentBlockStringLines */ .wv)(blockLines).join('\n'), + ); + lexer.line += blockLines.length - 1; + lexer.lineStart = lineStart; + return token; + } // Escaped Triple-Quote (\""") + + if ( + code === 0x005c && + body.charCodeAt(position + 1) === 0x0022 && + body.charCodeAt(position + 2) === 0x0022 && + body.charCodeAt(position + 3) === 0x0022 + ) { + currentLine += body.slice(chunkStart, position); + chunkStart = position + 1; // skip only slash + + position += 4; + continue; + } // LineTerminator + + if (code === 0x000a || code === 0x000d) { + currentLine += body.slice(chunkStart, position); + blockLines.push(currentLine); + + if (code === 0x000d && body.charCodeAt(position + 1) === 0x000a) { + position += 2; + } else { + ++position; + } + + currentLine = ''; + chunkStart = position; + lineStart = position; + continue; + } // SourceCharacter + + if (isUnicodeScalarValue(code)) { + ++position; + } else if (isSupplementaryCodePoint(body, position)) { + position += 2; + } else { + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)( + lexer.source, + position, + `Invalid character within String: ${printCodePointAt( + lexer, + position, + )}.`, + ); + } + } + + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .syntaxError */ .h)(lexer.source, position, 'Unterminated string.'); +} +/** + * Reads an alphanumeric + underscore name from the source. + * + * ``` + * Name :: + * - NameStart NameContinue* [lookahead != NameContinue] + * ``` + */ + +function readName(lexer, start) { + const body = lexer.source.body; + const bodyLength = body.length; + let position = start + 1; + + while (position < bodyLength) { + const code = body.charCodeAt(position); + + if ((0,_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNameContinue */ .HQ)(code)) { + ++position; + } else { + break; + } + } + + return createToken( + lexer, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TokenKind.NAME */ .T.NAME, + start, + position, + body.slice(start, position), + ); +} + + +/***/ }), + +/***/ 7867: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "k": () => (/* binding */ getLocation) +/* harmony export */ }); +/* harmony import */ var _jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9551); + +const LineRegExp = /\r\n|[\n\r]/g; +/** + * Represents a location in a Source. + */ + +/** + * Takes a Source and a UTF-8 character offset, and returns the corresponding + * line and column as a SourceLocation. + */ +function getLocation(source, position) { + let lastLineStart = 0; + let line = 1; + + for (const match of source.body.matchAll(LineRegExp)) { + typeof match.index === 'number' || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_0__/* .invariant */ .k)(false); + + if (match.index >= position) { + break; + } + + lastLineStart = match.index + match[0].length; + line += 1; + } + + return { + line, + column: position + 1 - lastLineStart, + }; +} + + +/***/ }), + +/***/ 4275: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "H2": () => (/* binding */ parseValue), +/* harmony export */ "Qc": () => (/* binding */ parse), +/* harmony export */ "gZ": () => (/* binding */ parseType), +/* harmony export */ "tl": () => (/* binding */ parseConstValue) +/* harmony export */ }); +/* unused harmony export Parser */ +/* harmony import */ var _error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5219); +/* harmony import */ var _ast_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2380); +/* harmony import */ var _directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9878); +/* harmony import */ var _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7359); +/* harmony import */ var _lexer_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(2105); +/* harmony import */ var _source_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7926); +/* harmony import */ var _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4635); + + + + + + + +/** + * Configuration options to control parser behavior + */ + +/** + * Given a GraphQL source, parses it into a Document. + * Throws GraphQLError if a syntax error is encountered. + */ +function parse(source, options) { + const parser = new Parser(source, options); + return parser.parseDocument(); +} +/** + * Given a string containing a GraphQL value (ex. `[42]`), parse the AST for + * that value. + * Throws GraphQLError if a syntax error is encountered. + * + * This is useful within tools that operate upon GraphQL Values directly and + * in isolation of complete GraphQL documents. + * + * Consider providing the results to the utility function: valueFromAST(). + */ + +function parseValue(source, options) { + const parser = new Parser(source, options); + parser.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.SOF */ .T.SOF); + const value = parser.parseValueLiteral(false); + parser.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.EOF */ .T.EOF); + return value; +} +/** + * Similar to parseValue(), but raises a parse error if it encounters a + * variable. The return type will be a constant value. + */ + +function parseConstValue(source, options) { + const parser = new Parser(source, options); + parser.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.SOF */ .T.SOF); + const value = parser.parseConstValueLiteral(); + parser.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.EOF */ .T.EOF); + return value; +} +/** + * Given a string containing a GraphQL Type (ex. `[Int!]`), parse the AST for + * that type. + * Throws GraphQLError if a syntax error is encountered. + * + * This is useful within tools that operate upon GraphQL Types directly and + * in isolation of complete GraphQL documents. + * + * Consider providing the results to the utility function: typeFromAST(). + */ + +function parseType(source, options) { + const parser = new Parser(source, options); + parser.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.SOF */ .T.SOF); + const type = parser.parseTypeReference(); + parser.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.EOF */ .T.EOF); + return type; +} +/** + * This class is exported only to assist people in implementing their own parsers + * without duplicating too much code and should be used only as last resort for cases + * such as experimental syntax or if certain features could not be contributed upstream. + * + * It is still part of the internal API and is versioned, so any changes to it are never + * considered breaking changes. If you still need to support multiple versions of the + * library, please use the `versionInfo` variable for version detection. + * + * @internal + */ + +class Parser { + constructor(source, options = {}) { + const sourceObj = (0,_source_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isSource */ .T)(source) ? source : new _source_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Source */ .H(source); + this._lexer = new _lexer_mjs__WEBPACK_IMPORTED_MODULE_2__/* .Lexer */ .h(sourceObj); + this._options = options; + this._tokenCounter = 0; + } + /** + * Converts a name lex token into a name parse node. + */ + + parseName() { + const token = this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.NAME */ .T.NAME); + return this.node(token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.NAME */ .h.NAME, + value: token.value, + }); + } // Implements the parsing rules in the Document section. + + /** + * Document : Definition+ + */ + + parseDocument() { + return this.node(this._lexer.token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.DOCUMENT */ .h.DOCUMENT, + definitions: this.many( + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.SOF */ .T.SOF, + this.parseDefinition, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.EOF */ .T.EOF, + ), + }); + } + /** + * Definition : + * - ExecutableDefinition + * - TypeSystemDefinition + * - TypeSystemExtension + * + * ExecutableDefinition : + * - OperationDefinition + * - FragmentDefinition + * + * TypeSystemDefinition : + * - SchemaDefinition + * - TypeDefinition + * - DirectiveDefinition + * + * TypeDefinition : + * - ScalarTypeDefinition + * - ObjectTypeDefinition + * - InterfaceTypeDefinition + * - UnionTypeDefinition + * - EnumTypeDefinition + * - InputObjectTypeDefinition + */ + + parseDefinition() { + if (this.peek(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L)) { + return this.parseOperationDefinition(); + } // Many definitions begin with a description and require a lookahead. + + const hasDescription = this.peekDescription(); + const keywordToken = hasDescription + ? this._lexer.lookahead() + : this._lexer.token; + + if (keywordToken.kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.NAME */ .T.NAME) { + switch (keywordToken.value) { + case 'schema': + return this.parseSchemaDefinition(); + + case 'scalar': + return this.parseScalarTypeDefinition(); + + case 'type': + return this.parseObjectTypeDefinition(); + + case 'interface': + return this.parseInterfaceTypeDefinition(); + + case 'union': + return this.parseUnionTypeDefinition(); + + case 'enum': + return this.parseEnumTypeDefinition(); + + case 'input': + return this.parseInputObjectTypeDefinition(); + + case 'directive': + return this.parseDirectiveDefinition(); + } + + if (hasDescription) { + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .syntaxError */ .h)( + this._lexer.source, + this._lexer.token.start, + 'Unexpected description, descriptions are supported only on type definitions.', + ); + } + + switch (keywordToken.value) { + case 'query': + case 'mutation': + case 'subscription': + return this.parseOperationDefinition(); + + case 'fragment': + return this.parseFragmentDefinition(); + + case 'extend': + return this.parseTypeSystemExtension(); + } + } + + throw this.unexpected(keywordToken); + } // Implements the parsing rules in the Operations section. + + /** + * OperationDefinition : + * - SelectionSet + * - OperationType Name? VariableDefinitions? Directives? SelectionSet + */ + + parseOperationDefinition() { + const start = this._lexer.token; + + if (this.peek(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L)) { + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.OPERATION_DEFINITION */ .h.OPERATION_DEFINITION, + operation: _ast_mjs__WEBPACK_IMPORTED_MODULE_5__/* .OperationTypeNode.QUERY */ .ku.QUERY, + name: undefined, + variableDefinitions: [], + directives: [], + selectionSet: this.parseSelectionSet(), + }); + } + + const operation = this.parseOperationType(); + let name; + + if (this.peek(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.NAME */ .T.NAME)) { + name = this.parseName(); + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.OPERATION_DEFINITION */ .h.OPERATION_DEFINITION, + operation, + name, + variableDefinitions: this.parseVariableDefinitions(), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * OperationType : one of query mutation subscription + */ + + parseOperationType() { + const operationToken = this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.NAME */ .T.NAME); + + switch (operationToken.value) { + case 'query': + return _ast_mjs__WEBPACK_IMPORTED_MODULE_5__/* .OperationTypeNode.QUERY */ .ku.QUERY; + + case 'mutation': + return _ast_mjs__WEBPACK_IMPORTED_MODULE_5__/* .OperationTypeNode.MUTATION */ .ku.MUTATION; + + case 'subscription': + return _ast_mjs__WEBPACK_IMPORTED_MODULE_5__/* .OperationTypeNode.SUBSCRIPTION */ .ku.SUBSCRIPTION; + } + + throw this.unexpected(operationToken); + } + /** + * VariableDefinitions : ( VariableDefinition+ ) + */ + + parseVariableDefinitions() { + return this.optionalMany( + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.PAREN_L */ .T.PAREN_L, + this.parseVariableDefinition, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.PAREN_R */ .T.PAREN_R, + ); + } + /** + * VariableDefinition : Variable : Type DefaultValue? Directives[Const]? + */ + + parseVariableDefinition() { + return this.node(this._lexer.token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.VARIABLE_DEFINITION */ .h.VARIABLE_DEFINITION, + variable: this.parseVariable(), + type: (this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.COLON */ .T.COLON), this.parseTypeReference()), + defaultValue: this.expectOptionalToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.EQUALS */ .T.EQUALS) + ? this.parseConstValueLiteral() + : undefined, + directives: this.parseConstDirectives(), + }); + } + /** + * Variable : $ Name + */ + + parseVariable() { + const start = this._lexer.token; + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.DOLLAR */ .T.DOLLAR); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.VARIABLE */ .h.VARIABLE, + name: this.parseName(), + }); + } + /** + * ``` + * SelectionSet : { Selection+ } + * ``` + */ + + parseSelectionSet() { + return this.node(this._lexer.token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.SELECTION_SET */ .h.SELECTION_SET, + selections: this.many( + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L, + this.parseSelection, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_R */ .T.BRACE_R, + ), + }); + } + /** + * Selection : + * - Field + * - FragmentSpread + * - InlineFragment + */ + + parseSelection() { + return this.peek(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.SPREAD */ .T.SPREAD) + ? this.parseFragment() + : this.parseField(); + } + /** + * Field : Alias? Name Arguments? Directives? SelectionSet? + * + * Alias : Name : + */ + + parseField() { + const start = this._lexer.token; + const nameOrAlias = this.parseName(); + let alias; + let name; + + if (this.expectOptionalToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.COLON */ .T.COLON)) { + alias = nameOrAlias; + name = this.parseName(); + } else { + name = nameOrAlias; + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.FIELD */ .h.FIELD, + alias, + name, + arguments: this.parseArguments(false), + directives: this.parseDirectives(false), + selectionSet: this.peek(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L) + ? this.parseSelectionSet() + : undefined, + }); + } + /** + * Arguments[Const] : ( Argument[?Const]+ ) + */ + + parseArguments(isConst) { + const item = isConst ? this.parseConstArgument : this.parseArgument; + return this.optionalMany(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.PAREN_L */ .T.PAREN_L, item, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.PAREN_R */ .T.PAREN_R); + } + /** + * Argument[Const] : Name : Value[?Const] + */ + + parseArgument(isConst = false) { + const start = this._lexer.token; + const name = this.parseName(); + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.COLON */ .T.COLON); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.ARGUMENT */ .h.ARGUMENT, + name, + value: this.parseValueLiteral(isConst), + }); + } + + parseConstArgument() { + return this.parseArgument(true); + } // Implements the parsing rules in the Fragments section. + + /** + * Corresponds to both FragmentSpread and InlineFragment in the spec. + * + * FragmentSpread : ... FragmentName Directives? + * + * InlineFragment : ... TypeCondition? Directives? SelectionSet + */ + + parseFragment() { + const start = this._lexer.token; + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.SPREAD */ .T.SPREAD); + const hasTypeCondition = this.expectOptionalKeyword('on'); + + if (!hasTypeCondition && this.peek(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.NAME */ .T.NAME)) { + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.FRAGMENT_SPREAD */ .h.FRAGMENT_SPREAD, + name: this.parseFragmentName(), + directives: this.parseDirectives(false), + }); + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INLINE_FRAGMENT */ .h.INLINE_FRAGMENT, + typeCondition: hasTypeCondition ? this.parseNamedType() : undefined, + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * FragmentDefinition : + * - fragment FragmentName on TypeCondition Directives? SelectionSet + * + * TypeCondition : NamedType + */ + + parseFragmentDefinition() { + const start = this._lexer.token; + this.expectKeyword('fragment'); // Legacy support for defining variables within fragments changes + // the grammar of FragmentDefinition: + // - fragment FragmentName VariableDefinitions? on TypeCondition Directives? SelectionSet + + if (this._options.allowLegacyFragmentVariables === true) { + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.FRAGMENT_DEFINITION */ .h.FRAGMENT_DEFINITION, + name: this.parseFragmentName(), + variableDefinitions: this.parseVariableDefinitions(), + typeCondition: (this.expectKeyword('on'), this.parseNamedType()), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.FRAGMENT_DEFINITION */ .h.FRAGMENT_DEFINITION, + name: this.parseFragmentName(), + typeCondition: (this.expectKeyword('on'), this.parseNamedType()), + directives: this.parseDirectives(false), + selectionSet: this.parseSelectionSet(), + }); + } + /** + * FragmentName : Name but not `on` + */ + + parseFragmentName() { + if (this._lexer.token.value === 'on') { + throw this.unexpected(); + } + + return this.parseName(); + } // Implements the parsing rules in the Values section. + + /** + * Value[Const] : + * - [~Const] Variable + * - IntValue + * - FloatValue + * - StringValue + * - BooleanValue + * - NullValue + * - EnumValue + * - ListValue[?Const] + * - ObjectValue[?Const] + * + * BooleanValue : one of `true` `false` + * + * NullValue : `null` + * + * EnumValue : Name but not `true`, `false` or `null` + */ + + parseValueLiteral(isConst) { + const token = this._lexer.token; + + switch (token.kind) { + case _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACKET_L */ .T.BRACKET_L: + return this.parseList(isConst); + + case _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L: + return this.parseObject(isConst); + + case _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.INT */ .T.INT: + this.advanceLexer(); + return this.node(token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INT */ .h.INT, + value: token.value, + }); + + case _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.FLOAT */ .T.FLOAT: + this.advanceLexer(); + return this.node(token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.FLOAT */ .h.FLOAT, + value: token.value, + }); + + case _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.STRING */ .T.STRING: + case _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BLOCK_STRING */ .T.BLOCK_STRING: + return this.parseStringLiteral(); + + case _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.NAME */ .T.NAME: + this.advanceLexer(); + + switch (token.value) { + case 'true': + return this.node(token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.BOOLEAN */ .h.BOOLEAN, + value: true, + }); + + case 'false': + return this.node(token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.BOOLEAN */ .h.BOOLEAN, + value: false, + }); + + case 'null': + return this.node(token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.NULL */ .h.NULL, + }); + + default: + return this.node(token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.ENUM */ .h.ENUM, + value: token.value, + }); + } + + case _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.DOLLAR */ .T.DOLLAR: + if (isConst) { + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.DOLLAR */ .T.DOLLAR); + + if (this._lexer.token.kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.NAME */ .T.NAME) { + const varName = this._lexer.token.value; + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .syntaxError */ .h)( + this._lexer.source, + token.start, + `Unexpected variable "$${varName}" in constant value.`, + ); + } else { + throw this.unexpected(token); + } + } + + return this.parseVariable(); + + default: + throw this.unexpected(); + } + } + + parseConstValueLiteral() { + return this.parseValueLiteral(true); + } + + parseStringLiteral() { + const token = this._lexer.token; + this.advanceLexer(); + return this.node(token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.STRING */ .h.STRING, + value: token.value, + block: token.kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BLOCK_STRING */ .T.BLOCK_STRING, + }); + } + /** + * ListValue[Const] : + * - [ ] + * - [ Value[?Const]+ ] + */ + + parseList(isConst) { + const item = () => this.parseValueLiteral(isConst); + + return this.node(this._lexer.token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.LIST */ .h.LIST, + values: this.any(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACKET_L */ .T.BRACKET_L, item, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACKET_R */ .T.BRACKET_R), + }); + } + /** + * ``` + * ObjectValue[Const] : + * - { } + * - { ObjectField[?Const]+ } + * ``` + */ + + parseObject(isConst) { + const item = () => this.parseObjectField(isConst); + + return this.node(this._lexer.token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.OBJECT */ .h.OBJECT, + fields: this.any(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L, item, _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_R */ .T.BRACE_R), + }); + } + /** + * ObjectField[Const] : Name : Value[?Const] + */ + + parseObjectField(isConst) { + const start = this._lexer.token; + const name = this.parseName(); + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.COLON */ .T.COLON); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.OBJECT_FIELD */ .h.OBJECT_FIELD, + name, + value: this.parseValueLiteral(isConst), + }); + } // Implements the parsing rules in the Directives section. + + /** + * Directives[Const] : Directive[?Const]+ + */ + + parseDirectives(isConst) { + const directives = []; + + while (this.peek(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.AT */ .T.AT)) { + directives.push(this.parseDirective(isConst)); + } + + return directives; + } + + parseConstDirectives() { + return this.parseDirectives(true); + } + /** + * ``` + * Directive[Const] : @ Name Arguments[?Const]? + * ``` + */ + + parseDirective(isConst) { + const start = this._lexer.token; + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.AT */ .T.AT); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.DIRECTIVE */ .h.DIRECTIVE, + name: this.parseName(), + arguments: this.parseArguments(isConst), + }); + } // Implements the parsing rules in the Types section. + + /** + * Type : + * - NamedType + * - ListType + * - NonNullType + */ + + parseTypeReference() { + const start = this._lexer.token; + let type; + + if (this.expectOptionalToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACKET_L */ .T.BRACKET_L)) { + const innerType = this.parseTypeReference(); + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACKET_R */ .T.BRACKET_R); + type = this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.LIST_TYPE */ .h.LIST_TYPE, + type: innerType, + }); + } else { + type = this.parseNamedType(); + } + + if (this.expectOptionalToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BANG */ .T.BANG)) { + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.NON_NULL_TYPE */ .h.NON_NULL_TYPE, + type, + }); + } + + return type; + } + /** + * NamedType : Name + */ + + parseNamedType() { + return this.node(this._lexer.token, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.NAMED_TYPE */ .h.NAMED_TYPE, + name: this.parseName(), + }); + } // Implements the parsing rules in the Type Definition section. + + peekDescription() { + return this.peek(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.STRING */ .T.STRING) || this.peek(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BLOCK_STRING */ .T.BLOCK_STRING); + } + /** + * Description : StringValue + */ + + parseDescription() { + if (this.peekDescription()) { + return this.parseStringLiteral(); + } + } + /** + * ``` + * SchemaDefinition : Description? schema Directives[Const]? { OperationTypeDefinition+ } + * ``` + */ + + parseSchemaDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('schema'); + const directives = this.parseConstDirectives(); + const operationTypes = this.many( + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L, + this.parseOperationTypeDefinition, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_R */ .T.BRACE_R, + ); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.SCHEMA_DEFINITION */ .h.SCHEMA_DEFINITION, + description, + directives, + operationTypes, + }); + } + /** + * OperationTypeDefinition : OperationType : NamedType + */ + + parseOperationTypeDefinition() { + const start = this._lexer.token; + const operation = this.parseOperationType(); + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.COLON */ .T.COLON); + const type = this.parseNamedType(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.OPERATION_TYPE_DEFINITION */ .h.OPERATION_TYPE_DEFINITION, + operation, + type, + }); + } + /** + * ScalarTypeDefinition : Description? scalar Name Directives[Const]? + */ + + parseScalarTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('scalar'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.SCALAR_TYPE_DEFINITION */ .h.SCALAR_TYPE_DEFINITION, + description, + name, + directives, + }); + } + /** + * ObjectTypeDefinition : + * Description? + * type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition? + */ + + parseObjectTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('type'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.OBJECT_TYPE_DEFINITION */ .h.OBJECT_TYPE_DEFINITION, + description, + name, + interfaces, + directives, + fields, + }); + } + /** + * ImplementsInterfaces : + * - implements `&`? NamedType + * - ImplementsInterfaces & NamedType + */ + + parseImplementsInterfaces() { + return this.expectOptionalKeyword('implements') + ? this.delimitedMany(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.AMP */ .T.AMP, this.parseNamedType) + : []; + } + /** + * ``` + * FieldsDefinition : { FieldDefinition+ } + * ``` + */ + + parseFieldsDefinition() { + return this.optionalMany( + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L, + this.parseFieldDefinition, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_R */ .T.BRACE_R, + ); + } + /** + * FieldDefinition : + * - Description? Name ArgumentsDefinition? : Type Directives[Const]? + */ + + parseFieldDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseName(); + const args = this.parseArgumentDefs(); + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.COLON */ .T.COLON); + const type = this.parseTypeReference(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.FIELD_DEFINITION */ .h.FIELD_DEFINITION, + description, + name, + arguments: args, + type, + directives, + }); + } + /** + * ArgumentsDefinition : ( InputValueDefinition+ ) + */ + + parseArgumentDefs() { + return this.optionalMany( + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.PAREN_L */ .T.PAREN_L, + this.parseInputValueDef, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.PAREN_R */ .T.PAREN_R, + ); + } + /** + * InputValueDefinition : + * - Description? Name : Type DefaultValue? Directives[Const]? + */ + + parseInputValueDef() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseName(); + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.COLON */ .T.COLON); + const type = this.parseTypeReference(); + let defaultValue; + + if (this.expectOptionalToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.EQUALS */ .T.EQUALS)) { + defaultValue = this.parseConstValueLiteral(); + } + + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INPUT_VALUE_DEFINITION */ .h.INPUT_VALUE_DEFINITION, + description, + name, + type, + defaultValue, + directives, + }); + } + /** + * InterfaceTypeDefinition : + * - Description? interface Name Directives[Const]? FieldsDefinition? + */ + + parseInterfaceTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('interface'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INTERFACE_TYPE_DEFINITION */ .h.INTERFACE_TYPE_DEFINITION, + description, + name, + interfaces, + directives, + fields, + }); + } + /** + * UnionTypeDefinition : + * - Description? union Name Directives[Const]? UnionMemberTypes? + */ + + parseUnionTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('union'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const types = this.parseUnionMemberTypes(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.UNION_TYPE_DEFINITION */ .h.UNION_TYPE_DEFINITION, + description, + name, + directives, + types, + }); + } + /** + * UnionMemberTypes : + * - = `|`? NamedType + * - UnionMemberTypes | NamedType + */ + + parseUnionMemberTypes() { + return this.expectOptionalToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.EQUALS */ .T.EQUALS) + ? this.delimitedMany(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.PIPE */ .T.PIPE, this.parseNamedType) + : []; + } + /** + * EnumTypeDefinition : + * - Description? enum Name Directives[Const]? EnumValuesDefinition? + */ + + parseEnumTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('enum'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const values = this.parseEnumValuesDefinition(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.ENUM_TYPE_DEFINITION */ .h.ENUM_TYPE_DEFINITION, + description, + name, + directives, + values, + }); + } + /** + * ``` + * EnumValuesDefinition : { EnumValueDefinition+ } + * ``` + */ + + parseEnumValuesDefinition() { + return this.optionalMany( + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L, + this.parseEnumValueDefinition, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_R */ .T.BRACE_R, + ); + } + /** + * EnumValueDefinition : Description? EnumValue Directives[Const]? + */ + + parseEnumValueDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + const name = this.parseEnumValueName(); + const directives = this.parseConstDirectives(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.ENUM_VALUE_DEFINITION */ .h.ENUM_VALUE_DEFINITION, + description, + name, + directives, + }); + } + /** + * EnumValue : Name but not `true`, `false` or `null` + */ + + parseEnumValueName() { + if ( + this._lexer.token.value === 'true' || + this._lexer.token.value === 'false' || + this._lexer.token.value === 'null' + ) { + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .syntaxError */ .h)( + this._lexer.source, + this._lexer.token.start, + `${getTokenDesc( + this._lexer.token, + )} is reserved and cannot be used for an enum value.`, + ); + } + + return this.parseName(); + } + /** + * InputObjectTypeDefinition : + * - Description? input Name Directives[Const]? InputFieldsDefinition? + */ + + parseInputObjectTypeDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('input'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const fields = this.parseInputFieldsDefinition(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INPUT_OBJECT_TYPE_DEFINITION */ .h.INPUT_OBJECT_TYPE_DEFINITION, + description, + name, + directives, + fields, + }); + } + /** + * ``` + * InputFieldsDefinition : { InputValueDefinition+ } + * ``` + */ + + parseInputFieldsDefinition() { + return this.optionalMany( + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L, + this.parseInputValueDef, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_R */ .T.BRACE_R, + ); + } + /** + * TypeSystemExtension : + * - SchemaExtension + * - TypeExtension + * + * TypeExtension : + * - ScalarTypeExtension + * - ObjectTypeExtension + * - InterfaceTypeExtension + * - UnionTypeExtension + * - EnumTypeExtension + * - InputObjectTypeDefinition + */ + + parseTypeSystemExtension() { + const keywordToken = this._lexer.lookahead(); + + if (keywordToken.kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.NAME */ .T.NAME) { + switch (keywordToken.value) { + case 'schema': + return this.parseSchemaExtension(); + + case 'scalar': + return this.parseScalarTypeExtension(); + + case 'type': + return this.parseObjectTypeExtension(); + + case 'interface': + return this.parseInterfaceTypeExtension(); + + case 'union': + return this.parseUnionTypeExtension(); + + case 'enum': + return this.parseEnumTypeExtension(); + + case 'input': + return this.parseInputObjectTypeExtension(); + } + } + + throw this.unexpected(keywordToken); + } + /** + * ``` + * SchemaExtension : + * - extend schema Directives[Const]? { OperationTypeDefinition+ } + * - extend schema Directives[Const] + * ``` + */ + + parseSchemaExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('schema'); + const directives = this.parseConstDirectives(); + const operationTypes = this.optionalMany( + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_L */ .T.BRACE_L, + this.parseOperationTypeDefinition, + _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.BRACE_R */ .T.BRACE_R, + ); + + if (directives.length === 0 && operationTypes.length === 0) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.SCHEMA_EXTENSION */ .h.SCHEMA_EXTENSION, + directives, + operationTypes, + }); + } + /** + * ScalarTypeExtension : + * - extend scalar Name Directives[Const] + */ + + parseScalarTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('scalar'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + + if (directives.length === 0) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.SCALAR_TYPE_EXTENSION */ .h.SCALAR_TYPE_EXTENSION, + name, + directives, + }); + } + /** + * ObjectTypeExtension : + * - extend type Name ImplementsInterfaces? Directives[Const]? FieldsDefinition + * - extend type Name ImplementsInterfaces? Directives[Const] + * - extend type Name ImplementsInterfaces + */ + + parseObjectTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('type'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + + if ( + interfaces.length === 0 && + directives.length === 0 && + fields.length === 0 + ) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.OBJECT_TYPE_EXTENSION */ .h.OBJECT_TYPE_EXTENSION, + name, + interfaces, + directives, + fields, + }); + } + /** + * InterfaceTypeExtension : + * - extend interface Name ImplementsInterfaces? Directives[Const]? FieldsDefinition + * - extend interface Name ImplementsInterfaces? Directives[Const] + * - extend interface Name ImplementsInterfaces + */ + + parseInterfaceTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('interface'); + const name = this.parseName(); + const interfaces = this.parseImplementsInterfaces(); + const directives = this.parseConstDirectives(); + const fields = this.parseFieldsDefinition(); + + if ( + interfaces.length === 0 && + directives.length === 0 && + fields.length === 0 + ) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INTERFACE_TYPE_EXTENSION */ .h.INTERFACE_TYPE_EXTENSION, + name, + interfaces, + directives, + fields, + }); + } + /** + * UnionTypeExtension : + * - extend union Name Directives[Const]? UnionMemberTypes + * - extend union Name Directives[Const] + */ + + parseUnionTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('union'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const types = this.parseUnionMemberTypes(); + + if (directives.length === 0 && types.length === 0) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.UNION_TYPE_EXTENSION */ .h.UNION_TYPE_EXTENSION, + name, + directives, + types, + }); + } + /** + * EnumTypeExtension : + * - extend enum Name Directives[Const]? EnumValuesDefinition + * - extend enum Name Directives[Const] + */ + + parseEnumTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('enum'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const values = this.parseEnumValuesDefinition(); + + if (directives.length === 0 && values.length === 0) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.ENUM_TYPE_EXTENSION */ .h.ENUM_TYPE_EXTENSION, + name, + directives, + values, + }); + } + /** + * InputObjectTypeExtension : + * - extend input Name Directives[Const]? InputFieldsDefinition + * - extend input Name Directives[Const] + */ + + parseInputObjectTypeExtension() { + const start = this._lexer.token; + this.expectKeyword('extend'); + this.expectKeyword('input'); + const name = this.parseName(); + const directives = this.parseConstDirectives(); + const fields = this.parseInputFieldsDefinition(); + + if (directives.length === 0 && fields.length === 0) { + throw this.unexpected(); + } + + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INPUT_OBJECT_TYPE_EXTENSION */ .h.INPUT_OBJECT_TYPE_EXTENSION, + name, + directives, + fields, + }); + } + /** + * ``` + * DirectiveDefinition : + * - Description? directive @ Name ArgumentsDefinition? `repeatable`? on DirectiveLocations + * ``` + */ + + parseDirectiveDefinition() { + const start = this._lexer.token; + const description = this.parseDescription(); + this.expectKeyword('directive'); + this.expectToken(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.AT */ .T.AT); + const name = this.parseName(); + const args = this.parseArgumentDefs(); + const repeatable = this.expectOptionalKeyword('repeatable'); + this.expectKeyword('on'); + const locations = this.parseDirectiveLocations(); + return this.node(start, { + kind: _kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.DIRECTIVE_DEFINITION */ .h.DIRECTIVE_DEFINITION, + description, + name, + arguments: args, + repeatable, + locations, + }); + } + /** + * DirectiveLocations : + * - `|`? DirectiveLocation + * - DirectiveLocations | DirectiveLocation + */ + + parseDirectiveLocations() { + return this.delimitedMany(_tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.PIPE */ .T.PIPE, this.parseDirectiveLocation); + } + /* + * DirectiveLocation : + * - ExecutableDirectiveLocation + * - TypeSystemDirectiveLocation + * + * ExecutableDirectiveLocation : one of + * `QUERY` + * `MUTATION` + * `SUBSCRIPTION` + * `FIELD` + * `FRAGMENT_DEFINITION` + * `FRAGMENT_SPREAD` + * `INLINE_FRAGMENT` + * + * TypeSystemDirectiveLocation : one of + * `SCHEMA` + * `SCALAR` + * `OBJECT` + * `FIELD_DEFINITION` + * `ARGUMENT_DEFINITION` + * `INTERFACE` + * `UNION` + * `ENUM` + * `ENUM_VALUE` + * `INPUT_OBJECT` + * `INPUT_FIELD_DEFINITION` + */ + + parseDirectiveLocation() { + const start = this._lexer.token; + const name = this.parseName(); + + if (Object.prototype.hasOwnProperty.call(_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_6__/* .DirectiveLocation */ .B, name.value)) { + return name; + } + + throw this.unexpected(start); + } // Core parsing utility functions + + /** + * Returns a node that, if configured to do so, sets a "loc" field as a + * location object, used to identify the place in the source that created a + * given parsed object. + */ + + node(startToken, node) { + if (this._options.noLocation !== true) { + node.loc = new _ast_mjs__WEBPACK_IMPORTED_MODULE_5__/* .Location */ .Ye( + startToken, + this._lexer.lastToken, + this._lexer.source, + ); + } + + return node; + } + /** + * Determines if the next token is of a given kind + */ + + peek(kind) { + return this._lexer.token.kind === kind; + } + /** + * If the next token is of the given kind, return that token after advancing the lexer. + * Otherwise, do not change the parser state and throw an error. + */ + + expectToken(kind) { + const token = this._lexer.token; + + if (token.kind === kind) { + this.advanceLexer(); + return token; + } + + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .syntaxError */ .h)( + this._lexer.source, + token.start, + `Expected ${getTokenKindDesc(kind)}, found ${getTokenDesc(token)}.`, + ); + } + /** + * If the next token is of the given kind, return "true" after advancing the lexer. + * Otherwise, do not change the parser state and return "false". + */ + + expectOptionalToken(kind) { + const token = this._lexer.token; + + if (token.kind === kind) { + this.advanceLexer(); + return true; + } + + return false; + } + /** + * If the next token is a given keyword, advance the lexer. + * Otherwise, do not change the parser state and throw an error. + */ + + expectKeyword(value) { + const token = this._lexer.token; + + if (token.kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.NAME */ .T.NAME && token.value === value) { + this.advanceLexer(); + } else { + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .syntaxError */ .h)( + this._lexer.source, + token.start, + `Expected "${value}", found ${getTokenDesc(token)}.`, + ); + } + } + /** + * If the next token is a given keyword, return "true" after advancing the lexer. + * Otherwise, do not change the parser state and return "false". + */ + + expectOptionalKeyword(value) { + const token = this._lexer.token; + + if (token.kind === _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.NAME */ .T.NAME && token.value === value) { + this.advanceLexer(); + return true; + } + + return false; + } + /** + * Helper function for creating an error when an unexpected lexed token is encountered. + */ + + unexpected(atToken) { + const token = + atToken !== null && atToken !== void 0 ? atToken : this._lexer.token; + return (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .syntaxError */ .h)( + this._lexer.source, + token.start, + `Unexpected ${getTokenDesc(token)}.`, + ); + } + /** + * Returns a possibly empty list of parse nodes, determined by the parseFn. + * This list begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + + any(openKind, parseFn, closeKind) { + this.expectToken(openKind); + const nodes = []; + + while (!this.expectOptionalToken(closeKind)) { + nodes.push(parseFn.call(this)); + } + + return nodes; + } + /** + * Returns a list of parse nodes, determined by the parseFn. + * It can be empty only if open token is missing otherwise it will always return non-empty list + * that begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + + optionalMany(openKind, parseFn, closeKind) { + if (this.expectOptionalToken(openKind)) { + const nodes = []; + + do { + nodes.push(parseFn.call(this)); + } while (!this.expectOptionalToken(closeKind)); + + return nodes; + } + + return []; + } + /** + * Returns a non-empty list of parse nodes, determined by the parseFn. + * This list begins with a lex token of openKind and ends with a lex token of closeKind. + * Advances the parser to the next lex token after the closing token. + */ + + many(openKind, parseFn, closeKind) { + this.expectToken(openKind); + const nodes = []; + + do { + nodes.push(parseFn.call(this)); + } while (!this.expectOptionalToken(closeKind)); + + return nodes; + } + /** + * Returns a non-empty list of parse nodes, determined by the parseFn. + * This list may begin with a lex token of delimiterKind followed by items separated by lex tokens of tokenKind. + * Advances the parser to the next lex token after last item in the list. + */ + + delimitedMany(delimiterKind, parseFn) { + this.expectOptionalToken(delimiterKind); + const nodes = []; + + do { + nodes.push(parseFn.call(this)); + } while (this.expectOptionalToken(delimiterKind)); + + return nodes; + } + + advanceLexer() { + const { maxTokens } = this._options; + + const token = this._lexer.advance(); + + if (maxTokens !== undefined && token.kind !== _tokenKind_mjs__WEBPACK_IMPORTED_MODULE_0__/* .TokenKind.EOF */ .T.EOF) { + ++this._tokenCounter; + + if (this._tokenCounter > maxTokens) { + throw (0,_error_syntaxError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .syntaxError */ .h)( + this._lexer.source, + token.start, + `Document contains more that ${maxTokens} tokens. Parsing aborted.`, + ); + } + } + } +} +/** + * A helper function to describe a token as a string for debugging. + */ + +function getTokenDesc(token) { + const value = token.value; + return getTokenKindDesc(token.kind) + (value != null ? ` "${value}"` : ''); +} +/** + * A helper function to describe a token kind as a string for debugging. + */ + +function getTokenKindDesc(kind) { + return (0,_lexer_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isPunctuatorTokenKind */ .u)(kind) ? `"${kind}"` : kind; +} + + +/***/ }), + +/***/ 5844: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "D$": () => (/* binding */ isTypeExtensionNode), +/* harmony export */ "G4": () => (/* binding */ isTypeSystemDefinitionNode), +/* harmony export */ "Ir": () => (/* binding */ isDefinitionNode), +/* harmony export */ "Of": () => (/* binding */ isConstValueNode), +/* harmony export */ "VB": () => (/* binding */ isTypeNode), +/* harmony export */ "Wk": () => (/* binding */ isExecutableDefinitionNode), +/* harmony export */ "aU": () => (/* binding */ isTypeSystemExtensionNode), +/* harmony export */ "nr": () => (/* binding */ isValueNode), +/* harmony export */ "pO": () => (/* binding */ isSelectionNode), +/* harmony export */ "zT": () => (/* binding */ isTypeDefinitionNode) +/* harmony export */ }); +/* harmony import */ var _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7359); + +function isDefinitionNode(node) { + return ( + isExecutableDefinitionNode(node) || + isTypeSystemDefinitionNode(node) || + isTypeSystemExtensionNode(node) + ); +} +function isExecutableDefinitionNode(node) { + return ( + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.OPERATION_DEFINITION */ .h.OPERATION_DEFINITION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FRAGMENT_DEFINITION */ .h.FRAGMENT_DEFINITION + ); +} +function isSelectionNode(node) { + return ( + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FIELD */ .h.FIELD || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FRAGMENT_SPREAD */ .h.FRAGMENT_SPREAD || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.INLINE_FRAGMENT */ .h.INLINE_FRAGMENT + ); +} +function isValueNode(node) { + return ( + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.VARIABLE */ .h.VARIABLE || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.INT */ .h.INT || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FLOAT */ .h.FLOAT || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.STRING */ .h.STRING || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.BOOLEAN */ .h.BOOLEAN || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.NULL */ .h.NULL || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.ENUM */ .h.ENUM || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.LIST */ .h.LIST || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.OBJECT */ .h.OBJECT + ); +} +function isConstValueNode(node) { + return ( + isValueNode(node) && + (node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.LIST */ .h.LIST + ? node.values.some(isConstValueNode) + : node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.OBJECT */ .h.OBJECT + ? node.fields.some((field) => isConstValueNode(field.value)) + : node.kind !== _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.VARIABLE */ .h.VARIABLE) + ); +} +function isTypeNode(node) { + return ( + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.NAMED_TYPE */ .h.NAMED_TYPE || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.LIST_TYPE */ .h.LIST_TYPE || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.NON_NULL_TYPE */ .h.NON_NULL_TYPE + ); +} +function isTypeSystemDefinitionNode(node) { + return ( + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.SCHEMA_DEFINITION */ .h.SCHEMA_DEFINITION || + isTypeDefinitionNode(node) || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.DIRECTIVE_DEFINITION */ .h.DIRECTIVE_DEFINITION + ); +} +function isTypeDefinitionNode(node) { + return ( + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.SCALAR_TYPE_DEFINITION */ .h.SCALAR_TYPE_DEFINITION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.OBJECT_TYPE_DEFINITION */ .h.OBJECT_TYPE_DEFINITION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.INTERFACE_TYPE_DEFINITION */ .h.INTERFACE_TYPE_DEFINITION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.UNION_TYPE_DEFINITION */ .h.UNION_TYPE_DEFINITION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.ENUM_TYPE_DEFINITION */ .h.ENUM_TYPE_DEFINITION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.INPUT_OBJECT_TYPE_DEFINITION */ .h.INPUT_OBJECT_TYPE_DEFINITION + ); +} +function isTypeSystemExtensionNode(node) { + return node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.SCHEMA_EXTENSION */ .h.SCHEMA_EXTENSION || isTypeExtensionNode(node); +} +function isTypeExtensionNode(node) { + return ( + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.SCALAR_TYPE_EXTENSION */ .h.SCALAR_TYPE_EXTENSION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.OBJECT_TYPE_EXTENSION */ .h.OBJECT_TYPE_EXTENSION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.INTERFACE_TYPE_EXTENSION */ .h.INTERFACE_TYPE_EXTENSION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.UNION_TYPE_EXTENSION */ .h.UNION_TYPE_EXTENSION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.ENUM_TYPE_EXTENSION */ .h.ENUM_TYPE_EXTENSION || + node.kind === _kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.INPUT_OBJECT_TYPE_EXTENSION */ .h.INPUT_OBJECT_TYPE_EXTENSION + ); +} + + +/***/ }), + +/***/ 850: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Q": () => (/* binding */ printLocation), +/* harmony export */ "z": () => (/* binding */ printSourceLocation) +/* harmony export */ }); +/* harmony import */ var _location_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7867); + + +/** + * Render a helpful description of the location in the GraphQL Source document. + */ +function printLocation(location) { + return printSourceLocation( + location.source, + (0,_location_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getLocation */ .k)(location.source, location.start), + ); +} +/** + * Render a helpful description of the location in the GraphQL Source document. + */ + +function printSourceLocation(source, sourceLocation) { + const firstLineColumnOffset = source.locationOffset.column - 1; + const body = ''.padStart(firstLineColumnOffset) + source.body; + const lineIndex = sourceLocation.line - 1; + const lineOffset = source.locationOffset.line - 1; + const lineNum = sourceLocation.line + lineOffset; + const columnOffset = sourceLocation.line === 1 ? firstLineColumnOffset : 0; + const columnNum = sourceLocation.column + columnOffset; + const locationStr = `${source.name}:${lineNum}:${columnNum}\n`; + const lines = body.split(/\r\n|[\n\r]/g); + const locationLine = lines[lineIndex]; // Special case for minified documents + + if (locationLine.length > 120) { + const subLineIndex = Math.floor(columnNum / 80); + const subLineColumnNum = columnNum % 80; + const subLines = []; + + for (let i = 0; i < locationLine.length; i += 80) { + subLines.push(locationLine.slice(i, i + 80)); + } + + return ( + locationStr + + printPrefixedLines([ + [`${lineNum} |`, subLines[0]], + ...subLines.slice(1, subLineIndex + 1).map((subLine) => ['|', subLine]), + ['|', '^'.padStart(subLineColumnNum)], + ['|', subLines[subLineIndex + 1]], + ]) + ); + } + + return ( + locationStr + + printPrefixedLines([ + // Lines specified like this: ["prefix", "string"], + [`${lineNum - 1} |`, lines[lineIndex - 1]], + [`${lineNum} |`, locationLine], + ['|', '^'.padStart(columnNum)], + [`${lineNum + 1} |`, lines[lineIndex + 1]], + ]) + ); +} + +function printPrefixedLines(lines) { + const existingLines = lines.filter(([_, line]) => line !== undefined); + const padLen = Math.max(...existingLines.map(([prefix]) => prefix.length)); + return existingLines + .map(([prefix, line]) => prefix.padStart(padLen) + (line ? ' ' + line : '')) + .join('\n'); +} + + +/***/ }), + +/***/ 3486: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "S": () => (/* binding */ print) +}); + +// EXTERNAL MODULE: ./node_modules/graphql/language/blockString.mjs +var blockString = __webpack_require__(7392); +;// CONCATENATED MODULE: ./node_modules/graphql/language/printString.mjs +/** + * Prints a string as a GraphQL StringValue literal. Replaces control characters + * and excluded characters (" U+0022 and \\ U+005C) with escape sequences. + */ +function printString(str) { + return `"${str.replace(escapedRegExp, escapedReplacer)}"`; +} // eslint-disable-next-line no-control-regex + +const escapedRegExp = /[\x00-\x1f\x22\x5c\x7f-\x9f]/g; + +function escapedReplacer(str) { + return escapeSequences[str.charCodeAt(0)]; +} // prettier-ignore + +const escapeSequences = [ + '\\u0000', + '\\u0001', + '\\u0002', + '\\u0003', + '\\u0004', + '\\u0005', + '\\u0006', + '\\u0007', + '\\b', + '\\t', + '\\n', + '\\u000B', + '\\f', + '\\r', + '\\u000E', + '\\u000F', + '\\u0010', + '\\u0011', + '\\u0012', + '\\u0013', + '\\u0014', + '\\u0015', + '\\u0016', + '\\u0017', + '\\u0018', + '\\u0019', + '\\u001A', + '\\u001B', + '\\u001C', + '\\u001D', + '\\u001E', + '\\u001F', + '', + '', + '\\"', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 2F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 3F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 4F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '\\\\', + '', + '', + '', // 5F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', // 6F + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '\\u007F', + '\\u0080', + '\\u0081', + '\\u0082', + '\\u0083', + '\\u0084', + '\\u0085', + '\\u0086', + '\\u0087', + '\\u0088', + '\\u0089', + '\\u008A', + '\\u008B', + '\\u008C', + '\\u008D', + '\\u008E', + '\\u008F', + '\\u0090', + '\\u0091', + '\\u0092', + '\\u0093', + '\\u0094', + '\\u0095', + '\\u0096', + '\\u0097', + '\\u0098', + '\\u0099', + '\\u009A', + '\\u009B', + '\\u009C', + '\\u009D', + '\\u009E', + '\\u009F', +]; + +// EXTERNAL MODULE: ./node_modules/graphql/language/visitor.mjs +var visitor = __webpack_require__(7304); +;// CONCATENATED MODULE: ./node_modules/graphql/language/printer.mjs + + + +/** + * Converts an AST into a string, using one set of reasonable + * formatting rules. + */ + +function print(ast) { + return (0,visitor/* visit */.Vn)(ast, printDocASTReducer); +} +const MAX_LINE_LENGTH = 80; +const printDocASTReducer = { + Name: { + leave: (node) => node.value, + }, + Variable: { + leave: (node) => '$' + node.name, + }, + // Document + Document: { + leave: (node) => join(node.definitions, '\n\n'), + }, + OperationDefinition: { + leave(node) { + const varDefs = wrap('(', join(node.variableDefinitions, ', '), ')'); + const prefix = join( + [ + node.operation, + join([node.name, varDefs]), + join(node.directives, ' '), + ], + ' ', + ); // Anonymous queries with no directives or variable definitions can use + // the query short form. + + return (prefix === 'query' ? '' : prefix + ' ') + node.selectionSet; + }, + }, + VariableDefinition: { + leave: ({ variable, type, defaultValue, directives }) => + variable + + ': ' + + type + + wrap(' = ', defaultValue) + + wrap(' ', join(directives, ' ')), + }, + SelectionSet: { + leave: ({ selections }) => block(selections), + }, + Field: { + leave({ alias, name, arguments: args, directives, selectionSet }) { + const prefix = wrap('', alias, ': ') + name; + let argsLine = prefix + wrap('(', join(args, ', '), ')'); + + if (argsLine.length > MAX_LINE_LENGTH) { + argsLine = prefix + wrap('(\n', indent(join(args, '\n')), '\n)'); + } + + return join([argsLine, join(directives, ' '), selectionSet], ' '); + }, + }, + Argument: { + leave: ({ name, value }) => name + ': ' + value, + }, + // Fragments + FragmentSpread: { + leave: ({ name, directives }) => + '...' + name + wrap(' ', join(directives, ' ')), + }, + InlineFragment: { + leave: ({ typeCondition, directives, selectionSet }) => + join( + [ + '...', + wrap('on ', typeCondition), + join(directives, ' '), + selectionSet, + ], + ' ', + ), + }, + FragmentDefinition: { + leave: ( + { name, typeCondition, variableDefinitions, directives, selectionSet }, // Note: fragment variable definitions are experimental and may be changed + ) => + // or removed in the future. + `fragment ${name}${wrap('(', join(variableDefinitions, ', '), ')')} ` + + `on ${typeCondition} ${wrap('', join(directives, ' '), ' ')}` + + selectionSet, + }, + // Value + IntValue: { + leave: ({ value }) => value, + }, + FloatValue: { + leave: ({ value }) => value, + }, + StringValue: { + leave: ({ value, block: isBlockString }) => + isBlockString ? (0,blockString/* printBlockString */.LZ)(value) : printString(value), + }, + BooleanValue: { + leave: ({ value }) => (value ? 'true' : 'false'), + }, + NullValue: { + leave: () => 'null', + }, + EnumValue: { + leave: ({ value }) => value, + }, + ListValue: { + leave: ({ values }) => '[' + join(values, ', ') + ']', + }, + ObjectValue: { + leave: ({ fields }) => '{' + join(fields, ', ') + '}', + }, + ObjectField: { + leave: ({ name, value }) => name + ': ' + value, + }, + // Directive + Directive: { + leave: ({ name, arguments: args }) => + '@' + name + wrap('(', join(args, ', '), ')'), + }, + // Type + NamedType: { + leave: ({ name }) => name, + }, + ListType: { + leave: ({ type }) => '[' + type + ']', + }, + NonNullType: { + leave: ({ type }) => type + '!', + }, + // Type System Definitions + SchemaDefinition: { + leave: ({ description, directives, operationTypes }) => + wrap('', description, '\n') + + join(['schema', join(directives, ' '), block(operationTypes)], ' '), + }, + OperationTypeDefinition: { + leave: ({ operation, type }) => operation + ': ' + type, + }, + ScalarTypeDefinition: { + leave: ({ description, name, directives }) => + wrap('', description, '\n') + + join(['scalar', name, join(directives, ' ')], ' '), + }, + ObjectTypeDefinition: { + leave: ({ description, name, interfaces, directives, fields }) => + wrap('', description, '\n') + + join( + [ + 'type', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + FieldDefinition: { + leave: ({ description, name, arguments: args, type, directives }) => + wrap('', description, '\n') + + name + + (hasMultilineItems(args) + ? wrap('(\n', indent(join(args, '\n')), '\n)') + : wrap('(', join(args, ', '), ')')) + + ': ' + + type + + wrap(' ', join(directives, ' ')), + }, + InputValueDefinition: { + leave: ({ description, name, type, defaultValue, directives }) => + wrap('', description, '\n') + + join( + [name + ': ' + type, wrap('= ', defaultValue), join(directives, ' ')], + ' ', + ), + }, + InterfaceTypeDefinition: { + leave: ({ description, name, interfaces, directives, fields }) => + wrap('', description, '\n') + + join( + [ + 'interface', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + UnionTypeDefinition: { + leave: ({ description, name, directives, types }) => + wrap('', description, '\n') + + join( + ['union', name, join(directives, ' '), wrap('= ', join(types, ' | '))], + ' ', + ), + }, + EnumTypeDefinition: { + leave: ({ description, name, directives, values }) => + wrap('', description, '\n') + + join(['enum', name, join(directives, ' '), block(values)], ' '), + }, + EnumValueDefinition: { + leave: ({ description, name, directives }) => + wrap('', description, '\n') + join([name, join(directives, ' ')], ' '), + }, + InputObjectTypeDefinition: { + leave: ({ description, name, directives, fields }) => + wrap('', description, '\n') + + join(['input', name, join(directives, ' '), block(fields)], ' '), + }, + DirectiveDefinition: { + leave: ({ description, name, arguments: args, repeatable, locations }) => + wrap('', description, '\n') + + 'directive @' + + name + + (hasMultilineItems(args) + ? wrap('(\n', indent(join(args, '\n')), '\n)') + : wrap('(', join(args, ', '), ')')) + + (repeatable ? ' repeatable' : '') + + ' on ' + + join(locations, ' | '), + }, + SchemaExtension: { + leave: ({ directives, operationTypes }) => + join( + ['extend schema', join(directives, ' '), block(operationTypes)], + ' ', + ), + }, + ScalarTypeExtension: { + leave: ({ name, directives }) => + join(['extend scalar', name, join(directives, ' ')], ' '), + }, + ObjectTypeExtension: { + leave: ({ name, interfaces, directives, fields }) => + join( + [ + 'extend type', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + InterfaceTypeExtension: { + leave: ({ name, interfaces, directives, fields }) => + join( + [ + 'extend interface', + name, + wrap('implements ', join(interfaces, ' & ')), + join(directives, ' '), + block(fields), + ], + ' ', + ), + }, + UnionTypeExtension: { + leave: ({ name, directives, types }) => + join( + [ + 'extend union', + name, + join(directives, ' '), + wrap('= ', join(types, ' | ')), + ], + ' ', + ), + }, + EnumTypeExtension: { + leave: ({ name, directives, values }) => + join(['extend enum', name, join(directives, ' '), block(values)], ' '), + }, + InputObjectTypeExtension: { + leave: ({ name, directives, fields }) => + join(['extend input', name, join(directives, ' '), block(fields)], ' '), + }, +}; +/** + * Given maybeArray, print an empty string if it is null or empty, otherwise + * print all items together separated by separator if provided + */ + +function join(maybeArray, separator = '') { + var _maybeArray$filter$jo; + + return (_maybeArray$filter$jo = + maybeArray === null || maybeArray === void 0 + ? void 0 + : maybeArray.filter((x) => x).join(separator)) !== null && + _maybeArray$filter$jo !== void 0 + ? _maybeArray$filter$jo + : ''; +} +/** + * Given array, print each item on its own line, wrapped in an indented `{ }` block. + */ + +function block(array) { + return wrap('{\n', indent(join(array, '\n')), '\n}'); +} +/** + * If maybeString is not null or empty, then wrap with start and end, otherwise print an empty string. + */ + +function wrap(start, maybeString, end = '') { + return maybeString != null && maybeString !== '' + ? start + maybeString + end + : ''; +} + +function indent(str) { + return wrap(' ', str.replace(/\n/g, '\n ')); +} + +function hasMultilineItems(maybeArray) { + var _maybeArray$some; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + return (_maybeArray$some = + maybeArray === null || maybeArray === void 0 + ? void 0 + : maybeArray.some((str) => str.includes('\n'))) !== null && + _maybeArray$some !== void 0 + ? _maybeArray$some + : false; +} + + +/***/ }), + +/***/ 7926: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "H": () => (/* binding */ Source), +/* harmony export */ "T": () => (/* binding */ isSource) +/* harmony export */ }); +/* harmony import */ var _jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7826); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_instanceOf_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8306); + + + + +/** + * A representation of source input to GraphQL. The `name` and `locationOffset` parameters are + * optional, but they are useful for clients who store GraphQL documents in source files. + * For example, if the GraphQL input starts at line 40 in a file named `Foo.graphql`, it might + * be useful for `name` to be `"Foo.graphql"` and location to be `{ line: 40, column: 1 }`. + * The `line` and `column` properties in `locationOffset` are 1-indexed. + */ +class Source { + constructor( + body, + name = 'GraphQL request', + locationOffset = { + line: 1, + column: 1, + }, + ) { + typeof body === 'string' || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_0__/* .devAssert */ .a)(false, `Body must be a string. Received: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(body)}.`); + this.body = body; + this.name = name; + this.locationOffset = locationOffset; + this.locationOffset.line > 0 || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_0__/* .devAssert */ .a)( + false, + 'line in locationOffset is 1-indexed and must be positive.', + ); + this.locationOffset.column > 0 || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_0__/* .devAssert */ .a)( + false, + 'column in locationOffset is 1-indexed and must be positive.', + ); + } + + get [Symbol.toStringTag]() { + return 'Source'; + } +} +/** + * Test if the given value is a Source object. + * + * @internal + */ + +function isSource(source) { + return (0,_jsutils_instanceOf_mjs__WEBPACK_IMPORTED_MODULE_2__/* .instanceOf */ .n)(source, Source); +} + + +/***/ }), + +/***/ 4635: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "T": () => (/* binding */ TokenKind) +/* harmony export */ }); +/** + * An exported enum describing the different kinds of tokens that the + * lexer emits. + */ +var TokenKind; + +(function (TokenKind) { + TokenKind['SOF'] = ''; + TokenKind['EOF'] = ''; + TokenKind['BANG'] = '!'; + TokenKind['DOLLAR'] = '$'; + TokenKind['AMP'] = '&'; + TokenKind['PAREN_L'] = '('; + TokenKind['PAREN_R'] = ')'; + TokenKind['SPREAD'] = '...'; + TokenKind['COLON'] = ':'; + TokenKind['EQUALS'] = '='; + TokenKind['AT'] = '@'; + TokenKind['BRACKET_L'] = '['; + TokenKind['BRACKET_R'] = ']'; + TokenKind['BRACE_L'] = '{'; + TokenKind['PIPE'] = '|'; + TokenKind['BRACE_R'] = '}'; + TokenKind['NAME'] = 'Name'; + TokenKind['INT'] = 'Int'; + TokenKind['FLOAT'] = 'Float'; + TokenKind['STRING'] = 'String'; + TokenKind['BLOCK_STRING'] = 'BlockString'; + TokenKind['COMMENT'] = 'Comment'; +})(TokenKind || (TokenKind = {})); + + +/** + * The enum type representing the token kinds values. + * + * @deprecated Please use `TokenKind`. Will be remove in v17. + */ + + +/***/ }), + +/***/ 7304: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "$_": () => (/* binding */ BREAK), +/* harmony export */ "CK": () => (/* binding */ getVisitFn), +/* harmony export */ "Eu": () => (/* binding */ getEnterLeaveForKind), +/* harmony export */ "Vn": () => (/* binding */ visit), +/* harmony export */ "j1": () => (/* binding */ visitInParallel) +/* harmony export */ }); +/* harmony import */ var _jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7826); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5821); +/* harmony import */ var _ast_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2380); +/* harmony import */ var _kinds_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7359); + + + + +/** + * A visitor is provided to visit, it contains the collection of + * relevant functions to be called during the visitor's traversal. + */ + +const BREAK = Object.freeze({}); +/** + * visit() will walk through an AST using a depth-first traversal, calling + * the visitor's enter function at each node in the traversal, and calling the + * leave function after visiting that node and all of its child nodes. + * + * By returning different values from the enter and leave functions, the + * behavior of the visitor can be altered, including skipping over a sub-tree of + * the AST (by returning false), editing the AST by returning a value or null + * to remove the value, or to stop the whole traversal by returning BREAK. + * + * When using visit() to edit an AST, the original AST will not be modified, and + * a new version of the AST with the changes applied will be returned from the + * visit function. + * + * ```ts + * const editedAST = visit(ast, { + * enter(node, key, parent, path, ancestors) { + * // @return + * // undefined: no action + * // false: skip visiting this node + * // visitor.BREAK: stop visiting altogether + * // null: delete this node + * // any value: replace this node with the returned value + * }, + * leave(node, key, parent, path, ancestors) { + * // @return + * // undefined: no action + * // false: no action + * // visitor.BREAK: stop visiting altogether + * // null: delete this node + * // any value: replace this node with the returned value + * } + * }); + * ``` + * + * Alternatively to providing enter() and leave() functions, a visitor can + * instead provide functions named the same as the kinds of AST nodes, or + * enter/leave visitors at a named key, leading to three permutations of the + * visitor API: + * + * 1) Named visitors triggered when entering a node of a specific kind. + * + * ```ts + * visit(ast, { + * Kind(node) { + * // enter the "Kind" node + * } + * }) + * ``` + * + * 2) Named visitors that trigger upon entering and leaving a node of a specific kind. + * + * ```ts + * visit(ast, { + * Kind: { + * enter(node) { + * // enter the "Kind" node + * } + * leave(node) { + * // leave the "Kind" node + * } + * } + * }) + * ``` + * + * 3) Generic visitors that trigger upon entering and leaving any node. + * + * ```ts + * visit(ast, { + * enter(node) { + * // enter any node + * }, + * leave(node) { + * // leave any node + * } + * }) + * ``` + */ + +function visit(root, visitor, visitorKeys = _ast_mjs__WEBPACK_IMPORTED_MODULE_0__/* .QueryDocumentKeys */ .h8) { + const enterLeaveMap = new Map(); + + for (const kind of Object.values(_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind */ .h)) { + enterLeaveMap.set(kind, getEnterLeaveForKind(visitor, kind)); + } + /* eslint-disable no-undef-init */ + + let stack = undefined; + let inArray = Array.isArray(root); + let keys = [root]; + let index = -1; + let edits = []; + let node = root; + let key = undefined; + let parent = undefined; + const path = []; + const ancestors = []; + /* eslint-enable no-undef-init */ + + do { + index++; + const isLeaving = index === keys.length; + const isEdited = isLeaving && edits.length !== 0; + + if (isLeaving) { + key = ancestors.length === 0 ? undefined : path[path.length - 1]; + node = parent; + parent = ancestors.pop(); + + if (isEdited) { + if (inArray) { + node = node.slice(); + let editOffset = 0; + + for (const [editKey, editValue] of edits) { + const arrayKey = editKey - editOffset; + + if (editValue === null) { + node.splice(arrayKey, 1); + editOffset++; + } else { + node[arrayKey] = editValue; + } + } + } else { + node = Object.defineProperties( + {}, + Object.getOwnPropertyDescriptors(node), + ); + + for (const [editKey, editValue] of edits) { + node[editKey] = editValue; + } + } + } + + index = stack.index; + keys = stack.keys; + edits = stack.edits; + inArray = stack.inArray; + stack = stack.prev; + } else if (parent) { + key = inArray ? index : keys[index]; + node = parent[key]; + + if (node === null || node === undefined) { + continue; + } + + path.push(key); + } + + let result; + + if (!Array.isArray(node)) { + var _enterLeaveMap$get, _enterLeaveMap$get2; + + (0,_ast_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isNode */ .UG)(node) || (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_2__/* .devAssert */ .a)(false, `Invalid AST Node: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(node)}.`); + const visitFn = isLeaving + ? (_enterLeaveMap$get = enterLeaveMap.get(node.kind)) === null || + _enterLeaveMap$get === void 0 + ? void 0 + : _enterLeaveMap$get.leave + : (_enterLeaveMap$get2 = enterLeaveMap.get(node.kind)) === null || + _enterLeaveMap$get2 === void 0 + ? void 0 + : _enterLeaveMap$get2.enter; + result = + visitFn === null || visitFn === void 0 + ? void 0 + : visitFn.call(visitor, node, key, parent, path, ancestors); + + if (result === BREAK) { + break; + } + + if (result === false) { + if (!isLeaving) { + path.pop(); + continue; + } + } else if (result !== undefined) { + edits.push([key, result]); + + if (!isLeaving) { + if ((0,_ast_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isNode */ .UG)(result)) { + node = result; + } else { + path.pop(); + continue; + } + } + } + } + + if (result === undefined && isEdited) { + edits.push([key, node]); + } + + if (isLeaving) { + path.pop(); + } else { + var _node$kind; + + stack = { + inArray, + index, + keys, + edits, + prev: stack, + }; + inArray = Array.isArray(node); + keys = inArray + ? node + : (_node$kind = visitorKeys[node.kind]) !== null && + _node$kind !== void 0 + ? _node$kind + : []; + index = -1; + edits = []; + + if (parent) { + ancestors.push(parent); + } + + parent = node; + } + } while (stack !== undefined); + + if (edits.length !== 0) { + // New root + return edits[edits.length - 1][1]; + } + + return root; +} +/** + * Creates a new visitor instance which delegates to many visitors to run in + * parallel. Each visitor will be visited for each node before moving on. + * + * If a prior visitor edits a node, no following visitors will see that node. + */ + +function visitInParallel(visitors) { + const skipping = new Array(visitors.length).fill(null); + const mergedVisitor = Object.create(null); + + for (const kind of Object.values(_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind */ .h)) { + let hasVisitor = false; + const enterList = new Array(visitors.length).fill(undefined); + const leaveList = new Array(visitors.length).fill(undefined); + + for (let i = 0; i < visitors.length; ++i) { + const { enter, leave } = getEnterLeaveForKind(visitors[i], kind); + hasVisitor || (hasVisitor = enter != null || leave != null); + enterList[i] = enter; + leaveList[i] = leave; + } + + if (!hasVisitor) { + continue; + } + + const mergedEnterLeave = { + enter(...args) { + const node = args[0]; + + for (let i = 0; i < visitors.length; i++) { + if (skipping[i] === null) { + var _enterList$i; + + const result = + (_enterList$i = enterList[i]) === null || _enterList$i === void 0 + ? void 0 + : _enterList$i.apply(visitors[i], args); + + if (result === false) { + skipping[i] = node; + } else if (result === BREAK) { + skipping[i] = BREAK; + } else if (result !== undefined) { + return result; + } + } + } + }, + + leave(...args) { + const node = args[0]; + + for (let i = 0; i < visitors.length; i++) { + if (skipping[i] === null) { + var _leaveList$i; + + const result = + (_leaveList$i = leaveList[i]) === null || _leaveList$i === void 0 + ? void 0 + : _leaveList$i.apply(visitors[i], args); + + if (result === BREAK) { + skipping[i] = BREAK; + } else if (result !== undefined && result !== false) { + return result; + } + } else if (skipping[i] === node) { + skipping[i] = null; + } + } + }, + }; + mergedVisitor[kind] = mergedEnterLeave; + } + + return mergedVisitor; +} +/** + * Given a visitor instance and a node kind, return EnterLeaveVisitor for that kind. + */ + +function getEnterLeaveForKind(visitor, kind) { + const kindVisitor = visitor[kind]; + + if (typeof kindVisitor === 'object') { + // { Kind: { enter() {}, leave() {} } } + return kindVisitor; + } else if (typeof kindVisitor === 'function') { + // { Kind() {} } + return { + enter: kindVisitor, + leave: undefined, + }; + } // { enter() {}, leave() {} } + + return { + enter: visitor.enter, + leave: visitor.leave, + }; +} +/** + * Given a visitor instance, if it is leaving or not, and a node kind, return + * the function the visitor runtime should call. + * + * @deprecated Please use `getEnterLeaveForKind` instead. Will be removed in v17 + */ + +/* c8 ignore next 8 */ + +function getVisitFn(visitor, kind, isLeaving) { + const { enter, leave } = getEnterLeaveForKind(visitor, kind); + return isLeaving ? leave : enter; +} + + +/***/ }), + +/***/ 6303: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "g": () => (/* binding */ assertEnumValueName), +/* harmony export */ "i": () => (/* binding */ assertName) +/* harmony export */ }); +/* harmony import */ var _jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7826); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); +/* harmony import */ var _language_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8297); + + + +/** + * Upholds the spec rules about naming. + */ + +function assertName(name) { + name != null || (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_0__/* .devAssert */ .a)(false, 'Must provide name.'); + typeof name === 'string' || (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_0__/* .devAssert */ .a)(false, 'Expected name to be a string.'); + + if (name.length === 0) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__('Expected name to be a non-empty string.'); + } + + for (let i = 1; i < name.length; ++i) { + if (!(0,_language_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNameContinue */ .HQ)(name.charCodeAt(i))) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Names must only contain [_a-zA-Z0-9] but "${name}" does not.`, + ); + } + } + + if (!(0,_language_characterClasses_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNameStart */ .LQ)(name.charCodeAt(0))) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Names must start with [_a-zA-Z] but "${name}" does not.`, + ); + } + + return name; +} +/** + * Upholds the spec rules about naming enum values. + * + * @internal + */ + +function assertEnumValueName(name) { + if (name === 'true' || name === 'false' || name === 'null') { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__(`Enum values cannot be named: ${name}`); + } + + return assertName(name); +} + + +/***/ }), + +/***/ 398: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "mR": () => (/* binding */ GraphQLEnumType), + "sR": () => (/* binding */ GraphQLInputObjectType), + "oW": () => (/* binding */ GraphQLInterfaceType), + "p2": () => (/* binding */ GraphQLList), + "bM": () => (/* binding */ GraphQLNonNull), + "h6": () => (/* binding */ GraphQLObjectType), + "n2": () => (/* binding */ GraphQLScalarType), + "Gp": () => (/* binding */ GraphQLUnionType), + "DM": () => (/* binding */ argsToArgsConfig), + "fU": () => (/* binding */ assertAbstractType), + "M_": () => (/* binding */ assertCompositeType), + "Zu": () => (/* binding */ assertEnumType), + "U8": () => (/* binding */ assertInputObjectType), + "qT": () => (/* binding */ assertInputType), + "k2": () => (/* binding */ assertInterfaceType), + "H5": () => (/* binding */ assertLeafType), + "kS": () => (/* binding */ assertListType), + "rM": () => (/* binding */ assertNamedType), + "E$": () => (/* binding */ assertNonNullType), + "i_": () => (/* binding */ assertNullableType), + "Z6": () => (/* binding */ assertObjectType), + "Gt": () => (/* binding */ assertOutputType), + "Pt": () => (/* binding */ assertScalarType), + "p_": () => (/* binding */ assertType), + "rc": () => (/* binding */ assertUnionType), + "vX": () => (/* binding */ assertWrappingType), + "WO": () => (/* binding */ defineArguments), + "xC": () => (/* binding */ getNamedType), + "tf": () => (/* binding */ getNullableType), + "m0": () => (/* binding */ isAbstractType), + "Gv": () => (/* binding */ isCompositeType), + "EM": () => (/* binding */ isEnumType), + "hL": () => (/* binding */ isInputObjectType), + "j$": () => (/* binding */ isInputType), + "oT": () => (/* binding */ isInterfaceType), + "UT": () => (/* binding */ isLeafType), + "HG": () => (/* binding */ isListType), + "Zs": () => (/* binding */ isNamedType), + "zM": () => (/* binding */ isNonNullType), + "zP": () => (/* binding */ isNullableType), + "lp": () => (/* binding */ isObjectType), + "SZ": () => (/* binding */ isOutputType), + "dK": () => (/* binding */ isRequiredArgument), + "Wd": () => (/* binding */ isRequiredInputField), + "KA": () => (/* binding */ isScalarType), + "P9": () => (/* binding */ isType), + "EN": () => (/* binding */ isUnionType), + "fw": () => (/* binding */ isWrappingType), + "WB": () => (/* binding */ resolveObjMapThunk), + "_9": () => (/* binding */ resolveReadonlyArrayThunk) +}); + +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/devAssert.mjs +var devAssert = __webpack_require__(7826); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/didYouMean.mjs +var didYouMean = __webpack_require__(3177); +;// CONCATENATED MODULE: ./node_modules/graphql/jsutils/identityFunc.mjs +/** + * Returns the first argument it receives. + */ +function identityFunc(x) { + return x; +} + +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/inspect.mjs +var inspect = __webpack_require__(5821); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/instanceOf.mjs +var instanceOf = __webpack_require__(8306); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/isObjectLike.mjs +var isObjectLike = __webpack_require__(8495); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/keyMap.mjs +var keyMap = __webpack_require__(3498); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/keyValMap.mjs +var keyValMap = __webpack_require__(4950); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/mapValue.mjs +var mapValue = __webpack_require__(5723); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/suggestionList.mjs +var suggestionList = __webpack_require__(3294); +// EXTERNAL MODULE: ./node_modules/graphql/jsutils/toObjMap.mjs +var toObjMap = __webpack_require__(8824); +// EXTERNAL MODULE: ./node_modules/graphql/error/GraphQLError.mjs +var GraphQLError = __webpack_require__(8087); +// EXTERNAL MODULE: ./node_modules/graphql/language/kinds.mjs +var kinds = __webpack_require__(7359); +// EXTERNAL MODULE: ./node_modules/graphql/language/printer.mjs + 1 modules +var printer = __webpack_require__(3486); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/valueFromASTUntyped.mjs +var valueFromASTUntyped = __webpack_require__(2319); +// EXTERNAL MODULE: ./node_modules/graphql/type/assertName.mjs +var assertName = __webpack_require__(6303); +;// CONCATENATED MODULE: ./node_modules/graphql/type/definition.mjs + + + + + + + + + + + + + + + + +function isType(type) { + return ( + isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + isInputObjectType(type) || + isListType(type) || + isNonNullType(type) + ); +} +function assertType(type) { + if (!isType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL type.`); + } + + return type; +} +/** + * There are predicates for each kind of GraphQL type. + */ + +function isScalarType(type) { + return (0,instanceOf/* instanceOf */.n)(type, GraphQLScalarType); +} +function assertScalarType(type) { + if (!isScalarType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL Scalar type.`); + } + + return type; +} +function isObjectType(type) { + return (0,instanceOf/* instanceOf */.n)(type, GraphQLObjectType); +} +function assertObjectType(type) { + if (!isObjectType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL Object type.`); + } + + return type; +} +function isInterfaceType(type) { + return (0,instanceOf/* instanceOf */.n)(type, GraphQLInterfaceType); +} +function assertInterfaceType(type) { + if (!isInterfaceType(type)) { + throw new Error( + `Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL Interface type.`, + ); + } + + return type; +} +function isUnionType(type) { + return (0,instanceOf/* instanceOf */.n)(type, GraphQLUnionType); +} +function assertUnionType(type) { + if (!isUnionType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL Union type.`); + } + + return type; +} +function isEnumType(type) { + return (0,instanceOf/* instanceOf */.n)(type, GraphQLEnumType); +} +function assertEnumType(type) { + if (!isEnumType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL Enum type.`); + } + + return type; +} +function isInputObjectType(type) { + return (0,instanceOf/* instanceOf */.n)(type, GraphQLInputObjectType); +} +function assertInputObjectType(type) { + if (!isInputObjectType(type)) { + throw new Error( + `Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL Input Object type.`, + ); + } + + return type; +} +function isListType(type) { + return (0,instanceOf/* instanceOf */.n)(type, GraphQLList); +} +function assertListType(type) { + if (!isListType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL List type.`); + } + + return type; +} +function isNonNullType(type) { + return (0,instanceOf/* instanceOf */.n)(type, GraphQLNonNull); +} +function assertNonNullType(type) { + if (!isNonNullType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL Non-Null type.`); + } + + return type; +} +/** + * These types may be used as input types for arguments and directives. + */ + +function isInputType(type) { + return ( + isScalarType(type) || + isEnumType(type) || + isInputObjectType(type) || + (isWrappingType(type) && isInputType(type.ofType)) + ); +} +function assertInputType(type) { + if (!isInputType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL input type.`); + } + + return type; +} +/** + * These types may be used as output types as the result of fields. + */ + +function isOutputType(type) { + return ( + isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + (isWrappingType(type) && isOutputType(type.ofType)) + ); +} +function assertOutputType(type) { + if (!isOutputType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL output type.`); + } + + return type; +} +/** + * These types may describe types which may be leaf values. + */ + +function isLeafType(type) { + return isScalarType(type) || isEnumType(type); +} +function assertLeafType(type) { + if (!isLeafType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL leaf type.`); + } + + return type; +} +/** + * These types may describe the parent context of a selection set. + */ + +function isCompositeType(type) { + return isObjectType(type) || isInterfaceType(type) || isUnionType(type); +} +function assertCompositeType(type) { + if (!isCompositeType(type)) { + throw new Error( + `Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL composite type.`, + ); + } + + return type; +} +/** + * These types may describe the parent context of a selection set. + */ + +function isAbstractType(type) { + return isInterfaceType(type) || isUnionType(type); +} +function assertAbstractType(type) { + if (!isAbstractType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL abstract type.`); + } + + return type; +} +/** + * List Type Wrapper + * + * A list is a wrapping type which points to another type. + * Lists are often created within the context of defining the fields of + * an object type. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * parents: { type: new GraphQLList(PersonType) }, + * children: { type: new GraphQLList(PersonType) }, + * }) + * }) + * ``` + */ + +class GraphQLList { + constructor(ofType) { + isType(ofType) || + (0,devAssert/* devAssert */.a)(false, `Expected ${(0,inspect/* inspect */.X)(ofType)} to be a GraphQL type.`); + this.ofType = ofType; + } + + get [Symbol.toStringTag]() { + return 'GraphQLList'; + } + + toString() { + return '[' + String(this.ofType) + ']'; + } + + toJSON() { + return this.toString(); + } +} +/** + * Non-Null Type Wrapper + * + * A non-null is a wrapping type which points to another type. + * Non-null types enforce that their values are never null and can ensure + * an error is raised if this ever occurs during a request. It is useful for + * fields which you can make a strong guarantee on non-nullability, for example + * usually the id field of a database row will never be null. + * + * Example: + * + * ```ts + * const RowType = new GraphQLObjectType({ + * name: 'Row', + * fields: () => ({ + * id: { type: new GraphQLNonNull(GraphQLString) }, + * }) + * }) + * ``` + * Note: the enforcement of non-nullability occurs within the executor. + */ + +class GraphQLNonNull { + constructor(ofType) { + isNullableType(ofType) || + (0,devAssert/* devAssert */.a)( + false, + `Expected ${(0,inspect/* inspect */.X)(ofType)} to be a GraphQL nullable type.`, + ); + this.ofType = ofType; + } + + get [Symbol.toStringTag]() { + return 'GraphQLNonNull'; + } + + toString() { + return String(this.ofType) + '!'; + } + + toJSON() { + return this.toString(); + } +} +/** + * These types wrap and modify other types + */ + +function isWrappingType(type) { + return isListType(type) || isNonNullType(type); +} +function assertWrappingType(type) { + if (!isWrappingType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL wrapping type.`); + } + + return type; +} +/** + * These types can all accept null as a value. + */ + +function isNullableType(type) { + return isType(type) && !isNonNullType(type); +} +function assertNullableType(type) { + if (!isNullableType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL nullable type.`); + } + + return type; +} +function getNullableType(type) { + if (type) { + return isNonNullType(type) ? type.ofType : type; + } +} +/** + * These named types do not include modifiers like List or NonNull. + */ + +function isNamedType(type) { + return ( + isScalarType(type) || + isObjectType(type) || + isInterfaceType(type) || + isUnionType(type) || + isEnumType(type) || + isInputObjectType(type) + ); +} +function assertNamedType(type) { + if (!isNamedType(type)) { + throw new Error(`Expected ${(0,inspect/* inspect */.X)(type)} to be a GraphQL named type.`); + } + + return type; +} +function getNamedType(type) { + if (type) { + let unwrappedType = type; + + while (isWrappingType(unwrappedType)) { + unwrappedType = unwrappedType.ofType; + } + + return unwrappedType; + } +} +/** + * Used while defining GraphQL types to allow for circular references in + * otherwise immutable type definitions. + */ + +function resolveReadonlyArrayThunk(thunk) { + return typeof thunk === 'function' ? thunk() : thunk; +} +function resolveObjMapThunk(thunk) { + return typeof thunk === 'function' ? thunk() : thunk; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ + +/** + * Scalar Type Definition + * + * The leaf values of any request and input values to arguments are + * Scalars (or Enums) and are defined with a name and a series of functions + * used to parse input from ast or variables and to ensure validity. + * + * If a type's serialize function returns `null` or does not return a value + * (i.e. it returns `undefined`) then an error will be raised and a `null` + * value will be returned in the response. It is always better to validate + * + * Example: + * + * ```ts + * const OddType = new GraphQLScalarType({ + * name: 'Odd', + * serialize(value) { + * if (!Number.isFinite(value)) { + * throw new Error( + * `Scalar "Odd" cannot represent "${value}" since it is not a finite number.`, + * ); + * } + * + * if (value % 2 === 0) { + * throw new Error(`Scalar "Odd" cannot represent "${value}" since it is even.`); + * } + * return value; + * } + * }); + * ``` + */ +class GraphQLScalarType { + constructor(config) { + var _config$parseValue, + _config$serialize, + _config$parseLiteral, + _config$extensionASTN; + + const parseValue = + (_config$parseValue = config.parseValue) !== null && + _config$parseValue !== void 0 + ? _config$parseValue + : identityFunc; + this.name = (0,assertName/* assertName */.i)(config.name); + this.description = config.description; + this.specifiedByURL = config.specifiedByURL; + this.serialize = + (_config$serialize = config.serialize) !== null && + _config$serialize !== void 0 + ? _config$serialize + : identityFunc; + this.parseValue = parseValue; + this.parseLiteral = + (_config$parseLiteral = config.parseLiteral) !== null && + _config$parseLiteral !== void 0 + ? _config$parseLiteral + : (node, variables) => parseValue((0,valueFromASTUntyped/* valueFromASTUntyped */.M)(node, variables)); + this.extensions = (0,toObjMap/* toObjMap */.u)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN = config.extensionASTNodes) !== null && + _config$extensionASTN !== void 0 + ? _config$extensionASTN + : []; + config.specifiedByURL == null || + typeof config.specifiedByURL === 'string' || + (0,devAssert/* devAssert */.a)( + false, + `${this.name} must provide "specifiedByURL" as a string, ` + + `but got: ${(0,inspect/* inspect */.X)(config.specifiedByURL)}.`, + ); + config.serialize == null || + typeof config.serialize === 'function' || + (0,devAssert/* devAssert */.a)( + false, + `${this.name} must provide "serialize" function. If this custom Scalar is also used as an input type, ensure "parseValue" and "parseLiteral" functions are also provided.`, + ); + + if (config.parseLiteral) { + (typeof config.parseValue === 'function' && + typeof config.parseLiteral === 'function') || + (0,devAssert/* devAssert */.a)( + false, + `${this.name} must provide both "parseValue" and "parseLiteral" functions.`, + ); + } + } + + get [Symbol.toStringTag]() { + return 'GraphQLScalarType'; + } + + toConfig() { + return { + name: this.name, + description: this.description, + specifiedByURL: this.specifiedByURL, + serialize: this.serialize, + parseValue: this.parseValue, + parseLiteral: this.parseLiteral, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +/** + * Object Type Definition + * + * Almost all of the GraphQL types you define will be object types. Object types + * have a name, but most importantly describe their fields. + * + * Example: + * + * ```ts + * const AddressType = new GraphQLObjectType({ + * name: 'Address', + * fields: { + * street: { type: GraphQLString }, + * number: { type: GraphQLInt }, + * formatted: { + * type: GraphQLString, + * resolve(obj) { + * return obj.number + ' ' + obj.street + * } + * } + * } + * }); + * ``` + * + * When two types need to refer to each other, or a type needs to refer to + * itself in a field, you can use a function expression (aka a closure or a + * thunk) to supply the fields lazily. + * + * Example: + * + * ```ts + * const PersonType = new GraphQLObjectType({ + * name: 'Person', + * fields: () => ({ + * name: { type: GraphQLString }, + * bestFriend: { type: PersonType }, + * }) + * }); + * ``` + */ +class GraphQLObjectType { + constructor(config) { + var _config$extensionASTN2; + + this.name = (0,assertName/* assertName */.i)(config.name); + this.description = config.description; + this.isTypeOf = config.isTypeOf; + this.extensions = (0,toObjMap/* toObjMap */.u)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN2 = config.extensionASTNodes) !== null && + _config$extensionASTN2 !== void 0 + ? _config$extensionASTN2 + : []; + + this._fields = () => defineFieldMap(config); + + this._interfaces = () => defineInterfaces(config); + + config.isTypeOf == null || + typeof config.isTypeOf === 'function' || + (0,devAssert/* devAssert */.a)( + false, + `${this.name} must provide "isTypeOf" as a function, ` + + `but got: ${(0,inspect/* inspect */.X)(config.isTypeOf)}.`, + ); + } + + get [Symbol.toStringTag]() { + return 'GraphQLObjectType'; + } + + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + + return this._fields; + } + + getInterfaces() { + if (typeof this._interfaces === 'function') { + this._interfaces = this._interfaces(); + } + + return this._interfaces; + } + + toConfig() { + return { + name: this.name, + description: this.description, + interfaces: this.getInterfaces(), + fields: fieldsToFieldsConfig(this.getFields()), + isTypeOf: this.isTypeOf, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +function defineInterfaces(config) { + var _config$interfaces; + + const interfaces = resolveReadonlyArrayThunk( + (_config$interfaces = config.interfaces) !== null && + _config$interfaces !== void 0 + ? _config$interfaces + : [], + ); + Array.isArray(interfaces) || + (0,devAssert/* devAssert */.a)( + false, + `${config.name} interfaces must be an Array or a function which returns an Array.`, + ); + return interfaces; +} + +function defineFieldMap(config) { + const fieldMap = resolveObjMapThunk(config.fields); + isPlainObj(fieldMap) || + (0,devAssert/* devAssert */.a)( + false, + `${config.name} fields must be an object with field names as keys or a function which returns such an object.`, + ); + return (0,mapValue/* mapValue */.j)(fieldMap, (fieldConfig, fieldName) => { + var _fieldConfig$args; + + isPlainObj(fieldConfig) || + (0,devAssert/* devAssert */.a)( + false, + `${config.name}.${fieldName} field config must be an object.`, + ); + fieldConfig.resolve == null || + typeof fieldConfig.resolve === 'function' || + (0,devAssert/* devAssert */.a)( + false, + `${config.name}.${fieldName} field resolver must be a function if ` + + `provided, but got: ${(0,inspect/* inspect */.X)(fieldConfig.resolve)}.`, + ); + const argsConfig = + (_fieldConfig$args = fieldConfig.args) !== null && + _fieldConfig$args !== void 0 + ? _fieldConfig$args + : {}; + isPlainObj(argsConfig) || + (0,devAssert/* devAssert */.a)( + false, + `${config.name}.${fieldName} args must be an object with argument names as keys.`, + ); + return { + name: (0,assertName/* assertName */.i)(fieldName), + description: fieldConfig.description, + type: fieldConfig.type, + args: defineArguments(argsConfig), + resolve: fieldConfig.resolve, + subscribe: fieldConfig.subscribe, + deprecationReason: fieldConfig.deprecationReason, + extensions: (0,toObjMap/* toObjMap */.u)(fieldConfig.extensions), + astNode: fieldConfig.astNode, + }; + }); +} + +function defineArguments(config) { + return Object.entries(config).map(([argName, argConfig]) => ({ + name: (0,assertName/* assertName */.i)(argName), + description: argConfig.description, + type: argConfig.type, + defaultValue: argConfig.defaultValue, + deprecationReason: argConfig.deprecationReason, + extensions: (0,toObjMap/* toObjMap */.u)(argConfig.extensions), + astNode: argConfig.astNode, + })); +} + +function isPlainObj(obj) { + return (0,isObjectLike/* isObjectLike */.y)(obj) && !Array.isArray(obj); +} + +function fieldsToFieldsConfig(fields) { + return (0,mapValue/* mapValue */.j)(fields, (field) => ({ + description: field.description, + type: field.type, + args: argsToArgsConfig(field.args), + resolve: field.resolve, + subscribe: field.subscribe, + deprecationReason: field.deprecationReason, + extensions: field.extensions, + astNode: field.astNode, + })); +} +/** + * @internal + */ + +function argsToArgsConfig(args) { + return (0,keyValMap/* keyValMap */.w)( + args, + (arg) => arg.name, + (arg) => ({ + description: arg.description, + type: arg.type, + defaultValue: arg.defaultValue, + deprecationReason: arg.deprecationReason, + extensions: arg.extensions, + astNode: arg.astNode, + }), + ); +} +function isRequiredArgument(arg) { + return isNonNullType(arg.type) && arg.defaultValue === undefined; +} + +/** + * Interface Type Definition + * + * When a field can return one of a heterogeneous set of types, a Interface type + * is used to describe what types are possible, what fields are in common across + * all types, as well as a function to determine which type is actually used + * when the field is resolved. + * + * Example: + * + * ```ts + * const EntityType = new GraphQLInterfaceType({ + * name: 'Entity', + * fields: { + * name: { type: GraphQLString } + * } + * }); + * ``` + */ +class GraphQLInterfaceType { + constructor(config) { + var _config$extensionASTN3; + + this.name = (0,assertName/* assertName */.i)(config.name); + this.description = config.description; + this.resolveType = config.resolveType; + this.extensions = (0,toObjMap/* toObjMap */.u)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN3 = config.extensionASTNodes) !== null && + _config$extensionASTN3 !== void 0 + ? _config$extensionASTN3 + : []; + this._fields = defineFieldMap.bind(undefined, config); + this._interfaces = defineInterfaces.bind(undefined, config); + config.resolveType == null || + typeof config.resolveType === 'function' || + (0,devAssert/* devAssert */.a)( + false, + `${this.name} must provide "resolveType" as a function, ` + + `but got: ${(0,inspect/* inspect */.X)(config.resolveType)}.`, + ); + } + + get [Symbol.toStringTag]() { + return 'GraphQLInterfaceType'; + } + + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + + return this._fields; + } + + getInterfaces() { + if (typeof this._interfaces === 'function') { + this._interfaces = this._interfaces(); + } + + return this._interfaces; + } + + toConfig() { + return { + name: this.name, + description: this.description, + interfaces: this.getInterfaces(), + fields: fieldsToFieldsConfig(this.getFields()), + resolveType: this.resolveType, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +/** + * Union Type Definition + * + * When a field can return one of a heterogeneous set of types, a Union type + * is used to describe what types are possible as well as providing a function + * to determine which type is actually used when the field is resolved. + * + * Example: + * + * ```ts + * const PetType = new GraphQLUnionType({ + * name: 'Pet', + * types: [ DogType, CatType ], + * resolveType(value) { + * if (value instanceof Dog) { + * return DogType; + * } + * if (value instanceof Cat) { + * return CatType; + * } + * } + * }); + * ``` + */ +class GraphQLUnionType { + constructor(config) { + var _config$extensionASTN4; + + this.name = (0,assertName/* assertName */.i)(config.name); + this.description = config.description; + this.resolveType = config.resolveType; + this.extensions = (0,toObjMap/* toObjMap */.u)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN4 = config.extensionASTNodes) !== null && + _config$extensionASTN4 !== void 0 + ? _config$extensionASTN4 + : []; + this._types = defineTypes.bind(undefined, config); + config.resolveType == null || + typeof config.resolveType === 'function' || + (0,devAssert/* devAssert */.a)( + false, + `${this.name} must provide "resolveType" as a function, ` + + `but got: ${(0,inspect/* inspect */.X)(config.resolveType)}.`, + ); + } + + get [Symbol.toStringTag]() { + return 'GraphQLUnionType'; + } + + getTypes() { + if (typeof this._types === 'function') { + this._types = this._types(); + } + + return this._types; + } + + toConfig() { + return { + name: this.name, + description: this.description, + types: this.getTypes(), + resolveType: this.resolveType, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +function defineTypes(config) { + const types = resolveReadonlyArrayThunk(config.types); + Array.isArray(types) || + (0,devAssert/* devAssert */.a)( + false, + `Must provide Array of types or a function which returns such an array for Union ${config.name}.`, + ); + return types; +} + +/** + * Enum Type Definition + * + * Some leaf values of requests and input values are Enums. GraphQL serializes + * Enum values as strings, however internally Enums can be represented by any + * kind of type, often integers. + * + * Example: + * + * ```ts + * const RGBType = new GraphQLEnumType({ + * name: 'RGB', + * values: { + * RED: { value: 0 }, + * GREEN: { value: 1 }, + * BLUE: { value: 2 } + * } + * }); + * ``` + * + * Note: If a value is not provided in a definition, the name of the enum value + * will be used as its internal value. + */ +class GraphQLEnumType { + /* */ + constructor(config) { + var _config$extensionASTN5; + + this.name = (0,assertName/* assertName */.i)(config.name); + this.description = config.description; + this.extensions = (0,toObjMap/* toObjMap */.u)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN5 = config.extensionASTNodes) !== null && + _config$extensionASTN5 !== void 0 + ? _config$extensionASTN5 + : []; + this._values = defineEnumValues(this.name, config.values); + this._valueLookup = new Map( + this._values.map((enumValue) => [enumValue.value, enumValue]), + ); + this._nameLookup = (0,keyMap/* keyMap */.P)(this._values, (value) => value.name); + } + + get [Symbol.toStringTag]() { + return 'GraphQLEnumType'; + } + + getValues() { + return this._values; + } + + getValue(name) { + return this._nameLookup[name]; + } + + serialize(outputValue) { + const enumValue = this._valueLookup.get(outputValue); + + if (enumValue === undefined) { + throw new GraphQLError/* GraphQLError */.__( + `Enum "${this.name}" cannot represent value: ${(0,inspect/* inspect */.X)(outputValue)}`, + ); + } + + return enumValue.name; + } + + parseValue(inputValue) /* T */ + { + if (typeof inputValue !== 'string') { + const valueStr = (0,inspect/* inspect */.X)(inputValue); + throw new GraphQLError/* GraphQLError */.__( + `Enum "${this.name}" cannot represent non-string value: ${valueStr}.` + + didYouMeanEnumValue(this, valueStr), + ); + } + + const enumValue = this.getValue(inputValue); + + if (enumValue == null) { + throw new GraphQLError/* GraphQLError */.__( + `Value "${inputValue}" does not exist in "${this.name}" enum.` + + didYouMeanEnumValue(this, inputValue), + ); + } + + return enumValue.value; + } + + parseLiteral(valueNode, _variables) /* T */ + { + // Note: variables will be resolved to a value before calling this function. + if (valueNode.kind !== kinds/* Kind.ENUM */.h.ENUM) { + const valueStr = (0,printer/* print */.S)(valueNode); + throw new GraphQLError/* GraphQLError */.__( + `Enum "${this.name}" cannot represent non-enum value: ${valueStr}.` + + didYouMeanEnumValue(this, valueStr), + { + nodes: valueNode, + }, + ); + } + + const enumValue = this.getValue(valueNode.value); + + if (enumValue == null) { + const valueStr = (0,printer/* print */.S)(valueNode); + throw new GraphQLError/* GraphQLError */.__( + `Value "${valueStr}" does not exist in "${this.name}" enum.` + + didYouMeanEnumValue(this, valueStr), + { + nodes: valueNode, + }, + ); + } + + return enumValue.value; + } + + toConfig() { + const values = (0,keyValMap/* keyValMap */.w)( + this.getValues(), + (value) => value.name, + (value) => ({ + description: value.description, + value: value.value, + deprecationReason: value.deprecationReason, + extensions: value.extensions, + astNode: value.astNode, + }), + ); + return { + name: this.name, + description: this.description, + values, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +function didYouMeanEnumValue(enumType, unknownValueStr) { + const allNames = enumType.getValues().map((value) => value.name); + const suggestedValues = (0,suggestionList/* suggestionList */.D)(unknownValueStr, allNames); + return (0,didYouMean/* didYouMean */.l)('the enum value', suggestedValues); +} + +function defineEnumValues(typeName, valueMap) { + isPlainObj(valueMap) || + (0,devAssert/* devAssert */.a)( + false, + `${typeName} values must be an object with value names as keys.`, + ); + return Object.entries(valueMap).map(([valueName, valueConfig]) => { + isPlainObj(valueConfig) || + (0,devAssert/* devAssert */.a)( + false, + `${typeName}.${valueName} must refer to an object with a "value" key ` + + `representing an internal value but got: ${(0,inspect/* inspect */.X)(valueConfig)}.`, + ); + return { + name: (0,assertName/* assertEnumValueName */.g)(valueName), + description: valueConfig.description, + value: valueConfig.value !== undefined ? valueConfig.value : valueName, + deprecationReason: valueConfig.deprecationReason, + extensions: (0,toObjMap/* toObjMap */.u)(valueConfig.extensions), + astNode: valueConfig.astNode, + }; + }); +} + +/** + * Input Object Type Definition + * + * An input object defines a structured collection of fields which may be + * supplied to a field argument. + * + * Using `NonNull` will ensure that a value must be provided by the query + * + * Example: + * + * ```ts + * const GeoPoint = new GraphQLInputObjectType({ + * name: 'GeoPoint', + * fields: { + * lat: { type: new GraphQLNonNull(GraphQLFloat) }, + * lon: { type: new GraphQLNonNull(GraphQLFloat) }, + * alt: { type: GraphQLFloat, defaultValue: 0 }, + * } + * }); + * ``` + */ +class GraphQLInputObjectType { + constructor(config) { + var _config$extensionASTN6; + + this.name = (0,assertName/* assertName */.i)(config.name); + this.description = config.description; + this.extensions = (0,toObjMap/* toObjMap */.u)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN6 = config.extensionASTNodes) !== null && + _config$extensionASTN6 !== void 0 + ? _config$extensionASTN6 + : []; + this._fields = defineInputFieldMap.bind(undefined, config); + } + + get [Symbol.toStringTag]() { + return 'GraphQLInputObjectType'; + } + + getFields() { + if (typeof this._fields === 'function') { + this._fields = this._fields(); + } + + return this._fields; + } + + toConfig() { + const fields = (0,mapValue/* mapValue */.j)(this.getFields(), (field) => ({ + description: field.description, + type: field.type, + defaultValue: field.defaultValue, + deprecationReason: field.deprecationReason, + extensions: field.extensions, + astNode: field.astNode, + })); + return { + name: this.name, + description: this.description, + fields, + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + }; + } + + toString() { + return this.name; + } + + toJSON() { + return this.toString(); + } +} + +function defineInputFieldMap(config) { + const fieldMap = resolveObjMapThunk(config.fields); + isPlainObj(fieldMap) || + (0,devAssert/* devAssert */.a)( + false, + `${config.name} fields must be an object with field names as keys or a function which returns such an object.`, + ); + return (0,mapValue/* mapValue */.j)(fieldMap, (fieldConfig, fieldName) => { + !('resolve' in fieldConfig) || + (0,devAssert/* devAssert */.a)( + false, + `${config.name}.${fieldName} field has a resolve property, but Input Types cannot define resolvers.`, + ); + return { + name: (0,assertName/* assertName */.i)(fieldName), + description: fieldConfig.description, + type: fieldConfig.type, + defaultValue: fieldConfig.defaultValue, + deprecationReason: fieldConfig.deprecationReason, + extensions: (0,toObjMap/* toObjMap */.u)(fieldConfig.extensions), + astNode: fieldConfig.astNode, + }; + }); +} + +function isRequiredInputField(field) { + return isNonNullType(field.type) && field.defaultValue === undefined; +} + + +/***/ }), + +/***/ 8238: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "CO": () => (/* binding */ assertDirective), +/* harmony export */ "NZ": () => (/* binding */ GraphQLDirective), +/* harmony export */ "QE": () => (/* binding */ GraphQLSkipDirective), +/* harmony export */ "SY": () => (/* binding */ DEFAULT_DEPRECATION_REASON), +/* harmony export */ "V4": () => (/* binding */ specifiedDirectives), +/* harmony export */ "Yf": () => (/* binding */ GraphQLIncludeDirective), +/* harmony export */ "df": () => (/* binding */ GraphQLSpecifiedByDirective), +/* harmony export */ "fg": () => (/* binding */ GraphQLDeprecatedDirective), +/* harmony export */ "wX": () => (/* binding */ isDirective), +/* harmony export */ "xg": () => (/* binding */ isSpecifiedDirective) +/* harmony export */ }); +/* harmony import */ var _jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7826); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_instanceOf_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8306); +/* harmony import */ var _jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8495); +/* harmony import */ var _jsutils_toObjMap_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8824); +/* harmony import */ var _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(9878); +/* harmony import */ var _assertName_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6303); +/* harmony import */ var _definition_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(398); +/* harmony import */ var _scalars_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(3801); + + + + + + + + + +/** + * Test if the given value is a GraphQL directive. + */ + +function isDirective(directive) { + return (0,_jsutils_instanceOf_mjs__WEBPACK_IMPORTED_MODULE_0__/* .instanceOf */ .n)(directive, GraphQLDirective); +} +function assertDirective(directive) { + if (!isDirective(directive)) { + throw new Error( + `Expected ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(directive)} to be a GraphQL directive.`, + ); + } + + return directive; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ + +/** + * Directives are used by the GraphQL runtime as a way of modifying execution + * behavior. Type system creators will usually not create these directly. + */ +class GraphQLDirective { + constructor(config) { + var _config$isRepeatable, _config$args; + + this.name = (0,_assertName_mjs__WEBPACK_IMPORTED_MODULE_2__/* .assertName */ .i)(config.name); + this.description = config.description; + this.locations = config.locations; + this.isRepeatable = + (_config$isRepeatable = config.isRepeatable) !== null && + _config$isRepeatable !== void 0 + ? _config$isRepeatable + : false; + this.extensions = (0,_jsutils_toObjMap_mjs__WEBPACK_IMPORTED_MODULE_3__/* .toObjMap */ .u)(config.extensions); + this.astNode = config.astNode; + Array.isArray(config.locations) || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_4__/* .devAssert */ .a)(false, `@${config.name} locations must be an Array.`); + const args = + (_config$args = config.args) !== null && _config$args !== void 0 + ? _config$args + : {}; + ((0,_jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isObjectLike */ .y)(args) && !Array.isArray(args)) || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_4__/* .devAssert */ .a)( + false, + `@${config.name} args must be an object with argument names as keys.`, + ); + this.args = (0,_definition_mjs__WEBPACK_IMPORTED_MODULE_6__/* .defineArguments */ .WO)(args); + } + + get [Symbol.toStringTag]() { + return 'GraphQLDirective'; + } + + toConfig() { + return { + name: this.name, + description: this.description, + locations: this.locations, + args: (0,_definition_mjs__WEBPACK_IMPORTED_MODULE_6__/* .argsToArgsConfig */ .DM)(this.args), + isRepeatable: this.isRepeatable, + extensions: this.extensions, + astNode: this.astNode, + }; + } + + toString() { + return '@' + this.name; + } + + toJSON() { + return this.toString(); + } +} + +/** + * Used to conditionally include fields or fragments. + */ +const GraphQLIncludeDirective = new GraphQLDirective({ + name: 'include', + description: + 'Directs the executor to include this field or fragment only when the `if` argument is true.', + locations: [ + _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.FIELD */ .B.FIELD, + _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.FRAGMENT_SPREAD */ .B.FRAGMENT_SPREAD, + _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.INLINE_FRAGMENT */ .B.INLINE_FRAGMENT, + ], + args: { + if: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_6__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_8__/* .GraphQLBoolean */ .EZ), + description: 'Included when true.', + }, + }, +}); +/** + * Used to conditionally skip (exclude) fields or fragments. + */ + +const GraphQLSkipDirective = new GraphQLDirective({ + name: 'skip', + description: + 'Directs the executor to skip this field or fragment when the `if` argument is true.', + locations: [ + _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.FIELD */ .B.FIELD, + _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.FRAGMENT_SPREAD */ .B.FRAGMENT_SPREAD, + _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.INLINE_FRAGMENT */ .B.INLINE_FRAGMENT, + ], + args: { + if: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_6__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_8__/* .GraphQLBoolean */ .EZ), + description: 'Skipped when true.', + }, + }, +}); +/** + * Constant string used for default reason for a deprecation. + */ + +const DEFAULT_DEPRECATION_REASON = 'No longer supported'; +/** + * Used to declare element of a GraphQL schema as deprecated. + */ + +const GraphQLDeprecatedDirective = new GraphQLDirective({ + name: 'deprecated', + description: 'Marks an element of a GraphQL schema as no longer supported.', + locations: [ + _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.FIELD_DEFINITION */ .B.FIELD_DEFINITION, + _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.ARGUMENT_DEFINITION */ .B.ARGUMENT_DEFINITION, + _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.INPUT_FIELD_DEFINITION */ .B.INPUT_FIELD_DEFINITION, + _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.ENUM_VALUE */ .B.ENUM_VALUE, + ], + args: { + reason: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_8__/* .GraphQLString */ .kH, + description: + 'Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted using the Markdown syntax, as specified by [CommonMark](https://commonmark.org/).', + defaultValue: DEFAULT_DEPRECATION_REASON, + }, + }, +}); +/** + * Used to provide a URL for specifying the behavior of custom scalar definitions. + */ + +const GraphQLSpecifiedByDirective = new GraphQLDirective({ + name: 'specifiedBy', + description: 'Exposes a URL that specifies the behavior of this scalar.', + locations: [_language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_7__/* .DirectiveLocation.SCALAR */ .B.SCALAR], + args: { + url: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_6__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_8__/* .GraphQLString */ .kH), + description: 'The URL that specifies the behavior of this scalar.', + }, + }, +}); +/** + * The full list of specified directives. + */ + +const specifiedDirectives = Object.freeze([ + GraphQLIncludeDirective, + GraphQLSkipDirective, + GraphQLDeprecatedDirective, + GraphQLSpecifiedByDirective, +]); +function isSpecifiedDirective(directive) { + return specifiedDirectives.some(({ name }) => name === directive.name); +} + + +/***/ }), + +/***/ 2433: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Az": () => (/* binding */ SchemaMetaFieldDef), +/* harmony export */ "PX": () => (/* binding */ __TypeKind), +/* harmony export */ "TK": () => (/* binding */ __Schema), +/* harmony export */ "XQ": () => (/* binding */ __InputValue), +/* harmony export */ "e_": () => (/* binding */ __Field), +/* harmony export */ "hU": () => (/* binding */ TypeNameMetaFieldDef), +/* harmony export */ "jT": () => (/* binding */ __EnumValue), +/* harmony export */ "l3": () => (/* binding */ __Directive), +/* harmony export */ "nL": () => (/* binding */ introspectionTypes), +/* harmony export */ "qz": () => (/* binding */ __Type), +/* harmony export */ "s9": () => (/* binding */ isIntrospectionType), +/* harmony export */ "tF": () => (/* binding */ TypeMetaFieldDef), +/* harmony export */ "x2": () => (/* binding */ __DirectiveLocation), +/* harmony export */ "zU": () => (/* binding */ TypeKind) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9551); +/* harmony import */ var _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(9878); +/* harmony import */ var _language_printer_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3486); +/* harmony import */ var _utilities_astFromValue_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8631); +/* harmony import */ var _definition_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(398); +/* harmony import */ var _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3801); + + + + + + + +const __Schema = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLObjectType */ .h6({ + name: '__Schema', + description: + 'A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.', + fields: () => ({ + description: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: (schema) => schema.description, + }, + types: { + description: 'A list of all types supported by this server.', + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLList */ .p2(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__Type))), + + resolve(schema) { + return Object.values(schema.getTypeMap()); + }, + }, + queryType: { + description: 'The type that query operations will be rooted at.', + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__Type), + resolve: (schema) => schema.getQueryType(), + }, + mutationType: { + description: + 'If this server supports mutation, the type that mutation operations will be rooted at.', + type: __Type, + resolve: (schema) => schema.getMutationType(), + }, + subscriptionType: { + description: + 'If this server support subscription, the type that subscription operations will be rooted at.', + type: __Type, + resolve: (schema) => schema.getSubscriptionType(), + }, + directives: { + description: 'A list of all directives supported by this server.', + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM( + new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLList */ .p2(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__Directive)), + ), + resolve: (schema) => schema.getDirectives(), + }, + }), +}); +const __Directive = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLObjectType */ .h6({ + name: '__Directive', + description: + "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", + fields: () => ({ + name: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH), + resolve: (directive) => directive.name, + }, + description: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: (directive) => directive.description, + }, + isRepeatable: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLBoolean */ .EZ), + resolve: (directive) => directive.isRepeatable, + }, + locations: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM( + new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLList */ .p2(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__DirectiveLocation)), + ), + resolve: (directive) => directive.locations, + }, + args: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM( + new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLList */ .p2(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__InputValue)), + ), + args: { + includeDeprecated: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLBoolean */ .EZ, + defaultValue: false, + }, + }, + + resolve(field, { includeDeprecated }) { + return includeDeprecated + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, + }, + }), +}); +const __DirectiveLocation = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLEnumType */ .mR({ + name: '__DirectiveLocation', + description: + 'A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.', + values: { + QUERY: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.QUERY */ .B.QUERY, + description: 'Location adjacent to a query operation.', + }, + MUTATION: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.MUTATION */ .B.MUTATION, + description: 'Location adjacent to a mutation operation.', + }, + SUBSCRIPTION: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.SUBSCRIPTION */ .B.SUBSCRIPTION, + description: 'Location adjacent to a subscription operation.', + }, + FIELD: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.FIELD */ .B.FIELD, + description: 'Location adjacent to a field.', + }, + FRAGMENT_DEFINITION: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.FRAGMENT_DEFINITION */ .B.FRAGMENT_DEFINITION, + description: 'Location adjacent to a fragment definition.', + }, + FRAGMENT_SPREAD: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.FRAGMENT_SPREAD */ .B.FRAGMENT_SPREAD, + description: 'Location adjacent to a fragment spread.', + }, + INLINE_FRAGMENT: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.INLINE_FRAGMENT */ .B.INLINE_FRAGMENT, + description: 'Location adjacent to an inline fragment.', + }, + VARIABLE_DEFINITION: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.VARIABLE_DEFINITION */ .B.VARIABLE_DEFINITION, + description: 'Location adjacent to a variable definition.', + }, + SCHEMA: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.SCHEMA */ .B.SCHEMA, + description: 'Location adjacent to a schema definition.', + }, + SCALAR: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.SCALAR */ .B.SCALAR, + description: 'Location adjacent to a scalar definition.', + }, + OBJECT: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.OBJECT */ .B.OBJECT, + description: 'Location adjacent to an object type definition.', + }, + FIELD_DEFINITION: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.FIELD_DEFINITION */ .B.FIELD_DEFINITION, + description: 'Location adjacent to a field definition.', + }, + ARGUMENT_DEFINITION: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.ARGUMENT_DEFINITION */ .B.ARGUMENT_DEFINITION, + description: 'Location adjacent to an argument definition.', + }, + INTERFACE: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.INTERFACE */ .B.INTERFACE, + description: 'Location adjacent to an interface definition.', + }, + UNION: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.UNION */ .B.UNION, + description: 'Location adjacent to a union definition.', + }, + ENUM: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.ENUM */ .B.ENUM, + description: 'Location adjacent to an enum definition.', + }, + ENUM_VALUE: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.ENUM_VALUE */ .B.ENUM_VALUE, + description: 'Location adjacent to an enum value definition.', + }, + INPUT_OBJECT: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.INPUT_OBJECT */ .B.INPUT_OBJECT, + description: 'Location adjacent to an input object type definition.', + }, + INPUT_FIELD_DEFINITION: { + value: _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_2__/* .DirectiveLocation.INPUT_FIELD_DEFINITION */ .B.INPUT_FIELD_DEFINITION, + description: 'Location adjacent to an input object field definition.', + }, + }, +}); +const __Type = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLObjectType */ .h6({ + name: '__Type', + description: + 'The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name, description and optional `specifiedByURL`, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.', + fields: () => ({ + kind: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__TypeKind), + + resolve(type) { + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isScalarType */ .KA)(type)) { + return TypeKind.SCALAR; + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isObjectType */ .lp)(type)) { + return TypeKind.OBJECT; + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInterfaceType */ .oT)(type)) { + return TypeKind.INTERFACE; + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isUnionType */ .EN)(type)) { + return TypeKind.UNION; + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isEnumType */ .EM)(type)) { + return TypeKind.ENUM; + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputObjectType */ .hL)(type)) { + return TypeKind.INPUT_OBJECT; + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isListType */ .HG)(type)) { + return TypeKind.LIST; + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isNonNullType */ .zM)(type)) { + return TypeKind.NON_NULL; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered) + + false || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_3__/* .invariant */ .k)(false, `Unexpected type: "${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_4__/* .inspect */ .X)(type)}".`); + }, + }, + name: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: (type) => ('name' in type ? type.name : undefined), + }, + description: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: ( + type, // FIXME: add test case + ) => + /* c8 ignore next */ + 'description' in type ? type.description : undefined, + }, + specifiedByURL: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: (obj) => + 'specifiedByURL' in obj ? obj.specifiedByURL : undefined, + }, + fields: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLList */ .p2(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__Field)), + args: { + includeDeprecated: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLBoolean */ .EZ, + defaultValue: false, + }, + }, + + resolve(type, { includeDeprecated }) { + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isObjectType */ .lp)(type) || (0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInterfaceType */ .oT)(type)) { + const fields = Object.values(type.getFields()); + return includeDeprecated + ? fields + : fields.filter((field) => field.deprecationReason == null); + } + }, + }, + interfaces: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLList */ .p2(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__Type)), + + resolve(type) { + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isObjectType */ .lp)(type) || (0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInterfaceType */ .oT)(type)) { + return type.getInterfaces(); + } + }, + }, + possibleTypes: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLList */ .p2(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__Type)), + + resolve(type, _args, _context, { schema }) { + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isAbstractType */ .m0)(type)) { + return schema.getPossibleTypes(type); + } + }, + }, + enumValues: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLList */ .p2(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__EnumValue)), + args: { + includeDeprecated: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLBoolean */ .EZ, + defaultValue: false, + }, + }, + + resolve(type, { includeDeprecated }) { + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isEnumType */ .EM)(type)) { + const values = type.getValues(); + return includeDeprecated + ? values + : values.filter((field) => field.deprecationReason == null); + } + }, + }, + inputFields: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLList */ .p2(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__InputValue)), + args: { + includeDeprecated: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLBoolean */ .EZ, + defaultValue: false, + }, + }, + + resolve(type, { includeDeprecated }) { + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputObjectType */ .hL)(type)) { + const values = Object.values(type.getFields()); + return includeDeprecated + ? values + : values.filter((field) => field.deprecationReason == null); + } + }, + }, + ofType: { + type: __Type, + resolve: (type) => ('ofType' in type ? type.ofType : undefined), + }, + }), +}); +const __Field = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLObjectType */ .h6({ + name: '__Field', + description: + 'Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.', + fields: () => ({ + name: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH), + resolve: (field) => field.name, + }, + description: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: (field) => field.description, + }, + args: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM( + new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLList */ .p2(new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__InputValue)), + ), + args: { + includeDeprecated: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLBoolean */ .EZ, + defaultValue: false, + }, + }, + + resolve(field, { includeDeprecated }) { + return includeDeprecated + ? field.args + : field.args.filter((arg) => arg.deprecationReason == null); + }, + }, + type: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__Type), + resolve: (field) => field.type, + }, + isDeprecated: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLBoolean */ .EZ), + resolve: (field) => field.deprecationReason != null, + }, + deprecationReason: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: (field) => field.deprecationReason, + }, + }), +}); +const __InputValue = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLObjectType */ .h6({ + name: '__InputValue', + description: + 'Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.', + fields: () => ({ + name: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH), + resolve: (inputValue) => inputValue.name, + }, + description: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: (inputValue) => inputValue.description, + }, + type: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__Type), + resolve: (inputValue) => inputValue.type, + }, + defaultValue: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + description: + 'A GraphQL-formatted string representing the default value for this input value.', + + resolve(inputValue) { + const { type, defaultValue } = inputValue; + const valueAST = (0,_utilities_astFromValue_mjs__WEBPACK_IMPORTED_MODULE_5__/* .astFromValue */ .J)(defaultValue, type); + return valueAST ? (0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_6__/* .print */ .S)(valueAST) : null; + }, + }, + isDeprecated: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLBoolean */ .EZ), + resolve: (field) => field.deprecationReason != null, + }, + deprecationReason: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: (obj) => obj.deprecationReason, + }, + }), +}); +const __EnumValue = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLObjectType */ .h6({ + name: '__EnumValue', + description: + 'One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.', + fields: () => ({ + name: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH), + resolve: (enumValue) => enumValue.name, + }, + description: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: (enumValue) => enumValue.description, + }, + isDeprecated: { + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLBoolean */ .EZ), + resolve: (enumValue) => enumValue.deprecationReason != null, + }, + deprecationReason: { + type: _scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH, + resolve: (enumValue) => enumValue.deprecationReason, + }, + }), +}); +var TypeKind; + +(function (TypeKind) { + TypeKind['SCALAR'] = 'SCALAR'; + TypeKind['OBJECT'] = 'OBJECT'; + TypeKind['INTERFACE'] = 'INTERFACE'; + TypeKind['UNION'] = 'UNION'; + TypeKind['ENUM'] = 'ENUM'; + TypeKind['INPUT_OBJECT'] = 'INPUT_OBJECT'; + TypeKind['LIST'] = 'LIST'; + TypeKind['NON_NULL'] = 'NON_NULL'; +})(TypeKind || (TypeKind = {})); + + +const __TypeKind = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLEnumType */ .mR({ + name: '__TypeKind', + description: 'An enum describing what kind of type a given `__Type` is.', + values: { + SCALAR: { + value: TypeKind.SCALAR, + description: 'Indicates this type is a scalar.', + }, + OBJECT: { + value: TypeKind.OBJECT, + description: + 'Indicates this type is an object. `fields` and `interfaces` are valid fields.', + }, + INTERFACE: { + value: TypeKind.INTERFACE, + description: + 'Indicates this type is an interface. `fields`, `interfaces`, and `possibleTypes` are valid fields.', + }, + UNION: { + value: TypeKind.UNION, + description: + 'Indicates this type is a union. `possibleTypes` is a valid field.', + }, + ENUM: { + value: TypeKind.ENUM, + description: + 'Indicates this type is an enum. `enumValues` is a valid field.', + }, + INPUT_OBJECT: { + value: TypeKind.INPUT_OBJECT, + description: + 'Indicates this type is an input object. `inputFields` is a valid field.', + }, + LIST: { + value: TypeKind.LIST, + description: 'Indicates this type is a list. `ofType` is a valid field.', + }, + NON_NULL: { + value: TypeKind.NON_NULL, + description: + 'Indicates this type is a non-null. `ofType` is a valid field.', + }, + }, +}); +/** + * Note that these are GraphQLField and not GraphQLFieldConfig, + * so the format for args is different. + */ + +const SchemaMetaFieldDef = { + name: '__schema', + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(__Schema), + description: 'Access the current type schema of this server.', + args: [], + resolve: (_source, _args, _context, { schema }) => schema, + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, +}; +const TypeMetaFieldDef = { + name: '__type', + type: __Type, + description: 'Request the type information of a single type.', + args: [ + { + name: 'name', + description: undefined, + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH), + defaultValue: undefined, + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, + }, + ], + resolve: (_source, { name }, _context, { schema }) => schema.getType(name), + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, +}; +const TypeNameMetaFieldDef = { + name: '__typename', + type: new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLNonNull */ .bM(_scalars_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLString */ .kH), + description: 'The name of the current Object type at runtime.', + args: [], + resolve: (_source, _args, _context, { parentType }) => parentType.name, + deprecationReason: undefined, + extensions: Object.create(null), + astNode: undefined, +}; +const introspectionTypes = Object.freeze([ + __Schema, + __Directive, + __DirectiveLocation, + __Type, + __Field, + __InputValue, + __EnumValue, + __TypeKind, +]); +function isIntrospectionType(type) { + return introspectionTypes.some(({ name }) => type.name === name); +} + + +/***/ }), + +/***/ 3801: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "EZ": () => (/* binding */ GraphQLBoolean), +/* harmony export */ "HI": () => (/* binding */ GRAPHQL_MAX_INT), +/* harmony export */ "HS": () => (/* binding */ specifiedScalarTypes), +/* harmony export */ "_o": () => (/* binding */ GraphQLInt), +/* harmony export */ "av": () => (/* binding */ GraphQLFloat), +/* harmony export */ "kH": () => (/* binding */ GraphQLString), +/* harmony export */ "km": () => (/* binding */ GraphQLID), +/* harmony export */ "st": () => (/* binding */ GRAPHQL_MIN_INT), +/* harmony export */ "u1": () => (/* binding */ isSpecifiedScalarType) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8495); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7359); +/* harmony import */ var _language_printer_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3486); +/* harmony import */ var _definition_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(398); + + + + + + +/** + * Maximum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe up-to 2^53 - 1 + * */ + +const GRAPHQL_MAX_INT = 2147483647; +/** + * Minimum possible Int value as per GraphQL Spec (32-bit signed integer). + * n.b. This differs from JavaScript's numbers that are IEEE 754 doubles safe starting at -(2^53 - 1) + * */ + +const GRAPHQL_MIN_INT = -2147483648; +const GraphQLInt = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLScalarType */ .n2({ + name: 'Int', + description: + 'The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'boolean') { + return coercedValue ? 1 : 0; + } + + let num = coercedValue; + + if (typeof coercedValue === 'string' && coercedValue !== '') { + num = Number(coercedValue); + } + + if (typeof num !== 'number' || !Number.isInteger(num)) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Int cannot represent non-integer value: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(coercedValue)}`, + ); + } + + if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + 'Int cannot represent non 32-bit signed integer value: ' + + (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(coercedValue), + ); + } + + return num; + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'number' || !Number.isInteger(inputValue)) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Int cannot represent non-integer value: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(inputValue)}`, + ); + } + + if (inputValue > GRAPHQL_MAX_INT || inputValue < GRAPHQL_MIN_INT) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Int cannot represent non 32-bit signed integer value: ${inputValue}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INT */ .h.INT) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Int cannot represent non-integer value: ${(0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_4__/* .print */ .S)(valueNode)}`, + { + nodes: valueNode, + }, + ); + } + + const num = parseInt(valueNode.value, 10); + + if (num > GRAPHQL_MAX_INT || num < GRAPHQL_MIN_INT) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Int cannot represent non 32-bit signed integer value: ${valueNode.value}`, + { + nodes: valueNode, + }, + ); + } + + return num; + }, +}); +const GraphQLFloat = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLScalarType */ .n2({ + name: 'Float', + description: + 'The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](https://en.wikipedia.org/wiki/IEEE_floating_point).', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'boolean') { + return coercedValue ? 1 : 0; + } + + let num = coercedValue; + + if (typeof coercedValue === 'string' && coercedValue !== '') { + num = Number(coercedValue); + } + + if (typeof num !== 'number' || !Number.isFinite(num)) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Float cannot represent non numeric value: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(coercedValue)}`, + ); + } + + return num; + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'number' || !Number.isFinite(inputValue)) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Float cannot represent non numeric value: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(inputValue)}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.FLOAT */ .h.FLOAT && valueNode.kind !== _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INT */ .h.INT) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Float cannot represent non numeric value: ${(0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_4__/* .print */ .S)(valueNode)}`, + valueNode, + ); + } + + return parseFloat(valueNode.value); + }, +}); +const GraphQLString = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLScalarType */ .n2({ + name: 'String', + description: + 'The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); // Serialize string, boolean and number values to a string, but do not + // attempt to coerce object, function, symbol, or other types as strings. + + if (typeof coercedValue === 'string') { + return coercedValue; + } + + if (typeof coercedValue === 'boolean') { + return coercedValue ? 'true' : 'false'; + } + + if (typeof coercedValue === 'number' && Number.isFinite(coercedValue)) { + return coercedValue.toString(); + } + + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `String cannot represent value: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(outputValue)}`, + ); + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'string') { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `String cannot represent a non string value: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(inputValue)}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.STRING */ .h.STRING) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `String cannot represent a non string value: ${(0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_4__/* .print */ .S)(valueNode)}`, + { + nodes: valueNode, + }, + ); + } + + return valueNode.value; + }, +}); +const GraphQLBoolean = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLScalarType */ .n2({ + name: 'Boolean', + description: 'The `Boolean` scalar type represents `true` or `false`.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'boolean') { + return coercedValue; + } + + if (Number.isFinite(coercedValue)) { + return coercedValue !== 0; + } + + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Boolean cannot represent a non boolean value: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(coercedValue)}`, + ); + }, + + parseValue(inputValue) { + if (typeof inputValue !== 'boolean') { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Boolean cannot represent a non boolean value: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(inputValue)}`, + ); + } + + return inputValue; + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.BOOLEAN */ .h.BOOLEAN) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Boolean cannot represent a non boolean value: ${(0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_4__/* .print */ .S)(valueNode)}`, + { + nodes: valueNode, + }, + ); + } + + return valueNode.value; + }, +}); +const GraphQLID = new _definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLScalarType */ .n2({ + name: 'ID', + description: + 'The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `"4"`) or integer (such as `4`) input value will be accepted as an ID.', + + serialize(outputValue) { + const coercedValue = serializeObject(outputValue); + + if (typeof coercedValue === 'string') { + return coercedValue; + } + + if (Number.isInteger(coercedValue)) { + return String(coercedValue); + } + + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `ID cannot represent value: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(outputValue)}`, + ); + }, + + parseValue(inputValue) { + if (typeof inputValue === 'string') { + return inputValue; + } + + if (typeof inputValue === 'number' && Number.isInteger(inputValue)) { + return inputValue.toString(); + } + + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__(`ID cannot represent value: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(inputValue)}`); + }, + + parseLiteral(valueNode) { + if (valueNode.kind !== _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.STRING */ .h.STRING && valueNode.kind !== _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INT */ .h.INT) { + throw new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + 'ID cannot represent a non-string and non-integer value: ' + + (0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_4__/* .print */ .S)(valueNode), + { + nodes: valueNode, + }, + ); + } + + return valueNode.value; + }, +}); +const specifiedScalarTypes = Object.freeze([ + GraphQLString, + GraphQLInt, + GraphQLFloat, + GraphQLBoolean, + GraphQLID, +]); +function isSpecifiedScalarType(type) { + return specifiedScalarTypes.some(({ name }) => type.name === name); +} // Support serializing objects with custom valueOf() or toJSON() functions - +// a common way to represent a complex value which can be represented as +// a string (ex: MongoDB id objects). + +function serializeObject(outputValue) { + if ((0,_jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isObjectLike */ .y)(outputValue)) { + if (typeof outputValue.valueOf === 'function') { + const valueOfResult = outputValue.valueOf(); + + if (!(0,_jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isObjectLike */ .y)(valueOfResult)) { + return valueOfResult; + } + } + + if (typeof outputValue.toJSON === 'function') { + return outputValue.toJSON(); + } + } + + return outputValue; +} + + +/***/ }), + +/***/ 9678: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "EO": () => (/* binding */ assertSchema), +/* harmony export */ "XO": () => (/* binding */ GraphQLSchema), +/* harmony export */ "nN": () => (/* binding */ isSchema) +/* harmony export */ }); +/* harmony import */ var _jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7826); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_instanceOf_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8306); +/* harmony import */ var _jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8495); +/* harmony import */ var _jsutils_toObjMap_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8824); +/* harmony import */ var _language_ast_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(2380); +/* harmony import */ var _definition_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(398); +/* harmony import */ var _directives_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8238); +/* harmony import */ var _introspection_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2433); + + + + + + + + + +/** + * Test if the given value is a GraphQL schema. + */ + +function isSchema(schema) { + return (0,_jsutils_instanceOf_mjs__WEBPACK_IMPORTED_MODULE_0__/* .instanceOf */ .n)(schema, GraphQLSchema); +} +function assertSchema(schema) { + if (!isSchema(schema)) { + throw new Error(`Expected ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(schema)} to be a GraphQL schema.`); + } + + return schema; +} +/** + * Custom extensions + * + * @remarks + * Use a unique identifier name for your extension, for example the name of + * your library or project. Do not use a shortened identifier as this increases + * the risk of conflicts. We recommend you add at most one extension field, + * an object which can contain all the values you need. + */ + +/** + * Schema Definition + * + * A Schema is created by supplying the root types of each type of operation, + * query and mutation (optional). A schema definition is then supplied to the + * validator and executor. + * + * Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * query: MyAppQueryRootType, + * mutation: MyAppMutationRootType, + * }) + * ``` + * + * Note: When the schema is constructed, by default only the types that are + * reachable by traversing the root types are included, other types must be + * explicitly referenced. + * + * Example: + * + * ```ts + * const characterInterface = new GraphQLInterfaceType({ + * name: 'Character', + * ... + * }); + * + * const humanType = new GraphQLObjectType({ + * name: 'Human', + * interfaces: [characterInterface], + * ... + * }); + * + * const droidType = new GraphQLObjectType({ + * name: 'Droid', + * interfaces: [characterInterface], + * ... + * }); + * + * const schema = new GraphQLSchema({ + * query: new GraphQLObjectType({ + * name: 'Query', + * fields: { + * hero: { type: characterInterface, ... }, + * } + * }), + * ... + * // Since this schema references only the `Character` interface it's + * // necessary to explicitly list the types that implement it if + * // you want them to be included in the final schema. + * types: [humanType, droidType], + * }) + * ``` + * + * Note: If an array of `directives` are provided to GraphQLSchema, that will be + * the exact list of directives represented and allowed. If `directives` is not + * provided then a default set of the specified directives (e.g. `@include` and + * `@skip`) will be used. If you wish to provide *additional* directives to these + * specified directives, you must explicitly declare them. Example: + * + * ```ts + * const MyAppSchema = new GraphQLSchema({ + * ... + * directives: specifiedDirectives.concat([ myCustomDirective ]), + * }) + * ``` + */ +class GraphQLSchema { + // Used as a cache for validateSchema(). + constructor(config) { + var _config$extensionASTN, _config$directives; + + // If this schema was built from a source known to be valid, then it may be + // marked with assumeValid to avoid an additional type system validation. + this.__validationErrors = config.assumeValid === true ? [] : undefined; // Check for common mistakes during construction to produce early errors. + + (0,_jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isObjectLike */ .y)(config) || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_3__/* .devAssert */ .a)(false, 'Must provide configuration object.'); + !config.types || + Array.isArray(config.types) || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_3__/* .devAssert */ .a)( + false, + `"types" must be Array if provided but got: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(config.types)}.`, + ); + !config.directives || + Array.isArray(config.directives) || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_3__/* .devAssert */ .a)( + false, + '"directives" must be Array if provided but got: ' + + `${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(config.directives)}.`, + ); + this.description = config.description; + this.extensions = (0,_jsutils_toObjMap_mjs__WEBPACK_IMPORTED_MODULE_4__/* .toObjMap */ .u)(config.extensions); + this.astNode = config.astNode; + this.extensionASTNodes = + (_config$extensionASTN = config.extensionASTNodes) !== null && + _config$extensionASTN !== void 0 + ? _config$extensionASTN + : []; + this._queryType = config.query; + this._mutationType = config.mutation; + this._subscriptionType = config.subscription; // Provide specified directives (e.g. @include and @skip) by default. + + this._directives = + (_config$directives = config.directives) !== null && + _config$directives !== void 0 + ? _config$directives + : _directives_mjs__WEBPACK_IMPORTED_MODULE_5__/* .specifiedDirectives */ .V4; // To preserve order of user-provided types, we add first to add them to + // the set of "collected" types, so `collectReferencedTypes` ignore them. + + const allReferencedTypes = new Set(config.types); + + if (config.types != null) { + for (const type of config.types) { + // When we ready to process this type, we remove it from "collected" types + // and then add it together with all dependent types in the correct position. + allReferencedTypes.delete(type); + collectReferencedTypes(type, allReferencedTypes); + } + } + + if (this._queryType != null) { + collectReferencedTypes(this._queryType, allReferencedTypes); + } + + if (this._mutationType != null) { + collectReferencedTypes(this._mutationType, allReferencedTypes); + } + + if (this._subscriptionType != null) { + collectReferencedTypes(this._subscriptionType, allReferencedTypes); + } + + for (const directive of this._directives) { + // Directives are not validated until validateSchema() is called. + if ((0,_directives_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isDirective */ .wX)(directive)) { + for (const arg of directive.args) { + collectReferencedTypes(arg.type, allReferencedTypes); + } + } + } + + collectReferencedTypes(_introspection_mjs__WEBPACK_IMPORTED_MODULE_6__/* .__Schema */ .TK, allReferencedTypes); // Storing the resulting map for reference by the schema. + + this._typeMap = Object.create(null); + this._subTypeMap = Object.create(null); // Keep track of all implementations by interface name. + + this._implementationsMap = Object.create(null); + + for (const namedType of allReferencedTypes) { + if (namedType == null) { + continue; + } + + const typeName = namedType.name; + typeName || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_3__/* .devAssert */ .a)( + false, + 'One of the provided types for building the Schema is missing a name.', + ); + + if (this._typeMap[typeName] !== undefined) { + throw new Error( + `Schema must contain uniquely named types but contains multiple types named "${typeName}".`, + ); + } + + this._typeMap[typeName] = namedType; + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isInterfaceType */ .oT)(namedType)) { + // Store implementations by interface. + for (const iface of namedType.getInterfaces()) { + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isInterfaceType */ .oT)(iface)) { + let implementations = this._implementationsMap[iface.name]; + + if (implementations === undefined) { + implementations = this._implementationsMap[iface.name] = { + objects: [], + interfaces: [], + }; + } + + implementations.interfaces.push(namedType); + } + } + } else if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isObjectType */ .lp)(namedType)) { + // Store implementations by objects. + for (const iface of namedType.getInterfaces()) { + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isInterfaceType */ .oT)(iface)) { + let implementations = this._implementationsMap[iface.name]; + + if (implementations === undefined) { + implementations = this._implementationsMap[iface.name] = { + objects: [], + interfaces: [], + }; + } + + implementations.objects.push(namedType); + } + } + } + } + } + + get [Symbol.toStringTag]() { + return 'GraphQLSchema'; + } + + getQueryType() { + return this._queryType; + } + + getMutationType() { + return this._mutationType; + } + + getSubscriptionType() { + return this._subscriptionType; + } + + getRootType(operation) { + switch (operation) { + case _language_ast_mjs__WEBPACK_IMPORTED_MODULE_8__/* .OperationTypeNode.QUERY */ .ku.QUERY: + return this.getQueryType(); + + case _language_ast_mjs__WEBPACK_IMPORTED_MODULE_8__/* .OperationTypeNode.MUTATION */ .ku.MUTATION: + return this.getMutationType(); + + case _language_ast_mjs__WEBPACK_IMPORTED_MODULE_8__/* .OperationTypeNode.SUBSCRIPTION */ .ku.SUBSCRIPTION: + return this.getSubscriptionType(); + } + } + + getTypeMap() { + return this._typeMap; + } + + getType(name) { + return this.getTypeMap()[name]; + } + + getPossibleTypes(abstractType) { + return (0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isUnionType */ .EN)(abstractType) + ? abstractType.getTypes() + : this.getImplementations(abstractType).objects; + } + + getImplementations(interfaceType) { + const implementations = this._implementationsMap[interfaceType.name]; + return implementations !== null && implementations !== void 0 + ? implementations + : { + objects: [], + interfaces: [], + }; + } + + isSubType(abstractType, maybeSubType) { + let map = this._subTypeMap[abstractType.name]; + + if (map === undefined) { + map = Object.create(null); + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isUnionType */ .EN)(abstractType)) { + for (const type of abstractType.getTypes()) { + map[type.name] = true; + } + } else { + const implementations = this.getImplementations(abstractType); + + for (const type of implementations.objects) { + map[type.name] = true; + } + + for (const type of implementations.interfaces) { + map[type.name] = true; + } + } + + this._subTypeMap[abstractType.name] = map; + } + + return map[maybeSubType.name] !== undefined; + } + + getDirectives() { + return this._directives; + } + + getDirective(name) { + return this.getDirectives().find((directive) => directive.name === name); + } + + toConfig() { + return { + description: this.description, + query: this.getQueryType(), + mutation: this.getMutationType(), + subscription: this.getSubscriptionType(), + types: Object.values(this.getTypeMap()), + directives: this.getDirectives(), + extensions: this.extensions, + astNode: this.astNode, + extensionASTNodes: this.extensionASTNodes, + assumeValid: this.__validationErrors !== undefined, + }; + } +} + +function collectReferencedTypes(type, typeSet) { + const namedType = (0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .getNamedType */ .xC)(type); + + if (!typeSet.has(namedType)) { + typeSet.add(namedType); + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isUnionType */ .EN)(namedType)) { + for (const memberType of namedType.getTypes()) { + collectReferencedTypes(memberType, typeSet); + } + } else if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isObjectType */ .lp)(namedType) || (0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isInterfaceType */ .oT)(namedType)) { + for (const interfaceType of namedType.getInterfaces()) { + collectReferencedTypes(interfaceType, typeSet); + } + + for (const field of Object.values(namedType.getFields())) { + collectReferencedTypes(field.type, typeSet); + + for (const arg of field.args) { + collectReferencedTypes(arg.type, typeSet); + } + } + } else if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isInputObjectType */ .hL)(namedType)) { + for (const field of Object.values(namedType.getFields())) { + collectReferencedTypes(field.type, typeSet); + } + } + } + + return typeSet; +} + + +/***/ }), + +/***/ 9655: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "F": () => (/* binding */ validateSchema), +/* harmony export */ "J": () => (/* binding */ assertValidSchema) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(5821); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); +/* harmony import */ var _language_ast_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2380); +/* harmony import */ var _utilities_typeComparators_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(316); +/* harmony import */ var _definition_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(398); +/* harmony import */ var _directives_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8238); +/* harmony import */ var _introspection_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2433); +/* harmony import */ var _schema_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9678); + + + + + + + + +/** + * Implements the "Type Validation" sub-sections of the specification's + * "Type System" section. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the Schema is valid. + */ + +function validateSchema(schema) { + // First check to ensure the provided value is in fact a GraphQLSchema. + (0,_schema_mjs__WEBPACK_IMPORTED_MODULE_0__/* .assertSchema */ .EO)(schema); // If this Schema has already been validated, return the previous results. + + if (schema.__validationErrors) { + return schema.__validationErrors; + } // Validate the schema, producing a list of errors. + + const context = new SchemaValidationContext(schema); + validateRootTypes(context); + validateDirectives(context); + validateTypes(context); // Persist the results of validation before returning to ensure validation + // does not run multiple times for this schema. + + const errors = context.getErrors(); + schema.__validationErrors = errors; + return errors; +} +/** + * Utility function which asserts a schema is valid by throwing an error if + * it is invalid. + */ + +function assertValidSchema(schema) { + const errors = validateSchema(schema); + + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} + +class SchemaValidationContext { + constructor(schema) { + this._errors = []; + this.schema = schema; + } + + reportError(message, nodes) { + const _nodes = Array.isArray(nodes) ? nodes.filter(Boolean) : nodes; + + this._errors.push( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__(message, { + nodes: _nodes, + }), + ); + } + + getErrors() { + return this._errors; + } +} + +function validateRootTypes(context) { + const schema = context.schema; + const queryType = schema.getQueryType(); + + if (!queryType) { + context.reportError('Query root type must be provided.', schema.astNode); + } else if (!(0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isObjectType */ .lp)(queryType)) { + var _getOperationTypeNode; + + context.reportError( + `Query root type must be Object type, it cannot be ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)( + queryType, + )}.`, + (_getOperationTypeNode = getOperationTypeNode( + schema, + _language_ast_mjs__WEBPACK_IMPORTED_MODULE_4__/* .OperationTypeNode.QUERY */ .ku.QUERY, + )) !== null && _getOperationTypeNode !== void 0 + ? _getOperationTypeNode + : queryType.astNode, + ); + } + + const mutationType = schema.getMutationType(); + + if (mutationType && !(0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isObjectType */ .lp)(mutationType)) { + var _getOperationTypeNode2; + + context.reportError( + 'Mutation root type must be Object type if provided, it cannot be ' + + `${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(mutationType)}.`, + (_getOperationTypeNode2 = getOperationTypeNode( + schema, + _language_ast_mjs__WEBPACK_IMPORTED_MODULE_4__/* .OperationTypeNode.MUTATION */ .ku.MUTATION, + )) !== null && _getOperationTypeNode2 !== void 0 + ? _getOperationTypeNode2 + : mutationType.astNode, + ); + } + + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType && !(0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isObjectType */ .lp)(subscriptionType)) { + var _getOperationTypeNode3; + + context.reportError( + 'Subscription root type must be Object type if provided, it cannot be ' + + `${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(subscriptionType)}.`, + (_getOperationTypeNode3 = getOperationTypeNode( + schema, + _language_ast_mjs__WEBPACK_IMPORTED_MODULE_4__/* .OperationTypeNode.SUBSCRIPTION */ .ku.SUBSCRIPTION, + )) !== null && _getOperationTypeNode3 !== void 0 + ? _getOperationTypeNode3 + : subscriptionType.astNode, + ); + } +} + +function getOperationTypeNode(schema, operation) { + var _flatMap$find; + + return (_flatMap$find = [schema.astNode, ...schema.extensionASTNodes] + .flatMap( + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + (schemaNode) => { + var _schemaNode$operation; + + return ( + /* c8 ignore next */ + (_schemaNode$operation = + schemaNode === null || schemaNode === void 0 + ? void 0 + : schemaNode.operationTypes) !== null && + _schemaNode$operation !== void 0 + ? _schemaNode$operation + : [] + ); + }, + ) + .find((operationNode) => operationNode.operation === operation)) === null || + _flatMap$find === void 0 + ? void 0 + : _flatMap$find.type; +} + +function validateDirectives(context) { + for (const directive of context.schema.getDirectives()) { + // Ensure all directives are in fact GraphQL directives. + if (!(0,_directives_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isDirective */ .wX)(directive)) { + context.reportError( + `Expected directive but got: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(directive)}.`, + directive === null || directive === void 0 ? void 0 : directive.astNode, + ); + continue; + } // Ensure they are named correctly. + + validateName(context, directive); // TODO: Ensure proper locations. + // Ensure the arguments are valid. + + for (const arg of directive.args) { + // Ensure they are named correctly. + validateName(context, arg); // Ensure the type is an input type. + + if (!(0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInputType */ .j$)(arg.type)) { + context.reportError( + `The type of @${directive.name}(${arg.name}:) must be Input Type ` + + `but got: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(arg.type)}.`, + arg.astNode, + ); + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isRequiredArgument */ .dK)(arg) && arg.deprecationReason != null) { + var _arg$astNode; + + context.reportError( + `Required argument @${directive.name}(${arg.name}:) cannot be deprecated.`, + [ + getDeprecatedDirectiveNode(arg.astNode), + (_arg$astNode = arg.astNode) === null || _arg$astNode === void 0 + ? void 0 + : _arg$astNode.type, + ], + ); + } + } + } +} + +function validateName(context, node) { + // Ensure names are valid, however introspection types opt out. + if (node.name.startsWith('__')) { + context.reportError( + `Name "${node.name}" must not begin with "__", which is reserved by GraphQL introspection.`, + node.astNode, + ); + } +} + +function validateTypes(context) { + const validateInputObjectCircularRefs = + createInputObjectCircularRefsValidator(context); + const typeMap = context.schema.getTypeMap(); + + for (const type of Object.values(typeMap)) { + // Ensure all provided types are in fact GraphQL type. + if (!(0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNamedType */ .Zs)(type)) { + context.reportError( + `Expected GraphQL named type but got: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(type)}.`, + type.astNode, + ); + continue; + } // Ensure it is named correctly (excluding introspection types). + + if (!(0,_introspection_mjs__WEBPACK_IMPORTED_MODULE_6__/* .isIntrospectionType */ .s9)(type)) { + validateName(context, type); + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isObjectType */ .lp)(type)) { + // Ensure fields are valid + validateFields(context, type); // Ensure objects implement the interfaces they claim to. + + validateInterfaces(context, type); + } else if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInterfaceType */ .oT)(type)) { + // Ensure fields are valid. + validateFields(context, type); // Ensure interfaces implement the interfaces they claim to. + + validateInterfaces(context, type); + } else if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isUnionType */ .EN)(type)) { + // Ensure Unions include valid member types. + validateUnionMembers(context, type); + } else if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isEnumType */ .EM)(type)) { + // Ensure Enums have valid values. + validateEnumValues(context, type); + } else if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInputObjectType */ .hL)(type)) { + // Ensure Input Object fields are valid. + validateInputFields(context, type); // Ensure Input Objects do not contain non-nullable circular references + + validateInputObjectCircularRefs(type); + } + } +} + +function validateFields(context, type) { + const fields = Object.values(type.getFields()); // Objects and Interfaces both must define one or more fields. + + if (fields.length === 0) { + context.reportError(`Type ${type.name} must define one or more fields.`, [ + type.astNode, + ...type.extensionASTNodes, + ]); + } + + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); // Ensure the type is an output type + + if (!(0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isOutputType */ .SZ)(field.type)) { + var _field$astNode; + + context.reportError( + `The type of ${type.name}.${field.name} must be Output Type ` + + `but got: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(field.type)}.`, + (_field$astNode = field.astNode) === null || _field$astNode === void 0 + ? void 0 + : _field$astNode.type, + ); + } // Ensure the arguments are valid + + for (const arg of field.args) { + const argName = arg.name; // Ensure they are named correctly. + + validateName(context, arg); // Ensure the type is an input type + + if (!(0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInputType */ .j$)(arg.type)) { + var _arg$astNode2; + + context.reportError( + `The type of ${type.name}.${field.name}(${argName}:) must be Input ` + + `Type but got: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(arg.type)}.`, + (_arg$astNode2 = arg.astNode) === null || _arg$astNode2 === void 0 + ? void 0 + : _arg$astNode2.type, + ); + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isRequiredArgument */ .dK)(arg) && arg.deprecationReason != null) { + var _arg$astNode3; + + context.reportError( + `Required argument ${type.name}.${field.name}(${argName}:) cannot be deprecated.`, + [ + getDeprecatedDirectiveNode(arg.astNode), + (_arg$astNode3 = arg.astNode) === null || _arg$astNode3 === void 0 + ? void 0 + : _arg$astNode3.type, + ], + ); + } + } + } +} + +function validateInterfaces(context, type) { + const ifaceTypeNames = Object.create(null); + + for (const iface of type.getInterfaces()) { + if (!(0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInterfaceType */ .oT)(iface)) { + context.reportError( + `Type ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(type)} must only implement Interface types, ` + + `it cannot implement ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(iface)}.`, + getAllImplementsInterfaceNodes(type, iface), + ); + continue; + } + + if (type === iface) { + context.reportError( + `Type ${type.name} cannot implement itself because it would create a circular reference.`, + getAllImplementsInterfaceNodes(type, iface), + ); + continue; + } + + if (ifaceTypeNames[iface.name]) { + context.reportError( + `Type ${type.name} can only implement ${iface.name} once.`, + getAllImplementsInterfaceNodes(type, iface), + ); + continue; + } + + ifaceTypeNames[iface.name] = true; + validateTypeImplementsAncestors(context, type, iface); + validateTypeImplementsInterface(context, type, iface); + } +} + +function validateTypeImplementsInterface(context, type, iface) { + const typeFieldMap = type.getFields(); // Assert each interface field is implemented. + + for (const ifaceField of Object.values(iface.getFields())) { + const fieldName = ifaceField.name; + const typeField = typeFieldMap[fieldName]; // Assert interface field exists on type. + + if (!typeField) { + context.reportError( + `Interface field ${iface.name}.${fieldName} expected but ${type.name} does not provide it.`, + [ifaceField.astNode, type.astNode, ...type.extensionASTNodes], + ); + continue; + } // Assert interface field type is satisfied by type field type, by being + // a valid subtype. (covariant) + + if (!(0,_utilities_typeComparators_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isTypeSubTypeOf */ .uJ)(context.schema, typeField.type, ifaceField.type)) { + var _ifaceField$astNode, _typeField$astNode; + + context.reportError( + `Interface field ${iface.name}.${fieldName} expects type ` + + `${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(ifaceField.type)} but ${type.name}.${fieldName} ` + + `is type ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(typeField.type)}.`, + [ + (_ifaceField$astNode = ifaceField.astNode) === null || + _ifaceField$astNode === void 0 + ? void 0 + : _ifaceField$astNode.type, + (_typeField$astNode = typeField.astNode) === null || + _typeField$astNode === void 0 + ? void 0 + : _typeField$astNode.type, + ], + ); + } // Assert each interface field arg is implemented. + + for (const ifaceArg of ifaceField.args) { + const argName = ifaceArg.name; + const typeArg = typeField.args.find((arg) => arg.name === argName); // Assert interface field arg exists on object field. + + if (!typeArg) { + context.reportError( + `Interface field argument ${iface.name}.${fieldName}(${argName}:) expected but ${type.name}.${fieldName} does not provide it.`, + [ifaceArg.astNode, typeField.astNode], + ); + continue; + } // Assert interface field arg type matches object field arg type. + // (invariant) + // TODO: change to contravariant? + + if (!(0,_utilities_typeComparators_mjs__WEBPACK_IMPORTED_MODULE_7__/* .isEqualType */ ._7)(ifaceArg.type, typeArg.type)) { + var _ifaceArg$astNode, _typeArg$astNode; + + context.reportError( + `Interface field argument ${iface.name}.${fieldName}(${argName}:) ` + + `expects type ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(ifaceArg.type)} but ` + + `${type.name}.${fieldName}(${argName}:) is type ` + + `${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(typeArg.type)}.`, + [ + (_ifaceArg$astNode = ifaceArg.astNode) === null || + _ifaceArg$astNode === void 0 + ? void 0 + : _ifaceArg$astNode.type, + (_typeArg$astNode = typeArg.astNode) === null || + _typeArg$astNode === void 0 + ? void 0 + : _typeArg$astNode.type, + ], + ); + } // TODO: validate default values? + } // Assert additional arguments must not be required. + + for (const typeArg of typeField.args) { + const argName = typeArg.name; + const ifaceArg = ifaceField.args.find((arg) => arg.name === argName); + + if (!ifaceArg && (0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isRequiredArgument */ .dK)(typeArg)) { + context.reportError( + `Object field ${type.name}.${fieldName} includes required argument ${argName} that is missing from the Interface field ${iface.name}.${fieldName}.`, + [typeArg.astNode, ifaceField.astNode], + ); + } + } + } +} + +function validateTypeImplementsAncestors(context, type, iface) { + const ifaceInterfaces = type.getInterfaces(); + + for (const transitive of iface.getInterfaces()) { + if (!ifaceInterfaces.includes(transitive)) { + context.reportError( + transitive === type + ? `Type ${type.name} cannot implement ${iface.name} because it would create a circular reference.` + : `Type ${type.name} must implement ${transitive.name} because it is implemented by ${iface.name}.`, + [ + ...getAllImplementsInterfaceNodes(iface, transitive), + ...getAllImplementsInterfaceNodes(type, iface), + ], + ); + } + } +} + +function validateUnionMembers(context, union) { + const memberTypes = union.getTypes(); + + if (memberTypes.length === 0) { + context.reportError( + `Union type ${union.name} must define one or more member types.`, + [union.astNode, ...union.extensionASTNodes], + ); + } + + const includedTypeNames = Object.create(null); + + for (const memberType of memberTypes) { + if (includedTypeNames[memberType.name]) { + context.reportError( + `Union type ${union.name} can only include type ${memberType.name} once.`, + getUnionMemberTypeNodes(union, memberType.name), + ); + continue; + } + + includedTypeNames[memberType.name] = true; + + if (!(0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isObjectType */ .lp)(memberType)) { + context.reportError( + `Union type ${union.name} can only include Object types, ` + + `it cannot include ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(memberType)}.`, + getUnionMemberTypeNodes(union, String(memberType)), + ); + } + } +} + +function validateEnumValues(context, enumType) { + const enumValues = enumType.getValues(); + + if (enumValues.length === 0) { + context.reportError( + `Enum type ${enumType.name} must define one or more values.`, + [enumType.astNode, ...enumType.extensionASTNodes], + ); + } + + for (const enumValue of enumValues) { + // Ensure valid name. + validateName(context, enumValue); + } +} + +function validateInputFields(context, inputObj) { + const fields = Object.values(inputObj.getFields()); + + if (fields.length === 0) { + context.reportError( + `Input Object type ${inputObj.name} must define one or more fields.`, + [inputObj.astNode, ...inputObj.extensionASTNodes], + ); + } // Ensure the arguments are valid + + for (const field of fields) { + // Ensure they are named correctly. + validateName(context, field); // Ensure the type is an input type + + if (!(0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInputType */ .j$)(field.type)) { + var _field$astNode2; + + context.reportError( + `The type of ${inputObj.name}.${field.name} must be Input Type ` + + `but got: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_3__/* .inspect */ .X)(field.type)}.`, + (_field$astNode2 = field.astNode) === null || _field$astNode2 === void 0 + ? void 0 + : _field$astNode2.type, + ); + } + + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isRequiredInputField */ .Wd)(field) && field.deprecationReason != null) { + var _field$astNode3; + + context.reportError( + `Required input field ${inputObj.name}.${field.name} cannot be deprecated.`, + [ + getDeprecatedDirectiveNode(field.astNode), + (_field$astNode3 = field.astNode) === null || + _field$astNode3 === void 0 + ? void 0 + : _field$astNode3.type, + ], + ); + } + } +} + +function createInputObjectCircularRefsValidator(context) { + // Modified copy of algorithm from 'src/validation/rules/NoFragmentCycles.js'. + // Tracks already visited types to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedTypes = Object.create(null); // Array of types nodes used to produce meaningful errors + + const fieldPath = []; // Position in the type path + + const fieldPathIndexByTypeName = Object.create(null); + return detectCycleRecursive; // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + + function detectCycleRecursive(inputObj) { + if (visitedTypes[inputObj.name]) { + return; + } + + visitedTypes[inputObj.name] = true; + fieldPathIndexByTypeName[inputObj.name] = fieldPath.length; + const fields = Object.values(inputObj.getFields()); + + for (const field of fields) { + if ((0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNonNullType */ .zM)(field.type) && (0,_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInputObjectType */ .hL)(field.type.ofType)) { + const fieldType = field.type.ofType; + const cycleIndex = fieldPathIndexByTypeName[fieldType.name]; + fieldPath.push(field); + + if (cycleIndex === undefined) { + detectCycleRecursive(fieldType); + } else { + const cyclePath = fieldPath.slice(cycleIndex); + const pathStr = cyclePath.map((fieldObj) => fieldObj.name).join('.'); + context.reportError( + `Cannot reference Input Object "${fieldType.name}" within itself through a series of non-null fields: "${pathStr}".`, + cyclePath.map((fieldObj) => fieldObj.astNode), + ); + } + + fieldPath.pop(); + } + } + + fieldPathIndexByTypeName[inputObj.name] = undefined; + } +} + +function getAllImplementsInterfaceNodes(type, iface) { + const { astNode, extensionASTNodes } = type; + const nodes = + astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + return nodes + .flatMap((typeNode) => { + var _typeNode$interfaces; + + return ( + /* c8 ignore next */ + (_typeNode$interfaces = typeNode.interfaces) !== null && + _typeNode$interfaces !== void 0 + ? _typeNode$interfaces + : [] + ); + }) + .filter((ifaceNode) => ifaceNode.name.value === iface.name); +} + +function getUnionMemberTypeNodes(union, typeName) { + const { astNode, extensionASTNodes } = union; + const nodes = + astNode != null ? [astNode, ...extensionASTNodes] : extensionASTNodes; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + return nodes + .flatMap((unionNode) => { + var _unionNode$types; + + return ( + /* c8 ignore next */ + (_unionNode$types = unionNode.types) !== null && + _unionNode$types !== void 0 + ? _unionNode$types + : [] + ); + }) + .filter((typeNode) => typeNode.name.value === typeName); +} + +function getDeprecatedDirectiveNode(definitionNode) { + var _definitionNode$direc; + + return definitionNode === null || definitionNode === void 0 + ? void 0 + : (_definitionNode$direc = definitionNode.directives) === null || + _definitionNode$direc === void 0 + ? void 0 + : _definitionNode$direc.find( + (node) => node.name.value === _directives_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLDeprecatedDirective.name */ .fg.name, + ); +} + + +/***/ }), + +/***/ 2676: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "a": () => (/* binding */ TypeInfo), +/* harmony export */ "y": () => (/* binding */ visitWithTypeInfo) +/* harmony export */ }); +/* harmony import */ var _language_ast_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2380); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7359); +/* harmony import */ var _language_visitor_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7304); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(398); +/* harmony import */ var _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(2433); +/* harmony import */ var _typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(77); + + + + + + +/** + * TypeInfo is a utility class which, given a GraphQL schema, can keep track + * of the current field and type definitions at any point in a GraphQL document + * AST during a recursive descent by calling `enter(node)` and `leave(node)`. + */ + +class TypeInfo { + constructor( + schema, + /** + * Initial type may be provided in rare cases to facilitate traversals + * beginning somewhere other than documents. + */ + initialType, + /** @deprecated will be removed in 17.0.0 */ + getFieldDefFn, + ) { + this._schema = schema; + this._typeStack = []; + this._parentTypeStack = []; + this._inputTypeStack = []; + this._fieldDefStack = []; + this._defaultValueStack = []; + this._directive = null; + this._argument = null; + this._enumValue = null; + this._getFieldDef = + getFieldDefFn !== null && getFieldDefFn !== void 0 + ? getFieldDefFn + : getFieldDef; + + if (initialType) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputType */ .j$)(initialType)) { + this._inputTypeStack.push(initialType); + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isCompositeType */ .Gv)(initialType)) { + this._parentTypeStack.push(initialType); + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isOutputType */ .SZ)(initialType)) { + this._typeStack.push(initialType); + } + } + } + + get [Symbol.toStringTag]() { + return 'TypeInfo'; + } + + getType() { + if (this._typeStack.length > 0) { + return this._typeStack[this._typeStack.length - 1]; + } + } + + getParentType() { + if (this._parentTypeStack.length > 0) { + return this._parentTypeStack[this._parentTypeStack.length - 1]; + } + } + + getInputType() { + if (this._inputTypeStack.length > 0) { + return this._inputTypeStack[this._inputTypeStack.length - 1]; + } + } + + getParentInputType() { + if (this._inputTypeStack.length > 1) { + return this._inputTypeStack[this._inputTypeStack.length - 2]; + } + } + + getFieldDef() { + if (this._fieldDefStack.length > 0) { + return this._fieldDefStack[this._fieldDefStack.length - 1]; + } + } + + getDefaultValue() { + if (this._defaultValueStack.length > 0) { + return this._defaultValueStack[this._defaultValueStack.length - 1]; + } + } + + getDirective() { + return this._directive; + } + + getArgument() { + return this._argument; + } + + getEnumValue() { + return this._enumValue; + } + + enter(node) { + const schema = this._schema; // Note: many of the types below are explicitly typed as "unknown" to drop + // any assumptions of a valid schema to ensure runtime types are properly + // checked before continuing since TypeInfo is used as part of validation + // which occurs before guarantees of schema and document validity. + + switch (node.kind) { + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SELECTION_SET */ .h.SELECTION_SET: { + const namedType = (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getNamedType */ .xC)(this.getType()); + + this._parentTypeStack.push( + (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isCompositeType */ .Gv)(namedType) ? namedType : undefined, + ); + + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.FIELD */ .h.FIELD: { + const parentType = this.getParentType(); + let fieldDef; + let fieldType; + + if (parentType) { + fieldDef = this._getFieldDef(schema, parentType, node); + + if (fieldDef) { + fieldType = fieldDef.type; + } + } + + this._fieldDefStack.push(fieldDef); + + this._typeStack.push((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isOutputType */ .SZ)(fieldType) ? fieldType : undefined); + + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.DIRECTIVE */ .h.DIRECTIVE: + this._directive = schema.getDirective(node.name.value); + break; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.OPERATION_DEFINITION */ .h.OPERATION_DEFINITION: { + const rootType = schema.getRootType(node.operation); + + this._typeStack.push((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isObjectType */ .lp)(rootType) ? rootType : undefined); + + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INLINE_FRAGMENT */ .h.INLINE_FRAGMENT: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.FRAGMENT_DEFINITION */ .h.FRAGMENT_DEFINITION: { + const typeConditionAST = node.typeCondition; + const outputType = typeConditionAST + ? (0,_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_2__/* .typeFromAST */ ._)(schema, typeConditionAST) + : (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getNamedType */ .xC)(this.getType()); + + this._typeStack.push((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isOutputType */ .SZ)(outputType) ? outputType : undefined); + + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.VARIABLE_DEFINITION */ .h.VARIABLE_DEFINITION: { + const inputType = (0,_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_2__/* .typeFromAST */ ._)(schema, node.type); + + this._inputTypeStack.push( + (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputType */ .j$)(inputType) ? inputType : undefined, + ); + + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.ARGUMENT */ .h.ARGUMENT: { + var _this$getDirective; + + let argDef; + let argType; + const fieldOrDirective = + (_this$getDirective = this.getDirective()) !== null && + _this$getDirective !== void 0 + ? _this$getDirective + : this.getFieldDef(); + + if (fieldOrDirective) { + argDef = fieldOrDirective.args.find( + (arg) => arg.name === node.name.value, + ); + + if (argDef) { + argType = argDef.type; + } + } + + this._argument = argDef; + + this._defaultValueStack.push(argDef ? argDef.defaultValue : undefined); + + this._inputTypeStack.push((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputType */ .j$)(argType) ? argType : undefined); + + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.LIST */ .h.LIST: { + const listType = (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getNullableType */ .tf)(this.getInputType()); + const itemType = (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isListType */ .HG)(listType) ? listType.ofType : listType; // List positions never have a default value. + + this._defaultValueStack.push(undefined); + + this._inputTypeStack.push((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputType */ .j$)(itemType) ? itemType : undefined); + + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.OBJECT_FIELD */ .h.OBJECT_FIELD: { + const objectType = (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getNamedType */ .xC)(this.getInputType()); + let inputFieldType; + let inputField; + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputObjectType */ .hL)(objectType)) { + inputField = objectType.getFields()[node.name.value]; + + if (inputField) { + inputFieldType = inputField.type; + } + } + + this._defaultValueStack.push( + inputField ? inputField.defaultValue : undefined, + ); + + this._inputTypeStack.push( + (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputType */ .j$)(inputFieldType) ? inputFieldType : undefined, + ); + + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.ENUM */ .h.ENUM: { + const enumType = (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getNamedType */ .xC)(this.getInputType()); + let enumValue; + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isEnumType */ .EM)(enumType)) { + enumValue = enumType.getValue(node.value); + } + + this._enumValue = enumValue; + break; + } + + default: // Ignore other nodes + } + } + + leave(node) { + switch (node.kind) { + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SELECTION_SET */ .h.SELECTION_SET: + this._parentTypeStack.pop(); + + break; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.FIELD */ .h.FIELD: + this._fieldDefStack.pop(); + + this._typeStack.pop(); + + break; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.DIRECTIVE */ .h.DIRECTIVE: + this._directive = null; + break; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.OPERATION_DEFINITION */ .h.OPERATION_DEFINITION: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INLINE_FRAGMENT */ .h.INLINE_FRAGMENT: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.FRAGMENT_DEFINITION */ .h.FRAGMENT_DEFINITION: + this._typeStack.pop(); + + break; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.VARIABLE_DEFINITION */ .h.VARIABLE_DEFINITION: + this._inputTypeStack.pop(); + + break; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.ARGUMENT */ .h.ARGUMENT: + this._argument = null; + + this._defaultValueStack.pop(); + + this._inputTypeStack.pop(); + + break; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.LIST */ .h.LIST: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.OBJECT_FIELD */ .h.OBJECT_FIELD: + this._defaultValueStack.pop(); + + this._inputTypeStack.pop(); + + break; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.ENUM */ .h.ENUM: + this._enumValue = null; + break; + + default: // Ignore other nodes + } + } +} + +/** + * Not exactly the same as the executor's definition of getFieldDef, in this + * statically evaluated environment we do not always have an Object type, + * and need to handle Interface and Union types. + */ +function getFieldDef(schema, parentType, fieldNode) { + const name = fieldNode.name.value; + + if ( + name === _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_3__/* .SchemaMetaFieldDef.name */ .Az.name && + schema.getQueryType() === parentType + ) { + return _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_3__/* .SchemaMetaFieldDef */ .Az; + } + + if (name === _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_3__/* .TypeMetaFieldDef.name */ .tF.name && schema.getQueryType() === parentType) { + return _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_3__/* .TypeMetaFieldDef */ .tF; + } + + if (name === _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_3__/* .TypeNameMetaFieldDef.name */ .hU.name && (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isCompositeType */ .Gv)(parentType)) { + return _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_3__/* .TypeNameMetaFieldDef */ .hU; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isObjectType */ .lp)(parentType) || (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInterfaceType */ .oT)(parentType)) { + return parentType.getFields()[name]; + } +} +/** + * Creates a new visitor instance which maintains a provided TypeInfo instance + * along with visiting visitor. + */ + +function visitWithTypeInfo(typeInfo, visitor) { + return { + enter(...args) { + const node = args[0]; + typeInfo.enter(node); + const fn = (0,_language_visitor_mjs__WEBPACK_IMPORTED_MODULE_4__/* .getEnterLeaveForKind */ .Eu)(visitor, node.kind).enter; + + if (fn) { + const result = fn.apply(visitor, args); + + if (result !== undefined) { + typeInfo.leave(node); + + if ((0,_language_ast_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isNode */ .UG)(result)) { + typeInfo.enter(result); + } + } + + return result; + } + }, + + leave(...args) { + const node = args[0]; + const fn = (0,_language_visitor_mjs__WEBPACK_IMPORTED_MODULE_4__/* .getEnterLeaveForKind */ .Eu)(visitor, node.kind).leave; + let result; + + if (fn) { + result = fn.apply(visitor, args); + } + + typeInfo.leave(node); + return result; + }, + }; +} + + +/***/ }), + +/***/ 8631: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "J": () => (/* binding */ astFromValue) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9551); +/* harmony import */ var _jsutils_isIterableObject_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3831); +/* harmony import */ var _jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8495); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7359); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(398); +/* harmony import */ var _type_scalars_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3801); + + + + + + + +/** + * Produces a GraphQL Value AST given a JavaScript object. + * Function will match JavaScript/JSON values to GraphQL AST schema format + * by using suggested GraphQLInputType. For example: + * + * astFromValue("value", GraphQLString) + * + * A GraphQL type must be provided, which will be used to interpret different + * JavaScript values. + * + * | JSON Value | GraphQL Value | + * | ------------- | -------------------- | + * | Object | Input Object | + * | Array | List | + * | Boolean | Boolean | + * | String | String / Enum Value | + * | Number | Int / Float | + * | Unknown | Enum Value | + * | null | NullValue | + * + */ + +function astFromValue(value, type) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isNonNullType */ .zM)(type)) { + const astValue = astFromValue(value, type.ofType); + + if ( + (astValue === null || astValue === void 0 ? void 0 : astValue.kind) === + _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.NULL */ .h.NULL + ) { + return null; + } + + return astValue; + } // only explicit null, not undefined, NaN + + if (value === null) { + return { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.NULL */ .h.NULL, + }; + } // undefined + + if (value === undefined) { + return null; + } // Convert JavaScript array to GraphQL list. If the GraphQLType is a list, but + // the value is not an array, convert the value using the list's item type. + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isListType */ .HG)(type)) { + const itemType = type.ofType; + + if ((0,_jsutils_isIterableObject_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isIterableObject */ .i)(value)) { + const valuesNodes = []; + + for (const item of value) { + const itemNode = astFromValue(item, itemType); + + if (itemNode != null) { + valuesNodes.push(itemNode); + } + } + + return { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.LIST */ .h.LIST, + values: valuesNodes, + }; + } + + return astFromValue(value, itemType); + } // Populate the fields of the input object by creating ASTs from each value + // in the JavaScript object according to the fields in the input type. + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputObjectType */ .hL)(type)) { + if (!(0,_jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_3__/* .isObjectLike */ .y)(value)) { + return null; + } + + const fieldNodes = []; + + for (const field of Object.values(type.getFields())) { + const fieldValue = astFromValue(value[field.name], field.type); + + if (fieldValue) { + fieldNodes.push({ + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.OBJECT_FIELD */ .h.OBJECT_FIELD, + name: { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.NAME */ .h.NAME, + value: field.name, + }, + value: fieldValue, + }); + } + } + + return { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.OBJECT */ .h.OBJECT, + fields: fieldNodes, + }; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isLeafType */ .UT)(type)) { + // Since value is an internally represented value, it must be serialized + // to an externally represented value before converting into an AST. + const serialized = type.serialize(value); + + if (serialized == null) { + return null; + } // Others serialize based on their corresponding JavaScript scalar types. + + if (typeof serialized === 'boolean') { + return { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.BOOLEAN */ .h.BOOLEAN, + value: serialized, + }; + } // JavaScript numbers can be Int or Float values. + + if (typeof serialized === 'number' && Number.isFinite(serialized)) { + const stringNum = String(serialized); + return integerStringRegExp.test(stringNum) + ? { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INT */ .h.INT, + value: stringNum, + } + : { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.FLOAT */ .h.FLOAT, + value: stringNum, + }; + } + + if (typeof serialized === 'string') { + // Enum types use Enum literals. + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isEnumType */ .EM)(type)) { + return { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.ENUM */ .h.ENUM, + value: serialized, + }; + } // ID types can use Int literals. + + if (type === _type_scalars_mjs__WEBPACK_IMPORTED_MODULE_4__/* .GraphQLID */ .km && integerStringRegExp.test(serialized)) { + return { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INT */ .h.INT, + value: serialized, + }; + } + + return { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.STRING */ .h.STRING, + value: serialized, + }; + } + + throw new TypeError(`Cannot convert value to AST: ${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__/* .inspect */ .X)(serialized)}.`); + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_6__/* .invariant */ .k)(false, 'Unexpected input type: ' + (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__/* .inspect */ .X)(type)); +} +/** + * IntValue: + * - NegativeSign? 0 + * - NegativeSign? NonZeroDigit ( Digit+ )? + */ + +const integerStringRegExp = /^-?(?:0|[1-9][0-9]*)$/; + + +/***/ }), + +/***/ 6535: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "I": () => (/* binding */ buildSchema), +/* harmony export */ "M": () => (/* binding */ buildASTSchema) +/* harmony export */ }); +/* harmony import */ var _jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7826); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7359); +/* harmony import */ var _language_parser_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(4275); +/* harmony import */ var _type_directives_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8238); +/* harmony import */ var _type_schema_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(9678); +/* harmony import */ var _validation_validate_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6584); +/* harmony import */ var _extendSchema_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9557); + + + + + + + + +/** + * This takes the ast of a schema document produced by the parse function in + * src/language/parser.js. + * + * If no schema definition is provided, then it will look for types named Query, + * Mutation and Subscription. + * + * Given that AST it constructs a GraphQLSchema. The resulting schema + * has no resolve methods, so execution will use default resolvers. + */ +function buildASTSchema(documentAST, options) { + (documentAST != null && documentAST.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.DOCUMENT */ .h.DOCUMENT) || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_1__/* .devAssert */ .a)(false, 'Must provide valid Document AST.'); + + if ( + (options === null || options === void 0 ? void 0 : options.assumeValid) !== + true && + (options === null || options === void 0 + ? void 0 + : options.assumeValidSDL) !== true + ) { + (0,_validation_validate_mjs__WEBPACK_IMPORTED_MODULE_2__/* .assertValidSDL */ .zo)(documentAST); + } + + const emptySchemaConfig = { + description: undefined, + types: [], + directives: [], + extensions: Object.create(null), + extensionASTNodes: [], + assumeValid: false, + }; + const config = (0,_extendSchema_mjs__WEBPACK_IMPORTED_MODULE_3__/* .extendSchemaImpl */ .w)(emptySchemaConfig, documentAST, options); + + if (config.astNode == null) { + for (const type of config.types) { + switch (type.name) { + // Note: While this could make early assertions to get the correctly + // typed values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + case 'Query': + // @ts-expect-error validated in `validateSchema` + config.query = type; + break; + + case 'Mutation': + // @ts-expect-error validated in `validateSchema` + config.mutation = type; + break; + + case 'Subscription': + // @ts-expect-error validated in `validateSchema` + config.subscription = type; + break; + } + } + } + + const directives = [ + ...config.directives, // If specified directives were not explicitly declared, add them. + ..._type_directives_mjs__WEBPACK_IMPORTED_MODULE_4__/* .specifiedDirectives.filter */ .V4.filter((stdDirective) => + config.directives.every( + (directive) => directive.name !== stdDirective.name, + ), + ), + ]; + return new _type_schema_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLSchema */ .XO({ ...config, directives }); +} +/** + * A helper function to build a GraphQLSchema directly from a source + * document. + */ + +function buildSchema(source, options) { + const document = (0,_language_parser_mjs__WEBPACK_IMPORTED_MODULE_6__/* .parse */ .Qc)(source, { + noLocation: + options === null || options === void 0 ? void 0 : options.noLocation, + allowLegacyFragmentVariables: + options === null || options === void 0 + ? void 0 + : options.allowLegacyFragmentVariables, + }); + return buildASTSchema(document, { + assumeValidSDL: + options === null || options === void 0 ? void 0 : options.assumeValidSDL, + assumeValid: + options === null || options === void 0 ? void 0 : options.assumeValid, + }); +} + + +/***/ }), + +/***/ 7816: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "K": () => (/* binding */ coerceInputValue) +/* harmony export */ }); +/* harmony import */ var _jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(3177); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(9551); +/* harmony import */ var _jsutils_isIterableObject_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3831); +/* harmony import */ var _jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(8495); +/* harmony import */ var _jsutils_Path_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9380); +/* harmony import */ var _jsutils_printPathArray_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4244); +/* harmony import */ var _jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(3294); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(8087); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(398); + + + + + + + + + + + +/** + * Coerces a JavaScript value given a GraphQL Input Type. + */ +function coerceInputValue(inputValue, type, onError = defaultOnError) { + return coerceInputValueImpl(inputValue, type, onError, undefined); +} + +function defaultOnError(path, invalidValue, error) { + let errorPrefix = 'Invalid value ' + (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_0__/* .inspect */ .X)(invalidValue); + + if (path.length > 0) { + errorPrefix += ` at "value${(0,_jsutils_printPathArray_mjs__WEBPACK_IMPORTED_MODULE_1__/* .printPathArray */ .F)(path)}"`; + } + + error.message = errorPrefix + ': ' + error.message; + throw error; +} + +function coerceInputValueImpl(inputValue, type, onError, path) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNonNullType */ .zM)(type)) { + if (inputValue != null) { + return coerceInputValueImpl(inputValue, type.ofType, onError, path); + } + + onError( + (0,_jsutils_Path_mjs__WEBPACK_IMPORTED_MODULE_3__/* .pathToArray */ .N)(path), + inputValue, + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .GraphQLError */ .__( + `Expected non-nullable type "${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_0__/* .inspect */ .X)(type)}" not to be null.`, + ), + ); + return; + } + + if (inputValue == null) { + // Explicitly return the value null. + return null; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isListType */ .HG)(type)) { + const itemType = type.ofType; + + if ((0,_jsutils_isIterableObject_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isIterableObject */ .i)(inputValue)) { + return Array.from(inputValue, (itemValue, index) => { + const itemPath = (0,_jsutils_Path_mjs__WEBPACK_IMPORTED_MODULE_3__/* .addPath */ .Q)(path, index, undefined); + return coerceInputValueImpl(itemValue, itemType, onError, itemPath); + }); + } // Lists accept a non-list value as a list of one. + + return [coerceInputValueImpl(inputValue, itemType, onError, path)]; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInputObjectType */ .hL)(type)) { + if (!(0,_jsutils_isObjectLike_mjs__WEBPACK_IMPORTED_MODULE_6__/* .isObjectLike */ .y)(inputValue)) { + onError( + (0,_jsutils_Path_mjs__WEBPACK_IMPORTED_MODULE_3__/* .pathToArray */ .N)(path), + inputValue, + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .GraphQLError */ .__(`Expected type "${type.name}" to be an object.`), + ); + return; + } + + const coercedValue = {}; + const fieldDefs = type.getFields(); + + for (const field of Object.values(fieldDefs)) { + const fieldValue = inputValue[field.name]; + + if (fieldValue === undefined) { + if (field.defaultValue !== undefined) { + coercedValue[field.name] = field.defaultValue; + } else if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isNonNullType */ .zM)(field.type)) { + const typeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_0__/* .inspect */ .X)(field.type); + onError( + (0,_jsutils_Path_mjs__WEBPACK_IMPORTED_MODULE_3__/* .pathToArray */ .N)(path), + inputValue, + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .GraphQLError */ .__( + `Field "${field.name}" of required type "${typeStr}" was not provided.`, + ), + ); + } + + continue; + } + + coercedValue[field.name] = coerceInputValueImpl( + fieldValue, + field.type, + onError, + (0,_jsutils_Path_mjs__WEBPACK_IMPORTED_MODULE_3__/* .addPath */ .Q)(path, field.name, type.name), + ); + } // Ensure every provided field is defined. + + for (const fieldName of Object.keys(inputValue)) { + if (!fieldDefs[fieldName]) { + const suggestions = (0,_jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_7__/* .suggestionList */ .D)( + fieldName, + Object.keys(type.getFields()), + ); + onError( + (0,_jsutils_Path_mjs__WEBPACK_IMPORTED_MODULE_3__/* .pathToArray */ .N)(path), + inputValue, + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .GraphQLError */ .__( + `Field "${fieldName}" is not defined by type "${type.name}".` + + (0,_jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_8__/* .didYouMean */ .l)(suggestions), + ), + ); + } + } + + return coercedValue; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isLeafType */ .UT)(type)) { + let parseResult; // Scalars and Enums determine if a input value is valid via parseValue(), + // which can throw to indicate failure. If it throws, maintain a reference + // to the original error. + + try { + parseResult = type.parseValue(inputValue); + } catch (error) { + if (error instanceof _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .GraphQLError */ .__) { + onError((0,_jsutils_Path_mjs__WEBPACK_IMPORTED_MODULE_3__/* .pathToArray */ .N)(path), inputValue, error); + } else { + onError( + (0,_jsutils_Path_mjs__WEBPACK_IMPORTED_MODULE_3__/* .pathToArray */ .N)(path), + inputValue, + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .GraphQLError */ .__(`Expected type "${type.name}". ` + error.message, { + originalError: error, + }), + ); + } + + return; + } + + if (parseResult === undefined) { + onError( + (0,_jsutils_Path_mjs__WEBPACK_IMPORTED_MODULE_3__/* .pathToArray */ .N)(path), + inputValue, + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_4__/* .GraphQLError */ .__(`Expected type "${type.name}".`), + ); + } + + return parseResult; + } + /* c8 ignore next 3 */ + // Not reachable, all possible types have been considered. + + false || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_9__/* .invariant */ .k)(false, 'Unexpected input type: ' + (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_0__/* .inspect */ .X)(type)); +} + + +/***/ }), + +/***/ 9557: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "a": () => (/* binding */ extendSchema), +/* harmony export */ "w": () => (/* binding */ extendSchemaImpl) +/* harmony export */ }); +/* harmony import */ var _jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7826); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(9551); +/* harmony import */ var _jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(3498); +/* harmony import */ var _jsutils_mapValue_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(5723); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7359); +/* harmony import */ var _language_predicates_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5844); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(398); +/* harmony import */ var _type_directives_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(8238); +/* harmony import */ var _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(2433); +/* harmony import */ var _type_scalars_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(3801); +/* harmony import */ var _type_schema_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9678); +/* harmony import */ var _validation_validate_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(6584); +/* harmony import */ var _execution_values_mjs__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(6422); +/* harmony import */ var _valueFromAST_mjs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(2221); + + + + + + + + + + + + + + + + +/** + * Produces a new schema given an existing schema and a document which may + * contain GraphQL type extensions and definitions. The original schema will + * remain unaltered. + * + * Because a schema represents a graph of references, a schema cannot be + * extended without effectively making an entire copy. We do not know until it's + * too late if subgraphs remain unchanged. + * + * This algorithm copies the provided schema, applying extensions while + * producing the copy. The original schema remains unaltered. + */ +function extendSchema(schema, documentAST, options) { + (0,_type_schema_mjs__WEBPACK_IMPORTED_MODULE_0__/* .assertSchema */ .EO)(schema); + (documentAST != null && documentAST.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.DOCUMENT */ .h.DOCUMENT) || + (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_2__/* .devAssert */ .a)(false, 'Must provide valid Document AST.'); + + if ( + (options === null || options === void 0 ? void 0 : options.assumeValid) !== + true && + (options === null || options === void 0 + ? void 0 + : options.assumeValidSDL) !== true + ) { + (0,_validation_validate_mjs__WEBPACK_IMPORTED_MODULE_3__/* .assertValidSDLExtension */ .ED)(documentAST, schema); + } + + const schemaConfig = schema.toConfig(); + const extendedConfig = extendSchemaImpl(schemaConfig, documentAST, options); + return schemaConfig === extendedConfig + ? schema + : new _type_schema_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLSchema */ .XO(extendedConfig); +} +/** + * @internal + */ + +function extendSchemaImpl(schemaConfig, documentAST, options) { + var _schemaDef, _schemaDef$descriptio, _schemaDef2, _options$assumeValid; + + // Collect the type definitions and extensions found in the document. + const typeDefs = []; + const typeExtensionsMap = Object.create(null); // New directives and types are separate because a directives and types can + // have the same name. For example, a type named "skip". + + const directiveDefs = []; + let schemaDef; // Schema extensions are collected which may add additional operation types. + + const schemaExtensions = []; + + for (const def of documentAST.definitions) { + if (def.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCHEMA_DEFINITION */ .h.SCHEMA_DEFINITION) { + schemaDef = def; + } else if (def.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCHEMA_EXTENSION */ .h.SCHEMA_EXTENSION) { + schemaExtensions.push(def); + } else if ((0,_language_predicates_mjs__WEBPACK_IMPORTED_MODULE_4__/* .isTypeDefinitionNode */ .zT)(def)) { + typeDefs.push(def); + } else if ((0,_language_predicates_mjs__WEBPACK_IMPORTED_MODULE_4__/* .isTypeExtensionNode */ .D$)(def)) { + const extendedTypeName = def.name.value; + const existingTypeExtensions = typeExtensionsMap[extendedTypeName]; + typeExtensionsMap[extendedTypeName] = existingTypeExtensions + ? existingTypeExtensions.concat([def]) + : [def]; + } else if (def.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.DIRECTIVE_DEFINITION */ .h.DIRECTIVE_DEFINITION) { + directiveDefs.push(def); + } + } // If this document contains no new types, extensions, or directives then + // return the same unmodified GraphQLSchema instance. + + if ( + Object.keys(typeExtensionsMap).length === 0 && + typeDefs.length === 0 && + directiveDefs.length === 0 && + schemaExtensions.length === 0 && + schemaDef == null + ) { + return schemaConfig; + } + + const typeMap = Object.create(null); + + for (const existingType of schemaConfig.types) { + typeMap[existingType.name] = extendNamedType(existingType); + } + + for (const typeNode of typeDefs) { + var _stdTypeMap$name; + + const name = typeNode.name.value; + typeMap[name] = + (_stdTypeMap$name = stdTypeMap[name]) !== null && + _stdTypeMap$name !== void 0 + ? _stdTypeMap$name + : buildType(typeNode); + } + + const operationTypes = { + // Get the extended root operation types. + query: schemaConfig.query && replaceNamedType(schemaConfig.query), + mutation: schemaConfig.mutation && replaceNamedType(schemaConfig.mutation), + subscription: + schemaConfig.subscription && replaceNamedType(schemaConfig.subscription), + // Then, incorporate schema definition and all schema extensions. + ...(schemaDef && getOperationTypes([schemaDef])), + ...getOperationTypes(schemaExtensions), + }; // Then produce and return a Schema config with these types. + + return { + description: + (_schemaDef = schemaDef) === null || _schemaDef === void 0 + ? void 0 + : (_schemaDef$descriptio = _schemaDef.description) === null || + _schemaDef$descriptio === void 0 + ? void 0 + : _schemaDef$descriptio.value, + ...operationTypes, + types: Object.values(typeMap), + directives: [ + ...schemaConfig.directives.map(replaceDirective), + ...directiveDefs.map(buildDirective), + ], + extensions: Object.create(null), + astNode: + (_schemaDef2 = schemaDef) !== null && _schemaDef2 !== void 0 + ? _schemaDef2 + : schemaConfig.astNode, + extensionASTNodes: schemaConfig.extensionASTNodes.concat(schemaExtensions), + assumeValid: + (_options$assumeValid = + options === null || options === void 0 + ? void 0 + : options.assumeValid) !== null && _options$assumeValid !== void 0 + ? _options$assumeValid + : false, + }; // Below are functions used for producing this schema that have closed over + // this scope and have access to the schema, cache, and newly defined types. + + function replaceType(type) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isListType */ .HG)(type)) { + // @ts-expect-error + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLList */ .p2(replaceType(type.ofType)); + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isNonNullType */ .zM)(type)) { + // @ts-expect-error + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLNonNull */ .bM(replaceType(type.ofType)); + } // @ts-expect-error FIXME + + return replaceNamedType(type); + } + + function replaceNamedType(type) { + // Note: While this could make early assertions to get the correctly + // typed values, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + return typeMap[type.name]; + } + + function replaceDirective(directive) { + const config = directive.toConfig(); + return new _type_directives_mjs__WEBPACK_IMPORTED_MODULE_6__/* .GraphQLDirective */ .NZ({ + ...config, + args: (0,_jsutils_mapValue_mjs__WEBPACK_IMPORTED_MODULE_7__/* .mapValue */ .j)(config.args, extendArg), + }); + } + + function extendNamedType(type) { + if ((0,_type_introspection_mjs__WEBPACK_IMPORTED_MODULE_8__/* .isIntrospectionType */ .s9)(type) || (0,_type_scalars_mjs__WEBPACK_IMPORTED_MODULE_9__/* .isSpecifiedScalarType */ .u1)(type)) { + // Builtin types are not extended. + return type; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isScalarType */ .KA)(type)) { + return extendScalarType(type); + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isObjectType */ .lp)(type)) { + return extendObjectType(type); + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isInterfaceType */ .oT)(type)) { + return extendInterfaceType(type); + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isUnionType */ .EN)(type)) { + return extendUnionType(type); + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isEnumType */ .EM)(type)) { + return extendEnumType(type); + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isInputObjectType */ .hL)(type)) { + return extendInputObjectType(type); + } + /* c8 ignore next 3 */ + // Not reachable, all possible type definition nodes have been considered. + + false || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_10__/* .invariant */ .k)(false, 'Unexpected type: ' + (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_11__/* .inspect */ .X)(type)); + } + + function extendInputObjectType(type) { + var _typeExtensionsMap$co; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co !== void 0 + ? _typeExtensionsMap$co + : []; + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLInputObjectType */ .sR({ + ...config, + fields: () => ({ + ...(0,_jsutils_mapValue_mjs__WEBPACK_IMPORTED_MODULE_7__/* .mapValue */ .j)(config.fields, (field) => ({ + ...field, + type: replaceType(field.type), + })), + ...buildInputFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendEnumType(type) { + var _typeExtensionsMap$ty; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$ty = typeExtensionsMap[type.name]) !== null && + _typeExtensionsMap$ty !== void 0 + ? _typeExtensionsMap$ty + : []; + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLEnumType */ .mR({ + ...config, + values: { ...config.values, ...buildEnumValueMap(extensions) }, + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendScalarType(type) { + var _typeExtensionsMap$co2; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co2 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co2 !== void 0 + ? _typeExtensionsMap$co2 + : []; + let specifiedByURL = config.specifiedByURL; + + for (const extensionNode of extensions) { + var _getSpecifiedByURL; + + specifiedByURL = + (_getSpecifiedByURL = getSpecifiedByURL(extensionNode)) !== null && + _getSpecifiedByURL !== void 0 + ? _getSpecifiedByURL + : specifiedByURL; + } + + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLScalarType */ .n2({ + ...config, + specifiedByURL, + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendObjectType(type) { + var _typeExtensionsMap$co3; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co3 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co3 !== void 0 + ? _typeExtensionsMap$co3 + : []; + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLObjectType */ .h6({ + ...config, + interfaces: () => [ + ...type.getInterfaces().map(replaceNamedType), + ...buildInterfaces(extensions), + ], + fields: () => ({ + ...(0,_jsutils_mapValue_mjs__WEBPACK_IMPORTED_MODULE_7__/* .mapValue */ .j)(config.fields, extendField), + ...buildFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendInterfaceType(type) { + var _typeExtensionsMap$co4; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co4 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co4 !== void 0 + ? _typeExtensionsMap$co4 + : []; + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLInterfaceType */ .oW({ + ...config, + interfaces: () => [ + ...type.getInterfaces().map(replaceNamedType), + ...buildInterfaces(extensions), + ], + fields: () => ({ + ...(0,_jsutils_mapValue_mjs__WEBPACK_IMPORTED_MODULE_7__/* .mapValue */ .j)(config.fields, extendField), + ...buildFieldMap(extensions), + }), + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendUnionType(type) { + var _typeExtensionsMap$co5; + + const config = type.toConfig(); + const extensions = + (_typeExtensionsMap$co5 = typeExtensionsMap[config.name]) !== null && + _typeExtensionsMap$co5 !== void 0 + ? _typeExtensionsMap$co5 + : []; + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLUnionType */ .Gp({ + ...config, + types: () => [ + ...type.getTypes().map(replaceNamedType), + ...buildUnionTypes(extensions), + ], + extensionASTNodes: config.extensionASTNodes.concat(extensions), + }); + } + + function extendField(field) { + return { + ...field, + type: replaceType(field.type), + args: field.args && (0,_jsutils_mapValue_mjs__WEBPACK_IMPORTED_MODULE_7__/* .mapValue */ .j)(field.args, extendArg), + }; + } + + function extendArg(arg) { + return { ...arg, type: replaceType(arg.type) }; + } + + function getOperationTypes(nodes) { + const opTypes = {}; + + for (const node of nodes) { + var _node$operationTypes; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const operationTypesNodes = + /* c8 ignore next */ + (_node$operationTypes = node.operationTypes) !== null && + _node$operationTypes !== void 0 + ? _node$operationTypes + : []; + + for (const operationType of operationTypesNodes) { + // Note: While this could make early assertions to get the correctly + // typed values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + opTypes[operationType.operation] = getNamedType(operationType.type); + } + } + + return opTypes; + } + + function getNamedType(node) { + var _stdTypeMap$name2; + + const name = node.name.value; + const type = + (_stdTypeMap$name2 = stdTypeMap[name]) !== null && + _stdTypeMap$name2 !== void 0 + ? _stdTypeMap$name2 + : typeMap[name]; + + if (type === undefined) { + throw new Error(`Unknown type: "${name}".`); + } + + return type; + } + + function getWrappedType(node) { + if (node.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.LIST_TYPE */ .h.LIST_TYPE) { + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLList */ .p2(getWrappedType(node.type)); + } + + if (node.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.NON_NULL_TYPE */ .h.NON_NULL_TYPE) { + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLNonNull */ .bM(getWrappedType(node.type)); + } + + return getNamedType(node); + } + + function buildDirective(node) { + var _node$description; + + return new _type_directives_mjs__WEBPACK_IMPORTED_MODULE_6__/* .GraphQLDirective */ .NZ({ + name: node.name.value, + description: + (_node$description = node.description) === null || + _node$description === void 0 + ? void 0 + : _node$description.value, + // @ts-expect-error + locations: node.locations.map(({ value }) => value), + isRepeatable: node.repeatable, + args: buildArgumentMap(node.arguments), + astNode: node, + }); + } + + function buildFieldMap(nodes) { + const fieldConfigMap = Object.create(null); + + for (const node of nodes) { + var _node$fields; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const nodeFields = + /* c8 ignore next */ + (_node$fields = node.fields) !== null && _node$fields !== void 0 + ? _node$fields + : []; + + for (const field of nodeFields) { + var _field$description; + + fieldConfigMap[field.name.value] = { + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + type: getWrappedType(field.type), + description: + (_field$description = field.description) === null || + _field$description === void 0 + ? void 0 + : _field$description.value, + args: buildArgumentMap(field.arguments), + deprecationReason: getDeprecationReason(field), + astNode: field, + }; + } + } + + return fieldConfigMap; + } + + function buildArgumentMap(args) { + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const argsNodes = + /* c8 ignore next */ + args !== null && args !== void 0 ? args : []; + const argConfigMap = Object.create(null); + + for (const arg of argsNodes) { + var _arg$description; + + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + const type = getWrappedType(arg.type); + argConfigMap[arg.name.value] = { + type, + description: + (_arg$description = arg.description) === null || + _arg$description === void 0 + ? void 0 + : _arg$description.value, + defaultValue: (0,_valueFromAST_mjs__WEBPACK_IMPORTED_MODULE_12__/* .valueFromAST */ .u)(arg.defaultValue, type), + deprecationReason: getDeprecationReason(arg), + astNode: arg, + }; + } + + return argConfigMap; + } + + function buildInputFieldMap(nodes) { + const inputFieldMap = Object.create(null); + + for (const node of nodes) { + var _node$fields2; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const fieldsNodes = + /* c8 ignore next */ + (_node$fields2 = node.fields) !== null && _node$fields2 !== void 0 + ? _node$fields2 + : []; + + for (const field of fieldsNodes) { + var _field$description2; + + // Note: While this could make assertions to get the correctly typed + // value, that would throw immediately while type system validation + // with validateSchema() will produce more actionable results. + const type = getWrappedType(field.type); + inputFieldMap[field.name.value] = { + type, + description: + (_field$description2 = field.description) === null || + _field$description2 === void 0 + ? void 0 + : _field$description2.value, + defaultValue: (0,_valueFromAST_mjs__WEBPACK_IMPORTED_MODULE_12__/* .valueFromAST */ .u)(field.defaultValue, type), + deprecationReason: getDeprecationReason(field), + astNode: field, + }; + } + } + + return inputFieldMap; + } + + function buildEnumValueMap(nodes) { + const enumValueMap = Object.create(null); + + for (const node of nodes) { + var _node$values; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + const valuesNodes = + /* c8 ignore next */ + (_node$values = node.values) !== null && _node$values !== void 0 + ? _node$values + : []; + + for (const value of valuesNodes) { + var _value$description; + + enumValueMap[value.name.value] = { + description: + (_value$description = value.description) === null || + _value$description === void 0 + ? void 0 + : _value$description.value, + deprecationReason: getDeprecationReason(value), + astNode: value, + }; + } + } + + return enumValueMap; + } + + function buildInterfaces(nodes) { + // Note: While this could make assertions to get the correctly typed + // values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + return nodes.flatMap( + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + (node) => { + var _node$interfaces$map, _node$interfaces; + + return ( + /* c8 ignore next */ + (_node$interfaces$map = + (_node$interfaces = node.interfaces) === null || + _node$interfaces === void 0 + ? void 0 + : _node$interfaces.map(getNamedType)) !== null && + _node$interfaces$map !== void 0 + ? _node$interfaces$map + : [] + ); + }, + ); + } + + function buildUnionTypes(nodes) { + // Note: While this could make assertions to get the correctly typed + // values below, that would throw immediately while type system + // validation with validateSchema() will produce more actionable results. + // @ts-expect-error + return nodes.flatMap( + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + (node) => { + var _node$types$map, _node$types; + + return ( + /* c8 ignore next */ + (_node$types$map = + (_node$types = node.types) === null || _node$types === void 0 + ? void 0 + : _node$types.map(getNamedType)) !== null && + _node$types$map !== void 0 + ? _node$types$map + : [] + ); + }, + ); + } + + function buildType(astNode) { + var _typeExtensionsMap$na; + + const name = astNode.name.value; + const extensionASTNodes = + (_typeExtensionsMap$na = typeExtensionsMap[name]) !== null && + _typeExtensionsMap$na !== void 0 + ? _typeExtensionsMap$na + : []; + + switch (astNode.kind) { + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.OBJECT_TYPE_DEFINITION */ .h.OBJECT_TYPE_DEFINITION: { + var _astNode$description; + + const allNodes = [astNode, ...extensionASTNodes]; + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLObjectType */ .h6({ + name, + description: + (_astNode$description = astNode.description) === null || + _astNode$description === void 0 + ? void 0 + : _astNode$description.value, + interfaces: () => buildInterfaces(allNodes), + fields: () => buildFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INTERFACE_TYPE_DEFINITION */ .h.INTERFACE_TYPE_DEFINITION: { + var _astNode$description2; + + const allNodes = [astNode, ...extensionASTNodes]; + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLInterfaceType */ .oW({ + name, + description: + (_astNode$description2 = astNode.description) === null || + _astNode$description2 === void 0 + ? void 0 + : _astNode$description2.value, + interfaces: () => buildInterfaces(allNodes), + fields: () => buildFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.ENUM_TYPE_DEFINITION */ .h.ENUM_TYPE_DEFINITION: { + var _astNode$description3; + + const allNodes = [astNode, ...extensionASTNodes]; + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLEnumType */ .mR({ + name, + description: + (_astNode$description3 = astNode.description) === null || + _astNode$description3 === void 0 + ? void 0 + : _astNode$description3.value, + values: buildEnumValueMap(allNodes), + astNode, + extensionASTNodes, + }); + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.UNION_TYPE_DEFINITION */ .h.UNION_TYPE_DEFINITION: { + var _astNode$description4; + + const allNodes = [astNode, ...extensionASTNodes]; + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLUnionType */ .Gp({ + name, + description: + (_astNode$description4 = astNode.description) === null || + _astNode$description4 === void 0 + ? void 0 + : _astNode$description4.value, + types: () => buildUnionTypes(allNodes), + astNode, + extensionASTNodes, + }); + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCALAR_TYPE_DEFINITION */ .h.SCALAR_TYPE_DEFINITION: { + var _astNode$description5; + + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLScalarType */ .n2({ + name, + description: + (_astNode$description5 = astNode.description) === null || + _astNode$description5 === void 0 + ? void 0 + : _astNode$description5.value, + specifiedByURL: getSpecifiedByURL(astNode), + astNode, + extensionASTNodes, + }); + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INPUT_OBJECT_TYPE_DEFINITION */ .h.INPUT_OBJECT_TYPE_DEFINITION: { + var _astNode$description6; + + const allNodes = [astNode, ...extensionASTNodes]; + return new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLInputObjectType */ .sR({ + name, + description: + (_astNode$description6 = astNode.description) === null || + _astNode$description6 === void 0 + ? void 0 + : _astNode$description6.value, + fields: () => buildInputFieldMap(allNodes), + astNode, + extensionASTNodes, + }); + } + } + } +} +const stdTypeMap = (0,_jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_13__/* .keyMap */ .P)( + [..._type_scalars_mjs__WEBPACK_IMPORTED_MODULE_9__/* .specifiedScalarTypes */ .HS, ..._type_introspection_mjs__WEBPACK_IMPORTED_MODULE_8__/* .introspectionTypes */ .nL], + (type) => type.name, +); +/** + * Given a field or enum value node, returns the string value for the + * deprecation reason. + */ + +function getDeprecationReason(node) { + const deprecated = (0,_execution_values_mjs__WEBPACK_IMPORTED_MODULE_14__/* .getDirectiveValues */ .zu)(_type_directives_mjs__WEBPACK_IMPORTED_MODULE_6__/* .GraphQLDeprecatedDirective */ .fg, node); // @ts-expect-error validated by `getDirectiveValues` + + return deprecated === null || deprecated === void 0 + ? void 0 + : deprecated.reason; +} +/** + * Given a scalar node, returns the string value for the specifiedByURL. + */ + +function getSpecifiedByURL(node) { + const specifiedBy = (0,_execution_values_mjs__WEBPACK_IMPORTED_MODULE_14__/* .getDirectiveValues */ .zu)(_type_directives_mjs__WEBPACK_IMPORTED_MODULE_6__/* .GraphQLSpecifiedByDirective */ .df, node); // @ts-expect-error validated by `getDirectiveValues` + + return specifiedBy === null || specifiedBy === void 0 + ? void 0 + : specifiedBy.url; +} + + +/***/ }), + +/***/ 8360: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "n": () => (/* binding */ sortValueNode) +/* harmony export */ }); +/* harmony import */ var _jsutils_naturalCompare_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8224); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7359); + + +/** + * Sort ValueNode. + * + * This function returns a sorted copy of the given ValueNode. + * + * @internal + */ + +function sortValueNode(valueNode) { + switch (valueNode.kind) { + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.OBJECT */ .h.OBJECT: + return { ...valueNode, fields: sortFields(valueNode.fields) }; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.LIST */ .h.LIST: + return { ...valueNode, values: valueNode.values.map(sortValueNode) }; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.INT */ .h.INT: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FLOAT */ .h.FLOAT: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.STRING */ .h.STRING: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.BOOLEAN */ .h.BOOLEAN: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.NULL */ .h.NULL: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.ENUM */ .h.ENUM: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.VARIABLE */ .h.VARIABLE: + return valueNode; + } +} + +function sortFields(fields) { + return fields + .map((fieldNode) => ({ + ...fieldNode, + value: sortValueNode(fieldNode.value), + })) + .sort((fieldA, fieldB) => + (0,_jsutils_naturalCompare_mjs__WEBPACK_IMPORTED_MODULE_1__/* .naturalCompare */ .K)(fieldA.name.value, fieldB.name.value), + ); +} + + +/***/ }), + +/***/ 316: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "_7": () => (/* binding */ isEqualType), +/* harmony export */ "uJ": () => (/* binding */ isTypeSubTypeOf), +/* harmony export */ "zR": () => (/* binding */ doTypesOverlap) +/* harmony export */ }); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(398); + + +/** + * Provided two types, return true if the types are equal (invariant). + */ +function isEqualType(typeA, typeB) { + // Equivalent types are equal. + if (typeA === typeB) { + return true; + } // If either type is non-null, the other must also be non-null. + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isNonNullType */ .zM)(typeA) && (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isNonNullType */ .zM)(typeB)) { + return isEqualType(typeA.ofType, typeB.ofType); + } // If either type is a list, the other must also be a list. + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isListType */ .HG)(typeA) && (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isListType */ .HG)(typeB)) { + return isEqualType(typeA.ofType, typeB.ofType); + } // Otherwise the types are not equal. + + return false; +} +/** + * Provided a type and a super type, return true if the first type is either + * equal or a subset of the second super type (covariant). + */ + +function isTypeSubTypeOf(schema, maybeSubType, superType) { + // Equivalent type is a valid subtype + if (maybeSubType === superType) { + return true; + } // If superType is non-null, maybeSubType must also be non-null. + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isNonNullType */ .zM)(superType)) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isNonNullType */ .zM)(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } + + return false; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isNonNullType */ .zM)(maybeSubType)) { + // If superType is nullable, maybeSubType may be non-null or nullable. + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType); + } // If superType type is a list, maybeSubType type must also be a list. + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isListType */ .HG)(superType)) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isListType */ .HG)(maybeSubType)) { + return isTypeSubTypeOf(schema, maybeSubType.ofType, superType.ofType); + } + + return false; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isListType */ .HG)(maybeSubType)) { + // If superType is not a list, maybeSubType must also be not a list. + return false; + } // If superType type is an abstract type, check if it is super type of maybeSubType. + // Otherwise, the child type is not a valid subtype of the parent type. + + return ( + (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isAbstractType */ .m0)(superType) && + ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInterfaceType */ .oT)(maybeSubType) || (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isObjectType */ .lp)(maybeSubType)) && + schema.isSubType(superType, maybeSubType) + ); +} +/** + * Provided two composite types, determine if they "overlap". Two composite + * types overlap when the Sets of possible concrete types for each intersect. + * + * This is often used to determine if a fragment of a given type could possibly + * be visited in a context of another type. + * + * This function is commutative. + */ + +function doTypesOverlap(schema, typeA, typeB) { + // Equivalent types overlap + if (typeA === typeB) { + return true; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isAbstractType */ .m0)(typeA)) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isAbstractType */ .m0)(typeB)) { + // If both types are abstract, then determine if there is any intersection + // between possible concrete types of each. + return schema + .getPossibleTypes(typeA) + .some((type) => schema.isSubType(typeB, type)); + } // Determine if the latter type is a possible concrete type of the former. + + return schema.isSubType(typeA, typeB); + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isAbstractType */ .m0)(typeB)) { + // Determine if the former type is a possible concrete type of the latter. + return schema.isSubType(typeB, typeA); + } // Otherwise the types do not overlap. + + return false; +} + + +/***/ }), + +/***/ 77: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "_": () => (/* binding */ typeFromAST) +/* harmony export */ }); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7359); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(398); + + +function typeFromAST(schema, typeNode) { + switch (typeNode.kind) { + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.LIST_TYPE */ .h.LIST_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLList */ .p2(innerType); + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.NON_NULL_TYPE */ .h.NON_NULL_TYPE: { + const innerType = typeFromAST(schema, typeNode.type); + return innerType && new _type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLNonNull */ .bM(innerType); + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.NAMED_TYPE */ .h.NAMED_TYPE: + return schema.getType(typeNode.name.value); + } +} + + +/***/ }), + +/***/ 2221: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "u": () => (/* binding */ valueFromAST) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9551); +/* harmony import */ var _jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3498); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7359); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(398); + + + + + +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * A GraphQL type must be provided, which will be used to interpret different + * GraphQL Value literals. + * + * Returns `undefined` when the value could not be validly coerced according to + * the provided type. + * + * | GraphQL Value | JSON Value | + * | -------------------- | ------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String | String | + * | Int / Float | Number | + * | Enum Value | Unknown | + * | NullValue | null | + * + */ + +function valueFromAST(valueNode, type, variables) { + if (!valueNode) { + // When there is no node, then there is also no value. + // Importantly, this is different from returning the value null. + return; + } + + if (valueNode.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.VARIABLE */ .h.VARIABLE) { + const variableName = valueNode.name.value; + + if (variables == null || variables[variableName] === undefined) { + // No valid return value. + return; + } + + const variableValue = variables[variableName]; + + if (variableValue === null && (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isNonNullType */ .zM)(type)) { + return; // Invalid: intentionally return no value. + } // Note: This does no further checking that this variable is correct. + // This assumes that this query has been validated and the variable + // usage here is of the correct type. + + return variableValue; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isNonNullType */ .zM)(type)) { + if (valueNode.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.NULL */ .h.NULL) { + return; // Invalid: intentionally return no value. + } + + return valueFromAST(valueNode, type.ofType, variables); + } + + if (valueNode.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.NULL */ .h.NULL) { + // This is explicitly returning the value null. + return null; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isListType */ .HG)(type)) { + const itemType = type.ofType; + + if (valueNode.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.LIST */ .h.LIST) { + const coercedValues = []; + + for (const itemNode of valueNode.values) { + if (isMissingVariable(itemNode, variables)) { + // If an array contains a missing variable, it is either coerced to + // null or if the item type is non-null, it considered invalid. + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isNonNullType */ .zM)(itemType)) { + return; // Invalid: intentionally return no value. + } + + coercedValues.push(null); + } else { + const itemValue = valueFromAST(itemNode, itemType, variables); + + if (itemValue === undefined) { + return; // Invalid: intentionally return no value. + } + + coercedValues.push(itemValue); + } + } + + return coercedValues; + } + + const coercedValue = valueFromAST(valueNode, itemType, variables); + + if (coercedValue === undefined) { + return; // Invalid: intentionally return no value. + } + + return [coercedValue]; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isInputObjectType */ .hL)(type)) { + if (valueNode.kind !== _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.OBJECT */ .h.OBJECT) { + return; // Invalid: intentionally return no value. + } + + const coercedObj = Object.create(null); + const fieldNodes = (0,_jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_2__/* .keyMap */ .P)(valueNode.fields, (field) => field.name.value); + + for (const field of Object.values(type.getFields())) { + const fieldNode = fieldNodes[field.name]; + + if (!fieldNode || isMissingVariable(fieldNode.value, variables)) { + if (field.defaultValue !== undefined) { + coercedObj[field.name] = field.defaultValue; + } else if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isNonNullType */ .zM)(field.type)) { + return; // Invalid: intentionally return no value. + } + + continue; + } + + const fieldValue = valueFromAST(fieldNode.value, field.type, variables); + + if (fieldValue === undefined) { + return; // Invalid: intentionally return no value. + } + + coercedObj[field.name] = fieldValue; + } + + return coercedObj; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isLeafType */ .UT)(type)) { + // Scalars and Enums fulfill parsing a literal value via parseLiteral(). + // Invalid values represent a failure to parse correctly, in which case + // no value is returned. + let result; + + try { + result = type.parseLiteral(valueNode, variables); + } catch (_error) { + return; // Invalid: intentionally return no value. + } + + if (result === undefined) { + return; // Invalid: intentionally return no value. + } + + return result; + } + /* c8 ignore next 3 */ + // Not reachable, all possible input types have been considered. + + false || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_3__/* .invariant */ .k)(false, 'Unexpected input type: ' + (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_4__/* .inspect */ .X)(type)); +} // Returns true if the provided valueNode is a variable which is not defined +// in the set of variables. + +function isMissingVariable(valueNode, variables) { + return ( + valueNode.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.VARIABLE */ .h.VARIABLE && + (variables == null || variables[valueNode.name.value] === undefined) + ); +} + + +/***/ }), + +/***/ 2319: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "M": () => (/* binding */ valueFromASTUntyped) +/* harmony export */ }); +/* harmony import */ var _jsutils_keyValMap_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4950); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7359); + + +/** + * Produces a JavaScript value given a GraphQL Value AST. + * + * Unlike `valueFromAST()`, no type is provided. The resulting JavaScript value + * will reflect the provided GraphQL value AST. + * + * | GraphQL Value | JavaScript Value | + * | -------------------- | ---------------- | + * | Input Object | Object | + * | List | Array | + * | Boolean | Boolean | + * | String / Enum | String | + * | Int / Float | Number | + * | Null | null | + * + */ + +function valueFromASTUntyped(valueNode, variables) { + switch (valueNode.kind) { + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.NULL */ .h.NULL: + return null; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.INT */ .h.INT: + return parseInt(valueNode.value, 10); + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FLOAT */ .h.FLOAT: + return parseFloat(valueNode.value); + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.STRING */ .h.STRING: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.ENUM */ .h.ENUM: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.BOOLEAN */ .h.BOOLEAN: + return valueNode.value; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.LIST */ .h.LIST: + return valueNode.values.map((node) => + valueFromASTUntyped(node, variables), + ); + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.OBJECT */ .h.OBJECT: + return (0,_jsutils_keyValMap_mjs__WEBPACK_IMPORTED_MODULE_1__/* .keyValMap */ .w)( + valueNode.fields, + (field) => field.name.value, + (field) => valueFromASTUntyped(field.value, variables), + ); + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.VARIABLE */ .h.VARIABLE: + return variables === null || variables === void 0 + ? void 0 + : variables[valueNode.name.value]; + } +} + + +/***/ }), + +/***/ 2734: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "_t": () => (/* binding */ ValidationContext), +/* harmony export */ "yv": () => (/* binding */ SDLValidationContext) +/* harmony export */ }); +/* unused harmony export ASTValidationContext */ +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7359); +/* harmony import */ var _language_visitor_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7304); +/* harmony import */ var _utilities_TypeInfo_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2676); + + + + +/** + * An instance of this class is passed as the "this" context to all validators, + * allowing access to commonly useful contextual information from within a + * validation rule. + */ +class ASTValidationContext { + constructor(ast, onError) { + this._ast = ast; + this._fragments = undefined; + this._fragmentSpreads = new Map(); + this._recursivelyReferencedFragments = new Map(); + this._onError = onError; + } + + get [Symbol.toStringTag]() { + return 'ASTValidationContext'; + } + + reportError(error) { + this._onError(error); + } + + getDocument() { + return this._ast; + } + + getFragment(name) { + let fragments; + + if (this._fragments) { + fragments = this._fragments; + } else { + fragments = Object.create(null); + + for (const defNode of this.getDocument().definitions) { + if (defNode.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FRAGMENT_DEFINITION */ .h.FRAGMENT_DEFINITION) { + fragments[defNode.name.value] = defNode; + } + } + + this._fragments = fragments; + } + + return fragments[name]; + } + + getFragmentSpreads(node) { + let spreads = this._fragmentSpreads.get(node); + + if (!spreads) { + spreads = []; + const setsToVisit = [node]; + let set; + + while ((set = setsToVisit.pop())) { + for (const selection of set.selections) { + if (selection.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FRAGMENT_SPREAD */ .h.FRAGMENT_SPREAD) { + spreads.push(selection); + } else if (selection.selectionSet) { + setsToVisit.push(selection.selectionSet); + } + } + } + + this._fragmentSpreads.set(node, spreads); + } + + return spreads; + } + + getRecursivelyReferencedFragments(operation) { + let fragments = this._recursivelyReferencedFragments.get(operation); + + if (!fragments) { + fragments = []; + const collectedNames = Object.create(null); + const nodesToVisit = [operation.selectionSet]; + let node; + + while ((node = nodesToVisit.pop())) { + for (const spread of this.getFragmentSpreads(node)) { + const fragName = spread.name.value; + + if (collectedNames[fragName] !== true) { + collectedNames[fragName] = true; + const fragment = this.getFragment(fragName); + + if (fragment) { + fragments.push(fragment); + nodesToVisit.push(fragment.selectionSet); + } + } + } + } + + this._recursivelyReferencedFragments.set(operation, fragments); + } + + return fragments; + } +} +class SDLValidationContext extends ASTValidationContext { + constructor(ast, schema, onError) { + super(ast, onError); + this._schema = schema; + } + + get [Symbol.toStringTag]() { + return 'SDLValidationContext'; + } + + getSchema() { + return this._schema; + } +} +class ValidationContext extends ASTValidationContext { + constructor(schema, ast, typeInfo, onError) { + super(ast, onError); + this._schema = schema; + this._typeInfo = typeInfo; + this._variableUsages = new Map(); + this._recursiveVariableUsages = new Map(); + } + + get [Symbol.toStringTag]() { + return 'ValidationContext'; + } + + getSchema() { + return this._schema; + } + + getVariableUsages(node) { + let usages = this._variableUsages.get(node); + + if (!usages) { + const newUsages = []; + const typeInfo = new _utilities_TypeInfo_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TypeInfo */ .a(this._schema); + (0,_language_visitor_mjs__WEBPACK_IMPORTED_MODULE_2__/* .visit */ .Vn)( + node, + (0,_utilities_TypeInfo_mjs__WEBPACK_IMPORTED_MODULE_1__/* .visitWithTypeInfo */ .y)(typeInfo, { + VariableDefinition: () => false, + + Variable(variable) { + newUsages.push({ + node: variable, + type: typeInfo.getInputType(), + defaultValue: typeInfo.getDefaultValue(), + }); + }, + }), + ); + usages = newUsages; + + this._variableUsages.set(node, usages); + } + + return usages; + } + + getRecursiveVariableUsages(operation) { + let usages = this._recursiveVariableUsages.get(operation); + + if (!usages) { + usages = this.getVariableUsages(operation); + + for (const frag of this.getRecursivelyReferencedFragments(operation)) { + usages = usages.concat(this.getVariableUsages(frag)); + } + + this._recursiveVariableUsages.set(operation, usages); + } + + return usages; + } + + getType() { + return this._typeInfo.getType(); + } + + getParentType() { + return this._typeInfo.getParentType(); + } + + getInputType() { + return this._typeInfo.getInputType(); + } + + getParentInputType() { + return this._typeInfo.getParentInputType(); + } + + getFieldDef() { + return this._typeInfo.getFieldDef(); + } + + getDirective() { + return this._typeInfo.getDirective(); + } + + getArgument() { + return this._typeInfo.getArgument(); + } + + getEnumValue() { + return this._typeInfo.getEnumValue(); + } +} + + +/***/ }), + +/***/ 8081: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "i": () => (/* binding */ ExecutableDefinitionsRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7359); +/* harmony import */ var _language_predicates_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5844); + + + + +/** + * Executable definitions + * + * A GraphQL document is only valid for execution if all definitions are either + * operation or fragment definitions. + * + * See https://spec.graphql.org/draft/#sec-Executable-Definitions + */ +function ExecutableDefinitionsRule(context) { + return { + Document(node) { + for (const definition of node.definitions) { + if (!(0,_language_predicates_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isExecutableDefinitionNode */ .Wk)(definition)) { + const defName = + definition.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCHEMA_DEFINITION */ .h.SCHEMA_DEFINITION || + definition.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCHEMA_EXTENSION */ .h.SCHEMA_EXTENSION + ? 'schema' + : '"' + definition.name.value + '"'; + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__(`The ${defName} definition is not executable.`, { + nodes: definition, + }), + ); + } + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 8741: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "A": () => (/* binding */ FieldsOnCorrectTypeRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3177); +/* harmony import */ var _jsutils_naturalCompare_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8224); +/* harmony import */ var _jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3294); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(398); + + + + + + +/** + * Fields on correct type + * + * A GraphQL document is only valid if all fields selected are defined by the + * parent type, or are an allowed meta field such as __typename. + * + * See https://spec.graphql.org/draft/#sec-Field-Selections + */ +function FieldsOnCorrectTypeRule(context) { + return { + Field(node) { + const type = context.getParentType(); + + if (type) { + const fieldDef = context.getFieldDef(); + + if (!fieldDef) { + // This field doesn't exist, lets look for suggestions. + const schema = context.getSchema(); + const fieldName = node.name.value; // First determine if there are any suggested types to condition on. + + let suggestion = (0,_jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_0__/* .didYouMean */ .l)( + 'to use an inline fragment on', + getSuggestedTypeNames(schema, type, fieldName), + ); // If there are no suggested types, then perhaps this was a typo? + + if (suggestion === '') { + suggestion = (0,_jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_0__/* .didYouMean */ .l)(getSuggestedFieldNames(type, fieldName)); + } // Report an error, including helpful suggestions. + + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Cannot query field "${fieldName}" on type "${type.name}".` + + suggestion, + { + nodes: node, + }, + ), + ); + } + } + }, + }; +} +/** + * Go through all of the implementations of type, as well as the interfaces that + * they implement. If any of those types include the provided field, suggest them, + * sorted by how often the type is referenced. + */ + +function getSuggestedTypeNames(schema, type, fieldName) { + if (!(0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isAbstractType */ .m0)(type)) { + // Must be an Object type, which does not have possible fields. + return []; + } + + const suggestedTypes = new Set(); + const usageCount = Object.create(null); + + for (const possibleType of schema.getPossibleTypes(type)) { + if (!possibleType.getFields()[fieldName]) { + continue; + } // This object type defines this field. + + suggestedTypes.add(possibleType); + usageCount[possibleType.name] = 1; + + for (const possibleInterface of possibleType.getInterfaces()) { + var _usageCount$possibleI; + + if (!possibleInterface.getFields()[fieldName]) { + continue; + } // This interface type defines this field. + + suggestedTypes.add(possibleInterface); + usageCount[possibleInterface.name] = + ((_usageCount$possibleI = usageCount[possibleInterface.name]) !== + null && _usageCount$possibleI !== void 0 + ? _usageCount$possibleI + : 0) + 1; + } + } + + return [...suggestedTypes] + .sort((typeA, typeB) => { + // Suggest both interface and object types based on how common they are. + const usageCountDiff = usageCount[typeB.name] - usageCount[typeA.name]; + + if (usageCountDiff !== 0) { + return usageCountDiff; + } // Suggest super types first followed by subtypes + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInterfaceType */ .oT)(typeA) && schema.isSubType(typeA, typeB)) { + return -1; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInterfaceType */ .oT)(typeB) && schema.isSubType(typeB, typeA)) { + return 1; + } + + return (0,_jsutils_naturalCompare_mjs__WEBPACK_IMPORTED_MODULE_3__/* .naturalCompare */ .K)(typeA.name, typeB.name); + }) + .map((x) => x.name); +} +/** + * For the field name provided, determine if there are any similar field names + * that may be the result of a typo. + */ + +function getSuggestedFieldNames(type, fieldName) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isObjectType */ .lp)(type) || (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isInterfaceType */ .oT)(type)) { + const possibleFieldNames = Object.keys(type.getFields()); + return (0,_jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_4__/* .suggestionList */ .D)(fieldName, possibleFieldNames); + } // Otherwise, must be a Union type, which does not define fields. + + return []; +} + + +/***/ }), + +/***/ 7143: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "T": () => (/* binding */ FragmentsOnCompositeTypesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8087); +/* harmony import */ var _language_printer_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3486); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(398); +/* harmony import */ var _utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77); + + + + + +/** + * Fragments on composite type + * + * Fragments use a type condition to determine if they apply, since fragments + * can only be spread into a composite type (object, interface, or union), the + * type condition must also be a composite type. + * + * See https://spec.graphql.org/draft/#sec-Fragments-On-Composite-Types + */ +function FragmentsOnCompositeTypesRule(context) { + return { + InlineFragment(node) { + const typeCondition = node.typeCondition; + + if (typeCondition) { + const type = (0,_utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_0__/* .typeFromAST */ ._)(context.getSchema(), typeCondition); + + if (type && !(0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isCompositeType */ .Gv)(type)) { + const typeStr = (0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_2__/* .print */ .S)(typeCondition); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Fragment cannot condition on non composite type "${typeStr}".`, + { + nodes: typeCondition, + }, + ), + ); + } + } + }, + + FragmentDefinition(node) { + const type = (0,_utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_0__/* .typeFromAST */ ._)(context.getSchema(), node.typeCondition); + + if (type && !(0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isCompositeType */ .Gv)(type)) { + const typeStr = (0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_2__/* .print */ .S)(node.typeCondition); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Fragment "${node.name.value}" cannot condition on non composite type "${typeStr}".`, + { + nodes: node.typeCondition, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 7815: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "e": () => (/* binding */ KnownArgumentNamesRule), +/* harmony export */ "o": () => (/* binding */ KnownArgumentNamesOnDirectivesRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3177); +/* harmony import */ var _jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3294); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7359); +/* harmony import */ var _type_directives_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8238); + + + + + + +/** + * Known argument names + * + * A GraphQL field is only valid if all supplied arguments are defined by + * that field. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + * See https://spec.graphql.org/draft/#sec-Directives-Are-In-Valid-Locations + */ +function KnownArgumentNamesRule(context) { + return { + // eslint-disable-next-line new-cap + ...KnownArgumentNamesOnDirectivesRule(context), + + Argument(argNode) { + const argDef = context.getArgument(); + const fieldDef = context.getFieldDef(); + const parentType = context.getParentType(); + + if (!argDef && fieldDef && parentType) { + const argName = argNode.name.value; + const knownArgsNames = fieldDef.args.map((arg) => arg.name); + const suggestions = (0,_jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_0__/* .suggestionList */ .D)(argName, knownArgsNames); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Unknown argument "${argName}" on field "${parentType.name}.${fieldDef.name}".` + + (0,_jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_2__/* .didYouMean */ .l)(suggestions), + { + nodes: argNode, + }, + ), + ); + } + }, + }; +} +/** + * @internal + */ + +function KnownArgumentNamesOnDirectivesRule(context) { + const directiveArgs = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _type_directives_mjs__WEBPACK_IMPORTED_MODULE_3__/* .specifiedDirectives */ .V4; + + for (const directive of definedDirectives) { + directiveArgs[directive.name] = directive.args.map((arg) => arg.name); + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.DIRECTIVE_DEFINITION */ .h.DIRECTIVE_DEFINITION) { + var _def$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argsNodes = + (_def$arguments = def.arguments) !== null && _def$arguments !== void 0 + ? _def$arguments + : []; + directiveArgs[def.name.value] = argsNodes.map((arg) => arg.name.value); + } + } + + return { + Directive(directiveNode) { + const directiveName = directiveNode.name.value; + const knownArgs = directiveArgs[directiveName]; + + if (directiveNode.arguments && knownArgs) { + for (const argNode of directiveNode.arguments) { + const argName = argNode.name.value; + + if (!knownArgs.includes(argName)) { + const suggestions = (0,_jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_0__/* .suggestionList */ .D)(argName, knownArgs); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Unknown argument "${argName}" on directive "@${directiveName}".` + + (0,_jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_2__/* .didYouMean */ .l)(suggestions), + { + nodes: argNode, + }, + ), + ); + } + } + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 4873: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "J": () => (/* binding */ KnownDirectivesRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9551); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8087); +/* harmony import */ var _language_ast_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(2380); +/* harmony import */ var _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(9878); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7359); +/* harmony import */ var _type_directives_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8238); + + + + + + + + +/** + * Known directives + * + * A GraphQL document is only valid if all `@directives` are known by the + * schema and legally positioned. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Defined + */ +function KnownDirectivesRule(context) { + const locationsMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _type_directives_mjs__WEBPACK_IMPORTED_MODULE_0__/* .specifiedDirectives */ .V4; + + for (const directive of definedDirectives) { + locationsMap[directive.name] = directive.locations; + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.DIRECTIVE_DEFINITION */ .h.DIRECTIVE_DEFINITION) { + locationsMap[def.name.value] = def.locations.map((name) => name.value); + } + } + + return { + Directive(node, _key, _parent, _path, ancestors) { + const name = node.name.value; + const locations = locationsMap[name]; + + if (!locations) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__(`Unknown directive "@${name}".`, { + nodes: node, + }), + ); + return; + } + + const candidateLocation = getDirectiveLocationForASTPath(ancestors); + + if (candidateLocation && !locations.includes(candidateLocation)) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__( + `Directive "@${name}" may not be used on ${candidateLocation}.`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +function getDirectiveLocationForASTPath(ancestors) { + const appliedTo = ancestors[ancestors.length - 1]; + 'kind' in appliedTo || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_3__/* .invariant */ .k)(false); + + switch (appliedTo.kind) { + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.OPERATION_DEFINITION */ .h.OPERATION_DEFINITION: + return getDirectiveLocationForOperation(appliedTo.operation); + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.FIELD */ .h.FIELD: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.FIELD */ .B.FIELD; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.FRAGMENT_SPREAD */ .h.FRAGMENT_SPREAD: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.FRAGMENT_SPREAD */ .B.FRAGMENT_SPREAD; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INLINE_FRAGMENT */ .h.INLINE_FRAGMENT: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.INLINE_FRAGMENT */ .B.INLINE_FRAGMENT; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.FRAGMENT_DEFINITION */ .h.FRAGMENT_DEFINITION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.FRAGMENT_DEFINITION */ .B.FRAGMENT_DEFINITION; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.VARIABLE_DEFINITION */ .h.VARIABLE_DEFINITION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.VARIABLE_DEFINITION */ .B.VARIABLE_DEFINITION; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCHEMA_DEFINITION */ .h.SCHEMA_DEFINITION: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCHEMA_EXTENSION */ .h.SCHEMA_EXTENSION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.SCHEMA */ .B.SCHEMA; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCALAR_TYPE_DEFINITION */ .h.SCALAR_TYPE_DEFINITION: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCALAR_TYPE_EXTENSION */ .h.SCALAR_TYPE_EXTENSION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.SCALAR */ .B.SCALAR; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.OBJECT_TYPE_DEFINITION */ .h.OBJECT_TYPE_DEFINITION: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.OBJECT_TYPE_EXTENSION */ .h.OBJECT_TYPE_EXTENSION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.OBJECT */ .B.OBJECT; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.FIELD_DEFINITION */ .h.FIELD_DEFINITION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.FIELD_DEFINITION */ .B.FIELD_DEFINITION; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INTERFACE_TYPE_DEFINITION */ .h.INTERFACE_TYPE_DEFINITION: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INTERFACE_TYPE_EXTENSION */ .h.INTERFACE_TYPE_EXTENSION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.INTERFACE */ .B.INTERFACE; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.UNION_TYPE_DEFINITION */ .h.UNION_TYPE_DEFINITION: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.UNION_TYPE_EXTENSION */ .h.UNION_TYPE_EXTENSION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.UNION */ .B.UNION; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.ENUM_TYPE_DEFINITION */ .h.ENUM_TYPE_DEFINITION: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.ENUM_TYPE_EXTENSION */ .h.ENUM_TYPE_EXTENSION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.ENUM */ .B.ENUM; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.ENUM_VALUE_DEFINITION */ .h.ENUM_VALUE_DEFINITION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.ENUM_VALUE */ .B.ENUM_VALUE; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INPUT_OBJECT_TYPE_DEFINITION */ .h.INPUT_OBJECT_TYPE_DEFINITION: + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INPUT_OBJECT_TYPE_EXTENSION */ .h.INPUT_OBJECT_TYPE_EXTENSION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.INPUT_OBJECT */ .B.INPUT_OBJECT; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INPUT_VALUE_DEFINITION */ .h.INPUT_VALUE_DEFINITION: { + const parentNode = ancestors[ancestors.length - 3]; + 'kind' in parentNode || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_3__/* .invariant */ .k)(false); + return parentNode.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.INPUT_OBJECT_TYPE_DEFINITION */ .h.INPUT_OBJECT_TYPE_DEFINITION + ? _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.INPUT_FIELD_DEFINITION */ .B.INPUT_FIELD_DEFINITION + : _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.ARGUMENT_DEFINITION */ .B.ARGUMENT_DEFINITION; + } + // Not reachable, all possible types have been considered. + + /* c8 ignore next */ + + default: + false || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_3__/* .invariant */ .k)(false, 'Unexpected kind: ' + (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_5__/* .inspect */ .X)(appliedTo.kind)); + } +} + +function getDirectiveLocationForOperation(operation) { + switch (operation) { + case _language_ast_mjs__WEBPACK_IMPORTED_MODULE_6__/* .OperationTypeNode.QUERY */ .ku.QUERY: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.QUERY */ .B.QUERY; + + case _language_ast_mjs__WEBPACK_IMPORTED_MODULE_6__/* .OperationTypeNode.MUTATION */ .ku.MUTATION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.MUTATION */ .B.MUTATION; + + case _language_ast_mjs__WEBPACK_IMPORTED_MODULE_6__/* .OperationTypeNode.SUBSCRIPTION */ .ku.SUBSCRIPTION: + return _language_directiveLocation_mjs__WEBPACK_IMPORTED_MODULE_4__/* .DirectiveLocation.SUBSCRIPTION */ .B.SUBSCRIPTION; + } +} + + +/***/ }), + +/***/ 5311: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "a": () => (/* binding */ KnownFragmentNamesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * Known fragment names + * + * A GraphQL document is only valid if all `...Fragment` fragment spreads refer + * to fragments defined in the same document. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spread-target-defined + */ +function KnownFragmentNamesRule(context) { + return { + FragmentSpread(node) { + const fragmentName = node.name.value; + const fragment = context.getFragment(fragmentName); + + if (!fragment) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__(`Unknown fragment "${fragmentName}".`, { + nodes: node.name, + }), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 5580: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "I": () => (/* binding */ KnownTypeNamesRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3177); +/* harmony import */ var _jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3294); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8087); +/* harmony import */ var _language_predicates_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5844); +/* harmony import */ var _type_introspection_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(2433); +/* harmony import */ var _type_scalars_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3801); + + + + + + + +/** + * Known type names + * + * A GraphQL document is only valid if referenced types (specifically + * variable definitions and fragment conditions) are defined by the type schema. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Spread-Type-Existence + */ +function KnownTypeNamesRule(context) { + const schema = context.getSchema(); + const existingTypesMap = schema ? schema.getTypeMap() : Object.create(null); + const definedTypes = Object.create(null); + + for (const def of context.getDocument().definitions) { + if ((0,_language_predicates_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isTypeDefinitionNode */ .zT)(def)) { + definedTypes[def.name.value] = true; + } + } + + const typeNames = [ + ...Object.keys(existingTypesMap), + ...Object.keys(definedTypes), + ]; + return { + NamedType(node, _1, parent, _2, ancestors) { + const typeName = node.name.value; + + if (!existingTypesMap[typeName] && !definedTypes[typeName]) { + var _ancestors$; + + const definitionNode = + (_ancestors$ = ancestors[2]) !== null && _ancestors$ !== void 0 + ? _ancestors$ + : parent; + const isSDL = definitionNode != null && isSDLNode(definitionNode); + + if (isSDL && standardTypeNames.includes(typeName)) { + return; + } + + const suggestedTypes = (0,_jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_1__/* .suggestionList */ .D)( + typeName, + isSDL ? standardTypeNames.concat(typeNames) : typeNames, + ); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__( + `Unknown type "${typeName}".` + (0,_jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_3__/* .didYouMean */ .l)(suggestedTypes), + { + nodes: node, + }, + ), + ); + } + }, + }; +} +const standardTypeNames = [..._type_scalars_mjs__WEBPACK_IMPORTED_MODULE_4__/* .specifiedScalarTypes */ .HS, ..._type_introspection_mjs__WEBPACK_IMPORTED_MODULE_5__/* .introspectionTypes */ .nL].map( + (type) => type.name, +); + +function isSDLNode(value) { + return ( + 'kind' in value && + ((0,_language_predicates_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isTypeSystemDefinitionNode */ .G4)(value) || (0,_language_predicates_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isTypeSystemExtensionNode */ .aU)(value)) + ); +} + + +/***/ }), + +/***/ 7898: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "F": () => (/* binding */ LoneAnonymousOperationRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7359); + + + +/** + * Lone anonymous operation + * + * A GraphQL document is only valid if when it contains an anonymous operation + * (the query short-hand) that it contains only that one operation definition. + * + * See https://spec.graphql.org/draft/#sec-Lone-Anonymous-Operation + */ +function LoneAnonymousOperationRule(context) { + let operationCount = 0; + return { + Document(node) { + operationCount = node.definitions.filter( + (definition) => definition.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.OPERATION_DEFINITION */ .h.OPERATION_DEFINITION, + ).length; + }, + + OperationDefinition(node) { + if (!node.name && operationCount > 1) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + 'This anonymous operation must be the only defined operation.', + { + nodes: node, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 2877: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "t": () => (/* binding */ LoneSchemaDefinitionRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * Lone Schema definition + * + * A GraphQL document is only valid if it contains only one schema definition. + */ +function LoneSchemaDefinitionRule(context) { + var _ref, _ref2, _oldSchema$astNode; + + const oldSchema = context.getSchema(); + const alreadyDefined = + (_ref = + (_ref2 = + (_oldSchema$astNode = + oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.astNode) !== null && _oldSchema$astNode !== void 0 + ? _oldSchema$astNode + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getQueryType()) !== null && _ref2 !== void 0 + ? _ref2 + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getMutationType()) !== null && _ref !== void 0 + ? _ref + : oldSchema === null || oldSchema === void 0 + ? void 0 + : oldSchema.getSubscriptionType(); + let schemaDefinitionsCount = 0; + return { + SchemaDefinition(node) { + if (alreadyDefined) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + 'Cannot define a new schema within a schema extension.', + { + nodes: node, + }, + ), + ); + return; + } + + if (schemaDefinitionsCount > 0) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__('Must provide only one schema definition.', { + nodes: node, + }), + ); + } + + ++schemaDefinitionsCount; + }, + }; +} + + +/***/ }), + +/***/ 1422: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "H": () => (/* binding */ NoFragmentCyclesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * No fragment cycles + * + * The graph of fragment spreads must not form any cycles including spreading itself. + * Otherwise an operation could infinitely spread or infinitely execute on cycles in the underlying data. + * + * See https://spec.graphql.org/draft/#sec-Fragment-spreads-must-not-form-cycles + */ +function NoFragmentCyclesRule(context) { + // Tracks already visited fragments to maintain O(N) and to ensure that cycles + // are not redundantly reported. + const visitedFrags = Object.create(null); // Array of AST nodes used to produce meaningful errors + + const spreadPath = []; // Position in the spread path + + const spreadPathIndexByName = Object.create(null); + return { + OperationDefinition: () => false, + + FragmentDefinition(node) { + detectCycleRecursive(node); + return false; + }, + }; // This does a straight-forward DFS to find cycles. + // It does not terminate when a cycle was found but continues to explore + // the graph to find all possible cycles. + + function detectCycleRecursive(fragment) { + if (visitedFrags[fragment.name.value]) { + return; + } + + const fragmentName = fragment.name.value; + visitedFrags[fragmentName] = true; + const spreadNodes = context.getFragmentSpreads(fragment.selectionSet); + + if (spreadNodes.length === 0) { + return; + } + + spreadPathIndexByName[fragmentName] = spreadPath.length; + + for (const spreadNode of spreadNodes) { + const spreadName = spreadNode.name.value; + const cycleIndex = spreadPathIndexByName[spreadName]; + spreadPath.push(spreadNode); + + if (cycleIndex === undefined) { + const spreadFragment = context.getFragment(spreadName); + + if (spreadFragment) { + detectCycleRecursive(spreadFragment); + } + } else { + const cyclePath = spreadPath.slice(cycleIndex); + const viaPath = cyclePath + .slice(0, -1) + .map((s) => '"' + s.name.value + '"') + .join(', '); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Cannot spread fragment "${spreadName}" within itself` + + (viaPath !== '' ? ` via ${viaPath}.` : '.'), + { + nodes: cyclePath, + }, + ), + ); + } + + spreadPath.pop(); + } + + spreadPathIndexByName[fragmentName] = undefined; + } +} + + +/***/ }), + +/***/ 4790: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "$": () => (/* binding */ NoUndefinedVariablesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * No undefined variables + * + * A GraphQL operation is only valid if all variables encountered, both directly + * and via fragment spreads, are defined by that operation. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Uses-Defined + */ +function NoUndefinedVariablesRule(context) { + let variableNameDefined = Object.create(null); + return { + OperationDefinition: { + enter() { + variableNameDefined = Object.create(null); + }, + + leave(operation) { + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node } of usages) { + const varName = node.name.value; + + if (variableNameDefined[varName] !== true) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + operation.name + ? `Variable "$${varName}" is not defined by operation "${operation.name.value}".` + : `Variable "$${varName}" is not defined.`, + { + nodes: [node, operation], + }, + ), + ); + } + } + }, + }, + + VariableDefinition(node) { + variableNameDefined[node.variable.name.value] = true; + }, + }; +} + + +/***/ }), + +/***/ 1294: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "J": () => (/* binding */ NoUnusedFragmentsRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * No unused fragments + * + * A GraphQL document is only valid if all fragment definitions are spread + * within operations, or spread within other fragments spread within operations. + * + * See https://spec.graphql.org/draft/#sec-Fragments-Must-Be-Used + */ +function NoUnusedFragmentsRule(context) { + const operationDefs = []; + const fragmentDefs = []; + return { + OperationDefinition(node) { + operationDefs.push(node); + return false; + }, + + FragmentDefinition(node) { + fragmentDefs.push(node); + return false; + }, + + Document: { + leave() { + const fragmentNameUsed = Object.create(null); + + for (const operation of operationDefs) { + for (const fragment of context.getRecursivelyReferencedFragments( + operation, + )) { + fragmentNameUsed[fragment.name.value] = true; + } + } + + for (const fragmentDef of fragmentDefs) { + const fragName = fragmentDef.name.value; + + if (fragmentNameUsed[fragName] !== true) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__(`Fragment "${fragName}" is never used.`, { + nodes: fragmentDef, + }), + ); + } + } + }, + }, + }; +} + + +/***/ }), + +/***/ 2283: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "p": () => (/* binding */ NoUnusedVariablesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * No unused variables + * + * A GraphQL operation is only valid if all variables defined by an operation + * are used, either directly or within a spread fragment. + * + * See https://spec.graphql.org/draft/#sec-All-Variables-Used + */ +function NoUnusedVariablesRule(context) { + let variableDefs = []; + return { + OperationDefinition: { + enter() { + variableDefs = []; + }, + + leave(operation) { + const variableNameUsed = Object.create(null); + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node } of usages) { + variableNameUsed[node.name.value] = true; + } + + for (const variableDef of variableDefs) { + const variableName = variableDef.variable.name.value; + + if (variableNameUsed[variableName] !== true) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + operation.name + ? `Variable "$${variableName}" is never used in operation "${operation.name.value}".` + : `Variable "$${variableName}" is never used.`, + { + nodes: variableDef, + }, + ), + ); + } + } + }, + }, + + VariableDefinition(def) { + variableDefs.push(def); + }, + }; +} + + +/***/ }), + +/***/ 4203: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "y": () => (/* binding */ OverlappingFieldsCanBeMergedRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5821); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(7359); +/* harmony import */ var _language_printer_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3486); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(398); +/* harmony import */ var _utilities_sortValueNode_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8360); +/* harmony import */ var _utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(77); + + + + + + + + +function reasonMessage(reason) { + if (Array.isArray(reason)) { + return reason + .map( + ([responseName, subReason]) => + `subfields "${responseName}" conflict because ` + + reasonMessage(subReason), + ) + .join(' and '); + } + + return reason; +} +/** + * Overlapping fields can be merged + * + * A selection set is only valid if all fields (including spreading any + * fragments) either correspond to distinct response names or can be merged + * without ambiguity. + * + * See https://spec.graphql.org/draft/#sec-Field-Selection-Merging + */ + +function OverlappingFieldsCanBeMergedRule(context) { + // A memoization for when two fragments are compared "between" each other for + // conflicts. Two fragments may be compared many times, so memoizing this can + // dramatically improve the performance of this validator. + const comparedFragmentPairs = new PairSet(); // A cache for the "field map" and list of fragment names found in any given + // selection set. Selection sets may be asked for this information multiple + // times, so this improves the performance of this validator. + + const cachedFieldsAndFragmentNames = new Map(); + return { + SelectionSet(selectionSet) { + const conflicts = findConflictsWithinSelectionSet( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + context.getParentType(), + selectionSet, + ); + + for (const [[responseName, reason], fields1, fields2] of conflicts) { + const reasonMsg = reasonMessage(reason); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Fields "${responseName}" conflict because ${reasonMsg}. Use different aliases on the fields to fetch both if this was intentional.`, + { + nodes: fields1.concat(fields2), + }, + ), + ); + } + }, + }; +} + +/** + * Algorithm: + * + * Conflicts occur when two fields exist in a query which will produce the same + * response name, but represent differing values, thus creating a conflict. + * The algorithm below finds all conflicts via making a series of comparisons + * between fields. In order to compare as few fields as possible, this makes + * a series of comparisons "within" sets of fields and "between" sets of fields. + * + * Given any selection set, a collection produces both a set of fields by + * also including all inline fragments, as well as a list of fragments + * referenced by fragment spreads. + * + * A) Each selection set represented in the document first compares "within" its + * collected set of fields, finding any conflicts between every pair of + * overlapping fields. + * Note: This is the *only time* that a the fields "within" a set are compared + * to each other. After this only fields "between" sets are compared. + * + * B) Also, if any fragment is referenced in a selection set, then a + * comparison is made "between" the original set of fields and the + * referenced fragment. + * + * C) Also, if multiple fragments are referenced, then comparisons + * are made "between" each referenced fragment. + * + * D) When comparing "between" a set of fields and a referenced fragment, first + * a comparison is made between each field in the original set of fields and + * each field in the the referenced set of fields. + * + * E) Also, if any fragment is referenced in the referenced selection set, + * then a comparison is made "between" the original set of fields and the + * referenced fragment (recursively referring to step D). + * + * F) When comparing "between" two fragments, first a comparison is made between + * each field in the first referenced set of fields and each field in the the + * second referenced set of fields. + * + * G) Also, any fragments referenced by the first must be compared to the + * second, and any fragments referenced by the second must be compared to the + * first (recursively referring to step F). + * + * H) When comparing two fields, if both have selection sets, then a comparison + * is made "between" both selection sets, first comparing the set of fields in + * the first selection set with the set of fields in the second. + * + * I) Also, if any fragment is referenced in either selection set, then a + * comparison is made "between" the other set of fields and the + * referenced fragment. + * + * J) Also, if two fragments are referenced in both selection sets, then a + * comparison is made "between" the two fragments. + * + */ +// Find all conflicts found "within" a selection set, including those found +// via spreading in fragments. Called when visiting each SelectionSet in the +// GraphQL Document. +function findConflictsWithinSelectionSet( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentType, + selectionSet, +) { + const conflicts = []; + const [fieldMap, fragmentNames] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType, + selectionSet, + ); // (A) Find find all conflicts "within" the fields of this selection set. + // Note: this is the *only place* `collectConflictsWithin` is called. + + collectConflictsWithin( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + fieldMap, + ); + + if (fragmentNames.length !== 0) { + // (B) Then collect conflicts between these fields and those represented by + // each spread fragment name found. + for (let i = 0; i < fragmentNames.length; i++) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, + fieldMap, + fragmentNames[i], + ); // (C) Then compare this fragment with all other fragments found in this + // selection set to collect conflicts between fragments spread together. + // This compares each item in the list of fragment names to every other + // item in that same list (except for itself). + + for (let j = i + 1; j < fragmentNames.length; j++) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, + fragmentNames[i], + fragmentNames[j], + ); + } + } + } + + return conflicts; +} // Collect all conflicts found between a set of fields and a fragment reference +// including via spreading in any nested fragments. + +function collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + fragmentName, +) { + const fragment = context.getFragment(fragmentName); + + if (!fragment) { + return; + } + + const [fieldMap2, referencedFragmentNames] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment, + ); // Do not compare a fragment's fieldMap to itself. + + if (fieldMap === fieldMap2) { + return; + } // (D) First collect any conflicts between the provided collection of fields + // and the collection of fields represented by the given fragment. + + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + fieldMap2, + ); // (E) Then collect any conflicts between the provided collection of fields + // and any fragment names found in the given fragment. + + for (const referencedFragmentName of referencedFragmentNames) { + // Memoize so two fragments are not compared for conflicts more than once. + if ( + comparedFragmentPairs.has( + referencedFragmentName, + fragmentName, + areMutuallyExclusive, + ) + ) { + continue; + } + + comparedFragmentPairs.add( + referencedFragmentName, + fragmentName, + areMutuallyExclusive, + ); + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap, + referencedFragmentName, + ); + } +} // Collect all conflicts found between two fragments, including via spreading in +// any nested fragments. + +function collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + fragmentName2, +) { + // No need to compare a fragment to itself. + if (fragmentName1 === fragmentName2) { + return; + } // Memoize so two fragments are not compared for conflicts more than once. + + if ( + comparedFragmentPairs.has( + fragmentName1, + fragmentName2, + areMutuallyExclusive, + ) + ) { + return; + } + + comparedFragmentPairs.add(fragmentName1, fragmentName2, areMutuallyExclusive); + const fragment1 = context.getFragment(fragmentName1); + const fragment2 = context.getFragment(fragmentName2); + + if (!fragment1 || !fragment2) { + return; + } + + const [fieldMap1, referencedFragmentNames1] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment1, + ); + const [fieldMap2, referencedFragmentNames2] = + getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment2, + ); // (F) First, collect all conflicts between these two collections of fields + // (not including any nested fragments). + + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fieldMap2, + ); // (G) Then collect conflicts between the first fragment and any nested + // fragments spread in the second fragment. + + for (const referencedFragmentName2 of referencedFragmentNames2) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + referencedFragmentName2, + ); + } // (G) Then collect conflicts between the second fragment and any nested + // fragments spread in the first fragment. + + for (const referencedFragmentName1 of referencedFragmentNames1) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + referencedFragmentName1, + fragmentName2, + ); + } +} // Find all conflicts found between two selection sets, including those found +// via spreading in fragments. Called when determining if conflicts exist +// between the sub-fields of two overlapping fields. + +function findConflictsBetweenSubSelectionSets( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + parentType1, + selectionSet1, + parentType2, + selectionSet2, +) { + const conflicts = []; + const [fieldMap1, fragmentNames1] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType1, + selectionSet1, + ); + const [fieldMap2, fragmentNames2] = getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType2, + selectionSet2, + ); // (H) First, collect all conflicts between these two collections of field. + + collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fieldMap2, + ); // (I) Then collect conflicts between the first collection of fields and + // those referenced by each fragment name associated with the second. + + for (const fragmentName2 of fragmentNames2) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap1, + fragmentName2, + ); + } // (I) Then collect conflicts between the second collection of fields and + // those referenced by each fragment name associated with the first. + + for (const fragmentName1 of fragmentNames1) { + collectConflictsBetweenFieldsAndFragment( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fieldMap2, + fragmentName1, + ); + } // (J) Also collect conflicts between any fragment names by the first and + // fragment names by the second. This compares each item in the first set of + // names to each item in the second set of names. + + for (const fragmentName1 of fragmentNames1) { + for (const fragmentName2 of fragmentNames2) { + collectConflictsBetweenFragments( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + fragmentName1, + fragmentName2, + ); + } + } + + return conflicts; +} // Collect all Conflicts "within" one collection of fields. + +function collectConflictsWithin( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + fieldMap, +) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For every response name, if there are multiple fields, they + // must be compared to find a potential conflict. + for (const [responseName, fields] of Object.entries(fieldMap)) { + // This compares every field in the list to every other field in this list + // (except to itself). If the list only has one item, nothing needs to + // be compared. + if (fields.length > 1) { + for (let i = 0; i < fields.length; i++) { + for (let j = i + 1; j < fields.length; j++) { + const conflict = findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + false, // within one collection is never mutually exclusive + responseName, + fields[i], + fields[j], + ); + + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} // Collect all Conflicts between two collections of fields. This is similar to, +// but different from the `collectConflictsWithin` function above. This check +// assumes that `collectConflictsWithin` has already been called on each +// provided collection of fields. This is true because this validator traverses +// each individual selection set. + +function collectConflictsBetween( + context, + conflicts, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + fieldMap1, + fieldMap2, +) { + // A field map is a keyed collection, where each key represents a response + // name and the value at that key is a list of all fields which provide that + // response name. For any response name which appears in both provided field + // maps, each field from the first field map must be compared to every field + // in the second field map to find potential conflicts. + for (const [responseName, fields1] of Object.entries(fieldMap1)) { + const fields2 = fieldMap2[responseName]; + + if (fields2) { + for (const field1 of fields1) { + for (const field2 of fields2) { + const conflict = findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + responseName, + field1, + field2, + ); + + if (conflict) { + conflicts.push(conflict); + } + } + } + } + } +} // Determines if there is a conflict between two particular fields, including +// comparing their sub-fields. + +function findConflict( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + parentFieldsAreMutuallyExclusive, + responseName, + field1, + field2, +) { + const [parentType1, node1, def1] = field1; + const [parentType2, node2, def2] = field2; // If it is known that two fields could not possibly apply at the same + // time, due to the parent types, then it is safe to permit them to diverge + // in aliased field or arguments used as they will not present any ambiguity + // by differing. + // It is known that two parent types could never overlap if they are + // different Object types. Interface or Union types might overlap - if not + // in the current state of the schema, then perhaps in some future version, + // thus may not safely diverge. + + const areMutuallyExclusive = + parentFieldsAreMutuallyExclusive || + (parentType1 !== parentType2 && + (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isObjectType */ .lp)(parentType1) && + (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isObjectType */ .lp)(parentType2)); + + if (!areMutuallyExclusive) { + // Two aliases must refer to the same field. + const name1 = node1.name.value; + const name2 = node2.name.value; + + if (name1 !== name2) { + return [ + [responseName, `"${name1}" and "${name2}" are different fields`], + [node1], + [node2], + ]; + } // Two field calls must have the same arguments. + + if (stringifyArguments(node1) !== stringifyArguments(node2)) { + return [ + [responseName, 'they have differing arguments'], + [node1], + [node2], + ]; + } + } // The return type for each field. + + const type1 = def1 === null || def1 === void 0 ? void 0 : def1.type; + const type2 = def2 === null || def2 === void 0 ? void 0 : def2.type; + + if (type1 && type2 && doTypesConflict(type1, type2)) { + return [ + [ + responseName, + `they return conflicting types "${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(type1)}" and "${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)( + type2, + )}"`, + ], + [node1], + [node2], + ]; + } // Collect and compare sub-fields. Use the same "visited fragment names" list + // for both collections so fields in a fragment reference are never + // compared to themselves. + + const selectionSet1 = node1.selectionSet; + const selectionSet2 = node2.selectionSet; + + if (selectionSet1 && selectionSet2) { + const conflicts = findConflictsBetweenSubSelectionSets( + context, + cachedFieldsAndFragmentNames, + comparedFragmentPairs, + areMutuallyExclusive, + (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .getNamedType */ .xC)(type1), + selectionSet1, + (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .getNamedType */ .xC)(type2), + selectionSet2, + ); + return subfieldConflicts(conflicts, responseName, node1, node2); + } +} + +function stringifyArguments(fieldNode) { + var _fieldNode$arguments; + + // FIXME https://github.com/graphql/graphql-js/issues/2203 + const args = + /* c8 ignore next */ + (_fieldNode$arguments = fieldNode.arguments) !== null && + _fieldNode$arguments !== void 0 + ? _fieldNode$arguments + : []; + const inputObjectWithArgs = { + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.OBJECT */ .h.OBJECT, + fields: args.map((argNode) => ({ + kind: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.OBJECT_FIELD */ .h.OBJECT_FIELD, + name: argNode.name, + value: argNode.value, + })), + }; + return (0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_4__/* .print */ .S)((0,_utilities_sortValueNode_mjs__WEBPACK_IMPORTED_MODULE_5__/* .sortValueNode */ .n)(inputObjectWithArgs)); +} // Two types conflict if both types could not apply to a value simultaneously. +// Composite types are ignored as their individual field types will be compared +// later recursively. However List and Non-Null types must match. + +function doTypesConflict(type1, type2) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isListType */ .HG)(type1)) { + return (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isListType */ .HG)(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isListType */ .HG)(type2)) { + return true; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isNonNullType */ .zM)(type1)) { + return (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isNonNullType */ .zM)(type2) + ? doTypesConflict(type1.ofType, type2.ofType) + : true; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isNonNullType */ .zM)(type2)) { + return true; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isLeafType */ .UT)(type1) || (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isLeafType */ .UT)(type2)) { + return type1 !== type2; + } + + return false; +} // Given a selection set, return the collection of fields (a mapping of response +// name to field nodes and definitions) as well as a list of fragment names +// referenced via fragment spreads. + +function getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + parentType, + selectionSet, +) { + const cached = cachedFieldsAndFragmentNames.get(selectionSet); + + if (cached) { + return cached; + } + + const nodeAndDefs = Object.create(null); + const fragmentNames = Object.create(null); + + _collectFieldsAndFragmentNames( + context, + parentType, + selectionSet, + nodeAndDefs, + fragmentNames, + ); + + const result = [nodeAndDefs, Object.keys(fragmentNames)]; + cachedFieldsAndFragmentNames.set(selectionSet, result); + return result; +} // Given a reference to a fragment, return the represented collection of fields +// as well as a list of nested fragment names referenced via fragment spreads. + +function getReferencedFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragment, +) { + // Short-circuit building a type from the node if possible. + const cached = cachedFieldsAndFragmentNames.get(fragment.selectionSet); + + if (cached) { + return cached; + } + + const fragmentType = (0,_utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_6__/* .typeFromAST */ ._)(context.getSchema(), fragment.typeCondition); + return getFieldsAndFragmentNames( + context, + cachedFieldsAndFragmentNames, + fragmentType, + fragment.selectionSet, + ); +} + +function _collectFieldsAndFragmentNames( + context, + parentType, + selectionSet, + nodeAndDefs, + fragmentNames, +) { + for (const selection of selectionSet.selections) { + switch (selection.kind) { + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.FIELD */ .h.FIELD: { + const fieldName = selection.name.value; + let fieldDef; + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isObjectType */ .lp)(parentType) || (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isInterfaceType */ .oT)(parentType)) { + fieldDef = parentType.getFields()[fieldName]; + } + + const responseName = selection.alias + ? selection.alias.value + : fieldName; + + if (!nodeAndDefs[responseName]) { + nodeAndDefs[responseName] = []; + } + + nodeAndDefs[responseName].push([parentType, selection, fieldDef]); + break; + } + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.FRAGMENT_SPREAD */ .h.FRAGMENT_SPREAD: + fragmentNames[selection.name.value] = true; + break; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_3__/* .Kind.INLINE_FRAGMENT */ .h.INLINE_FRAGMENT: { + const typeCondition = selection.typeCondition; + const inlineFragmentType = typeCondition + ? (0,_utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_6__/* .typeFromAST */ ._)(context.getSchema(), typeCondition) + : parentType; + + _collectFieldsAndFragmentNames( + context, + inlineFragmentType, + selection.selectionSet, + nodeAndDefs, + fragmentNames, + ); + + break; + } + } + } +} // Given a series of Conflicts which occurred between two sub-fields, generate +// a single Conflict. + +function subfieldConflicts(conflicts, responseName, node1, node2) { + if (conflicts.length > 0) { + return [ + [responseName, conflicts.map(([reason]) => reason)], + [node1, ...conflicts.map(([, fields1]) => fields1).flat()], + [node2, ...conflicts.map(([, , fields2]) => fields2).flat()], + ]; + } +} +/** + * A way to keep track of pairs of things when the ordering of the pair does not matter. + */ + +class PairSet { + constructor() { + this._data = new Map(); + } + + has(a, b, areMutuallyExclusive) { + var _this$_data$get; + + const [key1, key2] = a < b ? [a, b] : [b, a]; + const result = + (_this$_data$get = this._data.get(key1)) === null || + _this$_data$get === void 0 + ? void 0 + : _this$_data$get.get(key2); + + if (result === undefined) { + return false; + } // areMutuallyExclusive being false is a superset of being true, hence if + // we want to know if this PairSet "has" these two with no exclusivity, + // we have to ensure it was added as such. + + return areMutuallyExclusive ? true : areMutuallyExclusive === result; + } + + add(a, b, areMutuallyExclusive) { + const [key1, key2] = a < b ? [a, b] : [b, a]; + + const map = this._data.get(key1); + + if (map === undefined) { + this._data.set(key1, new Map([[key2, areMutuallyExclusive]])); + } else { + map.set(key2, areMutuallyExclusive); + } + } +} + + +/***/ }), + +/***/ 3259: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "a": () => (/* binding */ PossibleFragmentSpreadsRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5821); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8087); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(398); +/* harmony import */ var _utilities_typeComparators_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(316); +/* harmony import */ var _utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(77); + + + + + + +/** + * Possible fragment spread + * + * A fragment spread is only valid if the type condition could ever possibly + * be true: if there is a non-empty intersection of the possible parent types, + * and possible types which pass the type condition. + */ +function PossibleFragmentSpreadsRule(context) { + return { + InlineFragment(node) { + const fragType = context.getType(); + const parentType = context.getParentType(); + + if ( + (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isCompositeType */ .Gv)(fragType) && + (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isCompositeType */ .Gv)(parentType) && + !(0,_utilities_typeComparators_mjs__WEBPACK_IMPORTED_MODULE_1__/* .doTypesOverlap */ .zR)(context.getSchema(), fragType, parentType) + ) { + const parentTypeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(parentType); + const fragTypeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(fragType); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Fragment cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, + { + nodes: node, + }, + ), + ); + } + }, + + FragmentSpread(node) { + const fragName = node.name.value; + const fragType = getFragmentType(context, fragName); + const parentType = context.getParentType(); + + if ( + fragType && + parentType && + !(0,_utilities_typeComparators_mjs__WEBPACK_IMPORTED_MODULE_1__/* .doTypesOverlap */ .zR)(context.getSchema(), fragType, parentType) + ) { + const parentTypeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(parentType); + const fragTypeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(fragType); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Fragment "${fragName}" cannot be spread here as objects of type "${parentTypeStr}" can never be of type "${fragTypeStr}".`, + { + nodes: node, + }, + ), + ); + } + }, + }; +} + +function getFragmentType(context, name) { + const frag = context.getFragment(name); + + if (frag) { + const type = (0,_utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_4__/* .typeFromAST */ ._)(context.getSchema(), frag.typeCondition); + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isCompositeType */ .Gv)(type)) { + return type; + } + } +} + + +/***/ }), + +/***/ 4800: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "g": () => (/* binding */ PossibleTypeExtensionsRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(3177); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(9551); +/* harmony import */ var _jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3294); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7359); +/* harmony import */ var _language_predicates_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5844); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(398); + + + + + + + + + +/** + * Possible type extension + * + * A type extension is only valid if the type is defined and has the same kind. + */ +function PossibleTypeExtensionsRule(context) { + const schema = context.getSchema(); + const definedTypes = Object.create(null); + + for (const def of context.getDocument().definitions) { + if ((0,_language_predicates_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isTypeDefinitionNode */ .zT)(def)) { + definedTypes[def.name.value] = def; + } + } + + return { + ScalarTypeExtension: checkExtension, + ObjectTypeExtension: checkExtension, + InterfaceTypeExtension: checkExtension, + UnionTypeExtension: checkExtension, + EnumTypeExtension: checkExtension, + InputObjectTypeExtension: checkExtension, + }; + + function checkExtension(node) { + const typeName = node.name.value; + const defNode = definedTypes[typeName]; + const existingType = + schema === null || schema === void 0 ? void 0 : schema.getType(typeName); + let expectedKind; + + if (defNode) { + expectedKind = defKindToExtKind[defNode.kind]; + } else if (existingType) { + expectedKind = typeToExtKind(existingType); + } + + if (expectedKind) { + if (expectedKind !== node.kind) { + const kindStr = extensionKindToTypeName(node.kind); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__(`Cannot extend non-${kindStr} type "${typeName}".`, { + nodes: defNode ? [defNode, node] : node, + }), + ); + } + } else { + const allTypeNames = Object.keys({ + ...definedTypes, + ...(schema === null || schema === void 0 + ? void 0 + : schema.getTypeMap()), + }); + const suggestedTypes = (0,_jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_2__/* .suggestionList */ .D)(typeName, allTypeNames); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Cannot extend type "${typeName}" because it is not defined.` + + (0,_jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_3__/* .didYouMean */ .l)(suggestedTypes), + { + nodes: node.name, + }, + ), + ); + } + } +} +const defKindToExtKind = { + [_language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.SCALAR_TYPE_DEFINITION */ .h.SCALAR_TYPE_DEFINITION]: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.SCALAR_TYPE_EXTENSION */ .h.SCALAR_TYPE_EXTENSION, + [_language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.OBJECT_TYPE_DEFINITION */ .h.OBJECT_TYPE_DEFINITION]: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.OBJECT_TYPE_EXTENSION */ .h.OBJECT_TYPE_EXTENSION, + [_language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.INTERFACE_TYPE_DEFINITION */ .h.INTERFACE_TYPE_DEFINITION]: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.INTERFACE_TYPE_EXTENSION */ .h.INTERFACE_TYPE_EXTENSION, + [_language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.UNION_TYPE_DEFINITION */ .h.UNION_TYPE_DEFINITION]: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.UNION_TYPE_EXTENSION */ .h.UNION_TYPE_EXTENSION, + [_language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.ENUM_TYPE_DEFINITION */ .h.ENUM_TYPE_DEFINITION]: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.ENUM_TYPE_EXTENSION */ .h.ENUM_TYPE_EXTENSION, + [_language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.INPUT_OBJECT_TYPE_DEFINITION */ .h.INPUT_OBJECT_TYPE_DEFINITION]: _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.INPUT_OBJECT_TYPE_EXTENSION */ .h.INPUT_OBJECT_TYPE_EXTENSION, +}; + +function typeToExtKind(type) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isScalarType */ .KA)(type)) { + return _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.SCALAR_TYPE_EXTENSION */ .h.SCALAR_TYPE_EXTENSION; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isObjectType */ .lp)(type)) { + return _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.OBJECT_TYPE_EXTENSION */ .h.OBJECT_TYPE_EXTENSION; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isInterfaceType */ .oT)(type)) { + return _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.INTERFACE_TYPE_EXTENSION */ .h.INTERFACE_TYPE_EXTENSION; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isUnionType */ .EN)(type)) { + return _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.UNION_TYPE_EXTENSION */ .h.UNION_TYPE_EXTENSION; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isEnumType */ .EM)(type)) { + return _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.ENUM_TYPE_EXTENSION */ .h.ENUM_TYPE_EXTENSION; + } + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isInputObjectType */ .hL)(type)) { + return _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.INPUT_OBJECT_TYPE_EXTENSION */ .h.INPUT_OBJECT_TYPE_EXTENSION; + } + /* c8 ignore next 3 */ + // Not reachable. All possible types have been considered + + false || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_6__/* .invariant */ .k)(false, 'Unexpected type: ' + (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_7__/* .inspect */ .X)(type)); +} + +function extensionKindToTypeName(kind) { + switch (kind) { + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.SCALAR_TYPE_EXTENSION */ .h.SCALAR_TYPE_EXTENSION: + return 'scalar'; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.OBJECT_TYPE_EXTENSION */ .h.OBJECT_TYPE_EXTENSION: + return 'object'; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.INTERFACE_TYPE_EXTENSION */ .h.INTERFACE_TYPE_EXTENSION: + return 'interface'; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.UNION_TYPE_EXTENSION */ .h.UNION_TYPE_EXTENSION: + return 'union'; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.ENUM_TYPE_EXTENSION */ .h.ENUM_TYPE_EXTENSION: + return 'enum'; + + case _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.INPUT_OBJECT_TYPE_EXTENSION */ .h.INPUT_OBJECT_TYPE_EXTENSION: + return 'input object'; + // Not reachable. All possible types have been considered + + /* c8 ignore next */ + + default: + false || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_6__/* .invariant */ .k)(false, 'Unexpected kind: ' + (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_7__/* .inspect */ .X)(kind)); + } +} + + +/***/ }), + +/***/ 1967: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "c": () => (/* binding */ ProvidedRequiredArgumentsOnDirectivesRule), +/* harmony export */ "s": () => (/* binding */ ProvidedRequiredArgumentsRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3498); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7359); +/* harmony import */ var _language_printer_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3486); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(398); +/* harmony import */ var _type_directives_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8238); + + + + + + + + +/** + * Provided required arguments + * + * A field or directive is only valid if all required (non-null without a + * default value) field arguments have been provided. + */ +function ProvidedRequiredArgumentsRule(context) { + return { + // eslint-disable-next-line new-cap + ...ProvidedRequiredArgumentsOnDirectivesRule(context), + Field: { + // Validate on leave to allow for deeper errors to appear first. + leave(fieldNode) { + var _fieldNode$arguments; + + const fieldDef = context.getFieldDef(); + + if (!fieldDef) { + return false; + } + + const providedArgs = new Set( // FIXME: https://github.com/graphql/graphql-js/issues/2203 + /* c8 ignore next */ + (_fieldNode$arguments = fieldNode.arguments) === null || + _fieldNode$arguments === void 0 + ? void 0 + : _fieldNode$arguments.map((arg) => arg.name.value), + ); + + for (const argDef of fieldDef.args) { + if (!providedArgs.has(argDef.name) && (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isRequiredArgument */ .dK)(argDef)) { + const argTypeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(argDef.type); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__( + `Field "${fieldDef.name}" argument "${argDef.name}" of type "${argTypeStr}" is required, but it was not provided.`, + { + nodes: fieldNode, + }, + ), + ); + } + } + }, + }, + }; +} +/** + * @internal + */ + +function ProvidedRequiredArgumentsOnDirectivesRule(context) { + var _schema$getDirectives; + + const requiredArgsMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = + (_schema$getDirectives = + schema === null || schema === void 0 + ? void 0 + : schema.getDirectives()) !== null && _schema$getDirectives !== void 0 + ? _schema$getDirectives + : _type_directives_mjs__WEBPACK_IMPORTED_MODULE_3__/* .specifiedDirectives */ .V4; + + for (const directive of definedDirectives) { + requiredArgsMap[directive.name] = (0,_jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_4__/* .keyMap */ .P)( + directive.args.filter(_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isRequiredArgument */ .dK), + (arg) => arg.name, + ); + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_5__/* .Kind.DIRECTIVE_DEFINITION */ .h.DIRECTIVE_DEFINITION) { + var _def$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argNodes = + (_def$arguments = def.arguments) !== null && _def$arguments !== void 0 + ? _def$arguments + : []; + requiredArgsMap[def.name.value] = (0,_jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_4__/* .keyMap */ .P)( + argNodes.filter(isRequiredArgumentNode), + (arg) => arg.name.value, + ); + } + } + + return { + Directive: { + // Validate on leave to allow for deeper errors to appear first. + leave(directiveNode) { + const directiveName = directiveNode.name.value; + const requiredArgs = requiredArgsMap[directiveName]; + + if (requiredArgs) { + var _directiveNode$argume; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argNodes = + (_directiveNode$argume = directiveNode.arguments) !== null && + _directiveNode$argume !== void 0 + ? _directiveNode$argume + : []; + const argNodeMap = new Set(argNodes.map((arg) => arg.name.value)); + + for (const [argName, argDef] of Object.entries(requiredArgs)) { + if (!argNodeMap.has(argName)) { + const argType = (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isType */ .P9)(argDef.type) + ? (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(argDef.type) + : (0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_6__/* .print */ .S)(argDef.type); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__( + `Directive "@${directiveName}" argument "${argName}" of type "${argType}" is required, but it was not provided.`, + { + nodes: directiveNode, + }, + ), + ); + } + } + } + }, + }, + }; +} + +function isRequiredArgumentNode(arg) { + return arg.type.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_5__/* .Kind.NON_NULL_TYPE */ .h.NON_NULL_TYPE && arg.defaultValue == null; +} + + +/***/ }), + +/***/ 1954: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "O": () => (/* binding */ ScalarLeafsRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5821); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8087); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(398); + + + + +/** + * Scalar leafs + * + * A GraphQL document is valid only if all leaf fields (fields without + * sub selections) are of scalar or enum types. + */ +function ScalarLeafsRule(context) { + return { + Field(node) { + const type = context.getType(); + const selectionSet = node.selectionSet; + + if (type) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isLeafType */ .UT)((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getNamedType */ .xC)(type))) { + if (selectionSet) { + const fieldName = node.name.value; + const typeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(type); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__( + `Field "${fieldName}" must not have a selection since type "${typeStr}" has no subfields.`, + { + nodes: selectionSet, + }, + ), + ); + } + } else if (!selectionSet) { + const fieldName = node.name.value; + const typeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(type); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__( + `Field "${fieldName}" of type "${typeStr}" must have a selection of subfields. Did you mean "${fieldName} { ... }"?`, + { + nodes: node, + }, + ), + ); + } + } + }, + }; +} + + +/***/ }), + +/***/ 423: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "Z": () => (/* binding */ SingleFieldSubscriptionsRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7359); +/* harmony import */ var _execution_collectFields_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7677); + + + + +/** + * Subscriptions must only include a non-introspection field. + * + * A GraphQL subscription is valid only if it contains a single root field and + * that root field is not an introspection field. + * + * See https://spec.graphql.org/draft/#sec-Single-root-field + */ +function SingleFieldSubscriptionsRule(context) { + return { + OperationDefinition(node) { + if (node.operation === 'subscription') { + const schema = context.getSchema(); + const subscriptionType = schema.getSubscriptionType(); + + if (subscriptionType) { + const operationName = node.name ? node.name.value : null; + const variableValues = Object.create(null); + const document = context.getDocument(); + const fragments = Object.create(null); + + for (const definition of document.definitions) { + if (definition.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_0__/* .Kind.FRAGMENT_DEFINITION */ .h.FRAGMENT_DEFINITION) { + fragments[definition.name.value] = definition; + } + } + + const fields = (0,_execution_collectFields_mjs__WEBPACK_IMPORTED_MODULE_1__/* .collectFields */ .g)( + schema, + fragments, + variableValues, + subscriptionType, + node.selectionSet, + ); + + if (fields.size > 1) { + const fieldSelectionLists = [...fields.values()]; + const extraFieldSelectionLists = fieldSelectionLists.slice(1); + const extraFieldSelections = extraFieldSelectionLists.flat(); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__( + operationName != null + ? `Subscription "${operationName}" must select only one top level field.` + : 'Anonymous Subscription must select only one top level field.', + { + nodes: extraFieldSelections, + }, + ), + ); + } + + for (const fieldNodes of fields.values()) { + const field = fieldNodes[0]; + const fieldName = field.name.value; + + if (fieldName.startsWith('__')) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__( + operationName != null + ? `Subscription "${operationName}" must not select an introspection top level field.` + : 'Anonymous Subscription must not select an introspection top level field.', + { + nodes: fieldNodes, + }, + ), + ); + } + } + } + } + }, + }; +} + + +/***/ }), + +/***/ 2337: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "L": () => (/* binding */ UniqueArgumentDefinitionNamesRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_groupBy_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3231); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); + + + +/** + * Unique argument definition names + * + * A GraphQL Object or Interface type is only valid if all its fields have uniquely named arguments. + * A GraphQL Directive is only valid if all its arguments are uniquely named. + */ +function UniqueArgumentDefinitionNamesRule(context) { + return { + DirectiveDefinition(directiveNode) { + var _directiveNode$argume; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argumentNodes = + (_directiveNode$argume = directiveNode.arguments) !== null && + _directiveNode$argume !== void 0 + ? _directiveNode$argume + : []; + return checkArgUniqueness(`@${directiveNode.name.value}`, argumentNodes); + }, + + InterfaceTypeDefinition: checkArgUniquenessPerField, + InterfaceTypeExtension: checkArgUniquenessPerField, + ObjectTypeDefinition: checkArgUniquenessPerField, + ObjectTypeExtension: checkArgUniquenessPerField, + }; + + function checkArgUniquenessPerField(typeNode) { + var _typeNode$fields; + + const typeName = typeNode.name.value; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const fieldNodes = + (_typeNode$fields = typeNode.fields) !== null && + _typeNode$fields !== void 0 + ? _typeNode$fields + : []; + + for (const fieldDef of fieldNodes) { + var _fieldDef$arguments; + + const fieldName = fieldDef.name.value; // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const argumentNodes = + (_fieldDef$arguments = fieldDef.arguments) !== null && + _fieldDef$arguments !== void 0 + ? _fieldDef$arguments + : []; + checkArgUniqueness(`${typeName}.${fieldName}`, argumentNodes); + } + + return false; + } + + function checkArgUniqueness(parentName, argumentNodes) { + const seenArgs = (0,_jsutils_groupBy_mjs__WEBPACK_IMPORTED_MODULE_0__/* .groupBy */ .v)(argumentNodes, (arg) => arg.name.value); + + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Argument "${parentName}(${argName}:)" can only be defined once.`, + { + nodes: argNodes.map((node) => node.name), + }, + ), + ); + } + } + + return false; + } +} + + +/***/ }), + +/***/ 2266: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "L": () => (/* binding */ UniqueArgumentNamesRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_groupBy_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3231); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); + + + +/** + * Unique argument names + * + * A GraphQL field or directive is only valid if all supplied arguments are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Argument-Names + */ +function UniqueArgumentNamesRule(context) { + return { + Field: checkArgUniqueness, + Directive: checkArgUniqueness, + }; + + function checkArgUniqueness(parentNode) { + var _parentNode$arguments; + + // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const argumentNodes = + (_parentNode$arguments = parentNode.arguments) !== null && + _parentNode$arguments !== void 0 + ? _parentNode$arguments + : []; + const seenArgs = (0,_jsutils_groupBy_mjs__WEBPACK_IMPORTED_MODULE_0__/* .groupBy */ .v)(argumentNodes, (arg) => arg.name.value); + + for (const [argName, argNodes] of seenArgs) { + if (argNodes.length > 1) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `There can be only one argument named "${argName}".`, + { + nodes: argNodes.map((node) => node.name), + }, + ), + ); + } + } + } +} + + +/***/ }), + +/***/ 3274: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "o": () => (/* binding */ UniqueDirectiveNamesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * Unique directive names + * + * A GraphQL document is only valid if all defined directives have unique names. + */ +function UniqueDirectiveNamesRule(context) { + const knownDirectiveNames = Object.create(null); + const schema = context.getSchema(); + return { + DirectiveDefinition(node) { + const directiveName = node.name.value; + + if ( + schema !== null && + schema !== void 0 && + schema.getDirective(directiveName) + ) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Directive "@${directiveName}" already exists in the schema. It cannot be redefined.`, + { + nodes: node.name, + }, + ), + ); + return; + } + + if (knownDirectiveNames[directiveName]) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `There can be only one directive named "@${directiveName}".`, + { + nodes: [knownDirectiveNames[directiveName], node.name], + }, + ), + ); + } else { + knownDirectiveNames[directiveName] = node.name; + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 6300: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "k": () => (/* binding */ UniqueDirectivesPerLocationRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7359); +/* harmony import */ var _language_predicates_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5844); +/* harmony import */ var _type_directives_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8238); + + + + + +/** + * Unique directive names per location + * + * A GraphQL document is only valid if all non-repeatable directives at + * a given location are uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Directives-Are-Unique-Per-Location + */ +function UniqueDirectivesPerLocationRule(context) { + const uniqueDirectiveMap = Object.create(null); + const schema = context.getSchema(); + const definedDirectives = schema + ? schema.getDirectives() + : _type_directives_mjs__WEBPACK_IMPORTED_MODULE_0__/* .specifiedDirectives */ .V4; + + for (const directive of definedDirectives) { + uniqueDirectiveMap[directive.name] = !directive.isRepeatable; + } + + const astDefinitions = context.getDocument().definitions; + + for (const def of astDefinitions) { + if (def.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.DIRECTIVE_DEFINITION */ .h.DIRECTIVE_DEFINITION) { + uniqueDirectiveMap[def.name.value] = !def.repeatable; + } + } + + const schemaDirectives = Object.create(null); + const typeDirectivesMap = Object.create(null); + return { + // Many different AST nodes may contain directives. Rather than listing + // them all, just listen for entering any node, and check to see if it + // defines any directives. + enter(node) { + if (!('directives' in node) || !node.directives) { + return; + } + + let seenDirectives; + + if ( + node.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCHEMA_DEFINITION */ .h.SCHEMA_DEFINITION || + node.kind === _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_1__/* .Kind.SCHEMA_EXTENSION */ .h.SCHEMA_EXTENSION + ) { + seenDirectives = schemaDirectives; + } else if ((0,_language_predicates_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isTypeDefinitionNode */ .zT)(node) || (0,_language_predicates_mjs__WEBPACK_IMPORTED_MODULE_2__/* .isTypeExtensionNode */ .D$)(node)) { + const typeName = node.name.value; + seenDirectives = typeDirectivesMap[typeName]; + + if (seenDirectives === undefined) { + typeDirectivesMap[typeName] = seenDirectives = Object.create(null); + } + } else { + seenDirectives = Object.create(null); + } + + for (const directive of node.directives) { + const directiveName = directive.name.value; + + if (uniqueDirectiveMap[directiveName]) { + if (seenDirectives[directiveName]) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `The directive "@${directiveName}" can only be used once at this location.`, + { + nodes: [seenDirectives[directiveName], directive], + }, + ), + ); + } else { + seenDirectives[directiveName] = directive; + } + } + } + }, + }; +} + + +/***/ }), + +/***/ 3201: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "L": () => (/* binding */ UniqueEnumValueNamesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(398); + + + +/** + * Unique enum value names + * + * A GraphQL enum type is only valid if all its values are uniquely named. + */ +function UniqueEnumValueNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownValueNames = Object.create(null); + return { + EnumTypeDefinition: checkValueUniqueness, + EnumTypeExtension: checkValueUniqueness, + }; + + function checkValueUniqueness(node) { + var _node$values; + + const typeName = node.name.value; + + if (!knownValueNames[typeName]) { + knownValueNames[typeName] = Object.create(null); + } // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const valueNodes = + (_node$values = node.values) !== null && _node$values !== void 0 + ? _node$values + : []; + const valueNames = knownValueNames[typeName]; + + for (const valueDef of valueNodes) { + const valueName = valueDef.name.value; + const existingType = existingTypeMap[typeName]; + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isEnumType */ .EM)(existingType) && existingType.getValue(valueName)) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Enum value "${typeName}.${valueName}" already exists in the schema. It cannot also be defined in this type extension.`, + { + nodes: valueDef.name, + }, + ), + ); + } else if (valueNames[valueName]) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `Enum value "${typeName}.${valueName}" can only be defined once.`, + { + nodes: [valueNames[valueName], valueDef.name], + }, + ), + ); + } else { + valueNames[valueName] = valueDef.name; + } + } + + return false; + } +} + + +/***/ }), + +/***/ 2618: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "y": () => (/* binding */ UniqueFieldDefinitionNamesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(398); + + + +/** + * Unique field definition names + * + * A GraphQL complex type is only valid if all its fields are uniquely named. + */ +function UniqueFieldDefinitionNamesRule(context) { + const schema = context.getSchema(); + const existingTypeMap = schema ? schema.getTypeMap() : Object.create(null); + const knownFieldNames = Object.create(null); + return { + InputObjectTypeDefinition: checkFieldUniqueness, + InputObjectTypeExtension: checkFieldUniqueness, + InterfaceTypeDefinition: checkFieldUniqueness, + InterfaceTypeExtension: checkFieldUniqueness, + ObjectTypeDefinition: checkFieldUniqueness, + ObjectTypeExtension: checkFieldUniqueness, + }; + + function checkFieldUniqueness(node) { + var _node$fields; + + const typeName = node.name.value; + + if (!knownFieldNames[typeName]) { + knownFieldNames[typeName] = Object.create(null); + } // FIXME: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + + const fieldNodes = + (_node$fields = node.fields) !== null && _node$fields !== void 0 + ? _node$fields + : []; + const fieldNames = knownFieldNames[typeName]; + + for (const fieldDef of fieldNodes) { + const fieldName = fieldDef.name.value; + + if (hasField(existingTypeMap[typeName], fieldName)) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Field "${typeName}.${fieldName}" already exists in the schema. It cannot also be defined in this type extension.`, + { + nodes: fieldDef.name, + }, + ), + ); + } else if (fieldNames[fieldName]) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Field "${typeName}.${fieldName}" can only be defined once.`, + { + nodes: [fieldNames[fieldName], fieldDef.name], + }, + ), + ); + } else { + fieldNames[fieldName] = fieldDef.name; + } + } + + return false; + } +} + +function hasField(type, fieldName) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isObjectType */ .lp)(type) || (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isInterfaceType */ .oT)(type) || (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isInputObjectType */ .hL)(type)) { + return type.getFields()[fieldName] != null; + } + + return false; +} + + +/***/ }), + +/***/ 5591: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "N": () => (/* binding */ UniqueFragmentNamesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * Unique fragment names + * + * A GraphQL document is only valid if all defined fragments have unique names. + * + * See https://spec.graphql.org/draft/#sec-Fragment-Name-Uniqueness + */ +function UniqueFragmentNamesRule(context) { + const knownFragmentNames = Object.create(null); + return { + OperationDefinition: () => false, + + FragmentDefinition(node) { + const fragmentName = node.name.value; + + if (knownFragmentNames[fragmentName]) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `There can be only one fragment named "${fragmentName}".`, + { + nodes: [knownFragmentNames[fragmentName], node.name], + }, + ), + ); + } else { + knownFragmentNames[fragmentName] = node.name; + } + + return false; + }, + }; +} + + +/***/ }), + +/***/ 2767: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "P": () => (/* binding */ UniqueInputFieldNamesRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(9551); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); + + + +/** + * Unique input field names + * + * A GraphQL input object value is only valid if all supplied fields are + * uniquely named. + * + * See https://spec.graphql.org/draft/#sec-Input-Object-Field-Uniqueness + */ +function UniqueInputFieldNamesRule(context) { + const knownNameStack = []; + let knownNames = Object.create(null); + return { + ObjectValue: { + enter() { + knownNameStack.push(knownNames); + knownNames = Object.create(null); + }, + + leave() { + const prevKnownNames = knownNameStack.pop(); + prevKnownNames || (0,_jsutils_invariant_mjs__WEBPACK_IMPORTED_MODULE_0__/* .invariant */ .k)(false); + knownNames = prevKnownNames; + }, + }, + + ObjectField(node) { + const fieldName = node.name.value; + + if (knownNames[fieldName]) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `There can be only one input field named "${fieldName}".`, + { + nodes: [knownNames[fieldName], node.name], + }, + ), + ); + } else { + knownNames[fieldName] = node.name; + } + }, + }; +} + + +/***/ }), + +/***/ 2621: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "H": () => (/* binding */ UniqueOperationNamesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * Unique operation names + * + * A GraphQL document is only valid if all defined operations have unique names. + * + * See https://spec.graphql.org/draft/#sec-Operation-Name-Uniqueness + */ +function UniqueOperationNamesRule(context) { + const knownOperationNames = Object.create(null); + return { + OperationDefinition(node) { + const operationName = node.name; + + if (operationName) { + if (knownOperationNames[operationName.value]) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `There can be only one operation named "${operationName.value}".`, + { + nodes: [ + knownOperationNames[operationName.value], + operationName, + ], + }, + ), + ); + } else { + knownOperationNames[operationName.value] = operationName; + } + } + + return false; + }, + + FragmentDefinition: () => false, + }; +} + + +/***/ }), + +/***/ 7990: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "q": () => (/* binding */ UniqueOperationTypesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * Unique operation types + * + * A GraphQL document is only valid if it has only one type per operation. + */ +function UniqueOperationTypesRule(context) { + const schema = context.getSchema(); + const definedOperationTypes = Object.create(null); + const existingOperationTypes = schema + ? { + query: schema.getQueryType(), + mutation: schema.getMutationType(), + subscription: schema.getSubscriptionType(), + } + : {}; + return { + SchemaDefinition: checkOperationTypes, + SchemaExtension: checkOperationTypes, + }; + + function checkOperationTypes(node) { + var _node$operationTypes; + + // See: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const operationTypesNodes = + (_node$operationTypes = node.operationTypes) !== null && + _node$operationTypes !== void 0 + ? _node$operationTypes + : []; + + for (const operationType of operationTypesNodes) { + const operation = operationType.operation; + const alreadyDefinedOperationType = definedOperationTypes[operation]; + + if (existingOperationTypes[operation]) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Type for ${operation} already defined in the schema. It cannot be redefined.`, + { + nodes: operationType, + }, + ), + ); + } else if (alreadyDefinedOperationType) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `There can be only one ${operation} type in schema.`, + { + nodes: [alreadyDefinedOperationType, operationType], + }, + ), + ); + } else { + definedOperationTypes[operation] = operationType; + } + } + + return false; + } +} + + +/***/ }), + +/***/ 9538: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "P": () => (/* binding */ UniqueTypeNamesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8087); + + +/** + * Unique type names + * + * A GraphQL document is only valid if all defined types have unique names. + */ +function UniqueTypeNamesRule(context) { + const knownTypeNames = Object.create(null); + const schema = context.getSchema(); + return { + ScalarTypeDefinition: checkTypeName, + ObjectTypeDefinition: checkTypeName, + InterfaceTypeDefinition: checkTypeName, + UnionTypeDefinition: checkTypeName, + EnumTypeDefinition: checkTypeName, + InputObjectTypeDefinition: checkTypeName, + }; + + function checkTypeName(node) { + const typeName = node.name.value; + + if (schema !== null && schema !== void 0 && schema.getType(typeName)) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__( + `Type "${typeName}" already exists in the schema. It cannot also be defined in this type definition.`, + { + nodes: node.name, + }, + ), + ); + return; + } + + if (knownTypeNames[typeName]) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_0__/* .GraphQLError */ .__(`There can be only one type named "${typeName}".`, { + nodes: [knownTypeNames[typeName], node.name], + }), + ); + } else { + knownTypeNames[typeName] = node.name; + } + + return false; + } +} + + +/***/ }), + +/***/ 1564: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "H": () => (/* binding */ UniqueVariableNamesRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_groupBy_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3231); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(8087); + + + +/** + * Unique variable names + * + * A GraphQL operation is only valid if all its variables are uniquely named. + */ +function UniqueVariableNamesRule(context) { + return { + OperationDefinition(operationNode) { + var _operationNode$variab; + + // See: https://github.com/graphql/graphql-js/issues/2203 + + /* c8 ignore next */ + const variableDefinitions = + (_operationNode$variab = operationNode.variableDefinitions) !== null && + _operationNode$variab !== void 0 + ? _operationNode$variab + : []; + const seenVariableDefinitions = (0,_jsutils_groupBy_mjs__WEBPACK_IMPORTED_MODULE_0__/* .groupBy */ .v)( + variableDefinitions, + (node) => node.variable.name.value, + ); + + for (const [variableName, variableNodes] of seenVariableDefinitions) { + if (variableNodes.length > 1) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_1__/* .GraphQLError */ .__( + `There can be only one variable named "$${variableName}".`, + { + nodes: variableNodes.map((node) => node.variable.name), + }, + ), + ); + } + } + }, + }; +} + + +/***/ }), + +/***/ 9831: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "j": () => (/* binding */ ValuesOfCorrectTypeRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(3177); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(5821); +/* harmony import */ var _jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3498); +/* harmony import */ var _jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(3294); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8087); +/* harmony import */ var _language_printer_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(3486); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(398); + + + + + + + + +/** + * Value literals of correct type + * + * A GraphQL document is only valid if all value literals are of the type + * expected at their position. + * + * See https://spec.graphql.org/draft/#sec-Values-of-Correct-Type + */ +function ValuesOfCorrectTypeRule(context) { + return { + ListValue(node) { + // Note: TypeInfo will traverse into a list's item type, so look to the + // parent input type to check if it is a list. + const type = (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getNullableType */ .tf)(context.getParentInputType()); + + if (!(0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isListType */ .HG)(type)) { + isValidValueNode(context, node); + return false; // Don't traverse further. + } + }, + + ObjectValue(node) { + const type = (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getNamedType */ .xC)(context.getInputType()); + + if (!(0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputObjectType */ .hL)(type)) { + isValidValueNode(context, node); + return false; // Don't traverse further. + } // Ensure every required field exists. + + const fieldNodeMap = (0,_jsutils_keyMap_mjs__WEBPACK_IMPORTED_MODULE_1__/* .keyMap */ .P)(node.fields, (field) => field.name.value); + + for (const fieldDef of Object.values(type.getFields())) { + const fieldNode = fieldNodeMap[fieldDef.name]; + + if (!fieldNode && (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isRequiredInputField */ .Wd)(fieldDef)) { + const typeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(fieldDef.type); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Field "${type.name}.${fieldDef.name}" of required type "${typeStr}" was not provided.`, + { + nodes: node, + }, + ), + ); + } + } + }, + + ObjectField(node) { + const parentType = (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getNamedType */ .xC)(context.getParentInputType()); + const fieldType = context.getInputType(); + + if (!fieldType && (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isInputObjectType */ .hL)(parentType)) { + const suggestions = (0,_jsutils_suggestionList_mjs__WEBPACK_IMPORTED_MODULE_4__/* .suggestionList */ .D)( + node.name.value, + Object.keys(parentType.getFields()), + ); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Field "${node.name.value}" is not defined by type "${parentType.name}".` + + (0,_jsutils_didYouMean_mjs__WEBPACK_IMPORTED_MODULE_5__/* .didYouMean */ .l)(suggestions), + { + nodes: node, + }, + ), + ); + } + }, + + NullValue(node) { + const type = context.getInputType(); + + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isNonNullType */ .zM)(type)) { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Expected value of type "${(0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(type)}", found ${(0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_6__/* .print */ .S)(node)}.`, + { + nodes: node, + }, + ), + ); + } + }, + + EnumValue: (node) => isValidValueNode(context, node), + IntValue: (node) => isValidValueNode(context, node), + FloatValue: (node) => isValidValueNode(context, node), + StringValue: (node) => isValidValueNode(context, node), + BooleanValue: (node) => isValidValueNode(context, node), + }; +} +/** + * Any value literal may be a valid representation of a Scalar, depending on + * that scalar type. + */ + +function isValidValueNode(context, node) { + // Report any error at the full type expected by the location. + const locationType = context.getInputType(); + + if (!locationType) { + return; + } + + const type = (0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .getNamedType */ .xC)(locationType); + + if (!(0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_0__/* .isLeafType */ .UT)(type)) { + const typeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(locationType); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Expected value of type "${typeStr}", found ${(0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_6__/* .print */ .S)(node)}.`, + { + nodes: node, + }, + ), + ); + return; + } // Scalars and Enums determine if a literal value is valid via parseLiteral(), + // which may throw or return an invalid value to indicate failure. + + try { + const parseResult = type.parseLiteral( + node, + undefined, + /* variables */ + ); + + if (parseResult === undefined) { + const typeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(locationType); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Expected value of type "${typeStr}", found ${(0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_6__/* .print */ .S)(node)}.`, + { + nodes: node, + }, + ), + ); + } + } catch (error) { + const typeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_2__/* .inspect */ .X)(locationType); + + if (error instanceof _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__) { + context.reportError(error); + } else { + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Expected value of type "${typeStr}", found ${(0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_6__/* .print */ .S)(node)}; ` + + error.message, + { + nodes: node, + originalError: error, + }, + ), + ); + } + } +} + + +/***/ }), + +/***/ 5972: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "I": () => (/* binding */ VariablesAreInputTypesRule) +/* harmony export */ }); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(8087); +/* harmony import */ var _language_printer_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(3486); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(398); +/* harmony import */ var _utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77); + + + + + +/** + * Variables are input types + * + * A GraphQL operation is only valid if all the variables it defines are of + * input types (scalar, enum, or input object). + * + * See https://spec.graphql.org/draft/#sec-Variables-Are-Input-Types + */ +function VariablesAreInputTypesRule(context) { + return { + VariableDefinition(node) { + const type = (0,_utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_0__/* .typeFromAST */ ._)(context.getSchema(), node.type); + + if (type !== undefined && !(0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_1__/* .isInputType */ .j$)(type)) { + const variableName = node.variable.name.value; + const typeName = (0,_language_printer_mjs__WEBPACK_IMPORTED_MODULE_2__/* .print */ .S)(node.type); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_3__/* .GraphQLError */ .__( + `Variable "$${variableName}" cannot be non-input type "${typeName}".`, + { + nodes: node.type, + }, + ), + ); + } + }, + }; +} + + +/***/ }), + +/***/ 9701: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "w": () => (/* binding */ VariablesInAllowedPositionRule) +/* harmony export */ }); +/* harmony import */ var _jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(5821); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(8087); +/* harmony import */ var _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(7359); +/* harmony import */ var _type_definition_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(398); +/* harmony import */ var _utilities_typeComparators_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(316); +/* harmony import */ var _utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(77); + + + + + + + +/** + * Variables in allowed position + * + * Variable usages must be compatible with the arguments they are passed to. + * + * See https://spec.graphql.org/draft/#sec-All-Variable-Usages-are-Allowed + */ +function VariablesInAllowedPositionRule(context) { + let varDefMap = Object.create(null); + return { + OperationDefinition: { + enter() { + varDefMap = Object.create(null); + }, + + leave(operation) { + const usages = context.getRecursiveVariableUsages(operation); + + for (const { node, type, defaultValue } of usages) { + const varName = node.name.value; + const varDef = varDefMap[varName]; + + if (varDef && type) { + // A var type is allowed if it is the same or more strict (e.g. is + // a subtype of) than the expected type. It can be more strict if + // the variable type is non-null when the expected type is nullable. + // If both are list types, the variable item type can be more strict + // than the expected item type (contravariant). + const schema = context.getSchema(); + const varType = (0,_utilities_typeFromAST_mjs__WEBPACK_IMPORTED_MODULE_0__/* .typeFromAST */ ._)(schema, varDef.type); + + if ( + varType && + !allowedVariableUsage( + schema, + varType, + varDef.defaultValue, + type, + defaultValue, + ) + ) { + const varTypeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(varType); + const typeStr = (0,_jsutils_inspect_mjs__WEBPACK_IMPORTED_MODULE_1__/* .inspect */ .X)(type); + context.reportError( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_2__/* .GraphQLError */ .__( + `Variable "$${varName}" of type "${varTypeStr}" used in position expecting type "${typeStr}".`, + { + nodes: [varDef, node], + }, + ), + ); + } + } + } + }, + }, + + VariableDefinition(node) { + varDefMap[node.variable.name.value] = node; + }, + }; +} +/** + * Returns true if the variable is allowed in the location it was found, + * which includes considering if default values exist for either the variable + * or the location at which it is located. + */ + +function allowedVariableUsage( + schema, + varType, + varDefaultValue, + locationType, + locationDefaultValue, +) { + if ((0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_3__/* .isNonNullType */ .zM)(locationType) && !(0,_type_definition_mjs__WEBPACK_IMPORTED_MODULE_3__/* .isNonNullType */ .zM)(varType)) { + const hasNonNullVariableDefaultValue = + varDefaultValue != null && varDefaultValue.kind !== _language_kinds_mjs__WEBPACK_IMPORTED_MODULE_4__/* .Kind.NULL */ .h.NULL; + const hasLocationDefaultValue = locationDefaultValue !== undefined; + + if (!hasNonNullVariableDefaultValue && !hasLocationDefaultValue) { + return false; + } + + const nullableLocationType = locationType.ofType; + return (0,_utilities_typeComparators_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isTypeSubTypeOf */ .uJ)(schema, varType, nullableLocationType); + } + + return (0,_utilities_typeComparators_mjs__WEBPACK_IMPORTED_MODULE_5__/* .isTypeSubTypeOf */ .uJ)(schema, varType, locationType); +} + + +/***/ }), + +/***/ 4196: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "M": () => (/* binding */ specifiedSDLRules), +/* harmony export */ "i": () => (/* binding */ specifiedRules) +/* harmony export */ }); +/* harmony import */ var _rules_ExecutableDefinitionsRule_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(8081); +/* harmony import */ var _rules_FieldsOnCorrectTypeRule_mjs__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(8741); +/* harmony import */ var _rules_FragmentsOnCompositeTypesRule_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(7143); +/* harmony import */ var _rules_KnownArgumentNamesRule_mjs__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(7815); +/* harmony import */ var _rules_KnownDirectivesRule_mjs__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(4873); +/* harmony import */ var _rules_KnownFragmentNamesRule_mjs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(5311); +/* harmony import */ var _rules_KnownTypeNamesRule_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(5580); +/* harmony import */ var _rules_LoneAnonymousOperationRule_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7898); +/* harmony import */ var _rules_LoneSchemaDefinitionRule_mjs__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(2877); +/* harmony import */ var _rules_NoFragmentCyclesRule_mjs__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(1422); +/* harmony import */ var _rules_NoUndefinedVariablesRule_mjs__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(4790); +/* harmony import */ var _rules_NoUnusedFragmentsRule_mjs__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(1294); +/* harmony import */ var _rules_NoUnusedVariablesRule_mjs__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(2283); +/* harmony import */ var _rules_OverlappingFieldsCanBeMergedRule_mjs__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(4203); +/* harmony import */ var _rules_PossibleFragmentSpreadsRule_mjs__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(3259); +/* harmony import */ var _rules_PossibleTypeExtensionsRule_mjs__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(4800); +/* harmony import */ var _rules_ProvidedRequiredArgumentsRule_mjs__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(1967); +/* harmony import */ var _rules_ScalarLeafsRule_mjs__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(1954); +/* harmony import */ var _rules_SingleFieldSubscriptionsRule_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(423); +/* harmony import */ var _rules_UniqueArgumentDefinitionNamesRule_mjs__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(2337); +/* harmony import */ var _rules_UniqueArgumentNamesRule_mjs__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(2266); +/* harmony import */ var _rules_UniqueDirectiveNamesRule_mjs__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(3274); +/* harmony import */ var _rules_UniqueDirectivesPerLocationRule_mjs__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(6300); +/* harmony import */ var _rules_UniqueEnumValueNamesRule_mjs__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(3201); +/* harmony import */ var _rules_UniqueFieldDefinitionNamesRule_mjs__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(2618); +/* harmony import */ var _rules_UniqueFragmentNamesRule_mjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(5591); +/* harmony import */ var _rules_UniqueInputFieldNamesRule_mjs__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(2767); +/* harmony import */ var _rules_UniqueOperationNamesRule_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2621); +/* harmony import */ var _rules_UniqueOperationTypesRule_mjs__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(7990); +/* harmony import */ var _rules_UniqueTypeNamesRule_mjs__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(9538); +/* harmony import */ var _rules_UniqueVariableNamesRule_mjs__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(1564); +/* harmony import */ var _rules_ValuesOfCorrectTypeRule_mjs__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(9831); +/* harmony import */ var _rules_VariablesAreInputTypesRule_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(5972); +/* harmony import */ var _rules_VariablesInAllowedPositionRule_mjs__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(9701); +// Spec Section: "Executable Definitions" + // Spec Section: "Field Selections on Objects, Interfaces, and Unions Types" + + // Spec Section: "Fragments on Composite Types" + + // Spec Section: "Argument Names" + + // Spec Section: "Directives Are Defined" + + // Spec Section: "Fragment spread target defined" + + // Spec Section: "Fragment Spread Type Existence" + + // Spec Section: "Lone Anonymous Operation" + + // SDL-specific validation rules + + // Spec Section: "Fragments must not form cycles" + + // Spec Section: "All Variable Used Defined" + + // Spec Section: "Fragments must be used" + + // Spec Section: "All Variables Used" + + // Spec Section: "Field Selection Merging" + + // Spec Section: "Fragment spread is possible" + + + // Spec Section: "Argument Optionality" + + // Spec Section: "Leaf Field Selections" + + // Spec Section: "Subscriptions with Single Root Field" + + + // Spec Section: "Argument Uniqueness" + + + // Spec Section: "Directives Are Unique Per Location" + + + + // Spec Section: "Fragment Name Uniqueness" + + // Spec Section: "Input Object Field Uniqueness" + + // Spec Section: "Operation Name Uniqueness" + + + + // Spec Section: "Variable Uniqueness" + + // Spec Section: "Value Type Correctness" + + // Spec Section: "Variables are Input Types" + + // Spec Section: "All Variable Usages Are Allowed" + + + +/** + * This set includes all validation rules defined by the GraphQL spec. + * + * The order of the rules in this list has been adjusted to lead to the + * most clear output when encountering multiple validation errors. + */ +const specifiedRules = Object.freeze([ + _rules_ExecutableDefinitionsRule_mjs__WEBPACK_IMPORTED_MODULE_0__/* .ExecutableDefinitionsRule */ .i, + _rules_UniqueOperationNamesRule_mjs__WEBPACK_IMPORTED_MODULE_1__/* .UniqueOperationNamesRule */ .H, + _rules_LoneAnonymousOperationRule_mjs__WEBPACK_IMPORTED_MODULE_2__/* .LoneAnonymousOperationRule */ .F, + _rules_SingleFieldSubscriptionsRule_mjs__WEBPACK_IMPORTED_MODULE_3__/* .SingleFieldSubscriptionsRule */ .Z, + _rules_KnownTypeNamesRule_mjs__WEBPACK_IMPORTED_MODULE_4__/* .KnownTypeNamesRule */ .I, + _rules_FragmentsOnCompositeTypesRule_mjs__WEBPACK_IMPORTED_MODULE_5__/* .FragmentsOnCompositeTypesRule */ .T, + _rules_VariablesAreInputTypesRule_mjs__WEBPACK_IMPORTED_MODULE_6__/* .VariablesAreInputTypesRule */ .I, + _rules_ScalarLeafsRule_mjs__WEBPACK_IMPORTED_MODULE_7__/* .ScalarLeafsRule */ .O, + _rules_FieldsOnCorrectTypeRule_mjs__WEBPACK_IMPORTED_MODULE_8__/* .FieldsOnCorrectTypeRule */ .A, + _rules_UniqueFragmentNamesRule_mjs__WEBPACK_IMPORTED_MODULE_9__/* .UniqueFragmentNamesRule */ .N, + _rules_KnownFragmentNamesRule_mjs__WEBPACK_IMPORTED_MODULE_10__/* .KnownFragmentNamesRule */ .a, + _rules_NoUnusedFragmentsRule_mjs__WEBPACK_IMPORTED_MODULE_11__/* .NoUnusedFragmentsRule */ .J, + _rules_PossibleFragmentSpreadsRule_mjs__WEBPACK_IMPORTED_MODULE_12__/* .PossibleFragmentSpreadsRule */ .a, + _rules_NoFragmentCyclesRule_mjs__WEBPACK_IMPORTED_MODULE_13__/* .NoFragmentCyclesRule */ .H, + _rules_UniqueVariableNamesRule_mjs__WEBPACK_IMPORTED_MODULE_14__/* .UniqueVariableNamesRule */ .H, + _rules_NoUndefinedVariablesRule_mjs__WEBPACK_IMPORTED_MODULE_15__/* .NoUndefinedVariablesRule */ .$, + _rules_NoUnusedVariablesRule_mjs__WEBPACK_IMPORTED_MODULE_16__/* .NoUnusedVariablesRule */ .p, + _rules_KnownDirectivesRule_mjs__WEBPACK_IMPORTED_MODULE_17__/* .KnownDirectivesRule */ .J, + _rules_UniqueDirectivesPerLocationRule_mjs__WEBPACK_IMPORTED_MODULE_18__/* .UniqueDirectivesPerLocationRule */ .k, + _rules_KnownArgumentNamesRule_mjs__WEBPACK_IMPORTED_MODULE_19__/* .KnownArgumentNamesRule */ .e, + _rules_UniqueArgumentNamesRule_mjs__WEBPACK_IMPORTED_MODULE_20__/* .UniqueArgumentNamesRule */ .L, + _rules_ValuesOfCorrectTypeRule_mjs__WEBPACK_IMPORTED_MODULE_21__/* .ValuesOfCorrectTypeRule */ .j, + _rules_ProvidedRequiredArgumentsRule_mjs__WEBPACK_IMPORTED_MODULE_22__/* .ProvidedRequiredArgumentsRule */ .s, + _rules_VariablesInAllowedPositionRule_mjs__WEBPACK_IMPORTED_MODULE_23__/* .VariablesInAllowedPositionRule */ .w, + _rules_OverlappingFieldsCanBeMergedRule_mjs__WEBPACK_IMPORTED_MODULE_24__/* .OverlappingFieldsCanBeMergedRule */ .y, + _rules_UniqueInputFieldNamesRule_mjs__WEBPACK_IMPORTED_MODULE_25__/* .UniqueInputFieldNamesRule */ .P, +]); +/** + * @internal + */ + +const specifiedSDLRules = Object.freeze([ + _rules_LoneSchemaDefinitionRule_mjs__WEBPACK_IMPORTED_MODULE_26__/* .LoneSchemaDefinitionRule */ .t, + _rules_UniqueOperationTypesRule_mjs__WEBPACK_IMPORTED_MODULE_27__/* .UniqueOperationTypesRule */ .q, + _rules_UniqueTypeNamesRule_mjs__WEBPACK_IMPORTED_MODULE_28__/* .UniqueTypeNamesRule */ .P, + _rules_UniqueEnumValueNamesRule_mjs__WEBPACK_IMPORTED_MODULE_29__/* .UniqueEnumValueNamesRule */ .L, + _rules_UniqueFieldDefinitionNamesRule_mjs__WEBPACK_IMPORTED_MODULE_30__/* .UniqueFieldDefinitionNamesRule */ .y, + _rules_UniqueArgumentDefinitionNamesRule_mjs__WEBPACK_IMPORTED_MODULE_31__/* .UniqueArgumentDefinitionNamesRule */ .L, + _rules_UniqueDirectiveNamesRule_mjs__WEBPACK_IMPORTED_MODULE_32__/* .UniqueDirectiveNamesRule */ .o, + _rules_KnownTypeNamesRule_mjs__WEBPACK_IMPORTED_MODULE_4__/* .KnownTypeNamesRule */ .I, + _rules_KnownDirectivesRule_mjs__WEBPACK_IMPORTED_MODULE_17__/* .KnownDirectivesRule */ .J, + _rules_UniqueDirectivesPerLocationRule_mjs__WEBPACK_IMPORTED_MODULE_18__/* .UniqueDirectivesPerLocationRule */ .k, + _rules_PossibleTypeExtensionsRule_mjs__WEBPACK_IMPORTED_MODULE_33__/* .PossibleTypeExtensionsRule */ .g, + _rules_KnownArgumentNamesRule_mjs__WEBPACK_IMPORTED_MODULE_19__/* .KnownArgumentNamesOnDirectivesRule */ .o, + _rules_UniqueArgumentNamesRule_mjs__WEBPACK_IMPORTED_MODULE_20__/* .UniqueArgumentNamesRule */ .L, + _rules_UniqueInputFieldNamesRule_mjs__WEBPACK_IMPORTED_MODULE_25__/* .UniqueInputFieldNamesRule */ .P, + _rules_ProvidedRequiredArgumentsRule_mjs__WEBPACK_IMPORTED_MODULE_22__/* .ProvidedRequiredArgumentsOnDirectivesRule */ .c, +]); + + +/***/ }), + +/***/ 6584: +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "ED": () => (/* binding */ assertValidSDLExtension), +/* harmony export */ "Gu": () => (/* binding */ validate), +/* harmony export */ "zo": () => (/* binding */ assertValidSDL) +/* harmony export */ }); +/* unused harmony export validateSDL */ +/* harmony import */ var _jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7826); +/* harmony import */ var _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(8087); +/* harmony import */ var _language_visitor_mjs__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(7304); +/* harmony import */ var _type_validate_mjs__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(9655); +/* harmony import */ var _utilities_TypeInfo_mjs__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(2676); +/* harmony import */ var _specifiedRules_mjs__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(4196); +/* harmony import */ var _ValidationContext_mjs__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(2734); + + + + + + + +/** + * Implements the "Validation" section of the spec. + * + * Validation runs synchronously, returning an array of encountered errors, or + * an empty array if no errors were encountered and the document is valid. + * + * A list of specific validation rules may be provided. If not provided, the + * default list of rules defined by the GraphQL specification will be used. + * + * Each validation rules is a function which returns a visitor + * (see the language/visitor API). Visitor methods are expected to return + * GraphQLErrors, or Arrays of GraphQLErrors when invalid. + * + * Validate will stop validation after a `maxErrors` limit has been reached. + * Attackers can send pathologically invalid queries to induce a DoS attack, + * so by default `maxErrors` set to 100 errors. + * + * Optionally a custom TypeInfo instance may be provided. If not provided, one + * will be created from the provided schema. + */ + +function validate( + schema, + documentAST, + rules = _specifiedRules_mjs__WEBPACK_IMPORTED_MODULE_0__/* .specifiedRules */ .i, + options, + /** @deprecated will be removed in 17.0.0 */ + typeInfo = new _utilities_TypeInfo_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TypeInfo */ .a(schema), +) { + var _options$maxErrors; + + const maxErrors = + (_options$maxErrors = + options === null || options === void 0 ? void 0 : options.maxErrors) !== + null && _options$maxErrors !== void 0 + ? _options$maxErrors + : 100; + documentAST || (0,_jsutils_devAssert_mjs__WEBPACK_IMPORTED_MODULE_2__/* .devAssert */ .a)(false, 'Must provide document.'); // If the schema used for validation is invalid, throw an error. + + (0,_type_validate_mjs__WEBPACK_IMPORTED_MODULE_3__/* .assertValidSchema */ .J)(schema); + const abortObj = Object.freeze({}); + const errors = []; + const context = new _ValidationContext_mjs__WEBPACK_IMPORTED_MODULE_4__/* .ValidationContext */ ._t( + schema, + documentAST, + typeInfo, + (error) => { + if (errors.length >= maxErrors) { + errors.push( + new _error_GraphQLError_mjs__WEBPACK_IMPORTED_MODULE_5__/* .GraphQLError */ .__( + 'Too many validation errors, error limit reached. Validation aborted.', + ), + ); // eslint-disable-next-line @typescript-eslint/no-throw-literal + + throw abortObj; + } + + errors.push(error); + }, + ); // This uses a specialized visitor which runs multiple visitors in parallel, + // while maintaining the visitor skip and break API. + + const visitor = (0,_language_visitor_mjs__WEBPACK_IMPORTED_MODULE_6__/* .visitInParallel */ .j1)(rules.map((rule) => rule(context))); // Visit the whole document with each instance of all provided rules. + + try { + (0,_language_visitor_mjs__WEBPACK_IMPORTED_MODULE_6__/* .visit */ .Vn)(documentAST, (0,_utilities_TypeInfo_mjs__WEBPACK_IMPORTED_MODULE_1__/* .visitWithTypeInfo */ .y)(typeInfo, visitor)); + } catch (e) { + if (e !== abortObj) { + throw e; + } + } + + return errors; +} +/** + * @internal + */ + +function validateSDL( + documentAST, + schemaToExtend, + rules = _specifiedRules_mjs__WEBPACK_IMPORTED_MODULE_0__/* .specifiedSDLRules */ .M, +) { + const errors = []; + const context = new _ValidationContext_mjs__WEBPACK_IMPORTED_MODULE_4__/* .SDLValidationContext */ .yv( + documentAST, + schemaToExtend, + (error) => { + errors.push(error); + }, + ); + const visitors = rules.map((rule) => rule(context)); + (0,_language_visitor_mjs__WEBPACK_IMPORTED_MODULE_6__/* .visit */ .Vn)(documentAST, (0,_language_visitor_mjs__WEBPACK_IMPORTED_MODULE_6__/* .visitInParallel */ .j1)(visitors)); + return errors; +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ + +function assertValidSDL(documentAST) { + const errors = validateSDL(documentAST); + + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} +/** + * Utility function which asserts a SDL document is valid by throwing an error + * if it is invalid. + * + * @internal + */ + +function assertValidSDLExtension(documentAST, schema) { + const errors = validateSDL(documentAST, schema); + + if (errors.length !== 0) { + throw new Error(errors.map((error) => error.message).join('\n\n')); + } +} + + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ // The module cache +/******/ var __webpack_module_cache__ = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ // Check if module is in cache +/******/ var cachedModule = __webpack_module_cache__[moduleId]; +/******/ if (cachedModule !== undefined) { +/******/ return cachedModule.exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = __webpack_module_cache__[moduleId] = { +/******/ id: moduleId, +/******/ loaded: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/************************************************************************/ +/******/ /* webpack/runtime/compat get default export */ +/******/ (() => { +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = (module) => { +/******/ var getter = module && module.__esModule ? +/******/ () => (module['default']) : +/******/ () => (module); +/******/ __webpack_require__.d(getter, { a: getter }); +/******/ return getter; +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/define property getters */ +/******/ (() => { +/******/ // define getter functions for harmony exports +/******/ __webpack_require__.d = (exports, definition) => { +/******/ for(var key in definition) { +/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) { +/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] }); +/******/ } +/******/ } +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/global */ +/******/ (() => { +/******/ __webpack_require__.g = (function() { +/******/ if (typeof globalThis === 'object') return globalThis; +/******/ try { +/******/ return this || new Function('return this')(); +/******/ } catch (e) { +/******/ if (typeof window === 'object') return window; +/******/ } +/******/ })(); +/******/ })(); +/******/ +/******/ /* webpack/runtime/hasOwnProperty shorthand */ +/******/ (() => { +/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop)) +/******/ })(); +/******/ +/******/ /* webpack/runtime/make namespace object */ +/******/ (() => { +/******/ // define __esModule on exports +/******/ __webpack_require__.r = (exports) => { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ })(); +/******/ +/******/ /* webpack/runtime/node module decorator */ +/******/ (() => { +/******/ __webpack_require__.nmd = (module) => { +/******/ module.paths = []; +/******/ if (!module.children) module.children = []; +/******/ return module; +/******/ }; +/******/ })(); +/******/ +/************************************************************************/ +var __webpack_exports__ = {}; +// This entry need to be wrapped in an IIFE because it need to be in strict mode. +(() => { +"use strict"; +// ESM COMPAT FLAG +__webpack_require__.r(__webpack_exports__); + +// EXPORTS +__webpack_require__.d(__webpack_exports__, { + "API": () => (/* binding */ API), + "main": () => (/* binding */ main) +}); + +;// CONCATENATED MODULE: ./src/types.ts +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ +; +; +; +//////// UTILITIES +/** An exception that conveys an HTTP status. */ +class HTTPError extends Error { + constructor(status, baseMessage) { + super(`[${status}] ${baseMessage}`); // unpackJSError() in evaluator.go parses this + this.status = status; + this.baseMessage = baseMessage; + } +} + +// EXTERNAL MODULE: ./node_modules/graphql/type/definition.mjs + 1 modules +var definition = __webpack_require__(398); +;// CONCATENATED MODULE: ./src/compile.ts +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + + + +function nonEmpty(a) { + return a !== undefined && a.length > 0; +} +//////// PATTERN SUBSTITUTION (in 'allow') +const kPatternRegex = /\${([^}]+)}|(\\\$)/g; +/** A string that may change based on the current user and args. */ +class Pattern { + constructor(str) { + this.str = str; + } + toString() { + return this.str; + } +} +class NonPattern extends Pattern { + constructor(str) { super(str); } + expand(user, args) { + return this.str; + } +} +class DollarPattern extends Pattern { + constructor(str) { super(str); } + expand(user, args) { + let result = this.str.replace(kPatternRegex, (match, expr, none) => { + if (none) { + return '$'; // \$ -> $ + } + else if (expr.startsWith("context.user.name")) { + if (!user) { + return ""; + } + else { + return user.name ?? ""; + } + } + else if (expr.startsWith("args.")) { + let varName = expr.slice(5); + let value = args ? args[varName] : undefined; + switch (typeof (value)) { + case "undefined": + throw new HTTPError(503, "Bad config: Unknown arg in channel/role pattern '${" + expr + "} in 'allow'"); + case "string": + return value; + case "number": + return String(value); + default: + throw new HTTPError(400, "Value of arg '" + varName + "' must be a string or number"); + } + } + else { + throw new HTTPError(503, "Bad config: Invalid channel/role pattern '${" + expr + "} in 'allow'"); + } + }); + return result; + } + toString() { + return "Pattern<" + this.str + ">"; + } +} +/** Creates a Pattern from a string. '$'-prefixed patterns will be substituted according to the + * rules of the 'allow' object. */ +function CompilePattern(name) { + if (name.match(kPatternRegex)) { + return new DollarPattern(name); + } + else { + return new NonPattern(name); + } +} +/** Creates an array of Patterns from an array of strings, or `undefined` if there are none. */ +function CompilePatterns(names) { + return nonEmpty(names) ? names.map(name => CompilePattern(name)) : undefined; +} +/** Matches an array of Patterns against an array of strings, returning true if any match. */ +function Match(patterns, values, user, args) { + return nonEmpty(values) && patterns.some(pat => values.includes(pat.expand(user, args))); +} +/** Matches an array of Patterns against a single string, returning true if any match. */ +function Match1(patterns, value, user, args) { + return patterns.some(pat => (value == pat.expand(user, args))); +} +//////// AUTHORIZATION +/** Checks authorization for a user, based on an Allow object. Created by CompileAllow. */ +class Allow { + constructor(name) { + this.name = name; + } + fail(user) { + console.log(`Auth failure calling function '${this.name}' for user ${JSON.stringify(user)}`); + if (user.isGuest) { + throw new HTTPError(401, `Login required to call function '${this.name}'`); + } + else { + throw new HTTPError(403, `Access forbidden to function '${this.name}'`); + } + } +} +class AllowAdminOnly extends Allow { + authorize(user, args) { + if (!user.isAdmin) + this.fail(user); + } +} +class AllowAnyone extends Allow { + authorize(user) { } +} +class AllowByConfig extends Allow { + constructor(name, config) { + super(name); + this.users = CompilePatterns(config.users); + this.roles = CompilePatterns(config.roles); + this.channels = CompilePatterns(config.channels); + } + authorize(user, args) { + console.assert(user.defaultCollection !== undefined); + if (!user.isAdmin + && !(this.users && Match1(this.users, user.name, user, args)) + && !(this.roles && Match(this.roles, user.roles, user, args)) + && !(this.channels && Match(this.channels, user.channels, user, args))) { + //throw new HTTPError((user.isGuest ? 401 : 403), `Access forbidden to function '${this.name}' ... user = ${user.name} ... user.channels=${user.channels} ... this.users=${this.users} ... this.channels=${this.channels}`); + this.fail(user); + } + } +} +/** Creates an Allow object based on an optional AllowConfig. + * If there is no config, the `lenient` parameter determines whether that means + * "anyone" or "admin only". */ +function CompileAllow(name, config, lenient) { + if (!config) { + return lenient ? new AllowAnyone(name) : new AllowAdminOnly(name); + } + else if (!config.users && !config.roles && !config.channels) { + return new AllowAdminOnly(name); + } + else if ((config.users && config.users.includes("*")) + || (config.roles && config.roles.includes("*")) + || (config.channels && config.channels.includes("*"))) { + return new AllowAnyone(name); + } + else { + return new AllowByConfig(name, config); + } +} +/** Given a function's parameter list, returns a function to validate the 'args' object. */ +function CompileParams(fnName, parameters) { + if (!nonEmpty(parameters)) { + return (args) => { + if (args) { + let argNames = Object.getOwnPropertyNames(args); + if (argNames.length > 0) { + throw new HTTPError(400, `Undeclared arguments '${argNames.join("', '")}' passed to ${fnName}`); + } + } + }; + } + else { + let paramSet = new Set; + for (let param of parameters) { + paramSet.add(param); + } + let nParams = paramSet.size; + if (nParams != parameters.length) { + throw new HTTPError(500, `Function/resolver ${fnName} has duplicate arg names`); + } + return (args) => { + if (!args) { + throw new HTTPError(400, `Function "${fnName}" called without arguments, but requires ${parameters}`); + } + for (let param of parameters) { + if (args[param] === undefined) { + throw new HTTPError(400, `Missing argument "${param}" in call to ${fnName}`); + } + } + let argNames = Object.getOwnPropertyNames(args); + if (argNames.length != nParams) { + for (let arg of argNames) { + if (!paramSet.has(arg)) { + throw new HTTPError(400, `Undeclared argument "${arg}" passed to ${fnName}`); + } + } + } + }; + } +} +//////// COMPILING FUNCTIONS: +// Returns the N1QL query string from a FunctionConfig. +function checkN1QL(config) { + if (!config.code.match(/^\s*\(*SELECT\b/i)) + throw new HTTPError(500, "only SELECT queries are allowed"); + return config.code; +} +// Annotates an exception with the name of the active function, and re-throws it. +function rethrow(x, what, fnName) { + if (x instanceof Error) { + x.message = `${x.message} (thrown by ${what} ${fnName})`; + throw x; + } + else { + throw Error(`${x} (thrown by ${what} ${fnName})`); + } +} +/** Compiles a FunctionConfig to a function. */ +function CompileFn(fnName, fnConfig, db) { + const allow = CompileAllow(fnName, fnConfig.allow, false); + const checkArgs = CompileParams(fnName, fnConfig.args); + switch (fnConfig.type) { + case "query": + const n1ql = checkN1QL(fnConfig); + return function (context, args) { + checkArgs(args); + allow.authorize(context.user, args); + console.debug(`QUERY ${fnName}`); + if (args) + args = { args: args }; + return db.query(context, fnName, n1ql, args); + }; + case "javascript": + const mutating = fnConfig.mutating ?? false; + const code = compileToJS(fnName, fnConfig, 2); + return function (context, args) { + console.debug(`FUNC ${fnName}`); + checkArgs(args); + allow.authorize(context.user, args); + if (!mutating) + BeginReadOnly(context); + try { + return code(context, args); + } + catch (x) { + rethrow(x, "function", fnName); + } + finally { + if (!mutating) + EndReadOnly(context); + } + }; + default: + throw new HTTPError(500, `unrecognized 'type' "${fnConfig.type}"`); + } +} +/** Compiles a FunctionConfig to a GraphQL resolver. */ +function CompileResolver(field, typeName, fieldName, fnConfig, db) { + let fnName = `${typeName}.${fieldName}`; + let mutating = (typeName == "Mutation"); + let allow = CompileAllow(fnName, fnConfig.allow, true); + if (fnConfig.args) { + throw new HTTPError(500, `'args' is not valid in a GraphQL resolver config`); + } + switch (fnConfig.type) { + case "query": + if (mutating) + throw new HTTPError(500, "GraphQL mutations must be implemented in JavaScript"); + let n1ql = checkN1QL(fnConfig); + let fieldType = field.type; + if (definition/* isNonNullType */.zM(fieldType)) + fieldType = fieldType.ofType; + let returnsGraphQLList = definition/* isListType */.HG(fieldType); + let returnsGraphQLScalar = definition/* isScalarType */.KA(fieldType); + field.resolve = function (parent, args, context, info) { + allow.authorize(context.user, args); + try { + let result = db.query(context, fnName, n1ql, { args: args, parent: parent }); + if (returnsGraphQLList) { + // Resolver returns a list, so just return the array of rows + return result; + } + else if (result.length == 0) { + return null; + } + else { + // GraphQL result is not a list (array), but N1QL always returns an array. + // So use the first row of the result as the value. + let row = result[0]; + if (!returnsGraphQLScalar) { + return row; + } + else { + // GraphQL result type is a scalar, but a N1QL row is always an object. + // Use the single field of the object, if any, as the result: + let cols = Object.getOwnPropertyNames(row); + if (cols.length == 1) { + return row[cols[0]]; + } + else { + throw new HTTPError(500, `resolver returns scalar type ${field.type}, but its N1QL query returns ${cols.length} columns, not 1`); + } + } + } + } + catch (x) { + rethrow(x, "resolver", fnName); + } + }; + break; + case "javascript": + let code = compileToJS(fnName, fnConfig, 4); + field.resolve = function (source, args, context, info) { + console.debug(`RESOLVE ${fnName}`); + allow.authorize(context.user, args); + if (!mutating) + BeginReadOnly(context); + try { + return code(source, args, context, upgradeInfo(info)); + } + catch (x) { + rethrow(x, "resolver", fnName); + } + finally { + if (!mutating) + EndReadOnly(context); + } + }; + break; + default: + throw new HTTPError(500, `unrecognized 'type' "${fnConfig.type}"`); + } +} +/** Compiles a FunctionConfig to a GraphQL type-name (interface) resolver. */ +function CompileTypeNameResolver(typeName, fnConfig, db) { + let fnName = `${typeName}.__typename`; + if (fnConfig.type != "javascript") { + throw new HTTPError(500, `a GraphQL '__typename' resolver must be JavaScript`); + } + else if (fnConfig.allow !== undefined) { + throw new HTTPError(500, `'allow' is not valid in a GraphQL '__typename' resolver`); + } + let fn = compileToJS(fnName, fnConfig, 4); + return (value, context, info) => { + return fn(context, value, info); + }; +} +/** Compiles a FunctionConfig to a GraphQL Subgraph `_resolveReference` resolver. */ +function CompileEntityReferenceResolver(typeName, fnConfig, db) { + let fnName = `${typeName}._resolveReference`; + if (fnConfig.type != "javascript") { + throw new HTTPError(500, `entity reference resolvers must be implemented in JavaScript`); + } + else if (fnConfig.allow !== undefined) { + throw new HTTPError(500, `entity reference resolver must not have an 'allow' config`); + } + let code = compileToJS(fnName, fnConfig, 3); + return function (ref, context, info) { + return code(context, ref, info); // Apollo's library has the params swapped + }; +} +// Compiles FunctionConfig.code to JavaScript if it's a string, and checks parameter count. +function compileToJS(name, fnConfig, nArgs) { + // http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval! + let fn; + try { + fn = Function(`"use strict"; return (${fnConfig.code})`)(); + } + catch (x) { + throw new HTTPError(500, `failed to compile: ${x}`); + } + if (typeof (fn) !== 'function') { + throw new HTTPError(500, `code does not compile to a JS function`); + } + else if (fn.length < 2 || fn.length > nArgs) { + throw new HTTPError(500, `should have 2-${nArgs} JavaScript arguments`); + } + return fn; +} +function upgradeInfo(info) { + function selectedFieldNames() { + let result = []; + if (this.fieldNodes.length > 0) { + let set = this.fieldNodes[0].selectionSet; + if (set) { + for (let sel of set.selections) { + if (sel.kind == "Field" && sel.name.kind == "Name") { + result.push(sel.name.value); + } + } + } + } + return result; + } + Object.defineProperty(info, "selectedFieldNames", { get: selectedFieldNames }); + return info; +} + +// EXTERNAL MODULE: ./node_modules/graphql/language/parser.mjs +var parser = __webpack_require__(4275); +// EXTERNAL MODULE: ./node_modules/graphql/utilities/buildASTSchema.mjs +var buildASTSchema = __webpack_require__(6535); +// EXTERNAL MODULE: ./node_modules/graphql/graphql.mjs +var graphql = __webpack_require__(2244); +// EXTERNAL MODULE: ./node_modules/@apollo/subgraph/dist/index.js +var dist = __webpack_require__(4903); +;// CONCATENATED MODULE: ./src/impl.ts +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + + + + +//////// DATABASE IMPLEMENTATION +// https://www.apollographql.com/docs/federation/building-supergraphs/subgraphs-apollo-server/ +const kFederationImportsStr = ` + extend schema @link( + url: "https://specs.apollo.dev/federation/v2.0", + import: ["@extends", "@external", "@inaccessible", "@key", "@override", "@provides", + "@requires", "@shareable", "@tag"] + ) +`; +/** Constructs a Database instance. */ +function MakeDatabase(functions, graphql, upstream) { + let db; + db = new DatabaseImpl(upstream); + let errors = db.configure(functions, graphql); + if (errors) + db = null; + return [db, errors]; +} +class DatabaseImpl { + constructor(upstream) { + this.upstream = upstream; + this.functions = {}; // Compiled JS functions + // Create a context for "context.admin" + let superUser = new UserImpl(this, null, true); + this.superUserContext = new ContextImpl(superUser, superUser, true); + superUser.context = this.superUserContext; + } + configure(functions, graphql) { + // Collect all errors/exceptions in an array to return at the end: + let errors = new ErrorList; + console.log("Initializing GraphQL/functions..."); + if (functions) { + let nFuncs = 0; + let maxSize = functions.max_code_size; + for (let fnName of Object.getOwnPropertyNames(functions.definitions)) { + let fnConfig = functions.definitions[fnName]; + if (maxSize !== undefined && fnConfig.code.length > maxSize) { + errors.complain(`function ${fnName}: code is too large (> ${maxSize} bytes)`); + } + else { + errors.try(`function ${fnName}: `, () => { + this.functions[fnName] = CompileFn(fnName, fnConfig, this); + ++nFuncs; + }); + } + } + if (functions.max_function_count !== undefined && nFuncs > functions.max_function_count) { + errors.complain(`too many functions (> ${functions.max_function_count})`); + } + } + if (graphql) { + if (!graphql.schema) { + errors.complain("GraphQL schema is missing"); + } + else if (graphql.max_schema_size !== undefined && graphql.schema.length > graphql.max_schema_size) { + errors.complain(`GraphQL schema too large (> ${graphql.max_schema_size} bytes)`); + } + else { + errors.try(`GraphQL schema: `, () => { + if (graphql.subgraph) { + // Prepend the required "extend schema..." declaration: + let document = parser/* parse */.Qc(kFederationImportsStr + "\n\n" + graphql.schema); + // Create a map with just the __resolveReference resolver fns, so the + // subgraph code can store them in the schema: + let resolvers = this.createApolloResolverMap(graphql, errors); + this.schema = (0,dist/* buildSubgraphSchema */.en)({ typeDefs: document, + resolvers: resolvers }); + } + else { + this.schema = buildASTSchema/* buildSchema */.I(graphql.schema); + } + }); + if (this.schema) { + this.configureResolvers(graphql, errors); + if (errors.errors.length == 0) + this.verifyResolversExist(errors); + } + } + } + if (errors.errors.length > 0) { + console.error(`Found ${errors.errors.length} error[s] in configuration!`); + return errors.errors; + } + return null; + } + configureResolvers(graphql, errors) { + let remainingResolvers = graphql.max_resolver_count ?? 1e9; + if (!graphql.resolvers) + return; + function canAddResolver(typeName, fieldName, config) { + if (remainingResolvers-- == 0) { + errors.complain(`too many GraphQL resolvers (> ${graphql.max_resolver_count})`); + return false; + } + let maxSize = graphql.max_code_size; + if (maxSize !== undefined && config.code.length > maxSize) { + errors.complain(`GraphQL resolver ${typeName}.${fieldName}: code is too large (> ${maxSize} bytes)`); + return false; + } + return true; + } + for (let typeName of Object.getOwnPropertyNames(graphql.resolvers)) { + let fields = graphql.resolvers[typeName]; + let schemaType = this.schema.getType(typeName); + if (!schemaType) { + errors.complain(`GraphQL resolver type '${typeName}': no such type in the schema`); + } + else if (schemaType instanceof definition/* GraphQLObjectType */.h6) { + let schemaFields = schemaType.getFields(); + for (let fieldName of Object.getOwnPropertyNames(fields)) { + let fnConfig = fields[fieldName]; + if (canAddResolver(typeName, fieldName, fnConfig)) { + if (graphql.subgraph && fieldName == '__resolveReference') + continue; + let schemaField = schemaFields[fieldName]; + if (schemaField) { + errors.try(`GraphQL resolver ${typeName}.${fieldName}: `, () => { + CompileResolver(schemaField, typeName, fieldName, fnConfig, this); + console.debug(`Compiled GraphQL resolver ${typeName}.${fieldName}`); + }); + } + else { + errors.complain(`GraphQL resolver ${typeName}.${fieldName}: no such field in the schema`); + } + } + } + } + else if (schemaType instanceof definition/* GraphQLInterfaceType */.oW + || schemaType instanceof definition/* GraphQLUnionType */.Gp) { + let ifType = schemaType; + for (let fieldName of Object.getOwnPropertyNames(fields)) { + let fnConfig = fields[fieldName]; + if (canAddResolver(typeName, fieldName, fnConfig)) { + if (fieldName == "__typename") { + errors.try(`GraphQL resolver ${typeName}.__typename: `, () => { + ifType.resolveType = CompileTypeNameResolver(typeName, fnConfig, this); + console.debug(`Compiled GraphQL resolver ${typeName}.__typename`); + }); + } + else { + errors.complain(`GraphQL resolver ${typeName}.${fieldName}: abstract types may only have a '__typename' resolver`); + } + } + } + } + else { + errors.complain(`GraphQL type ${typeName}: not an object or interface, so cannot have resolvers`); + } + } + } + verifyResolversExist(errors) { + let queryType = this.schema.getQueryType(); + let mutationType = this.schema.getMutationType(); + const typeMap = this.schema.getTypeMap(); + for (const typeName of Object.getOwnPropertyNames(typeMap)) { + const schemaType = typeMap[typeName]; + if (schemaType == queryType || schemaType == mutationType) { + const fields = schemaType.getFields(); + for (let fieldName of Object.getOwnPropertyNames(fields)) { + if (!fields[fieldName].resolve) + errors.complain(`GraphQL resolver ${typeName}.${fieldName}: missing function definition`); + } + } + else if (schemaType instanceof definition/* GraphQLInterfaceType */.oW + || schemaType instanceof definition/* GraphQLUnionType */.Gp) { + if (!schemaType.resolveType) + errors.complain(`GraphQL resolver ${typeName}.__typename: missing function definition`); + } + } + } + createApolloResolverMap(graphql, errors) { + let result = {}; + for (let [typeName, resolvers] of Object.entries(graphql.resolvers)) { + let resolveRef = resolvers['__resolveReference']; + if (resolveRef) { + let resolverFn = CompileEntityReferenceResolver(typeName, resolveRef, this); + result[typeName] = { + '__resolveReference': resolverFn + }; + } + } + return result; + } + makeContext(credentials, mutationAllowed) { + let user = new UserImpl(this, credentials); + let ctx = new ContextImpl(user, this.superUserContext.user, mutationAllowed); + user.context = ctx; + return ctx; + } + getFunction(name) { + let fn = this.functions[name]; + if (!fn) + throw new HTTPError(404, `No such function ${name}`); + return fn; + } + callFunction(context, name, args) { + console.debug(`>>> FUNCTION ${name}`); + return this.getFunction(name)(context, args); + } + query(context, fnName, n1ql, args) { + console.debug(`>>> N1QL ${n1ql}`); + return this.upstream.query(fnName, n1ql, args, context.user); + } + graphql(context, query, variableValues, operationName) { + console.debug(`>>> GRAPHQL ${query}`); + if (!this.schema) + throw new HTTPError(404, "No GraphQL schema"); + return graphql/* graphql */.B({ + contextValue: context, + schema: this.schema, + source: query, + variableValues: variableValues, + operationName: operationName, + }); + } + get(docID, collection, user) { + return this.upstream.get(docID, collection, user); + } + save(doc, docID, collection, user) { + return this.upstream.save(doc, docID, collection, user); + } + delete(docID, revID, collection, user) { + return this.upstream.delete(docID, revID, collection, user); + } +} +//////// CONTEXT IMPLEMENTATION +class ContextImpl { + constructor(user, admin, mutationAllowed) { + this.user = user; + this.admin = admin; + this.readOnlyLevel = 0; + if (!mutationAllowed) { + this.readOnlyLevel++; + } + } + checkUser(name) { + return this.user.isAdmin || match(name, this.user.name); + } + requireUser(name) { + if (!this.checkUser(name)) + this.permissionDenied("user"); + } + checkAdmin() { + return this.user.isAdmin; + } + requireAdmin() { + if (!this.checkAdmin()) + this.permissionDenied("admin only"); + } + checkRole(role) { + if (this.user.isAdmin) + return true; + for (let myRole of this.user.roles) { + if (match(role, myRole)) + return true; + } + return false; + } + requireRole(role) { + if (!this.checkRole(role)) + this.permissionDenied("role"); + } + checkAccess(channel) { + if (this.user.isAdmin) + return true; + for (let myChannel of this.user.channels) { + if (match(channel, myChannel)) + return true; + } + return false; + } + requireAccess(channel) { + if (!this.checkAccess(channel)) + this.permissionDenied("channel"); + } + checkAllowed(allow) { + return this.user.isAdmin + || (allow !== undefined && ((allow.users !== undefined && allow.users.includes(this.user.name)) || + (allow.roles !== undefined && this.checkRole(allow.roles)) || + (allow.channels !== undefined && this.checkAccess(allow.channels)))); + } + requireAllowed(allow) { + if (!this.checkAllowed(allow)) + this.permissionDenied(); + } + checkMutating() { + return this.readOnlyLevel == 0; + } + requireMutating() { + if (!this.checkMutating()) + throw new HTTPError(403, "Permission denied (read-only context)"); + } + permissionDenied(message = "") { + if (message) + message = ` (${message})`; + if (this.user.isGuest) { + throw new HTTPError(401, "Login required" + message); + } + else { + throw new HTTPError(403, "Permission denied" + message); + } + } +} +function BeginReadOnly(context) { + if (!context.user.isSuperUser) { + context.readOnlyLevel++; + } + console.debug(`++++ BeginReadOnly; now ${context.readOnlyLevel}`); +} +function EndReadOnly(context) { + if (!context.user.isSuperUser) { + context.readOnlyLevel--; + } + console.debug(`---- EndReadOnly; now ${context.readOnlyLevel}`); +} +//////// CRUD IMPLEMENTATION +class CRUDImpl { + constructor(db, collection, user) { + this.db = db; + this.collection = collection; + this.user = user; + } + get(docID) { + return this.db.get(docID, this.collection, this.user); + } + save(doc, docID) { + if (!this.user.canMutate) + throw new HTTPError(403, "save() is not allowed in a read-only context"); + return this.db.save(doc, docID, this.collection, this.user); + } + delete(docOrID) { + if (!this.user.canMutate) + throw new HTTPError(403, "delete() is not allowed in a read-only context"); + if (typeof docOrID === 'string') { + return this.db.delete(docOrID, undefined, this.collection, this.user); + } + else { + let id = docOrID['_id']; + if (!id) + throw "delete() called with doc object that has no '_id' property"; + return this.db.delete(id, docOrID._rev, this.collection, this.user); + } + } +} +//////// USER IMPLEMENTATION +let CallDepth = 1; +const MaxCallDepth = 20; +function ClearCallDepth() { CallDepth = 1; } +class UserImpl { + constructor(db, credentials, isSuperUser = false) { + this.db = db; + this.isSuperUser = isSuperUser; + if (credentials) { + [this.name, this.roles, this.channels] = credentials; + isSuperUser = false; + } + this.defaultCollection = new CRUDImpl(db, '_default', this); + } + get isGuest() { return this.name === ""; } + get isAdmin() { return this.name === undefined; } + get canMutate() { return this.isSuperUser || this.context.checkMutating(); } + collection(name) { + return new CRUDImpl(this.db, name, this); + } + function(name, args) { + let fn = this.db.getFunction(name); + if (++CallDepth > MaxCallDepth) { + --CallDepth; + let msg = `User function recursion too deep (calling function("${name}")`; + console.error(msg); + throw new HTTPError(508, msg); + } + try { + return fn(this.context, args); + } + finally { + --CallDepth; + } + } + async graphql(query, args) { + if (++CallDepth > MaxCallDepth) { + --CallDepth; + let msg = `User function recursion too deep (calling graphql())`; + console.error(msg); + throw new HTTPError(508, msg); + } + try { + let result = await this.db.graphql(this.context, query, args); + if (result.errors) { + let err = result.errors[0]; + if (err.originalError) + throw err.originalError; + throw Error(err.message); + } + if (result.data === undefined) + return null; + return result.data; + } + finally { + --CallDepth; + } + } + toJSON(key) { + if (this.isAdmin) { + return {}; + } + else { + return { + name: this.name, + roles: this.roles, + channels: this.channels + }; + } + } +} +; +//////// UTILITIES: +/** Utility that collects a list of error messages. */ +class ErrorList { + constructor() { + this.errors = []; + } + /** adds an error message to `errors`. */ + complain(msg) { + console.error(msg); + this.errors.push(msg); + } + /** calls a function, catching any exception and adding it to `errors`. */ + try(msg, fn) { + try { + fn(); + } + catch (err) { + if (err instanceof Error) { + msg += err.message; + } + else { + msg += String(err); + } + this.complain(msg); + } + } + ; +} +// Returns true if `what` is equal to `against` or included in it. +function match(what, against) { + if (typeof (what) === 'string') { + return (what == against); + } + else { + return what.includes(against); + } +} + +;// CONCATENATED MODULE: ./src/api.ts +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +// Wraps a `NativeAPI` and exposes it as an Upstream for a Database to use +class UpstreamNativeImpl { + constructor(native) { + this.native = native; + } + query(fnName, n1ql, args, user) { + let result = this.native.query(fnName, n1ql, this.stringify(args), user.isAdmin); + return JSON.parse(result); + } + get(docID, collection, user) { + let jresult = this.native.get(docID, collection, user.isAdmin); + if (jresult === null) + return jresult; + return this.parseDoc(jresult); + } + save(doc, docID, collection, user) { + return this.native.save(JSON.stringify(doc), docID, collection, user.isAdmin); + } + delete(docID, revID, collection, user) { + return this.native.delete(docID, revID, collection, user.isAdmin); + } + stringify(obj) { + return obj ? JSON.stringify(obj) : undefined; + } + parseDoc(json) { + let result = JSON.parse(json); + if (typeof (result) !== "object") + throw Error("NativeAPI returned JSON that's not an Object"); + return result; + } +} +/** The API this module implements, and the native code (evaluator.go) calls. */ +class API { + /** Constructs an instance and parses the configuration. + * Should not throw exceptions, but sets the `errors` property if config is invalid. + */ + constructor(configJSON, native) { + let config = JSON.parse(configJSON); + let [db, errors] = MakeDatabase(config.functions, config.graphql, new UpstreamNativeImpl(native)); + if (db !== null) + this.db = db; + this.errors = errors; + } + /** Calls a named function. */ + callFunction(name, argsJSON, user, roles, channels, mutationAllowed) { + let args = argsJSON ? JSON.parse(argsJSON) : undefined; + let context = this.makeContext(user, roles, channels, mutationAllowed); + ClearCallDepth(); + let result = this.db.callFunction(context, name, args); + if (result instanceof Promise) { + return result.then(result => JSON.stringify(result)); + } + else { + return JSON.stringify(result); + } + } + /** Runs a GraphQL query. */ + graphql(query, operationName, variablesJSON, user, roles, channels, mutationAllowed) { + if (operationName === "") + operationName = undefined; + let vars = variablesJSON ? JSON.parse(variablesJSON) : undefined; + let context = this.makeContext(user, roles, channels, mutationAllowed); + ClearCallDepth(); + return this.db.graphql(context, query, vars, operationName) + .then(result => JSON.stringify(result)); + } + makeContext(user, roles, channels, mutationAllowed) { + var credentials = null; + if (user !== undefined) { + credentials = [user, + roles?.split(',') ?? [], + channels?.split(',') ?? []]; + } + return this.db.makeContext(credentials, mutationAllowed); + } +} +; +/** Main entry point, called by Go `NewEvaluator()`. */ +function main(configJSON, native) { + return new API(configJSON, native); +} + +})(); + +SG_Engine = __webpack_exports__; +/******/ })() +; +//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7QUFBYTtBQUNiLDhDQUE2QyxFQUFFLGFBQWEsRUFBQztBQUM3RCw0QkFBNEIsR0FBRyxpQ0FBaUM7QUFDaEU7QUFDQTtBQUNBO0FBQ0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1dGFibGUgZGVmaW5pdGlvbiBmb3VuZCB3aGlsZSBidWlsZGluZyBzY2hlbWFcIiwgeyBub2RlczogZGVmaW5pdGlvbk5vZGUgfSkpO1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgY2FzZSAnU2NoZW1hRGVmaW5pdGlvbic6XG4gICAgICAgICAgICAgICAgc2NoZW1hRGVmaW5pdGlvbnMucHVzaChkZWZpbml0aW9uTm9kZSk7XG4gICAgICAgICAgICAgICAgc2NoZW1hLnNjaGVtYURlZmluaXRpb24ucHJlc2VydmVFbXB0eURlZmluaXRpb24gPSB0cnVlO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAnU2NoZW1hRXh0ZW5zaW9uJzpcbiAgICAgICAgICAgICAgICBzY2hlbWFFeHRlbnNpb25zLnB1c2goZGVmaW5pdGlvbk5vZGUpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAnU2NhbGFyVHlwZURlZmluaXRpb24nOlxuICAgICAgICAgICAgY2FzZSAnT2JqZWN0VHlwZURlZmluaXRpb24nOlxuICAgICAgICAgICAgY2FzZSAnSW50ZXJmYWNlVHlwZURlZmluaXRpb24nOlxuICAgICAgICAgICAgY2FzZSAnVW5pb25UeXBlRGVmaW5pdGlvbic6XG4gICAgICAgICAgICBjYXNlICdFbnVtVHlwZURlZmluaXRpb24nOlxuICAgICAgICAgICAgY2FzZSAnSW5wdXRPYmplY3RUeXBlRGVmaW5pdGlvbic6XG4gICAgICAgICAgICAgICAgdHlwZURlZmluaXRpb25zLnB1c2goZGVmaW5pdGlvbk5vZGUpO1xuICAgICAgICAgICAgICAgIGxldCB0eXBlID0gc2NoZW1hLnR5cGUoZGVmaW5pdGlvbk5vZGUubmFtZS52YWx1ZSk7XG4gICAgICAgICAgICAgICAgaWYgKCF0eXBlIHx8IHR5cGUuaXNCdWlsdEluKSB7XG4gICAgICAgICAgICAgICAgICAgI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lzdGluZykge1xuICAgICAgICAgICAgICAgICAgICBzY2hlbWEuYWRkVHlwZSgoMCwgZGVmaW5pdGlvbnNfMS5uZXdOYW1lZFR5cGUpKHdpdGhvdXRUcmFpbGluZ0RlZmluaXRpb24oZGVmaW5pdGlvbk5vZGUua2luZCksIGRlZmluaXRpb25Ob2RlLm5hbWUudmFsdWUpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZiAoZXhpc3RpbmcuaXNCdWlsdEluKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IGVycm9yXzEuRVJST1JTLklOVkFMSURfR1JBUEhRTC5lcnIoYENhbm5vdCBleHRlbmQgYnVpbHQtaW4gdHlwZSBcIiR7ZGVmaW5pdGlvbk5vZGUubmFtZS52YWx1ZX1cImApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgIGNhc2UgJ0RpcmVjdGl2ZURlZmluaXRpb24nOlxuICAgICAgICAgICAgICAgIGRpcmVjdGl2ZURlZmluaXRpb25zLnB1c2goZGVmaW5pdGlvbk5vZGUpO1xuICAgICAgICAgICAgICAgIHNjaGVtYS5hZGREaXJlY3RpdmVEZWZpbml0aW9uKGRlZmluaXRpb25Ob2RlLm5hbWUudmFsdWUpO1xuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICB9XG4gICAgfVxuICAgIHJldHVybiB7XG4gICAgICAgIGRpcmVjdGl2ZURlZmluaXRpb25zLFxuICAgICAgICB0eXBlRGVmaW5pdGlvbnMsXG4gICAgICAgIHR5cGVFeHRlbnNpb25zLFxuICAgICAgICBzY2hlbWFEZWZpbml0aW9ucyxcbiAgICAgICAgc2NoZW1hRXh0ZW5zaW9ucyxcbiAgICB9O1xufVxuZnVuY3Rpb24gd2l0aG91dFRyYWlsaW5nRGVmaW5pdGlvbihzdHIpIHtcbiAgICBjb25zdCBlbmRTdHJpbmcgPSBzdHIuZW5kc1dpdGgo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ZVR5cGVFeHRlbnNpb24nOlxuICAgICAgICAgICAgY29uc3QgZmllbGRCYXNlZFR5cGUgPSB0eXBlO1xuICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZE5vZGUgb2YgKF9iID0gZGVmaW5pdGlvbk5vZGUuZmllbGRzKSAhPT0gbnVsbCAmJiBfYiAhPT0gdm9pZCAwID8gX2IgOiBbXSkge1xuICAgICAgICAgICAgICAgIGlmIChibHVlcHJpbnQuaWdub3JlUGFyc2VkRmllbGQodHlwZSwgZmllbGROb2RlLm5hbWUudmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zdCBmaWVsZCA9IGZpZWxkQmFzZWRUeXBlLmFkZEZpZWxkKGZpZWxkTm9kZS5uYW1lLnZhbHVlKTtcbiAgICAgICAgICAgICAgICBmaWVsZC5zZXRPZkV4dGVuc2lvbihleHRlbnNpb24pO1xuICAgICAgICAgICAgICAgIGJ1aWxkRmllbGREZWZpbml0aW9uSW5uZXIoZmllbGROb2RlLCBmaWVsZCwgZXJyb3JzKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGZvciAoY29uc3QgaXRmTm9kZSBvZiAoX2MgPSBkZWZpbml0aW9uTm9kZS5pbnRlcmZhY2VzKSAhPT0gbnVsbCAmJiBfYyAhPT0gdm9pZCAwID8gX2MgOiBbXSkge1xuICAgICAgICAgICAgICAgIHdpdGhOb2RlQXR0YWNoZWRUb0Vycm9yKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgaXRmTmFtZSA9IGl0Zk5vZGUubmFtZS52YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkQmFzZWRUeXBlLmltcGxlbWVudHNJbnRlcmZhY2UoaXRmTmFtZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IGVycm9yXzEuRVJST1JTLklOVkFMSURfR1JBUEhRTC5lcnIoYFR5cGUgXCIke3R5cGV9XCIgY2FuIG9ubHkgaW1wbGVtZW50IFwiJHtpdGZOYW1lfVwiIG9uY2UuYCk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZmllbGRCYXNlZFR5cGUuYWRkSW1wbGVtZW50ZWRJbnRlcmZhY2UoaXRmTmFtZSkuc2V0T2ZFeHRlbnNpb24oZXh0ZW5zaW9uKTtcbiAgICAgICAgICAgICAgICB9LCBpdGZOb2RlLCBlcnJvcnMpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgJ1VuaW9uVHlwZURlZmluaXRpb24nOlxuICAgICAgICBjYXNlICdVbmlvblR5cGVFeHRlbnNpb24nOlxuICAgICAgICAgICAgY29uc3QgdW5pb25UeXBlID0gdHlwZTtcbiAgICAgICAgICAgIGZvciAoY29uc3QgbmFtZWRUeXBlIG9mIChfZCA9IGRlZmluaXRpb25Ob2RlLnR5cGVzKSAhPT0gbnVsbCAmJiBfZCAhPT0gdm9pZCAwID8gX2QgOiBbXSkge1xuICAgICAgICAgICAgICAgIHdpdGhOb2RlQXR0YWNoZWRUb0Vycm9yKCgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IG5hbWVkVHlwZS5uYW1lLnZhbHVlO1xuICAgICAgICAgICAgICAgICAgICBpZiAodW5pb25UeXBlLmhhc1R5cGVNZW1iZXIobmFtZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IGVycm9yXzEuRVJST1JTLklOVkFMSURfR1JBUEhRTC5lcnIoYFVuaW9uIHR5cGUgXCIke3VuaW9uVHlwZX1cIiBjYW4gb25seSBpbmNsdWRlIHR5cGUgXCIke25hbWV9XCIgb25jZS5gKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB1bmlvblR5cGUuYWRkVHlwZShuYW1lKS5zZXRPZkV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IsIGFzOiBcIjxhbGlhcz5cIiB9LmAsIHsgbm9kZXM6IGRpcmVjdGl2ZS5zb3VyY2VBU1QgfSkpO1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgIH1cbiAgICAgICAgbGV0IG5hbWU7XG4gICAgICAgIGZvciAoY29uc3QgW2tleSwgdmFsdWVdIG9mIE9iamVjdC5lbnRyaWVzKGVsdCkpIHtcbiAgICAgICAgICAgIHN3aXRjaCAoa2V5KSB7XG4gICAgICAgICAgICAgICAgY2FzZSAnbmFtZSc6XG4gICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgdmFsdWUgIT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMucHVzaChlcnJvcl8xLkVSUk9SUy5JTlZBTElEX0xJTktfRElSRUNUSVZFX1VTQUdFLmVycihgSW52YWxpZCB2YWx1ZSBmb3IgdGhlIFwibmFtZVwiIGZpZWxkIGZvciBzdWItdmFsdWUgJHsoMCwgdmFsdWVzXzEudmFsdWVUb1N0cmluZykoZWx0KX0gb2YgQGxpbmsoaW1wb3J0OikgYXJndW1lbnQ6IG11c3QgYmUgYSBzdHJpbmcuYCwgeyBub2RlczogZGlyZWN0aXZlLnNvdXJjZUFTVCB9KSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZSBpbXBvcnRBcmdMb29wO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIG5hbWUgPSB2YWx1ZTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgY2FzZSAnYXMnOlxuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHZhbHVlICE9PSAnc3RyaW5nJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzLnB1c2goZXJyb3JfMS5FUlJPUlMuSU5WQUxJRF9MSU5LX0RJUkVDVElWRV9VU0FHRS5lcnIoYEludmFsaWQgdmFsdWUgZm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xcbiAgICAgICAgICAgICAgICBuYW1lSW5GZWF0dXJlOiBzcGxpdHRlZFsxXSxcbiAgICAgICAgICAgICAgICBpc0ltcG9ydGVkOiBmYWxzZSxcbiAgICAgICAgICAgIH0gOiB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBjb25zdCBkaXJlY3RGZWF0dXJlID0gdGhpcy5ieUFsaWFzLmdldChlbGVtZW50Lm5hbWUpO1xuICAgICAgICAgICAgaWYgKGRpcmVjdEZlYXR1cmUgJiYgaXNEaXJlY3RpdmUpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICBmZWF0dXJlOiBkaXJlY3RGZWF0dXJlLFxuICAgICAgICAgICAgICAgICAgICBuYW1lSW5GZWF0dXJlOiAoX2IgPSAoX2EgPSBkaXJlY3RGZWF0dXJlLmltcG9ydHMuZmluZChpbXAgPT4gaW1wLmFzID09PSBgQCR7ZWxlbWVudC5uYW1lfWApKSA9PT0gbnVsbCB8fCBfYSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2EubmFtZS5zbGljZSgxKSkgIT09IG51bGwgJiYgX2IgIT09IHZvaWQgMCA/IF9iIDogZWxlbWVudC5uYW1lLFxuICAgICAgICAgICAgICAgICAgICBpc0ltcG9ydGVkOiB0cnVlLFxuICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb25zdCBpbXBvcnROYW1lID0gaXNEaXJlY3RpdmUgPyAnQCcgKyBlbGVtZW50Lm5hbWUgOiBlbGVtZW50Lm5hbWU7XG4gICAgICAgICAgICBjb25zdCBhbGxGZWF0dXJlcyA9IFt0aGlzLmNvcmVJdHNlbGYsIC4uLnRoaXMuYnlJZGVudGl0eS52YWx1ZXMoKV07XG4gICAgICAgICAgICBmb3IgKGNvbnN0IGZlYXR1cmUgb2YgYWxsRmVhdHVyZXMpIHtcbiAgICAgICAgICAgICAgICBmb3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gYXBpU2NoZW1hO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB0aGlzLmFwaVNjaGVtYTtcbiAgICB9XG4gICAgZW1wdHlBU1REZWZpbml0aW9uc0ZvckV4dGVuc2lvbnNXaXRob3V0RGVmaW5pdGlvbigpIHtcbiAgICAgICAgY29uc3Qgbm9kZXMgPSBbXTtcbiAgICAgICAgaWYgKHRoaXMuc2NoZW1hRGVmaW5pdGlvbi5oYXNFeHRlbnNpb25FbGVtZW50cygpICYmICF0aGlzLnNjaGVtYURlZmluaXRpb24uaGFzTm9uRXh0ZW5zaW9uRWxlbWVudHMoKSkge1xuICAgICAgICAgICAgY29uc3Qgbm9kZSA9IHsga2luZDogZ3JhcGhxbF8xLktpbmQuU0NIRU1BX0RFRklOSVRJT04sIG9wZXJhdGlvblR5cGVzOiBbXSB9O1xuICAgICAgICAgICAgbm9kZXMucHVzaChub2RlKTtcbiAgICAgICAgfVxuICAgICAgICBmb3IgKGNvbnN0IHR5cGUgb2YgdGhpcy50eXBlcygpKSB7XG4gICAgICAgICAgICBpZiAodHlwZS5oYXNFeHRlbnNpb25FbGVtZW50cygpICYmICF0eXBlLmhhc05vbkV4dGVuc2lvbkVsZW1lbnRzKCkpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBub2RlID0ge1xuICAgICAgICAgICAgICAgICAgICBraW5kOiB0eXBlLmFzdERlZmluaXRpb25LaW5kLFxuICAgICAgICAgICAgICAgICAgICBuYW1lOiB7IGtpbmQ6IGdyYXBocWxfMS5LaW5kLk5BTUUsIHZhbHVlOiB0eXBlLm5hbWUgfSxcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIG5vZGVzLnB1c2gobm9kZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG5vZGVzO1xuICAgIH1cbiAgICB0b0dyYXBoUUxKU1NjaGVtYShjb25maWcpIHtcbiAgICAgICAgdmFyIF9hLCBfYjtcbiAgICAgICAgY29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AgICAgY29uc3QgZ3JhcGhRTFNjaGVtYSA9ICgwLCBncmFwaHFsXzEuYnVpbGRBU1RTY2hlbWEpKGFzdCk7XG4gICAgICAgIGlmIChhZGRpdGlvbmFsTm9kZXMubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgZm9yIChjb25zdCBub2RlIG9mIGFkZGl0aW9uYWxOb2Rlcykge1xuICAgICAgICAgICAgICAgIHN3aXRjaCAobm9kZS5raW5kKSB7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgZ3JhcGhxbF8xLktpbmQuU0NIRU1BX0RFRklOSVRJT046XG4gICAgICAgICAgICAgICAgICAgICAgICBncmFwaFFMU2NoZW1hLmFzdE5vZGUgPSB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBncmFwaHFsXzEuS2luZC5TQ0FMQVJfVFlQRV9ERUZJTklUSU9OOlxuICAgICAgICAgICAgICAgICAgICBjYXNlIGdyYXBocWxfMS5LaW5kLk9CSkVDVF9UWVBFX0RFRklOSVRJT046XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgZ3JhcGhxbF8xLktpbmQuSU5URVJGQUNFX1RZUEVfREVGSU5JVElPTjpcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBncmFwaHFsXzEuS2luZC5FTlVNX1RZUEVfREVGSU5JVElPTjpcbiAgICAgICAgICAgICAgICAgICAgY2FzZSBncmFwaHFsXzEuS2luZC5VTklPTl9UWVBFX0RFRklOSVRJT046XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgZ3JhcGhxbF8xLktpbmQuSU5QVVRfT0JKRUNUX1RZUEVfREVGSU5JVElPTjpcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBncmFwaFFMU2NoZW1hLmdldFR5cGUobm9kZS5uYW1lLnZhbHVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZS5hc3ROb2RlID0gdW5kZWZpbmVkO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gZ3JhcGhRTFNjaGVtYTtcbiAgICB9XG4gICAgZ2V0IHNjaGVtYURlZmluaXRpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9zY2hlbWFEZWZpbml0aW9uO1xuICAgIH1cbiAgICB0eXBlcygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3R5cGVzLnZhbHVlcygpO1xuICAgIH1cbiAgICBpbnRlcmZhY2VUeXBlcygpIHtcbiAgICAgICAgcmV0dXJuIGZpbHRlclR5cGVzT2ZLaW5kKHRoaXMudHlwZXMoKSwgJ0ludGVyZmFjZVR5cGUnKTtcbiAgICB9XG4gICAgb2JqZWN0VHlwZXMoKSB7XG4gICAgICAgIHJldHVybiBmaWx0ZXJUeXBlc09mS2luZCh0aGlzLnR5cGVzKCksICdPYmplY3RUeXBlJyk7XG4gICAgfVxuICAgIHVuaW9uVHlwZXMoKSB7XG4gICAgICAgIHJldHVybiBmaWx0ZXJUeXBlc09mS2luZCh0aGlzLnR5cGVzKCksICdVbmlvblR5cGUnKTtcbiAgICB9XG4gICAgc2NhbGFyVHlwZXMoKSB7XG4gICAgICAgIHJldHVybiBmaWx0ZXJUeXBlc09mS2luZCh0aGlzLnR5cGVzKCksICdTY2FsYXJUeXBlJyk7XG4gICAgfVxuICAgIGlucHV0VHlwZXMoKSB7XG4gICAgICAgIHJldHVybiBmaWx0ZXJUeXBlc09mS2luZCh0aGlzLnR5cGVzKCksICdJbnB1dE9iamVjdFR5cGUnKTtcbiAgICB9XG4gICAgZW51bVR5cGVzKCkge1xuICAgICAgICByZXR1cm4gZmlsdGVyVHlwZXNPZktpbmQodGhpcy50eXBlcygpLCAnRW51bVR5cGUnKTtcbiAgICB9XG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iJHtjb29yZGluYXRlfTogaXQgaXMgbm90IGEgc3ludGFjdGljYWxseSB2YWxpZCBncmFwaFFMIGNvb3JkaW5hdGUuXCJgKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHlwZS5maWVsZChmaWVsZE9yRW51bU5hbWUpO1xuICAgICAgICAgICAgICAgIGNhc2UgJ0VudW1UeXBlJzpcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ05hbWUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHRocm93IGVycm9yXzEuRVJST1JTLklOVkFMSURfR1JBUEhRTC5lcnIoYEludmFsaWQgYXJndW1lbnQgXCIke2Nvb3JkaW5hdGV9OiBpdCBpcyBub3QgYSBzeW50YWN0aWNhbGx5IHZhbGlkIGdyYXBoUUwgY29vcmRpbmF0ZS5cImApO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB0eXBlLnZhbHVlKGZpZWxkT3JFbnVtTmFtZSk7XG4gICAgICAgICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgZXJyb3JfMS5FUlJPUlMuSU5WQUxJRF9HUkFQSFFMLmVycihgSW52YWxpZCBhcmd1bWVudCBcIiR7Y29vcmRpbmF0ZX06IGl0IGlzIG5vdCBhIHN5bnRhY3RpY2FsbHkgdmFsaWQgZ3JhcGhRTCBjb29yZGluYXRlLlwiYCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59XG5leHBvcnRzLlNjaGVtYSA9IFNjaGVtYTtcbmNsYXNzIFJvb3RUeXBlIGV4dGVuZHMgQmFzZUV4dGVuc2lvbk1lbWJlciB7XG4gICAgY29uc3RydWN0b3Iocm9vdEtpbmQsIHR5cGUpIHtcbiAgICAgICAgc3VwZXIoKTtcbiAgICAgICAgdGhpcy5yb290S2luZCA9IHJvb3RLaW5kO1xuICAgICAgICB0aGlzL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gIC5maWx0ZXIoKGEpID0+IGEgIT09IGFwcGxpZWQpXG4gICAgICAgICAgICAgICAgLmZvckVhY2goKG90aGVyKSA9PiBDb3JlRmVhdHVyZXMucHJvdG90eXBlWydtYXliZUFkZEZlYXR1cmUnXS5jYWxsKHNjaGVtYS5jb3JlRmVhdHVyZXMsIG90aGVyKSk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoY29yZUZlYXR1cmVzKSB7XG4gICAgICAgICAgICBDb3JlRmVhdHVyZXMucHJvdG90eXBlWydtYXliZUFkZEZlYXR1cmUnXS5jYWxsKGNvcmVGZWF0dXJlcywgYXBwbGllZCk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5vbk1vZGlmaWNhdGlvbigpO1xuICAgICAgICByZXR1cm4gYXBwbGllZDtcbiAgICB9XG4gICAgcm9vdChyb290S2luZCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fcm9vdHMuZ2V0KHJvb3RLaW5kKTtcbiAgICB9XG4gICAgcm9vdFR5cGUocm9vdEtpbmQpIHtcbiAgICAgICAgdmFyIF9hO1xuICAgICAgICByZXR1cm4gKF9hID0gdGhpcy5yb290KHJvb3RLaW5kKSkgPT09IG51bGwgfHwgX2EgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9hLnR5cGU7XG4gICAgfVxuICAgIHNldFJvb3Qocm9vdEtpbmQsIG5hbWVPclR5cGUpIHtcbiAgICAgICAgbGV0IHRvU2V0O1xuICAgICAgICBpZiAodHlwZW9mIG5hbWVPclR5cGUgPT09ICdzdHJpbmcnKSB7XG4gICAgICAgICAgICB0aGlzLmNoZWNrVXBkYXRlKCk7XG4gICAgICAgICAgICBjb25zdCBvYmogPSB0aGlzLnNjaGVtYSgpLnR5cGUobmFtZU9yVHlwZSk7XG4gICAgICAgICAgICBpZiAoIW9iaikge1xuICAgICAgICAgICAgICAgIHRocm93IGVycm9yXzEuRVJST1JTLklOVkFMSURfR1JBUEhRTC5lcnIoYENhbm5vdCBzZ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HJldHVybiB0aGlzLl9tZW1iZXJzLnZhbHVlcygpO1xuICAgIH1cbiAgICBtZW1iZXJzQ291bnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9tZW1iZXJzLnNpemU7XG4gICAgfVxuICAgIGhhc1R5cGVNZW1iZXIodHlwZSkge1xuICAgICAgICByZXR1cm4gdGhpcy5fbWVtYmVycy5oYXModHlwZW9mIHR5cGUgPT09ICdzdHJpbmcnID8gdHlwZSA6IHR5cGUubmFtZSk7XG4gICAgfVxuICAgIGFkZFR5cGUobmFtZU9yVHlwZU9yTWVtYmVyKSB7XG4gICAgICAgIGxldCB0b0FkZDtcbiAgICAgICAgaWYgKG5hbWVPclR5cGVPck1lbWJlciBpbnN0YW5jZW9mIFVuaW9uTWVtYmVyKSB7XG4gICAgICAgICAgICB0aGlzLmNoZWNrVXBkYXRlKG5hbWVPclR5cGVPck1lbWJlcik7XG4gICAgICAgICAgICB0b0FkZCA9IG5hbWVPclR5cGVPck1lbWJlcjtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGxldCBvYmo7XG4gICAgICAgICAgICBpZiAodHlwZW9mIG5hbWVPclR5cGVPck1lbWJlciA9PT0gJ3N0cmluZycpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmNoZWNrVXBkYXRlKCk7XG4gICAgICAgICAgICAgICAgY29uc3QgbWF5YmVPYmogPSB0aGlzLnNjaGVtYSgpLnR5cGUobmFtZU9yVHlwZU9yTWVtYmVyKTtcbiAgICAgICAgICAgICAgICBpZiAoIW1heWJlT2JqKSB7XG4gICAgICAgICAgICAgICAgICAgIHRocm93IGVycm9yXzEuRVJST1JTLklOVkFMSURfR1JBUEhRTC5lcnIoYENhbm5vdCBhZGQgdW5rbm93biB0eXBlICR7bmFtZU9yVHlwZU9yTWVtYmVyfSBhcyBtZW1iZXIgb2YgdW5pb24gdHlwZSAke3RoaXMubmFtZX1gKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZiAobWF5YmVPYmoua2luZCAhPSAnT2JqZWN0VHlwZScpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhyb3cgZXJyb3JfMS5FUlJPUlMuSU5WQUxJRF9HUkFQSFFMLmVycihgQ2Fubm90IGFkZCBub24tb2JqZWN0IHR5cGUgJHtuYW1lT3JUeXBlT3JNZW1iZXJ9IChvZiB0eXBlICR7bWF5YmVPYmoua2luZH0pIGFzIG1lbWJlciBvZiB1bmlvbiB0eXBlICR7dGhpcy5uYW1lfWApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBvYmogPSBtYXliZU9iajtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHRoaXMuY2hlY2tVcGRhdGUobmFtZU9yVHlwZU9yTWVtYmVyKTtcbiAgICAgICAgICAgICAgICBvYmogPSBuYW1lT3JUeXBlT3JNZW1iZXI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICB0b0FkZCA9IG5ldyBVbmlvbk1lbWJlcihvYmopO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGV4aXN0aW5nID0gdGhpcy5fbWVtYmVycy5nZXQodG9BZGQudHlwZS5uYW1lKTtcbiAgICAgICAgaWYgKCFleGlzdGluZykge1xuICAgICAgICAgICAgdGhpcy5fbWVtYmVycy5zZXQodG9BZGQudHlwZS5uYW1lLCB0b0FkZCk7XG4gICAgICAgICAgICBFbGVtZW50LnByb3RvdHlwZVsnc2V0UGFyZW50J10uY2FsbCh0b0FkZCwgdGhpcyk7XG4gICAgICAgICAgICBhZGRSZWZlcmVuY2VUb1R5cGUodGhpcywgdG9BZGQudHlwZSk7XG4gICAgICAgICAgICB0aGlzLm9uTW9kaWZpY2F0aW9uKCk7XG4gICAgICAgICAgICByZXR1cm4gdG9BZGQ7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICByZXR1cm4gZXhpc3Rpbmc7XG4gICAgICAgIH1cbiAgICB9XG4gICAgY2xlYXJUeXBlcygpIHtcbiAgICAgICAgZm9yIChjb25zdCB0eXBlIG9mIHRoaXMudHlwZXMoKSkge1xuICAgICAgICAgICAgdGhpcy5yZW1vdmVNZW1iZXIodHlwZSk7XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5vbk1vZGlmaWNhdGlvbigpO1xuICAgIH1cbiAgICBmaWVsZChuYW1lKSB7XG4gICAgICAgIGlmIChuYW1lID09PSBleHBvcnRzLnR5cGVuYW1lRmllbGROYW1lICYmIHRoaXMuX3R5cGVuYW1lRmllbGQpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzLl90eXBlbmFtZUZpZWxkO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB1bmRlZmluZWQ7XG4gICAgfVxuICAgIHR5cGVuYW1lRmllbGQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl90eXBlbmFtZUZpZWxkO1xuICAgIH1cbiAgICByZW1vdmVNZW1iZXIodHlwZSkge1xuICAgICAgICB0aGlzLl9tZW1iZXJzLmRlbGV0ZSh0eXBlLm5hbWUpO1xuICAgICAgICByZW1vdmVSZWZlcmVuY2VUb1R5cGUodGhpcywgdHlwZSk7XG4gICAgfVxuICAgIHJlbW92ZVR5cGVSZWZlcmVuY2UodHlwZSkge1xuICAgICAgICB0aGlzLl9tZW1iZXJzLmRlbGV0ZSh0eXBlLm5hbWUpO1xuICAgIH1cbiAgICByZW1vdmVJbm5lckVsZW1lbnRzKCkge1xuICAgICAgICBmb3IgKGNvbnN0IG1lbWJlciBvZiB0aGlzLm1lbWJlcnMoKSkge1xuICAgICAgICAgICAgbWVtYmVyLnJlbW92ZSgpO1xuICAgICAgICB9XG4gICAgfVxuICAgIGhhc05vbkV4dGVuc2lvbklubmVyRWxlbWVudHMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLm1lbWJlcnMoKS5zb21lKG0gPT4gbS5vZkV4dGVuc2lvbigpID09PSB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AgICAgICBpZiAoZW50cmllcy5sZW5ndGggIT09IE9iamVjdC5rZXlzKGV4cGVjdGVkQXJncykubGVuZ3RoKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChjb25zdCBba2V5LCB2YWxdIG9mIGVudHJpZXMpIHtcbiAgICAgICAgICAgIGlmICghKGtleSBpbiBleHBlY3RlZEFyZ3MpKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY29uc3QgZXhwZWN0ZWRWYWwgPSBleHBlY3RlZEFyZ3Nba2V5XTtcbiAgICAgICAgICAgIGlmICghKDAsIHZhbHVlc18xLnZhbHVlRXF1YWxzKShleHBlY3RlZFZhbCwgdmFsKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG4gICAgb2ZFeHRlbnNpb24oKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9leHRlbnNpb247XG4gICAgfVxuICAgIHJlbW92ZU9mRXh0ZW5zaW9uKCkge1xuICAgICAgICB0aGlzLl9leHRlbnNpb24gPSB1bmRlZmluZWQ7XG4gICAgfVxuICAgIHNldE9mRXh0ZW5zaW9uKGV4dGVuc2lvbikge1xuICAgICAgICB0aGlzLmNoZWNrVXBkYXRlKCk7XG4gICAgICAgIGlmIChleHRlbnNpb24pIHtcbiAgICAgICAgICAgIGNvbnN0IHBhcmVudCA9IHRoaXMucGFyZW50O1xuICAgICAgICAgICAgKDAsIHV0aWxzXzEuYXNzZXJ0KShwYXJlbnQgaW5zdGFuY2VvZiBTY2hlbWFEZWZpbml0aW9uIHx8IHBhcmVudCBpbnN0YW5jZW9mIEJhc2VOYW1lZFR5cGUsICdDYW4gb25seSBtYXJrIGRpcmVjdGl2ZSBwYXJ0cyBvZiBleHRlbnNp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gICAgIGNvbnN0IHZhck5hbWUgPSB0eXBlb2YgdmFyaWFibGUgPT09ICdzdHJpbmcnID8gdmFyaWFibGUgOiB2YXJpYWJsZS5uYW1lO1xuICAgICAgICByZXR1cm4gdGhpcy5fZGVmaW5pdGlvbnMuZ2V0KHZhck5hbWUpO1xuICAgIH1cbiAgICBpc0VtcHR5KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5fZGVmaW5pdGlvbnMuc2l6ZSA9PT0gMDtcbiAgICB9XG4gICAgZGVmaW5pdGlvbnMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLl9kZWZpbml0aW9ucy52YWx1ZXMoKTtcbiAgICB9XG4gICAgZmlsdGVyKHZhcmlhYmxlcykge1xuICAgICAgICBpZiAodmFyaWFibGVzLmxlbmd0aCA9PT0gMCkge1xuICAgICAgICAgICAgcmV0dXJuIG5ldyBWYXJpYWJsZURlZmluaXRpb25zKCk7XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgbmV3RGVmcyA9IG5ldyBWYXJpYWJsZURlZmluaXRpb25zKCk7XG4gICAgICAgIGZvciAoY29uc3QgdmFyaWFibGUgb2YgdmFyaWFibGVzKSB7XG4gICAgICAgICAgICBjb25zdCBkZWYgPSB0aGlzLmRlZmluaXRpb24odmFyaWFibGUpO1xuICAgICAgICAgICAgaWYgKCFkZWYpIHtcbiAgICAgICAgICAgICAgICB0aHJvdyBuZXcgRXJyb3IoYENhbm5vdCBmaW5kIHZhcmlhYmxlICR7dmFyaWFibGV9IGluIGRlZmluaXRpb25zICR7dGhpc31gKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIG5ld0RlZnMuYWRkKGRlZik7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIG5ld0RlZnM7XG4gICAgfVxuICAgIHRvVmFyaWFibGVEZWZpbml0aW9uTm9kZXMoKSB7XG4gICAgICAgIGlmICh0aGlzLl9kZWZpbml0aW9ucy5zaXplID09PSAwKSB7XG4gICAgICAgICAgICByZX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vZiBzb3VyY2UuaW50ZXJmYWNlSW1wbGVtZW50YXRpb25zKCkpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBkZXN0SW1wbCA9IGRlc3RGaWVsZEJhc2VkVHlwZS5hZGRJbXBsZW1lbnRlZEludGVyZmFjZShzb3VyY2VJbXBsLmludGVyZmFjZS5uYW1lKTtcbiAgICAgICAgICAgICAgICBjb3B5T2ZFeHRlbnNpb24oZXh0ZW5zaW9uc01hcCwgc291cmNlSW1wbCwgZGVzdEltcGwpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgIGNhc2UgJ1VuaW9uVHlwZSc6XG4gICAgICAgICAgICBjb25zdCBkZXN0VW5pb25UeXBlID0gZGVzdDtcbiAgICAgICAgICAgIGZvciAoY29uc3Qgc291cmNlVHlwZSBvZiBzb3VyY2UubWVtYmVycygpKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgZGVzdFR5cGUgPSBkZXN0VW5pb25UeXBlLmFkZFR5cGUoc291cmNlVHlwZS50eXBlLm5hbWUpO1xuICAgICAgICAgICAgICAgIGNvcHlPZkV4dGVuc2lvbihleHRlbnNpb25zTWFwLCBzb3VyY2VUeXBlLCBkZXN0VHlwZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBicmVhaztcbiAgICAgICAgY2FzZSAnRW51bVR5cGUnOlxuICAgICAgICAgICAgY29uc3QgZGVzdEVudW1UeXBlID0gZGVzdDtcbiAgICAgICAgICAgIGZvciAoY29uc3Qgc291cmNlVmFsdWUgb2Ygc291cmNlLnZhbHVlcykge1xuICAgICAgICAgICAgICAgIGNvbnN0IGRlc3RWYWx1ZSA9IGRlc3RFbnVtVHlwZS5hZGRWYWx1ZShzb3VyY2VWYWx1ZS5uYW1lKTtcbiAgICAgICAgICAgICAgICBkZXN0VmFsdWUuZGVzY3JpcHRpb24gPSBzb3VyY2VWYWx1ZS5kZXNjcmlwdGlvbjtcbiAgICAgICAgICAgICAgICBjb3B5T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1lLCBmaWVsZHNGY3QsIH0pIHtcbiAgICByZXR1cm4ge1xuICAgICAgICBuYW1lLFxuICAgICAgICBjaGVja09yQWRkOiAoc2NoZW1hLCBuYW1lSW5TY2hlbWEsIGFzQnVpbHRJbikgPT4ge1xuICAgICAgICAgICAgY29uc3QgYWN0dWFsTmFtZSA9IG5hbWVJblNjaGVtYSAhPT0gbnVsbCAmJiBuYW1lSW5TY2hlbWEgIT09IHZvaWQgMCA/IG5hbWVJblNjaGVtYSA6IG5hbWU7XG4gICAgICAgICAgICBjb25zdCBleHBlY3RlZEZpZWxkcyA9IGZpZWxkc0ZjdChzY2hlbWEpO1xuICAgICAgICAgICAgY29uc3QgZXhpc3RpbmcgPSBzY2hlbWEudHlwZShhY3R1YWxOYW1lKTtcbiAgICAgICAgICAgIGlmIChleGlzdGluZykge1xuICAgICAgICAgICAgICAgIGxldCBlcnJvcnMgPSBlbnN1cmVTYW1lVHlwZUtpbmQoJ09iamVjdFR5cGUnLCBleGlzdGluZyk7XG4gICAgICAgICAgICAgICAgaWYgKGVycm9ycy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnJvcnM7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICgwLCB1dGlsc18xLmFzc2VydCkoKDAsIGRlZmluaXRpb25zXzEuaXNPYmplY3RUeXBlKShleGlzdGluZyksICdTaG91bGQgYmUgYW4gb2JqZWN0IHR5cGUnKTtcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHsgbmFtZSwgdHlwZSwgYXJncyB9IG9mIGV4cGVjdGVkRmllbGRzKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4aXN0aW5nRmllbGQgPSBleGlzdGluZy5maWVsZChuYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFleGlzdGluZ0ZpZWxkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlcnJvcnMuY29uY2F0KGVycm9yXzEuRVJST1JTLlRZUEVfREVGSU5JVElPTl9JTlZBTElELmVycihgSW52YWxpZCBkZWZpbml0aW9uIG9mIHR5cGUgJHtuYW1lfTogbWlzc2luZyBmaWVsZCAke25hbWV9YCwgeyBub2RlczogZXhpc3Rpbmcuc291cmNlQVNUIH0pKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGxldCBleGlzdGluZ1R5cGUgPSBleGlzdGluZ0ZpZWxkLnR5cGU7XG4gICAgICAgICAgICAgICAgICAgIGlmICghKDAsIGRlZmluaXRpb25zXzEuaXNOb25OdWxsVHlwZSkodHlwZSkgJiYgKDAsIGRlZmluaXRpb25zXzEuaXNOb25OdWxsVHlwZSkoZXhpc3RpbmdUeXBlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXhpc3RpbmdUeXBlID0gZXhpc3RpbmdUeXBlLm9mVHlwZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAoISgwLCB0eXBlc18xLnNhbWVUeXBlKSh0eXBlLCBleGlzdGluZ1R5cGUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlcnJvcnMuY29uY2F0KGVycm9yXzEuRVJST1JTLlRZUEVfREVGSU5JVElPTl9JTlZBTElELmVycihgSW52YWxpZCBkZWZpbml0aW9uIGZvciBmaWVsZCAke25hbWV9IG9mIHR5cGUgJHtuYW1lfTogc2hvdWxkIGhhdmUgdHlwZSAke3R5cGV9IGJ1dCBmb3VuZCB0eXBlICR7ZXhpc3RpbmdGaWVsZC50eXBlfWAsIHsgbm9kZXM6IGV4aXN0aW5nRmllbGQuc291cmNlQVNUIH0pKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlcnJvcnMgPSBlcnJvcnMuY29uY2F0KGVuc3VyZVNhbWVBcmd1bWV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GlmIChlcnJvcnMubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXJyb3JzO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAoMCwgdXRpbHNfMS5hc3NlcnQpKCgwLCBkZWZpbml0aW9uc18xLmlzVW5pb25UeXBlKShleGlzdGluZyksICdTaG91bGQgYmUgYW4gdW5pb24gdHlwZScpO1xuICAgICAgICAgICAgICAgIGNvbnN0IGFjdHVhbE1lbWJlcnMgPSBleGlzdGluZy5tZW1iZXJzKCkubWFwKG0gPT4gbS50eXBlLm5hbWUpLnNvcnQoKG4xLCBuMikgPT4gbjEubG9jYWxlQ29tcGFyZShuMikpO1xuICAgICAgICAgICAgICAgIGlmICghKDAsIHV0aWxzXzEuYXJyYXlFcXVhbHMpKGV4cGVjdGVkTWVtYmVycywgYWN0dWFsTWVtYmVycykpIHtcbiAgICAgICAgICAgICAgICAgICAgZXJyb3JzID0gZXJyb3JzLmNvbmNhdChlcnJvcl8xLkVSUk9SUy5UWVBFX0RFRklOSVRJT05fSU5WQUxJRC5lcnIoYEludmFsaWQgZGVmaW5pdGlvbiBvZiB0eXBlICR7bmFtZX06IGV4cGVjdGVkIG1lbWJlcnMgWyR7ZXhwZWN0ZWRNZW1iZXJzfV0gYnV0IGZvdW5kIFske2FjdHVhbE1lbWJlcnN9XS5gLCB7IG5vZGVzOiBleGlzdGluZy5zb3VyY2VBU1QgfSkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICByZXR1cm4gZXJyb3JzO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uc3QgdHlwZSA9IHNjaGVtYS5hZGRUeXBlKG5ldyBkZWZpbml0aW9uc18xLlVuaW9uVHlwZShhY3R1YWxOYW1lLCBhc0J1aWx0SW4pKTtcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG1lbWJlciBvZiBleHBlY3RlZE1lbWJlcnMpIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZS5hZGRUeXBlKG1lbWJlcik7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBbXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfSxcbiAgICB9O1xufVxuZXhwb3J0cy5jcmVhdGVVbmlvblR5cGVTcGVjaWZpY2F0aW9uID0gY3JlYXRlVW5pb25UeXBlU3BlY2lmaWNhdGlvbjtcbmZ1bmN0aW9uIGNyZWF0ZUVudW1UeXBlU3BlY2lmaWNhdGlvbih7IG5hbWUsIHZhbHVlcywgfSkge1xuICAgIHJldHVybiB7XG4gICAgICAgIG5hbWUsXG4gICAgICAgIGNoZWNrT3JBZGQ6IChzY2hlbWEsIG5hbWVJblNjaGVtYSwgYXNCdWlsdEluKSA9PiB7XG4gICAgICAgICAgICBjb25zdCBhY3R1YWxOYW1lID0gbmFtZUluU2NoZW1hICE9PSBudWxsICYmIG5hbWVJblNjaGVtYSAhPT0gdm9pZCAwID8gbmFtZUluU2NoZW1hIDogbmFtZTtcbiAgICAgICAgICAgIGNvbnN0IGV4aXN0aW5nID0gc2NoZW1hLnR5cGUoYWN0dWFsTmFtZSk7XG4gICAgICAgICAgICBjb25zdCBleHBlY3RlZFZhbHVlTmFtZXMgPSB2YWx1ZXMubWFwKCh2KSA9PiB2Lm5hbWUpLnNvcnQoKG4xLCBuMikgPT4gbjEubG9jYWxlQ29tcGFyZShuMikpO1xuICAgICAgICAgICAgaWYgKGV4aXN0aW5nKSB7XG4gICAgICAgICAgICAgICAgbGV0IGVycm9ycyA9IGVuc3VyZVNhbWVUeXBlS2luZCgnRW51bVR5cGUnLCBleGlzdGluZyk7XG4gICAgICAgICAgICAgICAgaWYgKGVycm9ycy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBlcnJvcnM7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICgwLCB1dGlsc18xLmFz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gICBjb25zdCB7IGlzSW5TdWJncmFwaCwgdHlwZXNJbkZlZGVyYXRpb25EaXJlY3RpdmVzIH0gPSBmaWVsZEluZm9JblN1YmdyYXBoKGZpZWxkLCBzdWJncmFwaE5hbWUpO1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNJblN1YmdyYXBoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmaWVsZC5hcmd1bWVudHMoKS5mb3JFYWNoKChhcmcpID0+IHN0YWNrLnB1c2goKDAsIGRlZmluaXRpb25zXzEuYmFzZVR5cGUpKGFyZy50eXBlKSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RhY2sucHVzaCgoMCwgZGVmaW5pdGlvbnNfMS5iYXNlVHlwZSkoZmllbGQudHlwZSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZXNJbkZlZGVyYXRpb25EaXJlY3RpdmVzLmZvckVhY2goKHQpID0+IHN0YWNrLnB1c2godCkpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSAnSW5wdXRPYmplY3RUeXBlJzpcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIHR5cGUuZmllbGRzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgeyBpc0luU3ViZ3JhcGgsIHR5cGVzSW5GZWRlcmF0aW9uRGlyZWN0aXZlcyB9ID0gZmllbGRJbmZvSW5TdWJncmFwaChmaWVsZCwgc3ViZ3JhcGhOYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzSW5TdWJncmFwaCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgc3RhY2sucHVzaCgoMCwgZGVmaW5pdGlvbnNfMS5iYXNlVHlwZSkoZmllbGQudHlwZSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHlwZXNJbkZlZGVyYXRpb25EaXJlY3RpdmV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WVzKCksIChmLCBuYW1lKSA9PiB7XG4gICAgICAgICAgICAgICAgY29uc3QgZmllbGRBcHBsaWNhdGlvbnMgPSBmLmFwcGxpZWREaXJlY3RpdmVzT2YoZmllbGREaXJlY3RpdmUpO1xuICAgICAgICAgICAgICAgIGlmIChmaWVsZEFwcGxpY2F0aW9ucy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgYXBwbGljYXRpb24gPSBmaWVsZEFwcGxpY2F0aW9ucy5maW5kKChhcHBsaWNhdGlvbikgPT4gZ2V0U3ViZ3JhcGgoYXBwbGljYXRpb24pID09PSBuYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGFwcGxpY2F0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBhcmdzID0gYXBwbGljYXRpb24uYXJndW1lbnRzKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCB0eXBlc0luRmVkZXJhdGlvbkRpcmVjdGl2ZXMgPSB0eXBlc1VzZWRJbkZlZGVyYXRpb25EaXJlY3RpdmUoYXJncy5wcm92aWRlcywgKDAsIGRlZmluaXRpb25zXzEuYmFzZVR5cGUpKGYudHlwZSkpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLmNvbmNhdCh0eXBlc1VzZWRJbkZlZGVyYXRpb25EaXJlY3RpdmUoYXJncy5yZXF1aXJlcywgZi5wYXJlbnQpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IGlzSW5TdWJncmFwaDogdHJ1ZSwgdHlwZXNJbkZlZGVyYXRpb25EaXJlY3RpdmVzIH07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBpc0luU3ViZ3JhcGg6IGZhbHNlLCB0eXBlc0luRmVkZXJhdGlvbkRpcmVjdGl2ZXM6IFtdIH07XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IG93bmVyQXBwbGljYXRpb25zID0gb3duZXJEaXJlY3RpdmUgPyBmLnBhcmVudC5hcHBsaWVkRGlyZWN0aXZlc09mKG93bmVyRGlyZWN0aXZlKSA6IFtdO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBpc0luU3ViZ3JhcGg6ICFvd25lckFwcGxpY2F0aW9ucy5sZW5ndGggfHwgZ2V0U3ViZ3JhcGgob3duZXJBcHBsaWNhdGlvbnNbMF0pID09IG5hbWUsIHR5cGVzSW5GZWRlcmF0aW9uRGlyZWN0aXZlczogW10gfTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9LCAodCwgbmFtZSkgPT4ge1xuICAgICAgICAgICAgICAgIGNvbnN0IHR5cGVBcHBsaWNhdGlvbnMgPSB0LmFwcGxpZWREaXJlY3RpdmVzT2YodHlwZURpcmVjdGl2ZSk7XG4gICAgICAgICAgICAgICAgY29uc3QgYXBwbGljYXRpb24gPSB0eXBlQXBwbGljYXRpb25zLmZpbmQoKGFwcGxpY2F0aW9uKSA9PiAoYXBwbGljYXRpb24uYXJndW1lbnRzKCkua2V5ICYmIChnZXRTdWJncmFwaChhcHBsaWNhdGlvbikgPT09IG5hbWUpKSk7XG4gICAgICAgICAgICAgICAgaWYgKGFwcGxpY2F0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHR5cGVzSW5GZWRlcmF0aW9uRGlyZWN0aXZlcyA9IHR5cGVzVXNlZEluRmVkZXJhdGlvbkRpcmVjdGl2ZShhcHBsaWNhdGlvbi5hcmd1bWVudHMoKS5rZXksIHQpO1xuICAgICAgICAgICAgICAgICAgICByZXR1cm4geyBpc0VudGl0eVdpdGhLZXlJblN1YmdyYXBoOiB0cnVlLCB0eXBlc0luRmVkZXJhdGlvbkRpcmVjdGl2ZXMgfTtcbiAgICA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dGlvbnNfMS5uZXdOYW1lZFR5cGUpKHR5cGUua2luZCwgdHlwZS5uYW1lKSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBhcHBsaWNhdGlvbiBvZiB0eXBlQXBwbGljYXRpb25zKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBhcHBsaWNhdGlvbi5hcmd1bWVudHMoKTtcbiAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ViZ3JhcGhOYW1lID0gZ2V0U3ViZ3JhcGgoYXBwbGljYXRpb24pO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBzY2hlbWEgPSBzdWJncmFwaHMuZ2V0KHN1YmdyYXBoTmFtZSkuc2NoZW1hO1xuICAgICAgICAgICAgICAgICAgICBsZXQgc3ViZ3JhcGhUeXBlID0gc2NoZW1hLnR5cGUodHlwZS5uYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFzdWJncmFwaFR5cGUpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YmdyYXBoVHlwZSA9IHNjaGVtYS5hZGRUeXBlKCgwLCBkZWZpbml0aW9uc18xLm5ld05hbWVkVHlwZSkodHlwZS5raW5kLCB0eXBlLm5hbWUpKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAoYXJncy5rZXkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHsgcmVzb2x2YWJsZSB9ID0gYXJncztcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGRpcmVjdGl2ZSA9IHN1YmdyYXBoVHlwZS5hcHBseURpcmVjdGl2ZSgna2V5JywgeyAnZmllbGRzJzogYXJncy5rZXksIHJlc29sdmFibGUgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJncy5leHRlbnNpb24pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkaXJlY3RpdmUuc2V0T2ZFeHRlbnNpb24oc3ViZ3JhcGhUeXBlLm5ld0V4dGVuc2lvbigpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBmb3IgKGNvbnN0IHR5cGUgb2YgZmlsdGVyZWRUeXBlcyhzdXBlcmdyYXBoLCBqb2luU3BlYywgY29yZUZlYXR1cmVzLmNvcmVEZWZpbml0aW9uKSkge1xuICAgICAgICAgICAgc3dpdGNoICh0eXBlLmtpbmQpIHtcbiAgICAgICAgICAgICAgICBjYXNlICdPYmplY3RUeXBlJzpcbiAgICAgICAgICAgICAgICBjYXNlICdJbnRlcmZhY2VUeXBlJzpcbiAgICAgICAgICAgICAgICAgICAgY29uc3QgYWRkZWRJbnRlcmZhY2VzID0gW107XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGltcGxlbWVudHNBcHBsaWNhdGlvbnMgPSBpbXBsZW1lbnRzRGlyZWN0aXZlID8gdHlwZS5hcHBsaWVkRGlyZWN0aXZlc09mKGltcGxlbWVudHNEaXJlY3RpdmUpIDogW107XG4gICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYXBwbGljYXRpb24gb2YgaW1wbGVtZW50c0FwcGxpY2F0aW9ucykge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgYXJncyA9IGFwcGxpY2F0aW9uLmFyZ3VtZW50cygpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ViZ3JhcGggPSBzdWJncmFwaHMuZ2V0KGdyYXBoRW51bU5hbWVUb1N1YmdyYXBoTmFtZS5nZXQoYXJncy5ncmFwaCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc2NoZW1hID0gc3ViZ3JhcGguc2NoZW1hO1xuICAgICAgICAgICAgICAgICAgICAgICAgc2NoZW1hLnR5cGUodHlwZS5uYW1lKS5hZGRJbXBsZW1lbnRlZEludGVyZmFjZShhcmdzLmludGVyZmFjZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBhZGRlZEludGVyZmFjZXMucHVzaChhcmdzLmludGVyZmFjZSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbXBsZW1lbnRhdGlvbnMgb2YgdHlwZS5pbnRlcmZhY2VJbXBsZW1lbnRhdGlvbnMoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgbmFtZSA9IGltcGxlbWVudGF0aW9ucy5pbnRlcmZhY2UubmFtZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghYWRkZWRJbnRlcmZhY2VzLmluY2x1ZGVzKG5hbWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBzdWJncmFwaCBvZiBzdWJncmFwaHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ViZ3JhcGhUeXBlID0gc3ViZ3JhcGguc2NoZW1hLnR5cGUodHlwZS5uYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ViZ3JhcGhJdGYgPSBzdWJncmFwaC5zY2hlbWEudHlwZShuYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN1YmdyYXBoVHlwZSAmJiBzdWJncmFwaEl0Zikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViZ3JhcGhUeXBlLmFkZEltcGxlbWVudGVkSW50ZXJmYWNlKG5hbWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY2FzZSAnSW5wdXRPYmplY3RUeXBlJzpcbiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZCBvZiB0eXBlLmZpZWxkcygpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBmaWVsZEFwcGxpY2F0aW9ucyA9IGZpZWxkLmFwcGxpZWREaXJlY3RpdmVzT2YoZmllbGREaXJlY3RpdmUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFmaWVsZEFwcGxpY2F0aW9ucy5sZW5ndGgpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBvd25lckFwcGxpY2F0aW9ucyA9IG93bmVyRGlyZWN0aXZlID8gdHlwZS5hcHBsaWVkRGlyZWN0aXZlc09mKG93bmVyRGlyZWN0aXZlKSA6IFtdO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3duZXJBcHBsaWNhdGlvbnMubGVuZ3RoKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGZpZWxkQmFzZVR5cGUgPSAoMCwgZGVmaW5pdGlvbnNfMS5iYXNlVHlwZSkoZmllbGQudHlwZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgc3ViZ3JhcGggb2Ygc3ViZ3JhcGhzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoc3ViZ3JhcGguc2NoZW1hLnR5cGUoZmllbGRCYXNlVHlwZS5uYW1lKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFkZFN1YmdyYXBoRmllbGQoZmllbGQsIHN1YmdyYXBoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIHV0aWxzXzEuYXNzZXJ0KShvd25lckFwcGxpY2F0aW9ucy5sZW5ndGggPT0gMSwgKCkgPT4gYEZvdW5kIG11bHRpcGxlIGpvaW5fX293bmVyIGRpcmVjdGl2ZXMgb24gdHlwZSAke3R5cGV9YCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1YmdyYXBoID0gc3ViZ3JhcGhzLmdldChncmFwaEVudW1OYW1lVG9TdWJncmFwaE5hbWUuZ2V0KG93bmVyQXBwbGljYXRpb25zWzBdLmFyZ3VtZW50cygpLmdyYXBoKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1YmdyYXBoRmllbGQgPSBhZGRTdWJncmFwaEZpZWxkKGZpZWxkLCBzdWJncmFwaCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgwLCB1dGlsc18xLmFzc2VydCkoc3ViZ3JhcGhGaWVsZCwgKCkgPT4gYEZvdW5kIGpvaW5fX293bmVyIGRpcmVjdGl2ZSBvbiAke3R5cGV9IGJ1dCBubyBjb3JyZXNwb25kaW5nIGpvaW5fX3R5cGVgKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGFwcGxpY2F0aW9uIG9mIGZpZWxkQXBwbGljYXRpb25zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGFyZ3MgPSBhcHBsaWNhdGlvbi5hcmd1bWVudHMoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3Qgc3ViZ3JhcGggPSBzdWJncmFwaHMuZ2V0KGdyYXBoRW51bU5hbWVUb1N1YmdyYXBoTmFtZS5nZXQoYXJncy5ncmFwaCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdWJncmFwaEZpZWxkID0gYWRkU3ViZ3JhcGhGaWVsZChmaWVsZCwgc3ViZ3JhcGgsIGFyZ3MudHlwZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3ViZ3JhcGhGaWVsZCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIHV0aWxzXzEuYXNzZXJ0KSghaW5jbHVkZVR5cGVJblN1YmdyYXBoKHR5cGUsIHN1YmdyYXBoLm5hbWUpLCAoKSA9PiBgRm91bmQgam9pbl9fZmllbGQgZGlyZWN0aXZlIGZvciBncmFwaCAke3N1YmdyYXBoLm5hbWV9IG9uIGZpZWxkICR7ZmllbGQuY29vcmRpbmF0ZX0gYnV0IG5vIGNvcnJlc3BvbmRpbmcgam9pbl9fdHlwZSBvbiAke3R5cGV9YCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJncy5yZXF1aXJlcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViZ3JhcGhGaWVsZC5hcHBseURpcmVjdGl2ZShzdWJncmFwaC5tZXRhZGF0YSgpLnJlcXVpcmVzRGlyZWN0aXZlKCksIHsgJ2ZpZWxkcyc6IGFyZ3MucmVxdWlyZXMgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ3MucHJvdmlkZXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YmdyYXBoRmllbGQuYXBwbHlEaXJlY3RpdmUoc3ViZ3JhcGgubWV0YWRhdGEoKS5wcm92aWRlc0RpcmVjdGl2ZSgpLCB7ICdmaWVsZHMnOiBhcmdzLnByb3ZpZGVzIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhcmdzLmV4dGVybmFsKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJncmFwaEZpZWxkLmFwcGx5RGlyZWN0aXZlKHN1YmdyYXBoLm1ldGFkYXRhKCkuZXh0ZXJuYWxEaXJlY3RpdmUoKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ3MudXNlZE92ZXJyaWRkZW4pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHN1YmdyYXBoRmllbGQuYXBwbHlEaXJlY3RpdmUoc3ViZ3JhcGgubWV0YWRhdGEoKS5leHRlcm5hbERpcmVjdGl2ZSgpLCB7ICdyZWFzb24nOiAnW292ZXJyaWRkZW5dJyB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoYXJncy5vdmVycmlkZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViZ3JhcGhGaWVsZC5hcHBseURpcmVjdGl2ZShzdWJncmFwaC5tZXRhZGF0YSgpLm92ZXJyaWRlRGlyZWN0aXZlKCksIHsgJ2Zyb20nOiBhcmdzLm92ZXJyaWRlIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJ0VudW1UeXBlJzpcbiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBzdWJncmFwaCBvZiBzdWJncmFwaHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1YmdyYXBoRW51bSA9IHN1YmdyYXBoLnNjaGVtYS50eXBlKHR5cGUubmFtZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoIXN1YmdyYXBoRW51bSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgKDAsIHV0aWxzXzEuYXNzZXJ0KSgoMCwgZGVmaW5pdGlvbnNfMS5pc0VudW1UeXBlKShzdWJncmFwaEVudW0pLCAoKSA9PiBgJHtzdWJncmFwaEVudW19IHNob3VsZCBiZSBhbiBlbnVtIGJ1dCBmb3VuZCBhICR7c3ViZ3JhcGhFbnVtLmtpbmR9YCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHZhbHVlIG9mIHR5cGUudmFsdWVzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViZ3JhcGhFbnVtLmFkZFZhbHVlKHZhbHVlLm5hbWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIGNhc2UgJ1VuaW9uVHlwZSc6XG4gICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3Qgc3ViZ3JhcGggb2Ygc3ViZ3JhcGhzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBzdWJncmFwaFVuaW9uID0gc3ViZ3JhcGguc2NoZW1hLnR5cGUodHlwZS5uYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghc3ViZ3JhcGhVbmlvbikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgKDAsIHV0aWxzXzEuYXNzZXJ0KSgoMCwgZGVmaW5pdGlvbnNfMS5pc1VuaW9uVHlwZSkoc3ViZ3JhcGhVbmlvbiksICgpID0+IGAke3N1YmdyYXBoVW5pb259IHNob3VsZCBiZSBhbiBlbnVtIGJ1dCBmb3VuZCBhICR7c3ViZ3JhcGhVbmlvbi5raW5kfWApO1xuICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBtZW1iZXJUeXBlIG9mIHR5cGUudHlwZXMoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IHN1YmdyYXBoVHlwZSA9IHN1YmdyYXBoLnNjaGVtYS50eXBlKG1lbWJlclR5cGUubmFtZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHN1YmdyYXBoVHlwZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzdWJncmFwaFVuaW9uLmFkZFR5cGUoc3ViZ3JhcGhUeXBlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgY29uc3QgYWxsRXhlY3V0YWJsZURpcmVjdGl2ZXMgPSBzdXBlcmdyYXBoLmRpcmVjdGl2ZXMoKS5maWx0ZXIoKGRlZikgPT4gZGVmLmhhc0V4ZWN1dGFibGVMb2NhdGlvbnMoKSk7XG4gICAgICAgIGZvciAoY29uc3Qgc3ViZ3JhcGggb2Ygc3ViZ3JhcGhzKSB7XG4gICAgICAgICAgICBpZiAoaXNGZWQxKSB7XG4gICAgICAgICAgICAgICAgYWRkRXh0ZXJuYWxGaWVsZHMoc3ViZ3JhcGgsIHN1cGVyZ3JhcGgsIGlzRmVkMSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICAoMCwgZmVkZXJhdGlvbl8xLnJlbW92ZUluYWN0aXZlUHJvdmlkZXNBbmRSZXF1aXJlcykoc3ViZ3JhcGguc2NoZW1hKTtcbiAgICAgICAgICAgIGZvciAoY29uc3QgdHlwZSBvZiBzdWJncmFwaC5zY2hlbWEudHlwZXMoKSkge1xuICAgICAgICAgICAgICAgIHN3aXRjaCAodHlwZS5raW5kKSB7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdFR5cGUnOlxuICAgICAgICAgICAgICAgICAgICBjYXNlICdJbnRlcmZhY2VUeXBlJzpcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnSW5wdXRPYmplY3RUeXBlJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghdHlwZS5oYXNGaWVsZHMoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR5cGUucmVtb3ZlUmVjdXJzaXZlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnVW5pb25UeXBlJzpcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlLm1lbWJlcnNDb3VudCgpID09PSAwKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHlwZS5yZW1vdmVSZWN1cnNpdmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGZvciAoY29uc3QgZGVmaW5pdGlvbiBvZiBhbGxFeGVjdXRhYmxlRGlyZWN0aXZlcykge1xuICAgICAgICAgICAgICAgICgwLCBkZWZpbml0aW9uc18xLmNvcHlEaXJlY3RpdmVEZWZpbml0aW9uVG9TY2hlbWEpKHtcbiAgICAgICAgICAgICAgICAgICAgZGVmaW5pdGlvbixcbiAgICAgICAgICAgICAgICAgICAgc2NoZW1hOiBzdWJncmFwaC5zY2hlbWEsXG4gICAgICAgICAgICAgICAgICAgIGNvcHlEaXJlY3RpdmVBcHBsaWNhdGlvbnNJbkFyZ3VtZW50czogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIGxvY2F0aW9uRmlsdGVyOiAobG9jKSA9PiAoMCwgZGVmaW5pdGlvbnNfMS5pc0V4ZWN1dGFibGVEaXJlY3RpdmVMb2NhdGlvbikobG9jKSxcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoaXNGZWQxKSB7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IHN1YmdyYXBoIG9mIHN1YmdyYXBocykge1xuICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaXRmIG9mIHN1YmdyYXBoLnNjaGVtYS5pbnRlcmZhY2VUeXBlcygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IGltcGxlbWVudGF0aW9ucyA9IGl0Zi5wb3NzaWJsZVJ1bnRpbWVUeXBlcygpO1xuICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIGl0Zi5maWVsZHMoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKCFpbXBsZW1lbnRhdGlvbnMuZXZlcnkoaW1wbGVtID0+IGltcGxlbS5maWVsZChmaWVsZC5uYW1lKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBmaWVsZC5yZW1vdmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAoIWl0Zi5oYXNGaWVsZHMoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaXRmLnJlbW92ZSgpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuIC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gICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB2YWxpZGF0ZUZpZWxkU2V0U2VsZWN0aW9ucyh7XG4gICAgICAgICAgICAgICAgICAgIGRpcmVjdGl2ZU5hbWUsXG4gICAgICAgICAgICAgICAgICAgIHNlbGVjdGlvblNldDogc2VsZWN0aW9uLnNlbGVjdGlvblNldCxcbiAgICAgICAgICAgICAgICAgICAgaGFzRXh0ZXJuYWxJblBhcmVudHM6IG5ld0hhc0V4dGVybmFsSW5QYXJlbnRzLFxuICAgICAgICAgICAgICAgICAgICBtZXRhZGF0YSxcbiAgICAgICAgICAgICAgICAgICAgb25FcnJvcixcbiAgICAgICAgICAgICAgICAgICAgYWxsb3dPbk5vbkV4dGVybmFsTGVhZkZpZWxkcyxcbiAgICAgICAgICAgICAgICAgICAgYWxsb3dGaWVsZHNXaXRoQXJndW1lbnRzLFxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgdmFsaWRhdGVGaWVsZFNldFNlbGVjdGlvbnMoe1xuICAgICAgICAgICAgICAgIGRpcmVjdGl2ZU5hbWUsXG4gICAgICAgICAgICAgICAgc2VsZWN0aW9uU2V0OiBzZWxlY3Rpb24uc2VsZWN0aW9uU2V0LFxuICAgICAgICAgICAgICAgIGhhc0V4dGVybmFsSW5QYXJlbnRzLFxuICAgICAgICAgICAgICAgIG1ldGFkYXRhLFxuICAgICAgICAgICAgICAgIG9uRXJyb3IsXG4gICAgICAgICAgICAgICAgYWxsb3dPbk5vbkV4dGVybmFsTGVhZkZpZWxkcyxcbiAgICAgICAgICAgICAgICBhbGxvd0ZpZWxkc1dpdGhBcmd1bWVudHMsXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgIH1cbn1cbmZ1bmN0aW9uIHZ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CkpIHtcbiAgICAgICAgY29uc3QgdHlwZSA9IHRhcmdldFR5cGVFeHRyYWN0b3IoYXBwbGljYXRpb24ucGFyZW50KTtcbiAgICAgICAgaWYgKCF0eXBlKSB7XG4gICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgfVxuICAgICAgICBjb2xsZWN0VGFyZ2V0RmllbGRzKHtcbiAgICAgICAgICAgIHBhcmVudFR5cGU6IHR5cGUsXG4gICAgICAgICAgICBkaXJlY3RpdmU6IGFwcGxpY2F0aW9uLFxuICAgICAgICAgICAgaW5jbHVkZUludGVyZmFjZUZpZWxkc0ltcGxlbWVudGF0aW9uczogdHJ1ZSxcbiAgICAgICAgICAgIHZhbGlkYXRlOiBmYWxzZSxcbiAgICAgICAgfSkuZm9yRWFjaCgoZmllbGQpID0+IHVzZWRGaWVsZERlZnMuYWRkKGZpZWxkKSk7XG4gICAgfVxufVxuZnVuY3Rpb24gdmFsaWRhdGVBbGxFeHRlcm5hbEZpZWxkc1VzZWQobWV0YWRhdGEsIGVycm9yQ29sbGVjdG9yKSB7XG4gICAgZm9yIChjb25zdCB0eXBlIG9mIG1ldGFkYXRhLnNjaGVtYS50eXBlcygpKSB7XG4gICAgICAgIGlmICghKDAsIGRlZmluaXRpb25zXzEuaXNPYmplY3RUeXBlKSh0eXBlKSAmJiAhKDAsIGRlZmluaXRpb25zXzEuaXNJbnRlcmZhY2VUeXBlKSh0eXBlKSkge1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChjb25zdCBmaWVsZCBvZiB0eXBlLmZpZWxkcygpKSB7XG4gICAgICAgICAgICBpZiAoIW1ldGFkYXRhLmlzRmllbGRFeHRlcm5hbChmaWVsZCkgfHwgbWV0YWRhdGEuaXNGaWVsZFVzZWQoZmllbGQpKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlcnJvckNvbGxlY3Rvci5wdXNoKGVycm9yXzEu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0aW9uc18xLmFsbFNjaGVtYVJvb3RLaW5kcykge1xuICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSAoX2EgPSBzY2hlbWEuc2NoZW1hRGVmaW5pdGlvbi5yb290KGspKSA9PT0gbnVsbCB8fCBfYSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2EudHlwZTtcbiAgICAgICAgICAgICAgICBjb25zdCBkZWZhdWx0TmFtZSA9ICgwLCBkZWZpbml0aW9uc18xLmRlZmF1bHRSb290TmFtZSkoayk7XG4gICAgICAgICAgICAgICAgaWYgKHR5cGUgJiYgdHlwZS5uYW1lICE9PSBkZWZhdWx0TmFtZSkge1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBleGlzdGluZyA9IHNjaGVtYS50eXBlKGRlZmF1bHROYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGV4aXN0aW5nKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlcnJvckNvbGxlY3Rvci5wdXNoKGVycm9yXzEuRVJST1JfQ0FURUdPUklFUy5ST09UX1RZUEVfVVNFRC5nZXQoaykuZXJyKGBUaGUgc2NoZW1hIGhhcyBhIHR5cGUgbmFtZWQgXCIke2RlZmF1bHROYW1lfVwiIGJ1dCBpdCBpcyBub3Qgc2V0IGFzIHRoZSAke2t9IHJvb3QgdHlwZSAoXCIke3R5cGUubmFtZX1cIiBpcyBpbnN0ZWFkKTogYFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICsgJ3RoaXMgaXMgbm90IHN1cHBvcnRlZCBieSBmZWRlcmF0aW9uLiAnXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgKyAnSWYgYSByb290IHR5cGUgZG9lcyBub3QgdXNlIGl0cyBkZWZhdWx0IG5hbWUsIHRoZXJlIHNob3VsZCBiZSBubyBvdGhlciB0eXBlIHdpdGggdGhhdCBkZWZhdWx0IG5hbWUuJywgeyBub2RlczogKDAsIGRlZmluaXRpb25zXzEuc291cmNlQVNUcykodHlwZSwgZXhpc3RpbmcpIH0pKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB0eXBlLnJlbmFtZShkZWZhdWx0TmFtZSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGNvbnN0IG1ldGFkYXRhID0gZmVkZXJhdGlvbk1ldGFkYXRhKHNjaGVtYSk7XG4gICAgICAgICgwLCB1dGlsc18xLmFzc2VydCkobWV0YWRhdGEsICdGZWRlcmF0aW9uIHNjaGVtYSBzaG91bGQgaGF2ZSBoYWQgaXRzIG1ldGFkYXRhIHNldCBvbiBjb25zdHJ1Y3Rpb24nKTtcbiAgICAgICAgaWYgKCFtZXRhZGF0YS5pc0ZlZDJTY2hlbWEoKSkge1xuICAgICAgICAgICAgcmV0dXJuIGVycm9yQ29sbGVjdG9yO1xuICAgICAgICB9XG4gICAgICAgIGNvbnN0IGtleURpcmVjdGl2ZSA9IG1ldGFkYXRhLmtleURpcmVjdGl2ZSgpO1xuICAgICAgICB2YWxpZGF0ZUFsbEZpZWxkU2V0KHtcbiAgICAgICAgICAgIGRlZmluaXRpb246IGtleURpcmVjdGl2ZSxcbiAgICAgICAgICAgIHRhcmdldFR5cGVFeHRyYWN0b3I6IHR5cGUgPT4gdHlwZSxcbiAgICAgICAgICAgIGVycm9yQ29sbGVjdG9yLFxuICAgICAgICAgICAgbWV0YWRhdGEsXG4gICAgICAgICAgICBpc09uUGFyZW50VHlwZTogdHJ1ZSxcbiAgICAgICAgICAgIGFsbG93T25Ob25FeHRlcm5hbExlYWZGaWVsZHM6IHRydWUsXG4gICAgICAgICAgICBvbkZpZWxkczogZmllbGQgPT4ge1xuICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSAoMCwgZGVmaW5pdGlvbnNfMS5iYXNlVHlwZSkoZmllbGQudHlwZSk7XG4gICAgICAgICAgICAgICAgaWYgKCgwLCBkZWZpbml0aW9uc18xLmlzVW5pb25UeXBlKSh0eXBlKSB8fCAoMCwgZGVmaW5pdGlvbnNfMS5pc0ludGVyZmFjZVR5cGUpKHR5cGUpKSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBraW5kID0gdHlwZS5raW5kO1xuICAgICAgICAgICAgICAgICAgICBraW5kID0ga2luZC5zbGljZSgwLCBraW5kLmxlbmd0aCAtICdUeXBlJy5sZW5ndGgpO1xuICAgICAgICAgICAgICAgICAgICB0aHJvdyBlcnJvcl8xLkVSUk9SUy5LRVlfRklFTERTX1NFTEVDVF9JTlZBTElEX1RZUEUuZXJyKGBmaWVsZCBcIiR7ZmllbGQuY29vcmRpbmF0ZX1cIiBpcyBhICR7a2luZH0gdHlwZSB3aGljaCBpcyBub3QgYWxsb3dlZCBpbiBAa2V5YCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9KTtcbiAgICAgICAgdmFsaWRhdGVBbGxGaWVsZFNldCh7XG4gICAgICAgICAgICBkZWZpbml0aW9uOiBtZXRhZGF0YS5yZXF1aXJlc0RpcmVjdGl2ZSgpLFxuICAgICAgICAgICAgdGFyZ2V0VHlwZUV4dHJhY3RvcjogZmllbGQgPT4gZmllbGQucGFyZW50LFxuICAgICAgICAgICAgZXJyb3JDb2xsZWN0b3IsXG4gICAgICAgICAgICBtZXRhZGF0YSxcbiAgICAgICAgICAgIGFsbG93RmllbGRzV2l0aEFyZ3VtZW50czogdHJ1ZSxcbiAgICAgICAgfSk7XG4gICAgICAgIHZhbGlkYXRlQWxsRmllbGRTZXQoe1xuICAgICAgICAgICAgZGVmaW5pdGlvbjogbWV0YWRhdGEucHJvdmlkZXNEaXJlY3RpdmUoKSxcbiAgICAgICAgICAgIHRhcmdldFR5cGVFeHRyYWN0b3I6IGZpZWxkID0+IHtcbiAgICAgICAgICAgICAgICBpZiAobWV0YWRhdGEuaXNGaWVsZEV4dGVybmFsKGZpZWxkKSkge1xuICAgICAgICAgICAgICAgICAgICB0aHJvdyBlcnJvcl8xLkV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cIiwgXCJAcmVxdWlyZXNcIiwgXCJAcHJvdmlkZXNcIiwgXCJAZXh0ZXJuYWxcIiwgXCJAdGFnXCIsIFwiQGV4dGVuZHNcIiwgXCJAc2hhcmVhYmxlXCIsIFwiQGluYWNjZXNzaWJsZVwiLCBcIkBvdmVycmlkZVwiLCBcIkBjb21wb3NlRGlyZWN0aXZlXCJdKSc7XG5mdW5jdGlvbiBhc0ZlZDJTdWJncmFwaERvY3VtZW50KGRvY3VtZW50KSB7XG4gICAgY29uc3QgZmVkMkxpbmtFeHRlbnNpb24gPSB7XG4gICAgICAgIGtpbmQ6IGdyYXBocWxfMS5LaW5kLlNDSEVNQV9FWFRFTlNJT04sXG4gICAgICAgIGRpcmVjdGl2ZXM6IFt7XG4gICAgICAgICAgICAgICAga2luZDogZ3JhcGhxbF8xLktpbmQuRElSRUNUSVZFLFxuICAgICAgICAgICAgICAgIG5hbWU6IHsga2luZDogZ3JhcGhxbF8xLktpbmQuTkFNRSwgdmFsdWU6IGNvcmVTcGVjXzEubGlua0RpcmVjdGl2ZURlZmF1bHROYW1lIH0sXG4gICAgICAgICAgICAgICAgYXJndW1lbnRzOiBbe1xuICAgICAgICAgICAgICAgICAgICAgICAga2luZDogZ3JhcGhxbF8xLktpbmQuQVJHVU1FTlQsXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiB7IGtpbmQ6IGdyYXBocWxfMS5LaW5kLk5BTUUsIHZhbHVlOiAndXJsJyB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHsga2luZDogZ3JhcGhxbF8xLktpbmQuU1RSSU5HLCB2YWx1ZTogZmVkZXJhdGlvblNwZWMudXJsLnRvU3RyaW5nKCkgfVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgICAgICBraW5kOiBncmFwaHFsXzEuS2luZC5BUkdVTUVOVCxcbiAgICAgICAgICAgICAgICAgICAgICAgIG5hbWU6IH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ydWUpIHtcbiAgICAgICAgICAgIHNlbGVjdGlvblNldC5mb3JFYWNoRWxlbWVudCgoZWx0KSA9PiB7XG4gICAgICAgICAgICAgICAgaWYgKGVsdC5raW5kID09PSAnRmllbGQnICYmIGVsdC5hbGlhcykge1xuICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgZ3JhcGhxbF8xLkdyYXBoUUxFcnJvcihgQ2Fubm90IHVzZSBhbGlhcyBcIiR7ZWx0LmFsaWFzfVwiIGluIFwiJHtlbHR9XCI6IGFsaWFzZXMgYXJlIG5vdCBjdXJyZW50bHkgc3VwcG9ydGVkIGluIEAke2RpcmVjdGl2ZS5uYW1lfWApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBzZWxlY3Rpb25TZXQ7XG4gICAgfVxuICAgIGNhdGNoIChlKSB7XG4gICAgICAgIGlmICghKGUgaW5zdGFuY2VvZiBncmFwaHFsXzEuR3JhcGhRTEVycm9yKSB8fCAhZGVjb3JhdGVWYWxpZGF0aW9uRXJyb3JzKSB7XG4gICAgICAgICAgICB0aHJvdyBlO1xuICAgICAgICB9XG4gICAgICAgIHRocm93IGhhbmRsZUZpZWxkU2V0VmFsaWRhdGlvbkVycm9yKGRpcmVjdGl2ZSwgZSwgKG1zZykgPT4ge1xuICAgICAgICAgICAgaWYgKG1zZy5zdGFydHNXaXRoKCdDYW5ub3QgcXVlcnkgZmllbGQnKSkge1xuICAgICAgICAgICAgICAgIGlmIChtc2cuZW5kc1dpdGgoJy4nKSkge1xuICAgICAgICAgICAgICAgICAgICBtc2cgPSBtc2cuc2xpY2UoMCwgbXNnLmxlbmd0aCAtIDEpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoZGlyZWN0aXZlLm5hbWUgPT09IGZlZGVyYXRpb25TcGVjXzEua2V5RGlyZWN0aXZlU3BlYy5uYW1lKSB7XG4gICAgICAgICAgICAgICAgICA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SB7XG4gICAgICAgICAgICAgICAgICAgIGZpZWxkcy5wdXNoKGZpZWxkKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGluY2x1ZGVJbnRlcmZhY2VGaWVsZHNJbXBsZW1lbnRhdGlvbnMgJiYgKDAsIGRlZmluaXRpb25zXzEuaXNJbnRlcmZhY2VUeXBlKSh0KSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbXBsVHlwZSBvZiB0LnBvc3NpYmxlUnVudGltZVR5cGVzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbXBsRmllbGQgPSBpbXBsVHlwZS5maWVsZChmKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW1wbEZpZWxkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGZpZWxkcy5wdXNoKGltcGxGaWVsZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIHJldHVybiBmaWVsZDtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICB2YWxpZGF0ZSxcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIGNhdGNoIChlKSB7XG4gICAgICAgIGNvbnN0IGlzR3JhcGhRTEVycm9yID0gKDAsIGVycm9yXzEuZXJyb3JDYXVzZXMpKGUpICE9PSB1bmRlZmluZWQ7XG4gICAgICAgIGlmICghaXNHcmFwaFFMRXJyb3IgfHwgdmFsaWRhdGUpIHtcbiAgICAgICAgICAgIHRocm93IGU7XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmV0dXJuIGZpZWxkcztcbn1cbmV4cG9ydHMuY29sbGVjdFRhcmdldEZpZWxkcyA9IGNvbGxlY3RUYXJnZXRGaWVsZHM7XG5mdW5jdGlvbiB2YWxpZGF0ZUZpZWxkU2V0V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pZWxkKGV4cG9ydHMuZW50aXRpZXNGaWVsZE5hbWUpO1xuICAgICAgICBjb25zdCBlbnRpdHlUeXBlID0gbWV0YWRhdGEuZW50aXR5VHlwZSgpO1xuICAgICAgICBpZiAoZW50aXR5VHlwZSkge1xuICAgICAgICAgICAgY29uc3QgZW50aXR5RmllbGRUeXBlID0gbmV3IGRlZmluaXRpb25zXzEuTm9uTnVsbFR5cGUobmV3IGRlZmluaXRpb25zXzEuTGlzdFR5cGUoZW50aXR5VHlwZSkpO1xuICAgICAgICAgICAgaWYgKCFlbnRpdHlGaWVsZCkge1xuICAgICAgICAgICAgICAgIHF1ZXJ5VHlwZS5hZGRGaWVsZChleHBvcnRzLmVudGl0aWVzRmllbGROYW1lLCBlbnRpdHlGaWVsZFR5cGUpXG4gICAgICAgICAgICAgICAgICAgIC5hZGRBcmd1bWVudCgncmVwcmVzZW50YXRpb25zJywgbmV3IGRlZmluaXRpb25zXzEuTm9uTnVsbFR5cGUobmV3IGRlZmluaXRpb25zXzEuTGlzdFR5cGUobmV3IGRlZmluaXRpb25zXzEuTm9uTnVsbFR5cGUobWV0YWRhdGEuYW55VHlwZSgpKSkpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKCFlbnRpdHlGaWVsZC50eXBlKSB7XG4gICAgICAgICAgICAgICAgZW50aXR5RmllbGQudHlwZSA9IGVudGl0eVR5cGU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoZW50aXR5RmllbGQpIHtcbiAgICAgICAgICAgIGVudGl0eUZpZWxkLnJlbW92ZSgpO1xuICAgICAgICB9XG4gICAgICAgIGlmICghcXVlcnlUeXBlLmZpZWxkKGV4cG9ydHMuc2VydmljZUZpZWxkTmFtZSkpIHtcbiAgICAgICAgICAgIHF1ZXJ5VHlwZS5hZGRGaWVsZChleHBvcnRzLnNlcnZpY2VGaWVsZE5hbWUsIG5ldyBkZWZpbml0aW9uc18xLk5vbk51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lzLm1ldGFkYXRhKCk7XG4gICAgICAgIGNvbnN0IGV4dGVuZHNEaXJlY3RpdmUgPSBtZXRhZGF0YS5leHRlbmRzRGlyZWN0aXZlKCk7XG4gICAgICAgIGZvciAoY29uc3Qga2V5IG9mIG1ldGFkYXRhLmtleURpcmVjdGl2ZSgpLmFwcGxpY2F0aW9ucygpKSB7XG4gICAgICAgICAgICBjb25zdCBwYXJlbnRUeXBlID0ga2V5LnBhcmVudDtcbiAgICAgICAgICAgIGlmICghKGtleS5vZkV4dGVuc2lvbigpIHx8IHBhcmVudFR5cGUuaGFzQXBwbGllZERpcmVjdGl2ZShleHRlbmRzRGlyZWN0aXZlKSkpIHtcbiAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGNvbGxlY3RUYXJnZXRGaWVsZHMoe1xuICAgICAgICAgICAgICAgIHBhcmVudFR5cGUsXG4gICAgICAgICAgICAgICAgZGlyZWN0aXZlOiBrZXksXG4gICAgICAgICAgICAgICAgaW5jbHVkZUludGVyZmFjZUZpZWxkc0ltcGxlbWVudGF0aW9uczogZmFsc2UsXG4gICAgICAgICAgICAgICAgdmFsaWRhdGU6IGZhbHNlLFxuICAgICAgICAgICAgfSkuZmlsdGVyKChmaWVsZCkgPT4gZmllbGQuaGFzQXBwbGllZERpcmVjdGl2ZSh0aGlzLmV4dGVybmFsRGlyZWN0aXZlKSlcbiAgICAgICAgICAgICAgICAuZm9yRWFjaCgoZmllbGQpID0+IHRoaXMuZmFrZUV4dGVybmFsRmllbGRzLmFkZChmaWVsZC5jb29yZGluYXRlKSk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgY29sbGVjdFByb3ZpZGVkRmllbGRzKCkge1xuICAgICAgICBmb3IgKGNvbnN0IHByb3ZpZGVzIG9mIHRoaXMubWV0YWRhdGEoKS5wcm92aWRlc0RpcmVjdGl2ZSgpLmFwcGxpY2F0aW9ucygpKSB7XG4gICAgICAgICAgICBjb25zdCBwYX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ICAgICAgICAgIG9wZXJhdGlvbixcbiAgICAgICAgICAgICAgICAgICAgICAgIHR5cGU6IHsga2luZDogZ3JhcGhxbF8xLktpbmQuTkFNRURfVFlQRSwgbmFtZTogeyBraW5kOiBncmFwaHFsXzEuS2luZC5OQU1FLCB2YWx1ZTogdHlwZS5uYW1lIH0gfSxcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZGVmaW5pdGlvbiA9IHtcbiAgICAgICAgICAgICAgICBraW5kOiBncmFwaHFsXzEuS2luZC5TQ0hFTUFfREVGSU5JVElPTixcbiAgICAgICAgICAgICAgICBkZXNjcmlwdGlvbjogc2NoZW1hLmRlc2NyaXB0aW9uID8ge1xuICAgICAgICAgICAgICAgICAgICBraW5kOiBncmFwaHFsXzEuS2luZC5TVFJJTkcsXG4gICAgICAgICAgICAgICAgICAgIHZhbHVlOiBzY2hlbWEuZGVzY3JpcHRpb24sXG4gICAgICAgICAgICAgICAgfSA6IHVuZGVmaW5lZCxcbiAgICAgICAgICAgICAgICBvcGVyYXRpb25UeXBlcyxcbiAgICAgICAgICAgIH07XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGRlZmluaXRpb24sXG4gICAgICAgICAgICBleHRlbnNpb25zOiBbXSxcbiAgICAgICAgfTtcbiAgICB9XG59XG5mdW5jdGlvbiBoYXNOb25EZWZhdWx0Um9vdE5hbWVzKHNjaGVtYSkge1xuICAgIHJldHVybiBhbGxPcGVyYXRpb25UeXBlTm9kZS5zb21lKCh0KSA9PiBpc05vbkRlZmF1bHRSb290TmFtZShzY2hlbWEuZ2V0Um9vdFR5cGUodCksIHQpKTtcbn1cbmZ1bmN0aW9uIGlzTm9uRGVmYXVsdFJvb3ROYW1lKHR5cGUsIG9wZXJhdGlvbikge1xuICAgIHJldHVybiAhIXR5cGUgJiYgdHlwZS5uYW1lICE9PSAoMCwgZGVmaW5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VmaW5pdGlvbikpIHtcbiAgICAgICAgICAgIHJldHVybiB0cnVlO1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKChlbGVtZW50IGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5GaWVsZERlZmluaXRpb24pIHx8XG4gICAgICAgICAgICAoZWxlbWVudCBpbnN0YW5jZW9mIGRlZmluaXRpb25zXzEuQXJndW1lbnREZWZpbml0aW9uKSB8fFxuICAgICAgICAgICAgKGVsZW1lbnQgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLklucHV0RmllbGREZWZpbml0aW9uKSB8fFxuICAgICAgICAgICAgKGVsZW1lbnQgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLkVudW1WYWx1ZSkpIHtcbiAgICAgICAgICAgIHJldHVybiBpc0luQVBJU2NoZW1hKGVsZW1lbnQucGFyZW50KTtcbiAgICAgICAgfVxuICAgICAgICAoMCwgdXRpbHNfMS5hc3NlcnQpKGZhbHNlLCBcIlVucmVhY2hhYmxlIGNvZGUsIGVsZW1lbnQgaXMgb2YgdW5rbm93biB0eXBlLlwiKTtcbiAgICB9XG4gICAgZnVuY3Rpb24gZmV0Y2hJbmFjY2Vzc2libGVFbGVtZW50c0RlZXAoZWxlbWVudCkge1xuICAgICAgICBjb25zdCBpbmFjY2Vzc2libGVFbGVtZW50cyA9IFtdO1xuICAgICAgICBpZiAoaXNJbmFjY2Vzc2libGUoZWxlbWVudCkpIHtcbiAgICAgICAgICAgIGluYWNjZXNzaWJsZUVsZW1lbnRzLnB1c2goZWxlbWVudCk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKChlbGVtZW50IGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5PYmplY3RUeXBlKSB8fFxuICAgICAgICAgICAgKGVsZW1lbnQgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLkludGVyZmFjZVR5cGUpIHx8XG4gICAgICAgICAgICAoZWxlbWVudCBpbnN0YW5jZW9mIGRlZmluaXRpb25zXzEuSW5wdXRPYmplY3RUeXBlKSkge1xuICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZCBvZiBlbGVtZW50LmZpZWxkcygpKSB7XG4gICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlRWxlbWVudHMucHVzaCguLi5mZXRjaEluYWNjZXNzaWJsZUVsZW1lbnRzRGVlcChmaWVsZCkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGluYWNjZXNzaWJsZUVsZW1lbnRzO1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKGVsZW1lbnQgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLkVudW1UeXBlKSB7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IGVudW1WYWx1ZSBvZiBlbGVtZW50LnZhbHVlcykge1xuICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZUVsZW1lbnRzLnB1c2goLi4uZmV0Y2hJbmFjY2Vzc2libGVFbGVtZW50c0RlZXAoZW51bVZhbHVlKSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICByZXR1cm4gaW5hY2Nlc3NpYmxlRWxlbWVudHM7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoKGVsZW1lbnQgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLkRpcmVjdGl2ZURlZmluaXRpb24pIHx8XG4gICAgICAgICAgICAoZWxlbWVudCBpbnN0YW5jZW9mIGRlZmluaXRpb25zXzEuRmllbGREZWZpbml0aW9uKSkge1xuICAgICAgICAgICAgZm9yIChjb25zdCBhcmd1bWVudCBvZiBlbGVtZW50LmFyZ3VtZW50cygpKSB7XG4gICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlRWxlbWVudHMucHVzaCguLi5mZXRjaEluYWNjZXNzaWJsZUVsZW1lbnRzRGVlcChhcmd1bWVudCkpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIGluYWNjZXNzaWJsZUVsZW1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RzRGVlcCh0eXBlKTtcbiAgICAgICAgICAgIGlmIChpbmFjY2Vzc2libGVFbGVtZW50cy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgZXJyb3JzLnB1c2goZXJyb3JfMS5FUlJPUlMuRElTQUxMT1dFRF9JTkFDQ0VTU0lCTEUuZXJyKGBCdWlsdC1pbiB0eXBlIFwiJHt0eXBlLmNvb3JkaW5hdGV9XCIgY2Fubm90IHVzZSBAaW5hY2Nlc3NpYmxlLmAsIHtcbiAgICAgICAgICAgICAgICAgICAgbm9kZXM6IHR5cGUuc291cmNlQVNULFxuICAgICAgICAgICAgICAgICAgICBleHRlbnNpb25zOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfZWxlbWVudHM6IGluYWNjZXNzaWJsZUVsZW1lbnRzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLm1hcCgoZWxlbWVudCkgPT4gZWxlbWVudC5jb29yZGluYXRlKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZV9yZWZlcmVuY2VyczogW3R5cGUuY29vcmRpbmF0ZV0sXG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoaXNGZWF0dXJlRGVmaW5pdGlvbih0eXBlKSkge1xuICAgICAgICAgICAgY29uc3QgaW5hY2Nlc3NpYmxlRWxlbWVudHMgPSBmZXRjaEluYWNjZXNzaWJsZUVsZW1lbnRzRGVlcCh0eXBlKTtcbiAgICAgICAgICAgIGlmIChpbmFjY2Vzc2libGVFbGVtZW50cy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgZXJyb3JzLnB1c2goZXJyb3JfMS5FUlJPUlMuRElTQUxMT1dFRF9JTkFDQ0VTU0lCTEUuZXJyKGBDb3JlIGZlYXR1cmUgdHlwZSBcIiR7dHlwZS5jb29yZGluYXRlfVwiIGNhbm5vdCB1c2UgQGluYWNjZXNzaWJsZS5gLCB7XG4gICAgICAgICAgICAgICAgICAgIG5vZGVzOiB0eXBlLnNvdXJjZUFTVCxcbiAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX2VsZW1lbnRzOiBpbmFjY2Vzc2libGVFbGVtZW50c1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC5tYXAoKGVsZW1lbnQpID0+IGVsZW1lbnQuY29vcmRpbmF0ZSksXG4gICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfcmVmZXJlbmNlcnM6IFt0eXBlLmNvb3JkaW5hdGVdLFxuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKGlzSW5hY2Nlc3NpYmxlKHR5cGUpKSB7XG4gICAgICAgICAgICBjb25zdCByZWZlcmVuY2VycyA9IHR5cGUucmVmZXJlbmNlcnMoKTtcbiAgICAgICAgICAgIGZvciAoY29uc3QgcmVmZXJlbmNlciBvZiByZWZlcmVuY2Vycykge1xuICAgICAgICAgICAgICAgIGlmIChyZWZlcmVuY2VyIGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5GaWVsZERlZmluaXRpb24gfHxcbiAgICAgICAgICAgICAgICAgICAgcmVmZXJlbmNlciBpbnN0YW5jZW9mIGRlZmluaXRpb25zXzEuQXJndW1lbnREZWZpbml0aW9uIHx8XG4gICAgICAgICAgICAgICAgICAgIHJlZmVyZW5jZXIgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLklucHV0RmllbGREZWZpbml0aW9uKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc0luQVBJU2NoZW1hKHJlZmVyZW5jZXIpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMucHVzaChlcnJvcl8xLkVSUk9SUy5SRUZFUkVOQ0VEX0lOQUNDRVNTSUJMRS5lcnIoYFR5cGUgXCIke3R5cGUuY29vcmRpbmF0ZX1cIiBpcyBAaW5hY2Nlc3NpYmxlIGJ1dCBpcyByZWZlcmVuY2VkYCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYCBieSBcIiR7cmVmZXJlbmNlci5jb29yZGluYXRlfVwiLCB3aGljaCBpcyBpbiB0aGUgQVBJIHNjaGVtYS5gLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZXM6IHR5cGUuc291cmNlQVNULFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dGVuc2lvbnM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX2VsZW1lbnRzOiBbdHlwZS5jb29yZGluYXRlXSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX3JlZmVyZW5jZXJzOiBbcmVmZXJlbmNlci5jb29yZGluYXRlXSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZiAocmVmZXJlbmNlciBpbnN0YW5jZW9mIGRlZmluaXRpb25zXzEuU2NoZW1hRGVmaW5pdGlvbikge1xuICAgICAgICAgICAgICAgICAgICBpZiAodHlwZSA9PT0gcmVmZXJlbmNlci5yb290VHlwZSgncXVlcnknKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzLnB1c2goZXJyb3JfMS5FUlJPUlMuUVVFUllfUk9PVF9UWVBFX0lOQUNDRVNTSUJMRS5lcnIoYFR5cGUgXCIke3R5cGUuY29vcmRpbmF0ZX1cIiBpcyBAaW5hY2Nlc3NpYmxlIGJ1dCBpcyB0aGUgcm9vdGAgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGAgcXVlcnkgdHlwZSwgd2hpY2ggbXVzdCBiZSBpbiB0aGUgQVBJIHNjaGVtYS5gLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZXM6IHR5cGUuc291cmNlQVNULFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dGVuc2lvbnM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX2VsZW1lbnRzOiBbdHlwZS5jb29yZGluYXRlXSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICBpZiAoKHR5cGUgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLk9iamVjdFR5cGUpIHx8XG4gICAgICAgICAgICAgICAgKHR5cGUgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLkludGVyZmFjZVR5cGUpIHx8XG4gICAgICAgICAgICAgICAgKHR5cGUgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLklucHV0T2JqZWN0VHlwZSkpIHtcbiAgICAgICAgICAgICAgICBsZXQgaXNFbXB0eSA9IHRydWU7XG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZCBvZiB0eXBlLmZpZWxkcygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmICghaXNJbmFjY2Vzc2libGUoZmllbGQpKVxuICAgICAgICAgICAgICAgICAgICAgICAgaXNFbXB0eSA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoaXNFbXB0eSkge1xuICAgICAgICAgICAgICAgICAgICBlcnJvcnMucHVzaChlcnJvcl8xLkVSUk9SUy5PTkxZX0lOQUNDRVNTSUJMRV9DSElMRFJFTi5lcnIoYFR5cGUgXCIke3R5cGUuY29vcmRpbmF0ZX1cIiBpcyBpbiB0aGUgQVBJIHNjaGVtYSBidXQgYWxsIG9mIGl0c2AgK1xuICAgICAgICAgICAgICAgICAgICAgICAgYCAkeyh0eXBlIGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5JbnB1dE9iamVjdFR5cGUpID8gJ2lucHV0ICcgOiAnJ31maWVsZHNgICtcbiAgICAgICAgICAgICAgICAgICAgICAgIGAgYXJlIEBpbmFjY2Vzc2libGUuYCwge1xuICAgICAgICAgICAgICAgICAgICAgICAgbm9kZXM6IHR5cGUuc291cmNlQVNULFxuICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZV9lbGVtZW50czogdHlwZS5maWVsZHMoKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAubWFwKChmaWVsZCkgPT4gZmllbGQuY29vcmRpbmF0ZSksXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX3JlZmVyZW5jZXJzOiBbdHlwZS5jb29yZGluYXRlXSxcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKHR5cGUgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLlVuaW9uVHlwZSkge1xuICAgICAgICAgICAgICAgIGxldCBpc0VtcHR5ID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IG1lbWJlciBvZiB0eXBlLnR5cGVzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFpc0luYWNjZXNzaWJsZShtZW1iZXIpKVxuICAgICAgICAgICAgICAgICAgICAgICAgaXNFbXB0eSA9IGZhbHNlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBpZiAoaXNFbXB0eSkge1xuICAgICAgICAgICAgICAgICAgICBlcnJvcnMucHVzaChlcnJvcl8xLkVSUk9SUy5PTkxZX0lOQUNDRVNTSUJMRV9DSElMRFJFTi5lcnIoYFR5cGUgXCIke3R5cGUuY29vcmRpbmF0ZX1cIiBpcyBpbiB0aGUgQVBJIHNjaGVtYSBidXQgYWxsIG9mIGl0c2AgK1xuICAgICAgICAgICAgICAgICAgICAgICAgYCBtZW1iZXJzIGFyZSBAaW5hY2Nlc3NpYmxlLmAsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVzOiB0eXBlLnNvdXJjZUFTVCxcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4dGVuc2lvbnM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfZWxlbWVudHM6IHR5cGUudHlwZXMoKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAubWFwKCh0eXBlKSA9PiB0eXBlLmNvb3JkaW5hdGUpLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZV9yZWZlcmVuY2VyczogW3R5cGUuY29vcmRpbmF0ZV0sXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIGlmICh0eXBlIGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5FbnVtVHlwZSkge1xuICAgICAgICAgICAgICAgIGxldCBpc0VtcHR5ID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGVudW1WYWx1ZSBvZiB0eXBlLnZhbHVlcykge1xuICAgICAgICAgICAgICAgICAgICBpZiAoIWlzSW5hY2Nlc3NpYmxlKGVudW1WYWx1ZSkpXG4gICAgICAgICAgICAgICAgICAgICAgICBpc0VtcHR5ID0gZmFsc2U7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmIChpc0VtcHR5KSB7XG4gICAgICAgICAgICAgICAgICAgIGVycm9ycy5wdXNoKGVycm9yXzEuRVJST1JTLk9OTFlfSU5BQ0NFU1NJQkxFX0NISUxEUkVOLmVycihgVHlwZSBcIiR7dHlwZS5jb29yZGluYXRlfVwiIGlzIGluIHRoZSBBUEkgc2NoZW1hIGJ1dCBhbGwgb2YgaXRzYCArXG4gICAgICAgICAgICAgICAgICAgICAgICBgIHZhbHVlcyBhcmUgQGluYWNjZXNzaWJsZS5gLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICBub2RlczogdHlwZS5zb3VyY2VBU1QsXG4gICAgICAgICAgICAgICAgICAgICAgICBleHRlbnNpb25zOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX2VsZW1lbnRzOiB0eXBlLnZhbHVlc1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAubWFwKChlbnVtVmFsdWUpID0+IGVudW1WYWx1ZS5jb29yZGluYXRlKSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfcmVmZXJlbmNlcnM6IFt0eXBlLmNvb3JkaW5hdGVdLFxuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKCh0eXBlIGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5PYmplY3RUeXBlKSB8fFxuICAgICAgICAgICAgICAgICh0eXBlIGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5JbnRlcmZhY2VUeXBlKSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IGltcGxlbWVudGVkSW50ZXJmYWNlcyA9IHR5cGUuaW50ZXJmYWNlcygpO1xuICAgICAgICAgICAgICAgIGNvbnN0IGltcGxlbWVudGluZ1R5cGVzID0gW107XG4gICAgICAgICAgICAgICAgaWYgKHR5cGUgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLkludGVyZmFjZVR5cGUpIHtcbiAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCByZWZlcmVuY2VyIG9mIHR5cGUucmVmZXJlbmNlcnMoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKChyZWZlcmVuY2VyIGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5PYmplY3RUeXBlKSB8fFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIChyZWZlcmVuY2VyIGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5JbnRlcmZhY2VUeXBlKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltcGxlbWVudGluZ1R5cGVzLnB1c2gocmVmZXJlbmNlcik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZCBvZiB0eXBlLmZpZWxkcygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc0luYWNjZXNzaWJsZShmaWVsZCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW1wbGVtZW50ZWRJbnRlcmZhY2Ugb2YgaW1wbGVtZW50ZWRJbnRlcmZhY2VzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1wbGVtZW50ZWRGaWVsZCA9IGltcGxlbWVudGVkSW50ZXJmYWNlLmZpZWxkKGZpZWxkLm5hbWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbXBsZW1lbnRlZEZpZWxkICYmIGlzSW5BUElTY2hlbWEoaW1wbGVtZW50ZWRGaWVsZCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzLnB1c2goZXJyb3JfMS5FUlJPUlMuSU1QTEVNRU5URURfQllfSU5BQ0NFU1NJQkxFLmVycihgRmllbGQgXCIke2ZpZWxkLmNvb3JkaW5hdGV9XCIgaXMgQGluYWNjZXNzaWJsZSBidXRgICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGAgaW1wbGVtZW50cyB0aGUgaW50ZXJmYWNlIGZpZWxkYCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIFwiJHtpbXBsZW1lbnRlZEZpZWxkLmNvb3JkaW5hdGV9XCIsIHdoaWNoIGlzIGluIHRoZSBBUElgICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGAgc2NoZW1hLmAsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVzOiBmaWVsZC5zb3VyY2VBU1QsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRlbnNpb25zOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX2VsZW1lbnRzOiBbZmllbGQuY29vcmRpbmF0ZV0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX3JlZmVyZW5jZXJzOiBbaW1wbGVtZW50ZWRGaWVsZC5jb29yZGluYXRlXSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYXJndW1lbnQgb2YgZmllbGQuYXJndW1lbnRzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNJbmFjY2Vzc2libGUoYXJndW1lbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhcmd1bWVudC5pc1JlcXVpcmVkKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9ycy5wdXNoKGVycm9yXzEuRVJST1JTLlJFUVVJUkVEX0lOQUNDRVNTSUJMRS5lcnIoYEFyZ3VtZW50IFwiJHthcmd1bWVudC5jb29yZGluYXRlfVwiIGlzIEBpbmFjY2Vzc2libGUgYnV0YCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgYCBpcyBhIHJlcXVpcmVkIGFyZ3VtZW50IG9mIGl0cyBmaWVsZC5gLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZXM6IGFyZ3VtZW50LnNvdXJjZUFTVCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRlbnNpb25zOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZV9lbGVtZW50czogW2FyZ3VtZW50LmNvb3JkaW5hdGVdLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfcmVmZXJlbmNlcnM6IFthcmd1bWVudC5jb29yZGluYXRlXSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZm9yIChjb25zdCBpbXBsZW1lbnRpbmdUeXBlIG9mIGltcGxlbWVudGluZ1R5cGVzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbXBsZW1lbnRpbmdGaWVsZCA9IGltcGxlbWVudGluZ1R5cGUuZmllbGQoZmllbGQubmFtZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMCwgdXRpbHNfMS5hc3NlcnQpKGltcGxlbWVudGluZ0ZpZWxkLCBcIlNjaGVtYSBzaG91bGQgaGF2ZSBiZWVuIHZhbGlkLCBidXQgYW4gaW1wbGVtZW50aW5nIHR5cGVcIiArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXCIgZGlkIG5vdCBpbXBsZW1lbnQgb25lIG9mIHRoaXMgdHlwZSdzIGZpZWxkcy5cIik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBpbXBsZW1lbnRpbmdBcmd1bWVudCA9IGltcGxlbWVudGluZ0ZpZWxkXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmFyZ3VtZW50KGFyZ3VtZW50Lm5hbWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgKDAsIHV0aWxzXzEuYXNzZXJ0KShpbXBsZW1lbnRpbmdBcmd1bWVudCwgXCJTY2hlbWEgc2hvdWxkIGhhdmUgYmVlbiB2YWxpZCwgYnV0IGFuIGltcGxlbWVudGluZyB0eXBlXCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwiIGRpZCBub3QgaW1wbGVtZW50IG9uZSBvZiB0aGlzIHR5cGUncyBmaWVsZCdzIGFyZ3VtZW50cy5cIik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNJbkFQSVNjaGVtYShpbXBsZW1lbnRpbmdBcmd1bWVudCkgJiZcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbXBsZW1lbnRpbmdBcmd1bWVudC5pc1JlcXVpcmVkKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMucHVzaChlcnJvcl8xLkVSUk9SUy5SRVFVSVJFRF9JTkFDQ0VTU0lCTEUuZXJyKGBBcmd1bWVudCBcIiR7YXJndW1lbnQuY29vcmRpbmF0ZX1cIiBpcyBAaW5hY2Nlc3NpYmxlYCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGAgYnV0IGlzIGltcGxlbWVudGVkIGJ5IHRoZSByZXF1aXJlZCBhcmd1bWVudGAgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIFwiJHtpbXBsZW1lbnRpbmdBcmd1bWVudC5jb29yZGluYXRlfVwiLCB3aGljaCBpc2AgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIGluIHRoZSBBUEkgc2NoZW1hLmAsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZXM6IGFyZ3VtZW50LnNvdXJjZUFTVCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uczoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX2VsZW1lbnRzOiBbYXJndW1lbnQuY29vcmRpbmF0ZV0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfcmVmZXJlbmNlcnM6IFtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbXBsZW1lbnRpbmdBcmd1bWVudC5jb29yZGluYXRlLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGltcGxlbWVudGVkSW50ZXJmYWNlIG9mIGltcGxlbWVudGVkSW50ZXJmYWNlcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgY29uc3QgaW1wbGVtZW50ZWRBcmd1bWVudCA9IChfYSA9IGltcGxlbWVudGVkSW50ZXJmYWNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLmZpZWxkKGZpZWxkLm5hbWUpKSA9PT0gbnVsbCB8fCBfYSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2EuYXJndW1lbnQoYXJndW1lbnQubmFtZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaW1wbGVtZW50ZWRBcmd1bWVudCAmJlxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlzSW5BUElTY2hlbWEoaW1wbGVtZW50ZWRBcmd1bWVudCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMucHVzaChlcnJvcl8xLkVSUk9SUy5JTVBMRU1FTlRFRF9CWV9JTkFDQ0VTU0lCTEUuZXJyKGBBcmd1bWVudCBcIiR7YXJndW1lbnQuY29vcmRpbmF0ZX1cIiBpcyBAaW5hY2Nlc3NpYmxlYCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGAgYnV0IGltcGxlbWVudHMgdGhlIGludGVyZmFjZSBhcmd1bWVudGAgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIFwiJHtpbXBsZW1lbnRlZEFyZ3VtZW50LmNvb3JkaW5hdGV9XCIsIHdoaWNoIGlzIGluYCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGAgdGhlIEFQSSBzY2hlbWEuYCwge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlczogYXJndW1lbnQuc291cmNlQVNULFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRlbnNpb25zOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfZWxlbWVudHM6IFthcmd1bWVudC5jb29yZGluYXRlXSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZV9yZWZlcmVuY2VyczogW1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGltcGxlbWVudGVkQXJndW1lbnQuY29vcmRpbmF0ZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIF0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIGlmICh0eXBlIGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5JbnB1dE9iamVjdFR5cGUpIHtcbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGlucHV0RmllbGQgb2YgdHlwZS5maWVsZHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNJbmFjY2Vzc2libGUoaW5wdXRGaWVsZCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpbnB1dEZpZWxkLmlzUmVxdWlyZWQoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9ycy5wdXNoKGVycm9yXzEuRVJST1JTLlJFUVVJUkVEX0lOQUNDRVNTSUJMRS5lcnIoYElucHV0IGZpZWxkIFwiJHtpbnB1dEZpZWxkLmNvb3JkaW5hdGV9XCIgaXMgQGluYWNjZXNzaWJsZWAgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIGJ1dCBpcyBhIHJlcXVpcmVkIGlucHV0IGZpZWxkIG9mIGl0cyB0eXBlLmAsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgbm9kZXM6IGlucHV0RmllbGQuc291cmNlQVNULFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRlbnNpb25zOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfZWxlbWVudHM6IFtpbnB1dEZpZWxkLmNvb3JkaW5hdGVdLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX3JlZmVyZW5jZXJzOiBbaW5wdXRGaWVsZC5jb29yZGluYXRlXSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICgwLCB1dGlsc18xLmFzc2VydCkoZGVmYXVsdFZhbHVlUmVmZXJlbmNlcnMsIFwiSW5wdXQgZmllbGRzIGNhbid0IGJlIEBpbmFjY2Vzc2libGUgaW4gdjAuMSwgYnV0IGRlZmF1bHQgdmFsdWVcIiArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXCIgcmVmZXJlbmNlcnMgd2VyZW4ndCBjb21wdXRlZCAod2hpY2ggaXMgb25seSBza2lwcGVkIGZvciB2MC4xKS5cIik7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWZlcmVuY2VycyA9IChfYiA9IGRlZmF1bHRWYWx1ZVJlZmVyZW5jZXJzLmdldChpbnB1dEZpZWxkKSkgIT09IG51bGwgJiYgX2IgIT09IHZvaWQgMCA/IF9iIDogW107XG4gICAgICAgICAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IHJlZmVyZW5jZXIgb2YgcmVmZXJlbmNlcnMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNJbkFQSVNjaGVtYShyZWZlcmVuY2VyKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMucHVzaChlcnJvcl8xLkVSUk9SUy5ERUZBVUxUX1ZBTFVFX1VTRVNfSU5BQ0NFU1NJQkxFLmVycihgSW5wdXQgZmllbGQgXCIke2lucHV0RmllbGQuY29vcmRpbmF0ZX1cIiBpcyBAaW5hY2Nlc3NpYmxlYCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIGJ1dCBpcyB1c2VkIGluIHRoZSBkZWZhdWx0IHZhbHVlIG9mYCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIFwiJHtyZWZlcmVuY2VyLmNvb3JkaW5hdGV9XCIsIHdoaWNoIGlzIGluIHRoZSBBUEkgc2NoZW1hLmAsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVzOiB0eXBlLnNvdXJjZUFTVCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dGVuc2lvbnM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfZWxlbWVudHM6IFt0eXBlLmNvb3JkaW5hdGVdLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZV9yZWZlcmVuY2VyczogW3JlZmVyZW5jZXIuY29vcmRpbmF0ZV0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIGlmICh0eXBlIGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5FbnVtVHlwZSkge1xuICAgICAgICAgICAgICAgIGZvciAoY29uc3QgZW51bVZhbHVlIG9mIHR5cGUudmFsdWVzKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc0luYWNjZXNzaWJsZShlbnVtVmFsdWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAoMCwgdXRpbHNfMS5hc3NlcnQpKGRlZmF1bHRWYWx1ZVJlZmVyZW5jZXJzLCBcIkVudW0gdmFsdWVzIGNhbid0IGJlIEBpbmFjY2Vzc2libGUgaW4gdjAuMSwgYnV0IGRlZmF1bHQgdmFsdWVcIiArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgXCIgcmVmZXJlbmNlcnMgd2VyZW4ndCBjb21wdXRlZCAod2hpY2ggaXMgb25seSBza2lwcGVkIGZvciB2MC4xKS5cIik7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCByZWZlcmVuY2VycyA9IChfYyA9IGRlZmF1bHRWYWx1ZVJlZmVyZW5jZXJzLmdldChlbnVtVmFsdWUpKSAhPT0gbnVsbCAmJiBfYyAhPT0gdm9pZCAwID8gX2MgOiBbXTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgcmVmZXJlbmNlciBvZiByZWZlcmVuY2Vycykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmIChpc0luQVBJU2NoZW1hKHJlZmVyZW5jZXIpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9ycy5wdXNoKGVycm9yXzEuRVJST1JTLkRFRkFVTFRfVkFMVUVfVVNFU19JTkFDQ0VTU0lCTEUuZXJyKGBFbnVtIHZhbHVlIFwiJHtlbnVtVmFsdWUuY29vcmRpbmF0ZX1cIiBpcyBAaW5hY2Nlc3NpYmxlYCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIGJ1dCBpcyB1c2VkIGluIHRoZSBkZWZhdWx0IHZhbHVlIG9mYCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBgIFwiJHtyZWZlcmVuY2VyLmNvb3JkaW5hdGV9XCIsIHdoaWNoIGlzIGluIHRoZSBBUEkgc2NoZW1hLmAsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG5vZGVzOiB0eXBlLnNvdXJjZUFTVCxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dGVuc2lvbnM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfZWxlbWVudHM6IFt0eXBlLmNvb3JkaW5hdGVdLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZV9yZWZlcmVuY2VyczogW3JlZmVyZW5jZXIuY29vcmRpbmF0ZV0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cb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gICB9XG4gICAgICAgICAgICAgICAgfSkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKGlzRmVhdHVyZURlZmluaXRpb24oZGlyZWN0aXZlKSkge1xuICAgICAgICAgICAgY29uc3QgaW5hY2Nlc3NpYmxlRWxlbWVudHMgPSBmZXRjaEluYWNjZXNzaWJsZUVsZW1lbnRzRGVlcChkaXJlY3RpdmUpO1xuICAgICAgICAgICAgaWYgKGluYWNjZXNzaWJsZUVsZW1lbnRzLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgICAgICBlcnJvcnMucHVzaChlcnJvcl8xLkVSUk9SUy5ESVNBTExPV0VEX0lOQUNDRVNTSUJMRS5lcnIoYENvcmUgZmVhdHVyZSBkaXJlY3RpdmUgXCIke2RpcmVjdGl2ZS5jb29yZGluYXRlfVwiIGNhbm5vdCB1c2UgQGluYWNjZXNzaWJsZS5gLCB7XG4gICAgICAgICAgICAgICAgICAgIG5vZGVzOiBkaXJlY3RpdmUuc291cmNlQVNULFxuICAgICAgICAgICAgICAgICAgICBleHRlbnNpb25zOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfZWxlbWVudHM6IGluYWNjZXNzaWJsZUVsZW1lbnRzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLm1hcCgoZWxlbWVudCkgPT4gZWxlbWVudC5jb29yZGluYXRlKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZV9yZWZlcmVuY2VyczogW2RpcmVjdGl2ZS5jb29yZGluYXRlXSxcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmICh0eXBlU3lzdGVtTG9jYXRpb25zLmxlbmd0aCA+IDApIHtcbiAgICAgICAgICAgIGNvbnN0IGluYWNjZXNzaWJsZUVsZW1lbnRzID0gZmV0Y2hJbmFjY2Vzc2libGVFbGVtZW50c0RlZXAoZGlyZWN0aXZlKTtcbiAgICAgICAgICAgIGlmIChpbmFjY2Vzc2libGVFbGVtZW50cy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgZXJyb3JzLnB1c2goZXJyb3JfMS5FUlJPUlMuRElTQUxMT1dFRF9JTkFDQ0VTU0lCTEUuZXJyKGBEaXJlY3RpdmUgXCIke2RpcmVjdGl2ZS5jb29yZGluYXRlfVwiIGNhbm5vdCB1c2UgQGluYWNjZXNzaWJsZWAgK1xuICAgICAgICAgICAgICAgICAgICBgIGJlY2F1c2UgaXQgbWF5IGJlIGFwcGxpZWQgdG8gdGhlc2UgdHlwZS1zeXN0ZW0gbG9jYXRpb25zOmAgK1xuICAgICAgICAgICAgICAgICAgICBgICR7dHlwZVN5c3RlbUxvY2F0aW9ucy5qb2luKCcsICcpfS5gLCB7XG4gICAgICAgICAgICAgICAgICAgIG5vZGVzOiBkaXJlY3RpdmUuc291cmNlQVNULFxuICAgICAgICAgICAgICAgICAgICBleHRlbnNpb25zOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpbmFjY2Vzc2libGVfZWxlbWVudHM6IGluYWNjZXNzaWJsZUVsZW1lbnRzXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLm1hcCgoZWxlbWVudCkgPT4gZWxlbWVudC5jb29yZGluYXRlKSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZV9yZWZlcmVuY2VyczogW2RpcmVjdGl2ZS5jb29yZGluYXRlXSxcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIGZvciAoY29uc3QgYXJndW1lbnQgb2YgZGlyZWN0aXZlLmFyZ3VtZW50cygpKSB7XG4gICAgICAgICAgICAgICAgaWYgKGFyZ3VtZW50LmlzUmVxdWlyZWQoKSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXNJbmFjY2Vzc2libGUoYXJndW1lbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMucHVzaChlcnJvcl8xLkVSUk9SUy5SRVFVSVJFRF9JTkFDQ0VTU0lCTEUuZXJyKGBBcmd1bWVudCBcIiR7YXJndW1lbnQuY29vcmRpbmF0ZX1cIiBpcyBAaW5hY2Nlc3NpYmxlIGJ1dCBpcyBhYCArXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgYCByZXF1aXJlZCBhcmd1bWVudCBvZiBpdHMgZGlyZWN0aXZlLmAsIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBub2RlczogYXJndW1lbnQuc291cmNlQVNULFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGV4dGVuc2lvbnM6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaW5hY2Nlc3NpYmxlX2VsZW1lbnRzOiBbYXJndW1lbnQuY29vcmRpbmF0ZV0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGluYWNjZXNzaWJsZV9yZWZlcmVuY2VyczogW2FyZ3VtZW50LmNvb3JkaW5hdGVdLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH0pKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbiAgICBpZiAoZXJyb3JzLmxlbmd0aCA+IDApIHtcbiAgICAgICAgdGhyb3cgKDAsIGRlZmluaXRpb25zXzEuRXJyR3JhcGhRTEFQSVNjaGVtYVZhbGlkYXRpb25GYWlsZWQpKGVycm9ycyk7XG4gICAgfVxufVxuZnVuY3Rpb24gY29tcHV0ZURlZmF1bHRWYWx1ZVJlZmVyZW5jZXJzKHNjaGVtYSkge1xuICAgIGNvbnN0IHJlZmVyZW5jZ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vZlR5cGU7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IGl0ZW0gb2YgdmFsdWUpIHtcbiAgICAgICAgICAgICAgICBhZGRWYWx1ZVJlZmVyZW5jZXMoaXRlbSwgaXRlbVR5cGUsIHJlZmVyZW5jZXMpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICB9XG4gICAgICAgIHJldHVybjtcbiAgICB9XG4gICAgaWYgKCgwLCBkZWZpbml0aW9uc18xLmlzTGlzdFR5cGUpKHR5cGUpKSB7XG4gICAgICAgIHJldHVybiBhZGRWYWx1ZVJlZmVyZW5jZXModmFsdWUsIHR5cGUub2ZUeXBlLCByZWZlcmVuY2VzKTtcbiAgICB9XG4gICAgaWYgKHR5cGVvZiB2YWx1ZSA9PT0gJ29iamVjdCcpIHtcbiAgICAgICAgaWYgKCgwLCBkZWZpbml0aW9uc18xLmlzSW5wdXRPYmplY3RUeXBlKSh0eXBlKSkge1xuICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZCBvZiB0eXBlLmZpZWxkcygpKSB7XG4gICAgICAgICAgICAgICAgY29uc3QgZmllbGRWYWx1ZSA9IHZhbHVlW2ZpZWxkLm5hbWVdO1xuICAgICAgICAgICAgICAgIGlmIChmaWVsZFZhbHVlICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVmZXJlbmNlcy5wdXNoKGZpZWxkKTtcbiAgICAgICAgICAgICAgICAgICAgYWRkVmFsdWVSZWZlcmVuY2VzKGZpZWxkVmFsdWUsIGZpZWxkLnR5cGUsIHJlZmVyZW5jZXMpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSB7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuO1xuICAgIH1cbiAgICBpZiAodHlwZW9mIHZhbH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pKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBmaWVsZC5yZW1vdmUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGZvciAoY29uc3QgYXJndW1lbnQgb2YgZmllbGQuYXJndW1lbnRzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoaXNJbmFjY2Vzc2libGUoYXJndW1lbnQpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50LnJlbW92ZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKHR5cGUgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLklucHV0T2JqZWN0VHlwZSkge1xuICAgICAgICAgICAgICAgIGZvciAoY29uc3QgaW5wdXRGaWVsZCBvZiB0eXBlLmZpZWxkcygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChpc0luYWNjZXNzaWJsZShpbnB1dEZpZWxkKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgaW5wdXRGaWVsZC5yZW1vdmUoKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2UgaWYgKHR5cGUgaW5zdGFuY2VvZiBkZWZpbml0aW9uc18xLkVudW1UeXBlKSB7XG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBlbnVtVmFsdWUgb2YgdHlwZS52YWx1ZXMpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGlzSW5hY2Nlc3NpYmxlKGVudW1WYWx1ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVudW1WY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hbWUubGVuZ3RoID09PSAxKSB7XG4gICAgICAgICAgICAgICAgc3ViZ3JhcGhUb0VudW1OYW1lLnNldChzdWJncmFwaHNGb3JOYW1lWzBdLm5hbWUsIHNhbml0aXplZE5hbWUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBbaW5kZXgsIHN1YmdyYXBoXSBvZiBzdWJncmFwaHNGb3JOYW1lLmVudHJpZXMoKSkge1xuICAgICAgICAgICAgICAgICAgICBzdWJncmFwaFRvRW51bU5hbWUuc2V0KHN1YmdyYXBoLm5hbWUsIGAke3Nhbml0aXplZE5hbWV9XyR7aW5kZXggKyAxfWApO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBjb25zdCBncmFwaEVudW0gPSB0aGlzLmdyYXBoRW51bShzY2hlbWEpO1xuICAgICAgICBjb25zdCBncmFwaERpcmVjdGl2ZSA9IHRoaXMuZ3JhcGhEaXJlY3RpdmUoc2NoZW1hKTtcbiAgICAgICAgZm9yIChjb25zdCBzdWJncmFwaCBvZiBzdWJncmFwaHMpIHtcbiAgICAgICAgICAgIGNvbnN0IGVudW1WYWx1ZSA9IGdyYXBoRW51bS5hZGRWYWx1ZShzdWJncmFwaFRvRW51bU5hbWUuZ2V0KHN1YmdyYXBoLm5hbWUpKTtcbiAgICAgICAgICAgIGVudW1WYWx1ZS5hcHBseURpcmVjdGl2ZShncmFwaERpcmVjdGl2ZSwgeyBuYW1lOiBzdWJncmFwaC5uYW1lLCB1cmw6IHN1YmdyYXBoLnVybCB9KTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gc3ViZ3JhcGhUb0VudW1OYW1lO1xuICAgIH1cbiAgICBmaWVsZFNldFNjYWxhcihzY2hlbWEpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMudHlwZShzY2hlbWEsICdGaWVsZFNldCcpO1xuICAgIH1cbiAgICBncm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VsZWN0cyhkZWZpbml0aW9uKTtcbiAgICB9XG4gICAgc2VsZWN0cyhkZWZpbml0aW9uLCBhc3N1bWVWYWxpZCA9IGZhbHNlKSB7XG4gICAgICAgIGlmIChkZWZpbml0aW9uID09IHRoaXMuZGVmaW5pdGlvbikge1xuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMubmFtZSAhPT0gZGVmaW5pdGlvbi5uYW1lKSB7XG4gICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChjb25zdCBhcmdEZWYgb2YgZGVmaW5pdGlvbi5hcmd1bWVudHMoKSkge1xuICAgICAgICAgICAgY29uc3QgYXBwbGllZFZhbHVlID0gdGhpcy5hcmdzW2FyZ0RlZi5uYW1lXTtcbiAgICAgICAgICAgIGlmIChhcHBsaWVkVmFsdWUgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgIGlmIChhcmdEZWYuZGVmYXVsdFZhbHVlID09PSB1bmRlZmluZWQgJiYgISgwLCBkZWZpbml0aW9uc18xLmlzTnVsbGFibGVUeXBlKShhcmdEZWYudHlwZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIGlmICghYXNzdW1lVmFsaWQgJiYgISgwLCB2YWx1ZXNfMS5pc1ZhbGlkVmFsdWUpKGFwcGxpZWRWYWx1ZSwgYXJnRGVmLCB0aGlzLnZhcmlhYmxlRGVmaW5pdGlvbnMpKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCFhc3N1bWVWYWxpZCkge1xuICAgICAgICAgICAgZm9yIChjb25zdCBbbm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3MoKSB7XG4gICAgICAgIHJldHVybiB1bmRlZmluZWQ7XG4gICAgfVxuICAgIHdpdGhvdXREZWZlcigpIHtcbiAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgfVxuICAgIGVxdWFscyh0aGF0KSB7XG4gICAgICAgIGlmICh0aGlzID09PSB0aGF0KSB7XG4gICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhhdC5raW5kID09PSAnRmllbGQnXG4gICAgICAgICAgICAmJiB0aGlzLm5hbWUgPT09IHRoYXQubmFtZVxuICAgICAgICAgICAgJiYgdGhpcy5hbGlhcyA9PT0gdGhhdC5hbGlhc1xuICAgICAgICAgICAgJiYgKDAsIHZhbHVlc18xLmFyZ3VtZW50c0VxdWFscykodGhpcy5hcmdzLCB0aGF0LmFyZ3MpXG4gICAgICAgICAgICAmJiBoYXZlU2FtZURpcmVjdGl2ZXModGhpcywgdGhhdCk7XG4gICAgfVxuICAgIHRvU3RyaW5nKCkge1xuICAgICAgICBjb25zdCBhbGlhcyA9IHRoaXMuYWxpYXMgPyB0aGlzLmFsaWFzICsgJzogJyA6ICcnO1xuICAgICAgICBjb25zdCBlbnRyaWVzID0gT2JqZWN0LmVudHJpZXModGhpcy5hcmdzKTtcbiAgICAgICAgY29uc3QgYXJncyA9IGVudHJpZXMubGVuZ3RoID09IDBcbiAgICAgICAgICAgID8gJydcbiAgICAgICAgICAgIDogJygnICsgZW50cmllcy5tYXAoKFtuLCB2XSkgPT4geyB2YXIgX2E7IHJldHVybiBgJHtufTogJHsoMCwgdmFsdWVzXzEudmFsdWVUb1N0cmluZykodiwgKF9hID0gdGhpcy5kZWZpbml0aW9uLmFyZ3VtZW50KG4pKSA9PT0gbnVsbCB8fCBfYSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2EudHlwZSl9YDsgfSkuam9pbignLCAnKSArICcpJztcbiAgICAgICAgcmV0dXJuIGFsaWFzICsgdGhpcy5uYW1lICsg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50KHRoaXMuc291cmNlVHlwZSwgdGhpcy50eXBlQ29uZGl0aW9uKTtcbiAgICAgICAgdGhpcy5jb3B5QXR0YWNoZW1lbnRzVG8odXBkYXRlZCk7XG4gICAgICAgIHVwZGF0ZWREaXJlY3RpdmVzLmZvckVhY2goKGQpID0+IHVwZGF0ZWQuYXBwbHlEaXJlY3RpdmUoZC5kZWZpbml0aW9uLCBkLmFyZ3VtZW50cygpKSk7XG4gICAgICAgIHJldHVybiB1cGRhdGVkO1xuICAgIH1cbiAgICB3aXRoTm9ybWFsaXplZERlZmVyKG5vcm1hbGl6ZXIpIHtcbiAgICAgICAgY29uc3QgZGVmZXJBcmdzID0gdGhpcy5kZWZlckRpcmVjdGl2ZUFyZ3MoKTtcbiAgICAgICAgaWYgKCFkZWZlckFyZ3MpIHtcbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICB9XG4gICAgICAgIGxldCBuZXdEZWZlckFyZ3MgPSB1bmRlZmluZWQ7XG4gICAgICAgIGxldCBjb25kaXRpb25WYXJpYWJsZSA9IHVuZGVmaW5lZDtcbiAgICAgICAgaWYgKGRlZmVyQXJncy5pZiAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICBpZiAodHlwZW9mIGRlZmVyQXJncy5pZiA9PT0gJ2Jvb2xlYW4nKSB7XG4gICAgICAgICAgICAgICAgaWYgKGRlZmVyQXJncy5pZikge1xuICAgICAgICAgICAgICAgICAgICBuZXdEZWZlckFyZ3MgPSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAuLi5kZWZlckFyZ3MsXG4gICAgICAgICAgICAgICAgICAgICAgICBpZjogdW5kZWZpbmVkLFxuICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRoaXMud2l0aG91dERlZmVyKCk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgY29uZGl0aW9uVmFyaWFibGUgPSBkZWZlckFyZ3MuaWY7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgbGV0IGxhYmVsID0gZGVmZXJBcmdzLmxhYmVsO1xuICAgICAgICBpZiAoIWxhYmVsKSB7XG4gICAgICAgICAgICBsYWJlbCA9IG5vcm1hbGl6ZXIubmV3TGFiZWwoKTtcbiAgICAgICAgICAgIGlmIChuZXdEZWZlckFyZ3MpIHtcbiAgICAgICAgICAgICAgICBuZXdEZWZlckFyZ3MubGFiZWwgPSBsYWJlbDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIG5ld0RlZmVyQXJncyA9IHtcbiAgICAgICAgICAgICAgICAgICAgLi4uZGVmZXJBcmdzLFxuICAgICAgICAgICAgICAgICAgICBsYWJlbCxcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChjb25kaXRpb25WYXJpYWJsZSkge1xuICAgICAgICAgICAgbm9ybWFsaXplci5yZWdpc3RlckNvbmRpdGlvbihsYWJlbCwgY29uZGl0aW9uVmFyaWFibGUpO1xuICAgICAgICB9XG4gICAgICAgIGlmICghbmV3RGVmZXJBcmdzKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfVxuICAgICAgICBjb25zdCB1cGRhdGVkID0gbmV3IEZyYWdtZW50RWxlbWVudCh0aGlzLnNvdXJjZVR5cGUsIHRoaXMudHlwZUNvbmRpdGlvbik7XG4gICAgICAgIHRoaXMuY29weUF0dGFjaGVtZW50c1RvKHVwZGF0ZWQpO1xuICAgICAgICBjb25zdCBkZWZlckRpcmVjdGl2ZSA9IHRoaXMuc2NoZW1hKCkuZGVmZXJEaXJlY3RpdmUoKTtcbiAgICAgICAgdGhpcy5hcHBsaWVkRGlyZWN0aXZlcy5maW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ICAgICAgICAgICAgaGFzRGVmZXJzID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCFkZWZlckFyZ3MubGFiZWwgfHwgZGVmZXJBcmdzLmlmICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGhhc05vbkxhYmVsbGVkT3JDb25kaXRpb25hbERlZmVycyA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgaWYgKGRlZmVyQXJncy5sYWJlbCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy51c2VkTGFiZWxzLmFkZChkZWZlckFyZ3MubGFiZWwpO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKHNlbGVjdGlvbi5zZWxlY3Rpb25TZXQpIHtcbiAgICAgICAgICAgICAgICBzZWxlY3Rpb24uc2VsZWN0aW9uU2V0LnNlbGVjdGlvbnMoKS5mb3JFYWNoKChzKSA9PiBzdGFjay5wdXNoKHMpKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4geyBoYXNEZWZlcnMsIGhhc05vbkxhYmVsbGVkT3JDb25kaXRpb25hbERlZmVycyB9O1xuICAgIH1cbiAgICBuZXh0TGFiZWwoKSB7XG4gICAgICAgIHJldHVybiBgcXBfXyR7dGhpcy5pbmRleCsrfWA7XG4gICAgfVxuICAgIG5ld0xhYmVsKCkge1xuICAgICAgICBsZXQgY2FuZGlkYXRlID0gdGhpcy5uZXh0TGFiZWwoKTtcbiAgICAgICAgd2hpbGUgKHRoaXMudXNlZExhYmVscy5oYXMoY2FuZGlkYXRlKSkge1xuICAgICAgICAgICAgY2FuZGlkYXRlID0gdGhpcy5uZXh0TGFiZWwoKTtcbiAgICAgICAgfVxuICAgICAgICB0aGlzLmFzc2lnbmVkTGFiZWxzLmFkZChjYW5kaWRhdGUpO1x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mFtZSkge1xuICAgICAgICAgICAgICAgIHZhcmlhYmxlcyA9ICgwLCBkZWZpbml0aW9uc18xLm1lcmdlVmFyaWFibGVzKSh2YXJpYWJsZXMsIHNlbGVjdGlvbi51c2VkVmFyaWFibGVzKCkpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmICh0aGlzLmZyYWdtZW50cykge1xuICAgICAgICAgICAgdmFyaWFibGVzID0gKDAsIGRlZmluaXRpb25zXzEubWVyZ2VWYXJpYWJsZXMpKHZhcmlhYmxlcywgdGhpcy5mcmFnbWVudHMudmFyaWFibGVzKCkpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiB2YXJpYWJsZXM7XG4gICAgfVxuICAgIGNvbGxlY3RVc2VkRnJhZ21lbnROYW1lcyhjb2xsZWN0b3IpIHtcbiAgICAgICAgZm9yIChjb25zdCBieVJlc3BvbnNlTmFtZSBvZiB0aGlzLl9zZWxlY3Rpb25zLnZhbHVlcygpKSB7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IHNlbGVjdGlvbiBvZiBieVJlc3BvbnNlTmFtZSkge1xuICAgICAgICAgICAgICAgIHNlbGVjdGlvbi5jb2xsZWN0VXNlZEZyYWdtZW50TmFtZXMoY29sbGVjdG9yKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbiAgICBvcHRpbWl6ZShmcmFnbWVudHMpIHtcbiAgICAgICAgaWYgKCFmcmFnbWVudHMgfHwgZnJhZ21lbnRzLmlzRW1wdHkoKSkge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKHRoaXMuZnJhZ21lbnRzICYmIHRoaXMuZnJhZ21lbnRzLmRlZmluaXRpb25zKCkuc29tZShkZWYgPT4gZnJhZ21lbnRzLmdldChkZWYubmFtZSkpKSB7XG4gICAgICAgICAgICByZXR1cm4gdGhpcztcbiAgICAgICAgfVxuICAgICAgICBjb25zdCBvcHRpbWl6Z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mRlZCkpIHtcbiAgICAgICAgICAgICAgICB3aXRoRXhwYW5kZWQuYWRkQWxsKGV4cGFuZGVkKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHdpdGhFeHBhbmRlZC5hZGQoZXhwYW5kZWQpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHJldHVybiB3aXRoRXhwYW5kZWQ7XG4gICAgfVxuICAgIGxhenlNYXAobWFwcGVyKSB7XG4gICAgICAgIGxldCB1cGRhdGVkU2VsZWN0aW9ucyA9IHVuZGVmaW5lZDtcbiAgICAgICAgY29uc3Qgc2VsZWN0aW9ucyA9IHRoaXMuc2VsZWN0aW9ucygpO1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHNlbGVjdGlvbnMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICAgIGNvbnN0IHNlbGVjdGlvbiA9IHNlbGVjdGlvbnNbaV07XG4gICAgICAgICAgICBjb25zdCB1cGRhdGVkID0gbWFwcGVyKHNlbGVjdGlvbik7XG4gICAgICAgICAgICBpZiAodXBkYXRlZCAhPT0gc2VsZWN0aW9uICYmICF1cGRhdGVkU2VsZWN0aW9ucykge1xuICAgICAgICAgICAgICAgIHVwZGF0ZWRTZWxlY3Rpb25zID0gW107XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgaiA9IDA7IGogPCBpOyBqKyspIHtcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlZFNlbGVjdGlvbnMucHVzaChzZWxlY3Rpb25zW2pdKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAoISF1cGRhdGVkICYmIHVwZGF0ZWRTZWxlY3Rpb25zKSB7XG4gICAgICAgICAgICAgICAgaWYgKHVwZGF0ZWQgaW5zdGFuY2VvZiBTZWxlY3Rpb25TZXQpIHtcbiAgICAgICAgICAgICAgICAgICAgdXBkYXRlZC5zZWxlY3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RlRm9yQWRkaW5nVG8odGhpcyk7XG4gICAgICAgIGNvbnN0IGtleSA9IHRvQWRkLmtleSgpO1xuICAgICAgICBjb25zdCBleGlzdGluZyA9IHRoaXMuX3NlbGVjdGlvbnMuZ2V0KGtleSk7XG4gICAgICAgIGlmIChleGlzdGluZykge1xuICAgICAgICAgICAgZm9yIChjb25zdCBleGlzdGluZ1NlbGVjdGlvbiBvZiBleGlzdGluZykge1xuICAgICAgICAgICAgICAgIGlmIChleGlzdGluZ1NlbGVjdGlvbi5raW5kID09PSB0b0FkZC5raW5kICYmIGhhdmVTYW1lRGlyZWN0aXZlcyhleGlzdGluZ1NlbGVjdGlvbi5lbGVtZW50KCksIHRvQWRkLmVsZW1lbnQoKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKHRvQWRkLnNlbGVjdGlvblNldCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgZXhpc3RpbmdTZWxlY3Rpb24uc2VsZWN0aW9uU2V0Lm1lcmdlSW4odG9BZGQuc2VsZWN0aW9uU2V0KTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICByZXR1cm4gZXhpc3RpbmdTZWxlY3Rpb247XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIHRoaXMuX3NlbGVjdGlvbnMuYWRkKGtleSwgdG9BZGQpO1xuICAgICAgICArK3RoaXMuX3NlbGVjdGlvbkNvdW50O1xuICAgICAgICB0aGlzLl9jYWNoZWRTZWxlY3Rpb25zID0gdW5kZWZpbmVkO1xuICAgICAgICByZXR1cm4gdG9BZGQ7XG4gICAgfVxuICAgIGFkZFBhdGgocGF0aCwgb25QYXRoRW5kKSB7XG4gICAgICAgIGxldCBwcmV2aW91c1NlbGVjdGlvbnMgPSB0aGlzO1xuICAgICAgICBsZXQgY3VycmVudFNlbGVjdGlvbnMgPSB0aGlzO1xuICAgICAgICBmb3IgKGNvbnN0IGVsZW1lbnQgb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lY3Rpb25zLmxlbmd0aFxuICAgICAgICAgICAgICAgICAgICB8fCAhdGhhdFNlbGVjdGlvbnMuZXZlcnkodGhhdFNlbGVjdGlvbiA9PiB0aGlzU2VsZWN0aW9ucy5zb21lKHRoaXNTZWxlY3Rpb24gPT4gdGhpc1NlbGVjdGlvbi5jb250YWlucyh0aGF0U2VsZWN0aW9uKSkpKSkge1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICB9XG4gICAgdmFsaWRhdGUoKSB7XG4gICAgICAgIHZhbGlkYXRlKCF0aGlzLmlzRW1wdHkoKSwgKCkgPT4gYEludmFsaWQgZW1wdHkgc2VsZWN0aW9uIHNldGApO1xuICAgICAgICBmb3IgKGNvbnN0IHNlbGVjdGlvbiBvZiB0aGlzLnNlbGVjdGlvbnMoKSkge1xuICAgICAgICAgICAgc2VsZWN0aW9uLnZhbGlkYXRlKCk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgaXNFbXB0eSgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NlbGVjdGlvbnMuc2l6ZSA9PT0gMDtcbiAgICB9XG4gICAgdG9TZWxlY3Rpb25TZXROb2RlKCkge1xuICAgICAgICBpZiAodGhpcy5pc0VtcHR5KCkpIHtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAga2luZDogZ3JhcGhxbF8xLktpbmQuU0VMRUNUSU9OX1NFVCxcbiAgICAgICAgICAgICAgICBzZWxlY3Rpb25zOiBbe1xuICAgICAgICAgICAgICAgICAgICAgICAga2luZDogZ3JhcGhxbF8xLktpbmQuRklFTEQsXG4gICAgICAgICAgICAgICAgICAgICAgICBuYW1lOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAga2luZDogZ3JhcGhxbF8xLktpbmQuTkFNRSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogJy4uLicsXG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB9XVxuICAgICAgICAgICAgfTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAga2luZDogZ3JhcGhxbF8xLktpbmQuU0VMRUNUSU9OX1NFVCxcbiAgICAgICAgICAgIHNlbGVjdGlvbnM6IEFycmF5LmZyb20odGhpcy5zZWxlY3Rpb25zSW5QcmludE9yZGVyKCksIHMgPT4gcy50b1NlbGVjdGlvbk5vZGUoKSlcbiAgICAgICAgfTtcbiAgICB9XG4gICAgc2VsZWN0aW9uc0luUHJpbnRPcmRlcigpIHtcbiAgICAgICAgY29uc3QgdHlwZW5hbWVTZWxlY3Rpb24gPSB0aGlzLl9zZWxlY3Rpb25zLmdldChkZWZpbml0aW9uc18xLnR5cGVuYW1lRmllbGROYW1lKTtcbiAgICAgICAgY29uc3QgaXNOb25BbGlhc2VkVHlwZW5hbWVTZWxlY3Rpb24gPSAocykgPT4gcy5raW5kID09PSAnRmllbGRTZWxlY3Rpb24nICYmICFzLmZpZWxkLmFsaWFzICYmIHMuZmllbGQubmFtZSA9PT0gZGVmaW5pdGlvbnNfMS50eXBlbmFtZUZpZWxkTmFtZTtcbiAgICAgICAgaWYgKHR5cGVuYW1lU2VsZWN0aW9uKSB7XG4gICAgICAgICAgICByZXR1cm4gdHlwZW5hbWVTZWxlY3Rpb24uY29uY2F0KHRoaXMuc2VsZWN0aW9ucygpLmZpbHRlcihzID0+ICFpc05vbkFsaWFzZWRUeXBlbmFtZVNlbGVjdGlvbihzKSkpO1xuICAgICAgICB9XG4gICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRoaXMuc2VsZWN0aW9ucygpO1xuICAgICAgICB9XG4gICAgfVxuICAgIHRvT3BlcmF0aW9uUGF0aHMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnRvT3BlcmF0aW9uUGF0aHNJbnRlcm5hbChbXSk7XG4gICAgfVxuICAgIHRvT3BlcmF0aW9uUGF0aHNJbnRlcm5hbChwYXJlbnRQYXRocykge1xuICAgICAgICByZXR1cm4gdGhpcy5zZWxlY3Rpb25zKCkuZmxhdE1hcCgoc2VsZWN0aW9uKSA9PiB7XG4gICAgICAgICAgICBjb25zdCB1cGRhdGVkUGF0aHMgPSBwYXJlbnRQYXRocy5tYXAocGF0aCA9PiBwYXRoLmNvbmNhdChzZWxlY3Rpb24uZWxlbWVudCgpKSk7XG4gICAgICAgICAgICByZXR1cm4gc2VsZWN0aW9uLnNlbGVjdGlvblNldFxuICAgICAgICAgICAgICAgID8gc2VsZWN0aW9uLnNlbGVjdGlvblNldC50b09wZXJhdGlvblBhdGhzSW50ZXJuYWwodXBkYXRlZFBhdGhzKVxuICAgICAgICAgICAgICAgIDogdXBkYXRlZFBhdGhzO1xuICAgICAgICB9KTtcbiAgICB9XG4gICAgZm9yRWFjaEVsZW1lbnQoY2FsbGJhY2spIHtcbiAgICAgICAgdmFyIF9hO1xuICAgICAgICBjb25zdCBzdGFjayA9IHRoaXMuc2VsZWN0aW9ucygpLmNvbmNhdCgpO1xuICAgICAgICB3aGlsZSAoc3RhY2subGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgY29uc3Qgc2VsZWN0aW9uID0gc3RhY2sucG9wKCk7XG4gICAgICAgICAgICBjYWxsYmFjayhzZWxlY3Rpb24uZWxlbWVudCgpKTtcbiAgICAgICAgICAgIChfYSA9IHNlbGVjdGlvbi5zZWxlY3Rpb25TZXQpID09PSBudWxsIHx8IF9hID09PSB2b2lkIDAgPyB2b2lkIDAgOiBfYS5zZWxlY3Rpb25zKHRydWUpLmZvckVhY2goKHMpID0+IHN0YWNrLnB1c2gocykpO1xuICAgICAgICB9XG4gICAgfVxuICAgIGNsb25lKCkge1xuICAgICAgICBjb25zdCBjbG9uZWQgPSBuZXcgU2VsZWN0aW9uU2V0KHRoaXMucGFyZW50VHlwZSk7XG4gICAgICAgIGZvciAoY29uc3Qg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ID09PSBleHBhbmRlZFNlbGVjdGlvblxuICAgICAgICAgICAgPyB0aGlzXG4gICAgICAgICAgICA6IG5ldyBGaWVsZFNlbGVjdGlvbih0aGlzLmZpZWxkLCBleHBhbmRlZFNlbGVjdGlvbik7XG4gICAgfVxuICAgIGZpZWxkQXJndW1lbnRzVG9BU1QoKSB7XG4gICAgICAgIGNvbnN0IGVudHJpZXMgPSBPYmplY3QuZW50cmllcyh0aGlzLmZpZWxkLmFyZ3MpO1xuICAgICAgICBpZiAoZW50cmllcy5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgIHJldHVybiB1bmRlZmluZWQ7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIGVudHJpZXMubWFwKChbbiwgdl0pID0+IHtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAga2luZDogZ3JhcGhxbF8xLktpbmQuQVJHVU1FTlQsXG4gICAgICAgICAgICAgICAgbmFtZTogeyBraW5kOiBncmFwaHFsXzEuS2luZC5OQU1FLCB2YWx1ZTogbiB9LFxuICAgICAgICAgICAgICAgIHZhbHVlOiAoMCwgdmFsdWVzXzEudmFsdWVUb0FTVCkodiwgdGhpcy5maWVsZC5kZWZpbml0aW9uLmFyZ3VtZW50KG4pLnR5cGUpLFxuICAgICAgICAgICAgfTtcbiAgICAgICAgfSk7XG4gICAgfVxuICAgIHZhbGlkYXRlKCkge1xuICAgICAgICB2YXIgX2E7XG4gICAgICAgIHRoaXMuZmllbGQudmFsaWRhdGUoKTtcbiAgICAgICAgdmFsaWRhdGUoISh0aGlzLnNlbGVjdGlvblNldCAmJiB0aGlzLnNlbGVjdGlvblNldC5pc0VtcHR5KCkpLCAoKSA9PiBgSW52YWxpZCBlbXB0eSBzZWxlY3Rpb24gc2V0IGZvciBmaWVsZCBcIiR7dGhpcy5maWVsZC5kZWZpbml0aW9uLmNvb3JkaW5hdGV9XCIgb2Ygbm9uLWxlYWYgdHlwZSAke3RoaXMuZmllbGQuZGVmaW5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9IChfYSA9IHRoaXMuc2VsZWN0aW9uU2V0KSA9PT0gbnVsbCB8fCBfYSA9PT0gdm9pZCAwID8gdm9pZCAwIDogX2EuY2xvbmVJZkZyb3plbigpO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBuZXcgSW5saW5lRnJhZ21lbnRTZWxlY3Rpb24odXBkYXRlZEZyYWdtZW50LCB1cGRhdGVkU2VsZWN0aW9uU2V0KTtcbiAgICB9XG4gICAgZ2V0IHNlbGVjdGlvblNldCgpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuX3NlbGVjdGlvblNldDtcbiAgICB9XG4gICAgbmFtZWRGcmFnbWVudHMoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLnNlbGVjdGlvblNldC5mcmFnbWVudHM7XG4gICAgfVxuICAgIGVsZW1lbnQoKSB7XG4gICAgICAgIHJldHVybiB0aGlzLmZyYWdtZW50RWxlbWVudDtcbiAgICB9XG4gICAgdG9TZWxlY3Rpb25Ob2RlKCkge1xuICAgICAgICBjb25zdCB0eXBlQ29uZGl0aW9uID0gdGhpcy5lbGVtZW50KCkudHlwZUNvbmRpdGlvbjtcbiAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgIGtpbmQ6IGdyYXBocWxfMS5LaW5kLklOTElORV9GUkFHTUVOVCxcbiAgICAgICAgICAgIHR5cGVDb25kaXRpb246IHR5cGVDb25kaXRpb25cbiAgICAgICAgICAgICAgICA/IHtcbiAgICAgICAgICAgICAgICAgICAga2luZDogZ3JhcGhxbF8xLktpbmQuTkFNRURfVFlQRSxcbiAgICAgICAgICAgICAgICAgICAgbmFtZToge1xuICAgICAgICAgICAgICAgICAgICAgICAga2luZDogZ3JhcGhxbF8xLktpbmQuTkFNRSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiB0eXBlQ29uZGl0aW9uLm5hbWUsXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIDogdW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uICAgIH1cbiAgICBuYW1lZEZyYWdtZW50cygpIHtcbiAgICAgICAgcmV0dXJuIHRoaXMuZnJhZ21lbnRzO1xuICAgIH1cbiAgICBnZXQgc2VsZWN0aW9uU2V0KCkge1xuICAgICAgICByZXR1cm4gdGhpcy5uYW1lZEZyYWdtZW50LnNlbGVjdGlvblNldDtcbiAgICB9XG4gICAgdmFsaWRhdGUoKSB7XG4gICAgICAgIHRoaXMudmFsaWRhdGVEZWZlckFuZFN0cmVhbSgpO1xuICAgIH1cbiAgICB0b1NlbGVjdGlvbk5vZGUoKSB7XG4gICAgICAgIGNvbnN0IHNwcmVhZERpcmVjdGl2ZXMgPSB0aGlzLnNwcmVhZERpcmVjdGl2ZXMoKTtcbiAgICAgICAgY29uc3QgZGlyZWN0aXZlTm9kZXMgPSBzcHJlYWREaXJlY3RpdmVzLmxlbmd0aCA9PT0gMFxuICAgICAgICAgICAgPyB1bmRlZmluZWRcbiAgICAgICAgICAgIDogc3ByZWFkRGlyZWN0aXZlcy5tYXAoZGlyZWN0aXZlID0+IHtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICBraW5kOiBncmFwaHFsXzEuS2luZC5ESVJFQ1RJVkUsXG4gICAgICAgICAgICAgICAgICAgIG5hbWU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGtpbmQ6IGdyYXBocWxfMS5LaW5kLk5BTUUsXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZGlyZWN0aXZlLm5hbWUsXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50czogZGlyZWN0aXZlLmFyZ3VtZW50c1RvQVNUKClcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICBraW5kOiBncmFwaHFsXzEuS2luZC5GUkFHTUVOVF9TUFJFQUQsXG4gICAgICAgICAgICBuYW1lOi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zZSBncmFwaHFsXzEuS2luZC5PUEVSQVRJT05fREVGSU5JVElPTjpcbiAgICAgICAgICAgICAgICB2YWxpZGF0ZSghb3BlcmF0aW9uIHx8IG9wZXJhdGlvbk5hbWUsICgpID0+ICdNdXN0IHByb3ZpZGUgb3BlcmF0aW9uIG5hbWUgaWYgcXVlcnkgY29udGFpbnMgbXVsdGlwbGUgb3BlcmF0aW9ucy4nKTtcbiAgICAgICAgICAgICAgICBpZiAoIW9wZXJhdGlvbk5hbWUgfHwgKGRlZmluaXRpb24ubmFtZSAmJiBkZWZpbml0aW9uLm5hbWUudmFsdWUgPT09IG9wZXJhdGlvbk5hbWUpKSB7XG4gICAgICAgICAgICAgICAgICAgIG9wZXJhdGlvbiA9IGRlZmluaXRpb247XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgY2FzZSBncmFwaHFsXzEuS2luZC5GUkFHTUVOVF9ERUZJTklUSU9OOlxuICAgICAgICAgICAgICAgIGNvbnN0IG5hbWUgPSBkZWZpbml0aW9uLm5hbWUudmFsdWU7XG4gICAgICAgICAgICAgICAgY29uc3QgdHlwZU5hbWUgPSBkZWZpbml0aW9uLnR5cGVDb25kaXRpb24ubmFtZS52YWx1ZTtcbiAgICAgICAgICAgICAgICBjb25zdCB0eXBlQ29uZGl0aW9uID0gc2NoZW1hLnR5cGUodHlwZU5hbWUpO1xuICAgICAgICAgICAgICAgIGlmICghdHlwZUNvbmRpdGlvbikge1xuICAgICAgICAgICAgICAgICAgICB0aHJvdyBlcnJvcl8xLkVSUk9SUy5JTlZBTElEX0dSQVBIUUwuZXJyKGBVbmtub3duIHR5cGUgXCIke3R5cGVOYW1lfVwiIGZvciBmcmFnbWVudCBcIiR7bmFtZX1cImAsIHsgbm9kZXM6IGRlZmluaXRpb24gfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICghKDAsIGRlZmluaXRpb25zXzEuaXNDb21wb3Npd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IGZpZWxkLm9mRXh0ZW5zaW9uKCkgPT09IGQub2ZFeHRlbnNpb24oKSkpO1xuICAgICAgICAgICAgaWYgKGZpZWxkSXNTaGFyZWFibGUpIHtcbiAgICAgICAgICAgICAgICBzaGFyZWFibGVGaWVsZHMuYWRkKGZpZWxkLmNvb3JkaW5hdGUpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZm9yIChjb25zdCBwcm92aWRlcyBvZiBmaWVsZC5hcHBsaWVkRGlyZWN0aXZlc09mKHByb3ZpZGVzRGlyZWN0aXZlKSkge1xuICAgICAgICAgICAgICAgICgwLCBfMS5jb2xsZWN0VGFyZ2V0RmllbGRzKSh7XG4gICAgICAgICAgICAgICAgICAgIHBhcmVudFR5cGU6ICgwLCBfMS5iYXNlVHlwZSkoZmllbGQudHlwZSksXG4gICAgICAgICAgICAgICAgICAgIGRpcmVjdGl2ZTogcHJvdmlkZXMsXG4gICAgICAgICAgICAgICAgICAgIGluY2x1ZGVJbnRlcmZhY2VGaWVsZHNJbXBsZW1lbnRhdGlvbnM6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHZhbGlkYXRlOiBmYWxzZSxcbiAgICAgICAgICAgICAgICB9KS5mb3JFYWNoKChmKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgIGlmIChtZXRhZGF0YS5pc0ZpZWxkRXh0ZXJuYWwoZikpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNoYXJlYWJsZUZpZWxkcy5hZGQoZi5jb29yZGluYXRlKTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIGZvciAoY29uc3QgdHlwZSBvZiBzY2hlbWEuaW50ZXJmYWNlVHlwZXMoKSkge1xuICAgICAgICBhZGRLZXlGaWVsZHModHlwZSk7XG4gICAgfVxuICAgIHJldHVybiAoZmllbGQpID0+IHNoYXJlYWJsZUZpZWxkcy5oYXMoZmll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Ob2RlIG9mIChfYSA9IG5vZGVzLmFyZ3VtZW50cykgIT09IG51bGwgJiYgX2EgIT09IHZvaWQgMCA/IF9hIDogW10pIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChhcmdOb2RlLm5hbWUudmFsdWUgPT09ICdmaWVsZHMnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGFyZ05vZGUudmFsdWUua2luZCA9PT0gZ3JhcGhxbF8xLktpbmQuRU5VTSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnJlcGxhY2VGZWRlcmF0aW9uRGlyZWN0aXZlQXBwbGljYXRpb24oYXBwbGljYXRpb24sICgwLCBncmFwaHFsXzEucHJpbnQpKG5vZGVzKSwgZmllbGRzLCB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAuLi5ub2RlcyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGFyZ3VtZW50czogW3tcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLi4uYXJnTm9kZSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFsdWU6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGtpbmQ6IGdyYXBocWxfMS5LaW5kLlNUUklORyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhbHVlOiBmaWVsZHNcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1dXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmVtb3ZlRXh0ZXJuYWxPbkludGVyZmFjZSgpIHtcbiAgICAgICAgZm9yIChjb25zdCBpdGYgb2YgdGhpcy5zY2hlbWEuaW50ZXJmYWNlVHlwZXMoKSkge1xuICAgICAgICAgICAgZm9yIChjb25zdCBmaWVsZCBvZiBpdGYuZmllbGRzKCkpIHtcbiAgICAgICAgICAgICAgICBjb25zdCBleHRlcm5hbCA9IHRoaXMuZXh0ZXJuYWwoZmllbGQpO1xuICAgICAgICAgICAgICAgIGlmIChleHRlcm5hbCkge1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENoYW5nZShuZXcgRXh0ZXJuYWxPbkludGVyZmFjZVJlbW92YWwoZmllbGQuY29vcmRpbmF0ZSkpO1xuICAgICAgICAgICAgICAgICAgICBleHRlcm5hbC5yZW1vdmUoKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmVwbGFjZUZlZGVyYXRpb25EaXJlY3RpdmVBcHBsaWNhdGlvbihhcHBsaWNhdGlvbiwgYmVmb3JlLCBmaWVsZHMsIHVwZGF0ZWRTb3VyY2VBU1QpIHtcbiAgICAgICAgY29uc3QgZGlyZWN0aXZlID0gYXBwbGljYXRpb24uZGVmaW5pdGlvbjtcbiAgICAgICAgY29uc3QgcGFyZW50ID0gYXBwbGljYXRpb24ucGFyZW50O1xuICAgICAgICBhcHBsaWNhdGlvbi5yZW1vdmUoKTtcbiAgICAgICAgY29uc3QgbmV3RGlyZWN0aXZlID0gcGFyZW50LmFwcGx5RGlyZWN0aXZlKGRpcmVjdGl2ZSwgeyBmaWVsZHMgfSk7XG4gICAgICAgIG5ld0RpcmVjdGl2ZS5zb3VyY2VBU1QgPSB1cGRhdGVkU291cmNlQVNUO1xuICAgICAgICB0aGlzLmFkZEN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aW9uVHlwZUV4dGVuc2lvbih0eXBlKSAmJiAhaXNSb290VHlwZUV4dGVuc2lvbih0eXBlKSkge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgY29uc3Qga2V5QXBwbGljYXRpb25zID0gdHlwZS5hcHBsaWVkRGlyZWN0aXZlc09mKHRoaXMubWV0YWRhdGEua2V5RGlyZWN0aXZlKCkpO1xuICAgICAgICAgICAgaWYgKGtleUFwcGxpY2F0aW9ucy5sZW5ndGggPiAwKSB7XG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBrZXlBcHBsaWNhdGlvbiBvZiB0eXBlLmFwcGxpZWREaXJlY3RpdmVzT2YodGhpcy5tZXRhZGF0YS5rZXlEaXJlY3RpdmUoKSkpIHtcbiAgICAgICAgICAgICAgICAgICAgKDAsIGZlZGVyYXRpb25fMS5jb2xsZWN0VGFyZ2V0RmllbGRzKSh7XG4gICAgICAgICAgICAgICAgICAgICAgICBwYXJlbnRUeXBlOiB0eXBlLFxuICAgICAgICAgICAgICAgICAgICAgICAgZGlyZWN0aXZlOiBrZXlBcHBsaWNhdGlvbixcbiAgICAgICAgICAgICAgICAgICAgICAgIGluY2x1ZGVJbnRlcmZhY2VGaWVsZHNJbXBsZW1lbnRhdGlvbnM6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICAgICAgdmFsaWRhdGU6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICB9KS5mb3JFYWNoKChmaWVsZCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGZpZWxkLnBhcmVudCAhPT0gdHlwZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IGV4dGVybmFsID0gdGhpcy5leHRlcm5hbChmaWVsZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZXh0ZXJuYWwpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENoYW5nZShuZXcgRXh0ZXJuYWxPblR5cGVFeHRlbnNpb25SZW1vdmFsKGZpZWxkLmNvb3JkaW5hdGUpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBleHRlcm5hbC5yZW1vdmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgZm9yIChjb25zdCBvdGhlciBvZiB0aGlzLm90aGVyU3ViZ3JhcGhzKSB7XG4gICAgICAgICAgICAgICAgICAgIGNvbnN0IHR5cGVJbk90aGVyID0gb3RoZXIuc2NoZW1hLnR5cGUodHlwZS5uYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKCF0eXBlSW5PdGhlcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgKDAsIHV0aWxzXzEuYXNzZXJ0KSgoMCwgZGVmaW5pdGlvbnNfMS5pc0NvbXBvc2l0ZVR5cGUpKHR5cGVJbk90aGVyKSwgKCkgPT4gYFR5cGUgJHt0eXBlfSBpcyBvZiBraW5kICR7dHlwZS5raW5kfSBpbiAke3RoaXMuc3ViZ3JhcGgubmFtZX0gYnV0ICR7dHlwZUluT3RoZXIua2luZH0gaW4gJHtvdGhlci5uYW1lfWApO1xuICAgICAgICAgICAgICAgICAgICBjb25zdCBrZXlzSW5PdGhlciA9IHR5cGVJbk90aGVyLmFwcGxpZWREaXJlY3RpdmVzT2Yob3RoZXIubWV0YWRhdGEoKS5rZXlEaXJlY3RpdmUoKSk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChrZXlzSW5PdGhlci5sZW5ndGggPT09IDApIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICgwLCBmZWRlcmF0aW9uXzEuY29sbGVjdFRhcmdldEZpZWxkcykoe1xuICAgICAgICAgICAgICAgICAgICAgICAgcGFyZW50VHlwZTogdHlwZUluT3RoZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICBkaXJlY3RpdmU6IGtleXNJbk90aGVyWzBdLFxuICAgICAgICAgICAgICAgICAgICAgICAgaW5jbHVkZUludGVyZmFjZUZpZWxkc0ltcGxlbWVudGF0aW9uczogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgICAgICB2YWxpZGF0ZTogZmFsc2UsXG4gICAgICAgICAgICAgICAgICAgIH0pLmZvckVhY2goKGZpZWxkKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZmllbGQucGFyZW50ICE9PSB0eXBlSW5PdGhlcikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybjtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIGNvbnN0IG93bkZpZWxkID0gdHlwZS5maWVsZChmaWVsZC5uYW1lKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICghb3duRmllbGQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm47XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICBjb25zdCBleHRlcm5hbCA9IHRoaXMuZXh0ZXJuYWwob3duRmllbGQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGV4dGVybmFsKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRDaGFuZ2UobmV3IEV4dGVybmFsT25UeXBlRXh0ZW5zaW9uUmVtb3ZhbChvd25GaWVsZC5jb29yZGluYXRlKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXh0ZXJuYWwucmVtb3ZlKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cbiAgICByZW1vdmVUeXBlRXh0ZW5zaW9ucygpIHtcbiAgICAgICAgZm9yIChjb25zdCB0eXBlIG9mIHRoaXMuc2NoZW1hLnR5cGVzKCkpIHtcbiAgICAgICAgICAgIGlmICghaXNGZWRlcmF0aW9uVHlwZUV4dGVuc2lvbih0eXBlKSAmJiAhaXNSb290VHlwZUV4dGVuc2lvbih0eXBlKSkge1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgdGhpcy5hZGRDaGFuZ2UobmV3IFR5cGVFeHRlbnNpb25SZW1vdmFsKHR5cGUuY29vcmRpbmF0ZSkpO1xuICAgICAgICAgICAgdHlwZS5yZW1vdmVFeHRlbnNpb25zKCk7XG4gICAgICAgIH1cbiAgICB9XG4gICAgcmVtb3ZlVW51c2VkRXh0ZXJuYWxzKCkge1xuICAgICAgICBmb3IgKGNvbnN0IHR5cGUgb2YgdGhpcy5zY2hlbWEudHlwZXMoKSkge1xuICAgICAgICAgICAgaWYgKCEoMCwgZGVmaW5pdGlvbnNfMS5pc09iamVjdFR5cGUpKHR5cGUpICYmICEoMCwgZGVmaW5pdGlvbnNfMS5pc0ludGVyZmFjZVR5cGUpKHR5cGUpKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkIG9mIHR5cGUuZmllbGRzKCkpIHtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5tZXRhZGF0YS5pc0ZpZWxkRXh0ZXJuYWwoZmllbGQpICYmICF0aGlzLm1ldGFkYXRhLmlzRmllbGRVc2VkKGZpZWxkKSkge1xuICAgICAgICAgICAgICAgICAg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ZSkpIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZS5hcHBseURpcmVjdGl2ZShzaGFyZWFibGVEaXJlY3RpdmUpO1xuICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZENoYW5nZShuZXcgU2hhcmVhYmxlVHlwZUFkZGl0aW9uKHR5cGUuY29vcmRpbmF0ZSwgb3RoZXJEZWNsYXJpbmdTdWJncmFwaHMubWFwKChzKSA9PiBzLm5hbWUpKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgfVxuICAgIHJlbW92ZVRhZ09uRXh0ZXJuYWwoKSB7XG4gICAgICAgIGNvbnN0IHRhZ0RpcmVjdGl2ZSA9IHRoaXMuc2NoZW1hLmRpcmVjdGl2ZSgndGFnJyk7XG4gICAgICAgIGlmICghdGFnRGlyZWN0aXZlKSB7XG4gICAgICAgICAgICByZXR1cm47XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChjb25zdCBhcHBsaWNhdGlvbiBvZiBBcnJheS5mcm9tKHRhZ0RpcmVjdGl2ZS5hcHBsaWNhdGlvbnMoKSkpIHtcbiAgICAgICAgICAgIGNvbnN0IGVsZW1lbnQgPSBhcHBsaWNhdGlvbi5wYXJlbnQ7XG4gICAgICAgICAgICBpZiAoIShlbGVtZW50IGluc3RhbmNlb2YgZGVmaW5pdGlvbnNfMS5GaWVsZERlZmluaXRpb24pKSB7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAodGhpcy5leHRlcm5hbChlbGVtZW50KSkge1xuICAgICAgICAgICAgICAgIGNvbnN0IHRhZ0lzVXNlZEluT3RoZXJEZWZpbml0aW9uID0gdGhpcy5vdGhlclN1YmdyYXBoc1xuICAgICAgICAgICAgICAgICAgICAubWFwKChzKSA9PiBnZXRGaWVsZChzLnNjaGVtYSwgZWxlbWVudC5wYXJlbnQubmFtZSwgZWxlbWVudC5uYW1lKSlcbiAgICAg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5wdXNoKHZhbHVlKTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgIHRoaXMuc2V0KGtleSwgW3ZhbHVlXSk7XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgfVxuICAgIGFkZEFsbChvdGhlck1hcCkge1xuICAgICAgICBmb3IgKGNvbnN0IFtrLCB2c10gb2Ygb3RoZXJNYXAuZW50cmllcygpKSB7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IHYgb2YgdnMpIHtcbiAgICAgICAgICAgICAgICB0aGlzLmFkZChrLCB2KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcztcbiAgICB9XG59XG5leHBvcnRzLk11bHRpTWFwID0gTXVsdGlNYXA7XG5jbGFzcyBTZXRNdWx0aU1hcCBleHRlbmRzIE1hcCB7XG4gICAgYWRkKGtleSwgdmFsdWUpIHtcbiAgICAgICAgbGV0IHZhbHVlcyA9IHRoaXMuZ2V0KGtleSk7XG4gICAgICAgIGlmICghdmFsdWVzKSB7XG4gICAgICAgICAgICB2YWx1ZXMgPSBuZXcgU2V0KCk7XG4gICAgICAgICAgICB0aGlzLnNldChrZXksIHZhbHVlcyk7XG4gICAgICAgIH1cbiAgICAgICAgdmFsdWVzLmFkZCh2YWx1ZSk7XG4gICAgICAgIHJldHVybiB0aGlzO1xuICAgIH1cbiAgICBhZGRBbGwob3RoZXJNYXApIHtcbiAgICAgICAgZm9yIChjb25zdCBbaywgdnNdIG9mIG90aGVyTWFwLmVudHJpZXMoKSkge1xuICAgICAgICAgICAgZm9yIChjb25zdCB2IG9mIHZzKSB7XG4gICAgICAgICAgICAgICAgdGhpcy5hZGQoaywgdik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHRoaXM7XG4gICAgfVxufVxuZXhwb3J0cy5TZXRNdWx0aU1hcCA9IFNldE11bHRpTWFwO1xuY2xhc3MgT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5nZXQoa2V5KTtcbiAgICAgICAgICAgIGFzc2VydCh2LCAndmFsdWUgZm9yIGtub3duIGtleSBub3QgZm91bmQgaW4gT3JkZXJlZE1hcCcpO1xuICAgICAgICAgICAgcmV0dXJuIHY7XG4gICAgICAgIH0pO1xuICAgIH1cbiAgICBpbnNlcnRLZXlJbk9yZGVyKGtleSkge1xuICAgICAgICBsZXQgbG93ZXIgPSAwO1xuICAgICAgICBsZXQgdXBwZXIgPSB0aGlzLl9rZXlzLmxlbmd0aCAtIDE7XG4gICAgICAgIHdoaWxlIChsb3dlciA8PSB1cHBlcikge1xuICAgICAgICAgICAgY29uc3QgbWlkZGxlID0gTWF0aC5mbG9vcigodXBwZXIgKyBsb3dlcikgLyAyKTtcbiAgICAgICAgICAgIGlmICh0aGlzLl9jb21wYXJlRm4odGhpcy5fa2V5c1ttaWRkbGVdLCBrZXkpIDwgMCkge1xuICAgICAgICAgICAgICAgIGxvd2VyID0gbWlkZGxlICsgMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIHVwcGVyID0gbWlkZGxlIC0gMTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICB0aGlzLl9rZXlzID0gdGhpcy5fa2V5cy5zbGljZSgwLCBsb3dlcikuY29uY2F0KGtleSkuY29uY2F0KHRoaXMuX2tleXMuc2xpY2UobG93ZXIpKTtcbiAgICB9XG4gICAgKltTeW1ib2wuaXRlcmF0b3JdKCkge1xuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHRoaXMuX2tleXMubGVuZ3RoOyBpICs9IDEpIHtcbiAgICAgICAgICAgIGNvbnN0IHYgPSB0aGlzLl92YWx1ZXMuZ2V0KHRoaXMuX2tleXNbaV0pO1xuICAgICAgICAgICAgYXNzZXJ0KHYsICd2YWx1ZSBmb3Iga25vd24ga2V5IG5vdCBmb3VuZCBpbiBPcmRlcmVkTWFwJyk7XG4gICAgICAgICAgICB5aWVs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AgICAgICAgICAgICAgdGhpcy5maWVsZFBhdGgucG9wKCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgdGhpcy5maWVsZFBhdGhJbmRleEJ5VHlwZU5hbWUuZGVsZXRlKHR5cGUubmFtZSk7XG4gICAgfVxufVxuY2xhc3MgVmFsaWRhdG9yIHtcbiAgICBjb25zdHJ1Y3RvcihzY2hlbWEpIHtcbiAgICAgICAgdGhpcy5zY2hlbWEgPSBzY2hlbWE7XG4gICAgICAgIHRoaXMuZW1wdHlWYXJpYWJsZXMgPSBuZXcgZGVmaW5pdGlvbnNfMS5WYXJpYWJsZURlZmluaXRpb25zKCk7XG4gICAgICAgIHRoaXMuaGFzTWlzc2luZ1R5cGVzID0gZmFsc2U7XG4gICAgICAgIHRoaXMuZXJyb3JzID0gW107XG4gICAgfVxuICAgIHZhbGlkYXRlKCkge1xuICAgICAgICBmb3IgKGNvbnN0IHR5cGUgb2YgdGhpcy5zY2hlbWEudHlwZXMoKSkge1xuICAgICAgICAgICAgdGhpcy52YWxpZGF0ZU5hbWUodHlwZSk7XG4gICAgICAgICAgICBzd2l0Y2ggKHR5cGUua2luZCkge1xuICAgICAgICAgICAgICAgIGNhc2UgJ09iamVjdFR5cGUnOlxuICAgICAgICAgICAgICAgIGNhc2UgJ0ludGVyZmFjZVR5cGUnOlxuICAgICAgICAgICAgICAgICAgICB0aGlzLnZhbGlkYXRlT2JqZWN0T3JJbnRlcmZhY2VUeXBlKHR5cGUpO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICdJbnB1dE9iamVjdFR5cGUnOlxuICAgICAgICAgICAgICAgICAgICB0aGlzLnZhbGlkYXRlSW5wdXRPYmplY3RUeXBlKHR5cGUpO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICdVbmlvblR5cGUnOlxuICAgICAgICAgICAgICAgICAgICB0aGlzLnZhbGlkYXRlVW5pb25UeXBlKHR5cGUpO1xuICAgICAgICAgICAgICAgICAgICBicmVhaztcbiAgICAgICAgICAgICAgICBjYXNlICdFbnVtVHlwZSc6XG4gICAgICAgICAgICAgICAgICAgIHRoaXMudmFsaWRhdGVFbnVtVHlwZSh0eXBlKTtcbiAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgZm9yIChjb25zdCBkaXJlY3RpdmUgb2YgdGhpcy5zY2hlbWEuYWxsRGlyZWN0aXZlcygpKSB7XG4gICAgICAgICAgICB0aGlzLnZhbGlkYXRlTmFtZShkaXJlY3RpdmUpO1xuICAgICAgICAgICAgZm9yIChjb25zdCBhcmcgb2YgZGlyZWN0aXZlLmFyZ3VtZW50cygpKSB7XG4gICAgICAgICAgICAgICAgdGhpcy52YWxpZGF0ZUFyZyhhcmcpO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZm9yIChjb25zdCBhcHBsaWNhdGlvbiBvZiBkaXJlY3RpdmUuYXBwbGljYXRpb25zKCkpIHtcbiAgICAgICAgICAgICAgICB0aGlzLnZhbGlkYXRlRGlyZWN0aXZlQXBwbGljYXRpb24oZGlyZWN0aXZlLCBhcHBsaWNhdGlvbik7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCF0aGlzLmhhc01pc3NpbmdUeXBlcykge1xuICAgICAgICAgICAgY29uc3QgcmVmc1ZhbGlkYXRvciA9IG5ldyBJbnB1dE9iamVjdENpcmN1bGFyUmVmc1ZhbGlkYXRvcigobXNnLCBvcHRzKSA9PiB0aGlzLmFkZEVycm9yKG1zZywgb3B0cykpO1xuICAgICAgICAgICAgZm9yIChjb25zdCB0eXBlIG9mIHRoaXMuc2NoZW1hLnR5cGVzKCkpIHtcbiAgICAgICAgICAgICAgICBzd2l0Y2ggKHR5cGUua2luZCkge1xuICAgICAgICAgICAgICAgICAgICBjYXNlICdPYmplY3RUeXBlJzpcbiAgICAgICAgICAgICAgICAgICAgY2FzZSAnSW50ZXJmYWNlVHlwZSc6XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZhbGlkYXRlSW1wbGVtZW50ZWRJbnRlcmZhY2VzKHR5cGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICAgICAgICAgIGNhc2UgJ0lucHV0T2JqZWN0VHlwZSc6XG4gICAgICAgICAgICAgICAgICAgICAgICByZWZzVmFsaWRhdG9yLmRldGVjdEN5Y2xlcyh0eXBlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGJyZWFrO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5lcnJvcnM7XG4gICAgfVxuICAgIGFkZEVycm9yKG1lc3NhZ2UsIG9wdGlvbnMpIHtcbiAgICAgICAgdGhpcy5lcnJvcnMucHVzaChlcnJvcl8xLkVSUk9SUy5JTlZBTElEX0dSQVBIUUwuZXJyKG1lc3NhZ2UsIG9wdGlvbnMpKTtcbiAgICB9XG4gICAgdmFsaWRhdGVIYXNUeXBlKGVsdCkge1xuICAgICAgICBpZiAoIWVsdC50eXBlKSB7XG4gICAgICAgICAgICB0aGlzLmFkZEVycm9yKGBFbGVtZW50ICR7ZWx0LmNvb3JkaW5hdGV9IGRvZXMgbm90IGhhdmUgYSB0eXBlIHNldGAsIHsgbm9kZXM6IGVsdC5zb3VyY2VBU1QgfSk7XG4gICAgICAgICAgICB0aGlzLmhhc01pc3NpbmdUeXBlcyA9IGZhbHNlO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiAhIWVsdC50eXBlO1xuICAgIH1cbiAgICB2YWxpZGF0ZU5hbWUoZWx0KSB7XG4gICAgICAgIGlmICgoMCwgaW50cm9zcGVjdGlvbl8xLmlzSW50cm9zcGVjdGlvbk5hbWUpKGVsdC5uYW1lKSkge1xuICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgIC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ICAgIH1cbiAgICAgICAgICAgICAgICBmb3IgKGNvbnN0IGFyZyBvZiBmaWVsZC5hcmd1bWVudHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBpZiAoaXRmRmllbGQuYXJndW1lbnQoYXJnLm5hbWUpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICBpZiAoYXJnLmlzUmVxdWlyZWQoKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5hZGRFcnJvcihgRmllbGQgJHtmaWVsZC5jb29yZGluYXRlfSBpbmNsdWRlcyByZXF1aXJlZCBhcmd1bWVudCAke2FyZy5uYW1lfSB0aGF0IGlzIG1pc3NpbmcgZnJvbSB0aGUgSW50ZXJmYWNlIGZpZWxkICR7aXRmRmllbGQuY29vcmRpbmF0ZX0uYCwgeyBub2RlczogKDAsIGRlZmluaXRpb25zXzEuc291cmNlQVNUcykoYXJnLCBpdGZGaWVsZCkgfSk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBmb3IgKGNvbnN0IGl0Zk9mSXRmIG9mIGl0Zi5pbnRlcmZhY2VzKCkpIHtcbiAgICAgICAgICAgICAgICBpZiAoIXR5cGUuaW1wbGVtZW50c0ludGVyZmFjZShpdGZPZkl0ZikpIHtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGl0Zk9mSXRmID09PSB0eXBlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmFkZEVycm9yKGBUeXBlICR7dHlwZX0gY2Fubm90IGltcGxlbWVudCAke2l0Zn0gYmVjYXVzZSBpdCB3b3VsZCBjcmVhdGUgYSBjaXJjdWxhciByZWZlcmVuY2UuYCwgeyBub2RlczogKDAsIGRlZmluaXRpb25zXzEuc291cmNlQVNUcykodHlwZSwgaXRmKSB9KTtcbiAgICAgICAgICAgIC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WxfMS5LaW5kLk5BTUUsIHZhbHVlOiB2YWx1ZS5uYW1lIH0gfTtcbiAgICB9XG4gICAgaWYgKEFycmF5LmlzQXJyYXkodmFsdWUpKSB7XG4gICAgICAgIGNvbnN0IHZhbHVlc05vZGVzID0gW107XG4gICAgICAgIGZvciAoY29uc3QgaXRlbSBvZiB2YWx1ZSkge1xuICAgICAgICAgICAgY29uc3QgaXRlbU5vZGUgPSB2YWx1ZVRvQVNUVW50eXBlZChpdGVtKTtcbiAgICAgICAgICAgIGlmIChpdGVtTm9kZSAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgICAgdmFsdWVzTm9kZXMucHVzaChpdGVtTm9kZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgICAgcmV0dXJuIHsga2luZDogZ3JhcGhxbF8xLktpbmQuTElTVCwgdmFsdWVzOiB2YWx1ZXNOb2RlcyB9O1xuICAgIH1cbiAgICBpZiAodHlwZW9mIHZhbHVlID09PSAnb2JqZWN0Jykge1xuICAgICAgICBjb25zdCBmaWVsZE5vZGVzID0gW107XG4gICAgICAgIGZvciAoY29uc3Qga2V5IG9mIE9iamVjdC5rZXlzKHZhbHVlKSkge1xuICAgICAgICAgICAgY29uc3QgZmllbGRWYWx1ZSA9IHZhbHVlVG9BU1RVbnR5cGVkKHZhbHVlW2tleV0pO1xuICAgICAgICAgICAgaWYgKGZpZWxkVmFsdWUpIHtcbiAgICAgICAgICAgICAgICBmaWVsZE5vZGVzLnB1c2goe1xuICAgICAgICAgICAgICAgICAgICBraW5kOiBncmFwaHFsXzEuS2luZC5PQkpFQ1RfRklFTEQsXG4gICAgICAgICAgICAgICAgICAgIG5hbWU6IHsga2luZDogZ3JhcGhxbF8xLktpbmQuTkFNRSwgdmFsdWU6IGtleSB9LFxuICAgICAgICAgICAgICAgICAgICB2YWx1ZTogZmllbGRWYWx1ZSxcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfV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AgfVxuICAgICAgICBpZiAoIWlzRmluaXRlKHBhcnNlZCkpIHtcbiAgICAgICAgICAgIHRocm93IGVycm9yXzEuRVJST1JTLklOVkFMSURfR1JBUEhRTC5lcnIoYEZsb2F0IGNhbm5vdCByZXByZXNlbnQgbm9uIG51bWVyaWMgdmFsdWUgJHtwYXJzZWR9LmApO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBwYXJzZWQ7XG4gICAgfVxuICAgIGlmICgoMCwgZGVmaW5pdGlvbnNfMS5pc0Jvb2xlYW5UeXBlKShleHBlY3RlZFR5cGUpKSB7XG4gICAgICAgIGlmIChub2RlLmtpbmQgIT09IGdyYXBocWxfMS5LaW5kLkJPT0xFQU4pIHtcbiAgICAgICAgICAgIHRocm93IGVycm9yXzEuRVJST1JTLklOVkFMSURfR1JBUEhRTC5lcnIoYEJvb2xlYW4gY2Fubm90IHJlcHJlc2VudCBhIG5vbiBib29sZWFuIHZhbHVlICR7KDAsIGdyYXBocWxfMS5wcmludCkobm9kZSl9LmApO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBub2RlLnZhbHVlO1xuICAgIH1cbiAgICBpZiAoKDAsIGRlZmluaXRpb25zXzEuaXNTdHJpbmdUeXBlKShleHBlY3RlZFR5cGUpKSB7XG4gICAgICAgIGlmIChub2RlLmtpbmQgIT09IGdyYXBocWxfMS5LaW5kLlNUUklORykge1xuICAgICAgICAgICAgdGhyb3cgZXJyb3JfMS5FUlJPUlMuSU5WQUxJRF9HUkFQSFFMLmVycihgU3RyaW5nIGNhbm5vdCByZXByZXNlbnQgbm9uIHN0cmluZyB2YWx1ZSAkeygwLCBncmFwaHFsXzEucHJpbnQpKG5vZGUpfS5gKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gbm9kZS52YWx1ZTtcbiAgICB9XG4gICAgaWYgKCgwLCBkZWZpbml0aW9uc18xLmlzSURUeXBlKShleHBlY3RlZFR5cGUpKSB7XG4gICAgICAgIGlmIChub2RlLmtpbmQgIT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TmFtZSwgZmllbGRDb25maWdzXSBvZiBPYmplY3QuZW50cmllcyhyZXNvbHZlcnMpKSB7XG4gICAgICAgIGNvbnN0IHR5cGUgPSBzY2hlbWEuZ2V0VHlwZSh0eXBlTmFtZSk7XG4gICAgICAgIGlmICgoMCwgZ3JhcGhxbF8xLmlzQWJzdHJhY3RUeXBlKSh0eXBlKSkge1xuICAgICAgICAgICAgY29uc3QgZXhpc3RpbmdFeHRlbnNpb25zID0gdHlwZS5leHRlbnNpb25zO1xuICAgICAgICAgICAgZm9yIChjb25zdCBbZmllbGROYW1lLCBmaWVsZENvbmZpZ10gb2YgT2JqZWN0LmVudHJpZXMoZmllbGRDb25maWdzKSkge1xuICAgICAgICAgICAgICAgIGlmIChmaWVsZE5hbWUgPT09ICdfX3Jlc29sdmVSZWZlcmVuY2UnKSB7XG4gICAgICAgICAgICAgICAgICAgIHR5cGUuZXh0ZW5zaW9ucyA9IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIC4uLmV4aXN0aW5nRXh0ZW5zaW9ucyxcbiAgICAgICAgICAgICAgICAgICAgICAgIGFwb2xsbzoge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC4uLmV4aXN0aW5nRXh0ZW5zaW9ucy5hcG9sbG8sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc3ViZ3JhcGg6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgLi4uKF9hID0gZXhpc3RpbmdFeHRlbnNpb25zLmFwb2xsbykgPT09IG51bGwgfHwgX2EgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9hLnN1YmdyYXBoLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvbHZlUmVmZXJlbmNlOiBmaWVsZENvbmZpZyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgZWxzZSBpZiAoZmllbGROYW1lID09PSAnX19yZXNvbHZlVHlwZScpIHtcbiAgICAgICAgICAgICAgICAgICAgdHlwZS5yZXNvbHZlVHlwZSA9IGZpZWxkQ29uZmlnO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoKDAsIGdyYXBocWxfMS5pc1NjYWxhclR5cGUpKHR5cGUpKSB7XG4gICAgICAgICAgICBmb3IgKGNvbnN0IGZuIGluIGZpZWxkQ29uZmlncykge1xuICAgICAgICAgICAgICAgIHR5cGVbZm5dID0gZmllbGRDb25maWdzW2ZuXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBpZiAoKDAsIGdyYXBocWxfMS5pc0VudW1UeXBlKSh0eXBlKSkge1xuICAgICAgICAgICAgY29uc3QgdmFsdWVzID0gdHlwZS5nZXRWYWx1ZXMoKTtcbiAgICAgICAgICAgIGNvbnN0IG5ld1ZhbHVlcyA9IHt9O1xuICAgICAgICAgICAgdmFsdWVzLmZvckVhY2godmFsdWUgPT4ge1xuICAgICAgICAgICAgICAgIGxldCBuZXdWYWx1ZSA9IGZpZWxkQ29uZmlnc1t2YWx1ZS5uYW1lXTtcbiAgICAgICAgICAgICAgICBpZiAobmV3VmFsdWUgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICAgICAgICBuZXdWYWx1ZSA9IHZhbHVlLm5hbWU7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIG5ld1ZhbHVlc1t2YWx1ZS5uYW1lXSA9IHtcbiAgICAgICAgICAgICAgICAgICAgdmFsdWU6IG5ld1ZhbHVlLFxuICAgICAgICAgICAgICAgICAgICBkZXByZWNhdGlvblJlYXNvbjogdmFsdWUuZGVwcmVjYXRpb25SZWFzb24sXG4gICAgICAgICAgICAgICAgICAgIGRlc2NyaXB0aW9uOiB2YWx1ZS5kZXNjcmlwdGlvbixcbiAgICAgICAgICAgICAgICAgICAgYXN0Tm9kZTogdmFsdWUuYXN0Tm9kZSxcbiAgICAgICAgICAgICAgICAgICAgZXh0ZW5zaW9uczogdW5kZWZpbmVkXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgT2JqZWN0LmFzc2lnbih0eXBlLCBuZXcgZ3JhcGhxbF8xLkdyYXBoUUxFbnVtVHlwZSh7XG4gICAgICAgICAgICAgICAgLi4udHlwZS50b0NvbmZpZygpLFxuICAgICAgICAgICAgICAgIHZhbHVlczogbmV3VmFsdWVzXG4gICAgICAgICAgICB9KSk7XG4gICAgICAgIH1cbiAgICAgICAgaWYgKCEoMCwgZ3JhcGhxbF8xLmlzT2JqZWN0VHlwZSkodHlwZSkpXG4gICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgY29uc3QgZmllbGRNYXAgPSB0eXBlLmdldEZpZWxkcygpO1xuICAgICAgICBjb25zdCBleGlzdGluZ0V4dGVuc2lvbnMgPSB0eXBlLmV4dGVuc2lvbnM7XG4gICAgICAgIGZvciAoY29uc3QgW2ZpZWxkTmFtZSwgZmllbGRDb25maWddIG9mIE9iamVjdC5lbnRyaWVzKGZpZWxkQ29uZmlncykpIHtcbiAgICAgICAgICAgIGlmIChmaWVsZE5hbWUgPT09ICdfX3Jlc29sdmVSZWZlcmVuY2UnKSB7XG4gICAgICAgICAgICAgICAgdHlwZS5leHRlbnNpb25zID0ge1xuICAgICAgICAgICAgICAgICAgICAuLi5leGlzdGluZ0V4dGVuc2lvbnMsXG4gICAgICAgICAgICAgICAgICAgIGFwb2xsbzoge1xuICAgICAgICAgICAgICAgICAgICAgICAgLi4uZXhpc3RpbmdFeHRlbnNpb25zLmFwb2xsbyxcbiAgICAgICAgICAgICAgICAgICAgICAgIHN1YmdyYXBoOiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLi4uKF9iID0gZXhpc3RpbmdFeHRlbnNpb25zLmFwb2xsbykgPT09IG51bGwgfHwgX2IgPT09IHZvaWQgMCA/IHZvaWQgMCA6IF9iLnN1YmdyYXBoLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc29sdmVSZWZlcmVuY2U6IGZpZWxkQ29uZmlnLFxuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSBpZiAoZmllbGROYW1lID09PSAnX19pc1R5cGVPZicpIHtcbiAgICAgICAgICAgICAgICB0eXBlLmlzVHlwZU9mID0gZmllbGRDb25maWc7XG4gICAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBjb25zdCBmaWVsZCA9IGZpZWxkTWFwW2ZpZWxkTmFtZV07XG4gICAgICAgICAgICBpZiAoIWZpZWxkKVxuICAgICAgICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICAgICAgaWYgKHR5cGVvZiBmaWVsZENvbmZpZyA9PT0gXCJmdW5jdGlvblwiKSB7XG4gICAgICAgICAgICAgICAgZmllbGQucmVzb2x2ZSA9IGZpZWxkQ29uZmlnO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgZWxzZSB7XG4gICAgICAgICAgICAgICAgZmllbGQucmVzb2x2ZSA9IGZpZWxkQ29uZmlnLnJlc29sdmU7XG4gICAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICB9XG59XG5leHBvcnRzLmFkZFJlc29sdmVyc1RvU2NoZW1hID0gYWRkUmVzb2x2ZXJzVG9TY2hlbWE7XG5mdW5jdGlvbiBidWlsZFNjaGVtYUZyb21TREwobW9kdWxlc09yU0RMLCBzY2hlbWFUb0V4dGVuZCkge1xuICAgIGNvbnN0IG1vZHVsZXMgPSBtb2R1bGVzRnJvbVNETChtb2R1bGVzT3JTREwpO1xuICAgIGNvbnN0IGRvY3VtZW50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AgICAgIGVsc2Uge1xuICAgICAgICAgICAgICAgIGRlZmluaXRpb25zTWFwW3R5cGVOYW1lXSA9IFtkZWZpbml0aW9uXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmICgoMCwgZ3JhcGhxbF8xLmlzVHlwZUV4dGVuc2lvbk5vZGUpKGRlZmluaXRpb24pKSB7XG4gICAgICAgICAgICBjb25zdCB0eXBlTmFtZSA9IGRlZmluaXRpb24ubmFtZS52YWx1ZTtcbiAgICAgICAgICAgIGlmIChleHRlbnNpb25zTWFwW3R5cGVOYW1lXSkge1xuICAgICAgICAgICAgICAgIGV4dGVuc2lvbnNNYXBbdHlwZU5hbWVdLnB1c2goZGVmaW5pdGlvbik7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBlbHNlIHtcbiAgICAgICAgICAgICAgICBleHRlbnNpb25zTWFwW3R5cGVOYW1lXSA9IFtkZWZpbml0aW9uXTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmIChkZWZpbml0aW9uLmtpbmQgPT09IGdyYXBocWxfMS5LaW5kLkRJUkVDVElWRV9ERUZJTklUSU9OKSB7XG4gICAgICAgICAgICBkaXJlY3RpdmVEZWZpbml0aW9ucy5wdXNoKGRlZmluaXRpb24pO1xuICAgICAgICB9XG4gICAgICAgIGVsc2UgaWYgKGRlZmluaXRpb24ua2luZCA9PT0gZ3JhcGhxbF8xLktpbmQuU0NIRU1BX0RFRklOSVRJT04pIHtcbiAgICAgICAgICAgIHNjaGVtYURlZmluaXRpb25zLnB1c2goZGVmaW5pdGlvbik7XG4gICAgICAgICAgICBzY2hlbWFEaXJlY3RpdmVzLnB1c2goLi4uKGRlZmluaXRpb24uZGlyZWN0aXZlcyA/IGRlZmluaXRpb24uZGlyZWN0aXZlcyA6IFtdKSk7XG4gICAgICAgICAgICBkZXNjcmlwdGlvbiA9IGRlZmluaXRpb24uZGVzY3JpcHRpb247XG4gICAgICAg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wZS50b0NvbmZpZygpO1xuICAgICAgICAgICAgcmV0dXJuIG5ldyBncmFwaHFsXzEuR3JhcGhRTE9iamVjdFR5cGUoe1xuICAgICAgICAgICAgICAgIC4uLmNvbmZpZyxcbiAgICAgICAgICAgICAgICBpbnRlcmZhY2VzOiAoKSA9PiBjb25maWcuaW50ZXJmYWNlcy5tYXAocmVwbGFjZU5hbWVkVHlwZSksXG4gICAgICAgICAgICAgICAgZmllbGRzOiAoKSA9PiByZXBsYWNlRmllbGRzKGNvbmZpZy5maWVsZHMpXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuICAgICAgICBlbHNlIGlmICgoMCwgZ3JhcGhxbF8xLmlzSW50ZXJmYWNlVHlwZSkodHlwZSkpIHtcbiAgICAgICAgICAgIGNvbnN0IGNvbmZpZyA9IHR5cGUudG9Db25maWcoKTtcbiAgICAgICAgICAgIHJldHVybiBuZXcgZ3JhcGhxbF8xLkdyYXBoUUxJbnRlcmZhY2VUeXBlKHtcbiAgICAgICAgICAgICAgICAuLi5jb25maWcsXG4gICAgICAgICAgICAgICAgaW50ZXJmYWNlczogKCkgPT4gY29uZmlnLmludGVyZmFjZXMubWFwKHJlcGxhY2VOYW1lZFR5cGUpLFxuICAgICAgICAgICAgICAgIGZpZWxkczogKCkgPT4gcmVwbGFjZUZpZWxkcyhjb25maWcuZmllbGRzKVxuICAgICAgICAgICAgfSk7XG4gICAgICAgIH1cbiAgICAgICAgZWxzZSBpZiAoKDAsIGdyYXBocWxfMS5pc1VuaW9uVHlwZSkodHlwZSkpIHtcbiAgICAgICAgICAgIGNvbnN0IGNvbmZpZyA9IHR5cGUudG9Db25maWcoKTtcbiAgICAgICAgICAgIHJldHVybiBuZXcgZ3JhcGhxbF8xLkdyYXBoUUxVbmlvblR5cGUoe1xuICAgICAgICAgICAgICAgIC4uLmNvbmZpZyxcbiAgICAgICAgICAgICAgICB0eXBlczogKCkgPT4gY29uZmlnLnR5cGVzLm1hcChyZXBsYWNlTmFtZWRUe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vZHVsZS5leHBvcnRzID0gZnVuY3Rpb24gYmluZCh0aGF0KSB7XG4gICAgdmFyIHRhcmdldCA9IHRoaXM7XG4gICAgaWYgKHR5cGVvZiB0YXJnZXQgIT09ICdmdW5jdGlvbicgfHwgdG9TdHIuY2FsbCh0YXJnZXQpICE9PSBmdW5jVHlwZSkge1xuICAgICAgICB0aHJvdyBuZXcgVHlwZUVycm9yKEVSUk9SX01FU1NBR0UgKyB0YXJnZXQpO1xuICAgIH1cbiAgICB2YXIgYXJncyA9IHNsaWNlLmNhbGwoYXJndW1lbnRzLCAxKTtcblxuICAgIHZhciBib3VuZDtcbiAgICB2YXIgYmluZGVyID0gZnVuY3Rpb24gKCkge1xuICAgICAgICBpZiAodGhpcyBpbnN0YW5jZW9mIGJvdW5kKSB7XG4gICAgICAgICAgICB2YXIgcmVzdWx0ID0gdGFyZ2V0LmFwcGx5KFxuICAgICAgICAgICAgICAgIHRoaXMsXG4gICAgICAgICAgICAgICAgYXJncy5jb25jYXQoc2xpY2UuY2FsbChhcmd1bWVudHMpKVxuICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIGlmIChPYmplY3QocmVzdWx0KSA9PT0gcmVzdWx0KSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHJldHVybiB0aGlzO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgcmV0dXJuIHRhcmdldC5hcHBseShcbiAgICAgICAgICAgICAgICB0aGF0LFxuICAgICAgICAgICAgICAgIGFyZ3MuY29uY2F0KHNsaWNlLmNhbGwoYXJndW1lbnRzKSlcbiAgICAgICAgICAgICk7XG4gICAgICAgIH1cbiAgICB9O1xuXG4gICAgdmFyIGJvdW5kTGVuZ3RoID0gTWF0aC5tYXgoMCwgdGFyZ2V0Lmxlbmd0aCAtIGFyZ3MubGVuZ3RoKTtcbiAgICB2YXIgYm91bmRBcmdzID0gW107XG4gICAgZm9yICh2YXI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GVzKSB7XG4gICAgICBmb3IgKGNvbnN0IG5vZGUgb2YgdGhpcy5ub2Rlcykge1xuICAgICAgICBpZiAobm9kZS5sb2MpIHtcbiAgICAgICAgICBvdXRwdXQgKz0gJ1xcblxcbicgKyAoMCwgX3ByaW50TG9jYXRpb24ucHJpbnRMb2NhdGlvbikobm9kZS5sb2MpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfSBlbHNlIGlmICh0aGlzLnNvdXJjZSAmJiB0aGlzLmxvY2F0aW9ucykge1xuICAgICAgZm9yIChjb25zdCBsb2NhdGlvbiBvZiB0aGlzLmxvY2F0aW9ucykge1xuICAgICAgICBvdXRwdXQgKz1cbiAgICAgICAgICAnXFxuXFxuJyArXG4gICAgICAgICAgKDAsIF9wcmludExvY2F0aW9uLnByaW50U291cmNlTG9jYXRpb24pKHRoaXMuc291cmNlLCBsb2NhdGlvbik7XG4gICAgICB9XG4gICAgfVxuXG4gICAgcmV0dXJuIG91dHB1dDtcbiAgfVxuXG4gIHRvSlNPTigpIHtcbiAgICBjb25zdCBmb3JtYXR0ZWRFcnJvciA9IHtcbiAgICAgIG1lc3NhZ2U6IHRoaXMubWVzc2FnZSxcbiAgICB9O1xuXG4gICAgaWYgKHRoaXMubG9jYXRpb25zICE9IG51bGwpIHtcbiAgICAgIGZvcm1hdHRlZEVycm9yLmxvY2F0aW9ucyA9IHRoaXMubG9jYXRpb25zO1xuICAgIH1cblxuICAgIGlmICh0aGlzLnBhdGggIT0gbnVsbCkge1xuICAgICAgZm9ybWF0dGVkRXJyb3IucGF0aCA9IHRoaXMucGF0aDtcbiAgICB9XG5cbiAgICBpZiAodGhpcy5leHRlbnNpb25zICE9IG51bGwgJiYgT2JqZWN0LmtleXModGhpcy5leHRlbnNpb25zKS5sZW5ndGggPiAwKSB7XG4gICAgICBmb3JtYXR0ZWRFcnJvci5leHRlbnNpb25zID0gdGhpcy5leHRlbnNpb25zO1xuICAgIH1cblxuICAgIHJldHVybiBmb3JtYXR0ZWRFc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lbHNlIHtcbiAgICAgICAgICBmaWVsZHMuc2V0KG5hbWUsIFtzZWxlY3Rpb25dKTtcbiAgICAgICAgfVxuXG4gICAgICAgIGJyZWFrO1xuICAgICAgfVxuXG4gICAgICBjYXNlIF9raW5kcy5LaW5kLklOTElORV9GUkFHTUVOVDoge1xuICAgICAgICBpZiAoXG4gICAgICAgICAgIXNob3VsZEluY2x1ZGVOb2RlKHZhcmlhYmxlVmFsdWVzLCBzZWxlY3Rpb24pIHx8XG4gICAgICAgICAgIWRvZXNGcmFnbWVudENvbmRpdGlvbk1hdGNoKHNjaGVtYSwgc2VsZWN0aW9uLCBydW50aW1lVHlwZSlcbiAgICAgICAgKSB7XG4gICAgICAgICAgY29udGludWU7XG4gICAgICAgIH1cblxuICAgICAgICBjb2xsZWN0RmllbGRzSW1wbChcbiAgICAgICAgICBzY2hlbWEsXG4gICAgICAgICAgZnJhZ21lbnRzLFxuICAgICAgICAgIHZhcmlhYmxlVmFsdWVzLFxuICAgICAgICAgIHJ1bnRpbWVUeXBlLFxuICAgICAgICAgIHNlbGVjdGlvbi5zZWxlY3Rpb25TZXQsXG4gICAgICAgICAgZmllbGRzLFxuICAgICAgICAgIHZpc2l0ZWRGcmFnbWVudE5hbWVzLFxuICAgICAgICApO1xuICAgICAgICBicmVhaztcbiAgICAgIH1cblxuICAgICAgY2FzZSBfa2luZHMuS2luZC5GUkFHTUVOVF9TUFJFQUQ6IHtcbiAgICAgICAgY29uc3QgZnJhZ05hbWUgPSBzZWxlY3Rpb24ubmFtZS52YWx1ZTtcblxuICAgICAgICBpZiAoXG4gICAgICAgICAgdmlzaXRlZEZyYWdtZW50TmFtZXMuaGFzKGZyYWdOYW1lKSB8fFxuICAgICAgICAgICFzaG91bGRJbmNsdWRlTm9kZSh2YXJpYWJsZVZhbHVlcywgc2VsZWN0aW9uKVxuICAgICAgICApIHtcbiAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgfVxuXG4gICAgICAgIHZpc2l0ZWRGcmFnbW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XJlY3RpdmVzLCAnICcpXSwgJyAnKSxcbiAgfSxcbiAgT2JqZWN0VHlwZUV4dGVuc2lvbjoge1xuICAgIGxlYXZlOiAoeyBuYW1lLCBpbnRlcmZhY2VzLCBkaXJlY3RpdmVzLCBmaWVsZHMgfSkgPT5cbiAgICAgIGpvaW4oXG4gICAgICAgIFtcbiAgICAgICAgICAnZXh0ZW5kIHR5cGUnLFxuICAgICAgICAgIG5hbWUsXG4gICAgICAgICAgd3JhcCgnaW1wbGVtZW50cyAnLCBqb2luKGludGVyZmFjZXMsICcgJiAnKSksXG4gICAgICAgICAgam9pbihkaXJlY3RpdmVzLCAnICcpLFxuICAgICAgICAgIGJsb2NrKGZpZWxkcyksXG4gICAgICAgIF0sXG4gICAgICAgICcgJyxcbiAgICAgICksXG4gIH0sXG4gIEludGVyZmFjZVR5cGVFeHRlbnNpb246IHtcbiAgICBsZWF2ZTogKHsgbmFtZSwgaW50ZXJmYWNlcywgZGlyZWN0aXZlcywgZmllbGRzIH0pID0+XG4gICAgICBqb2luKFxuICAgICAgICBbXG4gICAgICAgICAgJ2V4dGVuZCBpbnRlcmZhY2UnLFxuICAgICAgICAgIG5hbWUsXG4gICAgICAgICAgd3JhcCgnaW1wbGVtZW50cyAnLCBqb2luKGludGVyZmFjZXMsICcgJiAnKSksXG4gICAgICAgICAgam9pbihkaXJlY3RpdmVzLCAnICcpLFxuICAgICAgICAgIGJsb2NrKGZpZWxkcyksXG4gICAgICAgIF0sXG4gICAgICAgICcgJyxcbiAgICAgICksXG4gIH0sXG4gIFVuaW9uVHlwZUV4dGVuc2lvbjoge1xuICAgIGxlYXZlOiAoeyBuYW1lLCBkaXJlY3RpdmVzLCB0eXBlcyB9KSA9PlxuICAgICAgam9pbihcbiAgICAgICAgW1xuICAgICAgICAgICdleHRlbmQgdW5pb24nLFxuICAgICAgICAgIG5hbWUsXG4gICAgICAgICAgam9pbihkaXJlY3RpdmVzLCAnICcpLFxuICAgICAgICAgIHdyYXAoJz0gJywgam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5cbiAgICAgICAgICAgIGlmIChlZGl0VmFsdWUgPT09IG51bGwpIHtcbiAgICAgICAgICAgICAgbm9kZS5zcGxpY2UoYXJyYXlLZXksIDEpO1xuICAgICAgICAgICAgICBlZGl0T2Zmc2V0Kys7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICBub2RlW2FycmF5S2V5XSA9IGVkaXRWYWx1ZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgbm9kZSA9IE9iamVjdC5kZWZpbmVQcm9wZXJ0aWVzKFxuICAgICAgICAgICAge30sXG4gICAgICAgICAgICBPYmplY3QuZ2V0T3duUHJvcGVydHlEZXNjcmlwdG9ycyhub2RlKSxcbiAgICAgICAgICApO1xuXG4gICAgICAgICAgZm9yIChjb25zdCBbZWRpdEtleSwgZWRpdFZhbHVlXSBvZiBlZGl0cykge1xuICAgICAgICAgICAgbm9kZVtlZGl0S2V5XSA9IGVkaXRWYWx1ZTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgaW5kZXggPSBzdGFjay5pbmRleDtcbiAgICAgIGtleXMgPSBzdGFjay5rZXlzO1xuICAgICAgZWRpdHMgPSBzdGFjay5lZGl0cztcbiAgICAgIGluQXJyYXkgPSBzdGFjay5pbkFycmF5O1xuICAgICAgc3RhY2sgPSBzdGFjay5wcmV2O1xuICAgIH0gZWxzZSBpZiAocGFyZW50KSB7XG4gICAgICBrZXkgPSBpbkFycmF5ID8gaW5kZXggOiBrZXlzW2luZGV4XTtcbiAgICAgIG5vZGUgPSBwYXJlbnRba2V5XTtcblxuICAgICAgaWYgKG5vZGUgPT09IG51bGwgfHwgbm9kZSA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAgIGNvbnRpbnVlO1xuICAgICAgfVxuXG4gICAgICBwYXRoLnB1c2goa2V5KTtcbiAgICB9XG5cbiAgICBsZXQgcmVzdWx0O1xuXG4g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ztcbiAgICAgIH1cblxuICAgICAgaWYgKHJlc3VsdCA9PT0gZmFsc2UpIHtcbiAgICAgICAgaWYgKCFpc0xlYXZpbmcpIHtcbiAgICAgICAgICBwYXRoLnBvcCgpO1xuICAgICAgICAgIGNvbnRpbnVlO1xuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKHJlc3VsdCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgIGVkaXRzLnB1c2goW2tleSwgcmVzdWx0XSk7XG5cbiAgICAgICAgaWYgKCFpc0xlYXZpbmcpIHtcbiAgICAgICAgICBpZiAoKDAsIF9hc3QuaXNOb2RlKShyZXN1bHQpKSB7XG4gICAgICAgICAgICBub2RlID0gcmVzdWx0O1xuICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICBwYXRoLnBvcCgpO1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuXG4gICAgaWYgKHJlc3VsdCA9PT0gdW5kZWZpbmVkICYmIGlzRWRpdGVkKSB7XG4gICAgICBlZGl0cy5wdXNoKFtrZXksIG5vZGVdKTtcbiAgICB9XG5cbiAgICBpZiAoaXNMZWF2aW5nKSB7XG4gICAgICBwYXRoLnBvcCgpO1xuICAgIH0gZWxzZSB7XG4gICAgICB2YXIgX25vZGUka2luZDtcblxuICAgICAgc3RhY2sgPSB7XG4gICAgICAgIGluQXJyYXksXG4gICAgICAgIGluZGV4LFxuICAgICAgICBrZXlzLFxuICAgICAgICBlZGl0cyxcbiAgICAgICAgcHJldjogc3RhY2ssXG4gICAgICB9O1xuICAgICAgaW5BcnJheSA9IEFycmF5LmlzQXJyYXkobm9kZSk7XG4gICAgICBrZXlzID0gaW5BcnJheVxuICAgICAgICA/IG5vZGVcbiAgICAgICAgOiAoX25vZGUka2luZCA9IHZpc2l0b3JLZXlzW25vZGUua2luZF0pICE9PSBudWxsICYmXG4gICAgICAgICAgX25vZGUka2luZCAhPT0gdm9pZ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gICAgICAgICAgaWYgKHJlc3VsdCA9PT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgc2tpcHBpbmdbaV0gPSBub2RlO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChyZXN1bHQgPT09IEJSRUFLKSB7XG4gICAgICAgICAgICAgIHNraXBwaW5nW2ldID0gQlJFQUs7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHJlc3VsdCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgICAgICAgIHJldHVybiByZXN1bHQ7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9LFxuXG4gICAgICBsZWF2ZSguLi5hcmdzKSB7XG4gICAgICAgIGNvbnN0IG5vZGUgPSBhcmdzWzBdO1xuXG4gICAgICAgIGZvciAobGV0IGkgPSAwOyBpIDwgdmlzaXRvcnMubGVuZ3RoOyBpKyspIHtcbiAgICAgICAgICBpZiAoc2tpcHBpbmdbaV0gPT09IG51bGwpIHtcbiAgICAgICAgICAgIHZhciBfbGVhdmVMaXN0JGk7XG5cbiAgICAgICAgICAgIGNvbnN0IHJlc3VsdCA9XG4gICAgICAgICAgICAgIChfbGVhdmVMaXN0JGkgPSBsZWF2ZUxpc3RbaV0pID09PSBudWxsIHx8IF9sZWF2ZUxpc3QkaSA9PT0gdm9pZCAwXG4gICAgICAgICAgICAgICAgPyB2b2lkIDBcbiAgICAgICAgICAgICAgICA6IF9sZWF2ZUxpc3QkaS5hcHBseSh2aXNpdG9yc1tpXSwgYXJncyk7XG5cbiAgICAgICAgICAgIGlmIChyZXN1bHQgPT09IEJSRUFLKSB7XG4gICAgICAgICAgICAgIHNraXBwaW5nW2ldID0gQlJFQUs7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHJlc3VsdCAhPT0gdW5kZWZpbmVkICYmIHJlc3VsdCAhPT0gZmFsc2UpIHtcbiAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgIH1cbiAgICA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B9XG5cbiAgICAgICAgaWYgKCgwLCBfZGVmaW5pdGlvbi5pc0VudW1UeXBlKSh0eXBlKSkge1xuICAgICAgICAgIHJldHVybiBUeXBlS2luZC5FTlVNO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKCgwLCBfZGVmaW5pdGlvbi5pc0lucHV0T2JqZWN0VHlwZSkodHlwZSkpIHtcbiAgICAgICAgICByZXR1cm4gVHlwZUtpbmQuSU5QVVRfT0JKRUNUO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKCgwLCBfZGVmaW5pdGlvbi5pc0xpc3RUeXBlKSh0eXBlKSkge1xuICAgICAgICAgIHJldHVybiBUeXBlS2luZC5MSVNUO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKCgwLCBfZGVmaW5pdGlvbi5pc05vbk51bGxUeXBlKSh0eXBlKSkge1xuICAgICAgICAgIHJldHVybiBUeXBlS2luZC5OT05fTlVMTDtcbiAgICAgICAgfVxuICAgICAgICAvKiBjOCBpZ25vcmUgbmV4dCAzICovXG4gICAgICAgIC8vIE5vdCByZWFjaGFibGUsIGFsbCBwb3NzaWJsZSB0eXBlcyBoYXZlIGJlZW4gY29uc2lkZXJlZClcblxuICAgICAgICBmYWxzZSB8fFxuICAgICAgICAgICgwLCBfaW52YXJpYW50LmludmFyaWFudCkoXG4gICAgICAgICAgICBmYWxzZSxcbiAgICAgICAgICAgIGBVbmV4cGVjdGVkIHR5cGU6IFwiJHsoMCwgX2luc3BlY3QuaW5zcGVjdCkodHlwZSl9XCIuYCxcbiAgICAgICAgICApO1xuICAgICAgfSxcbiAgICB9LFxuICAgIG5hbWU6IHtcbiAgICAgIHR5cGU6IF9zY2FsYXJzLkdyYXBoUUxTdHJpbmcsXG4gICAgICByZXNvbHZlOiAodHlwZSkgPT4gKCduYW1lJyBpbiB0eXBlID8gdHlwZS5uYW1lIDogdW5kZWZpbmVkKSxcbiAgICB9LFxuICAgIGRlc2NyaXB0aW9uOiB7XG4gICAgICB0eXBlO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W50YXRpb25zID0gdGhpcy5faW1wbGVtZW50YXRpb25zTWFwW2lmYWNlLm5hbWVdO1xuXG4gICAgICAgICAgICBpZiAoaW1wbGVtZW50YXRpb25zID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgaW1wbGVtZW50YXRpb25zID0gdGhpcy5faW1wbGVtZW50YXRpb25zTWFwW2lmYWNlLm5hbWVdID0ge1xuICAgICAgICAgICAgICAgIG9iamVjdHM6IFtdLFxuICAgICAgICAgICAgICAgIGludGVyZmFjZXM6IFtdLFxuICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpbXBsZW1lbnRhdGlvbnMuaW50ZXJmYWNlcy5wdXNoKG5hbWVkVHlwZSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKCgwLCBfZGVmaW5pdGlvbi5pc09iamVjdFR5cGUpKG5hbWVkVHlwZSkpIHtcbiAgICAgICAgLy8gU3RvcmUgaW1wbGVtZW50YXRpb25zIGJ5IG9iamVjdHMuXG4gICAgICAgIGZvciAoY29uc3QgaWZhY2Ugb2YgbmFtZWRUeXBlLmdldEludGVyZmFjZXMoKSkge1xuICAgICAgICAgIGlmICgoMCwgX2RlZmluaXRpb24uaXNJbnRlcmZhY2VUeXBlKShpZmFjZSkpIHtcbiAgICAgICAgICAgIGxldCBpbXBsZW1lbnRhdGlvbnMgPSB0aGlzLl9pbXBsZW1lbnRhdGlvbnNNYXBbaWZhY2UubmFtZV07XG5cbiAgICAgICAgICAgIGlmIChpbXBsZW1lbnRhdGlvbnMgPT09IHVuZGVmaW5lZCkge1xuICAgICAgICAgICAgICBpbXBsZW1lbnRhdGlvbnMgPSB0aGlzLl9pbXBsZW1lbnRhdGlvbnNNYXBbaWZhY2UubmFtZV0gPSB7XG4gICAgICAgICAgICAgICAgb2JqZWN0czogW10sXG4gICAgICAgICAgICAgICAgaW50ZXJmYWNlczogW10sXG4gICAgICAgICAgICAgIH07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ZJRUxEOiB7XG4gICAgICAgIGNvbnN0IG9iamVjdFR5cGUgPSAoMCwgX2RlZmluaXRpb24uZ2V0TmFtZWRUeXBlKSh0aGlzLmdldElucHV0VHlwZSgpKTtcbiAgICAgICAgbGV0IGlucHV0RmllbGRUeXBlO1xuICAgICAgICBsZXQgaW5wdXRGaWVsZDtcblxuICAgICAgICBpZiAoKDAsIF9kZWZpbml0aW9uLmlzSW5wdXRPYmplY3RUeXBlKShvYmplY3RUeXBlKSkge1xuICAgICAgICAgIGlucHV0RmllbGQgPSBvYmplY3RUeXBlLmdldEZpZWxkcygpW25vZGUubmFtZS52YWx1ZV07XG5cbiAgICAgICAgICBpZiAoaW5wdXRGaWVsZCkge1xuICAgICAgICAgICAgaW5wdXRGaWVsZFR5cGUgPSBpbnB1dEZpZWxkLnR5cGU7XG4gICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgdGhpcy5fZGVmYXVsdFZhbHVlU3RhY2sucHVzaChcbiAgICAgICAgICBpbnB1dEZpZWxkID8gaW5wdXRGaWVsZC5kZWZhdWx0VmFsdWUgOiB1bmRlZmluZWQsXG4gICAgICAgICk7XG5cbiAgICAgICAgdGhpcy5faW5wdXRUeXBlU3RhY2sucHVzaChcbiAgICAgICAgICAoMCwgX2RlZmluaXRpb24uaXNJbnB1dFR5cGUpKGlucHV0RmllbGRUeXBlKVxuICAgICAgICAgICAgPyBpbnB1dEZpZWxkVHlwZVxuICAgICAgICAgICAgOiB1bmRlZmluZWQsXG4gICAgICAgICk7XG5cbiAgICAgICAgYnJlYWs7XG4gICAgICB9XG5cbiAgICAgIGNhc2UgX2tpbmRzLktpbmQuRU5VTToge1xuICAgICAgICBjb25zdCBlbnVtVHlwZSA9ICgwLCBfZGVmaW5pdGlvbi5nZXROYW1lZFR5cGUpKHRoaXMuZ2V0SW5wdXRUeXBlKCkpO1xuICAgICAgICBsZXQgZW51bVZhbHVlO1xuXG4gICAgICAgIGlmICgoMCwgX2RlZmluaXRpb24uaXN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gICAgfFxuICogfCAtLS0tLS0tLS0tLS0tLS0tLS0tLSB8IC0tLS0tLS0tLS0tLS0gfFxuICogfCBJbnB1dCBPYmplY3QgICAgICAgICB8IE9iamVjdCAgICAgICAgfFxuICogfCBMaXN0ICAgICAgICAgICAgICAgICB8IEFycmF5ICAgICAgICAgfFxuICogfCBCb29sZWFuICAgICAgICAgICAgICB8IEJvb2xlYW4gICAgICAgfFxuICogfCBTdHJpbmcgICAgICAgICAgICAgICB8IFN0cmluZyAgICAgICAgfFxuICogfCBJbnQgLyBGbG9hdCAgICAgICAgICB8IE51bWJlciAgICAgICAgfFxuICogfCBFbnVtIFZhbHVlICAgICAgICAgICB8IFVua25vd24gICAgICAgfFxuICogfCBOdWxsVmFsdWUgICAgICAgICAgICB8IG51bGwgICAgICAgICAgfFxuICpcbiAqL1xuZnVuY3Rpb24gdmFsdWVGcm9tQVNUKHZhbHVlTm9kZSwgdHlwZSwgdmFyaWFibGVzKSB7XG4gIGlmICghdmFsdWVOb2RlKSB7XG4gICAgLy8gV2hlbiB0aGVyZSBpcyBubyBub2RlLCB0aGVuIHRoZXJlIGlzIGFsc28gbm8gdmFsdWUuXG4gICAgLy8gSW1wb3J0YW50bHksIHRoaXMgaXMgZGlmZmVyZW50IGZyb20gcmV0dXJuaW5nIHRoZSB2YWx1ZSBudWxsLlxuICAgIHJldHVybjtcbiAgfVxuXG4gIGlmICh2YWx1ZU5vZGUua2luZCA9PT0gX2tpbmRzLktpbmQuVkFSSUFCTEUpIHtcbiAgICBjb25zdCB2YXJpYWJsZU5hbWUgPSB2YWx1ZU5vZGUubmFtZS52YWx1ZTtcblxuICAgIGlmICh2YXJpYWJsZXMgPT0gbnVsbCB8fCB2YXJpYWJsZXNbdmFyaWFibGVOYW1lXSA9PT0gdW5kZWZpbmVkKSB7XG4gICAgICAvLyBObyB2YWxpZCByZXR1cm4gdmFsdWUuXG4gICAgICByZXR1cm47XG4gICAgfVxuXG4gICAgY29uc3QgdmFyaWFibGVWYWx1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Y2hlbWEgPT09IHZvaWQgMFxuICAgICAgPyB2b2lkIDBcbiAgICAgIDogb2xkU2NoZW1hLmdldFN1YnNjcmlwdGlvblR5cGUoKTtcbiAgbGV0IHNjaGVtYURlZmluaXRpb25zQ291bnQgPSAwO1xuICByZXR1cm4ge1xuICAgIFNjaGVtYURlZmluaXRpb24obm9kZSkge1xuICAgICAgaWYgKGFscmVhZHlEZWZpbmVkKSB7XG4gICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgJ0Nhbm5vdCBkZWZpbmUgYSBuZXcgc2NoZW1hIHdpdGhpbiBhIHNjaGVtYSBleHRlbnNpb24uJyxcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgbm9kZXM6IG5vZGUsXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICksXG4gICAgICAgICk7XG4gICAgICAgIHJldHVybjtcbiAgICAgIH1cblxuICAgICAgaWYgKHNjaGVtYURlZmluaXRpb25zQ291bnQgPiAwKSB7XG4gICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgJ011c3QgcHJvdmlkZSBvbmx5IG9uZSBzY2hlbWEgZGVmaW5pdGlvbi4nLFxuICAgICAgICAgICAge1xuICAgICAgICAgICAgICBub2Rlczogbm9kZSxcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgKSxcbiAgICAgICAgKTtcbiAgICAgIH1cblxuICAgICAgKytzY2hlbWFEZWZpbml0aW9uc0NvdW50O1xuICAgIH0sXG4gIH07XG59XG4iLCIndXNlIHN0cmljdCc7XG5cbk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAnX19lc01vZHVsZScsIHtcbiAgdmFsdWU6IHRydWUsXG59KTtcbmV4cG9ydHMuTm9Gc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IHtcbiAgICAgICAgY29uc3QgdXNhZ2VzID0gY29udGV4dC5nZXRSZWN1cnNpdmVWYXJpYWJsZVVzYWdlcyhvcGVyYXRpb24pO1xuXG4gICAgICAgIGZvciAoY29uc3QgeyBub2RlIH0gb2YgdXNhZ2VzKSB7XG4gICAgICAgICAgY29uc3QgdmFyTmFtZSA9IG5vZGUubmFtZS52YWx1ZTtcblxuICAgICAgICAgIGlmICh2YXJpYWJsZU5hbWVEZWZpbmVkW3Zhck5hbWVdICE9PSB0cnVlKSB7XG4gICAgICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgICAgICBuZXcgX0dyYXBoUUxFcnJvci5HcmFwaFFMRXJyb3IoXG4gICAgICAgICAgICAgICAgb3BlcmF0aW9uLm5hbWVcbiAgICAgICAgICAgICAgICAgID8gYFZhcmlhYmxlIFwiJCR7dmFyTmFtZX1cIiBpcyBub3QgZGVmaW5lZCBieSBvcGVyYXRpb24gXCIke29wZXJhdGlvbi5uYW1lLnZhbHVlfVwiLmBcbiAgICAgICAgICAgICAgICAgIDogYFZhcmlhYmxlIFwiJCR7dmFyTmFtZX1cIiBpcyBub3QgZGVmaW5lZC5gLFxuICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgIG5vZGVzOiBbbm9kZSwgb3BlcmF0aW9uXSxcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICApLFxuICAgICAgICAgICAgKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0sXG4gICAgfSxcblxuICAgIFZhcmlhYmxlRGVmaW5pdGlvbihub2RlKSB7XG4gICAgICB2YXJpYWJsZU5hbWVEZWZpbmVkW25vZGUudmFyaWFibGUubmFtZS52YWx1ZV0gPSB0cnVlO1xuICAgIH0sXG4gIH07XG59XG4iLCIndXNlIHN0cmljdCc7XG5cbk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAnX19lc01vZHVsZScsIHtcbiAgdmFs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Rpb24gb2Ygb3BlcmF0aW9uRGVmcykge1xuICAgICAgICAgIGZvciAoY29uc3QgZnJhZ21lbnQgb2YgY29udGV4dC5nZXRSZWN1cnNpdmVseVJlZmVyZW5jZWRGcmFnbWVudHMoXG4gICAgICAgICAgICBvcGVyYXRpb24sXG4gICAgICAgICAgKSkge1xuICAgICAgICAgICAgZnJhZ21lbnROYW1lVXNlZFtmcmFnbWVudC5uYW1lLnZhbHVlXSA9IHRydWU7XG4gICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgZm9yIChjb25zdCBmcmFnbWVudERlZiBvZiBmcmFnbWVudERlZnMpIHtcbiAgICAgICAgICBjb25zdCBmcmFnTmFtZSA9IGZyYWdtZW50RGVmLm5hbWUudmFsdWU7XG5cbiAgICAgICAgICBpZiAoZnJhZ21lbnROYW1lVXNlZFtmcmFnTmFtZV0gIT09IHRydWUpIHtcbiAgICAgICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgICAgIG5ldyBfR3JhcGhRTEVycm9yLkdyYXBoUUxFcnJvcihcbiAgICAgICAgICAgICAgICBgRnJhZ21lbnQgXCIke2ZyYWdOYW1lfVwiIGlzIG5ldmVyIHVzZWQuYCxcbiAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICBub2RlczogZnJhZ21lbnREZWYsXG4gICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgKSxcbiAgICAgICAgICAgICk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9LFxuICAgIH0sXG4gIH07XG59XG4iLCIndXNlIHN0cmljdCc7XG5cbk9iamVjdC5kZWZpbmVQcm9wZXJ0eShleHBvcnRzLCAnX19lc01vZHVsZScsIHtcbiAgdmFsdWU6IHRydWUsXG59KTtcbmV4cG9ydHMuTm9VbnVzZWRWYXJpYWJsZXNSdWxlID0gTm9VbnVzZWRWYXJpYWJsZXNSdWxlO1xuXG52YXIgX0dyYXBoUUxFcnJvciA9IH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2VsZWN0aW9uLmFsaWFzXG4gICAgICAgICAgPyBzZWxlY3Rpb24uYWxpYXMudmFsdWVcbiAgICAgICAgICA6IGZpZWxkTmFtZTtcblxuICAgICAgICBpZiAoIW5vZGVBbmREZWZzW3Jlc3BvbnNlTmFtZV0pIHtcbiAgICAgICAgICBub2RlQW5kRGVmc1tyZXNwb25zZU5hbWVdID0gW107XG4gICAgICAgIH1cblxuICAgICAgICBub2RlQW5kRGVmc1tyZXNwb25zZU5hbWVdLnB1c2goW3BhcmVudFR5cGUsIHNlbGVjdGlvbiwgZmllbGREZWZdKTtcbiAgICAgICAgYnJlYWs7XG4gICAgICB9XG5cbiAgICAgIGNhc2UgX2tpbmRzLktpbmQuRlJBR01FTlRfU1BSRUFEOlxuICAgICAgICBmcmFnbWVudE5hbWVzW3NlbGVjdGlvbi5uYW1lLnZhbHVlXSA9IHRydWU7XG4gICAgICAgIGJyZWFrO1xuXG4gICAgICBjYXNlIF9raW5kcy5LaW5kLklOTElORV9GUkFHTUVOVDoge1xuICAgICAgICBjb25zdCB0eXBlQ29uZGl0aW9uID0gc2VsZWN0aW9uLnR5cGVDb25kaXRpb247XG4gICAgICAgIGNvbnN0IGlubGluZUZyYWdtZW50VHlwZSA9IHR5cGVDb25kaXRpb25cbiAgICAgICAgICA/ICgwLCBfdHlwZUZyb21BU1QudHlwZUZyb21BU1QpKGNvbnRleHQuZ2V0U2NoZW1hKCksIHR5cGVDb25kaXRpb24pXG4gICAgICAgICAgOiBwYXJlbnRUeXBlO1xuXG4gICAgICAgIF9jb2xsZWN0RmllbGRzQW5kRnJhZ21lbnROYW1lcyhcbiAgICAgICAgICBjb250ZXh0LFxuICAgICAgICAgIGlubGluZUZyYWdtZW50VHlwZSxcbiAgICAgICAgICBzZWxlY3Rpb24uc2VsZWN0aW9uU2V0LFxuICAgICAgICAgIG5vZGVBbmREZWZzLFxuICAgICAgICAgIGZyYWdtZW50TmFtZXMsXG4gICAgICAgICk7XG5cbiAgICAgICAgYnJlYW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AgICAgICAgICBfZmllbGROb2RlJGFyZ3VtZW50cyA9PT0gdm9pZCAwXG4gICAgICAgICAgICA/IHZvaWQgMFxuICAgICAgICAgICAgOiBfZmllbGROb2RlJGFyZ3VtZW50cy5tYXAoKGFyZykgPT4gYXJnLm5hbWUudmFsdWUpLFxuICAgICAgICApO1xuXG4gICAgICAgIGZvciAoY29uc3QgYXJnRGVmIG9mIGZpZWxkRGVmLmFyZ3MpIHtcbiAgICAgICAgICBpZiAoXG4gICAgICAgICAgICAhcHJvdmlkZWRBcmdzLmhhcyhhcmdEZWYubmFtZSkgJiZcbiAgICAgICAgICAgICgwLCBfZGVmaW5pdGlvbi5pc1JlcXVpcmVkQXJndW1lbnQpKGFyZ0RlZilcbiAgICAgICAgICApIHtcbiAgICAgICAgICAgIGNvbnN0IGFyZ1R5cGVTdHIgPSAoMCwgX2luc3BlY3QuaW5zcGVjdCkoYXJnRGVmLnR5cGUpO1xuICAgICAgICAgICAgY29udGV4dC5yZXBvcnRFcnJvcihcbiAgICAgICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICAgIGBGaWVsZCBcIiR7ZmllbGREZWYubmFtZX1cIiBhcmd1bWVudCBcIiR7YXJnRGVmLm5hbWV9XCIgb2YgdHlwZSBcIiR7YXJnVHlwZVN0cn1cIiBpcyByZXF1aXJlZCwgYnV0IGl0IHdhcyBub3QgcHJvdmlkZWQuYCxcbiAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICBub2RlczogZmllbGROb2RlLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICksXG4gICAgICAgICAgICApO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSxcbiAgICB9LFxuICB9O1xufVxuLyoqXG4gKiBAaW50ZXJuYWxcbiAqL1xuXG5mdW5jdGlvbiBQcm92aWRlZFJlcXVpcmVkQXJndW1lbnRzT25EaXJlY3RpdmVzUnVsZ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xuXG4gICAgICAgICAgY29uc3QgZmllbGRzID0gKDAsIF9jb2xsZWN0RmllbGRzLmNvbGxlY3RGaWVsZHMpKFxuICAgICAgICAgICAgc2NoZW1hLFxuICAgICAgICAgICAgZnJhZ21lbnRzLFxuICAgICAgICAgICAgdmFyaWFibGVWYWx1ZXMsXG4gICAgICAgICAgICBzdWJzY3JpcHRpb25UeXBlLFxuICAgICAgICAgICAgbm9kZS5zZWxlY3Rpb25TZXQsXG4gICAgICAgICAgKTtcblxuICAgICAgICAgIGlmIChmaWVsZHMuc2l6ZSA+IDEpIHtcbiAgICAgICAgICAgIGNvbnN0IGZpZWxkU2VsZWN0aW9uTGlzdHMgPSBbLi4uZmllbGRzLnZhbHVlcygpXTtcbiAgICAgICAgICAgIGNvbnN0IGV4dHJhRmllbGRTZWxlY3Rpb25MaXN0cyA9IGZpZWxkU2VsZWN0aW9uTGlzdHMuc2xpY2UoMSk7XG4gICAgICAgICAgICBjb25zdCBleHRyYUZpZWxkU2VsZWN0aW9ucyA9IGV4dHJhRmllbGRTZWxlY3Rpb25MaXN0cy5mbGF0KCk7XG4gICAgICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgICAgICBuZXcgX0dyYXBoUUxFcnJvci5HcmFwaFFMRXJyb3IoXG4gICAgICAgICAgICAgICAgb3BlcmF0aW9uTmFtZSAhPSBudWxsXG4gICAgICAgICAgICAgICAgICA/IGBTdWJzY3JpcHRpb24gXCIke29wZXJhdGlvbk5hbWV9XCIgbXVzdCBzZWxlY3Qgb25seSBvbmUgdG9wIGxldmVsIGZpZWxkLmBcbiAgICAgICAgICAgICAgICAgIDogJ0Fub255bW91cyBTdWJzY3JpcHRpb24gbXVzdCBzZWxlY3Qgb25seSBvbmUgdG9wIGxldmVsIGZpZWxkLicsXG4gICAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgICAgbm9kZXM6IGV4dHJhRmllbGRTZWxlY3Rpb25zLFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICksXG4gICAgICAgICAgICApO1xuICAgICAgICAgIH1cblxuICAgICAgICAgIGZvciAoY29uc3QgZmllbGROb2RlcyBvZiBmaWVsZHMudmFsdWVzKCkpIHtcbiAgICAgICAgICAgIGNvbnN0IGZpZWxkID0gZmllbGROb2Rlc1swXTtcbiAgICAgICAgICAgIGNvbnN0IGZpZWxkTmFtZSA9IGZpZWxkLm5hbWUudmFsdWU7XG5cbiAgICAgICAgICAgIGlmIChmaWVsZE5hbWUuc3RhcnRzV2l0aCgnX18nKSkge1xuICAgICAgICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgICAgICAgIG5ldyBfR3JhcGhRTEVycm9yLkdyYXBoUUxFcnJvcihcbiAgICAgICAgICAgICAgICAgIG9wZXJhdGlvbk5hbWUgIT0gbnVsbFxuICAgICAgICAgICAgICAgICAgICA/IGBTdWJzY3JpcHRpb24gXCIke29wZXJhdGlvbk5hbWV9XCIgbXVzdCBub3Qgc2VsZWN0IGFuIGludHJvc3BlY3Rpb24gdG9wIGxldmVsIGZpZWxkLmBcbiAgICAgICAgICAgICAgICAgICAgOiAnQW5vbnltb3VzIFN1YnNjcmlwdGlvbiBtdXN0IG5vdCBzZWxlY3QgYW4gaW50cm9zcGVjdGlvbiB0b3AgbGV2ZWwgZmllbGQuJyxcbiAgICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgICAgbm9kZXM6IGZpZWxkTm9kZXMsXG4gICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICksXG4gICAgICAgICAgICAgICk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcbiAgfTtcbn1cbiIsIid1c2Ugc3RyaWN0JztcblxuT2JqZWN0LmRlZmluZVByb3BlcnR5KGV4cG9ydHMsICdfX2VzTW9kdWxlJywge1xuICB2YWx1ZTogdHJ1ZSxcbn0pO1xuZXhwb3J0cy5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FwaHFsLm9yZy9kcmFmdC8jc2VjLUlucHV0LU9iamVjdC1GaWVsZC1VbmlxdWVuZXNzXG4gKi9cbmZ1bmN0aW9uIFVuaXF1ZUlucHV0RmllbGROYW1lc1J1bGUoY29udGV4dCkge1xuICBjb25zdCBrbm93bk5hbWVTdGFjayA9IFtdO1xuICBsZXQga25vd25OYW1lcyA9IE9iamVjdC5jcmVhdGUobnVsbCk7XG4gIHJldHVybiB7XG4gICAgT2JqZWN0VmFsdWU6IHtcbiAgICAgIGVudGVyKCkge1xuICAgICAgICBrbm93bk5hbWVTdGFjay5wdXNoKGtub3duTmFtZXMpO1xuICAgICAgICBrbm93bk5hbWVzID0gT2JqZWN0LmNyZWF0ZShudWxsKTtcbiAgICAgIH0sXG5cbiAgICAgIGxlYXZlKCkge1xuICAgICAgICBjb25zdCBwcmV2S25vd25OYW1lcyA9IGtub3duTmFtZVN0YWNrLnBvcCgpO1xuICAgICAgICBwcmV2S25vd25OYW1lcyB8fCAoMCwgX2ludmFyaWFudC5pbnZhcmlhbnQpKGZhbHNlKTtcbiAgICAgICAga25vd25OYW1lcyA9IHByZXZLbm93bk5hbWVzO1xuICAgICAgfSxcbiAgICB9LFxuXG4gICAgT2JqZWN0RmllbGQobm9kZSkge1xuICAgICAgY29uc3QgZmllbGROYW1lID0gbm9kZS5uYW1lLnZhbHVlO1xuXG4gICAgICBpZiAoa25vd25OYW1lc1tmaWVsZE5hbWVdKSB7XG4gICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgYFRoZXJlIGNhbiBiZSBvbmx5IG9uZSBpbnB1dCBmaWVsZCBuYW1lZCBcIiR7ZmllbGROYW1lfVwiLmAsXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgIG5vZGVzOiBba25vd25OYW1lc1tmaWVsZE5hbWVdLCBub2RlLm5hbWVdLFxuICAgICAgICAgICAg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YpKSB7XG4gICAgICAgICAgY29uc3QgdHlwZVN0ciA9ICgwLCBfaW5zcGVjdC5pbnNwZWN0KShmaWVsZERlZi50eXBlKTtcbiAgICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICBgRmllbGQgXCIke3R5cGUubmFtZX0uJHtmaWVsZERlZi5uYW1lfVwiIG9mIHJlcXVpcmVkIHR5cGUgXCIke3R5cGVTdHJ9XCIgd2FzIG5vdCBwcm92aWRlZC5gLFxuICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgbm9kZXM6IG5vZGUsXG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICApLFxuICAgICAgICAgICk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9LFxuXG4gICAgT2JqZWN0RmllbGQobm9kZSkge1xuICAgICAgY29uc3QgcGFyZW50VHlwZSA9ICgwLCBfZGVmaW5pdGlvbi5nZXROYW1lZFR5cGUpKFxuICAgICAgICBjb250ZXh0LmdldFBhcmVudElucHV0VHlwZSgpLFxuICAgICAgKTtcbiAgICAgIGNvbnN0IGZpZWxkVHlwZSA9IGNvbnRleHQuZ2V0SW5wdXRUeXBlKCk7XG5cbiAgICAgIGlmICghZmllbGRUeXBlICYmICgwLCBfZGVmaW5pdGlvbi5pc0lucHV0T2JqZWN0VHlwZSkocGFyZW50VHlwZSkpIHtcbiAgICAgICAgY29uc3Qgc3VnZ2VzdGlvbnMgPSAoMCwgX3N1Z2dlc3Rpb25MaXN0LnN1Z2dlc3Rpb25MaXN0KShcbiAgICAgICAgICBub2RlLm5hbWUudmFsdWUsXG4gICAgICAgICAgT2JqZWN0LmtleXMocGFyZW50VHlwZS5nZXRGaWVsZHMoKSksXG4gICAgICAgICk7XG4gICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgYEZpZWxkIFwiJHtub2RlLm5hbWUudmFsdWV9XCIgaXMgbm90IGRlZmluZWQgYnkgdHlwZSBcIiR7cGFyZW50VHlwZS5uYW1lfVwiLmAgK1xuICAgICAgICAgICAgICAoMCwgX2RpZFlvdU1lYW4uZGlkWW91TWVhbikoc3VnZ2VzdGlvbnMpLFxuICAgICAgICAgICAge1xuICAgICAgICAgICAgICBub2Rlczogbm9kZSxcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgKSxcbiAgICAgICAgKTtcbiAgICAgIH1cbiAgICB9LFxuXG4gICAgTnVsbFZhbHVlKG5vZGUpIHtcbiAgICAgIGNvbnN0IHR5cGUgPSBjb250ZXh0LmdldElucHV0VHlwZSgpO1xuXG4gICAgICBpZiAoKDAsIF9kZWZpbml0aW9uLmlzTm9uTnVsbFR5cGUpKHR5cGUpKSB7XG4gICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgYEV4cGVjdGVkIHZhbHVlIG9mIHR5cGUgXCIkeygwLCBfaW5zcGVjdC5pbnNwZWN0KShcbiAgICAgICAgICAgICAgdHlwZSxcbiAgICAgICAgICAgICl9XCIsIGZvdW5kICR7KDAsIF9wcmludGVyLnByaW50KShub2RlKX0uYCxcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgbm9kZXM6IG5vZGUsXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICksXG4gICAgICAgICk7XG4gICAgICB9XG4gICAgfSxcblxuICAgIEVudW1WYWx1ZTogKG5vZGUpID0+IGlzVmFsaWRWYWx1ZU5vZGUoY29udGV4dCwgbm9kZSksXG4gICAgSW50VmFsdWU6IChub2RlKSA9PiBpc1ZhbGlkVmFsdWVOb2RlKGNvbnRleHQsIG5vZGUpLFxuICAgIEZsb2F0VmFsdWU6IChub2RlKS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SB0eXBlIChjb250cmF2YXJpYW50KS5cbiAgICAgICAgICAgIGNvbnN0IHNjaGVtYSA9IGNvbnRleHQuZ2V0U2NoZW1hKCk7XG4gICAgICAgICAgICBjb25zdCB2YXJUeXBlID0gKDAsIF90eXBlRnJvbUFTVC50eXBlRnJvbUFTVCkoc2NoZW1hLCB2YXJEZWYudHlwZSk7XG5cbiAgICAgICAgICAgIGlmIChcbiAgICAgICAgICAgICAgdmFyVHlwZSAmJlxuICAgICAgICAgICAgICAhYWxsb3dlZFZhcmlhYmxlVXNhZ2UoXG4gICAgICAgICAgICAgICAgc2NoZW1hLFxuICAgICAgICAgICAgICAgIHZhclR5cGUsXG4gICAgICAgICAgICAgICAgdmFyRGVmLmRlZmF1bHRWYWx1ZSxcbiAgICAgICAgICAgICAgICB0eXBlLFxuICAgICAgICAgICAgICAgIGRlZmF1bHRWYWx1ZSxcbiAgICAgICAgICAgICAgKVxuICAgICAgICAgICAgKSB7XG4gICAgICAgICAgICAgIGNvbnN0IHZhclR5cGVTdHIgPSAoMCwgX2luc3BlY3QuaW5zcGVjdCkodmFyVHlwZSk7XG4gICAgICAgICAgICAgIGNvbnN0IHR5cGVTdHIgPSAoMCwgX2luc3BlY3QuaW5zcGVjdCkodHlwZSk7XG4gICAgICAgICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICAgICAgYFZhcmlhYmxlIFwiJCR7dmFyTmFtZX1cIiBvZiB0eXBlIFwiJHt2YXJUeXBlU3RyfVwiIHVzZWQgaW4gcG9zaXRpb24gZXhwZWN0aW5nIHR5cGUgXCIke3R5cGVTdHJ9XCIuYCxcbiAgICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgICAgbm9kZXM6IFt2YXJEZWYsIG5vZGVdLFxuICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICApLFxu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BlLm5hbWV9LiR7ZmllbGREZWYubmFtZX0gaXMgZGVwcmVjYXRlZC4gJHtkZXByZWNhdGlvblJlYXNvbn1gLFxuICAgICAgICAgICAge1xuICAgICAgICAgICAgICBub2Rlczogbm9kZSxcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgKSxcbiAgICAgICAgKTtcbiAgICAgIH1cbiAgICB9LFxuXG4gICAgQXJndW1lbnQobm9kZSkge1xuICAgICAgY29uc3QgYXJnRGVmID0gY29udGV4dC5nZXRBcmd1bWVudCgpO1xuICAgICAgY29uc3QgZGVwcmVjYXRpb25SZWFzb24gPVxuICAgICAgICBhcmdEZWYgPT09IG51bGwgfHwgYXJnRGVmID09PSB2b2lkIDBcbiAgICAgICAgICA/IHZvaWQgMFxuICAgICAgICAgIDogYXJnRGVmLmRlcHJlY2F0aW9uUmVhc29uO1xuXG4gICAgICBpZiAoYXJnRGVmICYmIGRlcHJlY2F0aW9uUmVhc29uICE9IG51bGwpIHtcbiAgICAgICAgY29uc3QgZGlyZWN0aXZlRGVmID0gY29udGV4dC5nZXREaXJlY3RpdmUoKTtcblxuICAgICAgICBpZiAoZGlyZWN0aXZlRGVmICE9IG51bGwpIHtcbiAgICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICBgRGlyZWN0aXZlIFwiQCR7ZGlyZWN0aXZlRGVmLm5hbWV9XCIgYXJndW1lbnQgXCIke2FyZ0RlZi5uYW1lfVwiIGlzIGRlcHJlY2F0ZWQuICR7ZGVwcmVjYXRpb25SZWFzb259YCxcbiAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIG5vZGVzOiBub2RlLFxuICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgKSxcbiAgICAgICAgICApO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgIGNvbnN0IHBhcmVudFR5cGUgPSBjb250ZXh0LmdldFBhcmVudFR5cGUoKTtcbiAgICAgICAgICBjb25zdCBmaWVsZERlZiA9IGNvbnRleHQuZ2V0RmllbGREZWYoKTtcbiAgICAgICAgICAocGFyZW50VHlwZSAhPSBudWxsICYmIGZpZWxkRGVmICE9IG51bGwpIHx8XG4gICAgICAgICAgICAoMCwgX2ludmFyaWFudC5pbnZhcmlhbnQpKGZhbHNlKTtcbiAgICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICBgRmllbGQgXCIke3BhcmVudFR5cGUubmFtZX0uJHtmaWVsZERlZi5uYW1lfVwiIGFyZ3VtZW50IFwiJHthcmdEZWYubmFtZX1cIiBpcyBkZXByZWNhdGVkLiAke2RlcHJlY2F0aW9uUmVhc29ufWAsXG4gICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICBub2Rlczogbm9kZSxcbiAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICksXG4gICAgICAgICAgKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH0sXG5cbiAgICBPYmplY3RGaWVsZChub2RlKSB7XG4gICAgICBjb25zdCBpbnB1dE9iamVjdERlZiA9ICgwLCBfZGVmaW5pdGlvbi5nZXROYW1lZFR5cGUpKFxuICAgICAgICBjb250ZXh0LmdldFBhcmVudElucHV0VHlwZSgpLFxuICAgICAgKTtcblxuICAgICAgaWYgKCgwLCBfZGVmaW5pdGlvbi5pc0lucHV0T2JqZWN0VHlwZSkoaW5wdXRPYmplY3REZWYpKSB7XG4gICAgICAgIGNvbnN0IGlucHV0RmllbGREZWYgPSBpbnB1dE9iamVjdERlZi5nZXRGaWVsZHMoKVtub2RlLm5hbWUudmFsdWVdO1xuICAgICAgICBjb25zdCBkZXByZWNhdGlvblJlYXNvbiA9XG4gICAgICAgICAgaW5wdXRGaWVsZERlZiA9PT0gbnVsbCB8fCBpbnB1dEZpZWxkRGVmID09PSB2b2lkIDBcbiAgICAgICAgICAgID8gdm9pZCAwXG4gICAgICAgICAgICA6IGlucHV0RmllbGREZWYuZGVwcmVjYXRpb25SZWFzb247XG5cbiAgICAgICAgaWYgKGRlcHJlY2F0aW9uUmVhc29uICE9IG51bGwpIHtcbiAgICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgICAgbmV3IF9HcmFwaFFMRXJyb3IuR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICBgVGhlIGlucHV0IGZpZWxkICR7aW5wdXRPYmplY3REZWYubmFtZX0uJHtpbnB1dEZpZWxkRGVmLm5hbWV9IGlzIGRlcHJlY2F0ZWQuICR7ZGVwcmVjYXRpb25SZWFzb259YCxcbiAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIG5vZGVzOiBub2RlLFxuICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgKSxcbiAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcblxuICAgIEVudW1WYWx1ZShub2RlKSB7XG4gICAgICBjb25zdCBlbnVtVmFsdWVEZWYgPSBjb250ZXh0LmdldEVudW1WYWx1ZSgpO1xuICAgICAgY29uc3QgZGVwcmVjYXRpb25SZWFzb24gPVxuICAgICAgICBlbnVtVmFsdWVEZWYgPT09IG51bGwgfHwgZW51bVZhbHVlRGVmID09PSB2b2lkIDBcbiAgICAgICAgICA/IHZvaWQgMFxuICAgICAgICAgIDogZW51bVZhbHVlRGVmLmRlcHJlY2F0aW9uUmVhc29uO1xuXG4gICAgICBpZiAoZW51bVZhbHVlRGVmICYmIGRlcHJlY2F0aW9uUmVhc29uICE9IG51bGwpIHtcbiAgICAgICAgY29uc3QgZW51bVR5cGVEZWYgPSAoMCwgX2RlZmluaXRpb24uZ2V0TmFtZWRUeXBlKShcbiAgICAgICAgICBjb250ZXh0LmdldElucHV0VHlwZSgpLFxuICAgICAgICApO1xuICAgICAgICBlbnVtVHlwZURlZiAhP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AgICAgYnJlYWs7XG4gICAgZWxzZVxuICAgICAgY29kZSA9IDQ3IC8qLyovO1xuICAgIGlmIChjb2RlID09PSA0NyAvKi8qLykge1xuICAgICAgaWYgKGxhc3RTbGFzaCA9PT0gaSAtIDEgfHwgZG90cyA9PT0gMSkge1xuICAgICAgICAvLyBOT09QXG4gICAgICB9IGVsc2UgaWYgKGxhc3RTbGFzaCAhPT0gaSAtIDEgJiYgZG90cyA9PT0gMikge1xuICAgICAgICBpZiAocmVzLmxlbmd0aCA8IDIgfHwgbGFzdFNlZ21lbnRMZW5ndGggIT09IDIgfHwgcmVzLmNoYXJDb2RlQXQocmVzLmxlbmd0aCAtIDEpICE9PSA0NiAvKi4qLyB8fCByZXMuY2hhckNvZGVBdChyZXMubGVuZ3RoIC0gMikgIT09IDQ2IC8qLiovKSB7XG4gICAgICAgICAgaWYgKHJlcy5sZW5ndGggPiAyKSB7XG4gICAgICAgICAgICB2YXIgbGFzdFNsYXNoSW5kZXggPSByZXMubGFzdEluZGV4T2YoJy8nKTtcbiAgICAgICAgICAgIGlmIChsYXN0U2xhc2hJbmRleCAhPT0gcmVzLmxlbmd0aCAtIDEpIHtcbiAgICAgICAgICAgICAgaWYgKGxhc3RTbGFzaEluZGV4ID09PSAtMSkge1xuICAgICAgICAgICAgICAgIHJlcyA9ICcnO1xuICAgICAgICAgICAgICAgIGxhc3RTZWdtZW50TGVuZ3RoID0gMDtcbiAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICByZXMgPSByZXMuc2xpY2UoMCwgbGFzdFNsYXNoSW5kZXgpO1xuICAgICAgICAgICAgICAgIGxhc3RTZWdtZW50TGVuZ3RoID0gcmVzLmxlbmd0aCAtIDEgLSByZXMubGFzdEluZGV4T2YoJy8nKTtcbiAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICBsYXN0U2xhc2ggPSBpO1xuICAgICAgICAgICAgICBkb3RzID0gMDtcbiAgICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIGlmIChyZXMubGVuZ3RoID09PSAyIHx8IHJlcy5sZW5ndGggPT09IDEpIHtcbiAgICAgICAgICAgIHJlcyA9ICcnO1xuICAgICAgICAgICAgbGFzdFNlZ21lbnRMZW5ndGggPSAwO1xuICAgICAgICAgICAgbGFzdFNsYXNoID0gaTtcbiAgICAgICAgICAgIGRvdHMgPSAwO1xuICAgICAgICAgICAgY29udGludWU7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIGlmIChhbGxvd0Fib3ZlUm9vdCkge1xuICAgICAgICAgIGlmIChyZXMubGVuZ3RoID4gMClcbiAgICAgICAgICAgIHJlcyArPSAnLy4uJztcbiAgICAgICAgICBlbHNlXG4gICAgICAgICAgICByZXMgPSAnLi4nO1xuICAgICAgICAgIGxhc3RTZWdtZW50TGVuZ3RoID0gMjtcbiAgICAgICAgfVxuICAgICAgfSBlbHNlIHtcbiAgICAgICAgaWYgKHJlcy5sZW5ndGggPiAwKVxuICAgICAgICAgIHJlcyArPSAnLycgKyBwYXRoLnNsaWNlKGxhc3RTbGFzaCArIDEsIGkpO1xuICAgICAgICBlbHNlXG4gICAgICAgICAgcmVzID0gcGF0aC5zbGljZShsYXN0U2xhc2ggKyAxLCBpKTtcbiAgICAgICAgbGFzdFNlZ21lbnRMZW5ndGggPSBpIC0gbGFzdFNsYXNoIC0gMTtcbiAgICAgIH1cbiAgICAgIGxhc3RTbGFzaCA9IGk7XG4gICAgICBkb3RzID0gMDtcbiAgICB9IGVsc2UgaWYgKGNvZGUgPT09IDQ2IC8qLiovICYmIGRvdHMgIT09IC0xKSB7XG4gICAgICArK2RvdHM7XG4gICAgfSBlbHNlIHtcbiAgICAgIGRvdHMgPSAtMTtcbiAgICB9XG4gIH1cbiAgcmV0dXJuIHJlcztcbn1cblxuZnVuY3Rpb24gX2Zvcm1hdChzZXAsIHBhdGhPYmplY3QpIHtcbiAgdmFyIGRpciA9IHBhdGhPYmplY3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gICAgICAgICAgICBlbmQgPSBpO1xuICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAvLyBFeHRlbnNpb24gZG9lcyBub3QgbWF0Y2gsIHNvIG91ciByZXN1bHQgaXMgdGhlIGVudGlyZSBwYXRoXG4gICAgICAgICAgICAgIC8vIGNvbXBvbmVudFxuICAgICAgICAgICAgICBleHRJZHggPSAtMTtcbiAgICAgICAgICAgICAgZW5kID0gZmlyc3ROb25TbGFzaEVuZDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgaWYgKHN0YXJ0ID09PSBlbmQpIGVuZCA9IGZpcnN0Tm9uU2xhc2hFbmQ7ZWxzZSBpZiAoZW5kID09PSAtMSkgZW5kID0gcGF0aC5sZW5ndGg7XG4gICAgICByZXR1cm4gcGF0aC5zbGljZShzdGFydCwgZW5kKTtcbiAgICB9IGVsc2Uge1xuICAgICAgZm9yIChpID0gcGF0aC5sZW5ndGggLSAxOyBpID49IDA7IC0taSkge1xuICAgICAgICBpZiAocGF0aC5jaGFyQ29kZUF0KGkpID09PSA0NyAvKi8qLykge1xuICAgICAgICAgICAgLy8gSWYgd2UgcmVhY2hlZCBhIHBhdGggc2VwYXJhdG9yIHRoYXQgd2FzIG5vdCBwYXJ0IG9mIGEgc2V0IG9mIHBhdGhcbiAgICAgICAgICAgIC8vIHNlcGFyYXRvcnMgYXQgdGhlIGVuZCBvZiB0aGUgc3RyaW5nLCBzdG9wIG5vd1xuICAgICAgICAgICAgaWYgKCFtYXRjaGVkU2xhc2gpIHtcbiAgICAgICAgICAgICAgc3RhcnQgPSBpICsgMTtcbiAgICAgICAgICAgICAgYnJlYWs7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgfSBlbHNlIGlmIChlbmQgPT09IC0xKSB7XG4gICAgICAgICAgLy8gV2Ugc2F3IHRoZSBmaXJzdCBub24tcGF0aCBzZXBhcmF0b3Is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UsICduYW1lJyk7XG4gICAgfSBlbHNlIHtcbiAgICAgIG5hbWUgPSBuYW1lLnJlcGxhY2UoLycvZywgXCJcXFxcJ1wiKVxuICAgICAgICAgICAgICAgICAucmVwbGFjZSgvXFxcXFwiL2csICdcIicpXG4gICAgICAgICAgICAgICAgIC5yZXBsYWNlKC8oXlwifFwiJCkvZywgXCInXCIpO1xuICAgICAgbmFtZSA9IGN0eC5zdHlsaXplKG5hbWUsICdzdHJpbmcnKTtcbiAgICB9XG4gIH1cblxuICByZXR1cm4gbmFtZSArICc6ICcgKyBzdHI7XG59XG5cblxuZnVuY3Rpb24gcmVkdWNlVG9TaW5nbGVTdHJpbmcob3V0cHV0LCBiYXNlLCBicmFjZXMpIHtcbiAgdmFyIG51bUxpbmVzRXN0ID0gMDtcbiAgdmFyIGxlbmd0aCA9IG91dHB1dC5yZWR1Y2UoZnVuY3Rpb24ocHJldiwgY3VyKSB7XG4gICAgbnVtTGluZXNFc3QrKztcbiAgICBpZiAoY3VyLmluZGV4T2YoJ1xcbicpID49IDApIG51bUxpbmVzRXN0Kys7XG4gICAgcmV0dXJuIHByZXYgKyBjdXIucmVwbGFjZSgvXFx1MDAxYlxcW1xcZFxcZD9tL2csICcnKS5sZW5ndGggKyAxO1xuICB9LCAwKTtcblxuICBpZiAobGVuZ3RoID4gNjApIHtcbiAgICByZXR1cm4gYnJhY2VzWzBdICtcbiAgICAgICAgICAgKGJhc2UgPT09ICcnID8gJycgOiBiYXNlICsgJ1xcbiAnKSArXG4gICAgICAgICAgICcgJyArXG4gICAgICAgICAgIG91dHB1dC5qb2luKCcsXFxuICAnKSArXG4gICAgICAgICAgICcgJyArXG4gICAgICAgICAgIGJyYWNlc1sxXTtcbiAgfVxuXG4gIHJldHVybiBicmFjZXNbMF0gKyBiYXNlICsgJyAnICsgb3V0cHV0LmpvaW4oJywgJykgKyAnICcgKyBicmFjZXNbMV07XG59XG5cblxuLy8gTk9URTogVGhlc2UgdHlwZSBjaGVja2luZyBmdW5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ICE9PSBudWxsICYmXG4gICAgX3JldHVyblR5cGUkcmVzb2x2ZVR5ICE9PSB2b2lkIDBcbiAgICAgID8gX3JldHVyblR5cGUkcmVzb2x2ZVR5XG4gICAgICA6IGV4ZUNvbnRleHQudHlwZVJlc29sdmVyO1xuICBjb25zdCBjb250ZXh0VmFsdWUgPSBleGVDb250ZXh0LmNvbnRleHRWYWx1ZTtcbiAgY29uc3QgcnVudGltZVR5cGUgPSByZXNvbHZlVHlwZUZuKHJlc3VsdCwgY29udGV4dFZhbHVlLCBpbmZvLCByZXR1cm5UeXBlKTtcblxuICBpZiAoaXNQcm9taXNlKHJ1bnRpbWVUeXBlKSkge1xuICAgIHJldHVybiBydW50aW1lVHlwZS50aGVuKChyZXNvbHZlZFJ1bnRpbWVUeXBlKSA9PlxuICAgICAgY29tcGxldGVPYmplY3RWYWx1ZShcbiAgICAgICAgZXhlQ29udGV4dCxcbiAgICAgICAgZW5zdXJlVmFsaWRSdW50aW1lVHlwZShcbiAgICAgICAgICByZXNvbHZlZFJ1bnRpbWVUeXBlLFxuICAgICAgICAgIGV4ZUNvbnRleHQsXG4gICAgICAgICAgcmV0dXJuVHlwZSxcbiAgICAgICAgICBmaWVsZE5vZGVzLFxuICAgICAgICAgIGluZm8sXG4gICAgICAgICAgcmVzdWx0LFxuICAgICAgICApLFxuICAgICAgICBmaWVsZE5vZGVzLFxuICAgICAgICBpbmZvLFxuICAgICAgICBwYXRoLFxuICAgICAgICByZXN1bHQsXG4gICAgICApLFxuICAgICk7XG4gIH1cblxuICByZXR1cm4gY29tcGxldGVPYmplY3RWYWx1ZShcbiAgICBleGVDb250ZXh0LFxuICAgIGVuc3VyZVZhbGlkUnVudGltZVR5cGUoXG4gICAgICBydW50aW1lVHlwZSxcbiAgICAgIGV4ZUNvbnRleHQsXG4gICAgICByZXR1cm5UeXBlLFxuICAgICAgZmllbGROb2RlcyxcbiAgICAgIGluZm8sXG4gICAgICByZXN1bHQsXG4gICAgKSxcbiAgICBmaWVsZ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gICAgICAgbm9kZXM6IG5vZGUsXG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICApLFxuICAgICAgICAgICk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgY29uc3QgcGFyZW50VHlwZSA9IGNvbnRleHQuZ2V0UGFyZW50VHlwZSgpO1xuICAgICAgICAgIGNvbnN0IGZpZWxkRGVmID0gY29udGV4dC5nZXRGaWVsZERlZigpO1xuICAgICAgICAgIChwYXJlbnRUeXBlICE9IG51bGwgJiYgZmllbGREZWYgIT0gbnVsbCkgfHwgaW52YXJpYW50KGZhbHNlKTtcbiAgICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgICAgbmV3IEdyYXBoUUxFcnJvcihcbiAgICAgICAgICAgICAgYEZpZWxkIFwiJHtwYXJlbnRUeXBlLm5hbWV9LiR7ZmllbGREZWYubmFtZX1cIiBhcmd1bWVudCBcIiR7YXJnRGVmLm5hbWV9XCIgaXMgZGVwcmVjYXRlZC4gJHtkZXByZWNhdGlvblJlYXNvbn1gLFxuICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgbm9kZXM6IG5vZGUsXG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICApLFxuICAgICAgICAgICk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9LFxuXG4gICAgT2JqZWN0RmllbGQobm9kZSkge1xuICAgICAgY29uc3QgaW5wdXRPYmplY3REZWYgPSBnZXROYW1lZFR5cGUoY29udGV4dC5nZXRQYXJlbnRJbnB1dFR5cGUoKSk7XG5cbiAgICAgIGlmIChpc0lucHV0T2JqZWN0VHlwZShpbnB1dE9iamVjdERlZikpIHtcbiAgICAgICAgY29uc3QgaW5wdXRGaWVsZERlZiA9IGlucHV0T2JqZWN0RGVmLmdldEZpZWxkcygpW25vZGUubmFtZS52YWx1ZV07XG4gICAgICAgIGNvbnN0IGRlcHJlY2F0aW9uUmVhc29uID1cbiAgICAgICAgICBpbnB1dEZpZWxkRGVmID09PSBudWxsIHx8IGlucHV0RmllbGREZWYgPT09IHZvaWQgMFxuICAgICAgICAgICAgPyB2b2lkIDBcbiAgICAgICAgICAgIDogaW5wdXRGaWVsZERlZi5kZXByZWNhdGlvblJlYXNvbjtcblxuICAgICAgICBpZiAoZGVwcmVjYXRpb25SZWFzb24gIT0gbnVsbCkge1xuICAgICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgICBuZXcgR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICBgVGhlIGlucHV0IGZpZWxkICR7aW5wdXRPYmplY3REZWYubmFtZX0uJHtpbnB1dEZpZWxkRGVmLm5hbWV9IGlzIGRlcHJlY2F0ZWQuICR7ZGVwcmVjYXRpb25SZWFzb259YCxcbiAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIG5vZGVzOiBub2RlLFxuICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgKSxcbiAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcblxuICAgIEVudW1WYWx1ZShub2RlKSB7XG4gICAgICBjb25zdCBlbnVtVmFsdWVEZWYgPSBjb250ZXh0LmdldEVudW1WYWx1ZSgpO1xuICAgICAgY29uc3QgZGVwcmVjYXRpb25SZWFzb24gPVxuICAgICAgICBlbnVtVmFsdWVEZWYgPT09IG51bGwgfHwgZW51bVZhbHVlRGVmID09PSB2b2lkIDBcbiAgICAgICAgICA/IHZvaWQgMFxuICAgICAgICAgIDogZW51bVZhbHVlRGVmLmRlcHJlY2F0aW9uUmVhc29uO1xuXG4gICAgICBpZiAoZW51bVZhbHVlRGVmICYmIGRlcHJlY2F0aW9uUmVhc29uICE9IG51bGwpIHtcbiAgICAgICAgY29uc3QgZW51bVR5cGVEZWYgPSBnZXROYW1lZFR5cGUoY29udGV4dC5nZXRJbnB1dFR5cGUoKSk7XG4gICAgICAgIGVudW1UeXBlRGVmICE9IG51bGwgfHwgaW52YXJpYW50KGZhbHNlKTt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gICB0eXBlcyB7XG4gICAgICAgICAgLi4uRnVsbFR5cGVcbiAgICAgICAgfVxuICAgICAgICBkaXJlY3RpdmVzIHtcbiAgICAgICAgICBuYW1lXG4gICAgICAgICAgJHtkZXNjcmlwdGlvbnN9XG4gICAgICAgICAgJHtkaXJlY3RpdmVJc1JlcGVhdGFibGV9XG4gICAgICAgICAgbG9jYXRpb25zXG4gICAgICAgICAgYXJncyR7aW5wdXREZXByZWNhdGlvbignKGluY2x1ZGVEZXByZWNhdGVkOiB0cnVlKScpfSB7XG4gICAgICAgICAgICAuLi5JbnB1dFZhbHVlXG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9XG4gICAgfVxuXG4gICAgZnJhZ21lbnQgRnVsbFR5cGUgb24gX19UeXBlIHtcbiAgICAgIGtpbmRcbiAgICAgIG5hbWVcbiAgICAgICR7ZGVzY3JpcHRpb25zfVxuICAgICAgJHtzcGVjaWZpZWRCeVVybH1cbiAgICAgIGZpZWxkcyhpbmNsdWRlRGVwcmVjYXRlZDogdHJ1ZSkge1xuICAgICAgICBuYW1lXG4gICAgICAgICR7ZGVzY3JpcHRpb25zfVxuICAgICAgICBhcmdzJHtpbnB1dERlcHJlY2F0aW9uKCcoaW5jbHVkZURlcHJlY2F0ZWQ6IHRydWUpJyl9IHtcbiAgICAgICAgICAuLi5JbnB1dFZhbHVlXG4gICAgICAgIH1cbiAgICAgICAgdHlwZSB7XG4gICAgICAgICAgLi4uVHlwZVJlZlxuICAgICAgICB9XG4gICAgICAgIGlzRGVwcmVjYXRlZFxuICAgICAgICBkZXByZWNhdGlvblJlYXNvblxuICAgICAgfVxuICAgICAgaW5wdXRGaWVsZHMke2lucHV0RGVwcmVjYXRpb24oJyhpbmNsdWRlRGVwcmVjYXRlZDogdHJ1ZSknKX0ge1xuICAgICAgICAuLi5JbnB1dFZhbHVlXG4gICAgICB9XG4gICAgICBpbnRlcmZhY2VzIHtcbiAgICAgICAgLi4uVHlwZVJlZlxuICAgICAgfVxuICAgICAgZW51bVZhbHVlcyhpbmNsdWRlRGVwcmVjYXRlZDogdHJ1ZSkge1xuICAgICAgICBuYW1lXG4gICAgICAgICR7ZGVzY3JpcHRpb25zfVxuICAgICAgICBpc0RlcHJlY2F0ZWRcbiAgICAgICAgZGVwcmVjYXRpb25SZWFzb25cbiAgICAgIH1cbiAgICAgIHBvc3NpYmxlVHlwZXMge1xuICAgICAgICAuLi5UeXBlUmVmXG4gICAgICB9XG4gICAgfVxuXG4gICAgZnJhZ21lbnQgSW5wdXRWYWx1ZSBvbiBfX0lucHV0VmFsdWUge1xuICAgICAgbmFtZVxuICAgICAgJHtkZXNjcmlwdGlvbnN9XG4gICAgICB0eXBlIHsgLi4uVHlwZVJlZiB9XG4gICAgICBkZWZhdWx0VmFsdWVcbiAgICAgICR7aW5wdXREZXByZWNhdGlvbignaXNEZXByZWNhdGVkJyl9XG4gICAgICAke2lucHV0RGVwcmVjYXRpb24oJ2RlcHJlY2F0aW9uUmVhc29uJyl9XG4gICAgfVxuXG4gICAgZnJhZ21lbnQgVHlwZVJlZiBvbiBfX1R5cGUge1xuICAgICAga2luZFxuICAgICAgbmFtZVxuICAgICAgb2ZUeXBlIHtcbiAgICAgICAga2luZFxuICAgICAgICBuYW1lXG4gICAgICAgIG9mVHlwZSB7XG4gICAgICAgICAga2luZFxuICAgICAgICAgIG5hbWVcbiAgICAgICAgICBvZlR5cGUge1xuICAgICAgICAgICAga2luZFxuICAgICAgICAgICAgbmFtZVxuICAgICAgICAgICAgb2ZUeXBlIHtcbiAgICAgICAgICAgICAga2luZFxuICAgICAgICAgICAgICBuYW1lXG4gICAgICAgICAgICAgIG9mVHlwZSB7XG4gICAgICAgICAgICAgICAga2luZFxuICAgICAgICAgICAgICAgIG5hbWVcbiAgICAgICAgICAgICAgICBvZlR5cGUge1xuICAgICAgICAgICAgICAgICAga2luZFxuICAgICAgICAgICAgICAgICAgbmFtZVxuICAgICAgICAgICAgICAgICAgb2ZUeXBlIHtcbiAgICAgICAgIC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UpIHx8IGlzSW50cm9zcGVjdGlvblR5cGUodHlwZSkpIHtcbiAgICAgIHJldHVybiB0eXBlO1xuICAgIH1cblxuICAgIGlmIChpc09iamVjdFR5cGUodHlwZSkpIHtcbiAgICAgIGNvbnN0IGNvbmZpZyA9IHR5cGUudG9Db25maWcoKTtcbiAgICAgIHJldHVybiBuZXcgR3JhcGhRTE9iamVjdFR5cGUoe1xuICAgICAgICAuLi5jb25maWcsXG4gICAgICAgIGludGVyZmFjZXM6ICgpID0+IHNvcnRUeXBlcyhjb25maWcuaW50ZXJmYWNlcyksXG4gICAgICAgIGZpZWxkczogKCkgPT4gc29ydEZpZWxkcyhjb25maWcuZmllbGRzKSxcbiAgICAgIH0pO1xuICAgIH1cblxuICAgIGlmIChpc0ludGVyZmFjZVR5cGUodHlwZSkpIHtcbiAgICAgIGNvbnN0IGNvbmZpZyA9IHR5cGUudG9Db25maWcoKTtcbiAgICAgIHJldHVybiBuZXcgR3JhcGhRTEludGVyZmFjZVR5cGUoe1xuICAgICAgICAuLi5jb25maWcsXG4gICAgICAgIGludGVyZmFjZXM6ICgpID0+IHNvcnRUeXBlcyhjb25maWcuaW50ZXJmYWNlcyksXG4gICAgICAgIGZpZWxkczogKCkgPT4gc29ydEZpZWxkcyhjb25maWcuZmllbGRzKSxcbiAgICAgIH0pO1xuICAgIH1cblxuICAgIGlmIChpc1VuaW9uVHlwZSh0eXBlKSkge1xuICAgICAgY29uc3QgY29uZmlnID0gdHlwZS50b0NvbmZpZygpO1xuICAgICAgcmV0dXJuIG5ldyBHcmFwaFFMVW5pb25UeXBlKHtcbiAgICAgICAgLi4uY29uZmlnLFxuICAgICAgICB0eXBlczogKCkgPT4gc29ydFR5cGVzKGNvbmZpZy50eXBlcyksXG4gICAgICB9KTtcbiAgICB9XG5cbiAgICBpZiAoaXNFbnVtVHlwZSh0eXBlKSkge1xuICAgICAgY29uc3QgY29uZmlnID0gdHlwZS50b0NvbmZpZygpO1xuICAgICAgcmV0dXJuIG5ldy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mludERlc2NyaXB0aW9uKHZhbHVlLCAnICAnLCAhaSkgK1xuICAgICAgICAnICAnICtcbiAgICAgICAgdmFsdWUubmFtZSArXG4gICAgICAgIHByaW50RGVwcmVjYXRlZCh2YWx1ZS5kZXByZWNhdGlvblJlYXNvbiksXG4gICAgKTtcbiAgcmV0dXJuIHByaW50RGVzY3JpcHRpb24odHlwZSkgKyBgZW51bSAke3R5cGUubmFtZX1gICsgcHJpbnRCbG9jayh2YWx1ZXMpO1xufVxuXG5mdW5jdGlvbiBwcmludElucHV0T2JqZWN0KHR5cGUpIHtcbiAgY29uc3QgZmllbGRzID0gT2JqZWN0LnZhbHVlcyh0eXBlLmdldEZpZWxkcygpKS5tYXAoXG4gICAgKGYsIGkpID0+IHByaW50RGVzY3JpcHRpb24oZiwgJyAgJywgIWkpICsgJyAgJyArIHByaW50SW5wdXRWYWx1ZShmKSxcbiAgKTtcbiAgcmV0dXJuIHByaW50RGVzY3JpcHRpb24odHlwZSkgKyBgaW5wdXQgJHt0eXBlLm5hbWV9YCArIHByaW50QmxvY2soZmllbGRzKTtcbn1cblxuZnVuY3Rpb24gcHJpbnRGaWVsZHModHlwZSkge1xuICBjb25zdCBmaWVsZHMgPSBPYmplY3QudmFsdWVzKHR5cGUuZ2V0RmllbGRzKCkpLm1hcChcbiAgICAoZiwgaSkgPT5cbiAgICAgIHByaW50RGVzY3JpcHRpb24oZiwgJyAgJywgIWkpICtcbiAgICAgICcgICcgK1xuICAgICAgZi5uYW1lICtcbiAgICAgIHByaW50QXJncyhmLmFyZ3MsICcgICcpICtcbiAgICAgICc6ICcgK1xuICAgICAgU3RyaW5nKGYudHlwZSkgK1xuICAgICAgcHJpbnREZXByZWNhdGVkKGYuZGVwcmVjYXRpb25SZWFzb24pLFxuICApO1xuICByZXR1cm4gcHJpbnRCbG9jayhmaWVsZHMpO1xufVxuXG5mdW5jdGlvbiBwcmludEJsb2NrKGl0ZW1zKSB7XG4gIHJldHVybiBpdGVtcy5sZW5ndGggIT09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yAgIC0gXCJDYXJyaWFnZSBSZXR1cm4gKFUrMDAwRClcIiBcIk5ldyBMaW5lIChVKzAwMEEpXCJcblxuICAgICAgY2FzZSAweDAwMGE6XG4gICAgICAgIC8vIFxcblxuICAgICAgICArK3Bvc2l0aW9uO1xuICAgICAgICArK2xleGVyLmxpbmU7XG4gICAgICAgIGxleGVyLmxpbmVTdGFydCA9IHBvc2l0aW9uO1xuICAgICAgICBjb250aW51ZTtcblxuICAgICAgY2FzZSAweDAwMGQ6XG4gICAgICAgIC8vIFxcclxuICAgICAgICBpZiAoYm9keS5jaGFyQ29kZUF0KHBvc2l0aW9uICsgMSkgPT09IDB4MDAwYSkge1xuICAgICAgICAgIHBvc2l0aW9uICs9IDI7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgKytwb3NpdGlvbjtcbiAgICAgICAgfVxuXG4gICAgICAgICsrbGV4ZXIubGluZTtcbiAgICAgICAgbGV4ZXIubGluZVN0YXJ0ID0gcG9zaXRpb247XG4gICAgICAgIGNvbnRpbnVlO1xuICAgICAgLy8gQ29tbWVudFxuXG4gICAgICBjYXNlIDB4MDAyMzpcbiAgICAgICAgLy8gI1xuICAgICAgICByZXR1cm4gcmVhZENvbW1lbnQobGV4ZXIsIHBvc2l0aW9uKTtcbiAgICAgIC8vIFRva2VuIDo6XG4gICAgICAvLyAgIC0gUHVuY3R1YXRvclxuICAgICAgLy8gICAtIE5hbWVcbiAgICAgIC8vICAgLSBJbnRWYWx1ZVxuICAgICAgLy8gICAtIEZsb2F0VmFsdWVcbiAgICAgIC8vICAgLSBTdHJpbmdWYWx1ZVxuICAgICAgLy9cbiAgICAgIC8vIFB1bmN0dWF0b3IgOjogb25lIG9mICEgJCAmICggKSAuLi4gOiA9IEAgWyBdIHsgfCB9XG5cbiAgICAgIGNhc2UgMHgwMDIxOlxuICAgICAgICAvLyAhXG4gICAgICAgIHJldHVybiBjcmVhdGVUb2tlbihsZXhlciwgVG9rZW5LaW5kLkJBTkcsIHBvc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pO1xuICAgICAgLy8gU3RyaW5nVmFsdWVcblxuICAgICAgY2FzZSAweDAwMjI6XG4gICAgICAgIC8vIFwiXG4gICAgICAgIGlmIChcbiAgICAgICAgICBib2R5LmNoYXJDb2RlQXQocG9zaXRpb24gKyAxKSA9PT0gMHgwMDIyICYmXG4gICAgICAgICAgYm9keS5jaGFyQ29kZUF0KHBvc2l0aW9uICsgMikgPT09IDB4MDAyMlxuICAgICAgICApIHtcbiAgICAgICAgICByZXR1cm4gcmVhZEJsb2NrU3RyaW5nKGxleGVyLCBwb3NpdGlvbik7XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gcmVhZFN0cmluZyhsZXhlciwgcG9zaXRpb24pO1xuICAgIH0gLy8gSW50VmFsdWUgfCBGbG9hdFZhbHVlIChEaWdpdCB8IC0pXG5cbiAgICBpZiAoaXNEaWdpdChjb2RlKSB8fCBjb2RlID09PSAweDAwMmQpIHtcbiAgICAgIHJldHVybiByZWFkTnVtYmVyKGxleGVyLCBwb3NpdGlvbiwgY29kZSk7XG4gICAgfSAvLyBOYW1lXG5cbiAgICBpZiAoaXNOYW1lU3RhcnQoY29kZSkpIHtcbiAgICAgIHJldHVybiByZWFkTmFtZShsZXhlciwgcG9zaXRpb24pO1xuICAgIH1cblxuICAgIHRocm93IHN5bnRheEVycm9yKFxuICAgICAgbGV4ZXIuc291cmNlLFxuICAgICAgcG9zaXRpb24sXG4gICAgICBjb2RlID09PSAweDAwMjdcbiAgICAgICAgPyAnVW5leHBlY3RlZCBzaW5nbGUgcXVvdGUgY2hhcmFjdGVyIChcXCcpLCBkaWQgeW91IG1lYW4gdG8gdXNlIGEgZG91YmxlIHF1b3RlIChcIik/J1xuICAgICAgICA6IGlzVW5pY29kZVNjYWxhclZhbHVlKGNvZGUpIHx8IGlzU3VwcGxlbWVudGFyeUNvZGVQb2ludChib2R5LCBwb3NpdGlvbilcbiAgICAgICAgPyBgVW5leHBlY3RlZCBjaGFyYWN0ZXI6ICR7cHJpbnRDb2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DAwNTdcbiAgICA6IC0xO1xufVxuLyoqXG4gKiB8IEVzY2FwZWQgQ2hhcmFjdGVyIHwgQ29kZSBQb2ludCB8IENoYXJhY3RlciBOYW1lICAgICAgICAgICAgICAgfFxuICogfCAtLS0tLS0tLS0tLS0tLS0tLSB8IC0tLS0tLS0tLS0gfCAtLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tLS0tIHxcbiAqIHwgYFwiYCAgICAgICAgICAgICAgIHwgVSswMDIyICAgICB8IGRvdWJsZSBxdW90ZSAgICAgICAgICAgICAgICAgfFxuICogfCBgXFxgICAgICAgICAgICAgICAgfCBVKzAwNUMgICAgIHwgcmV2ZXJzZSBzb2xpZHVzIChiYWNrIHNsYXNoKSB8XG4gKiB8IGAvYCAgICAgICAgICAgICAgIHwgVSswMDJGICAgICB8IHNvbGlkdXMgKGZvcndhcmQgc2xhc2gpICAgICAgfFxuICogfCBgYmAgICAgICAgICAgICAgICB8IFUrMDAwOCAgICAgfCBiYWNrc3BhY2UgICAgICAgICAgICAgICAgICAgIHxcbiAqIHwgYGZgICAgICAgICAgICAgICAgfCBVKzAwMEMgICAgIHwgZm9ybSBmZWVkICAgICAgICAgICAgICAgICAgICB8XG4gKiB8IGBuYCAgICAgICAgICAgICAgIHwgVSswMDBBICAgICB8IGxpbmUgZmVlZCAobmV3IGxpbmUpICAgICAgICAgfFxuICogfCBgcmAgICAgICAgICAgICAgICB8IFUrMDAwRCAgICAgfCBjYXJyaWFnZSByZXR1cm4gICAgICAgICAgICAgIHxcbiAqIHwgYHRgICAgICAgICAgICAgICAgfCBVKzAwMDkgICAgIHwgaG9yaXpvbnRhbCB0YWIgICAgICAgICAgICAgICB8XG4gKi9cblxuZnVuY3Rpb24gcmVhZEVzY2FwZWRDaGFyYWN0ZXIobGV4ZXIsIHBvc2l0aW9uKSB7XG4gIGNvbnN0IGJvZHkgPSBsZXhlci5zb3VyY2UuYm9keTtcbiAgY29uc3QgY29kZSA9IGJvZHkuY2hhckNvZGVBdChwb3NpdGlvbiArIDEpO1xuXG4gIHN3aXRjaCAoY29kZSkge1xuICAgIGNhc2UgMHgwMDIyOlxuICAgICAgLy8gXCJcbiAgICAgIHJldHVybiB7XG4gICAgICAgIHZhbHVlOiAnXFx1MDAyMicsXG4gICAgICAgIHNpemU6IDIsXG4gICAgICB9O1xuXG4gICAgY2FzZSAweDAwNWM6XG4gICAgICAvLyBcXFxuICAgICAgcmV0dXJuIHtcbiAgICAgICAgdmFsdWU6ICdcXHUwMDVjJyxcbiAgICAgICAgc2l6ZTogMixcbiAgICAgIH07XG5cbiAgICBjYXNlIDB4MDAyZjpcbiAgICAgIC8vIC9cbiAgICAgIHJldHVybiB7XG4gICAgICAgIHZhbHVlOiAnXFx1MDAyZicsXG4gICAgICAgIHNpemU6IDIsXG4gICAgICB9O1xuXG4gICAgY2FzZSAweDAwNjI6XG4gICAgICAvLyBiXG4gICAgICByZXR1cm4ge1xuICAgICAgICB2YWx1ZTogJ1xcdTAwMDgnLFxuICAgICAgICBzaXplOiAyLFxuICAgICAgfTtcblxuICAgIGNhc2UgMHgwMDY2OlxuICAgICAgLy8gZlxuICAgICAgcmV0dXJuIHtcbiAgICAgICAgdmFsdWU6ICdcXHUwMDBjJyxcbiAgICAgICAgc2l6ZTogMixcbiAgICAgIH07XG5cbiAgICBjYXNlIDB4MDA2ZTpcbiAgICAgIC8vIG5cbiAgICAgIHJldHVybiB7XG4gICAgICAgIHZhbHVlOiAnXFx1MDAwYScsXG4gICAgICAgIHNpemU6IDIsXG4gICAgICB9O1xuXG4gICAgY2FzZSAweDAwNzI6XG4gICAgICAvLyByXG4gICAgICByZXR1cm4ge1xuICAgICAgICB2YWx1ZTogJ1xcdTAwMGQnLFxuICAgICAgICBzaXplOiAyLFxuICAgICAgfTtcblxuICAgIGNhc2UgMHgwMDc0OlxuICAgICAgLy8gdFxuICAgICAgcmV0dXJuIHtcbiAgICAgICAgdmFsdWU6ICdcXHUwMDA5JyxcbiAgICAgICAgc2l6ZTogMixc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xuXG4gICAgaWYgKFxuICAgICAgY29kZSA9PT0gMHgwMDIyICYmXG4gICAgICBib2R5LmNoYXJDb2RlQXQocG9zaXRpb24gKyAxKSA9PT0gMHgwMDIyICYmXG4gICAgICBib2R5LmNoYXJDb2RlQXQocG9zaXRpb24gKyAyKSA9PT0gMHgwMDIyXG4gICAgKSB7XG4gICAgICBjdXJyZW50TGluZSArPSBib2R5LnNsaWNlKGNodW5rU3RhcnQsIHBvc2l0aW9uKTtcbiAgICAgIGJsb2NrTGluZXMucHVzaChjdXJyZW50TGluZSk7XG4gICAgICBjb25zdCB0b2tlbiA9IGNyZWF0ZVRva2VuKFxuICAgICAgICBsZXhlcixcbiAgICAgICAgVG9rZW5LaW5kLkJMT0NLX1NUUklORyxcbiAgICAgICAgc3RhcnQsXG4gICAgICAgIHBvc2l0aW9uICsgMywgLy8gUmV0dXJuIGEgc3RyaW5nIG9mIHRoZSBsaW5lcyBqb2luZWQgd2l0aCBVKzAwMEEuXG4gICAgICAgIGRlZGVudEJsb2NrU3RyaW5nTGluZXMoYmxvY2tMaW5lcykuam9pbignXFxuJyksXG4gICAgICApO1xuICAgICAgbGV4ZXIubGluZSArPSBibG9ja0xpbmVzLmxlbmd0aCAtIDE7XG4gICAgICBsZXhlci5saW5lU3RhcnQgPSBsaW5lU3RhcnQ7XG4gICAgICByZXR1cm4gdG9rZW47XG4gICAgfSAvLyBFc2NhcGVkIFRyaXBsZS1RdW90ZSAoXFxcIlwiXCIpXG5cbiAgICBpZiAoXG4gICAgICBjb2RlID09PSAweDAwNWMgJiZcbiAgICAgIGJvZHkuY2hhckNvZGVBdChwb3NpdGlvbiArIDEpID09PSAweDAwMjIgJiZcbiAgICAgIGJvZHkuY2hhckNvZGVBdChwb3NpdGlvbiArIDIpID09PSAweDAwMjIgJiZcbiAgICAgIGJvZHkuY2hhckNvZGVBdChwb3NpdGlvbiArIDMpID09PSAweDAwMjJcbiAgICApIHtcbiAgICAgIGN1cnJlbnRMaW5lICs9IGJvZH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ERlZmluaXRpb24rXG4gICAqL1xuXG4gIHBhcnNlRG9jdW1lbnQoKSB7XG4gICAgcmV0dXJuIHRoaXMubm9kZSh0aGlzLl9sZXhlci50b2tlbiwge1xuICAgICAga2luZDogS2luZC5ET0NVTUVOVCxcbiAgICAgIGRlZmluaXRpb25zOiB0aGlzLm1hbnkoXG4gICAgICAgIFRva2VuS2luZC5TT0YsXG4gICAgICAgIHRoaXMucGFyc2VEZWZpbml0aW9uLFxuICAgICAgICBUb2tlbktpbmQuRU9GLFxuICAgICAgKSxcbiAgICB9KTtcbiAgfVxuICAvKipcbiAgICogRGVmaW5pdGlvbiA6XG4gICAqICAgLSBFeGVjdXRhYmxlRGVmaW5pdGlvblxuICAgKiAgIC0gVHlwZVN5c3RlbURlZmluaXRpb25cbiAgICogICAtIFR5cGVTeXN0ZW1FeHRlbnNpb25cbiAgICpcbiAgICogRXhlY3V0YWJsZURlZmluaXRpb24gOlxuICAgKiAgIC0gT3BlcmF0aW9uRGVmaW5pdGlvblxuICAgKiAgIC0gRnJhZ21lbnREZWZpbml0aW9uXG4gICAqXG4gICAqIFR5cGVTeXN0ZW1EZWZpbml0aW9uIDpcbiAgICogICAtIFNjaGVtYURlZmluaXRpb25cbiAgICogICAtIFR5cGVEZWZpbml0aW9uXG4gICAqICAgLSBEaXJlY3RpdmVEZWZpbml0aW9uXG4gICAqXG4gICAqIFR5cGVEZWZpbml0aW9uIDpcbiAgICogICAtIFNjYWxhclR5cGVEZWZpbml0aW9uXG4gICAqICAgLSBPYmplY3RUeXBlRGVmaW5pdGlvblxuICAgKiAgIC0gSW50ZXJmYWNlVHlwZURlZmluaXRpb25cbiAgICogICAtIFVuaW9uVHlwZURlZmluaXRpb25cbiAgICogICAtIEVudW1UeXBlRGVmaW5pdGlvblxuICAgKiAgIC0gSW5wdXRPYmplY3RUeXBlRGVmaW5pdGlvblxuICAgKi9cblxuICBwYXJzZURlZmluaXRpb24oKSB7XG4gICAgaWYgKHRoaXMucGVlayhUb2tlb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ZhbmNlTGV4ZXIoKTtcbiAgICAgICAgcmV0dXJuIHRoaXMubm9kZSh0b2tlbiwge1xuICAgICAgICAgIGtpbmQ6IEtpbmQuSU5ULFxuICAgICAgICAgIHZhbHVlOiB0b2tlbi52YWx1ZSxcbiAgICAgICAgfSk7XG5cbiAgICAgIGNhc2UgVG9rZW5LaW5kLkZMT0FUOlxuICAgICAgICB0aGlzLmFkdmFuY2VMZXhlcigpO1xuICAgICAgICByZXR1cm4gdGhpcy5ub2RlKHRva2VuLCB7XG4gICAgICAgICAga2luZDogS2luZC5GTE9BVCxcbiAgICAgICAgICB2YWx1ZTogdG9rZW4udmFsdWUsXG4gICAgICAgIH0pO1xuXG4gICAgICBjYXNlIFRva2VuS2luZC5TVFJJTkc6XG4gICAgICBjYXNlIFRva2VuS2luZC5CTE9DS19TVFJJTkc6XG4gICAgICAgIHJldHVybiB0aGlzLnBhcnNlU3RyaW5nTGl0ZXJhbCgpO1xuXG4gICAgICBjYXNlIFRva2VuS2luZC5OQU1FOlxuICAgICAgICB0aGlzLmFkdmFuY2VMZXhlcigpO1xuXG4gICAgICAgIHN3aXRjaCAodG9rZW4udmFsdWUpIHtcbiAgICAgICAgICBjYXNlICd0cnVlJzpcbiAgICAgICAgICAgIHJldHVybiB0aGlzLm5vZGUodG9rZW4sIHtcbiAgICAgICAgICAgICAga2luZDogS2luZC5CT09MRUFOLFxuICAgICAgICAgICAgICB2YWx1ZTogdHJ1ZSxcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgY2FzZSAnZmFsc2UnOlxuICAgICAgICAgICAgcmV0dXJuIHRoaXMubm9kZSh0b2tlbiwge1xuICAgICAgICAgICAgICBraW5kOiBLaW5kLkJPT0xFQU4sXG4gICAgICAgICAgICAgIHZhbHVlOiBmYWxzZSxcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgY2FzZSAnbnVsbCc6XG4gICAgICAgICAgICByZXR1cm4gdGhpcy5ub2RlKHRva2VuLCB7XG4gICAgICAgICAgICAgIGtpbmQ6IEtpbmQuTlVMTCxcbiAgICAgICAgICAgIH0pO1xuXG4gICAgICAgICAgZGVmYXVsdDpcbiAgICAgICAgICAgIHJldHVybiB0aGlzLm5vZGUodG9rZW4sIHtcbiAgICAgICAgICAgICAga2luZDogS2luZC5FTlVNLFxuICAgICAgICAgICAgICB2YWx1ZTogdG9rZW4udmFsdWUsXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxuXG4gICAgICBjYXNlIFRva2VuS2luZC5ET0xMQVI6XG4gICAgICAgIGlmIChpc0NvbnN0KSB7XG4gICAgICAgICAgdGhpcy5leHBlY3RUb2tlbihUb2tlbktpbmQuRE9MTEFSKTtcblxuICAgICAgICAgIGlmICh0aGlzLl9sZXhlci50b2tlbi5raW5kID09PSBUb2tlbktpbmQuTkFNRSkge1xuICAgICAgICAgICAgY29uc3QgdmFyTmFtZSA9IHRoaXMuX2xleGVyLnRva2VuLnZhbHVlO1xuICAgICAgICAgICAgdGhyb3cgc3ludGF4RXJyb3IoXG4gICAgICAgICAgICAgIHRoaXMuX2xleGVyLnNvdXJjZSxcbiAgICAgICAgICAgICAgdG9rZW4uc3RhcnQsXG4gICAgICAgICAgICAgIGBVbmV4cGVjdGVkIHZhcmlhYmxlIFwiJCR7dmFyTmFtZX1cIiBpbiBjb25zdGFudCB2YWx1ZS5gLFxuICAgICAgICAgICAgKTtcbiAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgdGhyb3cgdGhpcy51bmV4cGVjdGVkKHRva2VuKTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cblxuICAgICAgICByZXR1cm4gdGhpcy5wYXJzZVZhcmlhYmxlKCk7XG5cbiAgICAgIGRlZmF1bHQ6XG4gICAgICAgIHRocm93IHRoaXMudW5leHBlY3RlZCgpO1xuICAgIH1cbiAgfVxuXG4gIHBhcnNlQ29uc3RWYWx1ZUxpdGVyYWwoKSB7XG4gICAgcmV0dXJuIHRoaXMucGFyc2VWYWx1ZUx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1xuICAgICAgICAgICAgICBub2RlLnNwbGljZShhcnJheUtleSwgMSk7XG4gICAgICAgICAgICAgIGVkaXRPZmZzZXQrKztcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgIG5vZGVbYXJyYXlLZXldID0gZWRpdFZhbHVlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICBub2RlID0gT2JqZWN0LmRlZmluZVByb3BlcnRpZXMoXG4gICAgICAgICAgICB7fSxcbiAgICAgICAgICAgIE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3JzKG5vZGUpLFxuICAgICAgICAgICk7XG5cbiAgICAgICAgICBmb3IgKGNvbnN0IFtlZGl0S2V5LCBlZGl0VmFsdWVdIG9mIGVkaXRzKSB7XG4gICAgICAgICAgICBub2RlW2VkaXRLZXldID0gZWRpdFZhbHVlO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuXG4gICAgICBpbmRleCA9IHN0YWNrLmluZGV4O1xuICAgICAga2V5cyA9IHN0YWNrLmtleXM7XG4gICAgICBlZGl0cyA9IHN0YWNrLmVkaXRzO1xuICAgICAgaW5BcnJheSA9IHN0YWNrLmluQXJyYXk7XG4gICAgICBzdGFjayA9IHN0YWNrLnByZXY7XG4gICAgfSBlbHNlIGlmIChwYXJlbnQpIHtcbiAgICAgIGtleSA9IGluQXJyYXkgPyBpbmRleCA6IGtleXNbaW5kZXhdO1xuICAgICAgbm9kZSA9IHBhcmVudFtrZXldO1xuXG4gICAgICBpZiAobm9kZSA9PT0gbnVsbCB8fCBub2RlID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgY29udGludWU7XG4gICAgICB9XG5cbiAgICAgIHBhdGgucHVzaChrZXkpO1xuICAgIH1cblxuICAgIGxldCByZXN1bHQ7XG5cbiAgICBpZiAoIUFycmF5LmlzQXJyYXkobm9kZSkpIHtcbiAgICAgIHZhciBfZW50ZX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ICB9IGVsc2UgaWYgKHJlc3VsdCAhPT0gdW5kZWZpbmVkKSB7XG4gICAgICAgIGVkaXRzLnB1c2goW2tleSwgcmVzdWx0XSk7XG5cbiAgICAgICAgaWYgKCFpc0xlYXZpbmcpIHtcbiAgICAgICAgICBpZiAoaXNOb2RlKHJlc3VsdCkpIHtcbiAgICAgICAgICAgIG5vZGUgPSByZXN1bHQ7XG4gICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHBhdGgucG9wKCk7XG4gICAgICAgICAgICBjb250aW51ZTtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICB9XG5cbiAgICBpZiAocmVzdWx0ID09PSB1bmRlZmluZWQgJiYgaXNFZGl0ZWQpIHtcbiAgICAgIGVkaXRzLnB1c2goW2tleSwgbm9kZV0pO1xuICAgIH1cblxuICAgIGlmIChpc0xlYXZpbmcpIHtcbiAgICAgIHBhdGgucG9wKCk7XG4gICAgfSBlbHNlIHtcbiAgICAgIHZhciBfbm9kZSRraW5kO1xuXG4gICAgICBzdGFjayA9IHtcbiAgICAgICAgaW5BcnJheSxcbiAgICAgICAgaW5kZXgsXG4gICAgICAgIGtleXMsXG4gICAgICAgIGVkaXRzLFxuICAgICAgICBwcmV2OiBzdGFjayxcbiAgICAgIH07XG4gICAgICBpbkFycmF5ID0gQXJyYXkuaXNBcnJheShub2RlKTtcbiAgICAgIGtleXMgPSBpbkFycmF5XG4gICAgICAgID8gbm9kZVxuICAgICAgICA6IChfbm9kZSRraW5kID0gdmlzaXRvcktleXNbbm9kZS5raW5kXSkgIT09IG51bGwgJiZcbiAgICAgICAgICBfbm9kZSRraW5kICE9PSB2b2lkIDBcbiAgICAgICAgPyBfbm9kZSRraW5kXG4gICAgICAgIDogW107XG4gICAgICBpbmRleCA9IC0xO1xuICAgICAgZWRpdHMgPSBbXTtcblxuICAgICAgaWYgKHBhcmVudCkge1xuICAgICAgICBhbmNlc3RvcnMucHVzaChwYXJlbnQpO1xuICAg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0IGkgPSAwOyBpIDwgdmlzaXRvcnMubGVuZ3RoOyArK2kpIHtcbiAgICAgIGNvbnN0IHsgZW50ZXIsIGxlYXZlIH0gPSBnZXRFbnRlckxlYXZlRm9yS2luZCh2aXNpdG9yc1tpXSwga2luZCk7XG4gICAgICBoYXNWaXNpdG9yIHx8IChoYXNWaXNpdG9yID0gZW50ZXIgIT0gbnVsbCB8fCBsZWF2ZSAhPSBudWxsKTtcbiAgICAgIGVudGVyTGlzdFtpXSA9IGVudGVyO1xuICAgICAgbGVhdmVMaXN0W2ldID0gbGVhdmU7XG4gICAgfVxuXG4gICAgaWYgKCFoYXNWaXNpdG9yKSB7XG4gICAgICBjb250aW51ZTtcbiAgICB9XG5cbiAgICBjb25zdCBtZXJnZWRFbnRlckxlYXZlID0ge1xuICAgICAgZW50ZXIoLi4uYXJncykge1xuICAgICAgICBjb25zdCBub2RlID0gYXJnc1swXTtcblxuICAgICAgICBmb3IgKGxldCBpID0gMDsgaSA8IHZpc2l0b3JzLmxlbmd0aDsgaSsrKSB7XG4gICAgICAgICAgaWYgKHNraXBwaW5nW2ldID09PSBudWxsKSB7XG4gICAgICAgICAgICB2YXIgX2VudGVyTGlzdCRpO1xuXG4gICAgICAgICAgICBjb25zdCByZXN1bHQgPVxuICAgICAgICAgICAgICAoX2VudGVyTGlzdCRpID0gZW50ZXJMaXN0W2ldKSA9PT0gbnVsbCB8fCBfZW50ZXJMaXN0JGkgPT09IHZvaWQgMFxuICAgICAgICAgICAgICAgID8gdm9pZCAwXG4gICAgICAgICAgICAgICAgOiBfZW50ZXJMaXN0JGkuYXBwbHkodmlzaXRvcnNbaV0sIGFyZ3MpO1xuXG4gICAgICAgICAgICBpZiAocmVzdWx0ID09PSBmYWxzZSkge1xuICAgICAgICAgICAgICBza2lwcGluZ1tpXSA9IG5vZGU7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHJlc3VsdCA9PT0gQlJFQUspIHtcbiAgICAgICAgICAgICAgc2tpcHBpbmdbaV0gPSBCUkVBSztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAocmVzdWx0ICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0sXG5cbiAgICAgIGxlYXZlKC4uLmFyZ3MpIHtcbiAgICAgICAgY29uc3Qgbm9kZSA9IGFyZ3NbMF07XG5cbiAgICAgICAgZm9yIChsZXQgaSA9IDA7IGkgPCB2aXNpdG9ycy5sZW5ndGg7IGkrKykge1xuICAgICAgICAgIGlmIChza2lwcGluZ1tpXSA9PT0gbnVsbCkge1xuICAgICAgICAgICAgdmFyIF9sZWF2ZUxpc3QkaTtcblxuICAgICAgICAgICAgY29uc3QgcmVzdWx0ID1cbiAgICAgICAgICAgICAgKF9sZWF2ZUxpc3QkaSA9IGxlYXZlTGlzdFtpXSkgPT09IG51bGwgfHwgX2xlYXZlTGlzdCRpID09PSB2b2lkIDBcbiAgICAgICAgICAgICAgICA/IHZvaWQgMFxuICAgICAgICAgICAgICAgIDogX2xlYXZlTGlzdCRpLmFwcGx5KHZpc2l0b3JzW2ldLCBhcmdzKTtcblxuICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gQlJFQUspIHtcbiAgICAgICAgICAgICAgc2tpcHBpbmdbaV0gPSBCUkVBSztcbiAgICAgICAgICAgIH0gZWxzZSBpZiAocmVzdWx0ICE9PSB1bmRlZmluZWQgJiYgcmVzdWx0ICE9PSBmYWxzZSkge1xuICAgICAgICAgICAgICByZXR1cm4gcmVzdWx0O1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH0gZWxzZSBpZiAoc2tpcHBpbmdbaV0gPT09IG5vZGUpIHtcbiAgICAgICAgICAgIHNraXBwaW5nW2ldID0gbnVsbDtcbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH0sXG4gICAgfTtcbiAgICBtZXJnZWRWaXNpdG9yW2tpbm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ICAgICByZXNvbHZlKHR5cGUpIHtcbiAgICAgICAgaWYgKGlzU2NhbGFyVHlwZSh0eXBlKSkge1xuICAgICAgICAgIHJldHVybiBUeXBlS2luZC5TQ0FMQVI7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoaXNPYmplY3RUeXBlKHR5cGUpKSB7XG4gICAgICAgICAgcmV0dXJuIFR5cGVLaW5kLk9CSkVDVDtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChpc0ludGVyZmFjZVR5cGUodHlwZSkpIHtcbiAgICAgICAgICByZXR1cm4gVHlwZUtpbmQuSU5URVJGQUNFO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGlzVW5pb25UeXBlKHR5cGUpKSB7XG4gICAgICAgICAgcmV0dXJuIFR5cGVLaW5kLlVOSU9OO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGlzRW51bVR5cGUodHlwZSkpIHtcbiAgICAgICAgICByZXR1cm4gVHlwZUtpbmQuRU5VTTtcbiAgICAgICAgfVxuXG4gICAgICAgIGlmIChpc0lucHV0T2JqZWN0VHlwZSh0eXBlKSkge1xuICAgICAgICAgIHJldHVybiBUeXBlS2luZC5JTlBVVF9PQkpFQ1Q7XG4gICAgICAgIH1cblxuICAgICAgICBpZiAoaXNMaXN0VHlwZSh0eXBlKSkge1xuICAgICAgICAgIHJldHVybiBUeXBlS2luZC5MSVNUO1xuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGlzTm9uTnVsbFR5cGUodHlwZSkpIHtcbiAgICAgICAgICByZXR1cm4gVHlwZUtpbmQuTk9OX05VTEw7XG4gICAgICAgIH1cbiAgICAgICAgLyogYzggaWdub3JlIG5leHQgMyAqL1xuICAgICAgICAvLyBOb3QgcmVhY2hhYmxlLCBhbGwgcG9zc2libGUgdHlwZXMgaGF2ZSBiZWVuIGNvbnNpZGVyZWQpXG5cbiAgICAgICAgZmFsc2UgfHwgaW52YXJpYW50KGZhbHNlLCBgVW5leHBlY3RlZCB0eXBlO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Ckge1xuICAgICAgICB0aHJvdyBuZXcgRXJyb3IoXG4gICAgICAgICAgYFNjaGVtYSBtdXN0IGNvbnRhaW4gdW5pcXVlbHkgbmFtZWQgdHlwZXMgYnV0IGNvbnRhaW5zIG11bHRpcGxlIHR5cGVzIG5hbWVkIFwiJHt0eXBlTmFtZX1cIi5gLFxuICAgICAgICApO1xuICAgICAgfVxuXG4gICAgICB0aGlzLl90eXBlTWFwW3R5cGVOYW1lXSA9IG5hbWVkVHlwZTtcblxuICAgICAgaWYgKGlzSW50ZXJmYWNlVHlwZShuYW1lZFR5cGUpKSB7XG4gICAgICAgIC8vIFN0b3JlIGltcGxlbWVudGF0aW9ucyBieSBpbnRlcmZhY2UuXG4gICAgICAgIGZvciAoY29uc3QgaWZhY2Ugb2YgbmFtZWRUeXBlLmdldEludGVyZmFjZXMoKSkge1xuICAgICAgICAgIGlmIChpc0ludGVyZmFjZVR5cGUoaWZhY2UpKSB7XG4gICAgICAgICAgICBsZXQgaW1wbGVtZW50YXRpb25zID0gdGhpcy5faW1wbGVtZW50YXRpb25zTWFwW2lmYWNlLm5hbWVdO1xuXG4gICAgICAgICAgICBpZiAoaW1wbGVtZW50YXRpb25zID09PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgICAgaW1wbGVtZW50YXRpb25zID0gdGhpcy5faW1wbGVtZW50YXRpb25zTWFwW2lmYWNlLm5hbWVdID0ge1xuICAgICAgICAgICAgICAgIG9iamVjdHM6IFtdLFxuICAgICAgICAgICAgICAgIGludGVyZmFjZXM6IFtdLFxuICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICBpbXBsZW1lbnRhdGlvbnMuaW50ZXJmYWNlcy5wdXNoKG5hbWVkVHlwZSk7XG4gICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICB9IGVsc2UgaWYgKGlzT2JqZWN0VHlwZShuYW1lZFR5cGUpKSB7XG4gICAgICAgIC8vIFN0b3JlIGltcGxlbWVudGF0aW9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4gICAgICAgIH0pO1xuICAgICAgfVxuXG4gICAgICBjYXNlIEtpbmQuU0NBTEFSX1RZUEVfREVGSU5JVElPTjoge1xuICAgICAgICB2YXIgX2FzdE5vZGUkZGVzY3JpcHRpb241O1xuXG4gICAgICAgIHJldHVybiBuZXcgR3JhcGhRTFNjYWxhclR5cGUoe1xuICAgICAgICAgIG5hbWUsXG4gICAgICAgICAgZGVzY3JpcHRpb246XG4gICAgICAgICAgICAoX2FzdE5vZGUkZGVzY3JpcHRpb241ID0gYXN0Tm9kZS5kZXNjcmlwdGlvbikgPT09IG51bGwgfHxcbiAgICAgICAgICAgIF9hc3ROb2RlJGRlc2NyaXB0aW9uNSA9PT0gdm9pZCAwXG4gICAgICAgICAgICAgID8gdm9pZCAwXG4gICAgICAgICAgICAgIDogX2FzdE5vZGUkZGVzY3JpcHRpb241LnZhbHVlLFxuICAgICAgICAgIHNwZWNpZmllZEJ5VVJMOiBnZXRTcGVjaWZpZWRCeVVSTChhc3ROb2RlKSxcbiAgICAgICAgICBhc3ROb2RlLFxuICAgICAgICAgIGV4dGVuc2lvbkFTVE5vZGVzLFxuICAgICAgICB9KTtcbiAgICAgIH1cblxuICAgICAgY2FzZSBLaW5kLklOUFVUX09CSkVDVF9UWVBFX0RFRklOSVRJT046IHtcbiAgICAgICAgdmFyIF9hc3ROb2RlJGRlc2NyaXB0aW9uNjtcblxuICAgICAgICBjb25zdCBhbGxOb2RlcyA9IFthc3ROb2RlLCAuLi5leHRlbnNpb25BU1ROb2Rlc107XG4gICAgICAgIHJldHVybiBuZXcgR3JhcGhRTElucHV0T2JqZWN0VHlwZSh7XG4gICAgICAgICAgbmFtZSxcbiAgICAgICAgICBkZXNjcmlwdGlvbjpcbiAgICAgICAgICAgIChfYXN0Tm9kZSRkZXNjcmlwdGlvbjYgPSBhc3ROb2RlLmRlc2NyaXB0aW9uKSA9PT0gbnVsbCB8fFxuICAgICAgICAgICAgX2FzdE5vZGUkZGVzY3JpcHRpb242ID09PSB2b2l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UgaHR0cHM6Ly9zcGVjLmdyYXBocWwub3JnL2RyYWZ0LyNzZWMtRnJhZ21lbnRzLU9uLUNvbXBvc2l0ZS1UeXBlc1xuICovXG5leHBvcnQgZnVuY3Rpb24gRnJhZ21lbnRzT25Db21wb3NpdGVUeXBlc1J1bGUoY29udGV4dCkge1xuICByZXR1cm4ge1xuICAgIElubGluZUZyYWdtZW50KG5vZGUpIHtcbiAgICAgIGNvbnN0IHR5cGVDb25kaXRpb24gPSBub2RlLnR5cGVDb25kaXRpb247XG5cbiAgICAgIGlmICh0eXBlQ29uZGl0aW9uKSB7XG4gICAgICAgIGNvbnN0IHR5cGUgPSB0eXBlRnJvbUFTVChjb250ZXh0LmdldFNjaGVtYSgpLCB0eXBlQ29uZGl0aW9uKTtcblxuICAgICAgICBpZiAodHlwZSAmJiAhaXNDb21wb3NpdGVUeXBlKHR5cGUpKSB7XG4gICAgICAgICAgY29uc3QgdHlwZVN0ciA9IHByaW50KHR5cGVDb25kaXRpb24pO1xuICAgICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgICBuZXcgR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICBgRnJhZ21lbnQgY2Fubm90IGNvbmRpdGlvbiBvbiBub24gY29tcG9zaXRlIHR5cGUgXCIke3R5cGVTdHJ9XCIuYCxcbiAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIG5vZGVzOiB0eXBlQ29uZGl0aW9uLFxuICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgKSxcbiAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcblxuICAgIEZyYWdtZW50RGVmaW5pdGlvbihub2RlKSB7XG4gICAgICBjb25zdCB0eXBlID0gdHlwZUZyb21BU1QoY29udGV4dC5nZXRTY2hlbWEoKSwgbm9kZS50eXBlQ29uZGl0aW9uKTtcblxuICAgICAgaWYgKHR5cGUgJiYgIWlzQ29tcG9zaXRlVHlwZSh0eXBlKSkge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G5hbWUuIEZvciBhbnkgcmVzcG9uc2UgbmFtZSB3aGljaCBhcHBlYXJzIGluIGJvdGggcHJvdmlkZWQgZmllbGRcbiAgLy8gbWFwcywgZWFjaCBmaWVsZCBmcm9tIHRoZSBmaXJzdCBmaWVsZCBtYXAgbXVzdCBiZSBjb21wYXJlZCB0byBldmVyeSBmaWVsZFxuICAvLyBpbiB0aGUgc2Vjb25kIGZpZWxkIG1hcCB0byBmaW5kIHBvdGVudGlhbCBjb25mbGljdHMuXG4gIGZvciAoY29uc3QgW3Jlc3BvbnNlTmFtZSwgZmllbGRzMV0gb2YgT2JqZWN0LmVudHJpZXMoZmllbGRNYXAxKSkge1xuICAgIGNvbnN0IGZpZWxkczIgPSBmaWVsZE1hcDJbcmVzcG9uc2VOYW1lXTtcblxuICAgIGlmIChmaWVsZHMyKSB7XG4gICAgICBmb3IgKGNvbnN0IGZpZWxkMSBvZiBmaWVsZHMxKSB7XG4gICAgICAgIGZvciAoY29uc3QgZmllbGQyIG9mIGZpZWxkczIpIHtcbiAgICAgICAgICBjb25zdCBjb25mbGljdCA9IGZpbmRDb25mbGljdChcbiAgICAgICAgICAgIGNvbnRleHQsXG4gICAgICAgICAgICBjYWNoZWRGaWVsZHNBbmRGcmFnbWVudE5hbWVzLFxuICAgICAgICAgICAgY29tcGFyZWRGcmFnbWVudFBhaXJzLFxuICAgICAgICAgICAgcGFyZW50RmllbGRzQXJlTXV0dWFsbHlFeGNsdXNpdmUsXG4gICAgICAgICAgICByZXNwb25zZU5hbWUsXG4gICAgICAgICAgICBmaWVsZDEsXG4gICAgICAgICAgICBmaWVsZDIsXG4gICAgICAgICAgKTtcblxuICAgICAgICAgIGlmIChjb25mbGljdCkge1xuICAgICAgICAgICAgY29uZmxpY3RzLnB1c2goY29uZmxpY3QpO1xuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfVxuICAgIH1cbiAgfVxufSAvLyBEZXRlcm1pbmVzIGlmIHRoZXJlIGlzIGEgY29uZmxpY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XG4gICAgICAgICAgY29uc3QgYXJnTm9kZU1hcCA9IG5ldyBTZXQoYXJnTm9kZXMubWFwKChhcmcpID0+IGFyZy5uYW1lLnZhbHVlKSk7XG5cbiAgICAgICAgICBmb3IgKGNvbnN0IFthcmdOYW1lLCBhcmdEZWZdIG9mIE9iamVjdC5lbnRyaWVzKHJlcXVpcmVkQXJncykpIHtcbiAgICAgICAgICAgIGlmICghYXJnTm9kZU1hcC5oYXMoYXJnTmFtZSkpIHtcbiAgICAgICAgICAgICAgY29uc3QgYXJnVHlwZSA9IGlzVHlwZShhcmdEZWYudHlwZSlcbiAgICAgICAgICAgICAgICA/IGluc3BlY3QoYXJnRGVmLnR5cGUpXG4gICAgICAgICAgICAgICAgOiBwcmludChhcmdEZWYudHlwZSk7XG4gICAgICAgICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgICAgICAgbmV3IEdyYXBoUUxFcnJvcihcbiAgICAgICAgICAgICAgICAgIGBEaXJlY3RpdmUgXCJAJHtkaXJlY3RpdmVOYW1lfVwiIGFyZ3VtZW50IFwiJHthcmdOYW1lfVwiIG9mIHR5cGUgXCIke2FyZ1R5cGV9XCIgaXMgcmVxdWlyZWQsIGJ1dCBpdCB3YXMgbm90IHByb3ZpZGVkLmAsXG4gICAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICAgIG5vZGVzOiBkaXJlY3RpdmVOb2RlLFxuICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICApLFxuICAgICAgICAgICAgICApO1xuICAgICAgICAgICAgfVxuICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgfSxcbiAgICB9LFxuICB9O1xufVxuXG5mdW5jdGlvbiBpc1JlcXVpcmVkQXJndW1lbnROb2RlKGFyZykge1xuICByZXR1cm4gYXJnLnR5cGUua2luZCA9PT0gS2luZC5OT05fTlVMTF9UWVBFICYmIGFyZy5kZWZhdWx0VmFsdWUgPT0gbnVsbDtcbn1cbi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GVjdGlvbiBzaW5jZSB0eXBlIFwiJHt0eXBlU3RyfVwiIGhhcyBubyBzdWJmaWVsZHMuYCxcbiAgICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgICBub2Rlczogc2VsZWN0aW9uU2V0LFxuICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICksXG4gICAgICAgICAgICApO1xuICAgICAgICAgIH1cbiAgICAgICAgfSBlbHNlIGlmICghc2VsZWN0aW9uU2V0KSB7XG4gICAgICAgICAgY29uc3QgZmllbGROYW1lID0gbm9kZS5uYW1lLnZhbHVlO1xuICAgICAgICAgIGNvbnN0IHR5cGVTdHIgPSBpbnNwZWN0KHR5cGUpO1xuICAgICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgICBuZXcgR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICBgRmllbGQgXCIke2ZpZWxkTmFtZX1cIiBvZiB0eXBlIFwiJHt0eXBlU3RyfVwiIG11c3QgaGF2ZSBhIHNlbGVjdGlvbiBvZiBzdWJmaWVsZHMuIERpZCB5b3UgbWVhbiBcIiR7ZmllbGROYW1lfSB7IC4uLiB9XCI/YCxcbiAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgIG5vZGVzOiBub2RlLFxuICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgKSxcbiAgICAgICAgICApO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgfSxcbiAgfTtcbn1cbiIsImltcG9ydCB7IEdyYXBoUUxFcnJvciB9IGZyb20gJy4uLy4uL2Vycm9yL0dyYXBoUUxFcnJvci5tanMnO1xuaW1wb3J0IHsgS2luZCB9IGZyb20gJy4uLy4uL2xhbmd1YWdlL2tpbmRzLm1qcyc7XG5pbXBvcnQgeyBjb2xsZWN0RmllbGRzIH0gZnJvbSAnLi4vLi4vZXhlY3V0aW9uL2NvbGxlY3RGaWVsZHMubWpzJztcblxuLyoqXG4gKiBTdWJzY3JpcHRpb25zIG11c3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aW9ucykge1xuICAgICAgICAgICAgaWYgKGRlZmluaXRpb24ua2luZCA9PT0gS2luZC5GUkFHTUVOVF9ERUZJTklUSU9OKSB7XG4gICAgICAgICAgICAgIGZyYWdtZW50c1tkZWZpbml0aW9uLm5hbWUudmFsdWVdID0gZGVmaW5pdGlvbjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG5cbiAgICAgICAgICBjb25zdCBmaWVsZHMgPSBjb2xsZWN0RmllbGRzKFxuICAgICAgICAgICAgc2NoZW1hLFxuICAgICAgICAgICAgZnJhZ21lbnRzLFxuICAgICAgICAgICAgdmFyaWFibGVWYWx1ZXMsXG4gICAgICAgICAgICBzdWJzY3JpcHRpb25UeXBlLFxuICAgICAgICAgICAgbm9kZS5zZWxlY3Rpb25TZXQsXG4gICAgICAgICAgKTtcblxuICAgICAgICAgIGlmIChmaWVsZHMuc2l6ZSA+IDEpIHtcbiAgICAgICAgICAgIGNvbnN0IGZpZWxkU2VsZWN0aW9uTGlzdHMgPSBbLi4uZmllbGRzLnZhbHVlcygpXTtcbiAgICAgICAgICAgIGNvbnN0IGV4dHJhRmllbGRTZWxlY3Rpb25MaXN0cyA9IGZpZWxkU2VsZWN0aW9uTGlzdHMuc2xpY2UoMSk7XG4gICAgICAgICAgICBjb25zdCBleHRyYUZpZWxkU2VsZWN0aW9ucyA9IGV4dHJhRmllbGRTZWxlY3Rpb25MaXN0cy5mbGF0KCk7XG4gICAgICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgICAgICBuZXcgR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICAgIG9wZXJhdGlvbk5hbWUgIT0gbnVsbFxuICAgICAgICAgICAgICAgICAgPyBgU3Vic2NyaXB0aW9uIFwiJHtvcGVyYXRpb25OYW1lfVwiIG11c3Qgc2VsZWN0IG9ubHkgb25lIHRvcCBsZXZlbCBmaWVsZC5gXG4gICAgICAgICAgICAgICAgICA6ICdBbm9ueW1vdXMgU3Vic2NyaXB0aW9uIG11c3Qgc2VsZWN0IG9ubHkgb25lIHRvcCBsZXZlbCBmaWVsZC4nLFxuICAgICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICAgIG5vZGVzOiBleHRyYUZpZWxkU2VsZWN0aW9ucyxcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICApLFxuICAgICAgICAgICAgKTtcbiAgICAgICAgICB9XG5cbiAgICAgICAgICBmb3IgKGNvbnN0IGZpZWxkTm9kZXMgb2YgZmllbGRzLnZhbHVlcygpKSB7XG4gICAgICAgICAgICBjb25zdCBmaWVsZCA9IGZpZWxkTm9kZXNbMF07XG4gICAgICAgICAgICBjb25zdCBmaWVsZE5hbWUgPSBmaWVsZC5uYW1lLnZhbHVlO1xuXG4gICAgICAgICAgICBpZiAoZmllbGROYW1lLnN0YXJ0c1dpdGgoJ19fJykpIHtcbiAgICAgICAgICAgICAgY29udGV4dC5yZXBvcnRFcnJvcihcbiAgICAgICAgICAgICAgICBuZXcgR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICAgICAgb3BlcmF0aW9uTmFtZSAhPSBudWxsXG4gICAgICAgICAgICAgICAgICAgID8gYFN1YnNjcmlwdGlvbiBcIiR7b3BlcmF0aW9uTmFtZX1cIiBtdXN0IG5vdCBzZWxlY3QgYW4gaW50cm9zcGVjdGlvbiB0b3AgbGV2ZWwgZmllbGQuYFxuICAgICAgICAgICAgICAgICAgICA6ICdBbm9ueW1vdXMgU3Vic2NyaXB0aW9uIG11c3Qgbm90IHNlbGVjdCBhbiBpbnRyb3NwZWN0aW9uIHRvcCBsZXZlbCBmaWVsZC4nLFxuICAgICAgICAgICAgICAgICAge1xuICAgICAgICAgICAgICAgICAgICBub2RlczogZmllbGROb2RlcyxcbiAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgKSxcbiAgICAgICAgICAgICAgKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICB9XG4gICAgICAgIH1cbiAgICAgIH1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W1lLnZhbHVlXSkge1xuICAgICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgICBuZXcgR3JhcGhRTEVycm9yKFxuICAgICAgICAgICAgICBgVGhlcmUgY2FuIGJlIG9ubHkgb25lIG9wZXJhdGlvbiBuYW1lZCBcIiR7b3BlcmF0aW9uTmFtZS52YWx1ZX1cIi5gLFxuICAgICAgICAgICAgICB7XG4gICAgICAgICAgICAgICAgbm9kZXM6IFtcbiAgICAgICAgICAgICAgICAgIGtub3duT3BlcmF0aW9uTmFtZXNbb3BlcmF0aW9uTmFtZS52YWx1ZV0sXG4gICAgICAgICAgICAgICAgICBvcGVyYXRpb25OYW1lLFxuICAgICAgICAgICAgICAgIF0sXG4gICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICApLFxuICAgICAgICAgICk7XG4gICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAga25vd25PcGVyYXRpb25OYW1lc1tvcGVyYXRpb25OYW1lLnZhbHVlXSA9IG9wZXJhdGlvbk5hbWU7XG4gICAgICAgIH1cbiAgICAgIH1cblxuICAgICAgcmV0dXJuIGZhbHNlO1xuICAgIH0sXG5cbiAgICBGcmFnbWVudERlZmluaXRpb246ICgpID0+IGZhbHNlLFxuICB9O1xufVxuIiwiaW1wb3J0IHsgR3JhcGhRTEVycm9yIH0gZnJvbSAnLi4vLi4vZXJyb3IvR3JhcGhRTEVycm9yLm1qcyc7XG5cbi8qKlxuICogVW5pcXVlIG9wZXJhdGlvbiB0eXBlc1xuICpcbiAqIEEgR3JhcGhRTCBkb2N1bWVudCBpcyBvbmx5IHZhbGlkIGlmIGl0IGhhcyBvbmx5IG9uZSB0eXBlIHBlciBvcGVyYXRpb24uXG4gKi9cbmV4cG9ydCBmdW5jdGlvbiBVbmlxdWVPcGVyYXRpb25UeXBlc1J1bGUoY29udGV4dCkge1xuICBjb25zdCBzY2hlbWEgPSBjb250ZXh0LmdldFNjaGVtYSgpO1xuICBjb25zdCBkZWZpbmVk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lEZWZpbmVkT3BlcmF0aW9uVHlwZSA9IGRlZmluZWRPcGVyYXRpb25UeXBlc1tvcGVyYXRpb25dO1xuXG4gICAgICBpZiAoZXhpc3RpbmdPcGVyYXRpb25UeXBlc1tvcGVyYXRpb25dKSB7XG4gICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgbmV3IEdyYXBoUUxFcnJvcihcbiAgICAgICAgICAgIGBUeXBlIGZvciAke29wZXJhdGlvbn0gYWxyZWFkeSBkZWZpbmVkIGluIHRoZSBzY2hlbWEuIEl0IGNhbm5vdCBiZSByZWRlZmluZWQuYCxcbiAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgbm9kZXM6IG9wZXJhdGlvblR5cGUsXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICksXG4gICAgICAgICk7XG4gICAgICB9IGVsc2UgaWYgKGFscmVhZHlEZWZpbmVkT3BlcmF0aW9uVHlwZSkge1xuICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgIG5ldyBHcmFwaFFMRXJyb3IoXG4gICAgICAgICAgICBgVGhlcmUgY2FuIGJlIG9ubHkgb25lICR7b3BlcmF0aW9ufSB0eXBlIGluIHNjaGVtYS5gLFxuICAgICAgICAgICAge1xuICAgICAgICAgICAgICBub2RlczogW2FscmVhZHlEZWZpbmVkT3BlcmF0aW9uVHlwZSwgb3BlcmF0aW9uVHlwZV0sXG4gICAgICAgICAgICB9LFxuICAgICAgICAgICksXG4gICAgICAgICk7XG4gICAgICB9IGVsc2Uge1xuICAgICAgICBkZWZpbmVkT3BlcmF0aW9uVHlwZXNbb3BlcmF0aW9uXSA9IG9wZXJhdGlvblR5cGU7XG4gICAgICB9XG4gICAgfVxuXG4gICAgcmV0dXJuIGZhbHNlO1xuICB9XG59XG4iLCJpbXBvcnQgeyBHcmFwaFFMRXJyb3IgfSBmcm9tICcuLi8uLi9lcnJvci9HcmFwaFFMRXJyb3IubWpzJztcblxuLyoqXG4g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c3QgZmllbGREZWYgb2YgT2JqZWN0LnZhbHVlcyh0eXBlLmdldEZpZWxkcygpKSkge1xuICAgICAgICBjb25zdCBmaWVsZE5vZGUgPSBmaWVsZE5vZGVNYXBbZmllbGREZWYubmFtZV07XG5cbiAgICAgICAgaWYgKCFmaWVsZE5vZGUgJiYgaXNSZXF1aXJlZElucHV0RmllbGQoZmllbGREZWYpKSB7XG4gICAgICAgICAgY29uc3QgdHlwZVN0ciA9IGluc3BlY3QoZmllbGREZWYudHlwZSk7XG4gICAgICAgICAgY29udGV4dC5yZXBvcnRFcnJvcihcbiAgICAgICAgICAgIG5ldyBHcmFwaFFMRXJyb3IoXG4gICAgICAgICAgICAgIGBGaWVsZCBcIiR7dHlwZS5uYW1lfS4ke2ZpZWxkRGVmLm5hbWV9XCIgb2YgcmVxdWlyZWQgdHlwZSBcIiR7dHlwZVN0cn1cIiB3YXMgbm90IHByb3ZpZGVkLmAsXG4gICAgICAgICAgICAgIHtcbiAgICAgICAgICAgICAgICBub2Rlczogbm9kZSxcbiAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICksXG4gICAgICAgICAgKTtcbiAgICAgICAgfVxuICAgICAgfVxuICAgIH0sXG5cbiAgICBPYmplY3RGaWVsZChub2RlKSB7XG4gICAgICBjb25zdCBwYXJlbnRUeXBlID0gZ2V0TmFtZWRUeXBlKGNvbnRleHQuZ2V0UGFyZW50SW5wdXRUeXBlKCkpO1xuICAgICAgY29uc3QgZmllbGRUeXBlID0gY29udGV4dC5nZXRJbnB1dFR5cGUoKTtcblxuICAgICAgaWYgKCFmaWVsZFR5cGUgJiYgaXNJbnB1dE9iamVjdFR5cGUocGFyZW50VHlwZSkpIHtcbiAgICAgICAgY29uc3Qgc3VnZ2VzdGlvbnMgPSBzdWdnZXN0aW9uTGlzdChcbiAgICAgICAgICBub2RlLm5hbWUudmFsdWUsXG4gICAgICAgICAgT2JqZWN0LmtleXMocGFyZW50VHlwZS5nZXRGaWVsZHMoKSksXG4gICAgICAgICk7XG4gICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgbmV3IEdyYXBoUUxFcnJvcihcbiAgICAgICAgICAgIGBGaWVsZCBcIiR7bm9kZS5uYW1lLnZhbHVlfVwiIGlzIG5vdCBkZWZpbmVkIGJ5IHR5cGUgXCIke3BhcmVudFR5cGUubmFtZX1cIi5gICtcbiAgICAgICAgICAgICAgZGlkWW91TWVhbihzdWdnZXN0aW9ucyksXG4gICAgICAgICAgICB7XG4gICAgICAgICAgICAgIG5vZGVzOiBub2RlLFxuICAgICAgICAgICAgfSxcbiAgICAgICAgICApLFxuICAgICAgICApO1xuICAgICAgfVxuICAgIH0sXG5cbiAgICBOdWxsVmFsdWUobm9kZSkge1xuICAgICAgY29uc3QgdHlwZSA9IGNvbnRleHQuZ2V0SW5wdXRUeXBlKCk7XG5cbiAgICAgIGlmIChpc05vbk51bGxUeXBlKHR5cGUpKSB7XG4gICAgICAgIGNvbnRleHQucmVwb3J0RXJyb3IoXG4gICAgICAgICAgbmV3IEdyYXBoUUxFcnJvcihcbiAgICAgICAgICAgIGBFeHBlY3RlZCB2YWx1ZSBvZiB0eXBlIFwiJHtpbnNwZWN0KHR5cGUpfVwiLCBmb3VuZCAke3ByaW50KG5vZGUpfS5gLFxuICAgICAgICAgICAge1xuICAgICAgICAgICAgICBub2Rlczogbm9kZSxcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgKSxcbiAgICAgICAgKTtcbiAgICAgIH1cbiAgICB9LFxuXG4gICAgRW51bVZhbHVlOiAobm9kZSkgPT4gaXNWYWxpZFZhbHVlTm9kZShjb250ZXh0LCBub2RlKSxcbiAgICBJbnRWYWx1ZTogKG5vZGUpID0+IGlzVmFsaWRWYWx1ZU5vZGUoY29udGV4dCwgbm9kZSksXG4gICAgRmxvYXRWYWx1ZTogKG5vZGUpID0+IGlzVmFsaWRWYWx1ZU5vZGUoY29udGV4dCwgbm9kZSksXG4gICAgU3RyaW5nVmFsdWU6IChub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bGwgd2hlbiB0aGUgZXhwZWN0ZWQgdHlwZSBpcyBudWxsYWJsZS5cbiAgICAgICAgICAgIC8vIElmIGJvdGggYXJlIGxpc3QgdHlwZXMsIHRoZSB2YXJpYWJsZSBpdGVtIHR5cGUgY2FuIGJlIG1vcmUgc3RyaWN0XG4gICAgICAgICAgICAvLyB0aGFuIHRoZSBleHBlY3RlZCBpdGVtIHR5cGUgKGNvbnRyYXZhcmlhbnQpLlxuICAgICAgICAgICAgY29uc3Qgc2NoZW1hID0gY29udGV4dC5nZXRTY2hlbWEoKTtcbiAgICAgICAgICAgIGNvbnN0IHZhclR5cGUgPSB0eXBlRnJvbUFTVChzY2hlbWEsIHZhckRlZi50eXBlKTtcblxuICAgICAgICAgICAgaWYgKFxuICAgICAgICAgICAgICB2YXJUeXBlICYmXG4gICAgICAgICAgICAgICFhbGxvd2VkVmFyaWFibGVVc2FnZShcbiAgICAgICAgICAgICAgICBzY2hlbWEsXG4gICAgICAgICAgICAgICAgdmFyVHlwZSxcbiAgICAgICAgICAgICAgICB2YXJEZWYuZGVmYXVsdFZhbHVlLFxuICAgICAgICAgICAgICAgIHR5cGUsXG4gICAgICAgICAgICAgICAgZGVmYXVsdFZhbHVlLFxuICAgICAgICAgICAgICApXG4gICAgICAgICAgICApIHtcbiAgICAgICAgICAgICAgY29uc3QgdmFyVHlwZVN0ciA9IGluc3BlY3QodmFyVHlwZSk7XG4gICAgICAgICAgICAgIGNvbnN0IHR5cGVTdHIgPSBpbnNwZWN0KHR5cGUpO1xuICAgICAgICAgICAgICBjb250ZXh0LnJlcG9ydEVycm9yKFxuICAgICAgICAgICAgICAgIG5ldyBHcmFwaFFMRXJyb3IoXG4gICAgICAgICAgICAgICAgICBgVmFyaWFibGUgXCIkJHt2YXJOYW1lfVwiIG9mIHR5cGUgXCIke3ZhclR5cGVTdHJ9XCIgdXNlZCBpbiBwb3NpdGlvbiBleHBlY3RpbmcgdHlwZSBcIiR7dHlwZVN0cn1cIi5gLFxuICAgICA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BsZXQgcmVzdWx0ID0gdGhpcy5zdHIucmVwbGFjZShrUGF0dGVyblJlZ2V4LCAobWF0Y2gsIGV4cHIsIG5vbmUpID0+IHtcbiAgICAgICAgICAgIGlmIChub25lKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuICckJzsgICAgIC8vIFxcJCAtPiAkXG4gICAgICAgICAgICB9IGVsc2UgaWYgKGV4cHIuc3RhcnRzV2l0aChcImNvbnRleHQudXNlci5uYW1lXCIpKSB7XG4gICAgICAgICAgICAgICAgaWYgKCF1c2VyKSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiBcIlwiO1xuICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgIHJldHVybiB1c2VyLm5hbWUgPz8gXCJcIjtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKGV4cHIuc3RhcnRzV2l0aChcImFyZ3MuXCIpKSB7XG4gICAgICAgICAgICAgICAgbGV0IHZhck5hbWUgPSBleHByLnNsaWNlKDUpXG4gICAgICAgICAgICAgICAgbGV0IHZhbHVlID0gYXJncyA/IGFyZ3NbdmFyTmFtZV0gOiB1bmRlZmluZWQ7XG4gICAgICAgICAgICAgICAgc3dpdGNoKHR5cGVvZih2YWx1ZSkpIHtcbiAgICAgICAgICAgICAgICBjYXNlIFwidW5kZWZpbmVkXCI6XG4gICAgICAgICAgICAgICAgICAgIHRocm93IG5ldyBIVFRQRXJyb3IoNTAzLCBcIkJhZCBjb25maWc6IFVua25vd24gYXJnIGluIGNoYW5uZWwvcm9sZSBwYXR0ZXJuICcke1wiICsgZXhwciArIFwifSBpbiAnYWxsb3cnXCIpO1xuICAgICAgICAgICAgICAgIGNhc2UgXCJzdHJpbmdcIjpcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHZhbHVlO1xuICAgICAgICAgICAgICAgIGNhc2UgXCJudW1iZXJcIjpcbiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIFN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dXRob3JpemUoY29udGV4dC51c2VyLCBhcmdzKTtcbiAgICAgICAgICAgIGNvbnNvbGUuZGVidWcoYFFVRVJZICR7Zm5OYW1lfWApO1xuICAgICAgICAgICAgaWYgKGFyZ3MpIGFyZ3MgPSB7YXJnczogYXJnc307XG4gICAgICAgICAgICByZXR1cm4gZGIucXVlcnkoY29udGV4dCwgZm5OYW1lLCBuMXFsLCBhcmdzKTtcbiAgICAgICAgfTtcbiAgICBjYXNlIFwiamF2YXNjcmlwdFwiOlxuICAgICAgICBjb25zdCBtdXRhdGluZyA9IGZuQ29uZmlnLm11dGF0aW5nID8/IGZhbHNlO1xuICAgICAgICBjb25zdCBjb2RlID0gY29tcGlsZVRvSlMoZm5OYW1lLCBmbkNvbmZpZywgMikgYXMgSlNGbjtcbiAgICAgICAgcmV0dXJuIGZ1bmN0aW9uKGNvbnRleHQsIGFyZ3MpIHtcbiAgICAgICAgICAgIGNvbnNvbGUuZGVidWcoYEZVTkMgJHtmbk5hbWV9YCk7XG4gICAgICAgICAgICBjaGVja0FyZ3MoYXJncyk7XG4gICAgICAgICAgICBhbGxvdy5hdXRob3JpemUoY29udGV4dC51c2VyLCBhcmdzKTtcbiAgICAgICAgICAgIGlmICghbXV0YXRpbmcpIEJlZ2luUmVhZE9ubHkoY29udGV4dCk7XG4gICAgICAgICAgICB0cnkge1xuICAgICAgICAgICAgICAgIHJldHVybiBjb2RlKGNvbnRleHQsIGFyZ3MpO1xuICAgICAgICAgICAgfSBjYXRjaCAoeCkge1xuICAgICAgICAgICAgICAgIHJldGhyb3coeCwgXCJmdW5jdGlvblwiLCBmbk5hbWUpO1xuICAgICAgICAgICAgfSBmaW5hbGx5IHtcbiAgICAgICAgICAgICAgICBpZiAoIW11dGF0aW5nKSBFbmRSZWFkT25seShjb250ZXh0KTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICBkZWZhdWx0OlxuICAgICAgICB0aHJvdyBuZXcgSFRUUEVycm9yKDUwMCwgYHVucmV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Wx3YXlzIHJldHVybnMgYW4gYXJyYXkuXG4gICAgICAgICAgICAgICAgICAgIC8vIFNvIHVzZSB0aGUgZmlyc3Qgcm93IG9mIHRoZSByZXN1bHQgYXMgdGhlIHZhbHVlLlxuICAgICAgICAgICAgICAgICAgICBsZXQgcm93ID0gcmVzdWx0WzBdO1xuICAgICAgICAgICAgICAgICAgICBpZiAoIXJldHVybnNHcmFwaFFMU2NhbGFyKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcm93XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAvLyBHcmFwaFFMIHJlc3VsdCB0eXBlIGlzIGEgc2NhbGFyLCBidXQgYSBOMVFMIHJvdyBpcyBhbHdheXMgYW4gb2JqZWN0LlxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gVXNlIHRoZSBzaW5nbGUgZmllbGQgb2YgdGhlIG9iamVjdCwgaWYgYW55LCBhcyB0aGUgcmVzdWx0OlxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGNvbHMgPSBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyhyb3cpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGNvbHMubGVuZ3RoID09IDEpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcm93W2NvbHNbMF1dO1xuICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0aHJvdyBuZXcgSFRUUEVycm9yKDUwMCwgYHJlc29sdmVyIHJldHVybnMgc2NhbGFyIHR5cGUgJHtmaWVsZC50eXBlfSwgYnV0IGl0cyBOMVFMIHF1ZXJ5IHJldHVybnMgJHtjb2xzLmxlbmd0aH0gY29sdW1ucywgbm90IDFgKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gY2F0Y2ggKHgpIHtcbiAgICAgICAgICAgICAgICByZXRocm93KHgsIFwicmVzb2x2ZXJcIiwgZm5OYW1lKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfTtcbiAgICAgICAgYnJlYWs7XG4gICAgY2FzZSBcImphdmFzY3JpcHRcIjpcbiAgICAgICAgbGV0IGNvZGUgPSBjb21waWxlVG9KUyhmbk5hbWUsIGZuQ29uZmlnLCA0KSBhcyBSZXNvbHZlckZuO1xuICAgICAgICBmaWVsZC5yZXNvbHZlID0gZnVuY3Rpb24oc291cmNlLCBhcmdzLCBjb250ZXh0LCBpbmZvKSB7XG4gICAgICAgICAgICBjb25zb2xlLmRlYnVnKGBSRVNPTFZFICR7Zm5OYW1lfWApO1xuICAgICAgICAgICAgYWxsb3cuYXV0aG9yaXplKGNvbnRleHQudXNlciwgYXJncyk7XG4gICAgICAgICAgICBpZiAoIW11dGF0aW5nKSBCZWdpblJlYWRPbmx5KGNvbnRleHQpO1xuICAgICAgICAgICAgdHJ5IHtcbiAgICAgICAgICAgICAgICByZXR1cm4gY29kZShzb3VyY2UsIGFyZ3MsIGNvbnRleHQsIHVwZ3JhZGVJbmZvKGluZm8pKTtcbiAgICAgICAgICAgIH0gY2F0Y2ggKHgpIHtcbiAgICAgICAgICAgICAgICByZXRocm93KHgsIFwicmVzb2x2ZXJcIiwgZm5OYW1lKTtcbiAgICAgICAgICAgIH0gZmluYWxseSB7XG4gICAgICAgICAgICAgICAgaWYgKCFtdXRhdGluZykgRW5kUmVhZE9ubHkoY29udGV4dCk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH07XG4gICAgICAgIGJyZWFrO1xuICAgIGRlZmF1bHQ6XG4gICAgICAgIHRocm93IG5ldyBIVFRQRXJyb3IoNTAwLCBgdW5yZWNvZ25pemVkICd0eXBlJyBcIiR7Zm5Db25maWcudHlwZX1cImApO1xuICAgIH1cbn1cblxuXG4vKiogQ29tcGlsZXMgYSBGdW5jdGlvb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gICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgZXJyb3JzLnRyeShgZnVuY3Rpb24gJHtmbk5hbWV9OiBgLCAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLmZ1bmN0aW9uc1tmbk5hbWVdID0gQ29tcGlsZUZuKGZuTmFtZSwgZm5Db25maWcsIHRoaXMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgKytuRnVuY3M7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGlmIChmdW5jdGlvbnMubWF4X2Z1bmN0aW9uX2NvdW50ICE9PSB1bmRlZmluZWQgJiYgbkZ1bmNzID4gZnVuY3Rpb25zLm1heF9mdW5jdGlvbl9jb3VudCkge1xuICAgICAgICAgICAgICAgIGVycm9ycy5jb21wbGFpbihgdG9vIG1hbnkgZnVuY3Rpb25zICg+ICR7ZnVuY3Rpb25zIS5tYXhfZnVuY3Rpb25fY291bnR9KWApO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGdyYXBocWwpIHtcbiAgICAgICAgICAgIGlmICghZ3JhcGhxbC5zY2hlbWEpIHtcbiAgICAgICAgICAgICAgICBlcnJvcnMuY29tcGxhaW4oXCJHcmFwaFFMIHNjaGVtYSBpcyBtaXNzaW5nXCIpO1xuICAgICAgICAgICAgfSBlbHNlIGlmIChncmFwaHFsLm1heF9zY2hlbWFfc2l6ZSAhPT0gdW5kZWZpbmVkICYmIGdyYXBocWwuc2NoZW1hLmxlbmd0aCA+IGdyYXBocWwubWF4X3NjaGVtYV9zaXplKSB7XG4gICAgICAgICAgICAgICAgZXJyb3JzLmNvbXBsYWluKGBHcmFwaFFMIHNjaGVtYSB0b28gbGFyZ2UgKD4gJHtncmFwaHFsLm1heF9zY2hlbWFfc2l6ZX0gYnl0ZXMpYCk7XG4gICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgIGVycm9ycy50cnkoYEdyYXBoUUwgc2NoZW1hOiBgLCAgKCkgPT4ge1xuICAgICAgICAgICAgICAgICAgICBpZiAoZ3JhcGhxbC5zdWJncmFwaCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gUHJlcGVuZCB0aGUgcmVxdWlyZWQgXCJleHRlbmQgc2NoZW1hLi4uXCIgZGVjbGFyYXRpb246XG4gICAgICAgICAgICAgICAgICAgICAgICBsZXQgZG9jdW1lbnQgPSBncS5wYXJzZShrRmVkZXJhdGlvbkltcG9ydHNTdHIgKyBcIlxcblxcblwiICsgZ3JhcGhxbC5zY2hlbWEhKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIENyZWF0ZSBhIG1hcCB3aXRoIGp1c3QgdGhlIF9fcmVzb2x2ZVJlZmVyZW5jZSByZXNvbHZlciBmbnMsIHNvIHRoZVxuICAgICAgICAgICAgICAgICAgICAgICAgLy8gc3ViZ3JhcGggY29kZSBjYW4gc3RvcmUgdGhlbSBpbiB0aGUgc2NoZW1hOlxuICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJlc29sdmVycyA9IHRoaXMuY3JlYXRlQXBvbGxvUmVzb2x2ZXJNYXAoZ3JhcGhxbCxlcnJvcnMpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdGhpcy5zY2hlbWEgPSBidWlsZFN1YmdyYXBoU2NoZW1hKHsgdHlwZURlZnM6IGRvY3VtZW50LFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmVzb2x2ZXJzOiByZXNvbHZlcnMgfSk7XG4gICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnNjaGVtYSA9IGdxLmJ1aWxkU2NoZW1hKGdyYXBocWwuc2NoZW1hISk7XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICBpZiAodGhpcy5zY2hlbWEpIHtcbiAgICAgICAgICAgICAgICAgICAgdGhpcy5jb25maWd1cmVSZXNvbHZlcnMoZ3JhcGhxbCwgZXJyb3JzKTtcbiAgICAgICAgICAgICAgICAgICAgaWYgKGVycm9ycy5lcnJvcnMubGVuZ3RoID09IDApXG4gICAgICAgICAgICAgICAgICAgICAgICB0aGlzLnZlcmlmeVJlc29sdmVyc0V4aXN0KGVycm9ycyk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgfVxuICAgICAgICB9XG5cbiAgICAgICAgaWYgKGVycm9ycy5lcnJvcnMubGVuZ3RoID4gMCkge1xuICAgICAgICAgICAgY29uc29sZS5lcnJvcihgRm91bmQgJHtlcnJvcnMuZXJyb3JzLmxlbmd0aH0gZXJyb3Jbc10gaW4gY29uZmlndXJhdGlvbiFgKTtcbiAgICAgICAgICAgIHJldHVybiBlcnJvcnMuZXJyb3JzO1xuICAgICAgICB9XG4gICAgICAgIHJldHVybiBudWxsO1xuICAgIH1cblxuXG4gICAgcHJpdmF0ZSBjb25maWd1cmVSZXNvbHZlcnMoZ3JhcGhxbDogR3JhcGhRTENvbmZpZywgZXJyb3JzOiBFcnJvckxpc3QpIHtcbiAgICAgICAgbGV0IHJlbWFpbmluZ1Jlc29sdmVycyA9IGdyYXBocWwubWF4X3Jlc29sdmVyX2NvdW50ID8/IDFlOTtcblxuICAgICAgICBpZiAoIWdyYXBocWwucmVzb2x2ZXJzKSAgcmV0dXJuO1xuXG4gICAgICAgIGZ1bmN0aW9uIGNhbkFkZFJlc29sdmVyKHR5cGVOYW1lOiBzdHJpbmcsIGZpZWxkTmFtZTogc3RyaW5nLCBjb25maWc6IEZ1bmN0aW9uQ29uZmlnKSB7XG4gICAgICAgICAgICBpZiAocmVtYWluaW5nUmVzb2x2ZXJzLS0gPT0gMCkge1xuICAgICAgICAgICAgICAgIGVycm9ycy5jb21wbGFpbihgdG9vIG1hbnkgR3JhcGhRTCByZXNvbHZlcnMgKD4gJHtncmFwaHFsLm1heF9yZXNvbHZlcl9jb3VudCF9KWApO1xuICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGxldCBtYXhTaXplID0gZ3JhcGhxbCEubWF4X2NvZGVfc2l6ZTtcbiAgICAgICAgICAgIGlmIChtYXhTaXplICE9PSB1bmRlZmluZWQgJiYgY29uZmlnLmNvZGUubGVuZ3RoID4gbWF4U2l6ZSkge1xuICAgICAgICAgICAgICAgIGVycm9ycy5jb21wbGFpbihgR3JhcGhRTCByZXNvbHZlciAke3R5cGVOYW1lfS4ke2ZpZWxkTmFtZX06IGNvZGUgaXMgdG9vIGxhcmdlICg+ICR7bWF4U2l6ZX0gYnl0ZXMpYCk7XG4gICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgIH1cblxuICAgICAgICBmb3IgKGxldCB0eXBlTmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyhncmFwaHFsLnJlc29sdmVycykpIHtcbiAgICAgICAgICAgIGxldCBmaWVsZHMgPSBncmFwaHFsLnJlc29sdmVyc1t0eXBlTmFtZV07XG4gICAgICAgICAgICBsZXQgc2NoZW1hVHlwZSA9IHRoaXMuc2NoZW1hIS5nZXRUeXBlKHR5cGVOYW1lKTtcbiAgICAgICAgICAgIGlmICghc2NoZW1hVHlwZSkge1xuICAgICAgICAgICAgICAgIGVycm9ycy5jb21wbGFpbihgR3JhcGhRTCByZXNvbHZlciB0eXBlICcke3R5cGVOYW1lfSc6IG5vIHN1Y2ggdHlwZSBpbiB0aGUgc2NoZW1hYCk7XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHNjaGVtYVR5cGUgaW5zdGFuY2VvZiBncS5HcmFwaFFMT2JqZWN0VHlwZSkge1xuICAgICAgICAgICAgICAgIGxldCBzY2hlbWFGaWVsZHMgPSBzY2hlbWFUeXBlLmdldEZpZWxkcygpO1xuICAgICAgICAgICAgICAgIGZvciAobGV0IGZpZWxkTmFtZSBvZiBPYmplY3QuZ2V0T3duUHJvcGVydHlOYW1lcyhmaWVsZHMpKSB7XG4gICAgICAgICAgICAgICAgICAgIGxldCBmbkNvbmZpZyA9IGZpZWxkc1tmaWVsZE5hbWVdO1xuICAgICAgICAgICAgICAgICAgICBpZiAoY2FuQWRkUmVzb2x2ZXIodHlwZU5hbWUsIGZpZWxkTmFtZSwgZm5Db25maWcpKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoZ3JhcGhxbC5zdWJncmFwaCAmJiBmaWVsZE5hbWUgPT0gJ19fcmVzb2x2ZVJlZmVyZW5jZScpICBjb250aW51ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBzY2hlbWFGaWVsZCA9IHNjaGVtYUZpZWxkc1tmaWVsZE5hbWVdO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHNjaGVtYUZpZWxkKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzLnRyeShgR3JhcGhRTCByZXNvbHZlciAke3R5cGVOYW1lfS4ke2ZpZWxkTmFtZX06IGAsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICgpID0+IHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgQ29tcGlsZVJlc29sdmVyKHNjaGVtYUZpZWxkLCB0eXBlTmFtZSwgZmllbGROYW1lLCBmbkNvbmZpZywgdGhpcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZGVidWcoYENvbXBpbGVkIEdyYXBoUUwgcmVzb2x2ZXIgJHt0eXBlTmFtZX0uJHtmaWVsZE5hbWV9YClcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZXJyb3JzLmNvbXBsYWluKGBHcmFwaFFMIHJlc29sdmVyICR7dHlwZU5hbWV9LiR7ZmllbGROYW1lfTogbm8gc3VjaCBmaWVsZCBpbiB0aGUgc2NoZW1hYCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICB9IGVsc2UgaWYgKHNjaGVtYVR5cGUgaW5zdGFuY2VvZiBncS5HcmFwaFFMSW50ZXJmYWNlVHlwZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHx8IHNjaGVtYVR5cGUgaW5zdGFuY2VvZiBncS5HcmFwaFFMVW5pb25UeXBlKSB7XG4gICAgICAgICAgICAgICAgbGV0IGlmVHlwZSA9IHNjaGVtYVR5cGU7XG4gICAgICAgICAgICAgICAgZm9yIChsZXQgZmllbGROYW1lIG9mIE9iamVjdC5nZXRPd25Qcm9wZXJ0eU5hbWVzKGZpZWxkcykpIHtcbiAgICAgICAgICAgICAgICAgICAgbGV0IGZuQ29uZmlnID0gZmllbGRzW2ZpZWxkTmFtZV07XG4gICAgICAgICAgICAgICAgICAgIGlmIChjYW5BZGRSZXNvbHZlcih0eXBlTmFtZSwgZmllbGROYW1lLCBmbkNvbmZpZykpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChmaWVsZE5hbWUgPT0gXCJfX3R5cGVuYW1lXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlcnJvcnMudHJ5KGBHcmFwaFFMIHJlc29sdmVyICR7dHlwZU5hbWV9Ll9fdHlwZW5hbWU6IGAsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoKSA9PiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmVHlwZS5yZXNvbHZlVHlwZSA9IENvbXBpbGVUeXBlTmFtZVJlc29sdmVyKHR5cGVOYW1lLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBmbkNvbmZpZywgdGhpcyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnNvbGUuZGVidWcoYENvbXBpbGVkIEdyYXBoUUwgcmVzb2x2ZXIgJHt0eXBlTmFtZX0uX190eXBlbmFtZWApXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGVycm9ycy5jb21wbGFpbihgR3JhcGhRTCByZXNvbHZlciAke3R5cGVOYW1lfS4ke2ZpZWxkTmFtZX06IGFic3RyYWN0IHR5cGVzIG1heSBvbmx5IGhhdmUgYSAnX190eXBlbmFtZScgcmVzb2x2ZXJgKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgZXJyb3JzLmNvbXBsYWluKGBHcmFwaFFMIHR5cGUgJHt0eXBlTmFtZX06IG5vdCBhbiBvYmplY3Qgb3IgaW50ZXJmYWNlLCBzbyBjYW5ub3QgaGF2ZSByZXNvbHZlcnNgKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgIH1cblxuICAgIHByaXZhdGUgdmVyaWZ5UmVzb2x2ZXJzRXhpc3QoZXJyb3JzOiBFcnJvckxpc3QpIHtcbiAgICAgICAgbGV0IHF1ZXJ5VHlwZSA9IHRoaXMuc2NoZW1hIS5nZXRRdWVyeVR5cGUoKTtcbiAgICAgICAgbGV0IG11dGF0aW9uVHlwZSA9IHRoaXMuc2NoZW1hIS5nZXRNdXRhdGlvblR5cGUoKTtcblxuICAgICAgICBjb25zdCB0eXBlTWFwID0gdGhpcy5zY2hlbWEhLmdldFR5cGVN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yb3JzKSB7XG4gICAgICAgICAgICAgICAgbGV0IGVyciA9IHJlc3VsdC5lcnJvcnNbMF07XG4gICAgICAgICAgICAgICAgaWYgKGVyci5vcmlnaW5hbEVycm9yKVxuICAgICAgICAgICAgICAgICAgICB0aHJvdyBlcnIub3JpZ2luYWxFcnJvcjtcbiAgICAgICAgICAgICAgICB0aHJvdyBFcnJvcihlcnIubWVzc2FnZSk7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAocmVzdWx0LmRhdGEgPT09IHVuZGVmaW5lZCkgcmV0dXJuIG51bGw7XG4gICAgICAgICAgICByZXR1cm4gcmVzdWx0LmRhdGE7XG4gICAgICAgIH0gZmluYWxseSB7XG4gICAgICAgICAgICAtLUNhbGxEZXB0aDtcbiAgICAgICAgfVxuICAgIH1cblxuXG4gICAgdG9KU09OKGtleTogc3RyaW5nKSA6IGFueSB7XG4gICAgICAgIGlmICh0aGlzLmlzQWRtaW4pIHtcbiAgICAgICAgICAgIHJldHVybiB7fTtcbiAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgbmFtZTogdGhpcy5uYW1lLFxuICAgICAgICAgICAgICAgIHJvbGVzOiB0aGlzLnJvbGVzLFxuICAgICAgICAgICAgICAgIGNoYW5uZWxzOiB0aGlzLmNoYW5uZWxzXG4gICAgICAgICAgICB9O1xuICAgICAgICB9XG4gICAgfVxuXG4gICAgY29udGV4dCE6IENvbnRleHRJbXBsO1xufTtcblxuXG4vLy8vLy8vLyBVVElMSVRJRVM6XG5cblxuLyoqIFV0aWxpdHkgdGhhdCBjb2xsZWN0cyBhIGxpc3Qgb2YgZXJyb3IgbWVzc2FnZXMuICovXG5jbGFzcyBFcnJvckxpc3Qge1xuICAgIC8qKiBhZGRzIGFuIGVycm9yIG1lc3NhZ2UgdG8gYGVycm9yc2AuICovXG4gICAgY29tcGxhaW4obXNnOiBzdHJpbmcpIHtcbiAgICAgICAgY29uc29sZS5lcn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mRlZmluZWQsXG4gICAgICAgICAgICB1c2VyOiBzdHJpbmcgfCB1bmRlZmluZWQsXG4gICAgICAgICAgICByb2xlczogc3RyaW5nIHwgdW5kZWZpbmVkLFxuICAgICAgICAgICAgY2hhbm5lbHM6IHN0cmluZyB8IHVuZGVmaW5lZCxcbiAgICAgICAgICAgIG11dGF0aW9uQWxsb3dlZDogYm9vbGVhbikgOiBQcm9taXNlPHN0cmluZz5cbiAgICB7XG4gICAgICAgIGlmIChvcGVyYXRpb25OYW1lID09PSBcIlwiKSBvcGVyYXRpb25OYW1lID0gdW5kZWZpbmVkO1xuICAgICAgICBsZXQgdmFycyA9IHZhcmlhYmxlc0pTT04gPyBKU09OLnBhcnNlKHZhcmlhYmxlc0pTT04pIDogdW5kZWZpbmVkO1xuICAgICAgICBsZXQgY29udGV4dCA9IHRoaXMubWFrZUNvbnRleHQodXNlciwgcm9sZXMsIGNoYW5uZWxzLCBtdXRhdGlvbkFsbG93ZWQpO1xuICAgICAgICBDbGVhckNhbGxEZXB0aCgpO1xuICAgICAgICByZXR1cm4gdGhpcy5kYi5ncmFwaHFsKGNvbnRleHQsIHF1ZXJ5LCB2YXJzLCBvcGVyYXRpb25OYW1lKVxuICAgICAgICAgICAgLnRoZW4oIHJlc3VsdCA9PiBKU09OLnN0cmluZ2lmeShyZXN1bHQpICk7XG4gICAgfVxuXG4gICAgcHJpdmF0ZSBtYWtlQ29udGV4dCh1c2VyOiBzdHJpbmcgfCB1bmRlZmluZWQsXG4gICAgICAgICAgICAgICAgICAgICAgICByb2xlczogc3RyaW5nIHwgdW5kZWZpbmVkLFxuICAgICAgICAgICAgICAgICAgICAgICAgY2hhbm5lbHM6IHN0cmluZyB8IHVuZGVmaW5lZCxcbiAgICAgICAgICAgICAgICAgICAgICAgIG11dGF0aW9uQWxsb3dlZDogYm9vbGVhbikgOiBDb250ZXh0XG4gICAge1xuICAgICAgICB2YXIgY3JlZGVudGlhbHM6IENyZWRlbnRpYWxzIHwgbnVsbCA9IG51bGw7XG4gICAgICAgIGlmICh1c2VyICE9PSB1bmRlZmluZWQpIHtcbiAgICAgICAgICAgIGNyZWRlbnRpYWxzID0gW3VzZXIsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICByb2xlcz8uc3BsaXQoJywnKSA/PyBbXSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgIGNoYW5uZWxzPy5zcGxpdCgnLCcpID8/IFtdXTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm4gdGhpcy5kYi5tYWtlQ29udGV4dChjcmVkZW50aWFscywgbXV0YXRpb25BbGxvd2VkKVxuICAgIH1cblxuICAgIHByaXZhdGUgZGIhOiBEYXRhYmFzZTtcbn07XG5cblxuLyoqIE1haW4gZW50cnkgcG9pbnQsIGNhbGxlZCBieSBHbyBgTmV3RXZhbHVhdG9yKClgLiAqL1xuZXhwb3J0IGZ1bmN0aW9uIG1haW4oY29uZmlnSlNPTjogc3RyaW5nLCBuYXRpdmU6IE5hdGl2ZUFQSSkgOiBBUEkge1xuICAgIHJldHVybiBuZXcgQVBJKGNvbmZpZ0pTT04sIG5hdGl2ZSk7XG59XG4iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0= \ No newline at end of file diff --git a/db/functions/engine/dist/main.js.LICENSE.txt b/db/functions/engine/dist/main.js.LICENSE.txt new file mode 100644 index 0000000000..4bb1cb6f28 --- /dev/null +++ b/db/functions/engine/dist/main.js.LICENSE.txt @@ -0,0 +1,6 @@ +/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ diff --git a/db/functions/engine/jest.config.js b/db/functions/engine/jest.config.js new file mode 100644 index 0000000000..58205a718a --- /dev/null +++ b/db/functions/engine/jest.config.js @@ -0,0 +1,22 @@ +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +module.exports = { + "roots": [ + "/src" + ], + "testMatch": [ + "**/__tests__/**/*.+(ts|tsx|js)", + "**/?(*.)+(spec|test).+(ts|tsx|js)" + ], + "transform": { + "^.+\\.(ts|tsx)$": "ts-jest" + }, +} diff --git a/db/functions/engine/package-lock.json b/db/functions/engine/package-lock.json new file mode 100644 index 0000000000..4a447fada4 --- /dev/null +++ b/db/functions/engine/package-lock.json @@ -0,0 +1,8345 @@ +{ + "name": "sg_js_engine", + "version": "0.2.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "sg_js_engine", + "version": "0.2.0", + "license": "Couchbase BSL", + "dependencies": { + "@apollo/subgraph": "^2.1.4", + "assert": "^2.0.0", + "console-browserify": "^1.2.0", + "graphql": "^16.5.0", + "path-browserify": "^1.0.1", + "source-map-support": "^0.5.21", + "url-parse": "^1.5.10", + "util": "^0.12.5" + }, + "devDependencies": { + "@types/jest": "^29.1.1", + "@types/node": "^18.7.23", + "jest": "^29.1.2", + "ts-jest": "^29.0.3", + "ts-loader": "^9.4.1", + "typescript": "^4.8.4", + "webpack": "^5.74.0", + "webpack-cli": "^4.10.0" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", + "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.1.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@apollo/cache-control-types": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@apollo/cache-control-types/-/cache-control-types-1.0.2.tgz", + "integrity": "sha512-Por80co1eUm4ATsvjCOoS/tIR8PHxqVjsA6z76I6Vw0rFn4cgyVElQcmQDIZiYsy41k8e5xkrMRECkM2WR8pNw==", + "peerDependencies": { + "graphql": "14.x || 15.x || 16.x" + } + }, + "node_modules/@apollo/federation-internals": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@apollo/federation-internals/-/federation-internals-2.1.4.tgz", + "integrity": "sha512-Fpln5hHEh0Jjy0vaTpIlv1SF+zg2cjunsH2X5QDHwKOXoHsT4o7LF+Duoy7LgZj6W3HNW9Z/srmuOXXNTl2gjw==", + "dependencies": { + "chalk": "^4.1.0", + "js-levenshtein": "^1.1.6" + }, + "engines": { + "node": ">=12.13.0" + }, + "peerDependencies": { + "graphql": "^16.5.0" + } + }, + "node_modules/@apollo/subgraph": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@apollo/subgraph/-/subgraph-2.1.4.tgz", + "integrity": "sha512-WrZuvCtTjLczkJq9BxyGgGB5lE0vr83ZFvbdVdByve+EbvfCh0rNtXNFaAXOkOcqzMcDv258AN44o7WBm+raYw==", + "dependencies": { + "@apollo/cache-control-types": "^1.0.2", + "@apollo/federation-internals": "^2.1.4" + }, + "engines": { + "node": ">=12.13.0" + }, + "peerDependencies": { + "graphql": "^16.5.0" + } + }, + "node_modules/@babel/code-frame": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", + "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", + "dev": true, + "dependencies": { + "@babel/highlight": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/compat-data": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.19.3.tgz", + "integrity": "sha512-prBHMK4JYYK+wDjJF1q99KK4JLL+egWS4nmNqdlMUgCExMZ+iZW0hGhyC3VEbsPjvaN0TBhW//VIFwBrk8sEiw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/core": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.19.3.tgz", + "integrity": "sha512-WneDJxdsjEvyKtXKsaBGbDeiyOjR5vYq4HcShxnIbG0qixpoHjI3MqeZM9NDvsojNCEBItQE4juOo/bU6e72gQ==", + "dev": true, + "dependencies": { + "@ampproject/remapping": "^2.1.0", + "@babel/code-frame": "^7.18.6", + "@babel/generator": "^7.19.3", + "@babel/helper-compilation-targets": "^7.19.3", + "@babel/helper-module-transforms": "^7.19.0", + "@babel/helpers": "^7.19.0", + "@babel/parser": "^7.19.3", + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.3", + "@babel/types": "^7.19.3", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.1", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/babel" + } + }, + "node_modules/@babel/core/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/generator": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.19.3.tgz", + "integrity": "sha512-fqVZnmp1ncvZU757UzDheKZpfPgatqY59XtW2/j/18H7u76akb8xqvjw82f+i2UKd/ksYsSick/BCLQUUtJ/qQ==", + "dev": true, + "dependencies": { + "@babel/types": "^7.19.3", + "@jridgewell/gen-mapping": "^0.3.2", + "jsesc": "^2.5.1" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/generator/node_modules/@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/helper-compilation-targets": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.19.3.tgz", + "integrity": "sha512-65ESqLGyGmLvgR0mst5AdW1FkNlj9rQsCKduzEoEPhBCDFGXvz2jW6bXFG6i0/MrV2s7hhXjjb2yAzcPuQlLwg==", + "dev": true, + "dependencies": { + "@babel/compat-data": "^7.19.3", + "@babel/helper-validator-option": "^7.18.6", + "browserslist": "^4.21.3", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/@babel/helper-compilation-targets/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/@babel/helper-environment-visitor": { + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", + "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-function-name": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz", + "integrity": "sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==", + "dev": true, + "dependencies": { + "@babel/template": "^7.18.10", + "@babel/types": "^7.19.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-hoist-variables": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", + "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", + "dev": true, + "dependencies": { + "@babel/types": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-imports": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz", + "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==", + "dev": true, + "dependencies": { + "@babel/types": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-module-transforms": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.19.0.tgz", + "integrity": "sha512-3HBZ377Fe14RbLIA+ac3sY4PTgpxHVkFrESaWhoI5PuyXPBBX8+C34qblV9G89ZtycGJCmCI/Ut+VUDK4bltNQ==", + "dev": true, + "dependencies": { + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-module-imports": "^7.18.6", + "@babel/helper-simple-access": "^7.18.6", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/helper-validator-identifier": "^7.18.6", + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.0", + "@babel/types": "^7.19.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-plugin-utils": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.19.0.tgz", + "integrity": "sha512-40Ryx7I8mT+0gaNxm8JGTZFUITNqdLAgdg0hXzeVZxVD6nFsdhQvip6v8dqkRHzsz1VFpFAaOCHNn0vKBL7Czw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-simple-access": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz", + "integrity": "sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==", + "dev": true, + "dependencies": { + "@babel/types": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-split-export-declaration": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", + "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "dev": true, + "dependencies": { + "@babel/types": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.18.10", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz", + "integrity": "sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-option": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz", + "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helpers": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.19.0.tgz", + "integrity": "sha512-DRBCKGwIEdqY3+rPJgG/dKfQy9+08rHIAJx8q2p+HSWP87s2HCrQmaAMMyMll2kIXKCW0cO1RdQskx15Xakftg==", + "dev": true, + "dependencies": { + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.0", + "@babel/types": "^7.19.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "dev": true, + "dependencies": { + "@babel/helper-validator-identifier": "^7.18.6", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/highlight/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/@babel/highlight/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "node_modules/@babel/highlight/node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "engines": { + "node": ">=0.8.0" + } + }, + "node_modules/@babel/highlight/node_modules/has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/highlight/node_modules/supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "dependencies": { + "has-flag": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/@babel/parser": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.19.3.tgz", + "integrity": "sha512-pJ9xOlNWHiy9+FuFP09DEAFbAn4JskgRsVcc169w2xRBC3FRGuQEwjeIMMND9L2zc0iEhO/tGv4Zq+km+hxNpQ==", + "dev": true, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.12.13" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-jsx": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.18.6.tgz", + "integrity": "sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.10.4" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.8.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.14.5" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/plugin-syntax-typescript": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.18.6.tgz", + "integrity": "sha512-mAWAuq4rvOepWCBid55JuRNvpTNf2UGVgoz4JV0fXEKolsVZDzsa4NqCef758WZJj/GDu0gVGItjKFiClTAmZA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.18.6" + }, + "engines": { + "node": ">=6.9.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0-0" + } + }, + "node_modules/@babel/template": { + "version": "7.18.10", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz", + "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.18.6", + "@babel/parser": "^7.18.10", + "@babel/types": "^7.18.10" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/traverse": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.19.3.tgz", + "integrity": "sha512-qh5yf6149zhq2sgIXmwjnsvmnNQC2iw70UFjp4olxucKrWd/dvlUsBI88VSLUsnMNF7/vnOiA+nk1+yLoCqROQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.18.6", + "@babel/generator": "^7.19.3", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-function-name": "^7.19.0", + "@babel/helper-hoist-variables": "^7.18.6", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/parser": "^7.19.3", + "@babel/types": "^7.19.3", + "debug": "^4.1.0", + "globals": "^11.1.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/types": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.19.3.tgz", + "integrity": "sha512-hGCaQzIY22DJlDh9CH7NOxgKkFjBk0Cw9xDO1Xmh2151ti7wiGfQ3LauXzL4HP1fmFlTX6XjpRETTpUcv7wQLw==", + "dev": true, + "dependencies": { + "@babel/helper-string-parser": "^7.18.10", + "@babel/helper-validator-identifier": "^7.19.1", + "to-fast-properties": "^2.0.0" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "node_modules/@discoveryjs/json-ext": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", + "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", + "dev": true, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "dependencies": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@istanbuljs/load-nyc-config/node_modules/camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/@jest/console": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.1.2.tgz", + "integrity": "sha512-ujEBCcYs82BTmRxqfHMQggSlkUZP63AE5YEaTPj7eFyJOzukkTorstOUC7L6nE3w5SYadGVAnTsQ/ZjTGL0qYQ==", + "dev": true, + "dependencies": { + "@jest/types": "^29.1.2", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.1.2", + "jest-util": "^29.1.2", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/core": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.1.2.tgz", + "integrity": "sha512-sCO2Va1gikvQU2ynDN8V4+6wB7iVrD2CvT0zaRst4rglf56yLly0NQ9nuRRAWFeimRf+tCdFsb1Vk1N9LrrMPA==", + "dev": true, + "dependencies": { + "@jest/console": "^29.1.2", + "@jest/reporters": "^29.1.2", + "@jest/test-result": "^29.1.2", + "@jest/transform": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.0.0", + "jest-config": "^29.1.2", + "jest-haste-map": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-regex-util": "^29.0.0", + "jest-resolve": "^29.1.2", + "jest-resolve-dependencies": "^29.1.2", + "jest-runner": "^29.1.2", + "jest-runtime": "^29.1.2", + "jest-snapshot": "^29.1.2", + "jest-util": "^29.1.2", + "jest-validate": "^29.1.2", + "jest-watcher": "^29.1.2", + "micromatch": "^4.0.4", + "pretty-format": "^29.1.2", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/environment": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.1.2.tgz", + "integrity": "sha512-rG7xZ2UeOfvOVzoLIJ0ZmvPl4tBEQ2n73CZJSlzUjPw4or1oSWC0s0Rk0ZX+pIBJ04aVr6hLWFn1DFtrnf8MhQ==", + "dev": true, + "dependencies": { + "@jest/fake-timers": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "jest-mock": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.1.2.tgz", + "integrity": "sha512-FXw/UmaZsyfRyvZw3M6POgSNqwmuOXJuzdNiMWW9LCYo0GRoRDhg+R5iq5higmRTHQY7hx32+j7WHwinRmoILQ==", + "dev": true, + "dependencies": { + "expect": "^29.1.2", + "jest-snapshot": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/expect-utils": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.1.2.tgz", + "integrity": "sha512-4a48bhKfGj/KAH39u0ppzNTABXQ8QPccWAFUFobWBaEMSMp+sB31Z2fK/l47c4a/Mu1po2ffmfAIPxXbVTXdtg==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/fake-timers": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.1.2.tgz", + "integrity": "sha512-GppaEqS+QQYegedxVMpCe2xCXxxeYwQ7RsNx55zc8f+1q1qevkZGKequfTASI7ejmg9WwI+SJCrHe9X11bLL9Q==", + "dev": true, + "dependencies": { + "@jest/types": "^29.1.2", + "@sinonjs/fake-timers": "^9.1.2", + "@types/node": "*", + "jest-message-util": "^29.1.2", + "jest-mock": "^29.1.2", + "jest-util": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/globals": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.1.2.tgz", + "integrity": "sha512-uMgfERpJYoQmykAd0ffyMq8wignN4SvLUG6orJQRe9WAlTRc9cdpCaE/29qurXixYJVZWUqIBXhSk8v5xN1V9g==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.1.2", + "@jest/expect": "^29.1.2", + "@jest/types": "^29.1.2", + "jest-mock": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/reporters": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.1.2.tgz", + "integrity": "sha512-X4fiwwyxy9mnfpxL0g9DD0KcTmEIqP0jUdnc2cfa9riHy+I6Gwwp5vOZiwyg0vZxfSDxrOlK9S4+340W4d+DAA==", + "dev": true, + "dependencies": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^29.1.2", + "@jest/test-result": "^29.1.2", + "@jest/transform": "^29.1.2", + "@jest/types": "^29.1.2", + "@jridgewell/trace-mapping": "^0.3.15", + "@types/node": "*", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^5.1.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.1.2", + "jest-util": "^29.1.2", + "jest-worker": "^29.1.2", + "slash": "^3.0.0", + "string-length": "^4.0.1", + "strip-ansi": "^6.0.0", + "terminal-link": "^2.0.0", + "v8-to-istanbul": "^9.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/@jest/schemas": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.0.0.tgz", + "integrity": "sha512-3Ab5HgYIIAnS0HjqJHQYZS+zXc4tUmTmBH3z83ajI6afXp8X3ZtdLX+nXx+I7LNkJD7uN9LAVhgnjDgZa2z0kA==", + "dev": true, + "dependencies": { + "@sinclair/typebox": "^0.24.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/source-map": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.0.0.tgz", + "integrity": "sha512-nOr+0EM8GiHf34mq2GcJyz/gYFyLQ2INDhAylrZJ9mMWoW21mLBfZa0BUVPPMxVYrLjeiRe2Z7kWXOGnS0TFhQ==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.15", + "callsites": "^3.0.0", + "graceful-fs": "^4.2.9" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-result": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.1.2.tgz", + "integrity": "sha512-jjYYjjumCJjH9hHCoMhA8PCl1OxNeGgAoZ7yuGYILRJX9NjgzTN0pCT5qAoYR4jfOP8htIByvAlz9vfNSSBoVg==", + "dev": true, + "dependencies": { + "@jest/console": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/test-sequencer": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.1.2.tgz", + "integrity": "sha512-fU6dsUqqm8sA+cd85BmeF7Gu9DsXVWFdGn9taxM6xN1cKdcP/ivSgXh5QucFRFz1oZxKv3/9DYYbq0ULly3P/Q==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.1.2", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.1.2", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/transform": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.1.2.tgz", + "integrity": "sha512-2uaUuVHTitmkx1tHF+eBjb4p7UuzBG7SXIaA/hNIkaMP6K+gXYGxP38ZcrofzqN0HeZ7A90oqsOa97WU7WZkSw==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.1.2", + "@jridgewell/trace-mapping": "^0.3.15", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^1.4.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.1.2", + "jest-regex-util": "^29.0.0", + "jest-util": "^29.1.2", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jest/types": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.1.2.tgz", + "integrity": "sha512-DcXGtoTykQB5jiwCmVr8H4vdg2OJhQex3qPkG+ISyDO7xQXbt/4R6dowcRyPemRnkH7JoHvZuxPBdlq+9JxFCg==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.0.0", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", + "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dev": true, + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "node_modules/@jridgewell/source-map/node_modules/@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dev": true, + "dependencies": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.15", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.15.tgz", + "integrity": "sha512-oWZNOULl+UbhsgB51uuZzglikfIKSUBO/M9W2OfEjn7cmqoAiCgmv9lyACTUacZwBz0ITnJ2NqjU8Tx0DHL88g==", + "dev": true, + "dependencies": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "node_modules/@sinclair/typebox": { + "version": "0.24.44", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.44.tgz", + "integrity": "sha512-ka0W0KN5i6LfrSocduwliMMpqVgohtPFidKdMEOUjoOFCHcOOYkKsPRxfs5f15oPNHTm6ERAm0GV/+/LTKeiWg==", + "dev": true + }, + "node_modules/@sinonjs/commons": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", + "integrity": "sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==", + "dev": true, + "dependencies": { + "type-detect": "4.0.8" + } + }, + "node_modules/@sinonjs/fake-timers": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-9.1.2.tgz", + "integrity": "sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw==", + "dev": true, + "dependencies": { + "@sinonjs/commons": "^1.7.0" + } + }, + "node_modules/@types/babel__core": { + "version": "7.1.19", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.19.tgz", + "integrity": "sha512-WEOTgRsbYkvA/KCsDwVEGkd7WAr1e3g31VHQ8zy5gul/V1qKullU/BU5I68X5v7V3GnB9eotmom4v5a5gjxorw==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "node_modules/@types/babel__generator": { + "version": "7.6.4", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.4.tgz", + "integrity": "sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__template": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", + "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", + "dev": true, + "dependencies": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "node_modules/@types/babel__traverse": { + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.18.2.tgz", + "integrity": "sha512-FcFaxOr2V5KZCviw1TnutEMVUVsGt4D2hP1TAfXZAMKuHYW3xQhe3jTxNPWutgCJ3/X1c5yX8ZoGVEItxKbwBg==", + "dev": true, + "dependencies": { + "@babel/types": "^7.3.0" + } + }, + "node_modules/@types/eslint": { + "version": "8.4.6", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.6.tgz", + "integrity": "sha512-/fqTbjxyFUaYNO7VcW5g+4npmqVACz1bB7RTHYuLj+PRjw9hrCwrUXVQFpChUS0JsyEFvMZ7U/PfmvWgxJhI9g==", + "dev": true, + "dependencies": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "node_modules/@types/eslint-scope": { + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.4.tgz", + "integrity": "sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA==", + "dev": true, + "dependencies": { + "@types/eslint": "*", + "@types/estree": "*" + } + }, + "node_modules/@types/estree": { + "version": "0.0.51", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.51.tgz", + "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==", + "dev": true + }, + "node_modules/@types/graceful-fs": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", + "integrity": "sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, + "node_modules/@types/istanbul-lib-coverage": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", + "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "dev": true + }, + "node_modules/@types/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-coverage": "*" + } + }, + "node_modules/@types/istanbul-reports": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz", + "integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==", + "dev": true, + "dependencies": { + "@types/istanbul-lib-report": "*" + } + }, + "node_modules/@types/jest": { + "version": "29.1.1", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.1.1.tgz", + "integrity": "sha512-U9Ey07dGWl6fUFaIaUQUKWG5NoKi/zizeVQCGV8s4nSU0jPgqphVZvS64+8BtWYvrc3ZGw6wo943NSYPxkrp/g==", + "dev": true, + "dependencies": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "node_modules/@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true + }, + "node_modules/@types/node": { + "version": "18.7.23", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz", + "integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg==", + "dev": true + }, + "node_modules/@types/prettier": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.1.tgz", + "integrity": "sha512-ri0UmynRRvZiiUJdiz38MmIblKK+oH30MztdBVR95dv/Ubw6neWSb8u1XpRb72L4qsZOhz+L+z9JD40SJmfWow==", + "dev": true + }, + "node_modules/@types/stack-utils": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", + "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", + "dev": true + }, + "node_modules/@types/yargs": { + "version": "17.0.13", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.13.tgz", + "integrity": "sha512-9sWaruZk2JGxIQU+IhI1fhPYRcQ0UuTNuKuCW9bR5fp7qi2Llf7WDzNa17Cy7TKnh3cdxDOiyTu6gaLS0eDatg==", + "dev": true, + "dependencies": { + "@types/yargs-parser": "*" + } + }, + "node_modules/@types/yargs-parser": { + "version": "21.0.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", + "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", + "dev": true + }, + "node_modules/@webassemblyjs/ast": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", + "integrity": "sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==", + "dev": true, + "dependencies": { + "@webassemblyjs/helper-numbers": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1" + } + }, + "node_modules/@webassemblyjs/floating-point-hex-parser": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz", + "integrity": "sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==", + "dev": true + }, + "node_modules/@webassemblyjs/helper-api-error": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz", + "integrity": "sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==", + "dev": true + }, + "node_modules/@webassemblyjs/helper-buffer": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz", + "integrity": "sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==", + "dev": true + }, + "node_modules/@webassemblyjs/helper-numbers": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz", + "integrity": "sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==", + "dev": true, + "dependencies": { + "@webassemblyjs/floating-point-hex-parser": "1.11.1", + "@webassemblyjs/helper-api-error": "1.11.1", + "@xtuc/long": "4.2.2" + } + }, + "node_modules/@webassemblyjs/helper-wasm-bytecode": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz", + "integrity": "sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==", + "dev": true + }, + "node_modules/@webassemblyjs/helper-wasm-section": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz", + "integrity": "sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg==", + "dev": true, + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1" + } + }, + "node_modules/@webassemblyjs/ieee754": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz", + "integrity": "sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ==", + "dev": true, + "dependencies": { + "@xtuc/ieee754": "^1.2.0" + } + }, + "node_modules/@webassemblyjs/leb128": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.1.tgz", + "integrity": "sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw==", + "dev": true, + "dependencies": { + "@xtuc/long": "4.2.2" + } + }, + "node_modules/@webassemblyjs/utf8": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.1.tgz", + "integrity": "sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ==", + "dev": true + }, + "node_modules/@webassemblyjs/wasm-edit": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz", + "integrity": "sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA==", + "dev": true, + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/helper-wasm-section": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1", + "@webassemblyjs/wasm-opt": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1", + "@webassemblyjs/wast-printer": "1.11.1" + } + }, + "node_modules/@webassemblyjs/wasm-gen": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz", + "integrity": "sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA==", + "dev": true, + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/ieee754": "1.11.1", + "@webassemblyjs/leb128": "1.11.1", + "@webassemblyjs/utf8": "1.11.1" + } + }, + "node_modules/@webassemblyjs/wasm-opt": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz", + "integrity": "sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw==", + "dev": true, + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1" + } + }, + "node_modules/@webassemblyjs/wasm-parser": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz", + "integrity": "sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA==", + "dev": true, + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-api-error": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/ieee754": "1.11.1", + "@webassemblyjs/leb128": "1.11.1", + "@webassemblyjs/utf8": "1.11.1" + } + }, + "node_modules/@webassemblyjs/wast-printer": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz", + "integrity": "sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg==", + "dev": true, + "dependencies": { + "@webassemblyjs/ast": "1.11.1", + "@xtuc/long": "4.2.2" + } + }, + "node_modules/@webpack-cli/configtest": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz", + "integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==", + "dev": true, + "peerDependencies": { + "webpack": "4.x.x || 5.x.x", + "webpack-cli": "4.x.x" + } + }, + "node_modules/@webpack-cli/info": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-1.5.0.tgz", + "integrity": "sha512-e8tSXZpw2hPl2uMJY6fsMswaok5FdlGNRTktvFk2sD8RjH0hE2+XistawJx1vmKteh4NmGmNUrp+Tb2w+udPcQ==", + "dev": true, + "dependencies": { + "envinfo": "^7.7.3" + }, + "peerDependencies": { + "webpack-cli": "4.x.x" + } + }, + "node_modules/@webpack-cli/serve": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz", + "integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==", + "dev": true, + "peerDependencies": { + "webpack-cli": "4.x.x" + }, + "peerDependenciesMeta": { + "webpack-dev-server": { + "optional": true + } + } + }, + "node_modules/@xtuc/ieee754": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", + "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==", + "dev": true + }, + "node_modules/@xtuc/long": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", + "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==", + "dev": true + }, + "node_modules/acorn": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", + "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==", + "dev": true, + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-import-assertions": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz", + "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==", + "dev": true, + "peerDependencies": { + "acorn": "^8" + } + }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, + "node_modules/ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", + "dev": true, + "peerDependencies": { + "ajv": "^6.9.1" + } + }, + "node_modules/ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "dependencies": { + "type-fest": "^0.21.3" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dev": true, + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "dependencies": { + "sprintf-js": "~1.0.2" + } + }, + "node_modules/assert": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-2.0.0.tgz", + "integrity": "sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==", + "dependencies": { + "es6-object-assign": "^1.1.0", + "is-nan": "^1.2.1", + "object-is": "^1.0.1", + "util": "^0.12.0" + } + }, + "node_modules/available-typed-arrays": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", + "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/babel-jest": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.1.2.tgz", + "integrity": "sha512-IuG+F3HTHryJb7gacC7SQ59A9kO56BctUsT67uJHp1mMCHUOMXpDwOHWGifWqdWVknN2WNkCVQELPjXx0aLJ9Q==", + "dev": true, + "dependencies": { + "@jest/transform": "^29.1.2", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.0.2", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.8.0" + } + }, + "node_modules/babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, + "dependencies": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/babel-plugin-jest-hoist": { + "version": "29.0.2", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.0.2.tgz", + "integrity": "sha512-eBr2ynAEFjcebVvu8Ktx580BD1QKCrBG1XwEUTXJe285p9HA/4hOhfWCFRQhTKSyBV0VzjhG7H91Eifz9s29hg==", + "dev": true, + "dependencies": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.1.14", + "@types/babel__traverse": "^7.0.6" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/babel-preset-current-node-syntax": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", + "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", + "dev": true, + "dependencies": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.8.3", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.8.3", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-top-level-await": "^7.8.3" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/babel-preset-jest": { + "version": "29.0.2", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.0.2.tgz", + "integrity": "sha512-BeVXp7rH5TK96ofyEnHjznjLMQ2nAeDJ+QzxKnHAAMs0RgrQsCywjAN8m4mOm5Di0pxU//3AoEeJJrerMH5UeA==", + "dev": true, + "dependencies": { + "babel-plugin-jest-hoist": "^29.0.2", + "babel-preset-current-node-syntax": "^1.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": "^7.0.0" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "dependencies": { + "fill-range": "^7.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/browserslist": { + "version": "4.21.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.4.tgz", + "integrity": "sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], + "dependencies": { + "caniuse-lite": "^1.0.30001400", + "electron-to-chromium": "^1.4.251", + "node-releases": "^2.0.6", + "update-browserslist-db": "^1.0.9" + }, + "bin": { + "browserslist": "cli.js" + }, + "engines": { + "node": "^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7" + } + }, + "node_modules/bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "dependencies": { + "fast-json-stable-stringify": "2.x" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "dependencies": { + "node-int64": "^0.4.0" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "node_modules/call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dependencies": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/caniuse-lite": { + "version": "1.0.30001415", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001415.tgz", + "integrity": "sha512-ER+PfgCJUe8BqunLGWd/1EY4g8AzQcsDAVzdtMGKVtQEmKAwaFfU6vb7EAVIqTMYsqxBorYZi2+22Iouj/y7GQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/caniuse-lite" + } + ] + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/char-regex": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/chrome-trace-event": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", + "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", + "dev": true, + "engines": { + "node": ">=6.0" + } + }, + "node_modules/ci-info": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.4.0.tgz", + "integrity": "sha512-t5QdPT5jq3o262DOQ8zA6E1tlH2upmUc4Hlvrbx1pGYJuiiHl7O7rvVNI+l8HTVhd/q3Qc9vqimkNk5yiXsAug==", + "dev": true + }, + "node_modules/cjs-module-lexer": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz", + "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", + "dev": true + }, + "node_modules/clone-deep": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", + "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", + "dev": true, + "dependencies": { + "is-plain-object": "^2.0.4", + "kind-of": "^6.0.2", + "shallow-clone": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true, + "engines": { + "iojs": ">= 1.0.0", + "node": ">= 0.12.0" + } + }, + "node_modules/collect-v8-coverage": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz", + "integrity": "sha512-iBPtljfCNcTKNAto0KEtDfZ3qzjJvqE3aTGZsbhjSBlorqpXJlaWWtPO35D+ZImoC3KWejX64o+yPGxhWSTzfg==", + "dev": true + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/colorette": { + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz", + "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", + "dev": true + }, + "node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "node_modules/concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "node_modules/console-browserify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", + "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==" + }, + "node_modules/convert-source-map": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", + "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==", + "dev": true, + "dependencies": { + "safe-buffer": "~5.1.1" + } + }, + "node_modules/convert-source-map/node_modules/safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dedent": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", + "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==", + "dev": true + }, + "node_modules/deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/define-properties": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz", + "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", + "dependencies": { + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/diff-sequences": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.0.0.tgz", + "integrity": "sha512-7Qe/zd1wxSDL4D/X/FPjOMB+ZMDt71W94KYaq05I2l0oQqgXgs7s4ftYYmV38gBSrPz2vcygxfs1xn0FT+rKNA==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/electron-to-chromium": { + "version": "1.4.271", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.271.tgz", + "integrity": "sha512-BCPBtK07xR1/uY2HFDtl3wK2De66AW4MSiPlLrnPNxKC/Qhccxd59W73654S3y6Rb/k3hmuGJOBnhjfoutetXA==", + "dev": true + }, + "node_modules/emittery": { + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.10.2.tgz", + "integrity": "sha512-aITqOwnLanpHLNXZJENbOgjUBeHocD+xsSJmNrjovKBW5HbSpW3d1pEls7GFQPUWXiwG9+0P4GtHfEqC/4M0Iw==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sindresorhus/emittery?sponsor=1" + } + }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "node_modules/enhanced-resolve": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz", + "integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==", + "dev": true, + "dependencies": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/envinfo": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", + "integrity": "sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==", + "dev": true, + "bin": { + "envinfo": "dist/cli.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/es-module-lexer": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz", + "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==", + "dev": true + }, + "node_modules/es6-object-assign": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz", + "integrity": "sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw==" + }, + "node_modules/escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + }, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true, + "bin": { + "esparse": "bin/esparse.js", + "esvalidate": "bin/esvalidate.js" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/esrecurse/node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true, + "engines": { + "node": ">=0.8.x" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true, + "engines": { + "node": ">= 0.8.0" + } + }, + "node_modules/expect": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.1.2.tgz", + "integrity": "sha512-AuAGn1uxva5YBbBlXb+2JPxJRuemZsmlGcapPXWNSBNsQtAULfjioREGBWuI0EOvYUKjDnrCy8PW5Zlr1md5mw==", + "dev": true, + "dependencies": { + "@jest/expect-utils": "^29.1.2", + "jest-get-type": "^29.0.0", + "jest-matcher-utils": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-util": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "node_modules/fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "node_modules/fastest-levenshtein": { + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", + "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==", + "dev": true, + "engines": { + "node": ">= 4.9.1" + } + }, + "node_modules/fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "dependencies": { + "bser": "2.1.1" + } + }, + "node_modules/fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "dependencies": { + "is-callable": "^1.1.3" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "node_modules/fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "node_modules/gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true, + "engines": { + "node": "6.* || 8.* || >= 10.*" + } + }, + "node_modules/get-intrinsic": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", + "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", + "dependencies": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true, + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", + "dev": true + }, + "node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/graceful-fs": { + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "node_modules/graphql": { + "version": "16.6.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.6.0.tgz", + "integrity": "sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw==", + "engines": { + "node": "^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0" + } + }, + "node_modules/has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "dependencies": { + "function-bind": "^1.1.1" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "dependencies": { + "get-intrinsic": "^1.1.1" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dependencies": { + "has-symbols": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/import-local": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", + "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "dev": true, + "dependencies": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + }, + "bin": { + "import-local-fixture": "fixtures/cli.js" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true, + "engines": { + "node": ">=0.8.19" + } + }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "node_modules/inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "node_modules/interpret": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz", + "integrity": "sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==", + "dev": true, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/is-arguments": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", + "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", + "dependencies": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", + "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", + "dev": true, + "dependencies": { + "has": "^1.0.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/is-generator-function": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", + "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", + "dependencies": { + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-nan": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", + "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", + "dependencies": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "dependencies": { + "isobject": "^3.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.10", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz", + "integrity": "sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==", + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "node_modules/isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.0.tgz", + "integrity": "sha512-6Lthe1hqXHBNsqvgDzGO6l03XNeu3CrG4RqQ1KM9+l5+jNGpEJfIELx1NS3SEHmJQA8np/u+E4EPRKRiu6m19A==", + "dev": true, + "dependencies": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-instrument/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "dependencies": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "dev": true, + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jest": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.1.2.tgz", + "integrity": "sha512-5wEIPpCezgORnqf+rCaYD1SK+mNN7NsstWzIsuvsnrhR/hSxXWd82oI7DkrbJ+XTD28/eG8SmxdGvukrGGK6Tw==", + "dev": true, + "dependencies": { + "@jest/core": "^29.1.2", + "@jest/types": "^29.1.2", + "import-local": "^3.0.2", + "jest-cli": "^29.1.2" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-changed-files": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.0.0.tgz", + "integrity": "sha512-28/iDMDrUpGoCitTURuDqUzWQoWmOmOKOFST1mi2lwh62X4BFf6khgH3uSuo1e49X/UDjuApAj3w0wLOex4VPQ==", + "dev": true, + "dependencies": { + "execa": "^5.0.0", + "p-limit": "^3.1.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-circus": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.1.2.tgz", + "integrity": "sha512-ajQOdxY6mT9GtnfJRZBRYS7toNIJayiiyjDyoZcnvPRUPwJ58JX0ci0PKAKUo2C1RyzlHw0jabjLGKksO42JGA==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.1.2", + "@jest/expect": "^29.1.2", + "@jest/test-result": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^0.7.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.1.2", + "jest-matcher-utils": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-runtime": "^29.1.2", + "jest-snapshot": "^29.1.2", + "jest-util": "^29.1.2", + "p-limit": "^3.1.0", + "pretty-format": "^29.1.2", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-cli": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.1.2.tgz", + "integrity": "sha512-vsvBfQ7oS2o4MJdAH+4u9z76Vw5Q8WBQF5MchDbkylNknZdrPTX1Ix7YRJyTlOWqRaS7ue/cEAn+E4V1MWyMzw==", + "dev": true, + "dependencies": { + "@jest/core": "^29.1.2", + "@jest/test-result": "^29.1.2", + "@jest/types": "^29.1.2", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "import-local": "^3.0.2", + "jest-config": "^29.1.2", + "jest-util": "^29.1.2", + "jest-validate": "^29.1.2", + "prompts": "^2.0.1", + "yargs": "^17.3.1" + }, + "bin": { + "jest": "bin/jest.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "node-notifier": "^8.0.1 || ^9.0.0 || ^10.0.0" + }, + "peerDependenciesMeta": { + "node-notifier": { + "optional": true + } + } + }, + "node_modules/jest-cli/node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "dependencies": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/jest-cli/node_modules/y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/jest-cli/node_modules/yargs": { + "version": "17.6.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.0.tgz", + "integrity": "sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==", + "dev": true, + "dependencies": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/jest-config": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.1.2.tgz", + "integrity": "sha512-EC3Zi86HJUOz+2YWQcJYQXlf0zuBhJoeyxLM6vb6qJsVmpP7KcCP1JnyF0iaqTaXdBP8Rlwsvs7hnKWQWWLwwA==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.1.2", + "@jest/types": "^29.1.2", + "babel-jest": "^29.1.2", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.1.2", + "jest-environment-node": "^29.1.2", + "jest-get-type": "^29.0.0", + "jest-regex-util": "^29.0.0", + "jest-resolve": "^29.1.2", + "jest-runner": "^29.1.2", + "jest-util": "^29.1.2", + "jest-validate": "^29.1.2", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.1.2", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@types/node": "*", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/jest-config/node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-diff": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.1.2.tgz", + "integrity": "sha512-4GQts0aUopVvecIT4IwD/7xsBaMhKTYoM4/njE/aVw9wpw+pIUVp8Vab/KnSzSilr84GnLBkaP3JLDnQYCKqVQ==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "diff-sequences": "^29.0.0", + "jest-get-type": "^29.0.0", + "pretty-format": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-docblock": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.0.0.tgz", + "integrity": "sha512-s5Kpra/kLzbqu9dEjov30kj1n4tfu3e7Pl8v+f8jOkeWNqM6Ds8jRaJfZow3ducoQUrf2Z4rs2N5S3zXnb83gw==", + "dev": true, + "dependencies": { + "detect-newline": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-each": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.1.2.tgz", + "integrity": "sha512-AmTQp9b2etNeEwMyr4jc0Ql/LIX/dhbgP21gHAizya2X6rUspHn2gysMXaj6iwWuOJ2sYRgP8c1P4cXswgvS1A==", + "dev": true, + "dependencies": { + "@jest/types": "^29.1.2", + "chalk": "^4.0.0", + "jest-get-type": "^29.0.0", + "jest-util": "^29.1.2", + "pretty-format": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-environment-node": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.1.2.tgz", + "integrity": "sha512-C59yVbdpY8682u6k/lh8SUMDJPbOyCHOTgLVVi1USWFxtNV+J8fyIwzkg+RJIVI30EKhKiAGNxYaFr3z6eyNhQ==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.1.2", + "@jest/fake-timers": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "jest-mock": "^29.1.2", + "jest-util": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-get-type": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.0.0.tgz", + "integrity": "sha512-83X19z/HuLKYXYHskZlBAShO7UfLFXu/vWajw9ZNJASN32li8yHMaVGAQqxFW1RCFOkB7cubaL6FaJVQqqJLSw==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-haste-map": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.1.2.tgz", + "integrity": "sha512-xSjbY8/BF11Jh3hGSPfYTa/qBFrm3TPM7WU8pU93m2gqzORVLkHFWvuZmFsTEBPRKndfewXhMOuzJNHyJIZGsw==", + "dev": true, + "dependencies": { + "@jest/types": "^29.1.2", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.0.0", + "jest-util": "^29.1.2", + "jest-worker": "^29.1.2", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "optionalDependencies": { + "fsevents": "^2.3.2" + } + }, + "node_modules/jest-leak-detector": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.1.2.tgz", + "integrity": "sha512-TG5gAZJpgmZtjb6oWxBLf2N6CfQ73iwCe6cofu/Uqv9iiAm6g502CAnGtxQaTfpHECBdVEMRBhomSXeLnoKjiQ==", + "dev": true, + "dependencies": { + "jest-get-type": "^29.0.0", + "pretty-format": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-matcher-utils": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.1.2.tgz", + "integrity": "sha512-MV5XrD3qYSW2zZSHRRceFzqJ39B2z11Qv0KPyZYxnzDHFeYZGJlgGi0SW+IXSJfOewgJp/Km/7lpcFT+cgZypw==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "jest-diff": "^29.1.2", + "jest-get-type": "^29.0.0", + "pretty-format": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-message-util": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.1.2.tgz", + "integrity": "sha512-9oJ2Os+Qh6IlxLpmvshVbGUiSkZVc2FK+uGOm6tghafnB2RyjKAxMZhtxThRMxfX1J1SOMhTn9oK3/MutRWQJQ==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.1.2", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.1.2", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-mock": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.1.2.tgz", + "integrity": "sha512-PFDAdjjWbjPUtQPkQufvniXIS3N9Tv7tbibePEjIIprzjgo0qQlyUiVMrT4vL8FaSJo1QXifQUOuPH3HQC/aMA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.1.2", + "@types/node": "*", + "jest-util": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-pnp-resolver": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz", + "integrity": "sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w==", + "dev": true, + "engines": { + "node": ">=6" + }, + "peerDependencies": { + "jest-resolve": "*" + }, + "peerDependenciesMeta": { + "jest-resolve": { + "optional": true + } + } + }, + "node_modules/jest-regex-util": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.0.0.tgz", + "integrity": "sha512-BV7VW7Sy0fInHWN93MMPtlClweYv2qrSCwfeFWmpribGZtQPWNvRSq9XOVgOEjU1iBGRKXUZil0o2AH7Iy9Lug==", + "dev": true, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.1.2.tgz", + "integrity": "sha512-7fcOr+k7UYSVRJYhSmJHIid3AnDBcLQX3VmT9OSbPWsWz1MfT7bcoerMhADKGvKCoMpOHUQaDHtQoNp/P9JMGg==", + "dev": true, + "dependencies": { + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.1.2", + "jest-pnp-resolver": "^1.2.2", + "jest-util": "^29.1.2", + "jest-validate": "^29.1.2", + "resolve": "^1.20.0", + "resolve.exports": "^1.1.0", + "slash": "^3.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-resolve-dependencies": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.1.2.tgz", + "integrity": "sha512-44yYi+yHqNmH3OoWZvPgmeeiwKxhKV/0CfrzaKLSkZG9gT973PX8i+m8j6pDrTYhhHoiKfF3YUFg/6AeuHw4HQ==", + "dev": true, + "dependencies": { + "jest-regex-util": "^29.0.0", + "jest-snapshot": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.1.2.tgz", + "integrity": "sha512-yy3LEWw8KuBCmg7sCGDIqKwJlULBuNIQa2eFSVgVASWdXbMYZ9H/X0tnXt70XFoGf92W2sOQDOIFAA6f2BG04Q==", + "dev": true, + "dependencies": { + "@jest/console": "^29.1.2", + "@jest/environment": "^29.1.2", + "@jest/test-result": "^29.1.2", + "@jest/transform": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "chalk": "^4.0.0", + "emittery": "^0.10.2", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.0.0", + "jest-environment-node": "^29.1.2", + "jest-haste-map": "^29.1.2", + "jest-leak-detector": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-resolve": "^29.1.2", + "jest-runtime": "^29.1.2", + "jest-util": "^29.1.2", + "jest-watcher": "^29.1.2", + "jest-worker": "^29.1.2", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-runner/node_modules/source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/jest-runtime": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.1.2.tgz", + "integrity": "sha512-jr8VJLIf+cYc+8hbrpt412n5jX3tiXmpPSYTGnwcvNemY+EOuLNiYnHJ3Kp25rkaAcTWOEI4ZdOIQcwYcXIAZw==", + "dev": true, + "dependencies": { + "@jest/environment": "^29.1.2", + "@jest/fake-timers": "^29.1.2", + "@jest/globals": "^29.1.2", + "@jest/source-map": "^29.0.0", + "@jest/test-result": "^29.1.2", + "@jest/transform": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "chalk": "^4.0.0", + "cjs-module-lexer": "^1.0.0", + "collect-v8-coverage": "^1.0.0", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-mock": "^29.1.2", + "jest-regex-util": "^29.0.0", + "jest-resolve": "^29.1.2", + "jest-snapshot": "^29.1.2", + "jest-util": "^29.1.2", + "slash": "^3.0.0", + "strip-bom": "^4.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-snapshot": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.1.2.tgz", + "integrity": "sha512-rYFomGpVMdBlfwTYxkUp3sjD6usptvZcONFYNqVlaz4EpHPnDvlWjvmOQ9OCSNKqYZqLM2aS3wq01tWujLg7gg==", + "dev": true, + "dependencies": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/traverse": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.1.2", + "@jest/transform": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/babel__traverse": "^7.0.6", + "@types/prettier": "^2.1.5", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.1.2", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.1.2", + "jest-get-type": "^29.0.0", + "jest-haste-map": "^29.1.2", + "jest-matcher-utils": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-util": "^29.1.2", + "natural-compare": "^1.4.0", + "pretty-format": "^29.1.2", + "semver": "^7.3.5" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-util": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.1.2.tgz", + "integrity": "sha512-vPCk9F353i0Ymx3WQq3+a4lZ07NXu9Ca8wya6o4Fe4/aO1e1awMMprZ3woPFpKwghEOW+UXgd15vVotuNN9ONQ==", + "dev": true, + "dependencies": { + "@jest/types": "^29.1.2", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.1.2.tgz", + "integrity": "sha512-k71pOslNlV8fVyI+mEySy2pq9KdXdgZtm7NHrBX8LghJayc3wWZH0Yr0mtYNGaCU4F1OLPXRkwZR0dBm/ClshA==", + "dev": true, + "dependencies": { + "@jest/types": "^29.1.2", + "camelcase": "^6.2.0", + "chalk": "^4.0.0", + "jest-get-type": "^29.0.0", + "leven": "^3.1.0", + "pretty-format": "^29.1.2" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-validate/node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/jest-watcher": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.1.2.tgz", + "integrity": "sha512-6JUIUKVdAvcxC6bM8/dMgqY2N4lbT+jZVsxh0hCJRbwkIEnbr/aPjMQ28fNDI5lB51Klh00MWZZeVf27KBUj5w==", + "dev": true, + "dependencies": { + "@jest/test-result": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.10.2", + "jest-util": "^29.1.2", + "string-length": "^4.0.1" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.1.2.tgz", + "integrity": "sha512-AdTZJxKjTSPHbXT/AIOjQVmoFx0LHFcVabWu0sxI7PAy7rFf8c0upyvgBKgguVXdM4vY74JdwkyD4hSmpTW8jA==", + "dev": true, + "dependencies": { + "@types/node": "*", + "jest-util": "^29.1.2", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/jest-worker/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/js-levenshtein": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz", + "integrity": "sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "node_modules/js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "dependencies": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true, + "bin": { + "jsesc": "bin/jsesc" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, + "node_modules/json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "node_modules/json5": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", + "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "dev": true, + "bin": { + "json5": "lib/cli.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, + "node_modules/loader-runner": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", + "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==", + "dev": true, + "engines": { + "node": ">=6.11.5" + } + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "dependencies": { + "p-locate": "^4.1.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "node_modules/makeerror": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dev": true, + "dependencies": { + "tmpl": "1.0.5" + } + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "node_modules/micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "dependencies": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "node_modules/natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "node_modules/neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", + "dev": true + }, + "node_modules/node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true + }, + "node_modules/node-releases": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", + "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", + "dev": true + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/object-is": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", + "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==", + "dependencies": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "dependencies": { + "wrappy": "1" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "dependencies": { + "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-locate/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "dependencies": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==" + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "node_modules/picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pirates": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", + "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==", + "dev": true, + "engines": { + "node": ">= 6" + } + }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pretty-format": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.1.2.tgz", + "integrity": "sha512-CGJ6VVGXVRP2o2Dorl4mAwwvDWT25luIsYhkyVQW32E4nL+TgW939J7LlKT/npq5Cpq6j3s+sy+13yk7xYpBmg==", + "dev": true, + "dependencies": { + "@jest/schemas": "^29.0.0", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + } + }, + "node_modules/pretty-format/node_modules/ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "dependencies": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" + }, + "node_modules/randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "dependencies": { + "safe-buffer": "^5.1.0" + } + }, + "node_modules/react-is": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", + "dev": true + }, + "node_modules/rechoir": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz", + "integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==", + "dev": true, + "dependencies": { + "resolve": "^1.9.0" + }, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" + }, + "node_modules/resolve": { + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "dev": true, + "dependencies": { + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, + "dependencies": { + "resolve-from": "^5.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/resolve.exports": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-1.1.0.tgz", + "integrity": "sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ==", + "dev": true, + "engines": { + "node": ">=10" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/schema-utils": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", + "integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==", + "dev": true, + "dependencies": { + "@types/json-schema": "^7.0.8", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + } + }, + "node_modules/semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "dev": true, + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "dependencies": { + "randombytes": "^2.1.0" + } + }, + "node_modules/shallow-clone": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", + "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", + "dev": true, + "dependencies": { + "kind-of": "^6.0.2" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "node_modules/sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + }, + "node_modules/stack-utils": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.5.tgz", + "integrity": "sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA==", + "dev": true, + "dependencies": { + "escape-string-regexp": "^2.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-length": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", + "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", + "dev": true, + "dependencies": { + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-hyperlinks": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz", + "integrity": "sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0", + "supports-color": "^7.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true, + "engines": { + "node": ">=6" + } + }, + "node_modules/terminal-link": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", + "integrity": "sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ==", + "dev": true, + "dependencies": { + "ansi-escapes": "^4.2.1", + "supports-hyperlinks": "^2.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/terser": { + "version": "5.15.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.15.1.tgz", + "integrity": "sha512-K1faMUvpm/FBxjBXud0LWVAGxmvoPbZbfTCYbSgaaYQaIXI3/TdI7a7ZGA73Zrou6Q8Zmz3oeUTsp/dj+ag2Xw==", + "dev": true, + "dependencies": { + "@jridgewell/source-map": "^0.3.2", + "acorn": "^8.5.0", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser-webpack-plugin": { + "version": "5.3.6", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.6.tgz", + "integrity": "sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.14", + "jest-worker": "^27.4.5", + "schema-utils": "^3.1.1", + "serialize-javascript": "^6.0.0", + "terser": "^5.14.1" + }, + "engines": { + "node": ">= 10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "^5.1.0" + }, + "peerDependenciesMeta": { + "@swc/core": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "uglify-js": { + "optional": true + } + } + }, + "node_modules/terser-webpack-plugin/node_modules/jest-worker": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", + "integrity": "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==", + "dev": true, + "dependencies": { + "@types/node": "*", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "engines": { + "node": ">= 10.13.0" + } + }, + "node_modules/terser-webpack-plugin/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, + "node_modules/test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/tmpl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true + }, + "node_modules/to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/ts-jest": { + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.3.tgz", + "integrity": "sha512-Ibygvmuyq1qp/z3yTh9QTwVVAbFdDy/+4BtIQR2sp6baF2SJU/8CKK/hhnGIDY2L90Az2jIqTwZPnN2p+BweiQ==", + "dev": true, + "dependencies": { + "bs-logger": "0.x", + "fast-json-stable-stringify": "2.x", + "jest-util": "^29.0.0", + "json5": "^2.2.1", + "lodash.memoize": "4.x", + "make-error": "1.x", + "semver": "7.x", + "yargs-parser": "^21.0.1" + }, + "bin": { + "ts-jest": "cli.js" + }, + "engines": { + "node": "^14.15.0 || ^16.10.0 || >=18.0.0" + }, + "peerDependencies": { + "@babel/core": ">=7.0.0-beta.0 <8", + "@jest/types": "^29.0.0", + "babel-jest": "^29.0.0", + "jest": "^29.0.0", + "typescript": ">=4.3" + }, + "peerDependenciesMeta": { + "@babel/core": { + "optional": true + }, + "@jest/types": { + "optional": true + }, + "babel-jest": { + "optional": true + }, + "esbuild": { + "optional": true + } + } + }, + "node_modules/ts-loader": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.4.1.tgz", + "integrity": "sha512-384TYAqGs70rn9F0VBnh6BPTfhga7yFNdC5gXbQpDrBj9/KsT4iRkGqKXhziofHOlE2j6YEaiTYVGKKvPhGWvw==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "enhanced-resolve": "^5.0.0", + "micromatch": "^4.0.0", + "semver": "^7.3.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "typescript": "*", + "webpack": "^5.0.0" + } + }, + "node_modules/type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true, + "engines": { + "node": ">=4" + } + }, + "node_modules/type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/typescript": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=4.2.0" + } + }, + "node_modules/update-browserslist-db": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.9.tgz", + "integrity": "sha512-/xsqn21EGVdXI3EXSum1Yckj3ZVZugqyOZQ/CxYPBD/R+ko9NSUScf8tFF4dOKY+2pvSSJA/S+5B8s4Zr4kyvg==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/browserslist" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/browserslist" + } + ], + "dependencies": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + }, + "bin": { + "browserslist-lint": "cli.js" + }, + "peerDependencies": { + "browserslist": ">= 4.21.0" + } + }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "dependencies": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, + "node_modules/util": { + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", + "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", + "dependencies": { + "inherits": "^2.0.3", + "is-arguments": "^1.0.4", + "is-generator-function": "^1.0.7", + "is-typed-array": "^1.1.3", + "which-typed-array": "^1.1.2" + } + }, + "node_modules/v8-to-istanbul": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.0.1.tgz", + "integrity": "sha512-74Y4LqY74kLE6IFyIjPtkSTWzUZmj8tdHT9Ii/26dvQ6K9Dl2NbEfj0XgU2sHCtKgt5VupqhlO/5aWuqS+IY1w==", + "dev": true, + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0" + }, + "engines": { + "node": ">=10.12.0" + } + }, + "node_modules/walker": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, + "dependencies": { + "makeerror": "1.0.12" + } + }, + "node_modules/watchpack": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", + "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", + "dev": true, + "dependencies": { + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.1.2" + }, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/webpack": { + "version": "5.74.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.74.0.tgz", + "integrity": "sha512-A2InDwnhhGN4LYctJj6M1JEaGL7Luj6LOmyBHjcI8529cm5p6VXiTIW2sn6ffvEAKmveLzvu4jrihwXtPojlAA==", + "dev": true, + "dependencies": { + "@types/eslint-scope": "^3.7.3", + "@types/estree": "^0.0.51", + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/wasm-edit": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1", + "acorn": "^8.7.1", + "acorn-import-assertions": "^1.7.6", + "browserslist": "^4.14.5", + "chrome-trace-event": "^1.0.2", + "enhanced-resolve": "^5.10.0", + "es-module-lexer": "^0.9.0", + "eslint-scope": "5.1.1", + "events": "^3.2.0", + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.2.9", + "json-parse-even-better-errors": "^2.3.1", + "loader-runner": "^4.2.0", + "mime-types": "^2.1.27", + "neo-async": "^2.6.2", + "schema-utils": "^3.1.0", + "tapable": "^2.1.1", + "terser-webpack-plugin": "^5.1.3", + "watchpack": "^2.4.0", + "webpack-sources": "^3.2.3" + }, + "bin": { + "webpack": "bin/webpack.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependenciesMeta": { + "webpack-cli": { + "optional": true + } + } + }, + "node_modules/webpack-cli": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.10.0.tgz", + "integrity": "sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==", + "dev": true, + "dependencies": { + "@discoveryjs/json-ext": "^0.5.0", + "@webpack-cli/configtest": "^1.2.0", + "@webpack-cli/info": "^1.5.0", + "@webpack-cli/serve": "^1.7.0", + "colorette": "^2.0.14", + "commander": "^7.0.0", + "cross-spawn": "^7.0.3", + "fastest-levenshtein": "^1.0.12", + "import-local": "^3.0.2", + "interpret": "^2.2.0", + "rechoir": "^0.7.0", + "webpack-merge": "^5.7.3" + }, + "bin": { + "webpack-cli": "bin/cli.js" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/webpack" + }, + "peerDependencies": { + "webpack": "4.x.x || 5.x.x" + }, + "peerDependenciesMeta": { + "@webpack-cli/generators": { + "optional": true + }, + "@webpack-cli/migrate": { + "optional": true + }, + "webpack-bundle-analyzer": { + "optional": true + }, + "webpack-dev-server": { + "optional": true + } + } + }, + "node_modules/webpack-cli/node_modules/commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true, + "engines": { + "node": ">= 10" + } + }, + "node_modules/webpack-merge": { + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.8.0.tgz", + "integrity": "sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q==", + "dev": true, + "dependencies": { + "clone-deep": "^4.0.1", + "wildcard": "^2.0.0" + }, + "engines": { + "node": ">=10.0.0" + } + }, + "node_modules/webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "dev": true, + "engines": { + "node": ">=10.13.0" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/which-typed-array": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", + "integrity": "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==", + "dependencies": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0", + "is-typed-array": "^1.1.10" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/wildcard": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.0.tgz", + "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==", + "dev": true + }, + "node_modules/wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "node_modules/write-file-atomic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, + "dependencies": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } + }, + "node_modules/yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + } + }, + "dependencies": { + "@ampproject/remapping": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.2.0.tgz", + "integrity": "sha512-qRmjj8nj9qmLTQXXmaR1cck3UXSRMPrbsLJAasZpF+t3riI71BXed5ebIOYwQntykeZuhjsdweEc9BxH5Jc26w==", + "dev": true, + "requires": { + "@jridgewell/gen-mapping": "^0.1.0", + "@jridgewell/trace-mapping": "^0.3.9" + } + }, + "@apollo/cache-control-types": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@apollo/cache-control-types/-/cache-control-types-1.0.2.tgz", + "integrity": "sha512-Por80co1eUm4ATsvjCOoS/tIR8PHxqVjsA6z76I6Vw0rFn4cgyVElQcmQDIZiYsy41k8e5xkrMRECkM2WR8pNw==", + "requires": {} + }, + "@apollo/federation-internals": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@apollo/federation-internals/-/federation-internals-2.1.4.tgz", + "integrity": "sha512-Fpln5hHEh0Jjy0vaTpIlv1SF+zg2cjunsH2X5QDHwKOXoHsT4o7LF+Duoy7LgZj6W3HNW9Z/srmuOXXNTl2gjw==", + "requires": { + "chalk": "^4.1.0", + "js-levenshtein": "^1.1.6" + } + }, + "@apollo/subgraph": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@apollo/subgraph/-/subgraph-2.1.4.tgz", + "integrity": "sha512-WrZuvCtTjLczkJq9BxyGgGB5lE0vr83ZFvbdVdByve+EbvfCh0rNtXNFaAXOkOcqzMcDv258AN44o7WBm+raYw==", + "requires": { + "@apollo/cache-control-types": "^1.0.2", + "@apollo/federation-internals": "^2.1.4" + } + }, + "@babel/code-frame": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.18.6.tgz", + "integrity": "sha512-TDCmlK5eOvH+eH7cdAFlNXeVJqWIQ7gW9tY1GJIpUtFb6CmjVyq2VM3u71bOyR8CRihcCgMUYoDNyLXao3+70Q==", + "dev": true, + "requires": { + "@babel/highlight": "^7.18.6" + } + }, + "@babel/compat-data": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.19.3.tgz", + "integrity": "sha512-prBHMK4JYYK+wDjJF1q99KK4JLL+egWS4nmNqdlMUgCExMZ+iZW0hGhyC3VEbsPjvaN0TBhW//VIFwBrk8sEiw==", + "dev": true + }, + "@babel/core": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.19.3.tgz", + "integrity": "sha512-WneDJxdsjEvyKtXKsaBGbDeiyOjR5vYq4HcShxnIbG0qixpoHjI3MqeZM9NDvsojNCEBItQE4juOo/bU6e72gQ==", + "dev": true, + "requires": { + "@ampproject/remapping": "^2.1.0", + "@babel/code-frame": "^7.18.6", + "@babel/generator": "^7.19.3", + "@babel/helper-compilation-targets": "^7.19.3", + "@babel/helper-module-transforms": "^7.19.0", + "@babel/helpers": "^7.19.0", + "@babel/parser": "^7.19.3", + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.3", + "@babel/types": "^7.19.3", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.2", + "json5": "^2.2.1", + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "@babel/generator": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.19.3.tgz", + "integrity": "sha512-fqVZnmp1ncvZU757UzDheKZpfPgatqY59XtW2/j/18H7u76akb8xqvjw82f+i2UKd/ksYsSick/BCLQUUtJ/qQ==", + "dev": true, + "requires": { + "@babel/types": "^7.19.3", + "@jridgewell/gen-mapping": "^0.3.2", + "jsesc": "^2.5.1" + }, + "dependencies": { + "@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + } + } + }, + "@babel/helper-compilation-targets": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/helper-compilation-targets/-/helper-compilation-targets-7.19.3.tgz", + "integrity": "sha512-65ESqLGyGmLvgR0mst5AdW1FkNlj9rQsCKduzEoEPhBCDFGXvz2jW6bXFG6i0/MrV2s7hhXjjb2yAzcPuQlLwg==", + "dev": true, + "requires": { + "@babel/compat-data": "^7.19.3", + "@babel/helper-validator-option": "^7.18.6", + "browserslist": "^4.21.3", + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "@babel/helper-environment-visitor": { + "version": "7.18.9", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.18.9.tgz", + "integrity": "sha512-3r/aACDJ3fhQ/EVgFy0hpj8oHyHpQc+LPtJoY9SzTThAsStm4Ptegq92vqKoE3vD706ZVFWITnMnxucw+S9Ipg==", + "dev": true + }, + "@babel/helper-function-name": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.19.0.tgz", + "integrity": "sha512-WAwHBINyrpqywkUH0nTnNgI5ina5TFn85HKS0pbPDfxFfhyR/aNQEn4hGi1P1JyT//I0t4OgXUlofzWILRvS5w==", + "dev": true, + "requires": { + "@babel/template": "^7.18.10", + "@babel/types": "^7.19.0" + } + }, + "@babel/helper-hoist-variables": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-hoist-variables/-/helper-hoist-variables-7.18.6.tgz", + "integrity": "sha512-UlJQPkFqFULIcyW5sbzgbkxn2FKRgwWiRexcuaR8RNJRy8+LLveqPjwZV/bwrLZCN0eUHD/x8D0heK1ozuoo6Q==", + "dev": true, + "requires": { + "@babel/types": "^7.18.6" + } + }, + "@babel/helper-module-imports": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.18.6.tgz", + "integrity": "sha512-0NFvs3VkuSYbFi1x2Vd6tKrywq+z/cLeYC/RJNFrIX/30Bf5aiGYbtvGXolEktzJH8o5E5KJ3tT+nkxuuZFVlA==", + "dev": true, + "requires": { + "@babel/types": "^7.18.6" + } + }, + "@babel/helper-module-transforms": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.19.0.tgz", + "integrity": "sha512-3HBZ377Fe14RbLIA+ac3sY4PTgpxHVkFrESaWhoI5PuyXPBBX8+C34qblV9G89ZtycGJCmCI/Ut+VUDK4bltNQ==", + "dev": true, + "requires": { + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-module-imports": "^7.18.6", + "@babel/helper-simple-access": "^7.18.6", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/helper-validator-identifier": "^7.18.6", + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.0", + "@babel/types": "^7.19.0" + } + }, + "@babel/helper-plugin-utils": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helper-plugin-utils/-/helper-plugin-utils-7.19.0.tgz", + "integrity": "sha512-40Ryx7I8mT+0gaNxm8JGTZFUITNqdLAgdg0hXzeVZxVD6nFsdhQvip6v8dqkRHzsz1VFpFAaOCHNn0vKBL7Czw==", + "dev": true + }, + "@babel/helper-simple-access": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.18.6.tgz", + "integrity": "sha512-iNpIgTgyAvDQpDj76POqg+YEt8fPxx3yaNBg3S30dxNKm2SWfYhD0TGrK/Eu9wHpUW63VQU894TsTg+GLbUa1g==", + "dev": true, + "requires": { + "@babel/types": "^7.18.6" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.18.6.tgz", + "integrity": "sha512-bde1etTx6ZyTmobl9LLMMQsaizFVZrquTEHOqKeQESMKo4PlObf+8+JA25ZsIpZhT/WEd39+vOdLXAFG/nELpA==", + "dev": true, + "requires": { + "@babel/types": "^7.18.6" + } + }, + "@babel/helper-string-parser": { + "version": "7.18.10", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.18.10.tgz", + "integrity": "sha512-XtIfWmeNY3i4t7t4D2t02q50HvqHybPqW2ki1kosnvWCwuCMeo81Jf0gwr85jy/neUdg5XDdeFE/80DXiO+njw==", + "dev": true + }, + "@babel/helper-validator-identifier": { + "version": "7.19.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.19.1.tgz", + "integrity": "sha512-awrNfaMtnHUr653GgGEs++LlAvW6w+DcPrOliSMXWCKo597CwL5Acf/wWdNkf/tfEQE3mjkeD1YOVZOUV/od1w==", + "dev": true + }, + "@babel/helper-validator-option": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-option/-/helper-validator-option-7.18.6.tgz", + "integrity": "sha512-XO7gESt5ouv/LRJdrVjkShckw6STTaB7l9BrpBaAHDeF5YZT+01PCwmR0SJHnkW6i8OwW/EVWRShfi4j2x+KQw==", + "dev": true + }, + "@babel/helpers": { + "version": "7.19.0", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.19.0.tgz", + "integrity": "sha512-DRBCKGwIEdqY3+rPJgG/dKfQy9+08rHIAJx8q2p+HSWP87s2HCrQmaAMMyMll2kIXKCW0cO1RdQskx15Xakftg==", + "dev": true, + "requires": { + "@babel/template": "^7.18.10", + "@babel/traverse": "^7.19.0", + "@babel/types": "^7.19.0" + } + }, + "@babel/highlight": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.18.6.tgz", + "integrity": "sha512-u7stbOuYjaPezCuLj29hNW1v64M2Md2qupEKP1fHc7WdOA3DgLh37suiSrZYY7haUB7iBeQZ9P1uiRF359do3g==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.18.6", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==", + "dev": true + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "dev": true, + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, + "@babel/parser": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.19.3.tgz", + "integrity": "sha512-pJ9xOlNWHiy9+FuFP09DEAFbAn4JskgRsVcc169w2xRBC3FRGuQEwjeIMMND9L2zc0iEhO/tGv4Zq+km+hxNpQ==", + "dev": true + }, + "@babel/plugin-syntax-async-generators": { + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-async-generators/-/plugin-syntax-async-generators-7.8.4.tgz", + "integrity": "sha512-tycmZxkGfZaxhMRbXlPXuVFpdWlXpir2W4AMhSJgRKzk/eDlIXOhb2LHWoLpDF7TEHylV5zNhykX6KAgHJmTNw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-bigint": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-bigint/-/plugin-syntax-bigint-7.8.3.tgz", + "integrity": "sha512-wnTnFlG+YxQm3vDxpGE57Pj0srRU4sHE/mDkt1qv2YJJSeUAec2ma4WLUnUPeKjyrfntVwe/N6dCXpU+zL3Npg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-class-properties": { + "version": "7.12.13", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-class-properties/-/plugin-syntax-class-properties-7.12.13.tgz", + "integrity": "sha512-fm4idjKla0YahUNgFNLCB0qySdsoPiZP3iQE3rky0mBUtMZ23yDJ9SJdg6dXTSDnulOVqiF3Hgr9nbXvXTQZYA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.12.13" + } + }, + "@babel/plugin-syntax-import-meta": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-import-meta/-/plugin-syntax-import-meta-7.10.4.tgz", + "integrity": "sha512-Yqfm+XDx0+Prh3VSeEQCPU81yC+JWZ2pDPFSS4ZdpfZhp4MkFMaDC1UqseovEKwSUpnIL7+vK+Clp7bfh0iD7g==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-syntax-json-strings": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-json-strings/-/plugin-syntax-json-strings-7.8.3.tgz", + "integrity": "sha512-lY6kdGpWHvjoe2vk4WrAapEuBR69EMxZl+RoGRhrFGNYVK8mOPAW8VfbT/ZgrFbXlDNiiaxQnAtgVCZ6jv30EA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-jsx": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-jsx/-/plugin-syntax-jsx-7.18.6.tgz", + "integrity": "sha512-6mmljtAedFGTWu2p/8WIORGwy+61PLgOMPOdazc7YoJ9ZCWUyFy3A6CpPkRKLKD1ToAesxX8KGEViAiLo9N+7Q==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.18.6" + } + }, + "@babel/plugin-syntax-logical-assignment-operators": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-logical-assignment-operators/-/plugin-syntax-logical-assignment-operators-7.10.4.tgz", + "integrity": "sha512-d8waShlpFDinQ5MtvGU9xDAOzKH47+FFoney2baFIoMr952hKOLp1HR7VszoZvOsV/4+RRszNY7D17ba0te0ig==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-syntax-nullish-coalescing-operator": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-nullish-coalescing-operator/-/plugin-syntax-nullish-coalescing-operator-7.8.3.tgz", + "integrity": "sha512-aSff4zPII1u2QD7y+F8oDsz19ew4IGEJg9SVW+bqwpwtfFleiQDMdzA/R+UlWDzfnHFCxxleFT0PMIrR36XLNQ==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-numeric-separator": { + "version": "7.10.4", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-numeric-separator/-/plugin-syntax-numeric-separator-7.10.4.tgz", + "integrity": "sha512-9H6YdfkcK/uOnY/K7/aA2xpzaAgkQn37yzWUMRK7OaPOqOpGS1+n0H5hxT9AUw9EsSjPW8SVyMJwYRtWs3X3ug==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.10.4" + } + }, + "@babel/plugin-syntax-object-rest-spread": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-object-rest-spread/-/plugin-syntax-object-rest-spread-7.8.3.tgz", + "integrity": "sha512-XoqMijGZb9y3y2XskN+P1wUGiVwWZ5JmoDRwx5+3GmEplNyVM2s2Dg8ILFQm8rWM48orGy5YpI5Bl8U1y7ydlA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-optional-catch-binding": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-catch-binding/-/plugin-syntax-optional-catch-binding-7.8.3.tgz", + "integrity": "sha512-6VPD0Pc1lpTqw0aKoeRTMiB+kWhAoT24PA+ksWSBrFtl5SIRVpZlwN3NNPQjehA2E/91FV3RjLWoVTglWcSV3Q==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-optional-chaining": { + "version": "7.8.3", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-optional-chaining/-/plugin-syntax-optional-chaining-7.8.3.tgz", + "integrity": "sha512-KoK9ErH1MBlCPxV0VANkXW2/dw4vlbGDrFgz8bmUsBGYkFRcbRwMh6cIJubdPrkxRwuGdtCk0v/wPTKbQgBjkg==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.8.0" + } + }, + "@babel/plugin-syntax-top-level-await": { + "version": "7.14.5", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-top-level-await/-/plugin-syntax-top-level-await-7.14.5.tgz", + "integrity": "sha512-hx++upLv5U1rgYfwe1xBQUhRmU41NEvpUvrp8jkrSCdvGSnM5/qdRMtylJ6PG5OFkBaHkbTAKTnd3/YyESRHFw==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.14.5" + } + }, + "@babel/plugin-syntax-typescript": { + "version": "7.18.6", + "resolved": "https://registry.npmjs.org/@babel/plugin-syntax-typescript/-/plugin-syntax-typescript-7.18.6.tgz", + "integrity": "sha512-mAWAuq4rvOepWCBid55JuRNvpTNf2UGVgoz4JV0fXEKolsVZDzsa4NqCef758WZJj/GDu0gVGItjKFiClTAmZA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.18.6" + } + }, + "@babel/template": { + "version": "7.18.10", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.18.10.tgz", + "integrity": "sha512-TI+rCtooWHr3QJ27kJxfjutghu44DLnasDMwpDqCXVTal9RLp3RSYNh4NdBrRP2cQAoG9A8juOQl6P6oZG4JxA==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.18.6", + "@babel/parser": "^7.18.10", + "@babel/types": "^7.18.10" + } + }, + "@babel/traverse": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.19.3.tgz", + "integrity": "sha512-qh5yf6149zhq2sgIXmwjnsvmnNQC2iw70UFjp4olxucKrWd/dvlUsBI88VSLUsnMNF7/vnOiA+nk1+yLoCqROQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.18.6", + "@babel/generator": "^7.19.3", + "@babel/helper-environment-visitor": "^7.18.9", + "@babel/helper-function-name": "^7.19.0", + "@babel/helper-hoist-variables": "^7.18.6", + "@babel/helper-split-export-declaration": "^7.18.6", + "@babel/parser": "^7.19.3", + "@babel/types": "^7.19.3", + "debug": "^4.1.0", + "globals": "^11.1.0" + } + }, + "@babel/types": { + "version": "7.19.3", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.19.3.tgz", + "integrity": "sha512-hGCaQzIY22DJlDh9CH7NOxgKkFjBk0Cw9xDO1Xmh2151ti7wiGfQ3LauXzL4HP1fmFlTX6XjpRETTpUcv7wQLw==", + "dev": true, + "requires": { + "@babel/helper-string-parser": "^7.18.10", + "@babel/helper-validator-identifier": "^7.19.1", + "to-fast-properties": "^2.0.0" + } + }, + "@bcoe/v8-coverage": { + "version": "0.2.3", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz", + "integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==", + "dev": true + }, + "@discoveryjs/json-ext": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", + "integrity": "sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==", + "dev": true + }, + "@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "dependencies": { + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + } + } + }, + "@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true + }, + "@jest/console": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/console/-/console-29.1.2.tgz", + "integrity": "sha512-ujEBCcYs82BTmRxqfHMQggSlkUZP63AE5YEaTPj7eFyJOzukkTorstOUC7L6nE3w5SYadGVAnTsQ/ZjTGL0qYQ==", + "dev": true, + "requires": { + "@jest/types": "^29.1.2", + "@types/node": "*", + "chalk": "^4.0.0", + "jest-message-util": "^29.1.2", + "jest-util": "^29.1.2", + "slash": "^3.0.0" + } + }, + "@jest/core": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/core/-/core-29.1.2.tgz", + "integrity": "sha512-sCO2Va1gikvQU2ynDN8V4+6wB7iVrD2CvT0zaRst4rglf56yLly0NQ9nuRRAWFeimRf+tCdFsb1Vk1N9LrrMPA==", + "dev": true, + "requires": { + "@jest/console": "^29.1.2", + "@jest/reporters": "^29.1.2", + "@jest/test-result": "^29.1.2", + "@jest/transform": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "jest-changed-files": "^29.0.0", + "jest-config": "^29.1.2", + "jest-haste-map": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-regex-util": "^29.0.0", + "jest-resolve": "^29.1.2", + "jest-resolve-dependencies": "^29.1.2", + "jest-runner": "^29.1.2", + "jest-runtime": "^29.1.2", + "jest-snapshot": "^29.1.2", + "jest-util": "^29.1.2", + "jest-validate": "^29.1.2", + "jest-watcher": "^29.1.2", + "micromatch": "^4.0.4", + "pretty-format": "^29.1.2", + "slash": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "@jest/environment": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/environment/-/environment-29.1.2.tgz", + "integrity": "sha512-rG7xZ2UeOfvOVzoLIJ0ZmvPl4tBEQ2n73CZJSlzUjPw4or1oSWC0s0Rk0ZX+pIBJ04aVr6hLWFn1DFtrnf8MhQ==", + "dev": true, + "requires": { + "@jest/fake-timers": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "jest-mock": "^29.1.2" + } + }, + "@jest/expect": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/expect/-/expect-29.1.2.tgz", + "integrity": "sha512-FXw/UmaZsyfRyvZw3M6POgSNqwmuOXJuzdNiMWW9LCYo0GRoRDhg+R5iq5higmRTHQY7hx32+j7WHwinRmoILQ==", + "dev": true, + "requires": { + "expect": "^29.1.2", + "jest-snapshot": "^29.1.2" + } + }, + "@jest/expect-utils": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/expect-utils/-/expect-utils-29.1.2.tgz", + "integrity": "sha512-4a48bhKfGj/KAH39u0ppzNTABXQ8QPccWAFUFobWBaEMSMp+sB31Z2fK/l47c4a/Mu1po2ffmfAIPxXbVTXdtg==", + "dev": true, + "requires": { + "jest-get-type": "^29.0.0" + } + }, + "@jest/fake-timers": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/fake-timers/-/fake-timers-29.1.2.tgz", + "integrity": "sha512-GppaEqS+QQYegedxVMpCe2xCXxxeYwQ7RsNx55zc8f+1q1qevkZGKequfTASI7ejmg9WwI+SJCrHe9X11bLL9Q==", + "dev": true, + "requires": { + "@jest/types": "^29.1.2", + "@sinonjs/fake-timers": "^9.1.2", + "@types/node": "*", + "jest-message-util": "^29.1.2", + "jest-mock": "^29.1.2", + "jest-util": "^29.1.2" + } + }, + "@jest/globals": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/globals/-/globals-29.1.2.tgz", + "integrity": "sha512-uMgfERpJYoQmykAd0ffyMq8wignN4SvLUG6orJQRe9WAlTRc9cdpCaE/29qurXixYJVZWUqIBXhSk8v5xN1V9g==", + "dev": true, + "requires": { + "@jest/environment": "^29.1.2", + "@jest/expect": "^29.1.2", + "@jest/types": "^29.1.2", + "jest-mock": "^29.1.2" + } + }, + "@jest/reporters": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/reporters/-/reporters-29.1.2.tgz", + "integrity": "sha512-X4fiwwyxy9mnfpxL0g9DD0KcTmEIqP0jUdnc2cfa9riHy+I6Gwwp5vOZiwyg0vZxfSDxrOlK9S4+340W4d+DAA==", + "dev": true, + "requires": { + "@bcoe/v8-coverage": "^0.2.3", + "@jest/console": "^29.1.2", + "@jest/test-result": "^29.1.2", + "@jest/transform": "^29.1.2", + "@jest/types": "^29.1.2", + "@jridgewell/trace-mapping": "^0.3.15", + "@types/node": "*", + "chalk": "^4.0.0", + "collect-v8-coverage": "^1.0.0", + "exit": "^0.1.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-instrument": "^5.1.0", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.1.3", + "jest-message-util": "^29.1.2", + "jest-util": "^29.1.2", + "jest-worker": "^29.1.2", + "slash": "^3.0.0", + "string-length": "^4.0.1", + "strip-ansi": "^6.0.0", + "terminal-link": "^2.0.0", + "v8-to-istanbul": "^9.0.1" + } + }, + "@jest/schemas": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/@jest/schemas/-/schemas-29.0.0.tgz", + "integrity": "sha512-3Ab5HgYIIAnS0HjqJHQYZS+zXc4tUmTmBH3z83ajI6afXp8X3ZtdLX+nXx+I7LNkJD7uN9LAVhgnjDgZa2z0kA==", + "dev": true, + "requires": { + "@sinclair/typebox": "^0.24.1" + } + }, + "@jest/source-map": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/@jest/source-map/-/source-map-29.0.0.tgz", + "integrity": "sha512-nOr+0EM8GiHf34mq2GcJyz/gYFyLQ2INDhAylrZJ9mMWoW21mLBfZa0BUVPPMxVYrLjeiRe2Z7kWXOGnS0TFhQ==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "^0.3.15", + "callsites": "^3.0.0", + "graceful-fs": "^4.2.9" + } + }, + "@jest/test-result": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/test-result/-/test-result-29.1.2.tgz", + "integrity": "sha512-jjYYjjumCJjH9hHCoMhA8PCl1OxNeGgAoZ7yuGYILRJX9NjgzTN0pCT5qAoYR4jfOP8htIByvAlz9vfNSSBoVg==", + "dev": true, + "requires": { + "@jest/console": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/istanbul-lib-coverage": "^2.0.0", + "collect-v8-coverage": "^1.0.0" + } + }, + "@jest/test-sequencer": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/test-sequencer/-/test-sequencer-29.1.2.tgz", + "integrity": "sha512-fU6dsUqqm8sA+cd85BmeF7Gu9DsXVWFdGn9taxM6xN1cKdcP/ivSgXh5QucFRFz1oZxKv3/9DYYbq0ULly3P/Q==", + "dev": true, + "requires": { + "@jest/test-result": "^29.1.2", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.1.2", + "slash": "^3.0.0" + } + }, + "@jest/transform": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/transform/-/transform-29.1.2.tgz", + "integrity": "sha512-2uaUuVHTitmkx1tHF+eBjb4p7UuzBG7SXIaA/hNIkaMP6K+gXYGxP38ZcrofzqN0HeZ7A90oqsOa97WU7WZkSw==", + "dev": true, + "requires": { + "@babel/core": "^7.11.6", + "@jest/types": "^29.1.2", + "@jridgewell/trace-mapping": "^0.3.15", + "babel-plugin-istanbul": "^6.1.1", + "chalk": "^4.0.0", + "convert-source-map": "^1.4.0", + "fast-json-stable-stringify": "^2.1.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.1.2", + "jest-regex-util": "^29.0.0", + "jest-util": "^29.1.2", + "micromatch": "^4.0.4", + "pirates": "^4.0.4", + "slash": "^3.0.0", + "write-file-atomic": "^4.0.1" + } + }, + "@jest/types": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/@jest/types/-/types-29.1.2.tgz", + "integrity": "sha512-DcXGtoTykQB5jiwCmVr8H4vdg2OJhQex3qPkG+ISyDO7xQXbt/4R6dowcRyPemRnkH7JoHvZuxPBdlq+9JxFCg==", + "dev": true, + "requires": { + "@jest/schemas": "^29.0.0", + "@types/istanbul-lib-coverage": "^2.0.0", + "@types/istanbul-reports": "^3.0.0", + "@types/node": "*", + "@types/yargs": "^17.0.8", + "chalk": "^4.0.0" + } + }, + "@jridgewell/gen-mapping": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.1.1.tgz", + "integrity": "sha512-sQXCasFk+U8lWYEe66WxRDOE9PjVz4vSM51fTu3Hw+ClTpUSQb718772vH3pyS5pShp6lvQM7SxgIDXXXmOX7w==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.0", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "@jridgewell/resolve-uri": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz", + "integrity": "sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w==", + "dev": true + }, + "@jridgewell/set-array": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.1.2.tgz", + "integrity": "sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==", + "dev": true + }, + "@jridgewell/source-map": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.2.tgz", + "integrity": "sha512-m7O9o2uR8k2ObDysZYzdfhb08VuEml5oWGiosa1VdaPZ/A6QyPkAJuwN0Q1lhULOf6B7MtQmHENS743hWtCrgw==", + "dev": true, + "requires": { + "@jridgewell/gen-mapping": "^0.3.0", + "@jridgewell/trace-mapping": "^0.3.9" + }, + "dependencies": { + "@jridgewell/gen-mapping": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.2.tgz", + "integrity": "sha512-mh65xKQAzI6iBcFzwv28KVWSmCkdRBWoOh+bYQGW3+6OZvbbN3TqMGo5hqYxQniRcH9F2VZIoJCm4pa3BPDK/A==", + "dev": true, + "requires": { + "@jridgewell/set-array": "^1.0.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.9" + } + } + } + }, + "@jridgewell/sourcemap-codec": { + "version": "1.4.14", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz", + "integrity": "sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==", + "dev": true + }, + "@jridgewell/trace-mapping": { + "version": "0.3.15", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.15.tgz", + "integrity": "sha512-oWZNOULl+UbhsgB51uuZzglikfIKSUBO/M9W2OfEjn7cmqoAiCgmv9lyACTUacZwBz0ITnJ2NqjU8Tx0DHL88g==", + "dev": true, + "requires": { + "@jridgewell/resolve-uri": "^3.0.3", + "@jridgewell/sourcemap-codec": "^1.4.10" + } + }, + "@sinclair/typebox": { + "version": "0.24.44", + "resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.24.44.tgz", + "integrity": "sha512-ka0W0KN5i6LfrSocduwliMMpqVgohtPFidKdMEOUjoOFCHcOOYkKsPRxfs5f15oPNHTm6ERAm0GV/+/LTKeiWg==", + "dev": true + }, + "@sinonjs/commons": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.8.3.tgz", + "integrity": "sha512-xkNcLAn/wZaX14RPlwizcKicDk9G3F8m2nU3L7Ukm5zBgTwiT0wsoFAHx9Jq56fJA1z/7uKGtCRu16sOUCLIHQ==", + "dev": true, + "requires": { + "type-detect": "4.0.8" + } + }, + "@sinonjs/fake-timers": { + "version": "9.1.2", + "resolved": "https://registry.npmjs.org/@sinonjs/fake-timers/-/fake-timers-9.1.2.tgz", + "integrity": "sha512-BPS4ynJW/o92PUR4wgriz2Ud5gpST5vz6GQfMixEDK0Z8ZCUv2M7SkBLykH56T++Xs+8ln9zTGbOvNGIe02/jw==", + "dev": true, + "requires": { + "@sinonjs/commons": "^1.7.0" + } + }, + "@types/babel__core": { + "version": "7.1.19", + "resolved": "https://registry.npmjs.org/@types/babel__core/-/babel__core-7.1.19.tgz", + "integrity": "sha512-WEOTgRsbYkvA/KCsDwVEGkd7WAr1e3g31VHQ8zy5gul/V1qKullU/BU5I68X5v7V3GnB9eotmom4v5a5gjxorw==", + "dev": true, + "requires": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0", + "@types/babel__generator": "*", + "@types/babel__template": "*", + "@types/babel__traverse": "*" + } + }, + "@types/babel__generator": { + "version": "7.6.4", + "resolved": "https://registry.npmjs.org/@types/babel__generator/-/babel__generator-7.6.4.tgz", + "integrity": "sha512-tFkciB9j2K755yrTALxD44McOrk+gfpIpvC3sxHjRawj6PfnQxrse4Clq5y/Rq+G3mrBurMax/lG8Qn2t9mSsg==", + "dev": true, + "requires": { + "@babel/types": "^7.0.0" + } + }, + "@types/babel__template": { + "version": "7.4.1", + "resolved": "https://registry.npmjs.org/@types/babel__template/-/babel__template-7.4.1.tgz", + "integrity": "sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==", + "dev": true, + "requires": { + "@babel/parser": "^7.1.0", + "@babel/types": "^7.0.0" + } + }, + "@types/babel__traverse": { + "version": "7.18.2", + "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.18.2.tgz", + "integrity": "sha512-FcFaxOr2V5KZCviw1TnutEMVUVsGt4D2hP1TAfXZAMKuHYW3xQhe3jTxNPWutgCJ3/X1c5yX8ZoGVEItxKbwBg==", + "dev": true, + "requires": { + "@babel/types": "^7.3.0" + } + }, + "@types/eslint": { + "version": "8.4.6", + "resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-8.4.6.tgz", + "integrity": "sha512-/fqTbjxyFUaYNO7VcW5g+4npmqVACz1bB7RTHYuLj+PRjw9hrCwrUXVQFpChUS0JsyEFvMZ7U/PfmvWgxJhI9g==", + "dev": true, + "requires": { + "@types/estree": "*", + "@types/json-schema": "*" + } + }, + "@types/eslint-scope": { + "version": "3.7.4", + "resolved": "https://registry.npmjs.org/@types/eslint-scope/-/eslint-scope-3.7.4.tgz", + "integrity": "sha512-9K4zoImiZc3HlIp6AVUDE4CWYx22a+lhSZMYNpbjW04+YF0KWj4pJXnEMjdnFTiQibFFmElcsasJXDbdI/EPhA==", + "dev": true, + "requires": { + "@types/eslint": "*", + "@types/estree": "*" + } + }, + "@types/estree": { + "version": "0.0.51", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.51.tgz", + "integrity": "sha512-CuPgU6f3eT/XgKKPqKd/gLZV1Xmvf1a2R5POBOGQa6uv82xpls89HU5zKeVoyR8XzHd1RGNOlQlvUe3CFkjWNQ==", + "dev": true + }, + "@types/graceful-fs": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.5.tgz", + "integrity": "sha512-anKkLmZZ+xm4p8JWBf4hElkM4XR+EZeA2M9BAkkTldmcyDY4mbdIJnRghDJH3Ov5ooY7/UAoENtmdMSkaAd7Cw==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, + "@types/istanbul-lib-coverage": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", + "integrity": "sha512-z/QT1XN4K4KYuslS23k62yDIDLwLFkzxOuMplDtObz0+y7VqJCaO2o+SPwHCvLFZh7xazvvoor2tA/hPz9ee7g==", + "dev": true + }, + "@types/istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@types/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-plGgXAPfVKFoYfa9NpYDAkseG+g6Jr294RqeqcqDixSbU34MZVJRi/P+7Y8GDpzkEwLaGZZOpKIEmeVZNtKsrg==", + "dev": true, + "requires": { + "@types/istanbul-lib-coverage": "*" + } + }, + "@types/istanbul-reports": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/@types/istanbul-reports/-/istanbul-reports-3.0.1.tgz", + "integrity": "sha512-c3mAZEuK0lvBp8tmuL74XRKn1+y2dcwOUpH7x4WrF6gk1GIgiluDRgMYQtw2OFcBvAJWlt6ASU3tSqxp0Uu0Aw==", + "dev": true, + "requires": { + "@types/istanbul-lib-report": "*" + } + }, + "@types/jest": { + "version": "29.1.1", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.1.1.tgz", + "integrity": "sha512-U9Ey07dGWl6fUFaIaUQUKWG5NoKi/zizeVQCGV8s4nSU0jPgqphVZvS64+8BtWYvrc3ZGw6wo943NSYPxkrp/g==", + "dev": true, + "requires": { + "expect": "^29.0.0", + "pretty-format": "^29.0.0" + } + }, + "@types/json-schema": { + "version": "7.0.11", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.11.tgz", + "integrity": "sha512-wOuvG1SN4Us4rez+tylwwwCV1psiNVOkJeM3AUWUNWg/jDQY2+HE/444y5gc+jBmRqASOm2Oeh5c1axHobwRKQ==", + "dev": true + }, + "@types/node": { + "version": "18.7.23", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.7.23.tgz", + "integrity": "sha512-DWNcCHolDq0ZKGizjx2DZjR/PqsYwAcYUJmfMWqtVU2MBMG5Mo+xFZrhGId5r/O5HOuMPyQEcM6KUBp5lBZZBg==", + "dev": true + }, + "@types/prettier": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/@types/prettier/-/prettier-2.7.1.tgz", + "integrity": "sha512-ri0UmynRRvZiiUJdiz38MmIblKK+oH30MztdBVR95dv/Ubw6neWSb8u1XpRb72L4qsZOhz+L+z9JD40SJmfWow==", + "dev": true + }, + "@types/stack-utils": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-2.0.1.tgz", + "integrity": "sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==", + "dev": true + }, + "@types/yargs": { + "version": "17.0.13", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.13.tgz", + "integrity": "sha512-9sWaruZk2JGxIQU+IhI1fhPYRcQ0UuTNuKuCW9bR5fp7qi2Llf7WDzNa17Cy7TKnh3cdxDOiyTu6gaLS0eDatg==", + "dev": true, + "requires": { + "@types/yargs-parser": "*" + } + }, + "@types/yargs-parser": { + "version": "21.0.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-21.0.0.tgz", + "integrity": "sha512-iO9ZQHkZxHn4mSakYV0vFHAVDyEOIJQrV2uZ06HxEPcx+mt8swXoZHIbaaJ2crJYFfErySgktuTZ3BeLz+XmFA==", + "dev": true + }, + "@webassemblyjs/ast": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.11.1.tgz", + "integrity": "sha512-ukBh14qFLjxTQNTXocdyksN5QdM28S1CxHt2rdskFyL+xFV7VremuBLVbmCePj+URalXBENx/9Lm7lnhihtCSw==", + "dev": true, + "requires": { + "@webassemblyjs/helper-numbers": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1" + } + }, + "@webassemblyjs/floating-point-hex-parser": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.11.1.tgz", + "integrity": "sha512-iGRfyc5Bq+NnNuX8b5hwBrRjzf0ocrJPI6GWFodBFzmFnyvrQ83SHKhmilCU/8Jv67i4GJZBMhEzltxzcNagtQ==", + "dev": true + }, + "@webassemblyjs/helper-api-error": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-api-error/-/helper-api-error-1.11.1.tgz", + "integrity": "sha512-RlhS8CBCXfRUR/cwo2ho9bkheSXG0+NwooXcc3PAILALf2QLdFyj7KGsKRbVc95hZnhnERon4kW/D3SZpp6Tcg==", + "dev": true + }, + "@webassemblyjs/helper-buffer": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-buffer/-/helper-buffer-1.11.1.tgz", + "integrity": "sha512-gwikF65aDNeeXa8JxXa2BAk+REjSyhrNC9ZwdT0f8jc4dQQeDQ7G4m0f2QCLPJiMTTO6wfDmRmj/pW0PsUvIcA==", + "dev": true + }, + "@webassemblyjs/helper-numbers": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-numbers/-/helper-numbers-1.11.1.tgz", + "integrity": "sha512-vDkbxiB8zfnPdNK9Rajcey5C0w+QJugEglN0of+kmO8l7lDb77AnlKYQF7aarZuCrv+l0UvqL+68gSDr3k9LPQ==", + "dev": true, + "requires": { + "@webassemblyjs/floating-point-hex-parser": "1.11.1", + "@webassemblyjs/helper-api-error": "1.11.1", + "@xtuc/long": "4.2.2" + } + }, + "@webassemblyjs/helper-wasm-bytecode": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.11.1.tgz", + "integrity": "sha512-PvpoOGiJwXeTrSf/qfudJhwlvDQxFgelbMqtq52WWiXC6Xgg1IREdngmPN3bs4RoO83PnL/nFrxucXj1+BX62Q==", + "dev": true + }, + "@webassemblyjs/helper-wasm-section": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.11.1.tgz", + "integrity": "sha512-10P9No29rYX1j7F3EVPX3JvGPQPae+AomuSTPiF9eBQeChHI6iqjMIwR9JmOJXwpnn/oVGDk7I5IlskuMwU/pg==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1" + } + }, + "@webassemblyjs/ieee754": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/ieee754/-/ieee754-1.11.1.tgz", + "integrity": "sha512-hJ87QIPtAMKbFq6CGTkZYJivEwZDbQUgYd3qKSadTNOhVY7p+gfP6Sr0lLRVTaG1JjFj+r3YchoqRYxNH3M0GQ==", + "dev": true, + "requires": { + "@xtuc/ieee754": "^1.2.0" + } + }, + "@webassemblyjs/leb128": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/leb128/-/leb128-1.11.1.tgz", + "integrity": "sha512-BJ2P0hNZ0u+Th1YZXJpzW6miwqQUGcIHT1G/sf72gLVD9DZ5AdYTqPNbHZh6K1M5VmKvFXwGSWZADz+qBWxeRw==", + "dev": true, + "requires": { + "@xtuc/long": "4.2.2" + } + }, + "@webassemblyjs/utf8": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/utf8/-/utf8-1.11.1.tgz", + "integrity": "sha512-9kqcxAEdMhiwQkHpkNiorZzqpGrodQQ2IGrHHxCy+Ozng0ofyMA0lTqiLkVs1uzTRejX+/O0EOT7KxqVPuXosQ==", + "dev": true + }, + "@webassemblyjs/wasm-edit": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-edit/-/wasm-edit-1.11.1.tgz", + "integrity": "sha512-g+RsupUC1aTHfR8CDgnsVRVZFJqdkFHpsHMfJuWQzWU3tvnLC07UqHICfP+4XyL2tnr1amvl1Sdp06TnYCmVkA==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/helper-wasm-section": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1", + "@webassemblyjs/wasm-opt": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1", + "@webassemblyjs/wast-printer": "1.11.1" + } + }, + "@webassemblyjs/wasm-gen": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-gen/-/wasm-gen-1.11.1.tgz", + "integrity": "sha512-F7QqKXwwNlMmsulj6+O7r4mmtAlCWfO/0HdgOxSklZfQcDu0TpLiD1mRt/zF25Bk59FIjEuGAIyn5ei4yMfLhA==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/ieee754": "1.11.1", + "@webassemblyjs/leb128": "1.11.1", + "@webassemblyjs/utf8": "1.11.1" + } + }, + "@webassemblyjs/wasm-opt": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-opt/-/wasm-opt-1.11.1.tgz", + "integrity": "sha512-VqnkNqnZlU5EB64pp1l7hdm3hmQw7Vgqa0KF/KCNO9sIpI6Fk6brDEiX+iCOYrvMuBWDws0NkTOxYEb85XQHHw==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-buffer": "1.11.1", + "@webassemblyjs/wasm-gen": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1" + } + }, + "@webassemblyjs/wasm-parser": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wasm-parser/-/wasm-parser-1.11.1.tgz", + "integrity": "sha512-rrBujw+dJu32gYB7/Lup6UhdkPx9S9SnobZzRVL7VcBH9Bt9bCBLEuX/YXOOtBsOZ4NQrRykKhffRWHvigQvOA==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/helper-api-error": "1.11.1", + "@webassemblyjs/helper-wasm-bytecode": "1.11.1", + "@webassemblyjs/ieee754": "1.11.1", + "@webassemblyjs/leb128": "1.11.1", + "@webassemblyjs/utf8": "1.11.1" + } + }, + "@webassemblyjs/wast-printer": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/@webassemblyjs/wast-printer/-/wast-printer-1.11.1.tgz", + "integrity": "sha512-IQboUWM4eKzWW+N/jij2sRatKMh99QEelo3Eb2q0qXkvPRISAj8Qxtmw5itwqK+TTkBuUIE45AxYPToqPtL5gg==", + "dev": true, + "requires": { + "@webassemblyjs/ast": "1.11.1", + "@xtuc/long": "4.2.2" + } + }, + "@webpack-cli/configtest": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/configtest/-/configtest-1.2.0.tgz", + "integrity": "sha512-4FB8Tj6xyVkyqjj1OaTqCjXYULB9FMkqQ8yGrZjRDrYh0nOE+7Lhs45WioWQQMV+ceFlE368Ukhe6xdvJM9Egg==", + "dev": true, + "requires": {} + }, + "@webpack-cli/info": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/info/-/info-1.5.0.tgz", + "integrity": "sha512-e8tSXZpw2hPl2uMJY6fsMswaok5FdlGNRTktvFk2sD8RjH0hE2+XistawJx1vmKteh4NmGmNUrp+Tb2w+udPcQ==", + "dev": true, + "requires": { + "envinfo": "^7.7.3" + } + }, + "@webpack-cli/serve": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/@webpack-cli/serve/-/serve-1.7.0.tgz", + "integrity": "sha512-oxnCNGj88fL+xzV+dacXs44HcDwf1ovs3AuEzvP7mqXw7fQntqIhQ1BRmynh4qEKQSSSRSWVyXRjmTbZIX9V2Q==", + "dev": true, + "requires": {} + }, + "@xtuc/ieee754": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@xtuc/ieee754/-/ieee754-1.2.0.tgz", + "integrity": "sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA==", + "dev": true + }, + "@xtuc/long": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@xtuc/long/-/long-4.2.2.tgz", + "integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==", + "dev": true + }, + "acorn": { + "version": "8.8.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.0.tgz", + "integrity": "sha512-QOxyigPVrpZ2GXT+PFyZTl6TtOFc5egxHIP9IlQ+RbupQuX4RkT/Bee4/kQuC02Xkzg84JcT7oLYtDIQxp+v7w==", + "dev": true + }, + "acorn-import-assertions": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/acorn-import-assertions/-/acorn-import-assertions-1.8.0.tgz", + "integrity": "sha512-m7VZ3jwz4eK6A4Vtt8Ew1/mNbP24u0FhdyfA7fSvnJR6LMdfOYnmuIrrJAgrYfYJ10F/otaHTtrtrtmHdMNzEw==", + "dev": true, + "requires": {} + }, + "ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "requires": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + } + }, + "ajv-keywords": { + "version": "3.5.2", + "resolved": "https://registry.npmjs.org/ajv-keywords/-/ajv-keywords-3.5.2.tgz", + "integrity": "sha512-5p6WTN0DdTGVQk6VjcEju19IgaHudalcfabD7yhDGeA6bcQnmL+CpveLJq/3hvfwd1aof6L386Ougkx6RfyMIQ==", + "dev": true, + "requires": {} + }, + "ansi-escapes": { + "version": "4.3.2", + "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", + "integrity": "sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==", + "dev": true, + "requires": { + "type-fest": "^0.21.3" + } + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "anymatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", + "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", + "dev": true, + "requires": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + } + }, + "argparse": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", + "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, + "requires": { + "sprintf-js": "~1.0.2" + } + }, + "assert": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/assert/-/assert-2.0.0.tgz", + "integrity": "sha512-se5Cd+js9dXJnu6Ag2JFc00t+HmHOen+8Q+L7O9zI0PqQXr20uk2J0XQqMxZEeo5U50o8Nvmmx7dZrl+Ufr35A==", + "requires": { + "es6-object-assign": "^1.1.0", + "is-nan": "^1.2.1", + "object-is": "^1.0.1", + "util": "^0.12.0" + } + }, + "available-typed-arrays": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.5.tgz", + "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==" + }, + "babel-jest": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.1.2.tgz", + "integrity": "sha512-IuG+F3HTHryJb7gacC7SQ59A9kO56BctUsT67uJHp1mMCHUOMXpDwOHWGifWqdWVknN2WNkCVQELPjXx0aLJ9Q==", + "dev": true, + "requires": { + "@jest/transform": "^29.1.2", + "@types/babel__core": "^7.1.14", + "babel-plugin-istanbul": "^6.1.1", + "babel-preset-jest": "^29.0.2", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "slash": "^3.0.0" + } + }, + "babel-plugin-istanbul": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/babel-plugin-istanbul/-/babel-plugin-istanbul-6.1.1.tgz", + "integrity": "sha512-Y1IQok9821cC9onCx5otgFfRm7Lm+I+wwxOx738M/WLPZ9Q42m4IG5W0FNX8WLL2gYMZo3JkuXIH2DOpWM+qwA==", + "dev": true, + "requires": { + "@babel/helper-plugin-utils": "^7.0.0", + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-instrument": "^5.0.4", + "test-exclude": "^6.0.0" + } + }, + "babel-plugin-jest-hoist": { + "version": "29.0.2", + "resolved": "https://registry.npmjs.org/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-29.0.2.tgz", + "integrity": "sha512-eBr2ynAEFjcebVvu8Ktx580BD1QKCrBG1XwEUTXJe285p9HA/4hOhfWCFRQhTKSyBV0VzjhG7H91Eifz9s29hg==", + "dev": true, + "requires": { + "@babel/template": "^7.3.3", + "@babel/types": "^7.3.3", + "@types/babel__core": "^7.1.14", + "@types/babel__traverse": "^7.0.6" + } + }, + "babel-preset-current-node-syntax": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/babel-preset-current-node-syntax/-/babel-preset-current-node-syntax-1.0.1.tgz", + "integrity": "sha512-M7LQ0bxarkxQoN+vz5aJPsLBn77n8QgTFmo8WK0/44auK2xlCXrYcUxHFxgU7qW5Yzw/CjmLRK2uJzaCd7LvqQ==", + "dev": true, + "requires": { + "@babel/plugin-syntax-async-generators": "^7.8.4", + "@babel/plugin-syntax-bigint": "^7.8.3", + "@babel/plugin-syntax-class-properties": "^7.8.3", + "@babel/plugin-syntax-import-meta": "^7.8.3", + "@babel/plugin-syntax-json-strings": "^7.8.3", + "@babel/plugin-syntax-logical-assignment-operators": "^7.8.3", + "@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.3", + "@babel/plugin-syntax-numeric-separator": "^7.8.3", + "@babel/plugin-syntax-object-rest-spread": "^7.8.3", + "@babel/plugin-syntax-optional-catch-binding": "^7.8.3", + "@babel/plugin-syntax-optional-chaining": "^7.8.3", + "@babel/plugin-syntax-top-level-await": "^7.8.3" + } + }, + "babel-preset-jest": { + "version": "29.0.2", + "resolved": "https://registry.npmjs.org/babel-preset-jest/-/babel-preset-jest-29.0.2.tgz", + "integrity": "sha512-BeVXp7rH5TK96ofyEnHjznjLMQ2nAeDJ+QzxKnHAAMs0RgrQsCywjAN8m4mOm5Di0pxU//3AoEeJJrerMH5UeA==", + "dev": true, + "requires": { + "babel-plugin-jest-hoist": "^29.0.2", + "babel-preset-current-node-syntax": "^1.0.0" + } + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "braces": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", + "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "dev": true, + "requires": { + "fill-range": "^7.0.1" + } + }, + "browserslist": { + "version": "4.21.4", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.21.4.tgz", + "integrity": "sha512-CBHJJdDmgjl3daYjN5Cp5kbTf1mUhZoS+beLklHIvkOWscs83YAhLlF3Wsh/lciQYAcbBJgTOD44VtG31ZM4Hw==", + "dev": true, + "requires": { + "caniuse-lite": "^1.0.30001400", + "electron-to-chromium": "^1.4.251", + "node-releases": "^2.0.6", + "update-browserslist-db": "^1.0.9" + } + }, + "bs-logger": { + "version": "0.2.6", + "resolved": "https://registry.npmjs.org/bs-logger/-/bs-logger-0.2.6.tgz", + "integrity": "sha512-pd8DCoxmbgc7hyPKOvxtqNcjYoOsABPQdcCUjGp3d42VR2CX1ORhk2A87oqqu5R1kk+76nsxZupkmyd+MVtCog==", + "dev": true, + "requires": { + "fast-json-stable-stringify": "2.x" + } + }, + "bser": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/bser/-/bser-2.1.1.tgz", + "integrity": "sha512-gQxTNE/GAfIIrmHLUE3oJyp5FO6HRBfhjnw4/wMmA63ZGDJnWBmgY/lyQBpnDUkGmAhbSe39tx2d/iTOAfglwQ==", + "dev": true, + "requires": { + "node-int64": "^0.4.0" + } + }, + "buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" + }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, + "callsites": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", + "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", + "dev": true + }, + "caniuse-lite": { + "version": "1.0.30001415", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001415.tgz", + "integrity": "sha512-ER+PfgCJUe8BqunLGWd/1EY4g8AzQcsDAVzdtMGKVtQEmKAwaFfU6vb7EAVIqTMYsqxBorYZi2+22Iouj/y7GQ==", + "dev": true + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "char-regex": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/char-regex/-/char-regex-1.0.2.tgz", + "integrity": "sha512-kWWXztvZ5SBQV+eRgKFeh8q5sLuZY2+8WUIzlxWVTg+oGwY14qylx1KbKzHd8P6ZYkAg0xyIDU9JMHhyJMZ1jw==", + "dev": true + }, + "chrome-trace-event": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/chrome-trace-event/-/chrome-trace-event-1.0.3.tgz", + "integrity": "sha512-p3KULyQg4S7NIHixdwbGX+nFHkoBiA4YQmyWtjb8XngSKV124nJmRysgAeujbUVb15vh+RvFUfCPqU7rXk+hZg==", + "dev": true + }, + "ci-info": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-3.4.0.tgz", + "integrity": "sha512-t5QdPT5jq3o262DOQ8zA6E1tlH2upmUc4Hlvrbx1pGYJuiiHl7O7rvVNI+l8HTVhd/q3Qc9vqimkNk5yiXsAug==", + "dev": true + }, + "cjs-module-lexer": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/cjs-module-lexer/-/cjs-module-lexer-1.2.2.tgz", + "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", + "dev": true + }, + "clone-deep": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz", + "integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==", + "dev": true, + "requires": { + "is-plain-object": "^2.0.4", + "kind-of": "^6.0.2", + "shallow-clone": "^3.0.0" + } + }, + "co": { + "version": "4.6.0", + "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", + "integrity": "sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==", + "dev": true + }, + "collect-v8-coverage": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz", + "integrity": "sha512-iBPtljfCNcTKNAto0KEtDfZ3qzjJvqE3aTGZsbhjSBlorqpXJlaWWtPO35D+ZImoC3KWejX64o+yPGxhWSTzfg==", + "dev": true + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "colorette": { + "version": "2.0.19", + "resolved": "https://registry.npmjs.org/colorette/-/colorette-2.0.19.tgz", + "integrity": "sha512-3tlv/dIP7FWvj3BsbHrGLJ6l/oKh1O3TcgBqMn+yyCagOxc23fyzDS6HypQbgxWbkpDnf52p1LuR4eWDQ/K9WQ==", + "dev": true + }, + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", + "dev": true + }, + "console-browserify": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.2.0.tgz", + "integrity": "sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA==" + }, + "convert-source-map": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.8.0.tgz", + "integrity": "sha512-+OQdjP49zViI/6i7nIJpA8rAl4sV/JdPfU9nZs3VqOwGIgizICvuN2ru6fMd+4llL0tar18UYJXfZ/TWtmhUjA==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", + "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==", + "dev": true + } + } + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dev": true, + "requires": { + "ms": "2.1.2" + } + }, + "dedent": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz", + "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==", + "dev": true + }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true + }, + "define-properties": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.4.tgz", + "integrity": "sha512-uckOqKcfaVvtBdsVkdPv3XjveQJsNQqmhXgRi8uhvWWuPYZCNlzT8qAyblUgNoXdHdjMTzAqeGjAoli8f+bzPA==", + "requires": { + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + } + }, + "detect-newline": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz", + "integrity": "sha512-TLz+x/vEXm/Y7P7wn1EJFNLxYpUD4TgMosxY6fAVJUnJMbupHBOncxyWUG9OpTaH9EBD7uFI5LfEgmMOc54DsA==", + "dev": true + }, + "diff-sequences": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.0.0.tgz", + "integrity": "sha512-7Qe/zd1wxSDL4D/X/FPjOMB+ZMDt71W94KYaq05I2l0oQqgXgs7s4ftYYmV38gBSrPz2vcygxfs1xn0FT+rKNA==", + "dev": true + }, + "electron-to-chromium": { + "version": "1.4.271", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.271.tgz", + "integrity": "sha512-BCPBtK07xR1/uY2HFDtl3wK2De66AW4MSiPlLrnPNxKC/Qhccxd59W73654S3y6Rb/k3hmuGJOBnhjfoutetXA==", + "dev": true + }, + "emittery": { + "version": "0.10.2", + "resolved": "https://registry.npmjs.org/emittery/-/emittery-0.10.2.tgz", + "integrity": "sha512-aITqOwnLanpHLNXZJENbOgjUBeHocD+xsSJmNrjovKBW5HbSpW3d1pEls7GFQPUWXiwG9+0P4GtHfEqC/4M0Iw==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "enhanced-resolve": { + "version": "5.10.0", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.10.0.tgz", + "integrity": "sha512-T0yTFjdpldGY8PmuXXR0PyQ1ufZpEGiHVrp7zHKB7jdR4qlmZHhONVM5AQOAWXuF/w3dnHbEQVrNptJgt7F+cQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.2.4", + "tapable": "^2.2.0" + } + }, + "envinfo": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/envinfo/-/envinfo-7.8.1.tgz", + "integrity": "sha512-/o+BXHmB7ocbHEAs6F2EnG0ogybVVUdkRunTT2glZU9XAaGmhqskrvKwqXuDfNjEO0LZKWdejEEpnq8aM0tOaw==", + "dev": true + }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, + "es-module-lexer": { + "version": "0.9.3", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-0.9.3.tgz", + "integrity": "sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==", + "dev": true + }, + "es6-object-assign": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/es6-object-assign/-/es6-object-assign-1.1.0.tgz", + "integrity": "sha512-MEl9uirslVwqQU369iHNWZXsI8yaZYGg/D65aOgZkeyFJwHYSxilf7rQzXKI7DdDuBPrBXbfk3sl9hJhmd5AUw==" + }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true + }, + "escape-string-regexp": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-2.0.0.tgz", + "integrity": "sha512-UpzcLCXolUWcNu5HtVMHYdXJjArjsF9C0aNnquZYY4uW/Vu0miy5YoWvbV345HauVvcAUnpRuhMMcqTcGOY2+w==", + "dev": true + }, + "eslint-scope": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz", + "integrity": "sha512-2NxwbF/hZ0KpepYN0cNbo+FN6XoK7GaHlQhgx/hIZl6Va0bF45RQOOwhLIy8lQDbuCiadSLCBnH2CFYquit5bw==", + "dev": true, + "requires": { + "esrecurse": "^4.3.0", + "estraverse": "^4.1.1" + } + }, + "esprima": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", + "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", + "dev": true + }, + "esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "requires": { + "estraverse": "^5.2.0" + }, + "dependencies": { + "estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true + } + } + }, + "estraverse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-4.3.0.tgz", + "integrity": "sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw==", + "dev": true + }, + "events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "dev": true + }, + "execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + } + }, + "exit": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", + "integrity": "sha512-Zk/eNKV2zbjpKzrsQ+n1G6poVbErQxJ0LBOJXaKZ1EViLzH+hrLu9cdXI4zw9dBQJslwBEpbQ2P1oS7nDxs6jQ==", + "dev": true + }, + "expect": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/expect/-/expect-29.1.2.tgz", + "integrity": "sha512-AuAGn1uxva5YBbBlXb+2JPxJRuemZsmlGcapPXWNSBNsQtAULfjioREGBWuI0EOvYUKjDnrCy8PW5Zlr1md5mw==", + "dev": true, + "requires": { + "@jest/expect-utils": "^29.1.2", + "jest-get-type": "^29.0.0", + "jest-matcher-utils": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-util": "^29.1.2" + } + }, + "fast-deep-equal": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", + "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", + "dev": true + }, + "fast-json-stable-stringify": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", + "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==", + "dev": true + }, + "fastest-levenshtein": { + "version": "1.0.16", + "resolved": "https://registry.npmjs.org/fastest-levenshtein/-/fastest-levenshtein-1.0.16.tgz", + "integrity": "sha512-eRnCtTTtGZFpQCwhJiUOuxPQWRXVKYDn0b2PeHfXL6/Zi53SLAzAHfVhVWK2AryC/WH05kGfxhFIPvTF0SXQzg==", + "dev": true + }, + "fb-watchman": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", + "integrity": "sha512-p5161BqbuCaSnB8jIbzQHOlpgsPmK5rJVDfDKO91Axs5NC1uu3HRQm6wt9cd9/+GtQQIO53JdGXXoyDpTAsgYA==", + "dev": true, + "requires": { + "bser": "2.1.1" + } + }, + "fill-range": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", + "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", + "dev": true, + "requires": { + "to-regex-range": "^5.0.1" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "for-each": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz", + "integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==", + "requires": { + "is-callable": "^1.1.3" + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", + "dev": true + }, + "fsevents": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", + "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "dev": true, + "optional": true + }, + "function-bind": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" + }, + "gensync": { + "version": "1.0.0-beta.2", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz", + "integrity": "sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==", + "dev": true + }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", + "dev": true + }, + "get-intrinsic": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.3.tgz", + "integrity": "sha512-QJVz1Tj7MS099PevUG5jvnt9tSkXN8K14dxQlikJuPt4uD9hHAHjLyLBiLR5zELelBdD9QNRAXZzsJx0WaDL9A==", + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.3" + } + }, + "get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true + }, + "get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true + }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", + "dev": true + }, + "globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true + }, + "gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "requires": { + "get-intrinsic": "^1.1.3" + } + }, + "graceful-fs": { + "version": "4.2.10", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.10.tgz", + "integrity": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", + "dev": true + }, + "graphql": { + "version": "16.6.0", + "resolved": "https://registry.npmjs.org/graphql/-/graphql-16.6.0.tgz", + "integrity": "sha512-KPIBPDlW7NxrbT/eh4qPXz5FiFdL5UbaA0XUNz2Rp3Z3hqBSkbj0GVjwFDztsWVauZUWsbKHgMg++sk8UX0bkw==" + }, + "has": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", + "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", + "requires": { + "function-bind": "^1.1.1" + } + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==" + }, + "has-property-descriptors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.0.tgz", + "integrity": "sha512-62DVLZGoiEBDHQyqG4w9xCuZ7eJEwNmJRWw2VY84Oedb7WFcA27fiEVe8oUQx9hAUJ4ekurquucTGwsyO1XGdQ==", + "requires": { + "get-intrinsic": "^1.1.1" + } + }, + "has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" + }, + "has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "requires": { + "has-symbols": "^1.0.2" + } + }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, + "human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true + }, + "import-local": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.1.0.tgz", + "integrity": "sha512-ASB07uLtnDs1o6EHjKpX34BKYDSqnFerfTOJL2HvMqF70LnxpjkzDB8J44oT9pu4AMPkQwf8jl6szgvNd2tRIg==", + "dev": true, + "requires": { + "pkg-dir": "^4.2.0", + "resolve-cwd": "^3.0.0" + } + }, + "imurmurhash": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", + "integrity": "sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "interpret": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/interpret/-/interpret-2.2.0.tgz", + "integrity": "sha512-Ju0Bz/cEia55xDwUWEa8+olFpCiQoypjnQySseKtmjNrnps3P+xfpUmGr90T7yjlVJmOtybRvPXhKMbHr+fWnw==", + "dev": true + }, + "is-arguments": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-arguments/-/is-arguments-1.1.1.tgz", + "integrity": "sha512-8Q7EARjzEnKpt/PCD7e1cgUS0a6X8u5tdSiMqXhojOdoV9TsMsiO+9VLC5vAmO8N7/GmXn7yjR8qnA6bVAEzfA==", + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true + }, + "is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==" + }, + "is-core-module": { + "version": "2.10.0", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.10.0.tgz", + "integrity": "sha512-Erxj2n/LDAZ7H8WNJXd9tw38GYM3dv8rk8Zcs+jJuxYTW7sozH+SS8NtrSjVL1/vpLvWi1hxy96IzjJ3EHTJJg==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "is-generator-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-2.1.0.tgz", + "integrity": "sha512-cTIB4yPYL/Grw0EaSzASzg6bBy9gqCofvWN8okThAYIxKJZC+udlRAmGbM0XLeniEJSs8uEgHPGuHSe1XsOLSQ==", + "dev": true + }, + "is-generator-function": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.0.10.tgz", + "integrity": "sha512-jsEjy9l3yiXEQ+PsXdmBwEPcOxaXWLspKdplFUVI9vq1iZgIekeC0L167qeu86czQaxed3q/Uzuw0swL0irL8A==", + "requires": { + "has-tostringtag": "^1.0.0" + } + }, + "is-nan": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/is-nan/-/is-nan-1.3.2.tgz", + "integrity": "sha512-E+zBKpQ2t6MEo1VsonYmluk9NxGrbzpeeLC2xIViuO2EjU2xsXsBPwTr3Ykv9l08UYEVEdWeRZNouaZqF6RN0w==", + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3" + } + }, + "is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true + }, + "is-plain-object": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", + "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", + "dev": true, + "requires": { + "isobject": "^3.0.1" + } + }, + "is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true + }, + "is-typed-array": { + "version": "1.1.10", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.10.tgz", + "integrity": "sha512-PJqgEHiWZvMpaFZ3uTc8kHPM4+4ADTlDniuQL7cU/UDA0Ql7F70yGfHph3cLNe+c9toaigv+DFzTJKhc2CtO6A==", + "requires": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0" + } + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true + }, + "isobject": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", + "integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==", + "dev": true + }, + "istanbul-lib-coverage": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.0.tgz", + "integrity": "sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==", + "dev": true + }, + "istanbul-lib-instrument": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-5.2.0.tgz", + "integrity": "sha512-6Lthe1hqXHBNsqvgDzGO6l03XNeu3CrG4RqQ1KM9+l5+jNGpEJfIELx1NS3SEHmJQA8np/u+E4EPRKRiu6m19A==", + "dev": true, + "requires": { + "@babel/core": "^7.12.3", + "@babel/parser": "^7.14.7", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.2.0", + "semver": "^6.3.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + } + }, + "istanbul-lib-source-maps": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.1.tgz", + "integrity": "sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + } + }, + "istanbul-reports": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.5.tgz", + "integrity": "sha512-nUsEMa9pBt/NOHqbcbeJEgqIlY/K7rVWUX6Lql2orY5e9roQOthbR3vtY4zzf2orPELg80fnxxk9zUyPlgwD1w==", + "dev": true, + "requires": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + } + }, + "jest": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest/-/jest-29.1.2.tgz", + "integrity": "sha512-5wEIPpCezgORnqf+rCaYD1SK+mNN7NsstWzIsuvsnrhR/hSxXWd82oI7DkrbJ+XTD28/eG8SmxdGvukrGGK6Tw==", + "dev": true, + "requires": { + "@jest/core": "^29.1.2", + "@jest/types": "^29.1.2", + "import-local": "^3.0.2", + "jest-cli": "^29.1.2" + } + }, + "jest-changed-files": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/jest-changed-files/-/jest-changed-files-29.0.0.tgz", + "integrity": "sha512-28/iDMDrUpGoCitTURuDqUzWQoWmOmOKOFST1mi2lwh62X4BFf6khgH3uSuo1e49X/UDjuApAj3w0wLOex4VPQ==", + "dev": true, + "requires": { + "execa": "^5.0.0", + "p-limit": "^3.1.0" + } + }, + "jest-circus": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-circus/-/jest-circus-29.1.2.tgz", + "integrity": "sha512-ajQOdxY6mT9GtnfJRZBRYS7toNIJayiiyjDyoZcnvPRUPwJ58JX0ci0PKAKUo2C1RyzlHw0jabjLGKksO42JGA==", + "dev": true, + "requires": { + "@jest/environment": "^29.1.2", + "@jest/expect": "^29.1.2", + "@jest/test-result": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "chalk": "^4.0.0", + "co": "^4.6.0", + "dedent": "^0.7.0", + "is-generator-fn": "^2.0.0", + "jest-each": "^29.1.2", + "jest-matcher-utils": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-runtime": "^29.1.2", + "jest-snapshot": "^29.1.2", + "jest-util": "^29.1.2", + "p-limit": "^3.1.0", + "pretty-format": "^29.1.2", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + } + }, + "jest-cli": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-29.1.2.tgz", + "integrity": "sha512-vsvBfQ7oS2o4MJdAH+4u9z76Vw5Q8WBQF5MchDbkylNknZdrPTX1Ix7YRJyTlOWqRaS7ue/cEAn+E4V1MWyMzw==", + "dev": true, + "requires": { + "@jest/core": "^29.1.2", + "@jest/test-result": "^29.1.2", + "@jest/types": "^29.1.2", + "chalk": "^4.0.0", + "exit": "^0.1.2", + "graceful-fs": "^4.2.9", + "import-local": "^3.0.2", + "jest-config": "^29.1.2", + "jest-util": "^29.1.2", + "jest-validate": "^29.1.2", + "prompts": "^2.0.1", + "yargs": "^17.3.1" + }, + "dependencies": { + "cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.1", + "wrap-ansi": "^7.0.0" + } + }, + "y18n": { + "version": "5.0.8", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", + "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", + "dev": true + }, + "yargs": { + "version": "17.6.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.6.0.tgz", + "integrity": "sha512-8H/wTDqlSwoSnScvV2N/JHfLWOKuh5MVla9hqLjK3nsfyy6Y4kDSYSvkU5YCUEPOSnRXfIyx3Sq+B/IWudTo4g==", + "dev": true, + "requires": { + "cliui": "^8.0.1", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", + "require-directory": "^2.1.1", + "string-width": "^4.2.3", + "y18n": "^5.0.5", + "yargs-parser": "^21.0.0" + } + } + } + }, + "jest-config": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-29.1.2.tgz", + "integrity": "sha512-EC3Zi86HJUOz+2YWQcJYQXlf0zuBhJoeyxLM6vb6qJsVmpP7KcCP1JnyF0iaqTaXdBP8Rlwsvs7hnKWQWWLwwA==", + "dev": true, + "requires": { + "@babel/core": "^7.11.6", + "@jest/test-sequencer": "^29.1.2", + "@jest/types": "^29.1.2", + "babel-jest": "^29.1.2", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "deepmerge": "^4.2.2", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-circus": "^29.1.2", + "jest-environment-node": "^29.1.2", + "jest-get-type": "^29.0.0", + "jest-regex-util": "^29.0.0", + "jest-resolve": "^29.1.2", + "jest-runner": "^29.1.2", + "jest-util": "^29.1.2", + "jest-validate": "^29.1.2", + "micromatch": "^4.0.4", + "parse-json": "^5.2.0", + "pretty-format": "^29.1.2", + "slash": "^3.0.0", + "strip-json-comments": "^3.1.1" + }, + "dependencies": { + "strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true + } + } + }, + "jest-diff": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-29.1.2.tgz", + "integrity": "sha512-4GQts0aUopVvecIT4IwD/7xsBaMhKTYoM4/njE/aVw9wpw+pIUVp8Vab/KnSzSilr84GnLBkaP3JLDnQYCKqVQ==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "diff-sequences": "^29.0.0", + "jest-get-type": "^29.0.0", + "pretty-format": "^29.1.2" + } + }, + "jest-docblock": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/jest-docblock/-/jest-docblock-29.0.0.tgz", + "integrity": "sha512-s5Kpra/kLzbqu9dEjov30kj1n4tfu3e7Pl8v+f8jOkeWNqM6Ds8jRaJfZow3ducoQUrf2Z4rs2N5S3zXnb83gw==", + "dev": true, + "requires": { + "detect-newline": "^3.0.0" + } + }, + "jest-each": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-each/-/jest-each-29.1.2.tgz", + "integrity": "sha512-AmTQp9b2etNeEwMyr4jc0Ql/LIX/dhbgP21gHAizya2X6rUspHn2gysMXaj6iwWuOJ2sYRgP8c1P4cXswgvS1A==", + "dev": true, + "requires": { + "@jest/types": "^29.1.2", + "chalk": "^4.0.0", + "jest-get-type": "^29.0.0", + "jest-util": "^29.1.2", + "pretty-format": "^29.1.2" + } + }, + "jest-environment-node": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-29.1.2.tgz", + "integrity": "sha512-C59yVbdpY8682u6k/lh8SUMDJPbOyCHOTgLVVi1USWFxtNV+J8fyIwzkg+RJIVI30EKhKiAGNxYaFr3z6eyNhQ==", + "dev": true, + "requires": { + "@jest/environment": "^29.1.2", + "@jest/fake-timers": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "jest-mock": "^29.1.2", + "jest-util": "^29.1.2" + } + }, + "jest-get-type": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-29.0.0.tgz", + "integrity": "sha512-83X19z/HuLKYXYHskZlBAShO7UfLFXu/vWajw9ZNJASN32li8yHMaVGAQqxFW1RCFOkB7cubaL6FaJVQqqJLSw==", + "dev": true + }, + "jest-haste-map": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.1.2.tgz", + "integrity": "sha512-xSjbY8/BF11Jh3hGSPfYTa/qBFrm3TPM7WU8pU93m2gqzORVLkHFWvuZmFsTEBPRKndfewXhMOuzJNHyJIZGsw==", + "dev": true, + "requires": { + "@jest/types": "^29.1.2", + "@types/graceful-fs": "^4.1.3", + "@types/node": "*", + "anymatch": "^3.0.3", + "fb-watchman": "^2.0.0", + "fsevents": "^2.3.2", + "graceful-fs": "^4.2.9", + "jest-regex-util": "^29.0.0", + "jest-util": "^29.1.2", + "jest-worker": "^29.1.2", + "micromatch": "^4.0.4", + "walker": "^1.0.8" + } + }, + "jest-leak-detector": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-leak-detector/-/jest-leak-detector-29.1.2.tgz", + "integrity": "sha512-TG5gAZJpgmZtjb6oWxBLf2N6CfQ73iwCe6cofu/Uqv9iiAm6g502CAnGtxQaTfpHECBdVEMRBhomSXeLnoKjiQ==", + "dev": true, + "requires": { + "jest-get-type": "^29.0.0", + "pretty-format": "^29.1.2" + } + }, + "jest-matcher-utils": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-29.1.2.tgz", + "integrity": "sha512-MV5XrD3qYSW2zZSHRRceFzqJ39B2z11Qv0KPyZYxnzDHFeYZGJlgGi0SW+IXSJfOewgJp/Km/7lpcFT+cgZypw==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "jest-diff": "^29.1.2", + "jest-get-type": "^29.0.0", + "pretty-format": "^29.1.2" + } + }, + "jest-message-util": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-29.1.2.tgz", + "integrity": "sha512-9oJ2Os+Qh6IlxLpmvshVbGUiSkZVc2FK+uGOm6tghafnB2RyjKAxMZhtxThRMxfX1J1SOMhTn9oK3/MutRWQJQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.12.13", + "@jest/types": "^29.1.2", + "@types/stack-utils": "^2.0.0", + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "micromatch": "^4.0.4", + "pretty-format": "^29.1.2", + "slash": "^3.0.0", + "stack-utils": "^2.0.3" + } + }, + "jest-mock": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-mock/-/jest-mock-29.1.2.tgz", + "integrity": "sha512-PFDAdjjWbjPUtQPkQufvniXIS3N9Tv7tbibePEjIIprzjgo0qQlyUiVMrT4vL8FaSJo1QXifQUOuPH3HQC/aMA==", + "dev": true, + "requires": { + "@jest/types": "^29.1.2", + "@types/node": "*", + "jest-util": "^29.1.2" + } + }, + "jest-pnp-resolver": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/jest-pnp-resolver/-/jest-pnp-resolver-1.2.2.tgz", + "integrity": "sha512-olV41bKSMm8BdnuMsewT4jqlZ8+3TCARAXjZGT9jcoSnrfUnRCqnMoF9XEeoWjbzObpqF9dRhHQj0Xb9QdF6/w==", + "dev": true, + "requires": {} + }, + "jest-regex-util": { + "version": "29.0.0", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.0.0.tgz", + "integrity": "sha512-BV7VW7Sy0fInHWN93MMPtlClweYv2qrSCwfeFWmpribGZtQPWNvRSq9XOVgOEjU1iBGRKXUZil0o2AH7Iy9Lug==", + "dev": true + }, + "jest-resolve": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.1.2.tgz", + "integrity": "sha512-7fcOr+k7UYSVRJYhSmJHIid3AnDBcLQX3VmT9OSbPWsWz1MfT7bcoerMhADKGvKCoMpOHUQaDHtQoNp/P9JMGg==", + "dev": true, + "requires": { + "chalk": "^4.0.0", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.1.2", + "jest-pnp-resolver": "^1.2.2", + "jest-util": "^29.1.2", + "jest-validate": "^29.1.2", + "resolve": "^1.20.0", + "resolve.exports": "^1.1.0", + "slash": "^3.0.0" + } + }, + "jest-resolve-dependencies": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-resolve-dependencies/-/jest-resolve-dependencies-29.1.2.tgz", + "integrity": "sha512-44yYi+yHqNmH3OoWZvPgmeeiwKxhKV/0CfrzaKLSkZG9gT973PX8i+m8j6pDrTYhhHoiKfF3YUFg/6AeuHw4HQ==", + "dev": true, + "requires": { + "jest-regex-util": "^29.0.0", + "jest-snapshot": "^29.1.2" + } + }, + "jest-runner": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-29.1.2.tgz", + "integrity": "sha512-yy3LEWw8KuBCmg7sCGDIqKwJlULBuNIQa2eFSVgVASWdXbMYZ9H/X0tnXt70XFoGf92W2sOQDOIFAA6f2BG04Q==", + "dev": true, + "requires": { + "@jest/console": "^29.1.2", + "@jest/environment": "^29.1.2", + "@jest/test-result": "^29.1.2", + "@jest/transform": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "chalk": "^4.0.0", + "emittery": "^0.10.2", + "graceful-fs": "^4.2.9", + "jest-docblock": "^29.0.0", + "jest-environment-node": "^29.1.2", + "jest-haste-map": "^29.1.2", + "jest-leak-detector": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-resolve": "^29.1.2", + "jest-runtime": "^29.1.2", + "jest-util": "^29.1.2", + "jest-watcher": "^29.1.2", + "jest-worker": "^29.1.2", + "p-limit": "^3.1.0", + "source-map-support": "0.5.13" + }, + "dependencies": { + "source-map-support": { + "version": "0.5.13", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.13.tgz", + "integrity": "sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==", + "dev": true, + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + } + } + }, + "jest-runtime": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-29.1.2.tgz", + "integrity": "sha512-jr8VJLIf+cYc+8hbrpt412n5jX3tiXmpPSYTGnwcvNemY+EOuLNiYnHJ3Kp25rkaAcTWOEI4ZdOIQcwYcXIAZw==", + "dev": true, + "requires": { + "@jest/environment": "^29.1.2", + "@jest/fake-timers": "^29.1.2", + "@jest/globals": "^29.1.2", + "@jest/source-map": "^29.0.0", + "@jest/test-result": "^29.1.2", + "@jest/transform": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "chalk": "^4.0.0", + "cjs-module-lexer": "^1.0.0", + "collect-v8-coverage": "^1.0.0", + "glob": "^7.1.3", + "graceful-fs": "^4.2.9", + "jest-haste-map": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-mock": "^29.1.2", + "jest-regex-util": "^29.0.0", + "jest-resolve": "^29.1.2", + "jest-snapshot": "^29.1.2", + "jest-util": "^29.1.2", + "slash": "^3.0.0", + "strip-bom": "^4.0.0" + } + }, + "jest-snapshot": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-snapshot/-/jest-snapshot-29.1.2.tgz", + "integrity": "sha512-rYFomGpVMdBlfwTYxkUp3sjD6usptvZcONFYNqVlaz4EpHPnDvlWjvmOQ9OCSNKqYZqLM2aS3wq01tWujLg7gg==", + "dev": true, + "requires": { + "@babel/core": "^7.11.6", + "@babel/generator": "^7.7.2", + "@babel/plugin-syntax-jsx": "^7.7.2", + "@babel/plugin-syntax-typescript": "^7.7.2", + "@babel/traverse": "^7.7.2", + "@babel/types": "^7.3.3", + "@jest/expect-utils": "^29.1.2", + "@jest/transform": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/babel__traverse": "^7.0.6", + "@types/prettier": "^2.1.5", + "babel-preset-current-node-syntax": "^1.0.0", + "chalk": "^4.0.0", + "expect": "^29.1.2", + "graceful-fs": "^4.2.9", + "jest-diff": "^29.1.2", + "jest-get-type": "^29.0.0", + "jest-haste-map": "^29.1.2", + "jest-matcher-utils": "^29.1.2", + "jest-message-util": "^29.1.2", + "jest-util": "^29.1.2", + "natural-compare": "^1.4.0", + "pretty-format": "^29.1.2", + "semver": "^7.3.5" + } + }, + "jest-util": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-29.1.2.tgz", + "integrity": "sha512-vPCk9F353i0Ymx3WQq3+a4lZ07NXu9Ca8wya6o4Fe4/aO1e1awMMprZ3woPFpKwghEOW+UXgd15vVotuNN9ONQ==", + "dev": true, + "requires": { + "@jest/types": "^29.1.2", + "@types/node": "*", + "chalk": "^4.0.0", + "ci-info": "^3.2.0", + "graceful-fs": "^4.2.9", + "picomatch": "^2.2.3" + } + }, + "jest-validate": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.1.2.tgz", + "integrity": "sha512-k71pOslNlV8fVyI+mEySy2pq9KdXdgZtm7NHrBX8LghJayc3wWZH0Yr0mtYNGaCU4F1OLPXRkwZR0dBm/ClshA==", + "dev": true, + "requires": { + "@jest/types": "^29.1.2", + "camelcase": "^6.2.0", + "chalk": "^4.0.0", + "jest-get-type": "^29.0.0", + "leven": "^3.1.0", + "pretty-format": "^29.1.2" + }, + "dependencies": { + "camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true + } + } + }, + "jest-watcher": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-watcher/-/jest-watcher-29.1.2.tgz", + "integrity": "sha512-6JUIUKVdAvcxC6bM8/dMgqY2N4lbT+jZVsxh0hCJRbwkIEnbr/aPjMQ28fNDI5lB51Klh00MWZZeVf27KBUj5w==", + "dev": true, + "requires": { + "@jest/test-result": "^29.1.2", + "@jest/types": "^29.1.2", + "@types/node": "*", + "ansi-escapes": "^4.2.1", + "chalk": "^4.0.0", + "emittery": "^0.10.2", + "jest-util": "^29.1.2", + "string-length": "^4.0.1" + } + }, + "jest-worker": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.1.2.tgz", + "integrity": "sha512-AdTZJxKjTSPHbXT/AIOjQVmoFx0LHFcVabWu0sxI7PAy7rFf8c0upyvgBKgguVXdM4vY74JdwkyD4hSmpTW8jA==", + "dev": true, + "requires": { + "@types/node": "*", + "jest-util": "^29.1.2", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + }, + "dependencies": { + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "js-levenshtein": { + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/js-levenshtein/-/js-levenshtein-1.1.6.tgz", + "integrity": "sha512-X2BB11YZtrRqY4EnQcLX5Rh373zbK4alC1FW7D7MBhL2gtcC17cTnr6DmfHZeS0s2rTHjUTMMHfG7gO8SSdw+g==" + }, + "js-tokens": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-4.0.0.tgz", + "integrity": "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==", + "dev": true + }, + "js-yaml": { + "version": "3.14.1", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz", + "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==", + "dev": true, + "requires": { + "argparse": "^1.0.7", + "esprima": "^4.0.0" + } + }, + "jsesc": { + "version": "2.5.2", + "resolved": "https://registry.npmjs.org/jsesc/-/jsesc-2.5.2.tgz", + "integrity": "sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==", + "dev": true + }, + "json-parse-even-better-errors": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", + "integrity": "sha512-xyFwyhro/JEof6Ghe2iz2NcXoj2sloNsWr/XsERDK/oiPCfaNhl5ONfp+jQdAZRQQ0IJWNzH9zIZF7li91kh2w==", + "dev": true + }, + "json-schema-traverse": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", + "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", + "dev": true + }, + "json5": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.1.tgz", + "integrity": "sha512-1hqLFMSrGHRHxav9q9gNjJ5EXznIxGVO09xQRrwplcS8qs28pZ8s8hupZAmqDwZUmVZ2Qb2jnyPOWcDH8m8dlA==", + "dev": true + }, + "kind-of": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz", + "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==", + "dev": true + }, + "kleur": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", + "integrity": "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w==", + "dev": true + }, + "leven": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz", + "integrity": "sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A==", + "dev": true + }, + "lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true + }, + "loader-runner": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.0.tgz", + "integrity": "sha512-3R/1M+yS3j5ou80Me59j7F9IMs4PXs3VqRrm0TU3AbKPxlmpoY1TNscJV/oGJXo8qCatFGTfDbY6W6ipGOYXfg==", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "lodash.memoize": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/lodash.memoize/-/lodash.memoize-4.1.2.tgz", + "integrity": "sha512-t7j+NzmgnQzTAYXcsHYLgimltOV1MXHtlOWf6GjL9Kj8GK5FInw5JotxvbOs+IvV1/Dzo04/fCGfLVs7aXb4Ag==", + "dev": true + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dev": true, + "requires": { + "yallist": "^4.0.0" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==", + "dev": true + }, + "makeerror": { + "version": "1.0.12", + "resolved": "https://registry.npmjs.org/makeerror/-/makeerror-1.0.12.tgz", + "integrity": "sha512-JmqCvUhmt43madlpFzG4BQzG2Z3m6tvQDNKdClZnO3VbIudJYmxsT0FNJMeiB2+JTSlTQTSbU8QdesVmwJcmLg==", + "dev": true, + "requires": { + "tmpl": "1.0.5" + } + }, + "merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true + }, + "micromatch": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", + "integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==", + "dev": true, + "requires": { + "braces": "^3.0.2", + "picomatch": "^2.3.1" + } + }, + "mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true + }, + "mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "requires": { + "mime-db": "1.52.0" + } + }, + "mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true + }, + "minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "natural-compare": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", + "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", + "dev": true + }, + "neo-async": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", + "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", + "dev": true + }, + "node-int64": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", + "integrity": "sha512-O5lz91xSOeoXP6DulyHfllpq+Eg00MWitZIbtPfoSEvqIHdl5gfcY6hYzDWnj0qD5tz52PI08u9qUvSVeUBeHw==", + "dev": true + }, + "node-releases": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.6.tgz", + "integrity": "sha512-PiVXnNuFm5+iYkLBNeq5211hvO38y63T0i2KKh2KnUs3RpzJ+JtODFjkD8yjLwnDkTYF1eKXheUwdssR+NRZdg==", + "dev": true + }, + "normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true + }, + "npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "requires": { + "path-key": "^3.0.0" + } + }, + "object-is": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/object-is/-/object-is-1.1.5.tgz", + "integrity": "sha512-3cyDsyHgtmi7I7DfSSI2LDp6SK2lwvtbg0p0R1e0RvTqF5ceGx+K2dfSjm1bKDMVCFEDAQvy+o8c6a7VujOddw==", + "requires": { + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" + } + }, + "object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==" + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "requires": { + "mimic-fn": "^2.1.0" + } + }, + "p-limit": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", + "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", + "dev": true, + "requires": { + "yocto-queue": "^0.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + }, + "dependencies": { + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + } + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "parse-json": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", + "integrity": "sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-even-better-errors": "^2.3.0", + "lines-and-columns": "^1.1.6" + } + }, + "path-browserify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-browserify/-/path-browserify-1.0.1.tgz", + "integrity": "sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==" + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "dev": true + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, + "picocolors": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz", + "integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==", + "dev": true + }, + "picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true + }, + "pirates": { + "version": "4.0.5", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", + "integrity": "sha512-8V9+HQPupnaXMA23c5hvl69zXvTwTzyAYasnkb0Tts4XvO4CliqONMOnvlq26rkhLC3nWDFBJf73LU1e1VZLaQ==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "pretty-format": { + "version": "29.1.2", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.1.2.tgz", + "integrity": "sha512-CGJ6VVGXVRP2o2Dorl4mAwwvDWT25luIsYhkyVQW32E4nL+TgW939J7LlKT/npq5Cpq6j3s+sy+13yk7xYpBmg==", + "dev": true, + "requires": { + "@jest/schemas": "^29.0.0", + "ansi-styles": "^5.0.0", + "react-is": "^18.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", + "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", + "dev": true + } + } + }, + "prompts": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz", + "integrity": "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q==", + "dev": true, + "requires": { + "kleur": "^3.0.3", + "sisteransi": "^1.0.5" + } + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==", + "dev": true + }, + "querystringify": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz", + "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ==" + }, + "randombytes": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", + "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", + "dev": true, + "requires": { + "safe-buffer": "^5.1.0" + } + }, + "react-is": { + "version": "18.2.0", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", + "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==", + "dev": true + }, + "rechoir": { + "version": "0.7.1", + "resolved": "https://registry.npmjs.org/rechoir/-/rechoir-0.7.1.tgz", + "integrity": "sha512-/njmZ8s1wVeR6pjTZ+0nCnv8SpZNRMT2D1RLOJQESlYFDBvwpTA4KWJpZ+sBJ4+vhjILRcK7JIFdGCdxEAAitg==", + "dev": true, + "requires": { + "resolve": "^1.9.0" + } + }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true + }, + "requires-port": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz", + "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ==" + }, + "resolve": { + "version": "1.22.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.1.tgz", + "integrity": "sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==", + "dev": true, + "requires": { + "is-core-module": "^2.9.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + } + }, + "resolve-cwd": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-cwd/-/resolve-cwd-3.0.0.tgz", + "integrity": "sha512-OrZaX2Mb+rJCpH/6CpSqt9xFVpN++x01XnN2ie9g6P5/3xelLAkXWVADpdz1IHD/KFfEXyE6V0U01OQ3UO2rEg==", + "dev": true, + "requires": { + "resolve-from": "^5.0.0" + } + }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + }, + "resolve.exports": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-1.1.0.tgz", + "integrity": "sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ==", + "dev": true + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "dev": true + }, + "schema-utils": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/schema-utils/-/schema-utils-3.1.1.tgz", + "integrity": "sha512-Y5PQxS4ITlC+EahLuXaY86TXfR7Dc5lw294alXOq86JAHCihAIZfqv8nNCWvaEJvaC51uN9hbLGeV0cFBdH+Fw==", + "dev": true, + "requires": { + "@types/json-schema": "^7.0.8", + "ajv": "^6.12.5", + "ajv-keywords": "^3.5.2" + } + }, + "semver": { + "version": "7.3.8", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.8.tgz", + "integrity": "sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==", + "dev": true, + "requires": { + "lru-cache": "^6.0.0" + } + }, + "serialize-javascript": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", + "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "dev": true, + "requires": { + "randombytes": "^2.1.0" + } + }, + "shallow-clone": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", + "integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==", + "dev": true, + "requires": { + "kind-of": "^6.0.2" + } + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true + }, + "sisteransi": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", + "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==", + "dev": true + }, + "slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + }, + "source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "requires": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "sprintf-js": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", + "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==", + "dev": true + }, + "stack-utils": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-2.0.5.tgz", + "integrity": "sha512-xrQcmYhOsn/1kX+Vraq+7j4oE2j/6BFscZ0etmYg81xuM8Gq0022Pxb8+IqgOFUIaxHs0KaSb7T1+OegiNrNFA==", + "dev": true, + "requires": { + "escape-string-regexp": "^2.0.0" + } + }, + "string-length": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/string-length/-/string-length-4.0.2.tgz", + "integrity": "sha512-+l6rNN5fYHNhZZy41RXsYptCjA2Igmq4EG7kZAYFQI1E1VTXarr6ZPXBg6eq7Y6eK4FEhY6AJlyuFIb/v/S0VQ==", + "dev": true, + "requires": { + "char-regex": "^1.0.2", + "strip-ansi": "^6.0.0" + } + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + }, + "strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true + }, + "strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "requires": { + "has-flag": "^4.0.0" + } + }, + "supports-hyperlinks": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/supports-hyperlinks/-/supports-hyperlinks-2.3.0.tgz", + "integrity": "sha512-RpsAZlpWcDwOPQA22aCH4J0t7L8JmAvsCxfOSEwm7cQs3LshN36QaTkwd70DnBOXDWGssw2eUoc8CaRWT0XunA==", + "dev": true, + "requires": { + "has-flag": "^4.0.0", + "supports-color": "^7.0.0" + } + }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true + }, + "tapable": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/tapable/-/tapable-2.2.1.tgz", + "integrity": "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==", + "dev": true + }, + "terminal-link": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz", + "integrity": "sha512-un0FmiRUQNr5PJqy9kP7c40F5BOfpGlYTrxonDChEZB7pzZxRNp/bt+ymiy9/npwXya9KH99nJ/GXFIiUkYGFQ==", + "dev": true, + "requires": { + "ansi-escapes": "^4.2.1", + "supports-hyperlinks": "^2.0.0" + } + }, + "terser": { + "version": "5.15.1", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.15.1.tgz", + "integrity": "sha512-K1faMUvpm/FBxjBXud0LWVAGxmvoPbZbfTCYbSgaaYQaIXI3/TdI7a7ZGA73Zrou6Q8Zmz3oeUTsp/dj+ag2Xw==", + "dev": true, + "requires": { + "@jridgewell/source-map": "^0.3.2", + "acorn": "^8.5.0", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + } + }, + "terser-webpack-plugin": { + "version": "5.3.6", + "resolved": "https://registry.npmjs.org/terser-webpack-plugin/-/terser-webpack-plugin-5.3.6.tgz", + "integrity": "sha512-kfLFk+PoLUQIbLmB1+PZDMRSZS99Mp+/MHqDNmMA6tOItzRt+Npe3E+fsMs5mfcM0wCtrrdU387UnV+vnSffXQ==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "^0.3.14", + "jest-worker": "^27.4.5", + "schema-utils": "^3.1.1", + "serialize-javascript": "^6.0.0", + "terser": "^5.14.1" + }, + "dependencies": { + "jest-worker": { + "version": "27.5.1", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-27.5.1.tgz", + "integrity": "sha512-7vuh85V5cdDofPyxn58nrPjBktZo0u9x1g8WtjQol+jZDaE+fhN+cIvTj11GndBnMnyfrUOG1sZQxCdjKh+DKg==", + "dev": true, + "requires": { + "@types/node": "*", + "merge-stream": "^2.0.0", + "supports-color": "^8.0.0" + } + }, + "supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + } + }, + "tmpl": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", + "integrity": "sha512-3f0uOEAQwIqGuWW2MVzYg8fV/QNnc/IpuJNG837rLuczAaLVHslWHZQj4IGiEl5Hs3kkbhwL9Ab7Hrsmuj+Smw==", + "dev": true + }, + "to-fast-properties": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/to-fast-properties/-/to-fast-properties-2.0.0.tgz", + "integrity": "sha512-/OaKK0xYrs3DmxRYqL/yDc+FxFUVYhDlXMhRmv3z915w2HF1tnN1omB354j8VUGO/hbRzyD6Y3sA7v7GS/ceog==", + "dev": true + }, + "to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "requires": { + "is-number": "^7.0.0" + } + }, + "ts-jest": { + "version": "29.0.3", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.0.3.tgz", + "integrity": "sha512-Ibygvmuyq1qp/z3yTh9QTwVVAbFdDy/+4BtIQR2sp6baF2SJU/8CKK/hhnGIDY2L90Az2jIqTwZPnN2p+BweiQ==", + "dev": true, + "requires": { + "bs-logger": "0.x", + "fast-json-stable-stringify": "2.x", + "jest-util": "^29.0.0", + "json5": "^2.2.1", + "lodash.memoize": "4.x", + "make-error": "1.x", + "semver": "7.x", + "yargs-parser": "^21.0.1" + } + }, + "ts-loader": { + "version": "9.4.1", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.4.1.tgz", + "integrity": "sha512-384TYAqGs70rn9F0VBnh6BPTfhga7yFNdC5gXbQpDrBj9/KsT4iRkGqKXhziofHOlE2j6YEaiTYVGKKvPhGWvw==", + "dev": true, + "requires": { + "chalk": "^4.1.0", + "enhanced-resolve": "^5.0.0", + "micromatch": "^4.0.0", + "semver": "^7.3.4" + } + }, + "type-detect": { + "version": "4.0.8", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", + "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", + "dev": true + }, + "type-fest": { + "version": "0.21.3", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.21.3.tgz", + "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", + "dev": true + }, + "typescript": { + "version": "4.8.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.4.tgz", + "integrity": "sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==", + "dev": true + }, + "update-browserslist-db": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.9.tgz", + "integrity": "sha512-/xsqn21EGVdXI3EXSum1Yckj3ZVZugqyOZQ/CxYPBD/R+ko9NSUScf8tFF4dOKY+2pvSSJA/S+5B8s4Zr4kyvg==", + "dev": true, + "requires": { + "escalade": "^3.1.1", + "picocolors": "^1.0.0" + } + }, + "uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "requires": { + "punycode": "^2.1.0" + } + }, + "url-parse": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz", + "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==", + "requires": { + "querystringify": "^2.1.1", + "requires-port": "^1.0.0" + } + }, + "util": { + "version": "0.12.5", + "resolved": "https://registry.npmjs.org/util/-/util-0.12.5.tgz", + "integrity": "sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==", + "requires": { + "inherits": "^2.0.3", + "is-arguments": "^1.0.4", + "is-generator-function": "^1.0.7", + "is-typed-array": "^1.1.3", + "which-typed-array": "^1.1.2" + } + }, + "v8-to-istanbul": { + "version": "9.0.1", + "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.0.1.tgz", + "integrity": "sha512-74Y4LqY74kLE6IFyIjPtkSTWzUZmj8tdHT9Ii/26dvQ6K9Dl2NbEfj0XgU2sHCtKgt5VupqhlO/5aWuqS+IY1w==", + "dev": true, + "requires": { + "@jridgewell/trace-mapping": "^0.3.12", + "@types/istanbul-lib-coverage": "^2.0.1", + "convert-source-map": "^1.6.0" + } + }, + "walker": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/walker/-/walker-1.0.8.tgz", + "integrity": "sha512-ts/8E8l5b7kY0vlWLewOkDXMmPdLcVV4GmOQLyxuSswIJsweeFZtAsMF7k1Nszz+TYBQrlYRmzOnr398y1JemQ==", + "dev": true, + "requires": { + "makeerror": "1.0.12" + } + }, + "watchpack": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.0.tgz", + "integrity": "sha512-Lcvm7MGST/4fup+ifyKi2hjyIAwcdI4HRgtvTpIUxBRhB+RFtUh8XtDOxUfctVCnhVi+QQj49i91OyvzkJl6cg==", + "dev": true, + "requires": { + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.1.2" + } + }, + "webpack": { + "version": "5.74.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.74.0.tgz", + "integrity": "sha512-A2InDwnhhGN4LYctJj6M1JEaGL7Luj6LOmyBHjcI8529cm5p6VXiTIW2sn6ffvEAKmveLzvu4jrihwXtPojlAA==", + "dev": true, + "requires": { + "@types/eslint-scope": "^3.7.3", + "@types/estree": "^0.0.51", + "@webassemblyjs/ast": "1.11.1", + "@webassemblyjs/wasm-edit": "1.11.1", + "@webassemblyjs/wasm-parser": "1.11.1", + "acorn": "^8.7.1", + "acorn-import-assertions": "^1.7.6", + "browserslist": "^4.14.5", + "chrome-trace-event": "^1.0.2", + "enhanced-resolve": "^5.10.0", + "es-module-lexer": "^0.9.0", + "eslint-scope": "5.1.1", + "events": "^3.2.0", + "glob-to-regexp": "^0.4.1", + "graceful-fs": "^4.2.9", + "json-parse-even-better-errors": "^2.3.1", + "loader-runner": "^4.2.0", + "mime-types": "^2.1.27", + "neo-async": "^2.6.2", + "schema-utils": "^3.1.0", + "tapable": "^2.1.1", + "terser-webpack-plugin": "^5.1.3", + "watchpack": "^2.4.0", + "webpack-sources": "^3.2.3" + } + }, + "webpack-cli": { + "version": "4.10.0", + "resolved": "https://registry.npmjs.org/webpack-cli/-/webpack-cli-4.10.0.tgz", + "integrity": "sha512-NLhDfH/h4O6UOy+0LSso42xvYypClINuMNBVVzX4vX98TmTaTUxwRbXdhucbFMd2qLaCTcLq/PdYrvi8onw90w==", + "dev": true, + "requires": { + "@discoveryjs/json-ext": "^0.5.0", + "@webpack-cli/configtest": "^1.2.0", + "@webpack-cli/info": "^1.5.0", + "@webpack-cli/serve": "^1.7.0", + "colorette": "^2.0.14", + "commander": "^7.0.0", + "cross-spawn": "^7.0.3", + "fastest-levenshtein": "^1.0.12", + "import-local": "^3.0.2", + "interpret": "^2.2.0", + "rechoir": "^0.7.0", + "webpack-merge": "^5.7.3" + }, + "dependencies": { + "commander": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-7.2.0.tgz", + "integrity": "sha512-QrWXB+ZQSVPmIWIhtEO9H+gwHaMGYiF5ChvoJ+K9ZGHG/sVsa6yiesAD1GC/x46sET00Xlwo1u49RVVVzvcSkw==", + "dev": true + } + } + }, + "webpack-merge": { + "version": "5.8.0", + "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-5.8.0.tgz", + "integrity": "sha512-/SaI7xY0831XwP6kzuwhKWVKDP9t1QY1h65lAFLbZqMPIuYcD9QAW4u9STIbU9kaJbPBB/geU/gLr1wDjOhQ+Q==", + "dev": true, + "requires": { + "clone-deep": "^4.0.1", + "wildcard": "^2.0.0" + } + }, + "webpack-sources": { + "version": "3.2.3", + "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-3.2.3.tgz", + "integrity": "sha512-/DyMEOrDgLKKIG0fmvtz+4dUX/3Ghozwgm6iPp8KRhvn+eQf9+Q7GWxVNMk3+uCPWfdXYC4ExGBckIXdFEfH1w==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, + "which-typed-array": { + "version": "1.1.9", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.9.tgz", + "integrity": "sha512-w9c4xkx6mPidwp7180ckYWfMmvxpjlZuIudNtDf4N/tTAUB8VJbX25qZoAsrtGuYNnGw3pa0AXgbGKRB8/EceA==", + "requires": { + "available-typed-arrays": "^1.0.5", + "call-bind": "^1.0.2", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "has-tostringtag": "^1.0.0", + "is-typed-array": "^1.1.10" + } + }, + "wildcard": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/wildcard/-/wildcard-2.0.0.tgz", + "integrity": "sha512-JcKqAHLPxcdb9KM49dufGXn2x3ssnfjbcaQdLlfZsL9rH9wgDQjUtDxbo8NE0F6SFvydeu1VhZe7hZuHsB2/pw==", + "dev": true + }, + "wrap-ansi": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", + "dev": true + }, + "write-file-atomic": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-4.0.2.tgz", + "integrity": "sha512-7KxauUdBmSdWnmpaGFg+ppNjKF8uNLry8LyzjauQDOVONfFLNKrKvQOxZ/VuTIcS/gge/YNahf5RIIQWTSarlg==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "signal-exit": "^3.0.7" + } + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==", + "dev": true + }, + "yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true + }, + "yocto-queue": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", + "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", + "dev": true + } + } +} diff --git a/db/functions/engine/package.json b/db/functions/engine/package.json new file mode 100644 index 0000000000..3380447a30 --- /dev/null +++ b/db/functions/engine/package.json @@ -0,0 +1,36 @@ +{ + "name": "sg_js_engine", + "version": "0.2.0", + "description": "Function and GraphQL engine for Couchbase Sync Gateway", + "main": "dst/engine.js", + "private": true, + "scripts": { + "test": "jest", + "build": "webpack --mode=production --node-env=production", + "build:dev": "webpack --mode=development", + "build:prod": "webpack --mode=production --node-env=production", + "watch": "webpack --watch" + }, + "author": "Couchbase, Inc.", + "license": "Couchbase BSL", + "dependencies": { + "@apollo/subgraph": "^2.1.4", + "assert": "^2.0.0", + "console-browserify": "^1.2.0", + "graphql": "^16.5.0", + "path-browserify": "^1.0.1", + "source-map-support": "^0.5.21", + "url-parse": "^1.5.10", + "util": "^0.12.5" + }, + "devDependencies": { + "@types/jest": "^29.1.1", + "@types/node": "^18.7.23", + "jest": "^29.1.2", + "ts-jest": "^29.0.3", + "ts-loader": "^9.4.1", + "typescript": "^4.8.4", + "webpack": "^5.74.0", + "webpack-cli": "^4.10.0" + } +} diff --git a/db/functions/engine/polyfill/url.js b/db/functions/engine/polyfill/url.js new file mode 100644 index 0000000000..844024a1d4 --- /dev/null +++ b/db/functions/engine/polyfill/url.js @@ -0,0 +1,18 @@ +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +// Apollo's library imports the URL class from Node's `url` package. +// Unfortunately there isn't a polyfill library that works exactly like this. +// The `url-parse` comes close, but the class is its default export, not a name. +// So this little adapter just re-exports it under the name `URL`. + +import * as urlparse from 'url-parse'; + +export let URL = urlparse; diff --git a/db/functions/engine/src/api.ts b/db/functions/engine/src/api.ts new file mode 100644 index 0000000000..9ef8fa7da2 --- /dev/null +++ b/db/functions/engine/src/api.ts @@ -0,0 +1,145 @@ +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +import { Args, User, Config, Database, Context, Credentials, Document, JSONObject } from './types' +import { ClearCallDepth, MakeDatabase, Upstream } from "./impl"; + + +/** The interface the native code needs to implement. + */ +export interface NativeAPI { + query(fnName: string, + n1ql: string, + argsJSON: string | undefined, + asAdmin: boolean) : string; + get(docID: string, + collection: string, + asAdmin: boolean) : string | null; + save(docJSON: string, + docID: string | undefined, + collection: string, + asAdmin: boolean) : string | null; + delete(docID: string, + revID: string | undefined, + collection: string, + asAdmin: boolean) : boolean; +} + + +// Wraps a `NativeAPI` and exposes it as an Upstream for a Database to use +class UpstreamNativeImpl implements Upstream { + constructor(private native: NativeAPI) { } + + query(fnName: string, n1ql: string, args: Args | undefined, user: User) : JSONObject[] { + let result = this.native.query(fnName, n1ql, this.stringify(args), user.isAdmin); + return JSON.parse(result); + } + + get(docID: string, collection: string, user: User) : Document | null { + let jresult = this.native.get(docID, collection, user.isAdmin); + if (jresult === null) return jresult; + return this.parseDoc(jresult) + } + + save(doc: object, docID: string | undefined, collection: string, user: User) : string | null { + return this.native.save(JSON.stringify(doc), docID, collection, user.isAdmin); + } + + delete(docID: string, revID: string | undefined, collection: string, user: User) : boolean { + return this.native.delete(docID, revID, collection, user.isAdmin); + } + + private stringify(obj: object | undefined) : string | undefined { + return obj ? JSON.stringify(obj) : undefined; + } + + private parseDoc(json: string) : Document { + let result = JSON.parse(json) + if (typeof(result) !== "object") + throw Error("NativeAPI returned JSON that's not an Object"); + return result as Document + } +} + + +/** The API this module implements, and the native code (evaluator.go) calls. */ +export class API { + /** Constructs an instance and parses the configuration. + * Should not throw exceptions, but sets the `errors` property if config is invalid. + */ + constructor(configJSON: string, native: NativeAPI) { + let config = JSON.parse(configJSON) as Config; + let [db, errors] = MakeDatabase(config.functions, config.graphql, + new UpstreamNativeImpl(native)); + if (db !== null) this.db = db; + this.errors = errors; + } + + /** Configuration errors. If there are errors, the API must not be called. */ + readonly errors: string[] | null; + + /** Calls a named function. */ + callFunction(name: string, + argsJSON: string | undefined, + user: string | undefined, + roles: string | undefined, + channels: string | undefined, + mutationAllowed: boolean) : string | Promise + { + let args = argsJSON ? JSON.parse(argsJSON) : undefined; + let context = this.makeContext(user, roles, channels, mutationAllowed); + ClearCallDepth(); + let result = this.db.callFunction(context, name, args); + if (result instanceof Promise) { + return result.then( result => JSON.stringify(result) ); + } else { + return JSON.stringify(result); + } + } + + /** Runs a GraphQL query. */ + graphql(query: string, + operationName: string | undefined, + variablesJSON: string | undefined, + user: string | undefined, + roles: string | undefined, + channels: string | undefined, + mutationAllowed: boolean) : Promise + { + if (operationName === "") operationName = undefined; + let vars = variablesJSON ? JSON.parse(variablesJSON) : undefined; + let context = this.makeContext(user, roles, channels, mutationAllowed); + ClearCallDepth(); + return this.db.graphql(context, query, vars, operationName) + .then( result => JSON.stringify(result) ); + } + + private makeContext(user: string | undefined, + roles: string | undefined, + channels: string | undefined, + mutationAllowed: boolean) : Context + { + var credentials: Credentials | null = null; + if (user !== undefined) { + credentials = [user, + roles?.split(',') ?? [], + channels?.split(',') ?? []]; + } + return this.db.makeContext(credentials, mutationAllowed) + } + + private db!: Database; +}; + + +/** Main entry point, called by Go `NewEvaluator()`. */ +export function main(configJSON: string, native: NativeAPI) : API { + return new API(configJSON, native); +} diff --git a/db/functions/engine/src/compile.test.ts b/db/functions/engine/src/compile.test.ts new file mode 100644 index 0000000000..6d15f39d92 --- /dev/null +++ b/db/functions/engine/src/compile.test.ts @@ -0,0 +1,82 @@ +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +import { CompilePattern, CompilePatterns, Match1 } from './compile'; +import { Args, User } from "./types"; + +import {expect, test} from '@jest/globals'; + + +const JoeBob = { + name: "JoeBob", + roles: [], + channels: [] +} as unknown as User; + +const Admin = { +} as unknown as User; + +const Rolo = { + name: "rolo", + roles: ["lackey", "goofball"], + channels: ["Netflix", "CNN"] +} as unknown as User; + +const SomeArgs : Args = { + "foo": "bar", + "baz": 99, +}; + +test('non-pattern', () => { + let p = CompilePattern("foobar"); + expect(p.expand(JoeBob)).toBe("foobar"); + expect(p.expand(Rolo, SomeArgs)).toBe("foobar"); +}); + +test('no-op pattern', () => { + let p = CompilePattern("My $$2 bill"); + expect(p.expand(JoeBob)).toBe("My $2 bill"); + expect(p.expand(Rolo, SomeArgs)).toBe("My $2 bill"); +}); + +test('arg pattern', () => { + let p = CompilePattern("Hey $foo!"); + expect(p.expand(JoeBob, SomeArgs)).toBe("Hey bar!"); + p = CompilePattern("From $foo to $baz"); + expect(p.expand(JoeBob, SomeArgs)).toBe("From bar to 99"); + p = CompilePattern("From$(foo)to$(baz)"); + expect(p.expand(JoeBob, SomeArgs)).toBe("Frombarto99"); +}); + +test('user pattern', () => { + let p = CompilePattern("some-$(user.name)"); + expect(p.expand(JoeBob, SomeArgs)).toBe("some-JoeBob"); + p = CompilePattern("some-$(context.user.name)"); + expect(p.expand(JoeBob, SomeArgs)).toBe("some-JoeBob"); +}); + +test('user pattern with admin', () => { + let p = CompilePattern("some-$(user.name)"); + expect(p.expand(Admin, SomeArgs)).toBe("some-"); + p = CompilePattern("some-$(context.user.name)"); + expect(p.expand(Admin, SomeArgs)).toBe("some-"); +}); + +test('matching', () => { + expect(CompilePatterns(undefined)).toBe(undefined); + + let pp = CompilePatterns(["foobar", "some-$(user.name)"])!; + expect(pp.length).toBe(2); + expect(pp[0].expand(Rolo, SomeArgs)).toBe("foobar"); + + expect(Match1(pp, "foobar", Rolo, SomeArgs)).toBeTruthy(); + expect(Match1(pp, "some-rolo", Rolo, SomeArgs)).toBeTruthy(); + expect(Match1(pp, "duh", Rolo, SomeArgs)).toBeFalsy(); +}); diff --git a/db/functions/engine/src/compile.ts b/db/functions/engine/src/compile.ts new file mode 100644 index 0000000000..2054834d43 --- /dev/null +++ b/db/functions/engine/src/compile.ts @@ -0,0 +1,442 @@ +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +import { AllowConfig, Args, Context, Database, FunctionConfig, User, JSFn, ResolverFn, HTTPError, ResolveInfo, EntityReferenceResolver, TypeResolverFn } from './types' +import { BeginReadOnly, EndReadOnly } from "./impl"; + +import * as gq from 'graphql'; + + +function nonEmpty(a: T[] | undefined) : a is T[] { + return a !== undefined && a.length > 0; +} + + +//////// PATTERN SUBSTITUTION (in 'allow') + + +const kPatternRegex = /\${([^}]+)}|(\\\$)/g; + +/** A string that may change based on the current user and args. */ +export abstract class Pattern { + constructor(protected str: string) { } + + abstract expand(user: User, args?: Args) : string; + + toString() : string { + return this.str; + } +} + +class NonPattern extends Pattern { + constructor(str: string) {super(str);} + + override expand(user: User, args?: Args) : string { + return this.str; + } +} + +class DollarPattern extends Pattern { + constructor(str: string) {super(str);} + + override expand(user: User, args?: Args) : string { + let result = this.str.replace(kPatternRegex, (match, expr, none) => { + if (none) { + return '$'; // \$ -> $ + } else if (expr.startsWith("context.user.name")) { + if (!user) { + return ""; + } else { + return user.name ?? ""; + } + } else if (expr.startsWith("args.")) { + let varName = expr.slice(5) + let value = args ? args[varName] : undefined; + switch(typeof(value)) { + case "undefined": + throw new HTTPError(503, "Bad config: Unknown arg in channel/role pattern '${" + expr + "} in 'allow'"); + case "string": + return value; + case "number": + return String(value); + default: + throw new HTTPError(400, "Value of arg '" + varName + "' must be a string or number"); + } + } else { + throw new HTTPError(503, "Bad config: Invalid channel/role pattern '${" + expr + "} in 'allow'"); + } + }); + return result; + } + + override toString() : string { + return "Pattern<" + this.str + ">"; + } +} + +/** Creates a Pattern from a string. '$'-prefixed patterns will be substituted according to the + * rules of the 'allow' object. */ +export function CompilePattern(name: string) : Pattern { + if (name.match(kPatternRegex)) { + return new DollarPattern(name); + } else { + return new NonPattern(name); + } +} + +/** Creates an array of Patterns from an array of strings, or `undefined` if there are none. */ +export function CompilePatterns(names?: string[]) : Pattern[] | undefined { + return nonEmpty(names) ? names.map( name => CompilePattern(name) ) : undefined; +} + +/** Matches an array of Patterns against an array of strings, returning true if any match. */ +export function Match(patterns: Pattern[], values: string[] | undefined, user: User, args?: Args) { + return nonEmpty(values) && patterns.some( pat => values.includes(pat.expand(user, args))); +} + +/** Matches an array of Patterns against a single string, returning true if any match. */ +export function Match1(patterns: Pattern[], value: string, user: User, args?: Args) { + return patterns.some( pat => (value == pat.expand(user, args))); +} + + +//////// AUTHORIZATION + + +/** Checks authorization for a user, based on an Allow object. Created by CompileAllow. */ +export abstract class Allow { + constructor(public readonly name: string) { } + + abstract authorize(user: User, args?: Args) : void; + + fail(user: User) : never { + console.log(`Auth failure calling function '${this.name}' for user ${JSON.stringify(user)}`); + if (user.isGuest) { + throw new HTTPError(401, `Login required to call function '${this.name}'`); + } else { + throw new HTTPError(403, `Access forbidden to function '${this.name}'`); + } + } +} + +class AllowAdminOnly extends Allow { + override authorize(user: User, args?: Args) { + if (!user.isAdmin) this.fail(user); + } +} + +class AllowAnyone extends Allow { + override authorize(user: User) { } +} + +class AllowByConfig extends Allow { + constructor(name: string, config: AllowConfig) { + super(name); + this.users = CompilePatterns(config.users); + this.roles = CompilePatterns(config.roles); + this.channels = CompilePatterns(config.channels); + } + + authorize(user: User, args?: Args) { + console.assert(user.defaultCollection !== undefined); + if (!user.isAdmin + && !(this.users && Match1(this.users, user.name!, user, args)) + && !(this.roles && Match(this.roles, user.roles, user, args)) + && !(this.channels && Match(this.channels, user.channels, user, args))) { + //throw new HTTPError((user.isGuest ? 401 : 403), `Access forbidden to function '${this.name}' ... user = ${user.name} ... user.channels=${user.channels} ... this.users=${this.users} ... this.channels=${this.channels}`); + this.fail(user); + } + } + + private users?: Pattern[]; + private roles?: Pattern[]; + private channels?: Pattern[]; +} + +/** Creates an Allow object based on an optional AllowConfig. + * If there is no config, the `lenient` parameter determines whether that means + * "anyone" or "admin only". */ +export function CompileAllow(name: string, config: AllowConfig | undefined, lenient: boolean) : Allow { + if (!config) { + return lenient ? new AllowAnyone(name) : new AllowAdminOnly(name); + } else if (!config.users && !config.roles && !config.channels) { + return new AllowAdminOnly(name); + } else if ((config.users && config.users.includes("*")) + || (config.roles && config.roles.includes("*")) + || (config.channels && config.channels.includes("*"))) { + return new AllowAnyone(name); + } else { + return new AllowByConfig(name, config); + } +} + + +//////// ARG VALIDATION: + + +/** A function that validates args, throwing an exception if they're invalid. */ +export type ArgsValidator = (args:Args | undefined) => void; + + +/** Given a function's parameter list, returns a function to validate the 'args' object. */ +export function CompileParams(fnName: string, parameters: string[] | undefined): ArgsValidator { + if (!nonEmpty(parameters)) { + return (args?: Args) : void => { + if (args) { + let argNames = Object.getOwnPropertyNames(args); + if (argNames.length > 0) { + throw new HTTPError(400, `Undeclared arguments '${argNames.join("', '")}' passed to ${fnName}`); + } + } + } + } else { + let paramSet = new Set; + for (let param of parameters) { + paramSet.add(param); + } + let nParams = paramSet.size; + if (nParams != parameters.length) { + throw new HTTPError(500, `Function/resolver ${fnName} has duplicate arg names`); + } + return (args?: Args) : void => { + if (!args) { + throw new HTTPError(400, `Function "${fnName}" called without arguments, but requires ${parameters}`); + } + for (let param of parameters) { + if (args[param] === undefined) { + throw new HTTPError(400, `Missing argument "${param}" in call to ${fnName}`); + } + } + let argNames = Object.getOwnPropertyNames(args); + if (argNames.length != nParams) { + for (let arg of argNames) { + if (!paramSet.has(arg)) { + throw new HTTPError(400, `Undeclared argument "${arg}" passed to ${fnName}`); + } + } + } + }; + } +} + + +//////// COMPILING FUNCTIONS: + + +// Returns the N1QL query string from a FunctionConfig. +function checkN1QL(config: FunctionConfig) : string { + if (!config.code.match(/^\s*\(*SELECT\b/i)) + throw new HTTPError(500, "only SELECT queries are allowed"); + return config.code; +} + + +// Annotates an exception with the name of the active function, and re-throws it. +function rethrow(x: unknown, what: string, fnName: string) : never { + if (x instanceof Error) { + x.message = `${x.message} (thrown by ${what} ${fnName})` + throw x; + } else { + throw Error(`${x} (thrown by ${what} ${fnName})`); + } +} + + +/** Compiles a FunctionConfig to a function. */ +export function CompileFn(fnName: string, + fnConfig: FunctionConfig, + db: Database) : JSFn +{ + const allow = CompileAllow(fnName, fnConfig.allow, false); + const checkArgs = CompileParams(fnName, fnConfig.args); + switch (fnConfig.type) { + case "query": + const n1ql = checkN1QL(fnConfig); + return function(context, args) { + checkArgs(args); + allow.authorize(context.user, args); + console.debug(`QUERY ${fnName}`); + if (args) args = {args: args}; + return db.query(context, fnName, n1ql, args); + }; + case "javascript": + const mutating = fnConfig.mutating ?? false; + const code = compileToJS(fnName, fnConfig, 2) as JSFn; + return function(context, args) { + console.debug(`FUNC ${fnName}`); + checkArgs(args); + allow.authorize(context.user, args); + if (!mutating) BeginReadOnly(context); + try { + return code(context, args); + } catch (x) { + rethrow(x, "function", fnName); + } finally { + if (!mutating) EndReadOnly(context); + } + }; + default: + throw new HTTPError(500, `unrecognized 'type' "${fnConfig.type}"`); + } +} + + +/** Compiles a FunctionConfig to a GraphQL resolver. */ +export function CompileResolver(field: gq.GraphQLField, + typeName: string, + fieldName: string, + fnConfig: FunctionConfig, + db: Database) +{ + let fnName = `${typeName}.${fieldName}`; + let mutating = (typeName == "Mutation"); + let allow = CompileAllow(fnName, fnConfig.allow, true); + if (fnConfig.args) { + throw new HTTPError(500, `'args' is not valid in a GraphQL resolver config`); + } + switch (fnConfig.type) { + case "query": + if (mutating) throw new HTTPError(500, "GraphQL mutations must be implemented in JavaScript"); + let n1ql = checkN1QL(fnConfig); + let fieldType = field.type; + if (gq.isNonNullType(fieldType)) + fieldType = fieldType.ofType; + let returnsGraphQLList = gq.isListType(fieldType); + let returnsGraphQLScalar = gq.isScalarType(fieldType); + field.resolve = function(parent, args, context, info) { + allow.authorize(context.user, args); + try { + let result = db.query(context, fnName, n1ql, {args: args, parent: parent}); + if (returnsGraphQLList) { + // Resolver returns a list, so just return the array of rows + return result; + } else if (result.length == 0) { + return null; + } else { + // GraphQL result is not a list (array), but N1QL always returns an array. + // So use the first row of the result as the value. + let row = result[0]; + if (!returnsGraphQLScalar) { + return row + } else { + // GraphQL result type is a scalar, but a N1QL row is always an object. + // Use the single field of the object, if any, as the result: + let cols = Object.getOwnPropertyNames(row); + if (cols.length == 1) { + return row[cols[0]]; + } else { + throw new HTTPError(500, `resolver returns scalar type ${field.type}, but its N1QL query returns ${cols.length} columns, not 1`); + } + } + } + } catch (x) { + rethrow(x, "resolver", fnName); + } + }; + break; + case "javascript": + let code = compileToJS(fnName, fnConfig, 4) as ResolverFn; + field.resolve = function(source, args, context, info) { + console.debug(`RESOLVE ${fnName}`); + allow.authorize(context.user, args); + if (!mutating) BeginReadOnly(context); + try { + return code(source, args, context, upgradeInfo(info)); + } catch (x) { + rethrow(x, "resolver", fnName); + } finally { + if (!mutating) EndReadOnly(context); + } + }; + break; + default: + throw new HTTPError(500, `unrecognized 'type' "${fnConfig.type}"`); + } +} + + +/** Compiles a FunctionConfig to a GraphQL type-name (interface) resolver. */ +export function CompileTypeNameResolver(typeName: string, + fnConfig: FunctionConfig, + db: Database) : gq.GraphQLTypeResolver +{ + let fnName = `${typeName}.__typename`; + if (fnConfig.type != "javascript") { + throw new HTTPError(500, `a GraphQL '__typename' resolver must be JavaScript`); + } else if (fnConfig.allow !== undefined) { + throw new HTTPError(500, `'allow' is not valid in a GraphQL '__typename' resolver`); + } + let fn = compileToJS(fnName, fnConfig, 4) as TypeResolverFn; + return (value, context, info) => { + return fn(context, value, info as ResolveInfo); + } + +} + + +export type ApolloEntityReferenceResolver = (reference: object, + context: Context, + info: ResolveInfo) => any; + + +/** Compiles a FunctionConfig to a GraphQL Subgraph `_resolveReference` resolver. */ +export function CompileEntityReferenceResolver(typeName: string, + fnConfig: FunctionConfig, + db: Database) : ApolloEntityReferenceResolver +{ + let fnName = `${typeName}._resolveReference`; + if (fnConfig.type != "javascript") { + throw new HTTPError(500, `entity reference resolvers must be implemented in JavaScript`); + } else if (fnConfig.allow !== undefined) { + throw new HTTPError(500, `entity reference resolver must not have an 'allow' config`); + } + let code = compileToJS(fnName, fnConfig, 3) as EntityReferenceResolver; + return function(ref, context, info) { + return code(context, ref, info); // Apollo's library has the params swapped + } +} + + +// Compiles FunctionConfig.code to JavaScript if it's a string, and checks parameter count. +function compileToJS(name: string, fnConfig: FunctionConfig, nArgs: number) : Function { + // http://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval#never_use_eval! + let fn: Function; + try { + fn = Function(`"use strict"; return (${fnConfig.code})`)() + } catch (x) { + throw new HTTPError(500, `failed to compile: ${x}`); + } + if (typeof(fn) !== 'function') { + throw new HTTPError(500, `code does not compile to a JS function`); + } else if (fn.length < 2 || fn.length > nArgs) { + throw new HTTPError(500, `should have 2-${nArgs} JavaScript arguments`); + } + return fn; +} + + +function upgradeInfo(info: gq.GraphQLResolveInfo) : ResolveInfo { + function selectedFieldNames(this: ResolveInfo) : string[] { + let result: string[] = []; + if (this.fieldNodes.length > 0) { + let set = this.fieldNodes[0].selectionSet; + if (set) { + for (let sel of set.selections) { + if (sel.kind == "Field" && sel.name.kind == "Name") { + result.push(sel.name.value) + } + } + } + } + return result; + } + Object.defineProperty(info, "selectedFieldNames", {get: selectedFieldNames}); + return info as unknown as ResolveInfo; +} diff --git a/db/functions/engine/src/impl.ts b/db/functions/engine/src/impl.ts new file mode 100644 index 0000000000..f1e5a34de4 --- /dev/null +++ b/db/functions/engine/src/impl.ts @@ -0,0 +1,568 @@ +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +import { AllowConfig, Args, Context, Credentials, Database, Document, FunctionsConfig, GraphQLConfig, CRUD, User, JSFn, HTTPError, JSONObject, FunctionConfig } from './types' +import { CompileEntityReferenceResolver, CompileFn, CompileResolver, CompileTypeNameResolver } from './compile' + +import * as gq from 'graphql'; +import { buildSubgraphSchema } from '@apollo/subgraph'; +import { GraphQLResolverMap } from "@apollo/subgraph/dist/schema-helper"; + + +/** Abstract interface to the N1QL query and CRUD implementation. Used by Database. */ +export interface Upstream { + query(fnName: string, + n1ql: string, + args: Args | undefined, + user: User) : JSONObject[]; + get(docID: string, collection: string, user: User) : Document | null; + save(doc: Document, docID: string | undefined, collection: string, user: User) : string | null; + delete(docID: string, revID: string | undefined, collection: string, user: User) : boolean; +} + + +//////// DATABASE IMPLEMENTATION + + +// https://www.apollographql.com/docs/federation/building-supergraphs/subgraphs-apollo-server/ +const kFederationImportsStr = ` + extend schema @link( + url: "https://specs.apollo.dev/federation/v2.0", + import: ["@extends", "@external", "@inaccessible", "@key", "@override", "@provides", + "@requires", "@shareable", "@tag"] + ) +`; + + +/** Constructs a Database instance. */ +export function MakeDatabase(functions: FunctionsConfig | undefined, + graphql: GraphQLConfig | undefined, + upstream: Upstream) : [Database | null, string[] | null] +{ + let db : Database | null; + db = new DatabaseImpl(upstream); + let errors = db.configure(functions, graphql); + if (errors) db = null; + return [db, errors]; +} + + +class DatabaseImpl implements Database { + + constructor(private upstream: Upstream) { + // Create a context for "context.admin" + let superUser = new UserImpl(this, null, true); + this.superUserContext = new ContextImpl(superUser, superUser, true); + superUser.context = this.superUserContext; + } + + configure(functions: FunctionsConfig | undefined, + graphql: GraphQLConfig | undefined) : string[] | null + { + // Collect all errors/exceptions in an array to return at the end: + let errors = new ErrorList; + console.log("Initializing GraphQL/functions..."); + + if (functions) { + let nFuncs = 0; + let maxSize = functions.max_code_size; + for (let fnName of Object.getOwnPropertyNames(functions.definitions)) { + let fnConfig = functions.definitions[fnName]; + if (maxSize !== undefined && fnConfig.code.length > maxSize) { + errors.complain(`function ${fnName}: code is too large (> ${maxSize} bytes)`) + } else { + errors.try(`function ${fnName}: `, () => { + this.functions[fnName] = CompileFn(fnName, fnConfig, this); + ++nFuncs; + }); + } + } + if (functions.max_function_count !== undefined && nFuncs > functions.max_function_count) { + errors.complain(`too many functions (> ${functions!.max_function_count})`); + } + } + + if (graphql) { + if (!graphql.schema) { + errors.complain("GraphQL schema is missing"); + } else if (graphql.max_schema_size !== undefined && graphql.schema.length > graphql.max_schema_size) { + errors.complain(`GraphQL schema too large (> ${graphql.max_schema_size} bytes)`); + } else { + errors.try(`GraphQL schema: `, () => { + if (graphql.subgraph) { + // Prepend the required "extend schema..." declaration: + let document = gq.parse(kFederationImportsStr + "\n\n" + graphql.schema!); + // Create a map with just the __resolveReference resolver fns, so the + // subgraph code can store them in the schema: + let resolvers = this.createApolloResolverMap(graphql,errors); + this.schema = buildSubgraphSchema({ typeDefs: document, + resolvers: resolvers }); + } else { + this.schema = gq.buildSchema(graphql.schema!); + } + }); + if (this.schema) { + this.configureResolvers(graphql, errors); + if (errors.errors.length == 0) + this.verifyResolversExist(errors); + } + } + } + + if (errors.errors.length > 0) { + console.error(`Found ${errors.errors.length} error[s] in configuration!`); + return errors.errors; + } + return null; + } + + + private configureResolvers(graphql: GraphQLConfig, errors: ErrorList) { + let remainingResolvers = graphql.max_resolver_count ?? 1e9; + + if (!graphql.resolvers) return; + + function canAddResolver(typeName: string, fieldName: string, config: FunctionConfig) { + if (remainingResolvers-- == 0) { + errors.complain(`too many GraphQL resolvers (> ${graphql.max_resolver_count!})`); + return false; + } + let maxSize = graphql!.max_code_size; + if (maxSize !== undefined && config.code.length > maxSize) { + errors.complain(`GraphQL resolver ${typeName}.${fieldName}: code is too large (> ${maxSize} bytes)`); + return false; + } + return true; + } + + for (let typeName of Object.getOwnPropertyNames(graphql.resolvers)) { + let fields = graphql.resolvers[typeName]; + let schemaType = this.schema!.getType(typeName); + if (!schemaType) { + errors.complain(`GraphQL resolver type '${typeName}': no such type in the schema`); + } else if (schemaType instanceof gq.GraphQLObjectType) { + let schemaFields = schemaType.getFields(); + for (let fieldName of Object.getOwnPropertyNames(fields)) { + let fnConfig = fields[fieldName]; + if (canAddResolver(typeName, fieldName, fnConfig)) { + if (graphql.subgraph && fieldName == '__resolveReference') continue; + let schemaField = schemaFields[fieldName]; + if (schemaField) { + errors.try(`GraphQL resolver ${typeName}.${fieldName}: `, + () => { + CompileResolver(schemaField, typeName, fieldName, fnConfig, this); + console.debug(`Compiled GraphQL resolver ${typeName}.${fieldName}`) + }); + } else { + errors.complain(`GraphQL resolver ${typeName}.${fieldName}: no such field in the schema`); + } + } + } + } else if (schemaType instanceof gq.GraphQLInterfaceType + || schemaType instanceof gq.GraphQLUnionType) { + let ifType = schemaType; + for (let fieldName of Object.getOwnPropertyNames(fields)) { + let fnConfig = fields[fieldName]; + if (canAddResolver(typeName, fieldName, fnConfig)) { + if (fieldName == "__typename") { + errors.try(`GraphQL resolver ${typeName}.__typename: `, + () => { + ifType.resolveType = CompileTypeNameResolver(typeName, + fnConfig, this); + console.debug(`Compiled GraphQL resolver ${typeName}.__typename`) + }); + } else { + errors.complain(`GraphQL resolver ${typeName}.${fieldName}: abstract types may only have a '__typename' resolver`); + } + } + } + } else { + errors.complain(`GraphQL type ${typeName}: not an object or interface, so cannot have resolvers`); + } + } + } + + private verifyResolversExist(errors: ErrorList) { + let queryType = this.schema!.getQueryType(); + let mutationType = this.schema!.getMutationType(); + + const typeMap = this.schema!.getTypeMap() + for (const typeName of Object.getOwnPropertyNames(typeMap)) { + const schemaType = typeMap[typeName]; + if (schemaType == queryType || schemaType == mutationType) { + const fields = schemaType.getFields(); + for (let fieldName of Object.getOwnPropertyNames(fields)) { + if (!fields[fieldName].resolve) + errors.complain(`GraphQL resolver ${typeName}.${fieldName}: missing function definition`); + } + } else if (schemaType instanceof gq.GraphQLInterfaceType + || schemaType instanceof gq.GraphQLUnionType) { + if (!schemaType.resolveType) + errors.complain(`GraphQL resolver ${typeName}.__typename: missing function definition`); + } + } + } + + createApolloResolverMap(graphql: GraphQLConfig, errors: ErrorList) : GraphQLResolverMap { + let result : GraphQLResolverMap = {} + for (let [typeName, resolvers] of Object.entries(graphql.resolvers)) { + let resolveRef = resolvers['__resolveReference']; + if (resolveRef) { + let resolverFn = CompileEntityReferenceResolver(typeName, resolveRef, this); + result[typeName] = { + '__resolveReference': resolverFn as gq.GraphQLFieldResolver + }; + } + } + return result; + } + + + makeContext(credentials: Credentials | null, mutationAllowed: boolean) { + let user = new UserImpl(this, credentials); + let ctx = new ContextImpl(user, this.superUserContext.user, mutationAllowed); + user.context = ctx; + return ctx; + } + + + getFunction(name: string) : JSFn { + let fn = this.functions[name]; + if (!fn) throw new HTTPError(404, `No such function ${name}`); + return fn; + } + + + callFunction(context: Context, + name: string, + args: Args | undefined) + { + console.debug(`>>> FUNCTION ${name}`); + return this.getFunction(name)(context, args); + } + + + + query(context: Context, + fnName: string, + n1ql: string, + args: Args | undefined) // note: `args` are top-level N1QL args, not the "args" object + : JSONObject[] + { + console.debug(`>>> N1QL ${n1ql}`); + return this.upstream.query(fnName, n1ql, args, context.user); + } + + + graphql(context: Context, + query: string, + variableValues?: Args, + operationName?: string) : Promise { + console.debug(`>>> GRAPHQL ${query}`); + if (!this.schema) throw new HTTPError(404, "No GraphQL schema"); + return gq.graphql({ + contextValue: context, + schema: this.schema, + source: query, + variableValues: variableValues, + operationName: operationName, + }); + } + + + get(docID: string, collection: string, user: User) : Document | null { + return this.upstream.get(docID, collection, user); + } + + save(doc: Document, docID: string | undefined, collection: string, user: User) : string | null { + return this.upstream.save(doc, docID, collection, user); + } + + delete(docID: string, revID: string | undefined, collection: string, user: User) : boolean { + return this.upstream.delete(docID, revID, collection, user); + } + + + private superUserContext: ContextImpl; // The admin Context (only one is needed) + private functions: Record = {}; // Compiled JS functions + private schema?: gq.GraphQLSchema; // Compiled GraphQL schema (with resolvers) +} + + +//////// CONTEXT IMPLEMENTATION + + +class ContextImpl implements Context { + constructor(readonly user: User, + readonly admin: User, + mutationAllowed: boolean) { + if (!mutationAllowed) { + this.readOnlyLevel++; + } + } + + checkUser(name: string | string[]) : boolean { + return this.user.isAdmin || match(name, this.user.name!); + } + + requireUser(name: string | string[]) { + if (!this.checkUser(name)) this.permissionDenied("user"); + } + + checkAdmin() : boolean { + return this.user.isAdmin; + } + + requireAdmin() { + if (!this.checkAdmin()) this.permissionDenied("admin only"); + } + + checkRole(role: string | string[]) : boolean { + if (this.user.isAdmin) return true; + for (let myRole of this.user.roles!) { + if (match(role, myRole)) return true; + } + return false; + } + + requireRole(role: string | string[]) { + if (!this.checkRole(role)) this.permissionDenied("role"); + } + + checkAccess(channel: string | string[]) : boolean { + if (this.user.isAdmin) return true; + for (let myChannel of this.user.channels!) { + if (match(channel, myChannel)) return true; + } + return false; + } + + requireAccess(channel: string | string[]) { + if (!this.checkAccess(channel)) this.permissionDenied("channel"); + } + + checkAllowed(allow: AllowConfig | undefined) : boolean { + return this.user.isAdmin + || (allow !== undefined && ( + (allow.users !== undefined && allow.users.includes(this.user.name!)) || + (allow.roles !== undefined && this.checkRole(allow.roles)) || + (allow.channels !== undefined && this.checkAccess(allow.channels)))); + } + + requireAllowed(allow: AllowConfig | undefined) { + if (!this.checkAllowed(allow)) this.permissionDenied(); + } + + checkMutating() : boolean { + return this.readOnlyLevel == 0; + } + + requireMutating() : void { + if (!this.checkMutating()) throw new HTTPError(403, "Permission denied (read-only context)"); + } + + private permissionDenied(message: string = "") : never { + if (message) message = ` (${message})`; + if (this.user.isGuest) { + throw new HTTPError(401, "Login required" + message); + } else { + throw new HTTPError(403, "Permission denied" + message); + } + } + + readOnlyLevel = 0; +} + +export function BeginReadOnly(context: Context) { + if (!context.user.isSuperUser) { + (context as ContextImpl).readOnlyLevel++; + } + console.debug(`++++ BeginReadOnly; now ${(context as ContextImpl).readOnlyLevel}`); +} + +export function EndReadOnly(context: Context) { + if (!context.user.isSuperUser) { + (context as ContextImpl).readOnlyLevel--; + } + console.debug(`---- EndReadOnly; now ${(context as ContextImpl).readOnlyLevel}`); +} + + +//////// CRUD IMPLEMENTATION + + +class CRUDImpl implements CRUD { + + constructor(private db: DatabaseImpl, + private collection: string, + private user: UserImpl) { } + + + get(docID: string) : Document | null { + return this.db.get(docID, this.collection, this.user); + } + + + save(doc: Document, docID?: string) : string | null { + if (!this.user.canMutate) + throw new HTTPError(403, "save() is not allowed in a read-only context"); + return this.db.save(doc, docID, this.collection, this.user); + } + + + delete(docOrID: string | Document) : boolean { + if (!this.user.canMutate) + throw new HTTPError(403, "delete() is not allowed in a read-only context"); + if (typeof docOrID === 'string') { + return this.db.delete(docOrID, undefined, this.collection, this.user); + } else { + let id = docOrID['_id']; + if (!id) throw "delete() called with doc object that has no '_id' property"; + return this.db.delete(id, docOrID._rev, this.collection, this.user); + } + } +} + + +//////// USER IMPLEMENTATION + + +export let CallDepth = 1; +export const MaxCallDepth = 20; + +export function ClearCallDepth() {CallDepth = 1;} + + +class UserImpl implements User { + + constructor(private db: DatabaseImpl, + credentials: Credentials | null, + readonly isSuperUser = false) + { + if (credentials) { + [this.name, this.roles, this.channels] = credentials; + isSuperUser = false; + } + this.defaultCollection = new CRUDImpl(db, '_default', this); + } + + + // Authorization: + + readonly name?: string; + readonly roles?: string[]; + readonly channels?: string[]; + + get isGuest() {return this.name === "";} + + get isAdmin() {return this.name === undefined;} + + get canMutate() : boolean {return this.isSuperUser || this.context.checkMutating();} + + + // API: + + readonly defaultCollection: CRUD; + + collection(name: string) : CRUD { + return new CRUDImpl(this.db, name, this); + } + + function(name: string, args?: Args) : unknown { + let fn = this.db.getFunction(name); + if (++CallDepth > MaxCallDepth) { + --CallDepth; + let msg = `User function recursion too deep (calling function("${name}")`; + console.error(msg); + throw new HTTPError(508, msg); + } + try { + return fn(this.context, args); + } finally { + --CallDepth; + } + } + + + async graphql(query: string, args?: Args) : Promise { + if (++CallDepth > MaxCallDepth) { + --CallDepth; + let msg = `User function recursion too deep (calling graphql())`; + console.error(msg); + throw new HTTPError(508, msg); + } + try { + let result = await this.db.graphql(this.context, query, args); + if (result.errors) { + let err = result.errors[0]; + if (err.originalError) + throw err.originalError; + throw Error(err.message); + } + if (result.data === undefined) return null; + return result.data; + } finally { + --CallDepth; + } + } + + + toJSON(key: string) : any { + if (this.isAdmin) { + return {}; + } else { + return { + name: this.name, + roles: this.roles, + channels: this.channels + }; + } + } + + context!: ContextImpl; +}; + + +//////// UTILITIES: + + +/** Utility that collects a list of error messages. */ +class ErrorList { + /** adds an error message to `errors`. */ + complain(msg: string) { + console.error(msg); + this.errors.push(msg); + } + /** calls a function, catching any exception and adding it to `errors`. */ + try(msg: string, fn: ()=>void) { + try { + fn(); + } catch (err) { + if (err instanceof Error) { + msg += err.message; + } else { + msg += String(err); + } + this.complain(msg); + } + }; + + errors: string[] = []; +} + + +// Returns true if `what` is equal to `against` or included in it. +function match(what: string | string[], against: string) { + if (typeof(what) === 'string') { + return (what == against); + } else { + return what.includes(against); + } +} diff --git a/db/functions/engine/src/types.ts b/db/functions/engine/src/types.ts new file mode 100644 index 0000000000..8719635e56 --- /dev/null +++ b/db/functions/engine/src/types.ts @@ -0,0 +1,198 @@ +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +import * as gq from 'graphql'; +import { ObjMap } from "graphql/jsutils/ObjMap"; + + +//////// CONFIGURATION + +type MaybePromise = T | Promise + +export type JSONObject = ObjMap; + +/** Named arguments to a function call. */ +export type Args = { [key:string]: any}; + +/** JavaScript function. May return a Promise. */ +export type JSFn = (context: Context, args?: Args) => unknown; + +/** JavaScript GraphQL resolver function. */ +export type ResolverFn = (source: any, + args: Args, + context: Context, + info: ResolveInfo) => undefined; + +export type TypeResolverFn = (value: any, context: Context, info: ResolveInfo) => undefined; + +/** Entity-reference resolver, for Apollo subgraphs. */ +export type EntityReferenceResolver = (context: Context, + reference: object, + info: ResolveInfo) => any; + + +/** GraphQL resolver `info` parameter. */ +export interface ResolveInfo extends gq.GraphQLResolveInfo { + /** The names of the fields of the returned object that will be used. + * The resolver implementation may omit any fields not included in this list; + * this can be a significant optimization. */ + readonly selectedFieldNames : string[]; +}; + +/** Authorization for a function. */ +export type AllowConfig = { + users?: string[], // Names of allowed users + roles?: string[], // Allowed roles + channels?: string[], // Allowed channels +}; + +/** Defines a function or GraphQL resolver. */ +export type FunctionConfig = { + type: "query" | "javascript", // Language the 'code' is in + code: string, // The function's JavaScript code or N1QL query + args?: string[], // Names of parameters (not used by GraphQL) + mutating?: boolean, // Is function allowed to modify the database? + allow?: AllowConfig, // Who's allowed to call this +}; + +/** Functions configuration: maps function name to its config. */ +export type FunctionsConfig = { + definitions: Record // Names & definitions of the functions + max_function_count?: number; // Maximum number of functions + max_code_size?: number; // Maximum size in bytes of a fn's `code` + max_request_size?: number; // Maximum size in bytes of a request +}; + +export type FieldMap = Record; +export type ResolverMap = Record; + +/** GraphQL configuration. */ +export type GraphQLConfig = { + schema?: string, // The schema itself + schemaFile?: string, // Path to schema file (only if schema is not given) + resolvers: ResolverMap, // GraphQL resolver functions + subgraph?: boolean, // Enables Apollo Federation subgraph support + max_code_size?: number; // Maximum size in bytes of a function's `code` + max_request_size?: number; // Maximum size in bytes of an incoming request + max_resolver_count?: number; // Maximum number of resolvers + max_schema_size?: number; // Maximum size in bytes of the schema +}; + + +/** Top-level configuration. */ +export type Config = { + functions?: FunctionsConfig; + graphql?: GraphQLConfig; +} + + +//////// RUNTIME CONTEXT + + +/** Type of the `context` parameter passed to all functions. */ +export interface Context { + readonly user: User; + readonly admin: User; + + checkUser(name: string | string[]) : boolean; + requireUser(name: string | string[]) : void; + checkAdmin() : boolean; + requireAdmin() : void; + checkRole(role: string | string[]) : boolean; + requireRole(role: string | string[]) : void; + checkAccess(channel: string | string[]) : boolean; + requireAccess(channel: string | string[]) : void; + checkMutating() : boolean; + requireMutating() : void; +} + + +/** The type of the `context.user` and `context.admin` objects. + * Exposes auth and APIs scoped to either the current user, or to an admin. */ + export interface User { + readonly name?: string; + readonly roles?: string[]; + readonly channels?: string[]; + + readonly isGuest : boolean; + readonly isAdmin : boolean; // This is an admin user + readonly isSuperUser : boolean; // This is the magic "context.admin" user + + readonly canMutate : boolean; + + readonly defaultCollection: CRUD; + + function(name: string, args?: Args) : unknown; + graphql(query: string, args?: Args) : Promise; +}; + + +/** Shape of a Couchbase document, used in the CRUD API. */ +export interface Document { + _id? : string; // Document ID (primary key) + _rev? : string; // Revision ID (used for MVCC) +}; + + +/** The type of the `User.defaultCollection` object. Exposes database CRUD APIs. */ +export interface CRUD { + get(docID: string) : Document | null; + save(doc: Document, docID?: string) : string | null; + delete(docID: string) : boolean; + delete(doc: Document) : boolean; +} + + +//////// UTILITIES + + +/** An exception that conveys an HTTP status. */ +export class HTTPError extends Error { + constructor(readonly status: number, + readonly baseMessage: string) { + super(`[${status}] ${baseMessage}`); // unpackJSError() in evaluator.go parses this + } +} + + +//////// DATABASE + + +/** User credentials: tuple of [username, roles, channels] */ +export type Credentials = [string, string[], string[]]; + + +/** Top-level object that stores the compiled state for a database. */ +export interface Database { + /** Sets the configuration. Returns all errors found. */ + configure(functions: FunctionsConfig | undefined, + graphql: GraphQLConfig | undefined) : string[] | null; + + /** Creates an execution context given a user's name, roles and channels. */ + makeContext(credentials: Credentials | null, + mutationAllowed: boolean) : Context; + + /** Calls a named function. */ + callFunction(context: Context, + name: string, + args?: Args) : MaybePromise; + + /** Runs a N1QL query. Called by functions of type "query". */ + query(context: Context, + fnName: string, + n1ql: string, + args?: Args) : JSONObject[]; + + /** Runs a GraphQL query. */ + graphql(context: Context, + query: string, + variableValues?: Args, + operationName?: string) : Promise; +} diff --git a/db/functions/engine/tsconfig.json b/db/functions/engine/tsconfig.json new file mode 100644 index 0000000000..64e5a0c0ec --- /dev/null +++ b/db/functions/engine/tsconfig.json @@ -0,0 +1,106 @@ +{ + "include": ["./src/**/*"], + "exclude": [], + + "compilerOptions": { + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */ + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "ES2020", /* Specify what module code is generated. */ + "rootDir": "./src", /* Specify the root folder within your source files. */ + "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + //"outFile": "./engine.js", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + "outDir": "./js", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */ + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */ + + /* Type Checking */ + "strict": true, /* Enable all strict type-checking options. */ + "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */ + } +} diff --git a/db/functions/engine/webpack.config.js b/db/functions/engine/webpack.config.js new file mode 100644 index 0000000000..8f7d56c4f6 --- /dev/null +++ b/db/functions/engine/webpack.config.js @@ -0,0 +1,101 @@ +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +const path = require('path'); +const webpack = require('webpack'); + +const isProduction = process.env.NODE_ENV == 'production'; + +const LicenseComment = +`/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. + +NOTE: This file was automatically generated by WebPack -- see ../README.md for instructions. +DO NOT EDIT IT. + +NOTE: The above copyright notice applies ONLY to the Couchbase source code in this file, +generated from the TypeScript files in ../src, not to the third-party code also included. +*/ +`; + +const config = { + entry: './src/api.ts', // <-- main module + + output: { + path: path.resolve(__dirname, 'dist'), // <-- JS output directory + library: { + type: 'var', // <-- expose entry point as global var + name: 'SG_Engine', // <-- name of entry point + }, + }, + + module: { + rules: [ + { + test: /\.(ts|tsx)$/i, // Transpile TypeScript to JS + loader: 'ts-loader', + exclude: ['/node_modules/'], + }, + ], + }, + + resolve: { + extensions: ['.tsx', '.ts', '.jsx', '.js', '...'], + + fallback: { + // @apollo modules call node.js APIs. Substitute browser-compatible alternatives: + "assert": require.resolve("assert/"), + "console": require.resolve("console-browserify"), + "path": require.resolve("path-browserify"), + "url": path.resolve(__dirname, 'polyfill/url.js'), + "util": require.resolve("util/"), + // Omit this module entirely (any calls will throw) but it's never called: + "fs": false, + } + }, + + devtool: 'inline-source-map', // put JS source map in the code itself + + optimization: { + // Turn off JS minimization because it strips all comments, including the Couchbase + // license comment inserted by the BannerPlugin. + // (It's not important for us anyway: the code isn't being downloaded so the file size + // doesn't matter, and parsing only happens rarely when a new JS VM is spun up.) + minimize: false, + }, + + plugins: [ + new webpack.BannerPlugin({ + banner: LicenseComment, // Prepend the Couchbase license comment + raw: true, + }) + ], + + ignoreWarnings: [ // Suppress Web-specific warnings about big code + /asset size limit/, + /entrypoint size limit/, + /limit the size/, + ], +}; + +module.exports = () => { + if (isProduction) { + config.mode = 'production'; + } else { + config.mode = 'development'; + } + return config; +}; diff --git a/db/functions/evaluator.go b/db/functions/evaluator.go new file mode 100644 index 0000000000..addb1b97ce --- /dev/null +++ b/db/functions/evaluator.go @@ -0,0 +1,439 @@ +//go:build cb_sg_v8 + +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +package functions + +import ( + "context" + _ "embed" + "encoding/json" + "fmt" + "log" + "regexp" + "strconv" + "strings" + + "github.com/couchbase/sg-bucket/js" + "github.com/couchbase/sync_gateway/base" + "github.com/couchbase/sync_gateway/db" + v8 "github.com/couchbasedeps/v8go" // Docs: https://pkg.go.dev/github.com/couchbasedeps/v8go +) + +// The JavaScript code run in a context, that defines the API, embedded in a string constant. +// `main.js` is generated by WebPack from the TypeScript sources; see engine/webpack.config.js. +// +//go:embed engine/dist/main.js +var kJavaScriptCode string + +// Used for JSON-encoding configuration for engine. +// Equivalent to TypeScript type `Config` in types.ts +type jsConfig struct { + Functions *FunctionsConfig `json:"functions,omitempty"` + GraphQL *GraphQLConfig `json:"graphql,omitempty"` +} + +// js.Template implementation; a "subclass" of js.BasicTemplate. +type functionServiceTemplate struct { + *js.V8BasicTemplate // "Superclass" + upstreamTemplate *v8.ObjectTemplate // Template of object holding JS callbacks + jsonConfig *v8.Value // JSON configuration string +} + +// Returns a ServiceFactory function that instantiates a "functions" js.Service +func makeService(functions *FunctionsConfig, graphql *GraphQLConfig) js.TemplateFactory { + return func(base *js.V8BasicTemplate) (js.V8Template, error) { + // Initialize the BaseService and compile the JS code: + if err := base.SetScript(kJavaScriptCode + "\n SG_Engine.main;"); err != nil { + return nil, err + } + + // Create the top-level 'process' namespace that Apollo's libraries expect: + process := base.NewObjectTemplate() + if err := process.Set("env", base.NewObjectTemplate()); err != nil { + return nil, err + } else if err := base.Global().Set("process", process); err != nil { + return nil, err + } + + // Create the template for the "upstream" object containing the callbacks to Go: + upstream := base.NewObjectTemplate() + if err := upstream.Set("query", base.NewCallback(doQuery)); err != nil { + return nil, err + } else if err := upstream.Set("get", base.NewCallback(doGet)); err != nil { + return nil, err + } else if err := upstream.Set("save", base.NewCallback(doSave)); err != nil { + return nil, err + } else if err := upstream.Set("delete", base.NewCallback(doDelete)); err != nil { + return nil, err + } + + // Create a JS string of the configuration JSON: + jsonConfig, err := json.Marshal(jsConfig{Functions: functions, GraphQL: graphql}) + if err != nil { + return nil, err + } + jsonConfigVal, err := base.NewString(string(jsonConfig)) + if err != nil { + return nil, err + } + + // Wrap the service in a js.Service implementation: + return &functionServiceTemplate{ + V8BasicTemplate: base, + upstreamTemplate: upstream, + jsonConfig: jsonConfigVal, + }, nil + } +} + +//////// EVALUATOR + +// A JavaScript execution context in an Environment. This is what actually does the work. +// It wraps a js.Runner that was instantiated from the functionService. +// **Not thread-safe! Must be called only on one goroutine at a time. In fact, all Evaluators created from the same Environment must be called only one one goroutine.** +type evaluator struct { + runner *js.V8Runner // The V8 context + api *v8.Object // JavaScript `API` object (see api.ts) + functionFn *v8.Function // JavaScript `API.callFunction()` function + graphqlFn *v8.Function // JavaScript `API.graphql()` function + delegate evaluatorDelegate // Provides native callbacks like the CRUD API + user *userCredentials // Name & capabilities of the calling user + mutationAllowed bool // Is the Evaluator allowed to make mutating calls? +} + +// Pluggable implementation of native functionality the JS code calls -- CRUD, query, logging. +type evaluatorDelegate interface { + // Return an error if evaluation has gone on too long. + checkTimeout() error + + // Perform a N1QL query. + query(fnName string, n1ql string, args map[string]any, asAdmin bool) (rowsAsJSON string, err error) + + // Get a document. + get(docID string, collection string, asAdmin bool) (doc map[string]any, err error) + // Save/create a document. + save(doc map[string]any, docID string, collection string, asAdmin bool) (saved bool, err error) + // Delete a document. + delete(docID string, revID string, collection string, asAdmin bool) (ok bool, err error) +} + +// Returns an evaluator for use with a Service. +func makeEvaluator(service *js.Service, dbc *db.Database, delegate evaluatorDelegate, user *userCredentials, ctx context.Context) (*evaluator, error) { + runner, err := service.GetRunner() + if err != nil { + return nil, err + } + v8Runner := runner.(*js.V8Runner) + if v8Runner == nil { + panic("functions/graphql only supports V8 engine") + } + + if dbc.Options.JavascriptTimeout > 0 { + var cancelFn context.CancelFunc + ctx, cancelFn = context.WithTimeout(ctx, dbc.Options.JavascriptTimeout) + defer cancelFn() + } + runner.SetContext(ctx) + + eval, ok := v8Runner.Client.(*evaluator) + if !ok { + if eval, err = newEvaluator(v8Runner); err != nil { + runner.Return() + return nil, err + } + } + eval.setup(delegate, user) + return eval, nil +} + +// Creates an Evaluator, wrapping a js.V8Runner. +// Usually it's better to call makeEvaluator since that will reuse an existing instance. +func newEvaluator(runner *js.V8Runner) (*evaluator, error) { + eval := &evaluator{runner: runner} + runner.Client = eval + + // Call the JS initialization code, passing it the configuration and the Upstream. + // This returns the JS `API` object. + fnService := runner.Template().(*functionServiceTemplate) + if fnService == nil { + panic("Couldn't cast to functionService") + } + upstream, err := runner.NewInstance(fnService.upstreamTemplate) + if err != nil { + return nil, err + } + eval.api, err = runner.RunAsObject(fnService.jsonConfig, upstream) + if err != nil { + return nil, err + } + + // Check the API.errors property for configuration errors: + if errorsVal, err := eval.api.Get("errors"); err != nil { + return nil, err + } else if errorArray, _ := errorsVal.AsArray(); errorArray != nil { + var errors *base.MultiError + len := errorArray.Length() + for i := uint32(0); i < len; i++ { + if errorVal, err := errorArray.GetIdx(i); err == nil { + errors = errors.Append(fmt.Errorf(errorVal.String())) + } + } + return nil, errors + } + + eval.functionFn = mustGetV8Fn(eval.api, "callFunction") + eval.graphqlFn = mustGetV8Fn(eval.api, "graphql") + return eval, nil +} + +func (eval *evaluator) setup(delegate evaluatorDelegate, user *userCredentials) { + if delegate == nil { + panic("nil delegate!") + } + eval.delegate = delegate + eval.user = user +} + +// Call this when finished using an evaluator. +func (eval *evaluator) close() { + eval.delegate = nil + eval.user = nil + eval.runner.Return() // This must be the last thing the evaluator does +} + +// Configures whether the Evaluator is allowed to mutate the database; if false (the default), calls to `save()` and `delete()` will fail. +func (eval *evaluator) setMutationAllowed(allowed bool) { + eval.mutationAllowed = allowed +} + +// Calls a named function. Result is returned as JSON data. +func (eval *evaluator) callFunction(name string, args map[string]any) ([]byte, error) { + return eval.wrapCall(func() (*v8.Value, error) { + user, roles, channels, err := eval.v8Credentials() + if err != nil { + return nil, err + } + jsonArgs, err := eval.runner.NewJSONString(args) + if err != nil { + return nil, err + } + args, err := eval.runner.ConvertArgs(name, jsonArgs, user, roles, channels, eval.mutationAllowed) + if err != nil { + return nil, err + } + // Calling JS method API.callFunction (api.ts) + return eval.runner.Call(eval.functionFn, eval.api, args...) + }) +} + +// Performs a GraphQL query. Result is an object of the usual GraphQL result shape, i.e. with `data` and/or `errors` properties. It is returned as a JSON string. +func (eval *evaluator) callGraphQL(query string, operationName string, variables map[string]any) ([]byte, error) { + return eval.wrapCall(func() (*v8.Value, error) { + user, roles, channels, err := eval.v8Credentials() + if err != nil { + return nil, err + } + jsonVariables, err := eval.runner.NewJSONString(variables) + if err != nil { + return nil, err + } + args, err := eval.runner.ConvertArgs(query, operationName, jsonVariables, user, roles, channels, eval.mutationAllowed) + if err != nil { + return nil, err + } + // Calling JS method API.callGraphQL (api.ts) + return eval.runner.Call(eval.graphqlFn, eval.api, args...) + }) +} + +// wraps a callback that makes a JS call. Converts the return value and error appropriately, +// and uses WithScopedValues so temporary values get cleaned up. +func (eval *evaluator) wrapCall(fn func() (*v8.Value, error)) (result []byte, err error) { + eval.runner.WithTemporaryValues(func() { + if v8Result, v8Err := fn(); v8Err == nil { + if resultStr, ok := js.StringToGo(v8Result); ok { + result = []byte(resultStr) + } + } else { + err = unpackError(v8Err) + } + }) + return +} + +// Encodes credentials as 3 parameters to pass to JS. +func (eval *evaluator) v8Credentials() (user *v8.Value, roles *v8.Value, channels *v8.Value, err error) { + undef := eval.runner.UndefinedValue() + if eval.user != nil { + user, err = eval.runner.NewString(eval.user.Name) + if err != nil { + return + } + } else { + user = undef + } + if eval.user != nil && len(eval.user.Roles) > 0 { + roles, err = eval.runner.NewString(strings.Join(eval.user.Roles, ",")) + if err != nil { + return + } + } else { + roles = undef + } + if eval.user != nil && len(eval.user.Channels) > 0 { + channels, err = eval.runner.NewString(strings.Join(eval.user.Channels, ",")) + if err != nil { + return + } + } else { + channels = undef + } + return +} + +//////// EVALUATOR CALLBACK IMPLEMENTATIONS: + +// query(fnName: string, n1ql: string, argsJSON: string | undefined, asAdmin: boolean) : string; +func doQuery(r *js.V8Runner, this *v8.Object, args []*v8.Value) (any, error) { + fnName := args[0].String() + n1ql := args[1].String() + fnArgs, err := jsonToGoMap(args[2]) + if err != nil { + return nil, err + } + asAdmin := args[3].Boolean() + eval := r.Client.(*evaluator) + return eval.delegate.query(fnName, n1ql, fnArgs, asAdmin) +} + +// get(docID: string, collection: string, asAdmin: boolean) : string | null; +func doGet(r *js.V8Runner, this *v8.Object, args []*v8.Value) (any, error) { + docID := args[0].String() + collection := args[1].String() + asAdmin := args[2].Boolean() + eval := r.Client.(*evaluator) + return returnAsJSON(eval.delegate.get(docID, collection, asAdmin)) +} + +// save(docJSON: string, docID: string | undefined, collection: string, asAdmin: boolean) : string | null; +func doSave(r *js.V8Runner, this *v8.Object, args []*v8.Value) (any, error) { + var docID string + doc, err := jsonToGoMap(args[0]) + if err != nil { + return nil, err + } + if arg1 := args[1]; arg1.IsString() { + docID = arg1.String() + } else if _id, found := doc["_id"].(string); found { + docID = _id + } else { + docID, err = base.GenerateRandomID() + if err != nil { + return nil, err + } + } + collection := args[2].String() + asAdmin := args[3].Boolean() + + eval := r.Client.(*evaluator) + if saved, err := eval.delegate.save(doc, docID, collection, asAdmin); saved && err == nil { + return docID, nil + } else { + return nil, err + } +} + +// delete(docID: string, revID: string | undefined, collection: string, asAdmin: boolean) : boolean; +func doDelete(r *js.V8Runner, this *v8.Object, args []*v8.Value) (any, error) { + docID := args[0].String() + var revID string + if arg1 := args[1]; arg1.IsString() { + revID = arg1.String() + } + collection := args[2].String() + asAdmin := args[3].Boolean() + eval := r.Client.(*evaluator) + return eval.delegate.delete(docID, revID, collection, asAdmin) +} + +//////// UTILITIES + +// Simple utility to wrap a function that returns a value and an error; returns just the value, panicking if there was an error. +// This is kind of equivalent to those 3-prong to 2-prong electric plug adapters... +// Needless to say, it should only be used if you know the error cannot occur, or that if it occurs something is very, very wrong. +func mustSucceed[T any](result T, err error) T { + if err != nil { + log.Fatalf("ASSERTION FAILURE: expected a %T, got %v", result, err) + } + return result +} + +func mustNoError(err error) { + if err != nil { + log.Fatalf("ASSERTION FAILURE: unexpected error %v", err) + } +} + +// Gets a named method of a JS object. Panics if not found. +func mustGetV8Fn(owner *v8.Object, name string) *v8.Function { + fnVal := mustSucceed(owner.Get(name)) + return mustSucceed(fnVal.AsFunction()) +} + +// Converts a result and error to a JSON-encoded string and error. +// - If `err` is non-nil on input, just passes it through. +// - Otherwise it JSON-encodes the `result` and returns it. +func returnAsJSON(result any, err error) (any, error) { + if result == nil || err != nil { + return nil, err + } else if jsonBytes, err := json.Marshal(result); err != nil { + return nil, err + } else { + return string(jsonBytes), nil + } +} + +// Converts & parses a JS string of JSON into a Go map. +func jsonToGoMap(val *v8.Value) (map[string]any, error) { + if val.IsNullOrUndefined() { + return nil, nil + } else if jsonStr, ok := js.StringToGo(val); !ok { + return nil, fmt.Errorf("unexpected error: instead of a string, got %s", val.DetailString()) + } else { + var result map[string]any + err := json.Unmarshal([]byte(jsonStr), &result) + return result, err + } +} + +// (This detects the way HTTP statuses are encoded into error messages by the class HTTPError in types.ts.) +var kHTTPErrRegexp = regexp.MustCompile(`^(Error:\s*)?\[(\d\d\d)\]\s+(.*)`) + +// Looks for an HTTP status in an error message and returns it as an HTTPError; else returns nil. +func unpackErrorStr(jsErrMessage string) error { + if m := kHTTPErrRegexp.FindStringSubmatch(jsErrMessage); m != nil { + if status, err := strconv.ParseUint(m[2], 10, 16); err == nil { + return &base.HTTPError{Status: int(status), Message: m[3]} + } + } + return nil +} + +// Postprocesses an error returned from running JS code, detecting the HTTPError type defined in types.ts. If the error is a v8.JSError, looks for an HTTP status in brackets at the start of the message; if found, returns a base.HTTPError. +func unpackError(err error) error { + if jsErr, ok := err.(*v8.JSError); ok { + if unpackedErr := unpackErrorStr(jsErr.Message); unpackedErr != nil { + return unpackedErr + } + } + return err +} diff --git a/db/functions/evaluator_test.go b/db/functions/evaluator_test.go new file mode 100644 index 0000000000..1d7e4459e6 --- /dev/null +++ b/db/functions/evaluator_test.go @@ -0,0 +1,101 @@ +//go:build cb_sg_v8 + +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +package functions + +import ( + "net/http" + "strconv" + "testing" + + "github.com/couchbase/sg-bucket/js" + "github.com/couchbase/sync_gateway/base" + "github.com/stretchr/testify/assert" +) + +// A basic bring-up test of the Evaluator and TypeScript engine. +func TestEvaluator(t *testing.T) { + ctx := base.TestCtx(t) + vm := js.V8.NewVM(ctx) + defer vm.Close() + + delegate := mockEvaluatorDelegate{} + eval, err := newStandaloneEvaluator(ctx, vm, &kTestFunctionsConfig, &kTestGraphQLConfig, &delegate) + if !assert.NoError(t, err) { + return + } + defer eval.close() + + result, err := eval.callFunction("square", map[string]any{"numero": 13}) + assert.NoError(t, err) + assert.Equal(t, "169", string(result)) + + result, err = eval.callFunction("cube", map[string]any{"numero": 13}) + assert.NoError(t, err) + assert.Equal(t, "2197", string(result)) +} + +//////// MOCK EVALUATOR DELEGATE (CRUD FUNCTIONS) + +type mockDoc = map[string]any + +type mockEvaluatorDelegate struct { + docs map[string]mockDoc +} + +func (d *mockEvaluatorDelegate) checkTimeout() error { return nil } + +func (d *mockEvaluatorDelegate) query(fnName string, n1ql string, args map[string]any, asAdmin bool) (rowsJSON string, err error) { + return "", base.HTTPErrorf(http.StatusNotImplemented, "query unimplemented") +} + +func (d *mockEvaluatorDelegate) get(docID string, coll string, asAdmin bool) (doc map[string]any, err error) { + return d.docs[docID], nil +} + +func (d *mockEvaluatorDelegate) save(doc map[string]any, docID string, coll string, asAdmin bool) (saved bool, err error) { + existingDoc := d.docs[docID] + curRevID, curExists := existingDoc["_rev"].(string) + if revID, exists := doc["_rev"].(string); exists { + if revID != curRevID || !curExists { + return false, nil + } + } + + var gen uint64 + if curExists { + gen, _ = strconv.ParseUint(curRevID, 10, 64) + } + doc["_id"] = docID + doc["_rev"] = strconv.FormatUint(gen+1, 10) + + if d.docs == nil { + d.docs = map[string]mockDoc{} + } + d.docs[docID] = doc + return true, nil +} + +func (d *mockEvaluatorDelegate) delete(docID string, revID string, coll string, asAdmin bool) (bool, error) { + existingDoc := d.docs[docID] + if existingDoc == nil { + return true, nil + } + if len(revID) > 0 { + curRevID, _ := existingDoc["_rev"].(string) + if revID != curRevID { + return false, nil + } + } + delete(d.docs, docID) + return true, nil +} diff --git a/db/functions/function.go b/db/functions/function.go index dd7d752ec5..0b029ba909 100644 --- a/db/functions/function.go +++ b/db/functions/function.go @@ -1,3 +1,5 @@ +//go:build cb_sg_v8 + /* Copyright 2022-Present Couchbase, Inc. @@ -12,118 +14,129 @@ package functions import ( "context" + "encoding/json" "fmt" - "net/http" - "reflect" - "regexp" - "strconv" - "strings" + "os" sgbucket "github.com/couchbase/sg-bucket" - "github.com/couchbase/sync_gateway/auth" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" - "github.com/couchbase/sync_gateway/channels" "github.com/couchbase/sync_gateway/db" - _ "github.com/robertkrimen/otto/underscore" ) -//////// CONFIGURATION TYPES: - -// Top level user-function config object: the map of names to queries. -type FunctionsConfig struct { - Definitions FunctionsDefs `json:"definitions"` // The function definitions - MaxFunctionCount *int `json:"max_function_count,omitempty"` // Maximum number of functions - MaxCodeSize *int `json:"max_code_size,omitempty"` // Maximum length (in bytes) of a function's code - MaxRequestSize *int `json:"max_request_size,omitempty"` // Maximum size of the JSON-encoded function arguments -} - -type FunctionsDefs = map[string]*FunctionConfig - -// Defines a JavaScript or N1QL function that a client can invoke by name. -// (Its name is the key in the FunctionsDefs.) -type FunctionConfig struct { - Type string `json:"type"` - Code string `json:"code"` // Javascript function or N1QL 'SELECT' - Args []string `json:"args,omitempty"` // Names of parameters/arguments - Mutating bool `json:"mutating,omitempty"` // Allowed to modify database? - Allow *Allow `json:"allow,omitempty"` // Permissions (admin-only if nil) -} +//////// INITIALIZATION: -// Permissions for a function -type Allow struct { - Channels []string `json:"channels,omitempty"` // Names of channel(s) that grant access - Roles []string `json:"roles,omitempty"` // Names of role(s) that have access - Users base.Set `json:"users,omitempty"` // Names of user(s) that have access +func (fnc *Config) Compile(vms *js.VMPool) (*db.UserFunctions, db.GraphQL, error) { + return CompileFunctions(fnc.Functions, fnc.GraphQL, vms) } -//////// INITIALIZATION: - -// implements UserFunction. Used for both JS and N1QL. -type functionImpl struct { - *FunctionConfig // Inherits from FunctionConfig - name string // Name of function - typeName string // "function" or "resolver" - checkArgs bool // If true, args must be checked against Args - allowByDefault bool // If true, a missing Allow means allow, not forbid - compiled *sgbucket.JSServer // Compiled form of the function; nil for N1QL +func (fnc *Config) N1QLQueryNames() []string { + queryNames := []string{} + if fnc.Functions != nil { + for fnName, fn := range fnc.Functions.Definitions { + if fn.Type == "query" { + queryNames = append(queryNames, db.QueryTypeUserFunctionPrefix+fnName) + } + } + } + if fnc.GraphQL != nil { + for typeName, resolvers := range fnc.GraphQL.Resolvers { + for fieldName, resolver := range resolvers { + if resolver.Type == "query" { + queryNames = append(queryNames, db.QueryTypeUserFunctionPrefix+graphQLResolverName(typeName, fieldName)) + } + } + } + } + return queryNames } // Compiles the functions in a UserFunctionConfigMap, returning UserFunctions. -func CompileFunctions(config FunctionsConfig) (*db.UserFunctions, error) { - if config.MaxFunctionCount != nil && len(config.Definitions) > *config.MaxFunctionCount { - return nil, fmt.Errorf("too many functions declared (> %d)", *config.MaxFunctionCount) +func CompileFunctions(fnConfig *FunctionsConfig, gqConfig *GraphQLConfig, vms *js.VMPool) (fns *db.UserFunctions, gq db.GraphQL, err error) { + if fnConfig == nil && gqConfig == nil { + return } - fns := db.UserFunctions{ - MaxRequestSize: config.MaxRequestSize, - Definitions: map[string]db.UserFunction{}, + if err = checkEngine(vms); err != nil { + return } - var multiError *base.MultiError - for name, fnConfig := range config.Definitions { - if config.MaxCodeSize != nil && len(fnConfig.Code) > *config.MaxCodeSize { - multiError = multiError.Append(fmt.Errorf("function code too large (> %d bytes)", *config.MaxCodeSize)) - } else if userFn, err := compileFunction(name, "function", fnConfig); err == nil { - fns.Definitions[name] = userFn - } else { - multiError = multiError.Append(err) + if gqConfig, err = readSchema(gqConfig); err != nil { + return + } + + service := js.NewCustomService(vms, "functions", makeService(fnConfig, gqConfig)) + + if fnConfig != nil { + fns = &db.UserFunctions{ + MaxRequestSize: fnConfig.MaxRequestSize, + Definitions: map[string]db.UserFunction{}, + } + for name, fnConfig := range fnConfig.Definitions { + fns.Definitions[name] = &functionImpl{ + FunctionConfig: fnConfig, + service: service, + name: name, + } + } + } + if gqConfig != nil { + gq = &graphQLImpl{ + config: gqConfig, + service: service, } } - return &fns, multiError.ErrorOrNil() + return } -// Validates a FunctionsConfig. -func ValidateFunctions(ctx context.Context, config FunctionsConfig) error { - _, err := CompileFunctions(config) - return err +func checkEngine(host js.ServiceHost) error { + if host.Engine().LanguageVersion() < js.ES2015 { + return fmt.Errorf("user functions and GraphQL are not compatible with JavaScript engine %s", host.Engine()) + } + return nil } -// Creates a functionImpl from a UserFunctionConfig. -func compileFunction(name string, typeName string, fnConfig *FunctionConfig) (*functionImpl, error) { - userFn := &functionImpl{ - FunctionConfig: fnConfig, - name: name, - typeName: typeName, - checkArgs: true, +// Creates an evaluator using a new VM not belonging to a pool. +// Remember to close it when finished! +func newStandaloneEvaluator(ctx context.Context, vm js.ServiceHost, fnConfig *FunctionsConfig, gqConfig *GraphQLConfig, delegate evaluatorDelegate) (*evaluator, error) { + if fnConfig == nil && gqConfig == nil { + return nil, nil } - var err error - switch fnConfig.Type { - case "javascript": - userFn.compiled, err = newFunctionJSServer(name, typeName, fnConfig.Code) - case "query": - err = validateN1QLQuery(fnConfig.Code) + if err := checkEngine(vm); err != nil { + return nil, err + } + service := js.NewCustomService(vm, "functions", makeService(fnConfig, gqConfig)) + if runner, err := service.GetRunner(); err != nil { + return nil, err + } else { + runner.SetContext(ctx) + eval, err := newEvaluator(runner.(*js.V8Runner)) if err != nil { - err = fmt.Errorf("%s %q invalid query: %v", typeName, name, err) + return nil, err } - default: - err = fmt.Errorf("%s %q has unrecognized 'type' %q", typeName, name, fnConfig.Type) + eval.setup(delegate, nil) + return eval, nil } +} - if err == nil { - if err = fnConfig.validateAllow(); err != nil { - err = base.HTTPErrorf(http.StatusInternalServerError, "%s %q has an illegal 'allow' pattern: %v", typeName, name, err) - - } +// Validates a FunctionsConfig & GraphQLConfig. +func ValidateFunctions(ctx context.Context, vm js.ServiceHost, fnConfig *FunctionsConfig, gqConfig *GraphQLConfig) error { + gqConfig, err := readSchema(gqConfig) + if err != nil { + return err + } + eval, err := newStandaloneEvaluator(ctx, vm, fnConfig, gqConfig, &databaseDelegate{ctx: ctx}) + if err == nil && eval != nil { + eval.close() } - return userFn, err + return err +} + +//////// FUNCTIONIMPL + +// implements UserFunction. +type functionImpl struct { + *FunctionConfig // Inherits from FunctionConfig + service *js.Service + name string // Name of function } func (fn *functionImpl) Name() string { @@ -131,7 +144,7 @@ func (fn *functionImpl) Name() string { } func (fn *functionImpl) isN1QL() bool { - return fn.compiled == nil + return fn.Type == "query" } func (fn *functionImpl) N1QLQueryName() (string, bool) { @@ -143,270 +156,128 @@ func (fn *functionImpl) N1QLQueryName() (string, bool) { } // Creates an Invocation of a UserFunction. -func (fn *functionImpl) Invoke(database *db.Database, args map[string]any, mutationAllowed bool, ctx context.Context) (db.UserFunctionInvocation, error) { - if ctx == nil { - return nil, fmt.Errorf("missing context to UserFunction.Invoke") - } - - if err := db.CheckTimeout(ctx); err != nil { - return nil, err - } - - if args == nil { - args = map[string]any{} - } - if fn.checkArgs { - if err := fn.checkArguments(args); err != nil { - return nil, err - } +func (fn *functionImpl) Invoke(dbc *db.Database, args map[string]any, mutationAllowed bool, ctx context.Context) (db.UserFunctionInvocation, error) { + inv := functionInvocation{ + functionImpl: fn, + args: args, + mutationAllowed: mutationAllowed, } + err := inv.delegate.init(dbc, ctx) + return &inv, err +} - // Check that the user is authorized: - if fn.Allow != nil || !fn.allowByDefault { - if err := fn.authorize(database.User(), args); err != nil { - return nil, err - } - } +// Implements UserFunctionInvocation +type functionInvocation struct { + *functionImpl + args map[string]any + mutationAllowed bool + delegate databaseDelegate +} - if (!fn.Mutating || !mutationAllowed) && ctx.Value(readOnlyKey) == nil { - // Add a value to the Context to indicate that mutations aren't allowed: - var why string - if !fn.Mutating { - why = fmt.Sprintf("%s %q", fn.typeName, fn.name) - } else { - why = "a read-only API call" - } - ctx = context.WithValue(ctx, readOnlyKey, why) - } +func (inv *functionInvocation) Iterate() (sgbucket.QueryResultIterator, error) { + return nil, nil +} - if fn.isN1QL() { - return &n1qlInvocation{ - functionImpl: fn, - db: database, - args: args, - ctx: ctx, - }, nil +func (inv *functionInvocation) Run() (interface{}, error) { + if resultJSON, err := inv.RunAsJSON(); err != nil { + return nil, err + } else if resultJSON == nil { + return nil, nil } else { - return &jsInvocation{ - functionImpl: fn, - db: database, - ctx: ctx, - args: args, - }, nil + var result any + err := json.Unmarshal([]byte(resultJSON), &result) + return result, err } } -//////// FUNCTION PARAMETERS/ARGUMENTS: - -// Checks that `args` contains exactly the same keys as the list `parameterNames`. -// Adds the special "context" parameter containing user data. -func (fn *functionImpl) checkArguments(args map[string]any) error { - // Make sure each specified parameter has a value in `args`: - for _, paramName := range fn.Args { - if _, found := args[paramName]; !found { - return base.HTTPErrorf(http.StatusBadRequest, "%s %q parameter %q is missing", fn.typeName, fn.name, paramName) - } - } - - // Any extra parameters in `args` are illegal: - if len(args) > len(fn.Args) { - for _, paramName := range fn.Args { - delete(args, paramName) - } - for badKey := range args { - return base.HTTPErrorf(http.StatusBadRequest, "%s %q has no parameter %q", fn.typeName, fn.name, badKey) - } +func (inv *functionInvocation) RunAsJSON() ([]byte, error) { + delegate := &inv.delegate + eval, err := makeEvaluator(inv.service, delegate.db, delegate, delegate.user, delegate.ctx) + if err != nil { + return nil, err } - return nil + defer eval.close() + eval.setMutationAllowed(inv.mutationAllowed) + return eval.callFunction(inv.name, inv.args) } -//////// AUTHORIZATION: - -// Looks for bad '$' patterns in the config's Allow strings. -func (fn *FunctionConfig) validateAllow() error { - if fn.Allow != nil { - // Construct an args object with a value for each declared argument: - fakeArgs := map[string]any{} - for _, argName := range fn.Args { - fakeArgs[argName] = "x" - } - // Subroutine that tests a pattern by trying to expand it with the args. - // If the result is a 500 error, something's wrong with the pattern itself. - checkPattern := func(pattern string) error { - _, err := expandPattern(pattern, fakeArgs, nil) - if err, ok := err.(*base.HTTPError); ok { - if err != nil && err.Status >= http.StatusInternalServerError { - return err - } - } - return nil - } - // Test each role and channel string: - for _, str := range fn.Allow.Roles { - if err := checkPattern(str); err != nil { - return err - } - } - for _, str := range fn.Allow.Channels { - if err := checkPattern(str); err != nil { - return err - } +//////// GRAPHQLIMPL + +// If the config's SchemaFile is set, reads the file and puts its contents into Schema. +// Returns a _copy_ of the config, to avoid mutating the original. +func readSchema(gq *GraphQLConfig) (*GraphQLConfig, error) { + if gq == nil { + return gq, nil + } else if gq.SchemaFile != nil { + // Read schema file: + if gq.Schema != nil { + return nil, fmt.Errorf("GraphQL config: only one of `schema` and `schemaFile` may be used`") + } else if schema, err := os.ReadFile(*gq.SchemaFile); err != nil { + return nil, fmt.Errorf("GraphQL: can't read schema file %s: %w", *gq.SchemaFile, err) + } else { + mutConfig := *gq + mutConfig.Schema = base.StringPtr(string(schema)) + mutConfig.SchemaFile = nil + return &mutConfig, nil } + } else if gq.Schema != nil { + return gq, nil + } else { + return nil, fmt.Errorf("GraphQL config: either `schema` or `schemaFile` must be defined") } - return nil } -// Authorizes a User against the function config's Allow object: -// - The user's name must be contained in Users, OR -// - The user must have a role contained in Roles, OR -// - The user must have access to a channel contained in Channels. -// In Roles and Channels, patterns of the form `${param}` are expanded using `args` and `user`. -func (fn *functionImpl) authorize(user auth.User, args map[string]any) error { - allow := fn.Allow - if user == nil { - return nil // User is admin - } else if allow != nil { // No Allow object means admin-only - if allow.Users.Contains(user.Name()) { - return nil // User is explicitly allowed - } - userRoles := user.RoleNames() - for _, rolePattern := range allow.Roles { - if role, err := expandPattern(rolePattern, args, user); err != nil { - return err - } else if userRoles.Contains(role) { - return nil // User has one of the allowed roles - } - } - // Check if the user has access to one of the given channels. - for _, channelPattern := range allow.Channels { - if channelPattern == channels.AllChannelWildcard { - return nil - } else if channel, err := expandPattern(channelPattern, args, user); err != nil { - return err - } else if user.CanSeeCollectionChannel(base.DefaultScope, base.DefaultCollection, channel) { - return nil // User has access to one of the allowed channels - } - } - } - return user.UnauthError(fmt.Sprintf("you are not allowed to call %s %q", fn.typeName, fn.name)) +// Implementation of db.graphQLImpl interface. +type graphQLImpl struct { + config *GraphQLConfig + service *js.Service } -// Expands patterns of the form `${param}` in `pattern`, looking up each such -// `param` in the `args` map and substituting its value. -// (`\$` is replaced with `$`.) -// It is an error if any `param` has no value, or if its value is not a string or integer. -func expandPattern(pattern string, args map[string]any, user auth.User) (string, error) { - if strings.IndexByte(pattern, '$') < 0 { - return pattern, nil - } - var err error - channel := kChannelPropertyRegexp.ReplaceAllStringFunc(pattern, func(matched string) string { - if err != nil { - return "" - } else if matched == "\\$" { - return "$" - } else if !strings.HasPrefix(matched, "${") || !strings.HasSuffix(matched, "}") { - err = base.HTTPErrorf(http.StatusInternalServerError, "missing curly-brace in pattern %q", matched) - return "" - } - arg := matched[2 : len(matched)-1] - - // Look up the argument: - if strings.HasPrefix(arg, "args.") { - var rval reflect.Value - rval, err = evalKeyPath(args, arg[5:]) - if err != nil { - return "" - } - - // Convert `rval` to a string: - for rval.Kind() == reflect.Interface { - rval = rval.Elem() - } - if rval.Kind() == reflect.String { - return rval.String() - } else if rval.CanInt() || rval.CanUint() || rval.CanFloat() || rval.Kind() == reflect.Bool { - return fmt.Sprintf("%v", rval) - } else { - err = base.HTTPErrorf(http.StatusBadRequest, "argument %q must be a string or number or boolean, not %v", arg, rval.Kind()) - return "" - } - } else if arg == "context.user.name" { - if user == nil { - return "" - } else { - return user.Name() - } - } else { - err = base.HTTPErrorf(http.StatusInternalServerError, "invalid variable expression %q", matched) - return "" - } - }) - return channel, err +func (gq *graphQLImpl) MaxRequestSize() *int { + return gq.config.MaxRequestSize } -// Evaluates a "key path", like "points[3].x.y" on a JSON-based map. -func evalKeyPath(root map[string]any, keyPath string) (reflect.Value, error) { - // Handle the first path component specially because we can access `root` without reflection: - var value reflect.Value - i := strings.IndexAny(keyPath, ".[") - if i < 0 { - i = len(keyPath) - } - key := keyPath[0:i] - keyPath = keyPath[i:] - firstVal := root[key] - if firstVal == nil { - return value, base.HTTPErrorf(http.StatusInternalServerError, "parameter %q is not declared in 'args'", key) +func (gq *graphQLImpl) QueryAsJSON(dbc *db.Database, query string, operationName string, variables map[string]interface{}, mutationAllowed bool, ctx context.Context) ([]byte, error) { + var delegate databaseDelegate + if err := delegate.init(dbc, ctx); err != nil { + return nil, err } - - value = reflect.ValueOf(firstVal) - if len(keyPath) == 0 { - return value, nil + eval, err := makeEvaluator(gq.service, dbc, &delegate, delegate.user, ctx) + if err != nil { + return nil, err } + defer eval.close() - for len(keyPath) > 0 { - ch := keyPath[0] - keyPath = keyPath[1:] - if ch == '.' { - i = strings.IndexAny(keyPath, ".[") - if i < 0 { - i = len(keyPath) - } - key = keyPath[0:i] - keyPath = keyPath[i:] + eval.setMutationAllowed(mutationAllowed) + return eval.callGraphQL(query, operationName, variables) +} - if value.Kind() != reflect.Map { - return value, base.HTTPErrorf(http.StatusBadRequest, "value is not a map") - } - value = value.MapIndex(reflect.ValueOf(key)) - } else if ch == '[' { - i = strings.IndexByte(keyPath, ']') - if i < 0 { - return value, base.HTTPErrorf(http.StatusInternalServerError, "missing ']") - } - key = keyPath[0:i] - keyPath = keyPath[i+1:] +func (gq *graphQLImpl) Query(dbc *db.Database, query string, operationName string, variables map[string]interface{}, mutationAllowed bool, ctx context.Context) (*db.GraphQLResult, error) { + resultJSON, err := gq.QueryAsJSON(dbc, query, operationName, variables, mutationAllowed, ctx) + if err != nil { + return nil, err + } else if resultJSON == nil { + return nil, nil + } else { + var result db.GraphQLResult + err = json.Unmarshal(resultJSON, &result) + return &result, err + } +} - index, err := strconv.ParseUint(key, 10, 8) - if err != nil { - return value, err - } - if value.Kind() != reflect.Array && value.Kind() != reflect.Slice { - return value, base.HTTPErrorf(http.StatusBadRequest, "value is a %v not an array", value.Type()) - } else if uint64(value.Len()) <= index { - return value, base.HTTPErrorf(http.StatusBadRequest, "array index out of range") +// Returns the names of all N1QL queries used. +func (gq *graphQLImpl) N1QLQueryNames() []string { + queryNames := []string{} + for typeName, resolvers := range gq.config.Resolvers { + for fieldName, resolver := range resolvers { + if resolver.Type == "query" { + queryNames = append(queryNames, db.QueryTypeUserFunctionPrefix+graphQLResolverName(typeName, fieldName)) } - value = value.Index(int(index)) - } else { - return value, base.HTTPErrorf(http.StatusInternalServerError, "invalid character after a ']'") - } - for value.Kind() == reflect.Interface || value.Kind() == reflect.Pointer { - value = value.Elem() } } - return value, nil + return queryNames } -// Regexp that matches a property pattern `${...}`, or a backslash-escaped `$`. -var kChannelPropertyRegexp = regexp.MustCompile(`(\\\$)|(\${?[^{}]*}?)`) +func graphQLResolverName(typeName string, fieldName string) string { + return typeName + "." + fieldName +} diff --git a/db/functions/function_base.go b/db/functions/function_base.go new file mode 100644 index 0000000000..131866fd3d --- /dev/null +++ b/db/functions/function_base.go @@ -0,0 +1,64 @@ +// Copyright 2023-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. + +package functions + +import "github.com/couchbase/sync_gateway/base" + +// Combines functions & GraphQL configuration. Implements db.IFunctionsAndGraphQLConfig. +type Config struct { + Functions *FunctionsConfig + GraphQL *GraphQLConfig +} + +// Top level user-function config object: the map of names to queries. +type FunctionsConfig struct { + Definitions FunctionsDefs `json:"definitions"` // The function definitions + MaxFunctionCount *int `json:"max_function_count,omitempty"` // Maximum number of functions + MaxCodeSize *int `json:"max_code_size,omitempty"` // Maximum length (in bytes) of a function's code + MaxRequestSize *int `json:"max_request_size,omitempty"` // Maximum size of the JSON-encoded function arguments +} + +type FunctionsDefs = map[string]*FunctionConfig + +// Defines a JavaScript or N1QL function that a client can invoke by name. +// (Its name is the key in the FunctionsDefs.) +type FunctionConfig struct { + Type string `json:"type"` + Code string `json:"code"` // Javascript function or N1QL 'SELECT' + Args []string `json:"args,omitempty"` // Names of parameters/arguments + Mutating bool `json:"mutating,omitempty"` // Allowed to modify database? + Allow *Allow `json:"allow,omitempty"` // Permissions (admin-only if nil) +} + +// Permissions for a function +type Allow struct { + Channels []string `json:"channels,omitempty"` // Names of channel(s) that grant access + Roles []string `json:"roles,omitempty"` // Names of role(s) that have access + Users base.Set `json:"users,omitempty"` // Names of user(s) that have access +} + +// Configuration for GraphQL. +type GraphQLConfig struct { + Schema *string `json:"schema,omitempty"` // Schema in SDL syntax + SchemaFile *string `json:"schemaFile,omitempty"` // Path of schema file + Resolvers GraphQLTypesMap `json:"resolvers"` // Defines query/mutation code + Subgraph bool `json:"subgraph,omitempty"` // Enable Apollo Subgraph support + MaxSchemaSize *int `json:"max_schema_size,omitempty"` // Maximum length (in bytes) of GraphQL schema + MaxResolverCount *int `json:"max_resolver_count,omitempty"` // Maximum number of GraphQL resolvers + MaxCodeSize *int `json:"max_code_size,omitempty"` // Maximum length (in bytes) of a function's code + MaxRequestSize *int `json:"max_request_size,omitempty"` // Maximum size of the encoded query & arguments +} + +//////// CONFIGURATION TYPES: + +// Maps GraphQL type names (incl. "Query") to their resolvers. +type GraphQLTypesMap map[string]GraphQLResolverConfig + +// Maps GraphQL field names to the resolvers that implement them. +type GraphQLResolverConfig map[string]FunctionConfig diff --git a/db/functions/function_no_v8.go b/db/functions/function_no_v8.go new file mode 100644 index 0000000000..228cbc6420 --- /dev/null +++ b/db/functions/function_no_v8.go @@ -0,0 +1,35 @@ +// Copyright 2023-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. + +//go:build !cb_sg_v8 + +package functions + +import ( + "context" + "fmt" + + "github.com/couchbase/sg-bucket/js" + "github.com/couchbase/sync_gateway/db" +) + +// Validates a FunctionsConfig & GraphQLConfig. +func ValidateFunctions(ctx context.Context, vm js.ServiceHost, fnConfig *FunctionsConfig, gqConfig *GraphQLConfig) error { + if fnConfig != nil || gqConfig != nil { + return fmt.Errorf("ValidateFunctions is not supported in non v8 build") + } + return nil +} + +func (fnc *Config) Compile(vms *js.VMPool) (*db.UserFunctions, db.GraphQL, error) { + return nil, nil, fmt.Errorf("functions.Config.Compile is not supported in non v8 build") +} + +func (fnc *Config) N1QLQueryNames() []string { + return nil +} diff --git a/db/functions/function_test.go b/db/functions/function_test.go index 5eae056062..622580fdf5 100644 --- a/db/functions/function_test.go +++ b/db/functions/function_test.go @@ -1,3 +1,5 @@ +//go:build cb_sg_v8 + /* Copyright 2022-Present Couchbase, Inc. @@ -14,18 +16,23 @@ import ( "context" "strings" "testing" + "time" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/auth" "github.com/couchbase/sync_gateway/base" "github.com/couchbase/sync_gateway/channels" "github.com/couchbase/sync_gateway/db" + v8 "github.com/couchbasedeps/v8go" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) +const kUserFunctionMaxCallDepth = 20 + var allowAll = &Allow{Channels: []string{"*"}} -var kUserFunctionConfig = FunctionsConfig{ +var kTestFunctionsConfig = FunctionsConfig{ Definitions: FunctionsDefs{ "square": &FunctionConfig{ Type: "javascript", @@ -33,6 +40,13 @@ var kUserFunctionConfig = FunctionsConfig{ Args: []string{"numero"}, Allow: &Allow{Channels: []string{"wonderland"}}, }, + "cube": &FunctionConfig{ + Type: "javascript", + Code: `function(context, args) {let square = context.user.function("square",args); + console.log("cube: square is", square); return square * args.numero;}`, + Args: []string{"numero"}, + Allow: &Allow{Channels: []string{"wonderland"}}, + }, "exceptional": &FunctionConfig{ Type: "javascript", Code: `function(context, args) {throw "oops";}`, @@ -50,6 +64,11 @@ var kUserFunctionConfig = FunctionsConfig{ else return args.n * context.user.function("factorial", {n: args.n-1});}`, Allow: allowAll, }, + "endless": &FunctionConfig{ + Type: "javascript", + Code: `function(context, args) {while(true);}`, + Allow: allowAll, + }, "great_and_terrible": &FunctionConfig{ Type: "javascript", Code: `function(context, args) {return "I am OZ the great and terrible";}`, @@ -134,14 +153,31 @@ var kUserFunctionConfig = FunctionsConfig{ "illegal_putDoc": &FunctionConfig{ Type: "javascript", - Code: `function(context, args) {context.user.function("putDoc", args);}`, + Code: `function(context, args) {return context.user.function("putDoc", args);}`, Args: []string{"docID", "doc"}, Allow: allowAll, }, "legal_putDoc": &FunctionConfig{ Type: "javascript", - Code: `function(context, args) {context.admin.function("putDoc", args);}`, + Code: `function(context, args) {return context.admin.function("putDoc", args);}`, + Args: []string{"docID", "doc"}, + Allow: allowAll, + }, + + // This fn has Mutating but calls one that doesn't + "nested_illegal_putDoc": &FunctionConfig{ + Type: "javascript", + Code: `function(context, args) {return context.user.function("illegal_putDoc", args);}`, + Args: []string{"docID", "doc"}, + Allow: allowAll, + Mutating: true, + }, + + // This fn uses context.admin to call a non-mutating function + "admin_illegal_putDoc": &FunctionConfig{ + Type: "javascript", + Code: `function(context, args) {return context.admin.function("illegal_putDoc", args);}`, Args: []string{"docID", "doc"}, Allow: allowAll, }, @@ -173,15 +209,11 @@ func addUserAlice(t *testing.T, db *db.Database) auth.User { // Unit test for JS user functions. func TestUserFunctions(t *testing.T) { - // FIXME : this test doesn't work because the access view does not exist on the collection ??? - t.Skip("Skipping test until access view is available with collections") - - // base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) - db, ctx := setupTestDBWithFunctions(t, &kUserFunctionConfig, nil) + db, ctx := setupTestDBWithFunctions(t, &kTestFunctionsConfig, nil) defer db.Close(ctx) - assert.NotNil(t, db.Options.UserFunctions) - assert.NotNil(t, db.Options.UserFunctions.Definitions["square"]) + assert.NotNil(t, db.UserFunctions) + assert.NotNil(t, db.UserFunctions.Definitions["square"]) // First run the tests as an admin: t.Run("AsAdmin", func(t *testing.T) { testUserFunctionsAsAdmin(t, ctx, db) }) @@ -222,7 +254,7 @@ func testUserFunctionsCommon(t *testing.T, ctx context.Context, db *db.Database) assert.EqualValues(t, "OK", result) // Max call depth: - result, err = db.CallUserFunction("factorial", map[string]any{"n": 20}, true, ctx) + result, err = db.CallUserFunction("factorial", map[string]any{"n": kUserFunctionMaxCallDepth}, true, ctx) assert.NoError(t, err) assert.EqualValues(t, 2.43290200817664e+18, result) @@ -244,13 +276,19 @@ func testUserFunctionsCommon(t *testing.T, ctx context.Context, db *db.Database) _, err = db.CallUserFunction("exceptional", nil, true, ctx) assert.ErrorContains(t, err, "oops") assert.ErrorContains(t, err, "exceptional") - jserr := err.(*jsError) + jserr := err.(*v8.JSError) assert.NotNil(t, jserr) // Call depth limit: _, err = db.CallUserFunction("factorial", map[string]any{"n": kUserFunctionMaxCallDepth + 1}, true, ctx) assert.ErrorContains(t, err, "User function recursion too deep") assert.ErrorContains(t, err, "factorial") + + // Timeout: + briefCtx, cancelFn := context.WithTimeout(ctx, 2*time.Second) + defer cancelFn() + _, err = db.CallUserFunction("endless", nil, true, briefCtx) + assert.ErrorContains(t, err, "context deadline exceeded") } // User-function tests, run as admin: @@ -283,7 +321,7 @@ func testUserFunctionsAsAdmin(t *testing.T, ctx context.Context, db *db.Database // Checking `context.user.name`: _, err = db.CallUserFunction("user_only", nil, true, ctx) assert.ErrorContains(t, err, "No user") - jserr := err.(*jsError) + jserr := err.(*v8.JSError) assert.NotNil(t, jserr) // No such function: @@ -333,95 +371,126 @@ func testUserFunctionsAsUser(t *testing.T, ctx context.Context, db *db.Database) // Test CRUD operations func TestUserFunctionsCRUD(t *testing.T) { - t.Skip("not collection aware") - // base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) - db, ctx := setupTestDBWithFunctions(t, &kUserFunctionConfig, nil) + db, ctx := setupTestDBWithFunctions(t, &kTestFunctionsConfig, nil) defer db.Close(ctx) body := map[string]any{"key": "value"} - // Create a doc with random ID: - result, err := db.CallUserFunction("putDoc", map[string]any{"docID": nil, "doc": body}, true, ctx) - assert.NoError(t, err) - assert.IsType(t, "", result) - _, err = db.CallUserFunction("getDoc", map[string]any{"docID": result}, true, ctx) - assert.NoError(t, err) + t.Run("Create a doc with random ID", func(t *testing.T) { + result, err := db.CallUserFunction("putDoc", map[string]any{"docID": nil, "doc": body}, true, ctx) + assert.NoError(t, err) + assert.IsType(t, "", result) + _, err = db.CallUserFunction("getDoc", map[string]any{"docID": result}, true, ctx) + assert.NoError(t, err) + }) docID := "foo" - // Missing document: - result, err = db.CallUserFunction("getDoc", map[string]any{"docID": docID}, true, ctx) - assert.NoError(t, err) - assert.EqualValues(t, nil, result) + t.Run("Missing document", func(t *testing.T) { + result, err := db.CallUserFunction("getDoc", map[string]any{"docID": docID}, true, ctx) + assert.NoError(t, err) + assert.EqualValues(t, nil, result) + }) docParams := map[string]any{ "docID": docID, "doc": body, } - // Illegal mutation (passing mutationAllowed = false): - _, err = db.CallUserFunction("putDoc", docParams, false, ctx) - assertHTTPError(t, err, 403) - - // Successful save (as admin): - result, err = db.CallUserFunction("putDoc", docParams, true, ctx) - assert.NoError(t, err) - assert.EqualValues(t, docID, result) // save() returns docID - - // Existing document: - result, err = db.CallUserFunction("getDoc", map[string]any{"docID": docID}, true, ctx) - assert.NoError(t, err) - revID, ok := result.(map[string]any)["_rev"].(string) - assert.True(t, ok) - assert.NotEmpty(t, revID) - assert.True(t, strings.HasPrefix(revID, "1-")) - body["_id"] = docID - body["_rev"] = revID - assert.EqualValues(t, body, result) - - // Update document with revID: - body["key2"] = 2 - _, err = db.CallUserFunction("putDoc", docParams, true, ctx) - assert.NoError(t, err) + t.Run("Illegal mutation", func(t *testing.T) { + // Illegal mutation (passing mutationAllowed = false): + _, err := db.CallUserFunction("putDoc", docParams, false, ctx) + assertHTTPError(t, err, 403) + }) - // Save fails with conflict: - body["key3"] = 3 - body["_rev"] = "9-9999" - result, err = db.CallUserFunction("putDoc", docParams, true, ctx) - assert.NoError(t, err) - assert.Nil(t, result) + t.Run("Successful save as admin", func(t *testing.T) { + result, err := db.CallUserFunction("putDoc", docParams, true, ctx) + assert.NoError(t, err) + assert.EqualValues(t, docID, result) // save() returns docID + }) - // Update document without revID: - body["key3"] = 4 - delete(body, "_revid") - result, err = db.CallUserFunction("putDoc", docParams, true, ctx) - assert.NoError(t, err) - assert.Equal(t, docID, result) + t.Run("Existing document", func(t *testing.T) { + result, err := db.CallUserFunction("getDoc", map[string]any{"docID": docID}, true, ctx) + assert.NoError(t, err) + revID, ok := result.(map[string]any)["_rev"].(string) + assert.True(t, ok) + assert.NotEmpty(t, revID) + assert.True(t, strings.HasPrefix(revID, "1-")) + body["_id"] = docID + body["_rev"] = revID + assert.EqualValues(t, body, result) + }) + + t.Run("Update document with revID", func(t *testing.T) { + body["key2"] = 2 + _, err := db.CallUserFunction("putDoc", docParams, true, ctx) + assert.NoError(t, err) + }) - // Get doc again to verify revision: - result, err = db.CallUserFunction("getDoc", map[string]any{"docID": docID}, true, ctx) - assert.NoError(t, err) - revID, ok = result.(map[string]any)["_rev"].(string) - assert.True(t, ok) - assert.NotEmpty(t, revID) - assert.True(t, strings.HasPrefix(revID, "3-")) + t.Run("Save fails with conflict", func(t *testing.T) { + body["key3"] = 3 + body["_rev"] = "9-9999" + result, err := db.CallUserFunction("putDoc", docParams, true, ctx) + assert.NoError(t, err) + assert.Nil(t, result) + }) - // Illegal mutation (a non-mutating function calling putDoc) - _, err = db.CallUserFunction("illegal_putDoc", docParams, true, ctx) - assertHTTPError(t, err, 403) + t.Run("Update document without revID", func(t *testing.T) { + body["key3"] = 4 + delete(body, "_rev") + result, err := db.CallUserFunction("putDoc", docParams, true, ctx) + assert.NoError(t, err) + assert.Equal(t, docID, result) + }) - // Legal mutation (a non-mutating function calling putDoc, but via 'admin') - _, err = db.CallUserFunction("legal_putDoc", docParams, true, ctx) - assert.NoError(t, err) + t.Run("Get doc again to verify revision", func(t *testing.T) { + result, err := db.CallUserFunction("getDoc", map[string]any{"docID": docID}, true, ctx) + assert.NoError(t, err) + revID, ok := result.(map[string]any)["_rev"].(string) + assert.True(t, ok) + assert.NotEmpty(t, revID) + assert.True(t, strings.HasPrefix(revID, "3-")) + }) + + t.Run("illegal_putDoc", func(t *testing.T) { + // Illegal mutation (a non-mutating function calling putDoc) + _, err := db.CallUserFunction("illegal_putDoc", docParams, true, ctx) + assertHTTPError(t, err, 403) + }) + t.Run("nested_illegal_putDoc", func(t *testing.T) { + // Illegal mutation (a non-mutating function calling putDoc) + _, err := db.CallUserFunction("nested_illegal_putDoc", docParams, true, ctx) + assertHTTPError(t, err, 403) + }) + /* This currently fails; it's ambiguous what should happen. TODO (jens 2-Feb-2023) + t.Run("admin_illegal_putDoc", func(t *testing.T) { + // Illegal mutation (a non-mutating function calling putDoc) + _, err := db.CallUserFunction("admin_illegal_putDoc", docParams, true, ctx) + assertHTTPError(t, err, 403) + }) + */ + t.Run("legal_putDoc", func(t *testing.T) { + // Legal mutation (a non-mutating function calling putDoc, but via 'admin') + _, err := db.CallUserFunction("legal_putDoc", docParams, true, ctx) + assert.NoError(t, err) + }) + t.Run("delDoc", func(t *testing.T) { + // Delete doc: + _, err := db.CallUserFunction("delDoc", map[string]any{"docID": docID}, true, ctx) + assert.NoError(t, err) + }) +} - // Delete doc: - _, err = db.CallUserFunction("delDoc", map[string]any{"docID": docID}, true, ctx) - assert.NoError(t, err) +func testValidateFunctions(t *testing.T, fnConfig *FunctionsConfig, gqConfig *GraphQLConfig) error { + ctx := base.TestCtx(t) + vm := js.V8.NewVM(ctx) + defer vm.Close() + return ValidateFunctions(ctx, vm, fnConfig, gqConfig) } // Test that JS syntax errors are detected when the db opens. func TestUserFunctionSyntaxError(t *testing.T) { - var kUserFunctionBadConfig = FunctionsConfig{ + var functionConfig = FunctionsConfig{ Definitions: FunctionsDefs{ "square": &FunctionConfig{ Code: "return args.numero * args.numero;", @@ -435,12 +504,12 @@ func TestUserFunctionSyntaxError(t *testing.T) { }, } - _, err := CompileFunctions(kUserFunctionBadConfig) + err := testValidateFunctions(t, &functionConfig, nil) assert.Error(t, err) } func TestUserFunctionsMaxFunctionCount(t *testing.T) { - var twoFunctionConfig = FunctionsConfig{ + var functionConfig = FunctionsConfig{ MaxFunctionCount: base.IntPtr(1), Definitions: FunctionsDefs{ "square": &FunctionConfig{ @@ -456,8 +525,8 @@ func TestUserFunctionsMaxFunctionCount(t *testing.T) { }, }, } - _, err := CompileFunctions(twoFunctionConfig) - assert.ErrorContains(t, err, "too many functions declared (> 1)") + err := testValidateFunctions(t, &functionConfig, nil) + assert.ErrorContains(t, err, "too many functions (> 1)") } func TestUserFunctionsMaxCodeSize(t *testing.T) { @@ -472,151 +541,8 @@ func TestUserFunctionsMaxCodeSize(t *testing.T) { }, }, } - _, err := CompileFunctions(functionConfig) - assert.ErrorContains(t, err, "function code too large (> 20 bytes)") -} - -// Low-level test of channel-name parameter expansion for user query/function auth -func TestUserFunctionAllow(t *testing.T) { - // FIXME : this test doesn't work because the access view does not exist on the collection ??? - t.Skip("Skipping test until access view is available with collections") - - // base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) - db, ctx := setupTestDBWithFunctions(t, &kUserFunctionConfig, nil) - defer db.Close(ctx) - - authenticator := auth.NewAuthenticator(db.MetadataStore, db, db.AuthenticatorOptions()) - user, err := authenticator.NewUser("maurice", "pass", base.SetOf("city-Paris")) - assert.NoError(t, err) - - params := map[string]any{ - "CITY": "Paris", - "BREAD": "Baguette", - "YEAR": 2020, - "WINE": map[string]any{"blanc": "Sauterne", "rouge": "Bordeaux"}, - "WORDS": []string{"ouais", "fromage", "amour", "vachement"}, - } - - ch, err := expandPattern("someChannel", params, user) - assert.NoError(t, err) - assert.Equal(t, ch, "someChannel") - - ch, err = expandPattern("sales-${args.CITY}-all", params, user) - assert.NoError(t, err) - assert.Equal(t, "sales-Paris-all", ch) - - ch, err = expandPattern("sales${args.CITY}All", params, user) - assert.NoError(t, err) - assert.Equal(t, "salesParisAll", ch) - - ch, err = expandPattern("sales${args.CITY}-${args.BREAD}", params, user) - assert.NoError(t, err) - assert.Equal(t, "salesParis-Baguette", ch) - - ch, err = expandPattern("sales-upTo-${args.YEAR}", params, user) - assert.NoError(t, err) - assert.Equal(t, "sales-upTo-2020", ch) - - ch, err = expandPattern("wines-${args.WINE.blanc}", params, user) - assert.NoError(t, err) - assert.Equal(t, "wines-Sauterne", ch) - - ch, err = expandPattern("${args.WORDS[2]}", params, user) - assert.NoError(t, err) - assert.Equal(t, "amour", ch) - - ch, err = expandPattern("employee-${context.user.name}", params, user) - assert.NoError(t, err) - assert.Equal(t, "employee-maurice", ch) - - // Escaped `\$`: - ch, err = expandPattern(`expen\$ive`, params, user) - assert.NoError(t, err) - assert.Equal(t, "expen$ive", ch) - ch, err = expandPattern(`\$wow`, params, user) - assert.NoError(t, err) - assert.Equal(t, "$wow", ch) - ch, err = expandPattern(`\${wow}`, params, user) - assert.NoError(t, err) - assert.Equal(t, "${wow}", ch) - - // error: missing brace - _, err = expandPattern("$wow", params, user) - assert.NotNil(t, err) - _, err = expandPattern("foobar$", params, user) - assert.NotNil(t, err) - _, err = expandPattern("$w{ow}", params, user) - assert.NotNil(t, err) - _, err = expandPattern("knows-${args.CITY", params, user) - assert.NotNil(t, err) - _, err = expandPattern("knows-${args.CITY-${args.CITY}", params, user) - assert.NotNil(t, err) - - // error: param value is not a string - _, err = expandPattern("knows-${args.WORDS}", params, user) - assert.NotNil(t, err) - - // error: undefined parameter - _, err = expandPattern("sales-upTo-${}", params, user) - assert.NotNil(t, err) - _, err = expandPattern("sales-upTo-${args.FOO}", params, user) - assert.NotNil(t, err) - - // error: not an arg or user - _, err = expandPattern("sales-upTo-${FOO}", params, user) - assert.NotNil(t, err) - _, err = expandPattern("sales-upTo-${context.user}", params, user) - assert.NotNil(t, err) - _, err = expandPattern("sales-upTo-${context.bar.FOO}", params, user) - assert.NotNil(t, err) - - // error: missing map item - _, err = expandPattern("wines-${args.WINE.plonk}", params, user) - assert.NotNil(t, err) - _, err = expandPattern("wines-${args.WINE.blanc.x}", params, user) - assert.NotNil(t, err) -} - -func TestKeyPath(t *testing.T) { - args := map[string]any{ - "CITY": "Paris", - "BREAD": "Baguette", - "YEAR": 2020, - "WINE": map[string]any{"blanc": "Sauterne", "rouge": "Bordeaux", - "nested": map[string]any{"Z": 321}}, - "WORDS": []any{"ouais", "fromage", "amour", "vachement", - map[string]any{"X": 123}, - []any{"arrayInArray"}}, - } - - val, err := evalKeyPath(args, "CITY") - if assert.NoError(t, err) { - assert.Equal(t, "Paris", val.Interface()) - } - val, err = evalKeyPath(args, "YEAR") - if assert.NoError(t, err) { - assert.Equal(t, 2020, val.Interface()) - } - val, err = evalKeyPath(args, "WINE.blanc") - if assert.NoError(t, err) { - assert.Equal(t, "Sauterne", val.Interface()) - } - val, err = evalKeyPath(args, "WINE.nested.Z") - if assert.NoError(t, err) { - assert.Equal(t, 321, val.Interface()) - } - val, err = evalKeyPath(args, "WORDS[1]") - if assert.NoError(t, err) { - assert.Equal(t, "fromage", val.Interface()) - } - val, err = evalKeyPath(args, "WORDS[4].X") - if assert.NoError(t, err) { - assert.Equal(t, 123, val.Interface()) - } - val, err = evalKeyPath(args, "WORDS[5][0]") - if assert.NoError(t, err) { - assert.Equal(t, "arrayInArray", val.Interface()) - } + err := testValidateFunctions(t, &functionConfig, nil) + assert.ErrorContains(t, err, "function square: code is too large (> 20 bytes)") } //////// UTILITY FUNCTIONS: @@ -636,37 +562,34 @@ func AddOptionsFromEnvironmentVariables(dbcOptions *db.DatabaseContextOptions) { func assertHTTPError(t *testing.T, err error, status int) bool { var httpErr *base.HTTPError return assert.Error(t, err) && - assert.ErrorAs(t, err, &httpErr) && + assert.ErrorAs(t, err, &httpErr, "Error is %T, %v", err, err) && assert.Equal(t, status, httpErr.Status, "Error is: %#v", err) } //////// SETUP FUNCTIONS func setupTestDBWithFunctions(t *testing.T, fnConfig *FunctionsConfig, gqConfig *GraphQLConfig) (*db.Database, context.Context) { + return setupTestDBWithFunctionsAndLogging(t, fnConfig, gqConfig, true) +} + +func setupTestDBWithFunctionsAndLogging(t *testing.T, fnConfig *FunctionsConfig, gqConfig *GraphQLConfig, jsDebugLogging bool) (*db.Database, context.Context) { cacheOptions := db.DefaultCacheOptions() options := db.DatabaseContextOptions{ - CacheOptions: &cacheOptions, - Scopes: db.GetScopesOptionsDefaultCollectionOnly(t), - } - var err error - if fnConfig != nil { - options.UserFunctions, err = CompileFunctions(*fnConfig) - assert.NoError(t, err) + CacheOptions: &cacheOptions, + Scopes: db.GetScopesOptionsDefaultCollectionOnly(t), + FunctionsConfig: &Config{fnConfig, gqConfig}, + JavaScriptEngine: base.StringPtr("V8"), // Not compatible with Otto, it's too old } - if gqConfig != nil { - options.GraphQL, err = CompileGraphQL(gqConfig) - assert.NoError(t, err) - } - return setupTestDBWithOptions(t, options) + return setupTestDBWithOptions(t, options, jsDebugLogging) } -func setupTestDBWithOptions(t testing.TB, dbcOptions db.DatabaseContextOptions) (*db.Database, context.Context) { +func setupTestDBWithOptions(t testing.TB, dbcOptions db.DatabaseContextOptions, jsDebugLogging bool) (*db.Database, context.Context) { tBucket := base.GetTestBucket(t) - return setupTestDBForBucketWithOptions(t, tBucket, dbcOptions) + return setupTestDBForBucketWithOptions(t, tBucket, dbcOptions, jsDebugLogging) } -func setupTestDBForBucketWithOptions(t testing.TB, tBucket base.Bucket, dbcOptions db.DatabaseContextOptions) (*db.Database, context.Context) { +func setupTestDBForBucketWithOptions(t testing.TB, tBucket base.Bucket, dbcOptions db.DatabaseContextOptions, jsDebugLogging bool) (*db.Database, context.Context) { ctx := base.TestCtx(t) AddOptionsFromEnvironmentVariables(&dbcOptions) dbCtx, err := db.NewDatabaseContext(ctx, "db", tBucket, false, dbcOptions) @@ -674,6 +597,9 @@ func setupTestDBForBucketWithOptions(t testing.TB, tBucket base.Bucket, dbcOptio db, err := db.CreateDatabase(dbCtx) assert.NoError(t, err, "Couldn't create database 'db'") ctx = db.AddDatabaseLogContext(ctx) + if jsDebugLogging { + base.SetUpTestLogging(t, base.LevelDebug, base.KeyJavascript) // Enable debug JS logging! + } return db, ctx } diff --git a/db/functions/graphql.go b/db/functions/graphql.go deleted file mode 100644 index 8d04f35ee3..0000000000 --- a/db/functions/graphql.go +++ /dev/null @@ -1,326 +0,0 @@ -/* -Copyright 2022-Present Couchbase, Inc. - -Use of this software is governed by the Business Source License included in -the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that -file, in accordance with the Business Source License, use of this software will -be governed by the Apache License, Version 2.0, included in the file -licenses/APL2.txt. -*/ - -package functions - -import ( - "context" - "fmt" - "os" - - gqltools "github.com/bhoriuchi/graphql-go-tools" - "github.com/couchbase/sync_gateway/base" - "github.com/couchbase/sync_gateway/db" - "github.com/graphql-go/graphql" - "github.com/graphql-go/graphql/language/ast" -) - -//////// CONFIGURATION TYPES: - -// Configuration for GraphQL. -type GraphQLConfig struct { - Schema *string `json:"schema,omitempty"` // Schema in SDL syntax - SchemaFile *string `json:"schemaFile,omitempty"` // Path of schema file - Resolvers GraphQLTypesMap `json:"resolvers"` // Defines query/mutation code - MaxSchemaSize *int `json:"max_schema_size,omitempty"` // Maximum length (in bytes) of GraphQL schema; default is 0, for unlimited - MaxResolverCount *int `json:"max_resolver_count,omitempty"` // Maximum number of GraphQL resolvers; default is 0, for unlimited - MaxCodeSize *int `json:"max_code_size,omitempty"` // Maximum length (in bytes) of a function's code - MaxRequestSize *int `json:"max_request_size,omitempty"` // Maximum size of the encoded query & arguments -} - -// Maps GraphQL type names (incl. "Query") to their resolvers. -type GraphQLTypesMap map[string]GraphQLResolverConfig - -// Maps GraphQL field names to the resolvers that implement them. -type GraphQLResolverConfig map[string]FunctionConfig - -//////// QUERYING - -// Runs a GraphQL query on behalf of a user, presumably invoked via a REST or BLIP API. -func (gq *graphQLImpl) Query(database *db.Database, query string, operationName string, variables map[string]any, mutationAllowed bool, ctx context.Context) (*graphql.Result, error) { - if err := db.CheckTimeout(ctx); err != nil { - return nil, err - } - ctx = context.WithValue(ctx, dbKey, database) - if !mutationAllowed && ctx.Value(readOnlyKey) == nil { - ctx = context.WithValue(ctx, readOnlyKey, "a read-only GraphQL API call") - } - result := graphql.Do(graphql.Params{ - Schema: gq.schema, - RequestString: query, - VariableValues: variables, - OperationName: operationName, - Context: ctx, - }) - return result, nil -} - -func (gq *graphQLImpl) MaxRequestSize() *int { - return gq.config.MaxRequestSize -} - -func (gq *graphQLImpl) N1QLQueryNames() []string { - queryNames := []string{} - for typeName, resolvers := range gq.config.Resolvers { - for fieldName, resolver := range resolvers { - if resolver.Type == "query" { - queryNames = append(queryNames, db.QueryTypeUserFunctionPrefix+graphQLResolverName(typeName, fieldName)) - } - } - } - return queryNames -} - -type gqContextKey string - -var dbKey = gqContextKey("db") // Context key to access the db.Database instance -var readOnlyKey = gqContextKey("readOnly") // Context key preventing mutation; val is fn name - -//////// GRAPHQL INITIALIZATION: - -// Implementation of db.graphQLImpl interface. -type graphQLImpl struct { - config *GraphQLConfig - schema graphql.Schema // The compiled GraphQL schema object -} - -// Creates a new GraphQL instance from its configuration. -func CompileGraphQL(config *GraphQLConfig) (*graphQLImpl, error) { - if schema, err := config.compileSchema(); err != nil { - return nil, err - } else { - gql := &graphQLImpl{ - config: config, - schema: schema, - } - return gql, nil - } -} - -// Validates a GraphQL configuration by parsing the schema. -func (config *GraphQLConfig) Validate(ctx context.Context) error { - _, err := config.compileSchema() - return err -} - -func (config *GraphQLConfig) compileSchema() (schema graphql.Schema, err error) { - // Get the schema source, from either `schema` or `schemaFile`: - schemaSource, err := config.getSchema() - if err != nil { - return schema, err - } - if config.MaxSchemaSize != nil && len(schemaSource) > *config.MaxSchemaSize { - return schema, fmt.Errorf("GraphQL schema too large (> %d bytes)", *config.MaxSchemaSize) - } - - var multiError *base.MultiError - resolverCount := 0 - // Assemble the resolvers: - resolvers := map[string]any{} -ResolverLoop: - for typeName, resolver := range config.Resolvers { - fieldMap := map[string]*gqltools.FieldResolve{} - var typeNameResolver graphql.ResolveTypeFn - for fieldName, fnConfig := range resolver { - if fnConfig.Args != nil { - err = fmt.Errorf("'args' is not valid in a GraphQL resolver config") - } else if config.MaxCodeSize != nil && len(fnConfig.Code) > *config.MaxCodeSize { - err = fmt.Errorf("resolver %s code too large (> %d bytes)", fieldName, *config.MaxCodeSize) - multiError = multiError.Append(err) - } else if fieldName == "__typename" { - // The "__typename" resolver returns the name of the concrete type of an - // instance of an interface. - typeNameResolver, err = config.compileTypeNameResolver(typeName, fnConfig) - resolverCount += 1 - } else { - var fn graphql.FieldResolveFn - fn, err = config.compileFieldResolver(typeName, fieldName, fnConfig) - fieldMap[fieldName] = &gqltools.FieldResolve{Resolve: fn} - resolverCount += 1 - } - if err != nil { - multiError = multiError.Append(err) - } - if config.MaxResolverCount != nil && resolverCount > *config.MaxResolverCount { - err = fmt.Errorf("too many GraphQL resolvers (> %d)", *config.MaxResolverCount) - multiError = multiError.Append(err) - break ResolverLoop // stop - } - } - if typeNameResolver == nil { - resolvers[typeName] = &gqltools.ObjectResolver{ - Fields: fieldMap, - } - } else { - resolvers[typeName] = &gqltools.InterfaceResolver{ - Fields: fieldMap, - ResolveType: typeNameResolver, - } - } - } - if multiError != nil { - return schema, multiError.ErrorOrNil() - } - - // Now compile the schema and create the graphql.Schema object: - schema, err = gqltools.MakeExecutableSchema(gqltools.ExecutableSchema{ - TypeDefs: schemaSource, - Resolvers: resolvers, - Debug: true, // This enables logging of unresolved-type errors - }) - - if err == nil && len(schema.TypeMap()) == 0 { - base.WarnfCtx(context.Background(), "GraphQL Schema object has no registered TypeMap -- this probably means the schema has unresolved types. See gqltools warnings above") - err = fmt.Errorf("GraphQL Schema object has no registered TypeMap -- this probably means the schema has unresolved types") - } - return schema, err -} - -// Reads the schema, either directly from the config or from an external file. -func (config *GraphQLConfig) getSchema() (string, error) { - if config.Schema != nil { - if config.SchemaFile != nil { - return "", fmt.Errorf("GraphQL config: only one of `schema` and `schemaFile` may be used") - } - return *config.Schema, nil - } else { - if config.SchemaFile == nil { - return "", fmt.Errorf("GraphQL config: either `schema` or `schemaFile` must be defined") - } - src, err := os.ReadFile(*config.SchemaFile) - if err != nil { - return "", fmt.Errorf("GraphQL config: can't read file %s: %w", *config.SchemaFile, err) - } - return string(src), nil - } -} - -//////// FIELD RESOLVER: - -// Subtype of db.UserFunctionInvocation that can be called as a GraphQL resolver. -// Implemented by userFunctionJSInvocation and userFunctionN1QLInvocation -type resolver = interface { - db.UserFunctionInvocation - - // Calls a user function as a GraphQL resolver, given the parameters passed by the go-graphql API. - Resolve(params graphql.ResolveParams) (any, error) -} - -func graphQLResolverName(typeName string, fieldName string) string { - return typeName + ":" + fieldName -} - -// Creates a graphQLResolver for the given JavaScript code, and returns a graphql-go FieldResolveFn -// that invokes it. -func (config *GraphQLConfig) compileFieldResolver(typeName string, fieldName string, fnConfig FunctionConfig) (graphql.FieldResolveFn, error) { - name := graphQLResolverName(typeName, fieldName) - isMutation := typeName == "Mutation" - if isMutation && fnConfig.Type == "query" { - return nil, fmt.Errorf("GraphQL mutations must be implemented in JavaScript") - } - - userFn, err := compileFunction(name, "GraphQL resolver", &fnConfig) - if err != nil { - return nil, err - } - userFn.checkArgs = false // graphql-go does this - userFn.allowByDefault = (typeName != "Query" && typeName != "Mutation") // not at top level - userFn.Mutating = isMutation - - return func(params graphql.ResolveParams) (any, error) { - ctx := params.Context - db := ctx.Value(dbKey).(*db.Database) - invocation, err := userFn.Invoke(db, params.Args, isMutation, ctx) - if err != nil { - return nil, err - } - return invocation.(resolver).Resolve(params) - }, nil -} - -func resolverInfo(params graphql.ResolveParams) map[string]any { - // Collect the 'selectedFieldNames', the fields the query wants from the value being resolved: - selectedFieldNames := []string{} - if len(params.Info.FieldASTs) > 0 { - if set := params.Info.FieldASTs[0].SelectionSet; set != nil { - for _, sel := range set.Selections { - if subfield, ok := sel.(*ast.Field); ok { - if subfield.Name.Kind == "Name" { - selectedFieldNames = append(selectedFieldNames, subfield.Name.Value) - } - } - } - } - } - - // The `info` parameter passed to the resolver fn; fields are a subset of graphql.ResolveInfo. - // NOTE: We've removed these fields until we get feedback that they're needed by developers. - // `selectedFieldNames` is not provided (directly) by ResolveInfo; it contains the fields of the - // resolver's result that will be used by the query (other fields will just be ignored.) - // This enables some important optimizations. - return map[string]any{ - "selectedFieldNames": selectedFieldNames, - } -} - -//////// TYPE-NAME RESOLVER: - -func (config *GraphQLConfig) compileTypeNameResolver(interfaceName string, fnConfig FunctionConfig) (graphql.ResolveTypeFn, error) { - if fnConfig.Type != "javascript" { - return nil, fmt.Errorf("a GraphQL '__typename__' resolver must be JavaScript") - } else if fnConfig.Allow != nil { - return nil, fmt.Errorf("'allow' is not valid in a GraphQL '__typename__' resolver") - } - - fn, err := compileFunction(interfaceName, "GraphQL type-name resolver", &fnConfig) - if err != nil { - return nil, err - } - name := interfaceName + ".__typename" - - return func(params graphql.ResolveTypeParams) *graphql.Object { - db_ := params.Context.Value(dbKey).(*db.Database) - invocation, err := fn.Invoke(db_, nil, false, params.Context) - if err != nil { - return nil - } - result, err := invocation.(*jsInvocation).ResolveType(params) - var objType *graphql.Object - if err != nil { - base.WarnfCtx(params.Context, "GraphQL resolver %q failed with error %v", name, err) - } else if typeName, ok := result.(string); !ok { - base.WarnfCtx(params.Context, "GraphQL resolver %q returned a non-string %v; return value must be a type-name string", name, result) - } else if typeVal := params.Info.Schema.Type(typeName); typeVal == nil { - base.WarnfCtx(params.Context, "GraphQL resolver %q returned %q, which is not the name of a type", name, typeName) - base.WarnfCtx(params.Context, "TypeMap is %+v", params.Info.Schema.TypeMap()) - } else if objType, ok = typeVal.(*graphql.Object); !ok { - base.WarnfCtx(params.Context, "GraphQL resolver %q returned %q which is not the name of an object type", name, typeName) - } - return objType - }, nil -} - -//////// UTILITIES - -func isGraphQLListType(typ graphql.Output) bool { - if nonnull, ok := typ.(*graphql.NonNull); ok { - typ = nonnull.OfType - } - _, isList := typ.(*graphql.List) - return isList -} - -func isGraphQLScalarType(typ graphql.Output) bool { - if nonnull, ok := typ.(*graphql.NonNull); ok { - typ = nonnull.OfType - } - _, isScalar := typ.(*graphql.Scalar) - return isScalar -} diff --git a/db/functions/graphql_subgraph_test.go b/db/functions/graphql_subgraph_test.go new file mode 100644 index 0000000000..ad880c45b6 --- /dev/null +++ b/db/functions/graphql_subgraph_test.go @@ -0,0 +1,224 @@ +//go:build cb_sg_v8 + +/* +Copyright 2022-Present Couchbase, Inc. + +Use of this software is governed by the Business Source License included in +the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that +file, in accordance with the Business Source License, use of this software will +be governed by the Apache License, Version 2.0, included in the file +licenses/APL2.txt. +*/ + +package functions + +import ( + "strings" + "testing" + + "github.com/stretchr/testify/assert" +) + +//////// APOLLO FEDERATION (SUBGRAPHS) + +func TestGraphQLSubgraph(t *testing.T) { + // Subgraph schema definition: + var kSchemaStr = ` + type Task @key(fields: "id") { + id: ID! + title: String! + } + type Person @key(fields: "id", resolvable: true) { + id: ID! + name: String! + } + type Wombat @key(fields: "id", resolvable: false) { # (Not added to _Entities enum!) + id: ID! + name: String! + } + type Query { + tasks: [Task!]! + }` + + // GraphQL configuration: + var config = GraphQLConfig{ + Schema: &kSchemaStr, + Subgraph: true, + Resolvers: map[string]GraphQLResolverConfig{ + "Query": { + "tasks": kDummyFieldResolver, + }, + "Task": { + "__resolveReference": { + Type: "javascript", + Code: `function(context, value) { + return {type: "Task", id: value.id, title: "Task-"+value.id}; + }`, + }, + }, + "Person": { + "__resolveReference": { + Type: "javascript", + Code: `function(context, value) { + return {type: "Person", id: value.id, name: "Bob "+value.id}; + }`, + }, + }, + "_Entity": { + "__typename": { + Type: "javascript", + Code: `function(context, value) {return value.type;}`, + }, + }, + }, + } + + // Validate the config: + t.Run("ValidateSchema", func(t *testing.T) { + assert.NoError(t, testValidateFunctions(t, nil, &config)) + }) + + db, ctx := setupTestDBWithFunctions(t, nil, &config) + defer db.Close(ctx) + + // Handle a `_service` query: + t.Run("ServiceQuery", func(t *testing.T) { + result, err := db.GraphQL.Query(db, `query { _service { sdl } }`, + "", nil, false, ctx) + if !assertGraphQLNoErrors(t, result, err) { + return + } + sdl, ok := result.Data.(map[string]any)["_service"].(map[string]any)["sdl"].(string) + assert.True(t, ok, "No 'sdl' key in result: %#v", result) + assert.True(t, strings.Contains(sdl, "union _Entity = Person | Task"), "Unexpected sdl: %s", sdl) + }) + + // Handle an `_entities` query: + t.Run("EntitiesQuery", func(t *testing.T) { + vars := map[string]any{ + "reprs": []any{ + map[string]any{"__typename": "Task", "id": "001"}, + map[string]any{"__typename": "Person", "id": "1138"}, + }, + } + + result, err := db.GraphQL.Query(db, ` + query($reprs: [_Any!]!) { + _entities(representations: $reprs) { + ...on Task { title } + ...on Person { name } + } + }`, + "", vars, false, ctx) + assertGraphQLResult(t, `{"_entities":[{"title":"Task-001"},{"name":"Bob 1138"}]}`, result, err) + }) +} + +func TestGraphQLApolloCompatibilitySubgraph(t *testing.T) { + // Subgraph schema definition; see https://github.com/apollographql/apollo-federation-subgraph-compatibility/blob/main/CONTRIBUTORS.md + // (I had to comment out a few things to get it to compile with graphql-go) + var kSchemaStr = ` + type Product @key(fields: "id") @key(fields: "sku package") @key(fields: "sku variation { id }") { + id: ID! + sku: String + package: String + variation: ProductVariation + dimensions: ProductDimension + createdBy: User @provides(fields: "totalProductsCreated") + notes: String @tag(name: "internal") + research: [ProductResearch!]! + } + + type DeprecatedProduct @key(fields: "sku package") { + sku: String! + package: String! + reason: String + createdBy: User + } + + type ProductVariation { + id: ID! + } + + type ProductResearch @key(fields: "study { caseNumber }") { + study: CaseStudy! + outcome: String + } + + type CaseStudy { + caseNumber: ID! + description: String + } + + type ProductDimension @shareable { + size: String + weight: Float + unit: String @inaccessible + } + +# extend + type Query { + product(id: ID!): Product + deprecatedProduct(sku: String!, package: String!): DeprecatedProduct @deprecated(reason: "Use product query instead") + } + +# extend + type User @key(fields: "email") { + averageProductsCreatedPerYear: Int @requires(fields: "totalProductsCreated yearsOfEmployment") + email: ID! @external + name: String @override(from: "users") + totalProductsCreated: Int @external + yearsOfEmployment: Int! @external + }` + + var config = GraphQLConfig{ + Schema: &kSchemaStr, + Subgraph: true, + Resolvers: map[string]GraphQLResolverConfig{ + "Query": { + "product": kDummyFieldResolver, + "deprecatedProduct": kDummyFieldResolver, + }, + "_Entity": { + "__typename": { + Type: "javascript", + Code: `function(context, value) {return value.type;}`, + }, + }, + "Product": { + "__resolveReference": { + Type: "javascript", + Code: `function(context, value) { + return {}; + }`, + }, + }, + "DeprecatedProduct": { + "__resolveReference": { + Type: "javascript", + Code: `function(context, value) { + return {}; + }`, + }, + }, + "ProductResearch": { + "__resolveReference": { + Type: "javascript", + Code: `function(context, value) { + return {}; + }`, + }, + }, + "User": { + "__resolveReference": { + Type: "javascript", + Code: `function(context, value) { + return {}; + }`, + }, + }, + }, + } + + assert.NoError(t, testValidateFunctions(t, nil, &config)) +} diff --git a/db/functions/graphql_test.go b/db/functions/graphql_test.go index 006b7601e2..0ee4984fb7 100644 --- a/db/functions/graphql_test.go +++ b/db/functions/graphql_test.go @@ -1,3 +1,5 @@ +//go:build cb_sg_v8 + /* Copyright 2020-Present Couchbase, Inc. @@ -13,15 +15,12 @@ package functions import ( "context" "encoding/json" - "fmt" "os" "strings" "testing" "github.com/couchbase/sync_gateway/base" "github.com/couchbase/sync_gateway/db" - - "github.com/graphql-go/graphql" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -60,16 +59,17 @@ var kTestGraphQLConfig = GraphQLConfig{ Allow: allowAll, }, "infinite": { - Type: "javascript", - Code: `function(parent, args, context, info) {return context.user.function("infinite");}`, + Type: "javascript", + Code: `async function(parent, args, context, info) { + return await context.user.function("infinite");}`, Allow: allowAll, }, "task": { Type: "javascript", Code: `function(parent, args, context, info) { - if (Object.keys(parent).length != 0) throw "Unexpected parent"; + if (parent !== undefined) throw "Unexpectedly-defined parent"; if (Object.keys(args).length != 1) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; + if (!info.selectedFieldNames) throw "No info.selectedFieldNames"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; return context.user.function("getTask", {id: args.id});}`, @@ -78,9 +78,9 @@ var kTestGraphQLConfig = GraphQLConfig{ "tasks": { Type: "javascript", Code: `function(parent, args, context, info) { - if (Object.keys(parent).length != 0) throw "Unexpected parent"; + if (parent !== undefined) throw "Unexpectedly-defined parent"; if (Object.keys(args).length != 0) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; + if (!info.selectedFieldNames) throw "No info.selectedFieldNames"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; return context.user.function("all");}`, @@ -89,9 +89,9 @@ var kTestGraphQLConfig = GraphQLConfig{ "toDo": { Type: "javascript", Code: `function(parent, args, context, info) { - if (Object.keys(parent).length != 0) throw "Unexpected parent"; - if (Object.keys(args).length != 0) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; + if (parent !== undefined) throw "Unexpectedly-defined parent"; + if (Object.keys(args).length != 1) throw "Unexpected args"; + if (!info.selectedFieldNames) throw "No info.selectedFieldNames"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; var result=new Array(); var all = context.user.function("all"); @@ -105,9 +105,9 @@ var kTestGraphQLConfig = GraphQLConfig{ "complete": { Type: "javascript", Code: `function(parent, args, context, info) { - if (Object.keys(parent).length != 0) throw "Unexpected parent"; + if (parent !== undefined) throw "Unexpectedly-defined parent"; if (Object.keys(args).length != 1) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; + if (!info.selectedFieldNames) throw "No info.selectedFieldNames"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; context.requireMutating(); @@ -135,7 +135,6 @@ var kTestGraphQLConfig = GraphQLConfig{ Code: `function(parent, args, context, info) { if (!parent.id) throw "Invalid parent"; if (Object.keys(args).length != 0) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; return "TOP SECRET!";}`, @@ -159,7 +158,7 @@ var kTestGraphQLUserFunctionsConfig = FunctionsConfig{ }, "getTask": { Type: "javascript", - Code: `function(context, args, parent, info) { + Code: `function(context, args) { var all = context.user.function("all"); for (var i = 0; i < all.length; i++) if (all[i].id == args.id) return all[i]; @@ -169,8 +168,8 @@ var kTestGraphQLUserFunctionsConfig = FunctionsConfig{ }, "infinite": { Type: "javascript", - Code: `function(context, args, parent, info) { - var result = context.user.graphql("query{ infinite }"); + Code: `async function(context, args) { + var result = await context.user.graphql("query{ infinite }"); if (result.errors) throw "GraphQL query failed:" + result.errors[0].message; return -1;}`, Allow: &Allow{Channels: []string{"*"}}, @@ -207,14 +206,13 @@ query { } ` -func assertGraphQLResult(t *testing.T, expected string, result *graphql.Result, err error) { +func assertGraphQLResult(t *testing.T, expected string, result *db.GraphQLResult, err error) { if !assert.NoError(t, err) || !assert.NotNil(t, result) { return } - if !assert.Zerof(t, len(result.Errors), "Unexpected GraphQL errors: %v", result.Errors) { + if !assert.Zerof(t, len(result.Errors), "Unexpected GraphQL errors: %#v", result.Errors) { for _, err := range result.Errors { t.Logf("\t%v", err) - t.Logf("\t\t%T %#v", err.OriginalError(), err.OriginalError()) } return } @@ -223,9 +221,15 @@ func assertGraphQLResult(t *testing.T, expected string, result *graphql.Result, assert.Equal(t, expected, string(j)) } +func assertGraphQLNoErrors(t *testing.T, result *db.GraphQLResult, err error) bool { + return assert.NoError(t, err) && + assert.NotNil(t, result) && + assert.Zerof(t, len(result.Errors), "Unexpected GraphQL errors: %v", result.Errors) +} + // Per the spec, GraphQL errors are not indicated via `err`, rather through an `errors` // property in the `result` object. -func assertGraphQLError(t *testing.T, expectedErrorText string, result *graphql.Result, err error) { +func assertGraphQLError(t *testing.T, expectedErrorText string, result *db.GraphQLResult, err error) { if !assert.NoError(t, err) || !assert.NotNil(t, result) { return } @@ -235,21 +239,18 @@ func assertGraphQLError(t *testing.T, expectedErrorText string, result *graphql. assert.NotZero(t, len(result.Errors), "Expected GraphQL error but got none; data is %s", string(data)) return } + var allErrs []string for _, err := range result.Errors { if strings.Contains(err.Error(), expectedErrorText) { return } + allErrs = append(allErrs, err.Error()) } - t.Logf("GraphQL error did not contain expected string %q: actually %#v", expectedErrorText, result.Errors) - t.Fail() + assert.FailNowf(t, "GraphQL error did not contain expected string", "Expected to find %q: actually:\n%s", expectedErrorText, strings.Join(allErrs, "\n")) } // Unit test for GraphQL queries. func TestUserGraphQL(t *testing.T) { - // FIXME : this test doesn't work because the access view does not exist on the collection ??? - t.Skip("Skipping test until access view is available with collections") - - // base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) db, ctx := setupTestDBWithFunctions(t, &kTestGraphQLUserFunctionsConfig, &kTestGraphQLConfig) defer db.Close(ctx) @@ -338,10 +339,10 @@ var kTestGraphQLConfigWithN1QL = GraphQLConfig{ }, "infinite": { Type: "javascript", - Code: `function(parent, args, context, info) { - var result = context.user.graphql("query{ infinite }"); - if (result.errors) throw "GraphQL query failed: " + result.errors[0].message; - return -1;}`, + Code: `async function(parent, args, context, info) { + var result = await context.user.graphql("query{ infinite }"); + if (result.errors) throw "GraphQL query failed:" + result.errors[0].message; + return -1;}`, Allow: allowAll, }, "task": { @@ -395,7 +396,7 @@ var kTestGraphQLConfigWithN1QL = GraphQLConfig{ Code: `function(parent, args, context, info) { if (!parent.id) throw "Invalid parent"; if (Object.keys(args).length != 0) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; + if (!info.selectedFieldNames) throw "No info.selectedFieldNames"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; return "TOP SECRET!";}`, @@ -416,9 +417,6 @@ type Body = db.Body // Unit test for GraphQL queries. func TestUserGraphQLWithN1QL(t *testing.T) { - - base.DisableTestWithCollections(t) - if base.UnitTestUrlIsWalrus() { t.Skip("This test is Couchbase Server only (requires N1QL)") } @@ -459,7 +457,75 @@ func TestUserGraphQLWithN1QL(t *testing.T) { assertGraphQLResult(t, `{"task":{"description":"Bass ale please","title":"Beer"}}`, result, err) } -func TestGraphQLMaxSchemaSize(t *testing.T) { +// A placeholder GraphQL resolver function (should never be called!) +var kDummyFieldResolver = FunctionConfig{ + Type: "javascript", + Code: `function(parent, args, context, info) {throw 'unimplemented';}`, + Allow: allowAll, +} + +var kDummyTypeResolver = FunctionConfig{ + Type: "javascript", + Code: `function(context,value) {throw 'unimplemented';}`, +} + +func TestUserGraphQLTypeNameResolver(t *testing.T) { + var schema = ` + interface Node { + id: ID! + } + type Task implements Node { + id: ID! + title: String! + } + type Person implements Node { + id: ID! + name: String! + } + type Query { + node(id: ID!) : Node + }` + + config := GraphQLConfig{ + Schema: &schema, + Resolvers: map[string]GraphQLResolverConfig{ + "Node": { + "__typename": { + Type: "javascript", + Code: `function(context,value) {return value.type;}`, + }, + }, + "Query": { + "node": { + Type: "javascript", + Code: `function(context, args) { + switch (args.id) { + case "1234": return {"type":"Task", "title": "Buy mangos"}; + case "4321": return {"type":"Person", "name": "Alice"}; + default: return null; + } + }`, + }, + }, + }, + } + + db, ctx := setupTestDBWithFunctions(t, nil, &config) + defer db.Close(ctx) + + const kQuery = `query($id:ID!) { node(id:$id) { + ... on Task {title} + ... on Person {name} + } }` + + result, err := db.UserGraphQLQuery(kQuery, "", map[string]any{"id": "1234"}, true, ctx) + assertGraphQLResult(t, `{"node":{"title":"Buy mangos"}}`, result, err) + + result, err = db.UserGraphQLQuery(kQuery, "", map[string]any{"id": "4321"}, true, ctx) + assertGraphQLResult(t, `{"node":{"name":"Alice"}}`, result, err) +} + +func TestUserGraphQLMaxSchemaSize(t *testing.T) { var schema = ` type Task { id: ID! @@ -476,17 +542,23 @@ func TestGraphQLMaxSchemaSize(t *testing.T) { "Query": { "square": { Type: "javascript", - Code: `function(context,args) {return args.n * args.n;}`, + Code: `function(parent, args, context, info) {return args.n * args.n;}`, }, }, }, } - _, err := CompileGraphQL(&config) + err := testValidateFunctions(t, nil, &config) assert.ErrorContains(t, err, "GraphQL schema too large (> 20 bytes)") } -func TestGraphQLMaxResolverCount(t *testing.T) { +func TestUserGraphQLMaxResolverCount(t *testing.T) { var schema = ` + type Query { + foo: String! + } + type Mutation { + bar: String! + } type Task { id: ID! title: String! @@ -502,24 +574,24 @@ func TestGraphQLMaxResolverCount(t *testing.T) { "Query": { "square": { Type: "javascript", - Code: `function(context,args) {return args.n * args.n;}`, + Code: `function(parent, args, context, info) {return args.n * args.n;}`, }, }, "Mutation": { "complete": { Type: "javascript", - Code: `function(context, args, parent, info) { }`, + Code: `function(parent, args, context, info) { }`, }, }, }, } - _, err := CompileGraphQL(&config) + err := testValidateFunctions(t, nil, &config) assert.ErrorContains(t, err, "too many GraphQL resolvers (> 1)") } func TestArgsInResolverConfig(t *testing.T) { var config = GraphQLConfig{ - Schema: base.StringPtr(`type Query{}`), + Schema: base.StringPtr(`type Query{square(n: Int!): Int!}`), Resolvers: map[string]GraphQLResolverConfig{ "Query": { "square": { @@ -530,23 +602,23 @@ func TestArgsInResolverConfig(t *testing.T) { }, }, } - _, err := CompileGraphQL(&config) + err := testValidateFunctions(t, nil, &config) assert.ErrorContains(t, err, `'args' is not valid in a GraphQL resolver config`) } func TestUnresolvedTypesInSchema(t *testing.T) { var config = GraphQLConfig{ - Schema: base.StringPtr(`type Query{} type abc{def:kkk}`), + Schema: base.StringPtr(`type Query{foo:Int!}`), Resolvers: nil, } - _, err := CompileGraphQL(&config) - assert.ErrorContains(t, err, `GraphQL Schema object has no registered TypeMap -- this probably means the schema has unresolved types`) + err := testValidateFunctions(t, nil, &config) + assert.ErrorContains(t, err, `GraphQL resolver Query.foo: missing function definition`) } func TestInvalidMutationType(t *testing.T) { t.Run("Unrecognized type cpp", func(t *testing.T) { var config = GraphQLConfig{ - Schema: base.StringPtr(`type Query{}`), + Schema: base.StringPtr(`type Query{foo:Int!} type Mutation{complete:Int!}`), Resolvers: map[string]GraphQLResolverConfig{ "Mutation": { "complete": { @@ -556,12 +628,12 @@ func TestInvalidMutationType(t *testing.T) { }, }, } - _, err := CompileGraphQL(&config) + err := testValidateFunctions(t, nil, &config) assert.ErrorContains(t, err, `unrecognized 'type' "cpp"`) }) t.Run("Unrecognized type query", func(t *testing.T) { var config = GraphQLConfig{ - Schema: base.StringPtr(`type Query{}`), + Schema: base.StringPtr(`type Query{foo:Int!} type Mutation{complete:Int!}`), Resolvers: map[string]GraphQLResolverConfig{ "Mutation": { "complete": { @@ -571,7 +643,7 @@ func TestInvalidMutationType(t *testing.T) { }, }, } - _, err := CompileGraphQL(&config) + err := testValidateFunctions(t, nil, &config) assert.ErrorContains(t, err, `GraphQL mutations must be implemented in JavaScript`) }) } @@ -588,8 +660,9 @@ func TestCompilationErrorInResolverCode(t *testing.T) { }, }, } - _, err := CompileGraphQL(&config) - assert.ErrorContains(t, err, `500 Error compiling GraphQL resolver "Query:square"`) + err := testValidateFunctions(t, nil, &config) + assert.ErrorContains(t, err, `Query.square`) + assert.ErrorContains(t, err, `SyntaxError`) } func TestGraphQLMaxCodeSize(t *testing.T) { @@ -606,8 +679,9 @@ func TestGraphQLMaxCodeSize(t *testing.T) { }, }, } - _, err := CompileGraphQL(&config) - assert.ErrorContains(t, err, "resolver square code too large (> 2 bytes)") + err := testValidateFunctions(t, nil, &config) + assert.ErrorContains(t, err, "Query.square") + assert.ErrorContains(t, err, "code is too large (> 2 bytes)") } // Unit Test for Typename resolver for interfaces in GraphQL schema @@ -630,8 +704,8 @@ func TestTypenameResolver(t *testing.T) { }, }, } - _, err := CompileGraphQL(&config) - assert.ErrorContains(t, err, "a GraphQL '__typename__' resolver must be JavaScript") + err := testValidateFunctions(t, nil, &config) + assert.ErrorContains(t, err, "a GraphQL '__typename' resolver must be JavaScript") }) t.Run("Error in compiling typename resolver", func(t *testing.T) { var config = GraphQLConfig{ @@ -649,8 +723,9 @@ func TestTypenameResolver(t *testing.T) { }, }, } - _, err := CompileGraphQL(&config) - assert.ErrorContains(t, err, `Error compiling GraphQL type-name resolver "Book"`) + err := testValidateFunctions(t, nil, &config) + assert.ErrorContains(t, err, `Book.__typename`) + assert.ErrorContains(t, err, `SyntaxError`) }) t.Run("Typename Resolver should not have allow", func(t *testing.T) { var config = GraphQLConfig{ @@ -671,8 +746,8 @@ func TestTypenameResolver(t *testing.T) { }, }, } - _, err := CompileGraphQL(&config) - assert.ErrorContains(t, err, "'allow' is not valid in a GraphQL '__typename__' resolver") + err := testValidateFunctions(t, nil, &config) + assert.ErrorContains(t, err, "'allow' is not valid in a GraphQL '__typename' resolver") }) t.Run("Correct Schema and Query produces the result", func(t *testing.T) { @@ -699,7 +774,7 @@ func TestTypenameResolver(t *testing.T) { }, }, } - _, err := CompileGraphQL(&config) + err := testValidateFunctions(t, nil, &config) assert.NoError(t, err) db, ctx := setupTestDBWithFunctions(t, nil, &config) defer db.Close(ctx) @@ -716,7 +791,7 @@ func TestInvalidSchemaAndSchemaFile(t *testing.T) { SchemaFile: base.StringPtr("someInvalidPath/someInvalidFileName"), Resolvers: nil, } - _, err := CompileGraphQL(&config) + err := testValidateFunctions(t, nil, &config) assert.ErrorContains(t, err, "GraphQL config: only one of `schema` and `schemaFile` may be used") }) @@ -724,7 +799,7 @@ func TestInvalidSchemaAndSchemaFile(t *testing.T) { var config = GraphQLConfig{ Resolvers: nil, } - _, err := CompileGraphQL(&config) + err := testValidateFunctions(t, nil, &config) assert.ErrorContains(t, err, "GraphQL config: either `schema` or `schemaFile` must be defined") }) @@ -732,9 +807,9 @@ func TestInvalidSchemaAndSchemaFile(t *testing.T) { var config = GraphQLConfig{ SchemaFile: base.StringPtr("dummySchemaFile.txt"), } - _, err := CompileGraphQL(&config) - fmt.Println(err) - assert.ErrorContains(t, err, "can't read file") + err := testValidateFunctions(t, nil, &config) + assert.ErrorContains(t, err, "GraphQL: can't read schema file dummySchemaFile.txt") + assert.ErrorContains(t, err, "no such file or directory") //? Might be OS specific }) } @@ -746,34 +821,19 @@ func TestValidSchemaFile(t *testing.T) { assert.NoError(t, err) var config = GraphQLConfig{ SchemaFile: base.StringPtr("schema.graphql"), + Resolvers: map[string]GraphQLResolverConfig{ + "Query": { + "sum": { + Type: "javascript", + Code: `function(parent, args, context, info) {return args.n + args.n;}`, + }, + }, + }, } - _, err = CompileGraphQL(&config) + err = testValidateFunctions(t, nil, &config) assert.NoError(t, err) err = os.Remove("schema.graphql") assert.NoError(t, err) }) } - -func TestFixOfCVE_2022_37315(t *testing.T) { - // Tests fix of CVE 2022-37315, reported as https://github.com/graphql-go/graphql/issues/637 - // Without the fix, this test panics: - // runtime: goroutine stack exceeds 1000000000-byte limit - // runtime: sp=0xc0209c03c8 stack=[0xc0209c0000, 0xc0409c0000] - // fatal error: stack overflow - - var schema = `String r` - var config = GraphQLConfig{ - Schema: &schema, - Resolvers: map[string]GraphQLResolverConfig{ - "Query": { - "square": { - Type: "javascript", - Code: `function(parent, args, context, info) {return args.n * args.n;}`, - }, - }, - }, - } - _, err := CompileGraphQL(&config) - assert.ErrorContains(t, err, `Syntax Error GraphQL (1:1) Unexpected Name "String"`) -} diff --git a/db/functions/js_callbacks.go b/db/functions/js_callbacks.go deleted file mode 100644 index 20014a78d9..0000000000 --- a/db/functions/js_callbacks.go +++ /dev/null @@ -1,327 +0,0 @@ -/* -Copyright 2022-Present Couchbase, Inc. - -Use of this software is governed by the Business Source License included in -the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that -file, in accordance with the Business Source License, use of this software will -be governed by the Apache License, Version 2.0, included in the file -licenses/APL2.txt. -*/ - -package functions - -import ( - "context" - "encoding/json" - "fmt" - "net/http" - - "github.com/couchbase/sync_gateway/base" - "github.com/couchbase/sync_gateway/db" - "github.com/robertkrimen/otto" -) - -func (runner *jsRunner) defineNativeCallbacks() { - // Implementation of the 'delete(docID)' callback: - runner.DefineNativeFunction("_delete", func(call otto.FunctionCall) otto.Value { - var docID string - var doc map[string]any - if arg0 := call.Argument(0); arg0.IsString() { - docID = arg0.String() - } else if arg0.IsObject() { - doc = ottoObjectParam(call, 0, false, "user.delete") - } else { - panic(call.Otto.MakeTypeError("user.delete() arg 1 must be a string or object")) - } - sudo := ottoBoolParam(call, 1) - ok, err := runner.do_delete(docID, doc, sudo) - return ottoResult(call, ok, err) - }) - - // Implementation of the 'function(name,params)' callback: - runner.DefineNativeFunction("_func", func(call otto.FunctionCall) otto.Value { - funcName := ottoStringParam(call, 0, "user.function") - params := ottoObjectParam(call, 1, true, "user.function") - sudo := ottoBoolParam(call, 2) - result, err := runner.do_func(funcName, params, sudo) - return ottoJSONResult(call, result, err) - }) - - // Implementation of the 'get(docID)' callback: - runner.DefineNativeFunction("_get", func(call otto.FunctionCall) otto.Value { - docID := ottoStringParam(call, 0, "user.get") - sudo := ottoBoolParam(call, 1) - doc, err := runner.do_get(docID, nil, sudo) - return ottoJSONResult(call, doc, err) - }) - - // Implementation of the 'graphql(query,params)' callback: - runner.DefineNativeFunction("_graphql", func(call otto.FunctionCall) otto.Value { - query := ottoStringParam(call, 0, "user.graphql") - params := ottoObjectParam(call, 1, true, "user.graphql") - sudo := ottoBoolParam(call, 2) - result, err := runner.do_graphql(query, params, sudo) - return ottoJSONResult(call, result, err) - }) - - // Implementation of the 'save(doc,docID?)' callback: - runner.DefineNativeFunction("_save", func(call otto.FunctionCall) otto.Value { - doc := ottoObjectParam(call, 0, false, "user.save") - docID := ottoOptionalStringParam(call, 1, "user.save") - sudo := ottoBoolParam(call, 2) - docID, err := runner.do_save(doc, docID, sudo) - return ottoResult(call, docID, err) - }) - - // Implementation of the '_requireMutating()' callback: - runner.DefineNativeFunction("_requireMutating", func(call otto.FunctionCall) otto.Value { - err := runner.checkMutationAllowed("requireMutating") - return ottoResult(call, nil, err) - }) -} - -func (runner *jsRunner) checkMutationAllowed(what string) error { - if roFn, ok := runner.ctx.Value(readOnlyKey).(string); ok { - name := fmt.Sprintf("%s %q", runner.kind, runner.name) - if name == roFn { - return base.HTTPErrorf(http.StatusForbidden, "%q called from non-mutating %s", what, roFn) - } else { - return base.HTTPErrorf(http.StatusForbidden, "%q called by %s %q from non-mutating %s", what, runner.kind, runner.name, roFn) - } - } else { - return nil - } -} - -// Enters admin/sudo mode, and returns a function that when called will exit it. -func (runner *jsRunner) enterSudo() func() { - user := runner.currentDB.User() - ctx := runner.ctx - runner.currentDB.SetUser(nil) - runner.ctx = context.WithValue(ctx, readOnlyKey, nil) - // Return the 'exitSudo' function that the caller will defer: - return func() { - runner.currentDB.SetUser(user) - runner.ctx = ctx - } -} - -//////// DATABASE CALLBACK FUNCTION IMPLEMENTATIONS: - -// Implementation of JS `user.delete(doc)` function -// Parameter can be either a docID or a document body with _id (and optionally _rev) -func (runner *jsRunner) do_delete(docID string, body map[string]any, sudo bool) (bool, error) { - if !sudo { - if err := runner.checkMutationAllowed("user.delete"); err != nil { - return false, err - } - } - tombstone := map[string]any{"_deleted": true} - if body != nil { - if _id, ok := body["_id"].(string); ok { - docID = _id - } else { - return false, base.HTTPErrorf(400, "Missing doc._id in delete() call") - } - if revID, ok := body["_rev"]; ok { - tombstone["_rev"] = revID - } - } - tombstone["_id"] = docID - - id, err := runner.do_save(tombstone, &docID, sudo) - return (id != nil), err -} - -// Implementation of JS `user.function(name, params)` function -func (runner *jsRunner) do_func(funcName string, params map[string]any, sudo bool) (any, error) { - if sudo { - exitSudo := runner.enterSudo() - defer exitSudo() - } - return runner.currentDB.CallUserFunction(funcName, params, true, runner.ctx) -} - -// Implementation of JS `user.get(docID, docType?)` function -func (runner *jsRunner) do_get(docID string, docType *string, sudo bool) (any, error) { - if err := db.CheckTimeout(runner.ctx); err != nil { - return nil, err - } else if sudo { - user := runner.currentDB.User() - runner.currentDB.SetUser(nil) - defer func() { runner.currentDB.SetUser(user) }() - } - collection, err := runner.currentDB.GetDefaultDatabaseCollectionWithUser() - if err != nil { - return nil, err - } - rev, err := collection.GetRev(runner.ctx, docID, "", false, nil) - if err != nil { - status, _ := base.ErrorAsHTTPStatus(err) - if status == http.StatusNotFound { - // Not-found is not an error; just return null. - return nil, nil - } - return nil, err - } - body, err := rev.Body() - if err != nil { - return nil, err - } - if docType != nil && body["type"] != *docType { - return nil, nil - } - body["_id"] = docID - body["_rev"] = rev.RevID - return body, nil -} - -// Implementation of JS `user.graphql(query, params)` function -func (runner *jsRunner) do_graphql(query string, params map[string]any, sudo bool) (any, error) { - if sudo { - exitSudo := runner.enterSudo() - defer exitSudo() - } - return runner.currentDB.UserGraphQLQuery(query, "", params, true, runner.ctx) -} - -// Implementation of JS `user.save(body, docID?)` function -func (runner *jsRunner) do_save(body map[string]any, docIDPtr *string, sudo bool) (*string, error) { - if err := db.CheckTimeout(runner.ctx); err != nil { - return nil, err - } else if sudo { - exitSudo := runner.enterSudo() - defer exitSudo() - } else if err := runner.checkMutationAllowed("user.put"); err != nil { - return nil, err - } - - // The optional `docID` parameter takes precedence over a `_id` key in the body. - // If neither is present, make up a new random docID. - var docID string - if docIDPtr != nil { - docID = *docIDPtr - } else if _id, found := body["_id"].(string); found { - docID = _id - } else { - var err error - docID, err = base.GenerateRandomID() - if err != nil { - return nil, err - } - } - delete(body, "_id") - collection, err := runner.currentDB.GetDefaultDatabaseCollectionWithUser() - if err != nil { - return nil, err - } - if _, found := body["_rev"]; found { - // If caller provided `_rev` property, use MVCC as normal: - _, _, err := collection.Put(runner.ctx, docID, body) - if err == nil { - return &docID, err // success - } else if status, _ := base.ErrorAsHTTPStatus(err); status == http.StatusConflict { - return nil, nil // conflict: no error, but returns null - } else { - return nil, err - } - - } else { - // If caller didn't provide a `_rev` property, fall back to "last writer wins": - // get the current revision if any, and pass it to Put so that the save always succeeds. - for { - rev, err := collection.GetRev(runner.ctx, docID, "", false, []string{}) - if err != nil { - if status, _ := base.ErrorAsHTTPStatus(err); status != http.StatusNotFound { - return nil, err - } - } - if rev.RevID == "" { - delete(body, "_rev") - } else { - body["_rev"] = rev.RevID - } - - _, _, err = collection.Put(runner.ctx, docID, body) - if err == nil { - break // success! - } else if status, _ := base.ErrorAsHTTPStatus(err); status != http.StatusConflict { - return nil, err - } - // on conflict (race condition), retry... - } - } - return &docID, nil -} - -//////// OTTO UTILITIES: - -// Returns a parameter of `call` as a Go string, or throws a JS exception if it's not a string. -func ottoBoolParam(call otto.FunctionCall, arg int) bool { - result, _ := call.Argument(arg).ToBoolean() - return result -} - -// Returns a parameter of `call` as a Go string, or throws a JS exception if it's not a string. -func ottoStringParam(call otto.FunctionCall, arg int, what string) string { - val := call.Argument(arg) - if !val.IsString() { - panic(call.Otto.MakeTypeError(fmt.Sprintf("%s() param %d must be a string", what, arg+1))) - } - return val.String() -} - -// Returns a parameter of `call` as a Go string or nil. -func ottoOptionalStringParam(call otto.FunctionCall, arg int, what string) *string { - val := call.Argument(arg) - if val.IsString() { - return base.StringPtr(val.String()) - } else if val.IsNull() || val.IsUndefined() { - return nil - } else { - panic(call.Otto.MakeTypeError(fmt.Sprintf("%s() param %d must be a string or null", what, arg+1))) - } -} - -// Returns a parameter of `call` as a Go map, or throws a JS exception if it's not a map. -// If `optional` is true, the parameter is allowed not to exist, in which case `nil` is returned. -func ottoObjectParam(call otto.FunctionCall, arg int, optional bool, what string) map[string]any { - val := call.Argument(arg) - if !val.IsObject() { - if optional && val.IsUndefined() { - return nil - } - panic(call.Otto.MakeTypeError(fmt.Sprintf("%s() param %d must be an object", what, arg+1))) - } - obj, err := val.Export() - if err != nil { - panic(call.Otto.MakeTypeError("Yikes, couldn't export JS value")) - } - return obj.(map[string]any) -} - -// Returns `result` back to Otto; or if `err` is non-nil, "throws" it via a Go panic -func ottoResult(call otto.FunctionCall, result any, err error) otto.Value { - if err == nil { - val, _ := call.Otto.ToValue(result) - return val - } else { - // (javaScriptRunner.convertError clumsily takes these apart back into errors) - if status, msg := base.ErrorAsHTTPStatus(err); status != 500 && status != 200 { - panic(call.Otto.MakeCustomError("HTTP", fmt.Sprintf("%d %s", status, msg))) - } else { - panic(call.Otto.MakeCustomError("Go", err.Error())) - } - } -} - -// Returns `result` back to Otto in JSON form; or if `err` is non-nil, "throws" it via a Go panic -func ottoJSONResult(call otto.FunctionCall, result any, err error) otto.Value { - if err == nil && result != nil { - if j, err := json.Marshal(result); err == nil { - val, _ := call.Otto.ToValue(string(j)) - return val - } - } - return ottoResult(call, result, err) -} diff --git a/db/functions/js_function.go b/db/functions/js_function.go deleted file mode 100644 index ee49e5bef1..0000000000 --- a/db/functions/js_function.go +++ /dev/null @@ -1,61 +0,0 @@ -/* -Copyright 2022-Present Couchbase, Inc. - -Use of this software is governed by the Business Source License included in -the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that -file, in accordance with the Business Source License, use of this software will -be governed by the Apache License, Version 2.0, included in the file -licenses/APL2.txt. -*/ - -package functions - -import ( - "context" - _ "embed" - - "github.com/couchbase/sync_gateway/base" - - sgbucket "github.com/couchbase/sg-bucket" - "github.com/couchbase/sync_gateway/db" - "github.com/graphql-go/graphql" - _ "github.com/robertkrimen/otto/underscore" -) - -// implements UserFunctionInvocation and resolver -type jsInvocation struct { - *functionImpl - db *db.Database - ctx context.Context - args map[string]any -} - -func (fn *jsInvocation) Iterate() (sgbucket.QueryResultIterator, error) { - return nil, nil -} - -func (fn *jsInvocation) Run() (any, error) { - return fn.call(db.MakeUserCtx(fn.db.User(), base.DefaultScope, base.DefaultCollection), fn.args) -} - -func (fn *jsInvocation) Resolve(params graphql.ResolveParams) (any, error) { - return fn.call( - params.Source, // parent - params.Args, // args - db.MakeUserCtx(fn.db.User(), base.DefaultScope, base.DefaultCollection), // context - resolverInfo(params)) // info -} - -func (fn *jsInvocation) ResolveType(params graphql.ResolveTypeParams) (any, error) { - info := map[string]any{} - return fn.call(db.MakeUserCtx(fn.db.User(), base.DefaultScope, base.DefaultCollection), params.Value, info) -} - -func (fn *jsInvocation) call(jsArgs ...any) (any, error) { - return fn.compiled.WithTask(func(task sgbucket.JSServerTask) (result any, err error) { - runner := task.(*jsRunner) - return runner.CallWithDB(fn.db, - fn.ctx, - jsArgs...) - }) -} diff --git a/db/functions/js_runner.go b/db/functions/js_runner.go deleted file mode 100644 index d0a66a8e5b..0000000000 --- a/db/functions/js_runner.go +++ /dev/null @@ -1,184 +0,0 @@ -/* -Copyright 2022-Present Couchbase, Inc. - -Use of this software is governed by the Business Source License included in -the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that -file, in accordance with the Business Source License, use of this software will -be governed by the Apache License, Version 2.0, included in the file -licenses/APL2.txt. -*/ - -package functions - -import ( - "context" - _ "embed" - "fmt" - "net/http" - "regexp" - "strconv" - "strings" - "time" - - sgbucket "github.com/couchbase/sg-bucket" - "github.com/couchbase/sync_gateway/base" - "github.com/couchbase/sync_gateway/db" - "github.com/robertkrimen/otto" - _ "github.com/robertkrimen/otto/underscore" -) - -//////// JS RUNNER - -// Number of Otto contexts to cache per function, i.e. the number of goroutines that can be simultaneously running each function. -const kUserFunctionCacheSize = 2 - -// Maximum nesting of JS user function calls (not the JS stack depth) -var kUserFunctionMaxCallDepth = 20 - -// The outermost JavaScript code. Evaluating it returns a function, which is then called by the -// Runner every time it's invoked. Contains `%s` where the actual function source code goes. -// -//go:embed js_wrapper.js -var kJavaScriptWrapper string - -// Creates a JSServer instance wrapping a userJSRunner, for user JS functions and GraphQL resolvers. -func newFunctionJSServer(name string, what string, sourceCode string) (*sgbucket.JSServer, error) { - js := fmt.Sprintf(kJavaScriptWrapper, sourceCode) - jsServer := sgbucket.NewJSServer(js, 0, kUserFunctionCacheSize, - func(fnSource string, timeout time.Duration) (sgbucket.JSServerTask, error) { - return newJSRunner(name, what, fnSource) - }) - // Call WithTask to force a task to be instantiated, which will detect syntax errors in the script. Otherwise the error only gets detected the first time a client calls the function. - var err error - _, err = jsServer.WithTask(func(sgbucket.JSServerTask) (any, error) { - return nil, nil - }) - return jsServer, err -} - -// An object that runs a user JavaScript function or a GraphQL resolver. -// Not thread-safe! Owned by an sgbucket.JSServer, which arbitrates access to it. -type jsRunner struct { - sgbucket.JSRunner // "Superclass" - kind string // "user function", "GraphQL resolver", etc - name string // Name of this function or resolver - currentDB *db.Database // db.Database instance (updated before every call) - ctx context.Context // Context (updated before every call) -} - -// Creates a jsRunner given its name and JavaScript source code. -func newJSRunner(name string, kind string, funcSource string) (*jsRunner, error) { - ctx := context.Background() - runner := &jsRunner{ - name: name, - kind: kind, - } - err := runner.InitWithLogging("", 0, - func(s string) { - base.ErrorfCtx(ctx, base.KeyJavascript.String()+": %s %s: %s", kind, name, base.UD(s)) - }, - func(s string) { - base.InfofCtx(ctx, base.KeyJavascript, "%s %s: %s", kind, name, base.UD(s)) - }) - if err != nil { - return nil, err - } - - // Define the `get`, `save`, etc. function callbacks: - runner.defineNativeCallbacks() - - // Set (and compile) the JS function: - if _, err := runner.JSRunner.SetFunction(funcSource); err != nil { - return nil, base.HTTPErrorf(http.StatusInternalServerError, "Error compiling %s %q: %v", kind, name, err) - } - - // Function that runs before every call: - runner.Before = func() { - if runner.currentDB == nil { - panic("javaScriptRunner can't run without a currentDB") - } - } - // Function that runs after every call: - runner.After = func(jsResult otto.Value, err error) (any, error) { - defer func() { - runner.currentDB = nil - }() - if err != nil { - base.ErrorfCtx(context.Background(), base.KeyJavascript.String()+": %s %s failed: %#v", runner.kind, runner.name, err) - return nil, runner.convertError(err) - } - return jsResult.Export() - } - - return runner, nil -} - -type jsRunnerContextKey string - -var ctxJSCallDepthKey = jsRunnerContextKey("call depth") - -// Calls a javaScriptRunner's JavaScript function. -func (runner *jsRunner) CallWithDB(db *db.Database, ctx context.Context, jsArgs ...any) (result any, err error) { - if ctx == nil { - panic("missing context to userJSRunner") - } - - var timeout time.Duration - if deadline, exists := ctx.Deadline(); exists { - timeout = time.Until(deadline) - if timeout <= 0 { - return nil, sgbucket.ErrJSTimeout - } - } - - var depth int - var ok bool - if depth, ok = ctx.Value(ctxJSCallDepthKey).(int); ok { - if depth >= kUserFunctionMaxCallDepth { - base.ErrorfCtx(ctx, "User function recursion too deep, calling %s", runner.name) - return nil, base.HTTPErrorf(http.StatusLoopDetected, "User function recursion too deep") - } - } - ctx = context.WithValue(ctx, ctxJSCallDepthKey, depth+1) - - runner.SetTimeout(timeout) - runner.currentDB = db - runner.ctx = ctx - return runner.Call(jsArgs...) -} - -// JavaScript error returned by a jsRunner -type jsError struct { - err error - runnerKind string - runnerName string -} - -func (jserr *jsError) Error() string { - return fmt.Sprintf("%v (while calling %s %q)", jserr.err, jserr.runnerKind, jserr.runnerName) -} - -func (jserr *jsError) Unwrap() error { - return jserr.err -} - -var HttpErrRE = regexp.MustCompile(`^HTTP:\s*(\d+)\s+(.*)`) - -func (runner *jsRunner) convertError(err error) error { - if err == sgbucket.ErrJSTimeout { - return base.HTTPErrorf(408, "Timeout in JavaScript") - } - // Unfortunately there is no API on otto.Error to get the name & message separately. - // Instead, look for the name as a prefix. (See the `ottoResult` function below) - str := err.Error() - if strings.HasPrefix(str, "HTTP:") { - m := HttpErrRE.FindStringSubmatch(str) - status, _ := strconv.ParseInt(m[1], 10, 0) - message := m[2] - if status == http.StatusUnauthorized && (runner.currentDB.User() == nil || runner.currentDB.User().Name() != "") { - status = http.StatusForbidden - } - return base.HTTPErrorf(int(status), "%s (while calling %s %q)", message, runner.kind, runner.name) - } - return &jsError{err, runner.kind, runner.name} -} diff --git a/db/functions/js_wrapper.js b/db/functions/js_wrapper.js deleted file mode 100644 index 34e77ad1fe..0000000000 --- a/db/functions/js_wrapper.js +++ /dev/null @@ -1,124 +0,0 @@ -/* -Copyright 2022-Present Couchbase, Inc. - -Use of this software is governed by the Business Source License included in -the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that -file, in accordance with the Business Source License, use of this software will -be governed by the Apache License, Version 2.0, included in the file -licenses/APL2.txt. -*/ - -function() { var userFn = (%s); // <-- substitutes the JS function - - if (typeof(userFn) !== "function") - throw "The JavaScript code is not a function"; - - function unmarshal(v) {return (typeof(v)==='string') ? JSON.parse(v) : v;} - - // This is what's passed as the `context` parameter to userFn: - var Context = { - user: { - name: "", - roles: [], - channels: [], - defaultCollection: { - delete: function(doc) {return _delete(doc);}, - get: function(docID) {return unmarshal(_get(docID));}, - save: function(body, docID) {return _save(body, docID);}, - }, - function: function(name, args) {return unmarshal(_func(name, args));}, - graphql: function(q,args) {return unmarshal(_graphql(q,args));}, - }, - admin: { - defaultCollection: { - delete: function(doc) {return _delete(doc, true);}, - get: function(docID) {return unmarshal(_get(docID, true));}, - save: function(body, docID) {return _save(body, docID, true);}, - }, - function: function(name, args) {return unmarshal(_func(name, args, true));}, - graphql: function(q,args) {return unmarshal(_graphql(q,args, true));}, - }, - - requireAdmin: function() { - if (!this.user.name) return; // user is admin - throw("HTTP: 403 Forbidden"); - }, - - requireUser: function(name) { - var userName = this.user.name; - if (!userName) return; // user is admin - var allowed; - if (Array.isArray(name)) { - allowed = (name.indexOf(userName) != -1); - } else { - allowed = (userName == name); - } - if (!allowed) - throw("HTTP: 401 Unauthorized"); - }, - - requireRole: function(role) { - var userRoles = this.user.roles; - if (!userRoles) return; // user is admin - if (Array.isArray(role)) { - for (var i = 0; i < role.length; ++i) { - if (userRoles[role[i]] !== undefined) - return; - } - } else { - if (userRoles[role] !== undefined) - return; - } - throw("HTTP: 401 Unauthorized"); - }, - - requireAccess: function(channel) { - var userChannels = this.user.channels; - if (!userChannels) return; // user is admin - if (Array.isArray(channel)) { - for (var i = 0; i < channel.length; ++i) { - if (userChannels.indexOf(channel[i]) != -1) - return; - } - } else { - if (userChannels.indexOf(channel) != -1) - return; - } - throw("HTTP: 401 Unauthorized"); - }, - - requireMutating: function() { - _requireMutating(); - } - }; - - - // Standard JS function not implemented in Otto - if (!Array.from) { - Array.from = function(v) { - var len = v.length; - if (typeof(len) !== 'number') throw TypeError("Array.from") - var a = new Array(len); - for (i = 0; i < len; ++i) - a[i] = v[i]; - return a; - } - } - - - // Return the JS function that will be invoked repeatedly by the runner: - return function (a, b, c, d) { - // Note: Can't declare this as `function(...args)` because Otto doesn't support rest parameters. - // - If called with 4 args, I'm a GraphQL resolver and 'context' is the 3rd argument. - // - If called with 2 args, I'm a regular function and 'context' is the 1st argument. - var contextIndex = (arguments.length == 4) ? 2 : 0; - var userInfo = arguments[contextIndex]; - var context = Object.create(Context); - context.user = Object.create(Context.user); - context.user.name = userInfo.name; - context.user.roles = userInfo.roles; - context.user.channels = userInfo.channels; - arguments[contextIndex] = context; - return userFn(a, b, c, d); - }; -}() diff --git a/db/functions/n1ql_function.go b/db/functions/n1ql_function.go deleted file mode 100644 index 7b61d93bac..0000000000 --- a/db/functions/n1ql_function.go +++ /dev/null @@ -1,140 +0,0 @@ -/* -Copyright 2022-Present Couchbase, Inc. - -Use of this software is governed by the Business Source License included in -the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that -file, in accordance with the Business Source License, use of this software will -be governed by the Apache License, Version 2.0, included in the file -licenses/APL2.txt. -*/ - -package functions - -import ( - "context" - "errors" - "fmt" - "net/http" - "regexp" - - "github.com/couchbase/gocb/v2" - sgbucket "github.com/couchbase/sg-bucket" - "github.com/couchbase/sync_gateway/base" - "github.com/couchbase/sync_gateway/db" - "github.com/graphql-go/graphql" -) - -// implements UserFunctionInvocation and resolver -type n1qlInvocation struct { - *functionImpl - db *db.Database - ctx context.Context - args map[string]any - n1qlArgs map[string]any -} - -type n1qlUserArgument struct { - Name *string `json:"name,omitempty"` - Email *string `json:"email,omitempty"` - Channels []string `json:"channels,omitempty"` - Roles []string `json:"roles,omitempty"` -} - -var n1qlQueryRegex = regexp.MustCompile(`^\s*\(*(?i:SELECT)\b`) - -func validateN1QLQuery(query string) error { - if n1qlQueryRegex.MatchString(query) { - return nil - } else { - return fmt.Errorf("only SELECT queries are allowed") - } -} - -func (fn *n1qlInvocation) Iterate() (sgbucket.QueryResultIterator, error) { - var userArg n1qlUserArgument - if user := fn.db.User(); user != nil { - userArg.Name = base.StringPtr(user.Name()) - userArg.Email = base.StringPtr(user.Email()) - userArg.Channels = user.Channels().AllKeys() - userArg.Roles = user.RoleNames().AllKeys() - } - if fn.n1qlArgs == nil { - fn.n1qlArgs = map[string]any{} - } - fn.n1qlArgs["args"] = fn.args - fn.n1qlArgs["user"] = &userArg - - // Run the N1QL query: - // TODO: Multi-collection support for user functions is not implemented. - iter, err := db.N1QLQueryWithStats(fn.ctx, fn.db.Bucket.DefaultDataStore(), db.QueryTypeUserFunctionPrefix+fn.name, fn.Code, fn.n1qlArgs, - base.RequestPlus, false, fn.db.DbStats, fn.db.Options.SlowQueryWarningThreshold) - - if err != nil { - // Return a friendlier error: - var qe *gocb.QueryError - if errors.As(err, &qe) { - base.WarnfCtx(fn.ctx, "Error running query %q: %v", fn.name, err) - return nil, base.HTTPErrorf(http.StatusInternalServerError, "Query %q: %s", fn.name, qe.Errors[0].Message) - } else { - base.WarnfCtx(fn.ctx, "Unknown error running query %q: %T %#v", fn.name, err, err) - return nil, base.HTTPErrorf(http.StatusInternalServerError, "Unknown error running query %q (see logs)", fn.name) - } - } - // Do a final timeout check, so the caller will know not to do any more work if time's up: - return iter, db.CheckTimeout(fn.ctx) -} - -func (fn *n1qlInvocation) Run() (any, error) { - rows, err := fn.Iterate() - if err != nil { - return nil, err - } - defer func() { - if rows != nil { - _ = rows.Close() - } - }() - result := []any{} - var row any - for rows.Next(&row) { - result = append(result, row) - } - err = rows.Close() - rows = nil // prevent 'defer' from closing again - return result, err -} - -func (fn *n1qlInvocation) Resolve(params graphql.ResolveParams) (any, error) { - fn.n1qlArgs = map[string]any{ - "parent": params.Source, - "info": resolverInfo(params), - } - // Run the query: - result, err := fn.Run() - if err != nil { - return nil, err - } - if !isGraphQLListType(params.Info.ReturnType) { - // GraphQL result type is not a list (array), but N1QL always returns an array. - // So use the first row of the result as the value, if there is one. - if rows, ok := result.([]any); ok { - if len(rows) > 0 { - result = rows[0] - } else { - return nil, nil - } - } - if isGraphQLScalarType(params.Info.ReturnType) { - // GraphQL result type is a scalar, but a N1QL row is always an object. - // Use the single field of the object, if any, as the result: - row := result.(map[string]any) - if len(row) != 1 { - return nil, base.HTTPErrorf(http.StatusInternalServerError, "resolver %q returns scalar type %s, but its N1QL query returns %d columns, not 1", fn.name, params.Info.ReturnType, len(row)) - } - for _, value := range row { - result = value - } - } - } - return result, nil -} diff --git a/db/functions/n1ql_function_test.go b/db/functions/n1ql_function_test.go index f75f2dc3a9..b745bf8e7b 100644 --- a/db/functions/n1ql_function_test.go +++ b/db/functions/n1ql_function_test.go @@ -1,3 +1,5 @@ +//go:build cb_sg_v8 + /* Copyright 2020-Present Couchbase, Inc. @@ -43,7 +45,7 @@ var kUserN1QLFunctionsConfig = FunctionsConfig{ }, "user_parts": &FunctionConfig{ Type: "query", - Code: "SELECT $user.name AS name, $user.email AS email", + Code: "SELECT $user.name AS name, $user.roles AS roles", Allow: &Allow{Channels: []string{"user-${context.user.name}"}}, }, "admin_only": &FunctionConfig{ @@ -102,7 +104,6 @@ func TestUserN1QLQueries(t *testing.T) { t.Skip("Requires collection-aware function security (CBG-2597)") } - // base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) db, ctx := setupTestDBWithFunctions(t, &kUserN1QLFunctionsConfig, nil) defer db.Close(ctx) @@ -193,17 +194,17 @@ func testUserQueriesAsUser(t *testing.T, ctx context.Context, db *db.Database) { assert.NoError(t, err) // (Can't compare the entire result string because the order of items in the "channels" array // is undefined and can change from one run to another.) - iter, err := fn.Iterate() + result, err := fn.RunAsJSON() assert.NoError(t, err) - resultStr := queryResultString(t, iter) - assert.True(t, strings.HasPrefix(resultStr, `[{"user":{"channels":["`)) - assert.True(t, strings.HasSuffix(resultStr, `"],"email":"","name":"alice","roles":["hero"]}}]`)) + resultStr := string(result) + assert.True(t, strings.HasPrefix(resultStr, `[{"user":{"channels":["`), "result is %s", resultStr) + assert.True(t, strings.HasSuffix(resultStr, `"],"name":"alice","roles":["hero"]}}]`), "result is %s", resultStr) fn, err = db.GetUserFunction("user_parts", nil, false, ctx) assert.NoError(t, err) - iter, err = fn.Iterate() + result, err = fn.RunAsJSON() assert.NoError(t, err) - assertQueryResults(t, `[{"email":"","name":"alice"}]`, iter) + assert.Equal(t, `[{"name":"alice","roles":["hero"]}]`, string(result)) // ERRORS: @@ -232,8 +233,8 @@ func TestUserN1QLQueriesInvalid(t *testing.T) { }, } - _, err := CompileFunctions(kBadN1QLFunctionsConfig) - assert.ErrorContains(t, err, "only SELECT queries are allowed") // See fn validateN1QLQuery + err := testValidateFunctions(t, &kBadN1QLFunctionsConfig, nil) + assert.ErrorContains(t, err, "only SELECT queries are allowed") var kOKN1QLFunctionsConfig = FunctionsConfig{ Definitions: FunctionsDefs{ @@ -252,6 +253,6 @@ func TestUserN1QLQueriesInvalid(t *testing.T) { }, } - _, err = CompileFunctions(kOKN1QLFunctionsConfig) + err = testValidateFunctions(t, &kOKN1QLFunctionsConfig, nil) assert.NoError(t, err) } diff --git a/db/functions/user.go b/db/functions/user.go new file mode 100644 index 0000000000..541b7a3881 --- /dev/null +++ b/db/functions/user.go @@ -0,0 +1,16 @@ +// Copyright 2023-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. + +package functions + +// Name and capabilities of the current user. (Admin is represented by a nil `*userCredentials`.) +type userCredentials struct { + Name string + Roles []string + Channels []string +} diff --git a/db/import.go b/db/import.go index f3061f100b..1fc27da1d2 100644 --- a/db/import.go +++ b/db/import.go @@ -12,15 +12,14 @@ package db import ( "context" - "errors" "fmt" "strconv" "time" sgbucket "github.com/couchbase/sg-bucket" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" "github.com/couchbase/sync_gateway/channels" - "github.com/robertkrimen/otto" ) type ImportMode uint8 @@ -235,13 +234,13 @@ func (db *DatabaseCollectionWithUser) importDoc(ctx context.Context, docid strin if isDelete && body == nil { deleteBody := Body{BodyDeleted: true} - shouldImport, importErr = importFilter.EvaluateFunction(ctx, deleteBody) + shouldImport, importErr = importFilter(ctx, deleteBody) } else if isDelete && body != nil { deleteBody := body.ShallowCopy() deleteBody[BodyDeleted] = true - shouldImport, importErr = importFilter.EvaluateFunction(ctx, deleteBody) + shouldImport, importErr = importFilter(ctx, deleteBody) } else { - shouldImport, importErr = importFilter.EvaluateFunction(ctx, body) + shouldImport, importErr = importFilter(ctx, body) } if importErr != nil { @@ -443,68 +442,32 @@ func (db *DatabaseCollectionWithUser) backupPreImportRevision(ctx context.Contex return nil } -// ////// Import Filter Function +//////// Import Filter Function -// A compiled JavaScript event function. -type jsImportFilterRunner struct { - sgbucket.JSRunner - response bool -} - -// Compiles a JavaScript event function to a jsImportFilterRunner object. -func newImportFilterRunner(funcSource string, timeout time.Duration) (sgbucket.JSServerTask, error) { - importFilterRunner := &jsEventTask{} - err := importFilterRunner.InitWithLogging(funcSource, timeout, - func(s string) { - base.ErrorfCtx(context.Background(), base.KeyJavascript.String()+": Import %s", base.UD(s)) - }, - func(s string) { base.InfofCtx(context.Background(), base.KeyJavascript, "Import %s", base.UD(s)) }) - if err != nil { - return nil, err - } +type ImportFilterFunction func(context.Context, Body) (bool, error) - importFilterRunner.After = func(result otto.Value, err error) (interface{}, error) { - nativeValue, _ := result.Export() - return nativeValue, err - } - - return importFilterRunner, nil -} - -type ImportFilterFunction struct { - *sgbucket.JSServer -} +func NewImportFilterFunction(vms *js.VMPool, fnSource string, timeout time.Duration) ImportFilterFunction { + // Create the import service with its JS script: + service := js.NewService(vms, "import", fnSource) -func NewImportFilterFunction(fnSource string, timeout time.Duration) *ImportFilterFunction { - - base.DebugfCtx(context.Background(), base.KeyImport, "Creating new ImportFilterFunction") - return &ImportFilterFunction{ - JSServer: sgbucket.NewJSServer(fnSource, timeout, kTaskCacheSize, - func(fnSource string, timeout time.Duration) (sgbucket.JSServerTask, error) { - return newImportFilterRunner(fnSource, timeout) - }), - } -} - -// Calls a jsEventFunction returning an interface{} -func (i *ImportFilterFunction) EvaluateFunction(ctx context.Context, doc Body) (bool, error) { + // Return a function that calls the function on a document: + return func(ctx context.Context, doc Body) (bool, error) { + if timeout > 0 { + var cancelFn context.CancelFunc + ctx, cancelFn = context.WithTimeout(ctx, timeout) + defer cancelFn() + } - result, err := i.Call(doc) - if err != nil { - base.WarnfCtx(ctx, "Unexpected error invoking import filter for document %s - processing aborted, document will not be imported. Error: %v", base.UD(doc), err) - return false, err - } - switch result := result.(type) { - case bool: - return result, nil - case string: - boolResult, err := strconv.ParseBool(result) + result, err := service.Run(ctx, doc) if err != nil { return false, err } - return boolResult, nil - default: - base.WarnfCtx(ctx, "Import filter function returned non-boolean result %v Type: %T", result, result) - return false, errors.New("Import filter function returned non-boolean value.") + switch result := result.(type) { + case bool: + return result, nil + case string: + return strconv.ParseBool(result) + } + return false, fmt.Errorf("import filter function returned non-boolean type %T: %+v", result, result) } } diff --git a/db/import_listener.go b/db/import_listener.go index 72ef8a8734..7cb9142bcc 100644 --- a/db/import_listener.go +++ b/db/import_listener.go @@ -214,19 +214,7 @@ func (il *importListener) ImportFeedEvent(event sgbucket.FeedEvent) { func (il *importListener) Stop() { if il != nil { if il.cbgtContext != nil { - il.cbgtContext.StopHeartbeatListener() - - // Close open PIndexes before stopping the manager. - _, pindexes := il.cbgtContext.Manager.CurrentMaps() - for _, pIndex := range pindexes { - err := il.cbgtContext.Manager.ClosePIndex(pIndex) - if err != nil { - base.DebugfCtx(il.loggingCtx, base.KeyImport, "Error closing pindex: %v", err) - } - } - // ClosePIndex calls are synchronous, so can stop manager once they've completed - il.cbgtContext.Manager.Stop() - il.cbgtContext.RemoveFeedCredentials(il.dbName) + il.cbgtContext.Stop() // Remove entry from global listener directory base.RemoveDestFactory(il.importDestKey) diff --git a/db/import_test.go b/db/import_test.go index d41412d169..6cf2d35f78 100644 --- a/db/import_test.go +++ b/db/import_test.go @@ -20,6 +20,7 @@ import ( "github.com/stretchr/testify/require" sgbucket "github.com/couchbase/sg-bucket" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" "github.com/stretchr/testify/assert" ) @@ -439,51 +440,47 @@ func TestEvaluateFunction(t *testing.T) { db, ctx := setupTestDB(t) defer db.Close(ctx) + testImport := func(body Body, source string) (result bool, err error) { + js.TestWithVMPools(t, 4, func(t *testing.T, pool *js.VMPool) { + importFilterFunc := NewImportFilterFunction(pool, source, 0) + result, err = importFilterFunc(base.TestCtx(t), body) + }) + return + } + // Simulate unexpected error invoking import filter for document - body := Body{"key": "value", "version": "1a"} - source := "illegal function(doc) {}" - importFilterFunc := NewImportFilterFunction(source, 0) - result, err := importFilterFunc.EvaluateFunction(base.TestCtx(t), body) + result, err := testImport(Body{"key": "value", "version": "1a"}, + "illegal function(doc) {}") assert.Error(t, err, "Unexpected token function error") assert.False(t, result, "Function evaluation result should be false") // Simulate boolean return value from import filter function - body = Body{"key": "value", "version": "2a"} - source = `function(doc) { if (doc.version == "2a") { return true; } else { return false; }}` - importFilterFunc = NewImportFilterFunction(source, 0) - result, err = importFilterFunc.EvaluateFunction(base.TestCtx(t), body) + result, err = testImport(Body{"key": "value", "version": "2a"}, + `function(doc) { if (doc.version == "2a") { return true; } else { return false; }}`) assert.NoError(t, err, "Import filter function shouldn't throw any error") assert.True(t, result, "Import filter function should return boolean value true") // Simulate non-boolean return value from import filter function; default switch case - body = Body{"key": "value", "version": "2b"} - source = `function(doc) { if (doc.version == "2b") { return 1.01; } else { return 0.01; }}` - importFilterFunc = NewImportFilterFunction(source, 0) - result, err = importFilterFunc.EvaluateFunction(base.TestCtx(t), body) + result, err = testImport(Body{"key": "value", "version": "2b"}, + `function(doc) { if (doc.version == "2b") { return 1.01; } else { return 0.01; }}`) assert.Error(t, err, "Import filter function returned non-boolean value") assert.False(t, result, "Import filter function evaluation result should be false") // Simulate string return value true from import filter function - body = Body{"key": "value", "version": "1a"} - source = `function(doc) { if (doc.version == "1a") { return "true"; } else { return "false"; }}` - importFilterFunc = NewImportFilterFunction(source, 0) - result, err = importFilterFunc.EvaluateFunction(base.TestCtx(t), body) + result, err = testImport(Body{"key": "value", "version": "1a"}, + `function(doc) { if (doc.version == "1a") { return "true"; } else { return "false"; }}`) assert.NoError(t, err, "Import filter function shouldn't throw any error") assert.True(t, result, "Import filter function should return true") // Simulate string return value false from import filter function - body = Body{"key": "value", "version": "2a"} - source = `function(doc) { if (doc.version == "1a") { return "true"; } else { return "false"; }}` - importFilterFunc = NewImportFilterFunction(source, 0) - result, err = importFilterFunc.EvaluateFunction(base.TestCtx(t), body) + result, err = testImport(Body{"key": "value", "version": "2a"}, + `function(doc) { if (doc.version == "1a") { return "true"; } else { return "false"; }}`) assert.NoError(t, err, "Import filter function shouldn't throw any error") assert.False(t, result, "Import filter function should return false") // Simulate strconv.ParseBool: parsing "TruE": invalid syntax - body = Body{"key": "value", "version": "1a"} - source = `function(doc) { if (doc.version == "1a") { return "TruE"; } else { return "FaLsE"; }}` - importFilterFunc = NewImportFilterFunction(source, 0) - result, err = importFilterFunc.EvaluateFunction(base.TestCtx(t), body) + result, err = testImport(Body{"key": "value", "version": "1a"}, + `function(doc) { if (doc.version == "1a") { return "TruE"; } else { return "FaLsE"; }}`) assert.Error(t, err, `strconv.ParseBool: parsing "TruE": invalid syntax`) assert.False(t, result, "Import filter function should return true") } @@ -525,3 +522,37 @@ func TestImportStampClusterUUID(t *testing.T) { require.NoError(t, err) require.Equal(t, 32, len(xattr["cluster_uuid"])) } + +// TestImporNonZeroStart makes sure docs written before sync gateway start get imported +func TestImportNonZeroStart(t *testing.T) { + if base.UnitTestUrlIsWalrus() { + t.Skip("test requires import feed, which requies DCP") + } + + bucket := base.GetTestBucket(t) + + doc1 := "doc1" + revID1 := "1-2a9efe8178aa817f4414ae976aa032d9" + + _, err := bucket.GetSingleDataStore().Add(doc1, 0, rawDocNoMeta()) + require.NoError(t, err) + + db, ctx := setupTestDBWithOptionsAndImport(t, bucket, DatabaseContextOptions{}) + defer db.Close(ctx) + + collection := GetSingleDatabaseCollectionWithUser(t, db) + _, ok := base.WaitForStat(func() int64 { + return collection.collectionStats.ImportCount.Value() + }, 1) + require.True(t, ok) + + _, ok = base.WaitForStat(func() int64 { + return db.DbStats.Database().DCPReceivedCount.Value() + }, 1) + require.True(t, ok) + + doc, err := collection.GetDocument(base.TestCtx(t), doc1, DocUnmarshalAll) + require.NoError(t, err) + require.Equal(t, revID1, doc.SyncData.CurrentRev) + +} diff --git a/db/query_test.go b/db/query_test.go index 3666f0443a..b66f2a545c 100644 --- a/db/query_test.go +++ b/db/query_test.go @@ -34,7 +34,7 @@ func TestQueryChannelsStatsView(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) // docID -> Sequence docSeqMap := make(map[string]uint64, 3) @@ -91,7 +91,7 @@ func TestQueryChannelsStatsN1ql(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) // docID -> Sequence docSeqMap := make(map[string]uint64, 3) @@ -272,7 +272,7 @@ func TestAccessQuery(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper( + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, `function(doc, oldDoc) { access(doc.accessUser, doc.accessChannel) }`, @@ -321,7 +321,7 @@ func TestRoleAccessQuery(t *testing.T) { defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper( + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, `function(doc, oldDoc) { role(doc.accessUser, "role:" + doc.accessChannel) }`, db.Options.JavascriptTimeout) @@ -377,7 +377,7 @@ func TestQueryChannelsActiveOnlyWithLimit(t *testing.T) { db, ctx := setupTestDB(t) defer db.Close(ctx) collection := GetSingleDatabaseCollectionWithUser(t, db) - collection.ChannelMapper = channels.NewChannelMapper(channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) + collection.ChannelMapper = channels.NewChannelMapper(&db.JS, channels.DocChannelsSyncFunction, db.Options.JavascriptTimeout) docIdFlagMap := make(map[string]uint8) var startSeq, endSeq uint64 body := Body{"channels": []string{"ABC"}} diff --git a/db/revision_cache_interface.go b/db/revision_cache_interface.go index c3fc20aca4..2f82796b72 100644 --- a/db/revision_cache_interface.go +++ b/db/revision_cache_interface.go @@ -162,6 +162,9 @@ func (rev *DocumentRevision) Mutable1xBody(db *DatabaseCollectionWithUser, reque if err != nil { return nil, err } + if b == nil { + return nil, base.RedactErrorf("null doc body for docID: %s revID: %s", base.UD(rev.DocID), base.UD(rev.RevID)) + } b[BodyId] = rev.DocID b[BodyRev] = rev.RevID diff --git a/db/sg_replicate_cfg.go b/db/sg_replicate_cfg.go index 37164152fb..9214a7caad 100644 --- a/db/sg_replicate_cfg.go +++ b/db/sg_replicate_cfg.go @@ -606,10 +606,10 @@ func (m *sgReplicateManager) NewActiveReplicatorConfig(config *ReplicationCfg) ( // Set conflict resolver for pull replications if rc.Direction == ActiveReplicatorTypePull || rc.Direction == ActiveReplicatorTypePushAndPull { if config.ConflictResolutionType == "" { - rc.ConflictResolverFunc, err = NewConflictResolverFunc(ConflictResolverDefault, "", m.dbContext.Options.JavascriptTimeout) + rc.ConflictResolverFunc, err = NewConflictResolverFunc(m.dbContext, ConflictResolverDefault, "") } else { - rc.ConflictResolverFunc, err = NewConflictResolverFunc(config.ConflictResolutionType, config.ConflictResolutionFn, m.dbContext.Options.JavascriptTimeout) + rc.ConflictResolverFunc, err = NewConflictResolverFunc(m.dbContext, config.ConflictResolutionType, config.ConflictResolutionFn) rc.ConflictResolverFuncSrc = config.ConflictResolutionFn } if err != nil { diff --git a/db/sg_replicate_cfg_test.go b/db/sg_replicate_cfg_test.go index f758dcfe9a..b3c0e85f41 100644 --- a/db/sg_replicate_cfg_test.go +++ b/db/sg_replicate_cfg_test.go @@ -15,6 +15,7 @@ import ( "sync" "testing" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -646,12 +647,15 @@ func TestIsCfgChanged(t *testing.T) { testCfg, err := base.NewCfgSG(testBucket.GetSingleDataStore(), "") require.NoError(t, err) - mgr, err := NewSGReplicateManager(base.TestCtx(t), &DatabaseContext{Name: "test"}, testCfg) + ctx := base.TestCtx(t) + dbctx := DatabaseContext{Name: "test"} + dbctx.JS.Init(ctx, js.EngineNamed(DefaultJavaScriptEngine), 4) + mgr, err := NewSGReplicateManager(ctx, &dbctx, testCfg) require.NoError(t, err) defer mgr.Stop() for _, testCase := range testCases { - t.Run(fmt.Sprintf("%s", testCase.name), func(t *testing.T) { + t.Run(testCase.name, func(t *testing.T) { replicationCfg := getInitialCfg() replicatorConfig, err := mgr.NewActiveReplicatorConfig(replicationCfg) require.NoError(t, err) diff --git a/db/sg_replicate_conflict_resolver.go b/db/sg_replicate_conflict_resolver.go index 8305590eb9..3aa24d8c45 100644 --- a/db/sg_replicate_conflict_resolver.go +++ b/db/sg_replicate_conflict_resolver.go @@ -12,13 +12,13 @@ package db import ( "context" + _ "embed" "errors" "fmt" "time" - sgbucket "github.com/couchbase/sg-bucket" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/base" - "github.com/robertkrimen/otto" ) type ConflictResolverType string @@ -170,7 +170,9 @@ func RemoteWinsConflictResolver(conflict Conflict) (winner Body, err error) { return conflict.RemoteDocument, nil } -func NewConflictResolverFunc(resolverType ConflictResolverType, customResolverSource string, customResolverTimeout time.Duration) (ConflictResolverFunc, error) { +//////// CUSTOM CONFLICT RESOLVER: + +func NewConflictResolverFunc(dbc *DatabaseContext, resolverType ConflictResolverType, customResolverSource string) (ConflictResolverFunc, error) { switch resolverType { case ConflictResolverLocalWins: return LocalWinsConflictResolver, nil @@ -179,117 +181,66 @@ func NewConflictResolverFunc(resolverType ConflictResolverType, customResolverSo case ConflictResolverDefault: return DefaultConflictResolver, nil case ConflictResolverCustom: - return NewCustomConflictResolver(customResolverSource, customResolverTimeout) + return NewCustomConflictResolver(customResolverSource, dbc.Options.JavascriptTimeout, &dbc.JS) default: - return nil, fmt.Errorf("Unknown Conflict Resolver type: %s", resolverType) + return nil, fmt.Errorf("unknown Conflict Resolver type: %s", resolverType) } } // NewCustomConflictResolver returns a ConflictResolverFunc that executes the // javascript conflict resolver specified by source -func NewCustomConflictResolver(source string, timeout time.Duration) (ConflictResolverFunc, error) { - conflictResolverJSServer := NewConflictResolverJSServer(source, timeout) - return conflictResolverJSServer.EvaluateFunction, nil -} - -// ConflictResolverJSServer manages the compiled javascript function runner instance -type ConflictResolverJSServer struct { - *sgbucket.JSServer -} - -func NewConflictResolverJSServer(fnSource string, timeout time.Duration) *ConflictResolverJSServer { +func NewCustomConflictResolver(source string, timeout time.Duration, host js.ServiceHost) (ConflictResolverFunc, error) { base.DebugfCtx(context.Background(), base.KeyReplicate, "Creating new ConflictResolverFunction") - return &ConflictResolverJSServer{ - JSServer: sgbucket.NewJSServer(fnSource, timeout, kTaskCacheSize, newConflictResolverRunner), - } -} - -// EvaluateFunction executes the conflict resolver with the provided conflict and returns the result. -func (i *ConflictResolverJSServer) EvaluateFunction(conflict Conflict) (Body, error) { - docID, _ := conflict.LocalDocument[BodyId].(string) - localRevID, _ := conflict.LocalDocument[BodyRev].(string) - remoteRevID, _ := conflict.RemoteDocument[BodyRev].(string) - result, err := i.Call(conflict) - if err != nil { - base.WarnfCtx(context.Background(), "Unexpected error invoking conflict resolver for document %s, local/remote revisions %s/%s - processing aborted, document will not be replicated. Error: %v", - base.UD(docID), base.UD(localRevID), base.UD(remoteRevID), err) - return nil, err - } - - // A null value returned by the conflict resolver should be treated as a delete - if result == nil { - return Body{BodyDeleted: true}, nil - } - - switch result := result.(type) { - case Body: - return result, nil - case map[string]interface{}: - return result, nil - case error: - base.WarnfCtx(context.Background(), "conflictResolverRunner: "+result.Error()) - return nil, result - default: - base.WarnfCtx(context.Background(), "Custom conflict resolution function returned non-document result %v Type: %T", result, result) - return nil, errors.New("Custom conflict resolution function returned non-document value.") - } -} - -// Compiles a JavaScript event function to a conflictResolverRunner object. -func newConflictResolverRunner(funcSource string, timeout time.Duration) (sgbucket.JSServerTask, error) { - conflictResolverRunner := &sgbucket.JSRunner{} - err := conflictResolverRunner.InitWithLogging(funcSource, timeout, - func(s string) { - base.ErrorfCtx(context.Background(), base.KeyJavascript.String()+": ConflictResolver %s", base.UD(s)) - }, - func(s string) { - base.InfofCtx(context.Background(), base.KeyJavascript, "ConflictResolver %s", base.UD(s)) - }) - if err != nil { - return nil, err - } - - // Implementation of the 'defaultPolicy(conflict)' callback: - conflictResolverRunner.DefineNativeFunction("defaultPolicy", func(call otto.FunctionCall) otto.Value { - if len(call.ArgumentList) == 0 { - return ErrorToOttoValue(conflictResolverRunner, errors.New("No conflict parameter specified when calling defaultPolicy()")) - } - rawConflict, exportErr := call.Argument(0).Export() - if exportErr != nil { - return ErrorToOttoValue(conflictResolverRunner, fmt.Errorf("Unable to export conflict parameter for defaultPolicy(): %v Error: %s", call.Argument(0), exportErr)) + service := js.NewService(host, "conflict resolver", fmt.Sprintf(kConflictResolverJSCode, source)) + + return func(conflict Conflict) (Body, error) { + // Here's the ConflictResolverFunc: + ctx := context.Background() + if timeout > 0 { + var cancelFn context.CancelFunc + ctx, cancelFn = context.WithTimeout(ctx, timeout) + defer cancelFn() } - // Called defaultPolicy with null/undefined value - return - if rawConflict == nil || call.Argument(0).IsUndefined() { - return ErrorToOttoValue(conflictResolverRunner, errors.New("Null or undefined value passed to defaultPolicy()")) + if service.Host().Engine() == js.Otto { + // Otto exposes Go objects directly to JS, meaning that the resolver fn is capable of + // modifying the document maps. A conflict resolver isn't allowed to do that, so make + // deep copies of both docs before calling it. + conflict.LocalDocument = conflict.LocalDocument.DeepCopy() + conflict.RemoteDocument = conflict.RemoteDocument.DeepCopy() } - conflict, ok := rawConflict.(Conflict) - if !ok { - return ErrorToOttoValue(conflictResolverRunner, fmt.Errorf("Invalid value passed to defaultPolicy(). Value was type %T, expected type Conflict", rawConflict)) - } + result, err := service.Run(ctx, conflict) - defaultWinner, _ := DefaultConflictResolver(conflict) - ottoDefaultWinner, err := conflictResolverRunner.ToValue(defaultWinner) if err != nil { - return ErrorToOttoValue(conflictResolverRunner, fmt.Errorf("Error converting default winner to javascript value. Error:%w", err)) + // Warn if the resolver fn fails: + docID, _ := conflict.LocalDocument[BodyId].(string) + localRevID, _ := conflict.LocalDocument[BodyRev].(string) + remoteRevID, _ := conflict.RemoteDocument[BodyRev].(string) + base.WarnfCtx(context.Background(), "Unexpected error invoking conflict resolver for document %s, local/remote revisions %s/%s - processing aborted, document will not be replicated. Error: %+v", + base.UD(docID), base.UD(localRevID), base.UD(remoteRevID), err) + return nil, err } - return ottoDefaultWinner - }) - conflictResolverRunner.After = func(result otto.Value, err error) (interface{}, error) { - nativeValue, _ := result.Export() - return nativeValue, err - } + // A null value returned by the conflict resolver should be treated as a delete + if result == nil { + return Body{BodyDeleted: true}, nil + } - return conflictResolverRunner, nil + switch result := result.(type) { + case map[string]interface{}: + return result, nil + case Body: + return result, nil + case error: + base.WarnfCtx(context.Background(), "conflictResolverRunner: "+result.Error()) + return nil, result + default: + base.WarnfCtx(context.Background(), "Custom conflict resolution function returned non-document result %v Type: %T", result, result) + return nil, errors.New("custom conflict resolution function returned non-document value") + } + }, nil } -// Converts an error to an otto value, to support native functions returning errors. -func ErrorToOttoValue(runner *sgbucket.JSRunner, err error) otto.Value { - errorValue, convertErr := runner.ToValue(err) - if convertErr != nil { - base.WarnfCtx(context.Background(), "Unable to convert error to otto value: %v", convertErr) - } - return errorValue -} +//go:embed sg_replicate_conflict_resolver.js +var kConflictResolverJSCode string diff --git a/db/sg_replicate_conflict_resolver.js b/db/sg_replicate_conflict_resolver.js new file mode 100644 index 0000000000..21149914bb --- /dev/null +++ b/db/sg_replicate_conflict_resolver.js @@ -0,0 +1,38 @@ +function() { var conflictResolver = %s; + +// Copyright 2012-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. + + function defaultPolicy(conflict) { + function chk(obj) { + if (!obj || typeof(obj) !== "object") + throw "defaultPolicy() called with invalid conflict object"; + return obj; + } + + // Based on the Go function DefaultConflictResolver() + chk(conflict); + var local = chk(conflict.LocalDocument); + var remote = chk(conflict.RemoteDocument); + var localDeleted = local._deleted; + var remoteDeleted = remote._deleted; + if (localDeleted && !remoteDeleted) return local; + if (remoteDeleted && !localDeleted) return remote; + + var rev1 = local._rev.split('-', 2); + var rev2 = remote._rev.split('-', 2); + var gen1 = Number(rev1[0]); + var gen2 = Number(rev2[0]); + if (gen1 < gen2 || (gen1 == gen2 && rev1[1] < rev2[1])) + return remote; + else + return local; + } + + return conflictResolver; +}() diff --git a/db/sg_replicate_conflict_resolver_test.go b/db/sg_replicate_conflict_resolver_test.go index a74f9cfb23..c786fb0a6f 100644 --- a/db/sg_replicate_conflict_resolver_test.go +++ b/db/sg_replicate_conflict_resolver_test.go @@ -13,6 +13,7 @@ package db import ( "testing" + "github.com/couchbase/sg-bucket/js" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) @@ -96,7 +97,7 @@ func TestCustomConflictResolver(t *testing.T) { }, { name: "merge", - resolverSource: `function(conflict) { + resolverSource: `function(conflict) { var mergedDoc = new Object(); mergedDoc.prop = conflict.LocalDocument.prop + conflict.RemoteDocument.prop; return mergedDoc; @@ -107,16 +108,43 @@ func TestCustomConflictResolver(t *testing.T) { }, { name: "mergeDelete", - resolverSource: `function(conflict) { + resolverSource: `function(conflict) { return null; }`, localDocument: Body{"_rev": "2-abc", "prop": "foo"}, remoteDocument: Body{"_rev": "1-abc", "prop": "bar"}, expectedWinner: Body{BodyDeleted: true}, }, + { + name: "invokeDefault local wins", + resolverSource: `function(conflict) { + return defaultPolicy(conflict); + }`, + localDocument: Body{"_rev": "2-abc", "prop": "foo"}, + remoteDocument: Body{"_rev": "1-def", "prop": "bar"}, + expectedWinner: Body{"_rev": "2-abc", "prop": "foo"}, + }, + { + name: "invokeDefault local wins again", + resolverSource: `function(conflict) { + return defaultPolicy(conflict); + }`, + localDocument: Body{"_rev": "2-abc", "prop": "foo"}, + remoteDocument: Body{"_rev": "2-abb", "prop": "bar"}, + expectedWinner: Body{"_rev": "2-abc", "prop": "foo"}, + }, + { + name: "invokeDefault remote wins", + resolverSource: `function(conflict) { + return defaultPolicy(conflict); + }`, + localDocument: Body{"_rev": "9-xyz", "prop": "foo"}, + remoteDocument: Body{"_rev": "10-abc", "prop": "bar"}, + expectedWinner: Body{"_rev": "10-abc", "prop": "bar"}, + }, { name: "invokeDefault", - resolverSource: `function(conflict) { + resolverSource: `function(conflict) { return defaultPolicy(conflict); }`, localDocument: Body{"_rev": "2-abc", "prop": "foo"}, @@ -125,7 +153,7 @@ func TestCustomConflictResolver(t *testing.T) { }, { name: "invokeDefaultWithInvalidValue", - resolverSource: `function(conflict) { + resolverSource: `function(conflict) { return defaultPolicy(conflict.LocalDocument); }`, localDocument: Body{"_rev": "2-abc", "prop": "foo"}, @@ -134,7 +162,7 @@ func TestCustomConflictResolver(t *testing.T) { }, { name: "invokeDefaultWithNoValue", - resolverSource: `function(conflict) { + resolverSource: `function(conflict) { return defaultPolicy(); }`, localDocument: Body{"_rev": "2-abc", "prop": "foo"}, @@ -143,7 +171,7 @@ func TestCustomConflictResolver(t *testing.T) { }, { name: "invokeDefaultWithNullValue", - resolverSource: `function(conflict) { + resolverSource: `function(conflict) { return defaultPolicy(null); }`, localDocument: Body{"_rev": "2-abc", "prop": "foo"}, @@ -154,19 +182,21 @@ func TestCustomConflictResolver(t *testing.T) { for _, test := range defaultConflictResolverTests { t.Run(test.name, func(tt *testing.T) { - conflict := Conflict{ - LocalDocument: test.localDocument, - RemoteDocument: test.remoteDocument, - } - customConflictResolverFunc, err := NewCustomConflictResolver(test.resolverSource, 0) - require.NoError(tt, err) - result, err := customConflictResolverFunc(conflict) - if test.expectError { - assert.Error(t, err) - return - } - assert.NoError(tt, err) - assert.Equal(tt, test.expectedWinner, result) + js.TestWithVMPools(tt, 4, func(ttt *testing.T, pool *js.VMPool) { + conflict := Conflict{ + LocalDocument: test.localDocument, + RemoteDocument: test.remoteDocument, + } + customConflictResolverFunc, err := NewCustomConflictResolver(test.resolverSource, 0, pool) + require.NoError(ttt, err) + result, err := customConflictResolverFunc(conflict) + if test.expectError { + assert.Error(ttt, err) + return + } + assert.NoError(ttt, err) + assert.Equal(ttt, test.expectedWinner, result) + }) }) } } diff --git a/db/util_testing.go b/db/util_testing.go index 67433123c8..63f6814d08 100644 --- a/db/util_testing.go +++ b/db/util_testing.go @@ -95,6 +95,17 @@ func (db *DatabaseContext) WaitForCaughtUp(targetCount int64) error { return errors.New("WaitForCaughtUp didn't catch up") } +func (db *DatabaseContext) WaitForTotalCaughtUp(targetCount int64) error { + for i := 0; i < 100; i++ { + caughtUpCount := db.DbStats.CBLReplicationPull().NumPullReplTotalCaughtUp.Value() + if caughtUpCount >= targetCount { + return nil + } + time.Sleep(100 * time.Millisecond) + } + return errors.New("WaitForCaughtUp didn't catch up") +} + type StatWaiter struct { initCount int64 // Document cached count when NewStatWaiter is called targetCount int64 // Target count used when Wait is called @@ -598,3 +609,13 @@ func GetSingleDatabaseCollection(tb testing.TB, database *DatabaseContext) *Data tb.Fatalf("Could not find a collection") return nil } + +// AllocateTestSequence allocates a sequence via the sequenceAllocator. For use by non-db tests +func AllocateTestSequence(database *DatabaseContext) (uint64, error) { + return database.sequences.incrementSequence(1) +} + +// ReleaseTestSequence releases a sequence via the sequenceAllocator. For use by non-db tests +func ReleaseTestSequence(database *DatabaseContext, sequence uint64) error { + return database.sequences.releaseSequence(sequence) +} diff --git a/db/validation.go b/db/validation.go index 2b991a6ec4..0feeaaceca 100644 --- a/db/validation.go +++ b/db/validation.go @@ -59,7 +59,7 @@ func validateImportBody(body Body) error { } // Prevent disallowed internal properties from being used - disallowed := []string{BodyId, BodyRev, BodyExpiry, BodyRevisions} + disallowed := []string{BodyId, BodyRev, BodyExpiry, BodyRevisions, BodyPurged} for _, prop := range disallowed { if _, ok := body[prop]; ok { return base.HTTPErrorf(http.StatusBadRequest, "top-level property '"+prop+"' is a reserved internal property therefore cannot be imported") diff --git a/docs/api/components/schemas.yaml b/docs/api/components/schemas.yaml index 40a4ac5cd4..400a6a31f0 100644 --- a/docs/api/components/schemas.yaml +++ b/docs/api/components/schemas.yaml @@ -242,9 +242,11 @@ User: description: A set of access grants by scope and collection. type: object additionalProperties: + x-additionalPropertiesName: scopename description: An object keyed by scope, containing a set of collections. type: object additionalProperties: + x-additionalPropertiesName: collectionname $ref: '#/CollectionAccessConfig' email: description: The email address of the user. @@ -345,9 +347,11 @@ Role: description: A set of access grants by scope and collection. type: object additionalProperties: + x-additionalPropertiesName: scopename description: An object keyed by scope, containing a set of collections. type: object additionalProperties: + x-additionalPropertiesName: collectionname $ref: '#/CollectionAccessConfig' title: Role User-session-information: @@ -465,6 +469,7 @@ Document: _attachments: type: object additionalProperties: + x-additionalPropertiesName: attachmentname description: The name of the attachment. type: object properties: @@ -529,15 +534,15 @@ Design-doc: type: string views: type: object - properties: - additionalProperties: - description: The name of the view. - type: object - properties: - map: - type: string - reduce: - type: string + additionalProperties: + x-additionalPropertiesName: viewname + description: The name of the view. + type: object + properties: + map: + type: string + reduce: + type: string options: type: object properties: @@ -1078,19 +1083,24 @@ Replication-status: - replication_id title: Replication-status Scopes: - description: A map of all the collections with their corresponding configs for this scope + description: Scope-specific configuration. type: object - additionalProperties: - $ref: '#/CollectionConfig' + properties: + collections: + description: An object keyed by collection name containing config for the specific collection. + type: object + additionalProperties: + x-additionalPropertiesName: collectionname + $ref: '#/CollectionConfig' title: Scopes CollectionConfig: - description: The configuration for the individual collection + description: Collection-specific configuration. type: object properties: sync: description: The Javascript function that newly created documents in this collection are ran through. type: string - example: 'function(doc){channel(doc.channels);}' + example: 'function(doc){channel("collection name");}' import_filter: description: |- This is the function that all imported documents in this collection are ran through in order to filter out what to import and what not to import. This allows you to control what is made available to Couchbase Mobile clients. If it is not set, then no documents are filtered when imported. @@ -1156,23 +1166,27 @@ Database: type: integer default: 1000 scopes: - description: Scope and collection specific config. + description: An object keyed by scope name containing config for the specific collection. type: object - properties: - additionalProperties: - $ref: '#/Scopes' + additionalProperties: + x-additionalPropertiesName: scopename + $ref: '#/Scopes' name: description: The name of the database. type: string sync: - description: The Javascript function that newly created documents are ran through for the _default scope and collection. + description: The Javascript function that newly created documents are ran through for the default scope and collection. + + If `scopes` parameter is set, this is ignored. type: string default: 'function(doc){channel(doc.channels);}' users: additionalProperties: + x-additionalPropertiesName: username $ref: '#/User' roles: additionalProperties: + x-additionalPropertiesName: rolename $ref: '#/Role' revs_limit: description: |- @@ -1203,9 +1217,11 @@ Database: default: 16 import_filter: description: |- - This is the function that all imported documents in the _default scope and collection are ran through in order to filter out what to import and what not to import. This allows you to control what is made available to Couchbase Mobile clients. If it is not set, then no documents are filtered when imported. + This is the function that all imported documents in the default scope and collection are ran through in order to filter out what to import and what not to import. This allows you to control what is made available to Couchbase Mobile clients. If it is not set, then no documents are filtered when imported. `import_docs` must be true to make this field applicable. + + If `scopes` parameter is set, this is ignored. type: string example: 'function(doc) { if (doc.type != ''mobile'') { return false; } return true; }' import_backup_old_rev: @@ -1231,8 +1247,8 @@ Database: type: string default: DCP enum: - - TAP - DCP + - TAP deprecated: true allow_empty_password: description: This controls whether users that are created can have an empty password or not. @@ -1443,6 +1459,7 @@ Database: description: Configuration for Local JWT authentication. type: object additionalProperties: + x-additionalPropertiesName: providername description: The providers name. type: object required: ['issuer', 'client_id', 'algorithms', 'keys'] @@ -1529,6 +1546,7 @@ Database: description: List of OpenID Connect issuers. type: object additionalProperties: + x-additionalPropertiesName: providername description: The providers name. type: object properties: @@ -1784,9 +1802,8 @@ Event-config: options: description: The options for the event. type: object - properties: - additionalProperties: - description: The option key and value. + additionalProperties: + description: The option key and value. title: Event-config Resync-status: description: The status of a resync operation @@ -2112,6 +2129,9 @@ Startup-config: type: integer maximum: 9 minimum: 0 + max_concurrent_replications: + description: Maximum number of concurrent replication connections allowed. If set to 0 this limit will be ignored. + type: integer readOnly: true unsupported: description: Settings that are not officially supported. It is highly recommended these are **not** used. @@ -2143,12 +2163,14 @@ Startup-config: description: 'A map of database name to credentials, that can be used instead of the bootstrap ones.' type: object additionalProperties: + x-additionalPropertiesName: databasename $ref: '#/CredentialsConfig' readOnly: true bucket_credentials: description: 'A map of bucket names to credentials, that can be used instead of the bootstrap ones.' type: object additionalProperties: + x-additionalPropertiesName: bucketname $ref: '#/CredentialsConfig' readOnly: true max_file_descriptors: @@ -2162,6 +2184,46 @@ Startup-config: type: integer readOnly: true title: Startup-config +Runtime-config: + type: object + properties: + logging: + description: The configuration settings for modifying Sync Gateway logging. + type: object + properties: + log_file_path: + description: Absolute or relative path on the filesystem to the log file directory. A relative path is from the directory that contains the Sync Gateway executable file. + type: string + readOnly: true + redaction_level: + description: Redaction level to apply to log output. + type: string + default: partial + enum: + - none + - partial + - full + - unset + readOnly: true + console: + $ref: '#/Console-logging-config' + error: + $ref: '#/File-logging-config' + warn: + $ref: '#/File-logging-config' + info: + $ref: '#/File-logging-config' + debug: + $ref: '#/File-logging-config' + trace: + $ref: '#/File-logging-config' + stats: + $ref: '#/File-logging-config' + max_concurrent_replications: + description: Maximum number of concurrent replication connections allowed. If set to 0 this limit will be ignored. + type: integer + default: 0 + title: Runtime-config File-logging-config: type: object properties: diff --git a/docs/api/paths/admin/_config.yaml b/docs/api/paths/admin/_config.yaml index 28dd1a84aa..0bc789a2a8 100644 --- a/docs/api/paths/admin/_config.yaml +++ b/docs/api/paths/admin/_config.yaml @@ -49,7 +49,7 @@ put: content: application/json: schema: - $ref: ../../components/schemas.yaml#/Startup-config + $ref: ../../components/schemas.yaml#/Runtime-config responses: '200': description: Successfully set runtime options diff --git a/docs/api/paths/admin/_post_upgrade.yaml b/docs/api/paths/admin/_post_upgrade.yaml index cb803eec47..9f4c23b3ea 100644 --- a/docs/api/paths/admin/_post_upgrade.yaml +++ b/docs/api/paths/admin/_post_upgrade.yaml @@ -32,6 +32,7 @@ post: description: A map of databases. type: object additionalProperties: + x-additionalPropertiesName: db description: The name of the database that was targetted. type: object properties: diff --git a/docs/api/paths/admin/keyspace-_changes.yaml b/docs/api/paths/admin/keyspace-_changes.yaml index 2ddb95633a..1c3819be88 100644 --- a/docs/api/paths/admin/keyspace-_changes.yaml +++ b/docs/api/paths/admin/keyspace-_changes.yaml @@ -96,6 +96,13 @@ get: - longpoll - continuous - websocket + + - name: request_plus + in: query + description: When true, ensures all valid documents written prior to the request being issued are included in the response. This is only applicable for non-continuous feeds. + schema: + type: boolean + default: 'false' responses: '200': $ref: ../../components/responses.yaml#/changes-feed @@ -156,6 +163,9 @@ post: feed: description: 'The type of changes feed to use. ' type: string + request_plus: + description: 'When true, ensures all valid documents written prior to the request being issued are included in the response. This is only applicable for non-continuous feeds.' + type: string responses: '200': $ref: ../../components/responses.yaml#/changes-feed diff --git a/examples/database_config/collections-with-custom-scope.json b/examples/database_config/collections-with-custom-scope.json new file mode 100644 index 0000000000..5d7a6c4bb6 --- /dev/null +++ b/examples/database_config/collections-with-custom-scope.json @@ -0,0 +1,38 @@ +{ + "name": "db", + "bucket": "bucket", + "scopes" : { + "scope1": { + "collections": { + "collection1" : { + "sync": ` + function(doc, oldDoc, meta) { + if (doc.type != "default") { + throw({forbidden : "Rejected document"}) + } + channel("legacy") + } + `, + "import_filter": ` + function(doc) { + return doc.type == "mobile" + } + ` + }, + "collection2" : { + "sync": ` + function(doc, oldDoc, meta) { + channel("collection1") + } + `, + "import_filter": ` + function(doc) { + return doc.type == "mobile" + } + ` + } + } + } + }, + "num_index_replicas": 0 +} diff --git a/examples/database_config/collections-with-default-collection.json b/examples/database_config/collections-with-default-collection.json new file mode 100644 index 0000000000..907b1f659f --- /dev/null +++ b/examples/database_config/collections-with-default-collection.json @@ -0,0 +1,38 @@ +{ + "name": "db", + "bucket": "bucket", + "scopes" : { + "_default": { + "collections": { + "_default" : { + "sync": ` + function(doc, oldDoc, meta) { + if (doc.collection != "default") { + throw({forbidden : "Rejected document"}) + } + channel("legacy") + } + `, + "import_filter": ` + function(doc) { + return doc.type == "mobile" + } + ` + }, + "collection1" : { + "sync": ` + function(doc, oldDoc, meta) { + channel("collection1") + } + `, + "import_filter": ` + function(doc) { + return doc.type == "mobile" + } + ` + } + } + } + }, + "num_index_replicas": 0 +} diff --git a/go.mod b/go.mod index 4aac998a8c..d7ae2fd989 100644 --- a/go.mod +++ b/go.mod @@ -3,50 +3,46 @@ module github.com/couchbase/sync_gateway go 1.19 require ( - github.com/bhoriuchi/graphql-go-tools v1.0.0 github.com/coreos/go-oidc v2.2.1+incompatible - github.com/couchbase/cbgt v1.3.2-0.20230405201040-c0ede9925e46 + github.com/couchbase/cbgt v1.3.4 github.com/couchbase/clog v0.1.0 - github.com/couchbase/go-blip v0.0.0-20221021161139-215cbac22bd7 + github.com/couchbase/go-blip v0.0.0-20230510201532-fcadc404bd41 github.com/couchbase/go-couchbase v0.1.1 github.com/couchbase/gocb/v2 v2.6.2 - github.com/couchbase/gocbcore/v10 v10.2.3-0.20230412164057-d9c465de8911 - github.com/couchbase/gomemcached v0.1.4 + github.com/couchbase/gocbcore/v10 v10.2.4-0.20230511103754-8dd1a95f5f33 + github.com/couchbase/gomemcached v0.2.1 github.com/couchbase/goutils v0.1.2 - github.com/couchbase/sg-bucket v0.0.0-20230113211151-ac6a75f57046 + github.com/couchbase/sg-bucket v0.0.0-20230711212925-3779b871a912 + github.com/couchbasedeps/v8go v1.7.5-0.20230711212500-516f3127f59a github.com/couchbaselabs/go-fleecedelta v0.0.0-20200408160354-2ed3f45fde8f github.com/couchbaselabs/walrus v0.0.0-20230118190455-97ce18d0c47d github.com/elastic/gosigar v0.14.2 github.com/felixge/fgprof v0.9.2 github.com/google/uuid v1.3.0 github.com/gorilla/mux v1.8.0 - github.com/graphql-go/graphql v0.8.0 github.com/imdario/mergo v0.3.12 github.com/json-iterator/go v1.1.12 github.com/kardianos/service v1.2.1 github.com/natefinch/lumberjack v2.0.0+incompatible github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.11.1 - github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f github.com/samuel/go-metrics v0.0.0-20150819231912-7ccf3e0e1fb1 github.com/shirou/gopsutil v3.21.11+incompatible github.com/stretchr/testify v1.8.2 - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa + golang.org/x/crypto v0.7.0 golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e - golang.org/x/net v0.0.0-20220919232410-f2f64ebce3c1 + golang.org/x/net v0.8.0 golang.org/x/oauth2 v0.0.0-20220718184931-c8730f7fcb92 gopkg.in/couchbaselabs/gocbconnstr.v1 v1.0.4 gopkg.in/square/go-jose.v2 v2.6.0 ) -replace github.com/graphql-go/graphql v0.8.0 => github.com/couchbasedeps/graphql-go v0.8.1 - require ( github.com/aws/aws-sdk-go v1.44.77 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect github.com/couchbase/blance v0.1.3 // indirect - github.com/couchbase/cbauth v0.1.9 // indirect + github.com/couchbase/cbauth v0.1.10 // indirect github.com/couchbase/tools-common v0.0.0-20220810163003-4c3c185822d4 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-ole/go-ole v1.2.6 // indirect @@ -64,12 +60,13 @@ require ( github.com/prometheus/common v0.32.1 // indirect github.com/prometheus/procfs v0.7.3 // indirect github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect + github.com/robertkrimen/otto v0.0.0-20211024170158-b87d35c0b86f // indirect github.com/sergi/go-diff v1.2.0 // indirect github.com/stretchr/objx v0.5.0 // indirect github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a // indirect github.com/yusufpapurcu/wmi v1.2.2 // indirect - golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect - golang.org/x/text v0.4.0 // indirect + golang.org/x/sys v0.6.0 // indirect + golang.org/x/text v0.8.0 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.28.0 // indirect gopkg.in/couchbase/gocb.v1 v1.6.7 // indirect diff --git a/go.sum b/go.sum index e41f8d6a7c..d72d2f9513 100644 --- a/go.sum +++ b/go.sum @@ -48,8 +48,6 @@ github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24 github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bhoriuchi/graphql-go-tools v1.0.0 h1:viibVf33DxOzyIgO1elJHCcoVbGwlU3Ua8Mc3phsvKU= -github.com/bhoriuchi/graphql-go-tools v1.0.0/go.mod h1:4HQhkpeopRlpAn7DDBseb/Cw+7w+7D2psWAxDuTDkIY= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= @@ -63,31 +61,31 @@ github.com/coreos/go-oidc v2.2.1+incompatible h1:mh48q/BqXqgjVHpy2ZY7WnWAbenxRjs github.com/coreos/go-oidc v2.2.1+incompatible/go.mod h1:CgnwVTmzoESiwO9qyAFEMiHoZ1nMCKZlZ9V6mm3/LKc= github.com/couchbase/blance v0.1.3 h1:CJCirD3+N02Z0w/ybZTqqSJa9XMbsCZO9jHxCEAPQqE= github.com/couchbase/blance v0.1.3/go.mod h1:2Sa/nsJSieN/r3T9LsrUYWeQ015qDsuHybhz4F4JcHU= -github.com/couchbase/cbauth v0.1.9 h1:eco/KAIyEIeLNcEXFG6BTsCLPTVAI28lu9FH91ehvM4= -github.com/couchbase/cbauth v0.1.9/go.mod h1:overPK2NvYkkZBWX0eqmuHB82nhhs8rt7A4wi5u7c2g= -github.com/couchbase/cbgt v1.3.2-0.20230405201040-c0ede9925e46 h1:tRxeXfSHBzAq6mtc9NCXLy+BfI3SFMdQZFH3rYarw5M= -github.com/couchbase/cbgt v1.3.2-0.20230405201040-c0ede9925e46/go.mod h1:tJF3TUUO3ZDBU15auN1gNsIVY3Oo+jj46zIXH4RBxk4= +github.com/couchbase/cbauth v0.1.10 h1:ixJGG9mAgL1HnWKt2eKmJ8gJa0rkaUURtDPDak7Dcts= +github.com/couchbase/cbauth v0.1.10/go.mod h1:YHG+5rUI6GoLLlIViT9IfD0nwqEebBcl66TQ4pDFDw4= +github.com/couchbase/cbgt v1.3.4 h1:T5Wi4TOxRRYSYyhgl9R5mwxpQ8wo7pwTkzbomj9dBVM= +github.com/couchbase/cbgt v1.3.4/go.mod h1:PIJ8U/25mrhsn4Dc3eK9iLXZ98jX1i2YuGH2Od+JVv4= github.com/couchbase/clog v0.1.0 h1:4Kh/YHkhRjMCbdQuvRVsm39XZh4FtL1d8fAwJsHrEPY= github.com/couchbase/clog v0.1.0/go.mod h1:7tzUpEOsE+fgU81yfcjy5N1H6XtbVC8SgOz/3mCjmd4= -github.com/couchbase/go-blip v0.0.0-20221021161139-215cbac22bd7 h1:/GTlMVovmGKrFAl5e7u9CXuhjTlR5a4911Ujou18Q4Q= -github.com/couchbase/go-blip v0.0.0-20221021161139-215cbac22bd7/go.mod h1:nSpldGTqAhTOaDDL0Li2dSE0smqbISKagT7fIqYIRec= +github.com/couchbase/go-blip v0.0.0-20230510201532-fcadc404bd41 h1:pjBwvGjhloggITOU9Fqg4yQ/lbZJUHnz8OsYUUczQDw= +github.com/couchbase/go-blip v0.0.0-20230510201532-fcadc404bd41/go.mod h1:nSpldGTqAhTOaDDL0Li2dSE0smqbISKagT7fIqYIRec= github.com/couchbase/go-couchbase v0.1.1 h1:ClFXELcKj/ojyoTYbsY34QUrrYCBi/1G749sXSCkdhk= github.com/couchbase/go-couchbase v0.1.1/go.mod h1:+/bddYDxXsf9qt0xpDUtRR47A2GjaXmGGAqQ/k3GJ8A= github.com/couchbase/gocb/v2 v2.6.2 h1:sZg0+3GiYW7OT53ENEGnkkQMXhVuJ1qOJplvZDlM5Xk= github.com/couchbase/gocb/v2 v2.6.2/go.mod h1:baRw5pIpzHil7q39M2zm+bon+ZgjgNAilkKI813zPiE= github.com/couchbase/gocbcore/v10 v10.2.2/go.mod h1:lYQIIk+tzoMcwtwU5GzPbDdqEkwkH3isI2rkSpfL0oM= -github.com/couchbase/gocbcore/v10 v10.2.3-0.20230412164057-d9c465de8911 h1:w9pxVkd0o0Fzk6QgtZGaPj1g9Bt7sNO1eLm2rIteQTA= -github.com/couchbase/gocbcore/v10 v10.2.3-0.20230412164057-d9c465de8911/go.mod h1:lYQIIk+tzoMcwtwU5GzPbDdqEkwkH3isI2rkSpfL0oM= -github.com/couchbase/gomemcached v0.1.4 h1:5n5wmr4dBu+X7XteP8QHP5S9inK9MBjNpN9b7WSQfuA= -github.com/couchbase/gomemcached v0.1.4/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo= +github.com/couchbase/gocbcore/v10 v10.2.4-0.20230511103754-8dd1a95f5f33 h1:l6O5889o5cJBwWt1gws5q5dzi/slDba/KvGNiWY9ieQ= +github.com/couchbase/gocbcore/v10 v10.2.4-0.20230511103754-8dd1a95f5f33/go.mod h1:lYQIIk+tzoMcwtwU5GzPbDdqEkwkH3isI2rkSpfL0oM= +github.com/couchbase/gomemcached v0.2.1 h1:lDONROGbklo8pOt4Sr4eV436PVEaKDr3o9gUlhv9I2U= +github.com/couchbase/gomemcached v0.2.1/go.mod h1:mxliKQxOv84gQ0bJWbI+w9Wxdpt9HjDvgW9MjCym5Vo= github.com/couchbase/goutils v0.1.2 h1:gWr8B6XNWPIhfalHNog3qQKfGiYyh4K4VhO3P2o9BCs= github.com/couchbase/goutils v0.1.2/go.mod h1:h89Ek/tiOxxqjz30nPPlwZdQbdB8BwgnuBxeoUe/ViE= -github.com/couchbase/sg-bucket v0.0.0-20230113211151-ac6a75f57046 h1:fyGdhMTONSnC9Sqhc0f9KXhT5Pmpst7obe3Tg92xQsk= -github.com/couchbase/sg-bucket v0.0.0-20230113211151-ac6a75f57046/go.mod h1:1LT+86k2vAk/puiscgWjGJYAaKxkHUjLg30eG6hzo+k= +github.com/couchbase/sg-bucket v0.0.0-20230711212925-3779b871a912 h1:zN5Ma98kV3Wo1hrkuypdHhxhSDu2d/eNj1gu3IBgGo4= +github.com/couchbase/sg-bucket v0.0.0-20230711212925-3779b871a912/go.mod h1:CXPMAE15hLVqPTjWdRyf8OMvAe/U83BiAOrEmpl+Aqg= github.com/couchbase/tools-common v0.0.0-20220810163003-4c3c185822d4 h1:Ub0gZWccoNL+ag59v8S23tbHDknfN1l3CVl7Kb+hFO0= github.com/couchbase/tools-common v0.0.0-20220810163003-4c3c185822d4/go.mod h1:lW0Em1mo5xqQ0mRMzJlg013/6ruyISupTfW7nbLaa1E= -github.com/couchbasedeps/graphql-go v0.8.1 h1:NpkpNePwszaRWK82vfCPDt86GT+vkhjZ9ot+X5rSAME= -github.com/couchbasedeps/graphql-go v0.8.1/go.mod h1:lUEkYy/kBLxIVYXYmURoaibTxkW/FAhWiZu+5rDzF8E= +github.com/couchbasedeps/v8go v1.7.5-0.20230711212500-516f3127f59a h1:eAnRt+HIzIEN9wOjtIdVcWxKl87gWwRMqUErcmu92Eo= +github.com/couchbasedeps/v8go v1.7.5-0.20230711212500-516f3127f59a/go.mod h1:idYCHzuZs5u+Yv9mYwhOBheFP82+7arI2Y8xVeU2Ttk= github.com/couchbaselabs/go-fleecedelta v0.0.0-20200408160354-2ed3f45fde8f h1:al5DxXEBAUmINnP5dR950gL47424WzncuRpNdg0TWR0= github.com/couchbaselabs/go-fleecedelta v0.0.0-20200408160354-2ed3f45fde8f/go.mod h1:daOs69VstinwoALl3wwWxjBf1nD4lIe3wwYhKHKDapY= github.com/couchbaselabs/gocaves/client v0.0.0-20230307083111-cc3960c624b1 h1:H7OK4q4WsDxqNIB/Ba8BQBXBHFilZnyItHrLr3qmsKA= @@ -196,9 +194,8 @@ github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+ github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM= github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= -github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -333,8 +330,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200302210943-78000ba7a073/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.7.0 h1:AvwMYaRytfdeVt3u6mLaxYtErKYjxA2OXjJ1HHq6t3A= +golang.org/x/crypto v0.7.0/go.mod h1:pYwdfH91IfpZVANVyUOhSIPZaFoJGxTFbZhFTx+dXZU= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -397,8 +394,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220919232410-f2f64ebce3c1 h1:TWZxd/th7FbRSMret2MVQdlI8uT49QEtwZdvJrxjEHU= -golang.org/x/net v0.0.0-20220919232410-f2f64ebce3c1/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= +golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= +golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -459,8 +456,8 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 h1:WIoqL4EROvwiPdUtaip4VcDdpZ4kha7wBWZrbVKCIZg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -470,8 +467,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= +golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/jenkins-integration-build.sh b/jenkins-integration-build.sh index 509d0f52ee..c49a6366dd 100755 --- a/jenkins-integration-build.sh +++ b/jenkins-integration-build.sh @@ -22,6 +22,7 @@ if [ "${1:-}" == "-m" ]; then DETECT_RACES="false" SG_EDITION="EE" XATTRS="true" + SG_V8="false" RUN_COUNT="1" # CBS server settings COUCHBASE_SERVER_PROTOCOL="couchbase" @@ -112,9 +113,15 @@ if [ "${SG_TEST_PROFILE_FREQUENCY:-}" == "true" ]; then export SG_TEST_PROFILE_FREQUENCY=${SG_TEST_PROFILE_FREQUENCY} fi +if [ "${SG_V8:-}" == "true" ]; then + BUILD_TAGS="-tags cb_sg_v8," +else + BUILD_TAGS="-tags " +fi + if [ "${RUN_WALRUS}" == "true" ]; then # EE - go test -coverprofile=coverage_walrus_ee.out -coverpkg=github.com/couchbase/sync_gateway/... -tags cb_sg_enterprise $GO_TEST_FLAGS github.com/couchbase/sync_gateway/${TARGET_PACKAGE} > verbose_unit_ee.out.raw 2>&1 | true + go test -coverprofile=coverage_walrus_ee.out -coverpkg=github.com/couchbase/sync_gateway/... ${BUILD_TAGS}cb_sg_enterprise $GO_TEST_FLAGS github.com/couchbase/sync_gateway/${TARGET_PACKAGE} > verbose_unit_ee.out.raw 2>&1 | true # CE go test -coverprofile=coverage_walrus_ce.out -coverpkg=github.com/couchbase/sync_gateway/... $GO_TEST_FLAGS github.com/couchbase/sync_gateway/${TARGET_PACKAGE} > verbose_unit_ce.out.raw 2>&1 | true fi @@ -139,7 +146,7 @@ export SG_TEST_BUCKET_POOL_DEBUG=${SG_TEST_BUCKET_POOL_DEBUG} export SG_TEST_TLS_SKIP_VERIFY=${TLS_SKIP_VERIFY} if [ "${SG_EDITION}" == "EE" ]; then - GO_TEST_FLAGS="${GO_TEST_FLAGS} -tags cb_sg_enterprise" + GO_TEST_FLAGS="${GO_TEST_FLAGS} ${BUILD_TAGS}cb_sg_enterprise" fi go test ${GO_TEST_FLAGS} -coverprofile=coverage_int.out -coverpkg=github.com/couchbase/sync_gateway/... github.com/couchbase/sync_gateway/${TARGET_PACKAGE} 2>&1 | stdbuf -oL tee "${INT_LOG_FILE_NAME}.out.raw" | stdbuf -oL grep -a -E '(--- (FAIL|PASS|SKIP):|github.com/couchbase/sync_gateway(/.+)?\t|TEST: |panic: )' @@ -149,7 +156,7 @@ if [ "${PIPESTATUS[0]}" -ne "0" ]; then # If test exit code is not 0 (failed) fi # Collect CBS logs if server error occurred -if [ "${SG_CBCOLLECT_ALWAYS:-}" == "true" ] || grep -a -q "server logs for details\|Timed out after 1m0s waiting for a bucket to become available\|unambiguous timeout" "${INT_LOG_FILE_NAME}.out.raw"; then +if [ "${SG_CBCOLLECT_ALWAYS:-}" == "true" ] || grep -a -q "server logs for details\|Timed out after 1m0s waiting for a bucket to become available" "${INT_LOG_FILE_NAME}.out.raw"; then docker exec -t couchbase /opt/couchbase/bin/cbcollect_info /workspace/cbcollect.zip fi diff --git a/manifest/3.0.xml b/manifest/3.0.xml index 2a16128f8a..9a96645ace 100644 --- a/manifest/3.0.xml +++ b/manifest/3.0.xml @@ -25,14 +25,14 @@ licenses/APL2.txt. - + - + diff --git a/manifest/3.0/3.0.6.xml b/manifest/3.0/3.0.6.xml index 218d1abaea..8f38b22ca0 100644 --- a/manifest/3.0/3.0.6.xml +++ b/manifest/3.0/3.0.6.xml @@ -25,7 +25,7 @@ licenses/APL2.txt. - + diff --git a/manifest/3.0/3.0.7.xml b/manifest/3.0/3.0.7.xml new file mode 100644 index 0000000000..137a2c494a --- /dev/null +++ b/manifest/3.0/3.0.7.xml @@ -0,0 +1,162 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/manifest/product-config.json b/manifest/product-config.json index fd5d46acb4..438af693be 100644 --- a/manifest/product-config.json +++ b/manifest/product-config.json @@ -400,10 +400,20 @@ "trigger_blackduck": true, "start_build": 7 }, - "manifest/3.0.xml": { + "manifest/3.0/3.0.7.xml": { + "do-build": false, "release": "3.0.7", "release_name": "Couchbase Sync Gateway 3.0.7", "production": true, + "interval": 1440, + "go_version": "1.16.15", + "trigger_blackduck": true, + "start_build": 7 + }, + "manifest/3.0.xml": { + "release": "3.0.8", + "release_name": "Couchbase Sync Gateway 3.0.8", + "production": true, "interval": 120, "go_version": "1.16.15", "trigger_blackduck": true, diff --git a/rest/admin_api.go b/rest/admin_api.go index ee67dff011..324129eb63 100644 --- a/rest/admin_api.go +++ b/rest/admin_api.go @@ -411,6 +411,7 @@ func (h *handler) handlePutConfig() error { Trace FileLoggerPutConfig `json:"trace,omitempty"` Stats FileLoggerPutConfig `json:"stats,omitempty"` } `json:"logging"` + ReplicationLimit *int `json:"max_concurrent_replications,omitempty"` } var config ServerPutConfig @@ -462,6 +463,16 @@ func (h *handler) handlePutConfig() error { base.EnableStatsLogger(*config.Logging.Stats.Enabled) } + if config.ReplicationLimit != nil { + if *config.ReplicationLimit < 0 { + return base.HTTPErrorf(http.StatusBadRequest, "replication limit cannot be less than 0") + } + h.server.Config.Replicator.MaxConcurrentReplications = *config.ReplicationLimit + h.server.ActiveReplicationsCounter.lock.Lock() + h.server.ActiveReplicationsCounter.activeReplicatorLimit = *config.ReplicationLimit + h.server.ActiveReplicationsCounter.lock.Unlock() + } + return base.HTTPErrorf(http.StatusOK, "Updated") } diff --git a/rest/adminapitest/admin_api_test.go b/rest/adminapitest/admin_api_test.go index 8bf10b64ed..51b18b9743 100644 --- a/rest/adminapitest/admin_api_test.go +++ b/rest/adminapitest/admin_api_test.go @@ -241,6 +241,62 @@ func TestLoggingKeys(t *testing.T) { assert.Equal(t, map[string]interface{}{}, noLogKeys) } +func TestServerlessChangesEndpointLimit(t *testing.T) { + base.RequireNumTestBuckets(t, 2) + base.SetUpTestLogging(t, base.LevelInfo, base.KeyReplicate, base.KeyHTTP, base.KeyHTTPResp, base.KeySync, base.KeySyncMsg, base.KeyChanges) + rt := rest.NewRestTester(t, &rest.RestTesterConfig{ + SyncFn: `function(doc) {channel(doc.channel);}`, + }) + defer rt.Close() + + resp := rt.SendAdminRequest(http.MethodPut, "/_config", `{"max_concurrent_replications" : 2}`) + rest.RequireStatus(t, resp, http.StatusOK) + resp = rt.SendAdminRequest("PUT", "/db/_user/alice", rest.GetUserPayload(t, "alice", "letmein", "", rt.GetSingleTestDatabaseCollection(), []string{"ABC"}, nil)) + rest.RequireStatus(t, resp, 201) + + // Put several documents in channel PBS + response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs1", `{"value":1, "channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs2", `{"value":2, "channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs3", `{"value":3, "channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + + changesJSON := `{"style":"all_docs", + "heartbeat":300000, + "feed":"longpoll", + "limit":50, + "since":"1", + "filter":"` + base.ByChannelFilter + `", + "channels":"ABC,PBS"}` + var wg sync.WaitGroup + wg.Add(2) + + // send some changes requests in go routines to run concurrently along with test + go func() { + defer wg.Done() + resp1 := rt.SendUserRequest(http.MethodPost, "/{{.keyspace}}/_changes", changesJSON, "alice") + rest.RequireStatus(t, resp1, http.StatusOK) + }() + + go func() { + defer wg.Done() + resp2 := rt.SendUserRequest(http.MethodPost, "/{{.keyspace}}/_changes", changesJSON, "alice") + rest.RequireStatus(t, resp2, http.StatusOK) + }() + + // assert count for replicators is correct according to changes request made above + rt.WaitForActiveReplicatorCount(2) + + // assert this request is rejected due to this request taking us over the limit + resp = rt.SendAdminRequest(http.MethodGet, "/{{.keyspace}}/_changes?feed=longpoll&since=999999&timeout=100000", "") + rest.RequireStatus(t, resp, http.StatusServiceUnavailable) + // put doc to end changes feeds + resp = rt.SendAdminRequest("PUT", "/{{.keyspace}}/abc1", `{"value":3, "channel":["ABC"]}`) + rest.RequireStatus(t, resp, 201) + wg.Wait() +} + func TestLoggingLevels(t *testing.T) { if base.GlobalTestLoggingSet.IsTrue() { t.Skip("Test does not work when a global test log level is set") @@ -4311,3 +4367,30 @@ func TestPerDBCredsOverride(t *testing.T) { assert.Equal(t, "invalidUsername", configs["db"].BucketConfig.Username) assert.Equal(t, "invalidPassword", configs["db"].BucketConfig.Password) } + +// Can be used to reproduce connections left open after database close. Manually deleting the bucket used by the test +// once the test reaches the sleep loop will log connection errors for unclosed connections. +func TestDeleteDatabaseCBGTTeardown(t *testing.T) { + t.Skip("Dev-time test used to repro agent connections being left open after database close") + if base.UnitTestUrlIsWalrus() { + t.Skip("This test only works against Couchbase Server") + } + base.SetUpTestLogging(t, base.LevelTrace, base.KeyHTTP, base.KeyImport) + + rtConfig := rest.RestTesterConfig{DatabaseConfig: &rest.DatabaseConfig{DbConfig: rest.DbConfig{AutoImport: true}}} + rt := rest.NewRestTester(t, &rtConfig) + defer rt.Close() + // Initialize database + _ = rt.GetDatabase() + + for i := 0; i < 1; i++ { + time.Sleep(1 * time.Second) // some time for polling + } + + resp := rt.SendAdminRequest(http.MethodDelete, "/db/", "") + rest.RequireStatus(t, resp, http.StatusOK) + + for i := 0; i < 1000; i++ { + time.Sleep(1 * time.Second) // some time for polling + } +} diff --git a/rest/api.go b/rest/api.go index 21884eab03..a340946003 100644 --- a/rest/api.go +++ b/rest/api.go @@ -218,7 +218,7 @@ func (h *handler) handleFlush() error { } // Manually re-open a temporary bucket connection just for flushing purposes - tempBucketForFlush, err := db.GetConnectToBucketFn(false)(h.ctx(), spec) + tempBucketForFlush, err := db.ConnectToBucket(h.ctx(), spec, false) if err != nil { return err } diff --git a/rest/api_test.go b/rest/api_test.go index 6458df6b27..7ed1e51745 100644 --- a/rest/api_test.go +++ b/rest/api_test.go @@ -35,15 +35,10 @@ import ( "github.com/couchbase/sync_gateway/channels" "github.com/couchbase/sync_gateway/db" "github.com/couchbaselabs/walrus" - "github.com/robertkrimen/otto/underscore" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" ) -func init() { - underscore.Disable() // It really slows down unit tests (by making otto.New take a lot longer) -} - // ////// REST TESTER HELPER CLASS: // ////// AND NOW THE TESTS: @@ -260,8 +255,12 @@ func TestCORSOrigin(t *testing.T) { response := rt.SendRequestWithHeaders(method, "/{{.keyspace}}/", "", reqHeaders) assert.Equal(t, tc.headerOutput, response.Header().Get("Access-Control-Allow-Origin")) if method == http.MethodGet { - RequireStatus(t, response, http.StatusBadRequest) - require.Contains(t, response.Body.String(), invalidDatabaseName) + if base.TestsUseNamedCollections() { + RequireStatus(t, response, http.StatusBadRequest) + require.Contains(t, response.Body.String(), invalidDatabaseName) + } else { // CBG-2978, should not be different from GSI/collections + RequireStatus(t, response, http.StatusUnauthorized) + } } else { RequireStatus(t, response, http.StatusNoContent) @@ -2678,6 +2677,19 @@ func TestDocChannelSetPruning(t *testing.T) { assert.Equal(t, uint64(12), syncData.ChannelSetHistory[0].End) } +func TestNullDocHandlingForMutable1xBody(t *testing.T) { + rt := NewRestTester(t, nil) + defer rt.Close() + collection := rt.GetSingleTestDatabaseCollectionWithUser() + + documentRev := db.DocumentRevision{DocID: "doc1", BodyBytes: []byte("null")} + + body, err := documentRev.Mutable1xBody(collection, nil, nil, false) + require.Error(t, err) + require.Nil(t, body) + assert.Contains(t, err.Error(), "null doc body for doc") +} + func TestTombstoneCompactionAPI(t *testing.T) { rt := NewRestTester(t, nil) rt.GetDatabase().PurgeInterval = 0 diff --git a/rest/attachmentcompactiontest/attachment_compaction_api_test.go b/rest/attachmentcompactiontest/attachment_compaction_api_test.go index 8cc82ba89e..39efe0c24e 100644 --- a/rest/attachmentcompactiontest/attachment_compaction_api_test.go +++ b/rest/attachmentcompactiontest/attachment_compaction_api_test.go @@ -15,6 +15,7 @@ import ( "testing" "time" + "github.com/couchbase/gocbcore/v10" "github.com/couchbase/sync_gateway/base" "github.com/couchbase/sync_gateway/db" "github.com/couchbase/sync_gateway/rest" @@ -415,3 +416,65 @@ func TestAttachmentCompactionAbort(t *testing.T) { status := rt.WaitForAttachmentCompactionStatus(t, db.BackgroundProcessStateStopped) assert.Equal(t, int64(0), status.PurgedAttachments) } + +func TestAttachmentCompactionMarkPhaseRollback(t *testing.T) { + if base.UnitTestUrlIsWalrus() { + t.Skip("This test only works against Couchbase Server") + } + var garbageVBUUID gocbcore.VbUUID = 1234 + base.SetUpTestLogging(t, base.LevelInfo, base.KeyAll) + + rt := rest.NewRestTesterDefaultCollection(t, nil) + defer rt.Close() + dataStore := rt.GetSingleDataStore() + + // Create some 'unmarked' attachments + makeUnmarkedDoc := func(docid string) { + err := dataStore.SetRaw(docid, 0, nil, []byte("{}")) + require.NoError(t, err) + } + + for i := 0; i < 1000; i++ { + docID := fmt.Sprintf("%s%s%d", base.AttPrefix, "unmarked", i) + makeUnmarkedDoc(docID) + } + + // kick off compaction and wait for "mark" phase to begin + resp := rt.SendAdminRequest("POST", "/{{.db}}/_compact?type=attachment", "") + rest.RequireStatus(t, resp, http.StatusOK) + _ = rt.WaitForAttachmentCompactionStatus(t, db.BackgroundProcessStateRunning) + + // immediately stop the compaction process (we just need the status data to be persisted to the bucket) + resp = rt.SendAdminRequest("POST", "/{{.db}}/_compact?type=attachment&action=stop", "") + rest.RequireStatus(t, resp, http.StatusOK) + stat := rt.WaitForAttachmentCompactionStatus(t, db.BackgroundProcessStateStopped) + require.Equal(t, db.MarkPhase, stat.Phase) + + // alter persisted dcp metadata from the first run to force a rollback + name := db.GenerateCompactionDCPStreamName(stat.CompactID, "mark") + checkpointPrefix := fmt.Sprintf("%s:%v", "_sync:dcp_ck:", name) + + meta := base.NewDCPMetadataCS(dataStore, 1024, 8, checkpointPrefix) + vbMeta := meta.GetMeta(0) + vbMeta.VbUUID = garbageVBUUID + meta.SetMeta(0, vbMeta) + meta.Persist(0, []uint16{0}) + + // kick off a new run attempting to start it again (should force into rollback handling) + resp = rt.SendAdminRequest("POST", "/{{.db}}/_compact?type=attachment&action=start", "") + rest.RequireStatus(t, resp, http.StatusOK) + _ = rt.WaitForAttachmentCompactionStatus(t, db.BackgroundProcessStateCompleted) + + // Validate results of recovered attachment compaction process + resp = rt.SendAdminRequest("GET", "/{{.db}}/_compact?type=attachment", "") + rest.RequireStatus(t, resp, http.StatusOK) + + // validate that the compaction process actually recovered from rollback by checking stats + var response db.AttachmentManagerResponse + err := base.JSONUnmarshal(resp.BodyBytes(), &response) + require.NoError(t, err) + require.Equal(t, db.BackgroundProcessStateCompleted, response.State) + require.Equal(t, int64(0), response.MarkedAttachments) + require.Equal(t, int64(1000), response.PurgedAttachments) + +} diff --git a/rest/blip_api_attachment_test.go b/rest/blip_api_attachment_test.go index a322369263..69cd0ca280 100644 --- a/rest/blip_api_attachment_test.go +++ b/rest/blip_api_attachment_test.go @@ -178,6 +178,121 @@ func TestBlipPushPullV2AttachmentV3Client(t *testing.T) { assert.Equal(t, int64(1), rt.GetDatabase().DbStats.CBLReplicationPush().AttachmentPushCount.Value()) assert.Equal(t, int64(11), rt.GetDatabase().DbStats.CBLReplicationPush().AttachmentPushBytes.Value()) } + +// TestBlipProveAttachmentV2 ensures that CBL's proveAttachment for deduplication is working correctly even for v2 attachments which aren't de-duped on the server side. +func TestBlipProveAttachmentV2(t *testing.T) { + base.SetUpTestLogging(t, base.LevelTrace, base.KeyAll) + rtConfig := RestTesterConfig{ + GuestEnabled: true, + } + rt := NewRestTester(t, &rtConfig) + defer rt.Close() + + btc, err := NewBlipTesterClientOptsWithRT(t, rt, &BlipTesterClientOpts{ + SupportedBLIPProtocols: []string{db.BlipCBMobileReplicationV2}, + }) + require.NoError(t, err) + defer btc.Close() + + err = btc.StartPull() + assert.NoError(t, err) + + const ( + doc1ID = "doc1" + doc2ID = "doc2" + ) + + const ( + attachmentName = "hello.txt" + attachmentData = "hello world" + ) + + var ( + attachmentDataB64 = base64.StdEncoding.EncodeToString([]byte(attachmentData)) + attachmentDigest = "sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0=" + ) + + // Create two docs with the same attachment data on SG - v2 attachments intentionally result in two copies, + // CBL will still de-dupe attachments based on digest, so will still try proveAttachmnet for the 2nd. + doc1Body := fmt.Sprintf(`{"greetings":[{"hi": "alice"}],"_attachments":{"%s":{"data":"%s"}}}`, attachmentName, attachmentDataB64) + response := rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/"+doc1ID, doc1Body) + RequireStatus(t, response, http.StatusCreated) + doc1RevID := RespRevID(t, response) + + data, ok := btc.WaitForRev(doc1ID, doc1RevID) + require.True(t, ok) + bodyTextExpected := fmt.Sprintf(`{"greetings":[{"hi":"alice"}],"_attachments":{"%s":{"revpos":1,"length":%d,"stub":true,"digest":"%s"}}}`, attachmentName, len(attachmentData), attachmentDigest) + require.JSONEq(t, bodyTextExpected, string(data)) + + // create doc2 now that we know the client has the attachment + doc2Body := fmt.Sprintf(`{"greetings":[{"howdy": "bob"}],"_attachments":{"%s":{"data":"%s"}}}`, attachmentName, attachmentDataB64) + response = rt.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/"+doc2ID, doc2Body) + RequireStatus(t, response, http.StatusCreated) + doc2RevID := RespRevID(t, response) + + data, ok = btc.WaitForRev(doc2ID, doc2RevID) + require.True(t, ok) + bodyTextExpected = fmt.Sprintf(`{"greetings":[{"howdy":"bob"}],"_attachments":{"%s":{"revpos":1,"length":%d,"stub":true,"digest":"%s"}}}`, attachmentName, len(attachmentData), attachmentDigest) + require.JSONEq(t, bodyTextExpected, string(data)) + + assert.Equal(t, int64(2), rt.GetDatabase().DbStats.CBLReplicationPull().RevSendCount.Value()) + assert.Equal(t, int64(0), rt.GetDatabase().DbStats.CBLReplicationPull().RevErrorCount.Value()) + assert.Equal(t, int64(1), rt.GetDatabase().DbStats.CBLReplicationPull().AttachmentPullCount.Value()) + assert.Equal(t, int64(len(attachmentData)), rt.GetDatabase().DbStats.CBLReplicationPull().AttachmentPullBytes.Value()) +} + +// TestBlipProveAttachmentV2Push ensures that CBL's attachment deduplication is ignored for push replications - resulting in new server-side digests and duplicated attachment data (v2 attachment format). +func TestBlipProveAttachmentV2Push(t *testing.T) { + base.SetUpTestLogging(t, base.LevelTrace, base.KeyAll) + rtConfig := RestTesterConfig{ + GuestEnabled: true, + } + rt := NewRestTester(t, &rtConfig) + defer rt.Close() + + btc, err := NewBlipTesterClientOptsWithRT(t, rt, &BlipTesterClientOpts{ + SupportedBLIPProtocols: []string{db.BlipCBMobileReplicationV2}, + }) + require.NoError(t, err) + defer btc.Close() + + const ( + doc1ID = "doc1" + doc2ID = "doc2" + ) + + const ( + attachmentName = "hello.txt" + attachmentData = "hello world" + ) + + var ( + attachmentDataB64 = base64.StdEncoding.EncodeToString([]byte(attachmentData)) + // attachmentDigest = "sha1-Kq5sNclPz7QV2+lfQIuc6R7oRu0=" + ) + + // Create two docs with the same attachment data on the client - v2 attachments intentionally result in two copies stored on the server, despite the client being able to share the data for both. + doc1Body := fmt.Sprintf(`{"greetings":[{"hi": "alice"}],"_attachments":{"%s":{"data":"%s"}}}`, attachmentName, attachmentDataB64) + doc1revID, err := btc.PushRev(doc1ID, "", []byte(doc1Body)) + require.NoError(t, err) + + err = rt.WaitForRev(doc1ID, doc1revID) + require.NoError(t, err) + + // create doc2 now that we know the server has the attachment - SG should still request the attachment data from the client. + doc2Body := fmt.Sprintf(`{"greetings":[{"howdy": "bob"}],"_attachments":{"%s":{"data":"%s"}}}`, attachmentName, attachmentDataB64) + doc2RevID, err := btc.PushRev(doc2ID, "", []byte(doc2Body)) + require.NoError(t, err) + + err = rt.WaitForRev(doc2ID, doc2RevID) + require.NoError(t, err) + + assert.Equal(t, int64(2), rt.GetDatabase().DbStats.CBLReplicationPush().DocPushCount.Value()) + assert.Equal(t, int64(0), rt.GetDatabase().DbStats.CBLReplicationPush().DocPushErrorCount.Value()) + assert.Equal(t, int64(2), rt.GetDatabase().DbStats.CBLReplicationPush().AttachmentPushCount.Value()) + assert.Equal(t, int64(2*len(attachmentData)), rt.GetDatabase().DbStats.CBLReplicationPush().AttachmentPushBytes.Value()) +} + func TestBlipPushPullNewAttachmentCommonAncestor(t *testing.T) { base.SetUpTestLogging(t, base.LevelInfo, base.KeyAll) rtConfig := RestTesterConfig{ diff --git a/rest/blip_api_crud_test.go b/rest/blip_api_crud_test.go index 356b51074a..bae3c89a18 100644 --- a/rest/blip_api_crud_test.go +++ b/rest/blip_api_crud_test.go @@ -2652,3 +2652,122 @@ func TestUnsubChanges(t *testing.T) { _, found = btc.WaitForRev("doc2", resp.Rev) assert.True(t, found) } + +// TestRequestPlusPull tests that a one-shot pull replication waits for pending changes when request plus is set on the replication. +func TestRequestPlusPull(t *testing.T) { + + base.SetUpTestLogging(t, base.LevelInfo, base.KeyDCP, base.KeyChanges, base.KeyHTTP) + defer db.SuspendSequenceBatching()() // Required for slow sequence simulation + + rtConfig := RestTesterConfig{ + SyncFn: `function(doc) { + channel(doc.channel); + if (doc.accessUser != "") { + access(doc.accessUser, doc.accessChannel) + } + }`, + } + rt := NewRestTester(t, &rtConfig) + defer rt.Close() + database := rt.GetDatabase() + + // Initialize blip tester client (will create user) + client, err := NewBlipTesterClientOptsWithRT(t, rt, &BlipTesterClientOpts{ + Username: "bernard", + }) + require.NoError(t, err) + defer client.Close() + + // Put a doc in channel PBS + response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-1", `{"channel":["PBS"]}`) + RequireStatus(t, response, 201) + + // Allocate a sequence but do not write a doc for it - will block DCP buffering until sequence is skipped + slowSequence, seqErr := db.AllocateTestSequence(database) + require.NoError(t, seqErr) + + // Write a document granting user 'bernard' access to PBS + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/grantDoc", `{"accessUser":"bernard", "accessChannel":"PBS"}`) + RequireStatus(t, response, 201) + + caughtUpStart := database.DbStats.CBLReplicationPull().NumPullReplTotalCaughtUp.Value() + + // Start a regular one-shot pull + err = client.StartOneshotPullRequestPlus() + assert.NoError(t, err) + + // Wait for the one-shot changes feed to go into wait mode before releasing the slow sequence + require.NoError(t, database.WaitForTotalCaughtUp(caughtUpStart+1)) + + // Release the slow sequence + releaseErr := db.ReleaseTestSequence(database, slowSequence) + require.NoError(t, releaseErr) + + // The one-shot pull should unblock and replicate the document in the granted channel + data, ok := client.WaitForDoc("pbs-1") + assert.True(t, ok) + assert.Equal(t, `{"channel":["PBS"]}`, string(data)) + +} + +// TestRequestPlusPull tests that a one-shot pull replication waits for pending changes when request plus is set on the db config. +func TestRequestPlusPullDbConfig(t *testing.T) { + + base.SetUpTestLogging(t, base.LevelInfo, base.KeyDCP, base.KeyChanges, base.KeyHTTP) + defer db.SuspendSequenceBatching()() // Required for slow sequence simulation + + rtConfig := RestTesterConfig{ + SyncFn: `function(doc) { + channel(doc.channel); + if (doc.accessUser != "") { + access(doc.accessUser, doc.accessChannel) + } + }`, + DatabaseConfig: &DatabaseConfig{ + DbConfig: DbConfig{ + ChangesRequestPlus: base.BoolPtr(true), + }, + }, + } + rt := NewRestTester(t, &rtConfig) + defer rt.Close() + database := rt.GetDatabase() + + // Initialize blip tester client (will create user) + client, err := NewBlipTesterClientOptsWithRT(t, rt, &BlipTesterClientOpts{ + Username: "bernard", + }) + require.NoError(t, err) + defer client.Close() + + // Put a doc in channel PBS + response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-1", `{"channel":["PBS"]}`) + RequireStatus(t, response, 201) + + // Allocate a sequence but do not write a doc for it - will block DCP buffering until sequence is skipped + slowSequence, seqErr := db.AllocateTestSequence(database) + require.NoError(t, seqErr) + + // Write a document granting user 'bernard' access to PBS + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/grantDoc", `{"accessUser":"bernard", "accessChannel":"PBS"}`) + RequireStatus(t, response, 201) + + caughtUpStart := database.DbStats.CBLReplicationPull().NumPullReplTotalCaughtUp.Value() + + // Start a regular one-shot pull + err = client.StartOneshotPull() + assert.NoError(t, err) + + // Wait for the one-shot changes feed to go into wait mode before releasing the slow sequence + require.NoError(t, database.WaitForTotalCaughtUp(caughtUpStart+1)) + + // Release the slow sequence + releaseErr := db.ReleaseTestSequence(database, slowSequence) + require.NoError(t, releaseErr) + + // The one-shot pull should unblock and replicate the document in the granted channel + data, ok := client.WaitForDoc("pbs-1") + assert.True(t, ok) + assert.Equal(t, `{"channel":["PBS"]}`, string(data)) + +} diff --git a/rest/blip_client_test.go b/rest/blip_client_test.go index 13558aee7e..cf4e2b554c 100644 --- a/rest/blip_client_test.go +++ b/rest/blip_client_test.go @@ -310,6 +310,7 @@ func (btr *BlipTesterReplicator) initHandlers(btc *BlipTesterClient) { } var missingDigests []string + var knownDigests []string btcr.attachmentsLock.RLock() for _, attachment := range attsMap { attMap, ok := attachment.(map[string]interface{}) @@ -320,10 +321,63 @@ func (btr *BlipTesterReplicator) initHandlers(btc *BlipTesterClient) { if _, found := btcr.attachments[digest]; !found { missingDigests = append(missingDigests, digest) + } else { + if btr.bt.blipContext.ActiveSubprotocol() == db.BlipCBMobileReplicationV2 { + // only v2 clients care about proveAttachments + knownDigests = append(knownDigests, digest) + } } } btcr.attachmentsLock.RUnlock() + for _, digest := range knownDigests { + attData, err := btcr.getAttachment(digest) + if err != nil { + panic(err) + } + nonce, proof, err := db.GenerateProofOfAttachment(attData) + if err != nil { + panic(err) + } + + // if we already have this attachment, _we_ should ask the peer whether _they_ have the attachment + outrq := blip.NewRequest() + outrq.SetProfile(db.MessageProveAttachment) + outrq.Properties[db.ProveAttachmentDigest] = digest + outrq.SetBody(nonce) + + err = btcr.sendPullMsg(outrq) + if err != nil { + panic(err) + } + + resp := outrq.Response() + btc.pullReplication.storeMessage(resp) + respBody, err := resp.Body() + if err != nil { + panic(err) + } + + if resp.Type() == blip.ErrorType { + // forward error from proveAttachment response into rev response + if !msg.NoReply() { + response := msg.Response() + errorCode, _ := strconv.Atoi(resp.Properties["Error-Code"]) + response.SetError(resp.Properties["Error-Code"], errorCode, string(respBody)) + } + return + } + + if string(respBody) != proof { + // forward error from proveAttachment response into rev response + if !msg.NoReply() { + response := msg.Response() + response.SetError(resp.Properties["Error-Code"], http.StatusForbidden, fmt.Sprintf("Incorrect proof for attachment %s", digest)) + } + return + } + } + for _, digest := range missingDigests { outrq := blip.NewRequest() outrq.SetProfile(db.MessageGetAttachment) @@ -430,10 +484,11 @@ func (btc *BlipTesterCollectionClient) saveAttachment(_, base64data string) (dat digest = db.Sha1DigestKey(data) if _, found := btc.attachments[digest]; found { - return 0, "", fmt.Errorf("attachment with digest already exists") + base.InfofCtx(context.TODO(), base.KeySync, "attachment with digest %s already exists", digest) + } else { + btc.attachments[digest] = data } - btc.attachments[digest] = data return len(data), digest, nil } @@ -632,19 +687,23 @@ func (btc *BlipTesterClient) Collection(collectionName string) *BlipTesterCollec // StartPull will begin a continuous pull replication since 0 between the client and server func (btcc *BlipTesterCollectionClient) StartPull() (err error) { - return btcc.StartPullSince("true", "0", "false", "") + return btcc.StartPullSince("true", "0", "false", "", "") } func (btcc *BlipTesterCollectionClient) StartOneshotPull() (err error) { - return btcc.StartPullSince("false", "0", "false", "") + return btcc.StartPullSince("false", "0", "false", "", "") } func (btcc *BlipTesterCollectionClient) StartOneshotPullFiltered(channels string) (err error) { - return btcc.StartPullSince("false", "0", "false", channels) + return btcc.StartPullSince("false", "0", "false", channels, "") +} + +func (btcc *BlipTesterCollectionClient) StartOneshotPullRequestPlus() (err error) { + return btcc.StartPullSince("false", "0", "false", "", "true") } // StartPullSince will begin a pull replication between the client and server with the given params. -func (btc *BlipTesterCollectionClient) StartPullSince(continuous, since, activeOnly string, channels string) (err error) { +func (btc *BlipTesterCollectionClient) StartPullSince(continuous, since, activeOnly, channels, requestPlus string) (err error) { subChangesRequest := blip.NewRequest() subChangesRequest.SetProfile(db.MessageSubChanges) subChangesRequest.Properties[db.SubChangesContinuous] = continuous @@ -654,6 +713,9 @@ func (btc *BlipTesterCollectionClient) StartPullSince(continuous, since, activeO subChangesRequest.Properties[db.SubChangesFilter] = base.ByChannelFilter subChangesRequest.Properties[db.SubChangesChannels] = channels } + if requestPlus != "" { + subChangesRequest.Properties[db.SubChangesRequestPlus] = requestPlus + } subChangesRequest.SetNoReply(true) if btc.parent.BlipTesterClientOpts.SendRevocations { @@ -923,6 +985,9 @@ func (btc *BlipTesterCollectionClient) GetRev(docID, revID string) (data []byte, // WaitForRev blocks until the given doc ID and rev ID have been stored by the client, and returns the data when found. func (btc *BlipTesterCollectionClient) WaitForRev(docID, revID string) (data []byte, found bool) { + if data, found := btc.GetRev(docID, revID); found { + return data, found + } ticker := time.NewTicker(50 * time.Millisecond) timeout := time.After(10 * time.Second) for { @@ -938,6 +1003,41 @@ func (btc *BlipTesterCollectionClient) WaitForRev(docID, revID string) (data []b } } +// GetDoc returns a rev stored in the Client under the given docID. (if multiple revs are present, rev body returned is non-deterministic) +func (btc *BlipTesterCollectionClient) GetDoc(docID string) (data []byte, found bool) { + btc.docsLock.RLock() + defer btc.docsLock.RUnlock() + + if rev, ok := btc.docs[docID]; ok { + for _, data := range rev { + return data.body, true + } + } + + return nil, false +} + +// WaitForDoc blocks until the given doc ID has been stored by the client, and returns the data when found. +func (btc *BlipTesterCollectionClient) WaitForDoc(docID string) (data []byte, found bool) { + + if data, found := btc.GetDoc(docID); found { + return data, found + } + ticker := time.NewTicker(50 * time.Millisecond) + timeout := time.After(10 * time.Second) + for { + select { + case <-timeout: + btc.parent.rt.TB.Fatalf("BlipTesterClient timed out waiting for doc ID: %v", docID) + return nil, false + case <-ticker.C: + if data, found := btc.GetDoc(docID); found { + return data, found + } + } + } +} + // GetMessage returns the message stored in the Client under the given serial number func (btr *BlipTesterReplicator) GetMessage(serialNumber blip.MessageNumber) (msg *blip.Message, found bool) { btr.messagesLock.RLock() @@ -1026,6 +1126,10 @@ func (btc *BlipTesterClient) WaitForRev(docID string, revID string) ([]byte, boo return btc.SingleCollection().WaitForRev(docID, revID) } +func (btc *BlipTesterClient) WaitForDoc(docID string) ([]byte, bool) { + return btc.SingleCollection().WaitForDoc(docID) +} + func (btc *BlipTesterClient) WaitForBlipRevMessage(docID string, revID string) (*blip.Message, bool) { return btc.SingleCollection().WaitForBlipRevMessage(docID, revID) } @@ -1038,16 +1142,20 @@ func (btc *BlipTesterClient) StartOneshotPullFiltered(channels string) error { return btc.SingleCollection().StartOneshotPullFiltered(channels) } +func (btc *BlipTesterClient) StartOneshotPullRequestPlus() error { + return btc.SingleCollection().StartOneshotPullRequestPlus() +} + func (btc *BlipTesterClient) PushRev(docID string, revID string, body []byte) (string, error) { return btc.SingleCollection().PushRev(docID, revID, body) } func (btc *BlipTesterClient) StartPullSince(continuous, since, activeOnly string) error { - return btc.SingleCollection().StartPullSince(continuous, since, activeOnly, "") + return btc.SingleCollection().StartPullSince(continuous, since, activeOnly, "", "") } func (btc *BlipTesterClient) StartFilteredPullSince(continuous, since, activeOnly string, channels string) error { - return btc.SingleCollection().StartPullSince(continuous, since, activeOnly, channels) + return btc.SingleCollection().StartPullSince(continuous, since, activeOnly, channels, "") } func (btc *BlipTesterClient) GetRev(docID, revID string) ([]byte, bool) { diff --git a/rest/blip_stats_test.go b/rest/blip_stats_test.go new file mode 100644 index 0000000000..de640ff761 --- /dev/null +++ b/rest/blip_stats_test.go @@ -0,0 +1,96 @@ +// Copyright 2023-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. + +package rest + +import ( + "testing" + + "github.com/couchbase/sync_gateway/base" + "github.com/stretchr/testify/require" +) + +func sendGetCheckpointRequest(bt *BlipTester) { + t := bt.restTester.TB + rq := bt.newRequest() + rq.SetProfile("getCheckpoint") + require.True(t, bt.sender.Send(rq)) + errorCode, exists := rq.Response().Properties["Error-Code"] + require.True(t, exists) + require.Equal(t, "404", errorCode) +} + +// waitForStatGreaterThan will retry for up to 20 seconds until the result of getStatFunc is equal to the expected value. +func waitForStatGreaterThan(t *testing.T, getStatFunc func() int64, expected int64) { + workerFunc := func() (shouldRetry bool, err error, val interface{}) { + val = getStatFunc() + stat, ok := val.(int64) + require.True(t, ok) + return stat <= expected, nil, val + } + // wait for up to 20 seconds for the stat to meet the expected value + err, val := base.RetryLoop("waitForStatGreaterThan retry loop", workerFunc, base.CreateSleeperFunc(200, 100)) + require.NoError(t, err) + valInt64, ok := val.(int64) + require.True(t, ok) + require.Greater(t, valInt64, expected) +} + +func TestBlipStatsBasic(t *testing.T) { + bt, err := NewBlipTester(t) + require.NoError(t, err) + defer bt.Close() + + // make sure requests have not incremented stats. + /// Note: there is a blip call in NewBlipTester to initialize collections + dbStats := bt.restTester.GetDatabase().DbStats.Database() + require.Equal(t, int64(0), dbStats.ReplicationBytesReceived.Value()) + require.Equal(t, int64(0), dbStats.ReplicationBytesSent.Value()) + + // send a request, close BlipSyncContext and make sure stats are incremented + sendGetCheckpointRequest(bt) + + // requests shouldn't be implemented as part of handler + require.Equal(t, int64(0), dbStats.ReplicationBytesReceived.Value()) + require.Equal(t, int64(0), dbStats.ReplicationBytesSent.Value()) + + bt.sender.Close() + + waitForStatGreaterThan(t, dbStats.ReplicationBytesReceived.Value, 1) + waitForStatGreaterThan(t, dbStats.ReplicationBytesSent.Value, 1) + +} + +func TestBlipStatsFastReport(t *testing.T) { + bt, err := NewBlipTester(t) + require.NoError(t, err) + defer bt.Close() + sendRequest := func() { + rq := bt.newRequest() + rq.SetProfile("getCheckpoint") + require.True(t, bt.sender.Send(rq)) + errorCode, exists := rq.Response().Properties["Error-Code"] + require.True(t, exists) + require.Equal(t, "404", errorCode) + } + + dbStats := bt.restTester.GetDatabase().DbStats.Database() + require.Equal(t, int64(0), dbStats.ReplicationBytesReceived.Value()) + require.Equal(t, int64(0), dbStats.ReplicationBytesSent.Value()) + + sendRequest() + + require.Equal(t, int64(0), dbStats.ReplicationBytesReceived.Value()) + require.Equal(t, int64(0), dbStats.ReplicationBytesSent.Value()) + + // set reporting interval to update stats immediately + bt.restTester.GetDatabase().Options.BlipStatsReportingInterval = 0 + sendRequest() + require.Less(t, int64(0), dbStats.ReplicationBytesReceived.Value()) + require.Less(t, int64(0), dbStats.ReplicationBytesSent.Value()) +} diff --git a/rest/blip_sync.go b/rest/blip_sync.go index 01242a4923..931c96fe8e 100644 --- a/rest/blip_sync.go +++ b/rest/blip_sync.go @@ -11,6 +11,7 @@ licenses/APL2.txt. package rest import ( + "context" "fmt" "net/http" @@ -22,6 +23,16 @@ import ( // HTTP handler for incoming BLIP sync WebSocket request (/db/_blipsync) func (h *handler) handleBLIPSync() error { + needRelease, err := h.server.incrementConcurrentReplications(h.rqCtx) + if err != nil { + h.db.DbStats.Database().NumReplicationsRejectedLimit.Add(1) + return err + } + // if we haven't incremented the active replicator due to MaxConcurrentReplications being 0, we don't need to decrement it + if needRelease { + defer h.server.decrementConcurrentReplications(h.rqCtx) + } + // Exit early when the connection can't be switched to websocket protocol. if _, ok := h.response.(http.Hijacker); !ok { base.DebugfCtx(h.ctx(), base.KeyHTTP, "Non-upgradable request received for BLIP+WebSocket protocol") @@ -71,3 +82,37 @@ func (h *handler) handleBLIPSync() error { return nil } + +// incrementConcurrentReplications increments the number of active replications (if there is capacity to do so) +// and rejects calls if no capacity is available +func (sc *ServerContext) incrementConcurrentReplications(ctx context.Context) (bool, error) { + // lock replications config limit + the active replications counter + sc.ActiveReplicationsCounter.lock.Lock() + defer sc.ActiveReplicationsCounter.lock.Unlock() + // if max concurrent replications is 0 then we don't need to keep track of concurrent replications + if sc.ActiveReplicationsCounter.activeReplicatorLimit == 0 { + return false, nil + } + + capacity := sc.ActiveReplicationsCounter.activeReplicatorLimit + count := sc.ActiveReplicationsCounter.activeReplicatorCount + + if count >= capacity { + base.InfofCtx(ctx, base.KeyHTTP, "Replication limit exceeded (active: %d limit: %d)", count, capacity) + return false, base.ErrReplicationLimitExceeded + } + sc.ActiveReplicationsCounter.activeReplicatorCount++ + base.TracefCtx(ctx, base.KeyHTTP, "Acquired replication slot (active: %d/%d)", sc.ActiveReplicationsCounter.activeReplicatorCount, capacity) + + return true, nil +} + +// decrementConcurrentReplications decrements the number of active replications on the server context +func (sc *ServerContext) decrementConcurrentReplications(ctx context.Context) { + // lock replications config limit + the active replications counter + sc.ActiveReplicationsCounter.lock.Lock() + defer sc.ActiveReplicationsCounter.lock.Unlock() + connections := sc.ActiveReplicationsCounter.activeReplicatorLimit + sc.ActiveReplicationsCounter.activeReplicatorCount-- + base.TracefCtx(ctx, base.KeyHTTP, "Released replication slot (active: %d/%d)", sc.activeReplicatorCount, connections) +} diff --git a/rest/changes_api.go b/rest/changes_api.go index 00c06170c0..b1f39173f3 100644 --- a/rest/changes_api.go +++ b/rest/changes_api.go @@ -37,6 +37,12 @@ const kDefaultTimeoutMS = 5 * 60 * 1000 // Maximum value of _changes?timeout property const kMaxTimeoutMS = 15 * 60 * 1000 +// Values for feed parameter on changes request +const feedTypeContinuous = "continuous" +const feedTypeLongpoll = "longpoll" +const feedTypeNormal = "normal" +const feedTypeWebsocket = "websocket" + func (h *handler) handleRevsDiff() error { var input map[string][]string err := h.readJSONInto(&input) @@ -180,6 +186,16 @@ func (h *handler) handleChanges() error { options.ActiveOnly = h.getBoolQuery("active_only") options.IncludeDocs = h.getBoolQuery("include_docs") options.Revocations = h.getBoolQuery("revocations") + + useRequestPlus, _ := h.getOptBoolQuery("request_plus", h.db.Options.ChangesRequestPlus) + if useRequestPlus && feed != feedTypeContinuous { + var seqErr error + options.RequestPlusSeq, seqErr = h.db.GetRequestPlusSequence() + if seqErr != nil { + return base.HTTPErrorf(http.StatusServiceUnavailable, "Unable to retrieve requestPlus sequence") + } + + } filter = h.getQuery("filter") channelsParam := h.getQuery("channels") if channelsParam != "" { @@ -248,6 +264,15 @@ func (h *handler) handleChanges() error { feed = "normal" } + needRelease, concurrentReplicationsErr := h.server.incrementConcurrentReplications(h.rqCtx) + if concurrentReplicationsErr != nil { + return concurrentReplicationsErr + } + // if we haven't incremented the active replicator due to MaxConcurrentReplications being 0, we don't need to decrement it + if needRelease { + defer h.server.decrementConcurrentReplications(h.rqCtx) + } + // Get the channels as parameters to an imaginary "bychannel" filter. // The default is all channels the user can access. userChannels := base.SetOf(ch.AllChannelWildcard) @@ -303,18 +328,18 @@ func (h *handler) handleChanges() error { var err error switch feed { - case "normal": + case feedTypeNormal: if filter == "_doc_ids" { err, forceClose = h.sendSimpleChanges(userChannels, options, docIdsArray) } else { err, forceClose = h.sendSimpleChanges(userChannels, options, nil) } - case "longpoll": + case feedTypeLongpoll: options.Wait = true err, forceClose = h.sendSimpleChanges(userChannels, options, nil) - case "continuous": + case feedTypeContinuous: err, forceClose = h.sendContinuousChangesByHTTP(userChannels, options) - case "websocket": + case feedTypeWebsocket: err, forceClose = h.sendContinuousChangesByWebSocket(userChannels, options) default: err = base.HTTPErrorf(http.StatusBadRequest, "Unknown feed type") @@ -445,7 +470,7 @@ func (h *handler) generateContinuousChanges(inChannels base.Set, options db.Chan options.Continuous = true err, forceClose := db.GenerateChanges(h.ctx(), h.rq.Context(), h.collection, inChannels, options, nil, send) if sendErr, ok := err.(*db.ChangesSendErr); ok { - h.logStatus(http.StatusOK, fmt.Sprintf("0Write error: %v", sendErr)) + h.logStatus(http.StatusOK, fmt.Sprintf("Write error: %v", sendErr)) return nil, forceClose // error is probably because the client closed the connection } else { h.logStatus(http.StatusOK, "OK (continuous feed closed)") @@ -571,7 +596,8 @@ func (h *handler) readChangesOptionsFromJSON(jsonData []byte) (feed string, opti HeartbeatMs *uint64 `json:"heartbeat"` TimeoutMs *uint64 `json:"timeout"` AcceptEncoding string `json:"accept_encoding"` - ActiveOnly bool `json:"active_only"` // Return active revisions only + ActiveOnly bool `json:"active_only"` // Return active revisions only + RequestPlus *bool `json:"request_plus"` // Wait for sequence buffering to catch up to database seq value at time request was issued } // Initialize since clock and hasher ahead of unmarshalling sequence @@ -615,6 +641,20 @@ func (h *handler) readChangesOptionsFromJSON(jsonData []byte) (feed string, opti compress = (input.AcceptEncoding == "gzip") + if h.db != nil && feed != feedTypeContinuous { + useRequestPlus := h.db.Options.ChangesRequestPlus + if input.RequestPlus != nil { + useRequestPlus = *input.RequestPlus + } + if useRequestPlus { + var seqErr error + options.RequestPlusSeq, seqErr = h.db.GetRequestPlusSequence() + if seqErr != nil { + err = base.HTTPErrorf(http.StatusServiceUnavailable, "Unable to retrieve requestPlus sequence: %v", seqErr) + return + } + } + } return } diff --git a/rest/changestest/changes_api_test.go b/rest/changestest/changes_api_test.go index 0c6472e7af..f9f63c83ca 100644 --- a/rest/changestest/changes_api_test.go +++ b/rest/changestest/changes_api_test.go @@ -3935,6 +3935,292 @@ func TestTombstoneCompaction(t *testing.T) { TestCompact(db.QueryTombstoneBatch + 20) } +// TestOneShotGrantTiming simulates a one-shot changes feed returning before a previously issued grant has been +// buffered over DCP. +func TestOneShotGrantTiming(t *testing.T) { + + base.SetUpTestLogging(t, base.LevelDebug, base.KeyChanges, base.KeyHTTP) + + defer db.SuspendSequenceBatching()() + + rt := rest.NewRestTester(t, + &rest.RestTesterConfig{ + SyncFn: `function(doc) { + channel(doc.channel); + if (doc.accessUser != "") { + access(doc.accessUser, doc.accessChannel) + } + }`, + }) + defer rt.Close() + + // Create user with access to no channels + ctx := rt.Context() + database := rt.GetDatabase() + a := database.Authenticator(ctx) + bernard, err := a.NewUser("bernard", "letmein", nil) + assert.NoError(t, err) + assert.NoError(t, a.Save(bernard)) + + // Put several documents in channel PBS + response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-1", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-2", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-3", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-4", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + + var changes struct { + Results []db.ChangeEntry + Last_Seq interface{} + } + + // Allocate a sequence but do not write a doc for it - will block DCP buffering until sequence is skipped + slowSequence, seqErr := db.AllocateTestSequence(database) + require.NoError(t, seqErr) + log.Printf("Allocated slowSequence: %v", slowSequence) + + // Write a document granting user access to PBS + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/grantDoc", `{"accessUser":"bernard", "accessChannel":"PBS"}`) + rest.RequireStatus(t, response, 201) + + // Issue normal one-shot changes request. Expect no results as granting document hasn't been buffered (blocked by + // slowSequence) + changesResponse := rt.SendUserRequest("GET", "/{{.keyspace}}/_changes", "", "bernard") + rest.RequireStatus(t, changesResponse, 200) + err = base.JSONUnmarshal(changesResponse.Body.Bytes(), &changes) + assert.NoError(t, err, "Error unmarshalling changes response") + for _, entry := range changes.Results { + log.Printf("Entry:%+v", entry) + } + require.Len(t, changes.Results, 0) + + // Release the slow sequence and wait for it to be processed over DCP + releaseErr := db.ReleaseTestSequence(database, slowSequence) + require.NoError(t, releaseErr) + require.NoError(t, rt.WaitForPendingChanges()) + + // Issue normal one-shot changes request. Expect results as granting document buffering is unblocked + changesResponse = rt.SendUserRequest("GET", "/{{.keyspace}}/_changes", "", "bernard") + rest.RequireStatus(t, changesResponse, 200) + err = base.JSONUnmarshal(changesResponse.Body.Bytes(), &changes) + assert.NoError(t, err, "Error unmarshalling changes response") + for _, entry := range changes.Results { + log.Printf("Entry:%+v", entry) + } + require.Len(t, changes.Results, 4) + +} + +// TestOneShotGrantRequestPlus simulates a one-shot changes feed being made before a previously issued grant has been +// buffered over DCP. When requestPlus is set, changes feed should block until grant is processed. +func TestOneShotGrantRequestPlus(t *testing.T) { + + base.SetUpTestLogging(t, base.LevelDebug, base.KeyChanges, base.KeyHTTP) + + defer db.SuspendSequenceBatching()() // Required for slow sequence simulation + + rt := rest.NewRestTester(t, + &rest.RestTesterConfig{ + SyncFn: `function(doc) { + channel(doc.channel); + if (doc.accessUser != "") { + access(doc.accessUser, doc.accessChannel) + } + }`, + }) + defer rt.Close() + + // Create user with access to no channels + ctx := rt.Context() + database := rt.GetDatabase() + a := database.Authenticator(ctx) + bernard, err := a.NewUser("bernard", "letmein", nil) + assert.NoError(t, err) + assert.NoError(t, a.Save(bernard)) + + // Put several documents in channel PBS + response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-1", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-2", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-3", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-4", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + + // Allocate a sequence but do not write a doc for it - will block DCP buffering until sequence is skipped + slowSequence, seqErr := db.AllocateTestSequence(database) + require.NoError(t, seqErr) + + // Write a document granting user access to PBS + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/grantDoc", `{"accessUser":"bernard", "accessChannel":"PBS"}`) + rest.RequireStatus(t, response, 201) + + caughtUpStart := database.DbStats.CBLReplicationPull().NumPullReplTotalCaughtUp.Value() + + var oneShotComplete sync.WaitGroup + // Issue a GET requestPlus one-shot changes request in a separate goroutine. + oneShotComplete.Add(1) + go func() { + defer oneShotComplete.Done() + var changes rest.ChangesResults + changesResponse := rt.SendUserRequest("GET", "/{{.keyspace}}/_changes?request_plus=true", "", "bernard") + rest.RequireStatus(t, changesResponse, 200) + err := base.JSONUnmarshal(changesResponse.Body.Bytes(), &changes) + assert.NoError(t, err, "Error unmarshalling changes response") + for _, entry := range changes.Results { + log.Printf("Entry:%+v", entry) + } + require.Len(t, changes.Results, 4) + }() + + // Issue a POST requestPlus one-shot changes request in a separate goroutine. + oneShotComplete.Add(1) + go func() { + defer oneShotComplete.Done() + var changes rest.ChangesResults + changesResponse := rt.SendUserRequest("POST", "/{{.keyspace}}/_changes", `{"request_plus":true}`, "bernard") + rest.RequireStatus(t, changesResponse, 200) + err = base.JSONUnmarshal(changesResponse.Body.Bytes(), &changes) + assert.NoError(t, err, "Error unmarshalling changes response") + for _, entry := range changes.Results { + log.Printf("Entry:%+v", entry) + } + require.Len(t, changes.Results, 4) + }() + + // Wait for the one-shot changes feed to go into wait mode before releasing the slow sequence + require.NoError(t, database.WaitForTotalCaughtUp(caughtUpStart+2)) + + // Release the slow sequence and wait for it to be processed over DCP + releaseErr := db.ReleaseTestSequence(database, slowSequence) + require.NoError(t, releaseErr) + require.NoError(t, rt.WaitForPendingChanges()) + + oneShotComplete.Wait() +} + +// TestOneShotGrantRequestPlusDbConfig simulates a one-shot changes feed being made before a previously issued grant has been +// buffered over DCP. When requestPlus is set via config, changes feed should block until grant is processed. +func TestOneShotGrantRequestPlusDbConfig(t *testing.T) { + + base.SetUpTestLogging(t, base.LevelDebug, base.KeyChanges, base.KeyHTTP) + + defer db.SuspendSequenceBatching()() + + rt := rest.NewRestTester(t, + &rest.RestTesterConfig{ + SyncFn: `function(doc) { + channel(doc.channel); + if (doc.accessUser != "") { + access(doc.accessUser, doc.accessChannel) + } + }`, + DatabaseConfig: &rest.DatabaseConfig{ + DbConfig: rest.DbConfig{ + ChangesRequestPlus: base.BoolPtr(true), + }, + }, + }) + defer rt.Close() + + // Create user with access to no channels + ctx := rt.Context() + database := rt.GetDatabase() + a := database.Authenticator(ctx) + bernard, err := a.NewUser("bernard", "letmein", nil) + assert.NoError(t, err) + assert.NoError(t, a.Save(bernard)) + + // Put several documents in channel PBS + response := rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-1", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-2", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-3", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/pbs-4", `{"channel":["PBS"]}`) + rest.RequireStatus(t, response, 201) + + // Allocate a sequence but do not write a doc for it - will block DCP buffering until sequence is skipped + slowSequence, seqErr := db.AllocateTestSequence(database) + require.NoError(t, seqErr) + log.Printf("Allocated slowSequence: %v", slowSequence) + + // Write a document granting user access to PBS + response = rt.SendAdminRequest("PUT", "/{{.keyspace}}/grantDoc", `{"accessUser":"bernard", "accessChannel":"PBS"}`) + rest.RequireStatus(t, response, 201) + + // Issue one-shot GET changes request explicitly setting request_plus=false (should override config value). + // Expect no results as granting document hasn't been buffered (blocked by slowSequence) + changesResponse := rt.SendUserRequest("GET", "/{{.keyspace}}/_changes?request_plus=false", "", "bernard") + rest.RequireStatus(t, changesResponse, 200) + var changes rest.ChangesResults + err = base.JSONUnmarshal(changesResponse.Body.Bytes(), &changes) + assert.NoError(t, err, "Error unmarshalling changes response") + for _, entry := range changes.Results { + log.Printf("Entry:%+v", entry) + } + require.Len(t, changes.Results, 0) + + // Issue one-shot POST changes request explicitly setting request_plus=false (should override config value). + // Expect no results as granting document hasn't been buffered (blocked by slowSequence) + changesResponse = rt.SendUserRequest("POST", "/{{.keyspace}}/_changes", `{"request_plus":false}`, "bernard") + rest.RequireStatus(t, changesResponse, 200) + err = base.JSONUnmarshal(changesResponse.Body.Bytes(), &changes) + assert.NoError(t, err, "Error unmarshalling changes response") + for _, entry := range changes.Results { + log.Printf("Entry:%+v", entry) + } + require.Len(t, changes.Results, 0) + + caughtUpStart := database.DbStats.CBLReplicationPull().NumPullReplTotalCaughtUp.Value() + + var oneShotComplete sync.WaitGroup + // Issue a GET one-shot changes request in a separate goroutine. Should run as request plus based on config + oneShotComplete.Add(1) + go func() { + defer oneShotComplete.Done() + var changes rest.ChangesResults + changesResponse := rt.SendUserRequest("GET", "/{{.keyspace}}/_changes", "", "bernard") + rest.RequireStatus(t, changesResponse, 200) + err := base.JSONUnmarshal(changesResponse.Body.Bytes(), &changes) + assert.NoError(t, err, "Error unmarshalling changes response") + for _, entry := range changes.Results { + log.Printf("Entry:%+v", entry) + } + require.Len(t, changes.Results, 4) + }() + + // Issue a POST one-shot changes request in a separate goroutine. Should run as request plus based on config + oneShotComplete.Add(1) + go func() { + defer oneShotComplete.Done() + var changes rest.ChangesResults + changesResponse := rt.SendUserRequest("POST", "/{{.keyspace}}/_changes", `{}`, "bernard") + rest.RequireStatus(t, changesResponse, 200) + err := base.JSONUnmarshal(changesResponse.Body.Bytes(), &changes) + assert.NoError(t, err, "Error unmarshalling changes response") + for _, entry := range changes.Results { + log.Printf("Entry:%+v", entry) + } + require.Len(t, changes.Results, 4) + }() + + // Wait for the one-shot changes feed to go into wait mode before releasing the slow sequence + require.NoError(t, database.WaitForTotalCaughtUp(caughtUpStart+2)) + + // Release the slow sequence and wait for it to be processed over DCP + releaseErr := db.ReleaseTestSequence(database, slowSequence) + require.NoError(t, releaseErr) + require.NoError(t, rt.WaitForPendingChanges()) + + oneShotComplete.Wait() +} + func waitForCompactStopped(dbc *db.DatabaseContext) error { for i := 0; i < 100; i++ { compactRunning := dbc.CacheCompactActive() diff --git a/rest/config.go b/rest/config.go index 0d6e17feed..abe561fc34 100644 --- a/rest/config.go +++ b/rest/config.go @@ -30,7 +30,7 @@ import ( "golang.org/x/crypto/bcrypt" "gopkg.in/square/go-jose.v2" - sgbucket "github.com/couchbase/sg-bucket" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/auth" "github.com/couchbase/sync_gateway/base" "github.com/couchbase/sync_gateway/db" @@ -161,10 +161,12 @@ type DbConfig struct { UserXattrKey string `json:"user_xattr_key,omitempty"` // Key of user xattr that will be accessible from the Sync Function. If empty the feature will be disabled. ClientPartitionWindowSecs *int `json:"client_partition_window_secs,omitempty"` // How long clients can remain offline for without losing replication metadata. Default 30 days (in seconds) Guest *auth.PrincipalConfig `json:"guest,omitempty"` // Guest user settings + JavaScriptEngine *string `json:"javascript_engine,omitempty"` // "Otto" or "V8"; default "Otto" JavascriptTimeoutSecs *uint32 `json:"javascript_timeout_secs,omitempty"` // The amount of seconds a Javascript function can run for. Set to 0 for no timeout. GraphQL *functions.GraphQLConfig `json:"graphql,omitempty"` // GraphQL configuration & resolver fns UserFunctions *functions.FunctionsConfig `json:"functions,omitempty"` // Named JS fns for clients to call Suspendable *bool `json:"suspendable,omitempty"` // Allow the database to be suspended + ChangesRequestPlus *bool `json:"changes_request_plus,omitempty"` // If set, is used as the default value of request_plus for non-continuous replications CORS *auth.CORSConfig `json:"cors,omitempty"` } @@ -689,13 +691,30 @@ func (dbConfig *DbConfig) validateVersion(ctx context.Context, isEnterpriseEditi base.WarnfCtx(ctx, `"pool" config option is not supported. The pool will be set to "default". The option should be removed from config file.`) } - if isEmpty, err := validateJavascriptFunction(dbConfig.Sync); err != nil { + // We need a JS VM to validate functions + var jsvm js.VM + { + jsEngineName := db.DefaultJavaScriptEngine + if dbConfig.JavaScriptEngine != nil { + jsEngineName = *dbConfig.JavaScriptEngine + } + if jsEngine := js.EngineNamed(jsEngineName); jsEngine == nil { + multiError = multiError.Append(fmt.Errorf("Invalid configuration - there is no JavaScript engine %q", jsEngineName)) + // Keep going with jsvm == nil. `validateJavascriptFunction` will detect this and + // just act as a no-op, rather than panicking or adding more errors. + } else { + jsvm = jsEngine.NewVM(ctx) + defer jsvm.Close() + } + } + + if isEmpty, err := validateJavascriptFunction(jsvm, dbConfig.Sync, 1, 3); err != nil { multiError = multiError.Append(fmt.Errorf("sync function error: %w", err)) } else if isEmpty { dbConfig.Sync = nil } - if isEmpty, err := validateJavascriptFunction(dbConfig.ImportFilter); err != nil { + if isEmpty, err := validateJavascriptFunction(jsvm, dbConfig.ImportFilter, 1, 1); err != nil { multiError = multiError.Append(fmt.Errorf("import filter error: %w", err)) } else if isEmpty { dbConfig.ImportFilter = nil @@ -858,13 +877,13 @@ func (dbConfig *DbConfig) validateVersion(ctx context.Context, isEnterpriseEditi // validate each collection's config for collectionName, collectionConfig := range scopeConfig.Collections { - if isEmpty, err := validateJavascriptFunction(collectionConfig.SyncFn); err != nil { + if isEmpty, err := validateJavascriptFunction(jsvm, collectionConfig.SyncFn, 1, 3); err != nil { multiError = multiError.Append(fmt.Errorf("collection %q sync function error: %w", collectionName, err)) } else if isEmpty { collectionConfig.SyncFn = nil } - if isEmpty, err := validateJavascriptFunction(collectionConfig.ImportFilter); err != nil { + if isEmpty, err := validateJavascriptFunction(jsvm, collectionConfig.ImportFilter, 1, 1); err != nil { multiError = multiError.Append(fmt.Errorf("collection %q import filter error: %w", collectionName, err)) } else if isEmpty { collectionConfig.ImportFilter = nil @@ -873,13 +892,8 @@ func (dbConfig *DbConfig) validateVersion(ctx context.Context, isEnterpriseEditi } } - if dbConfig.UserFunctions != nil { - if err := functions.ValidateFunctions(ctx, *dbConfig.UserFunctions); err != nil { - multiError = multiError.Append(err) - } - } - if dbConfig.GraphQL != nil { - if err := dbConfig.GraphQL.Validate(ctx); err != nil { + if jsvm != nil { + if err := functions.ValidateFunctions(ctx, jsvm, dbConfig.UserFunctions, dbConfig.GraphQL); err != nil { multiError = multiError.Append(err) } } @@ -967,9 +981,13 @@ func (dbConfig *DbConfig) deprecatedConfigCacheFallback() (warnings []string) { } // validateJavascriptFunction returns an error if the javascript function was invalid, if set. -func validateJavascriptFunction(jsFunc *string) (isEmpty bool, err error) { - if jsFunc != nil && strings.TrimSpace(*jsFunc) != "" { - if _, err := sgbucket.NewJSRunner(*jsFunc, 0); err != nil { +// If `vm` is nil, it's assumed that an earlier error has been reported about a bad JS VM config, +// so it will just silently skip function validation rather than adding to the noise. +func validateJavascriptFunction(vm js.VM, jsFunc *string, minArgs int, maxArgs int) (isEmpty bool, err error) { + if vm == nil { + return true, nil + } else if jsFunc != nil && strings.TrimSpace(*jsFunc) != "" { + if err := js.ValidateJavascriptFunction(vm, *jsFunc, minArgs, maxArgs); err != nil { return false, fmt.Errorf("invalid javascript syntax: %w", err) } return false, nil @@ -1266,7 +1284,8 @@ func SetupServerContext(ctx context.Context, config *StartupConfig, persistentCo sc := NewServerContext(ctx, config, persistentConfig) if !base.ServerIsWalrus(config.Bootstrap.Server) { - if err := sc.initializeCouchbaseServerConnections(ctx); err != nil { + failFast := false + if err := sc.initializeCouchbaseServerConnections(ctx, failFast); err != nil { return nil, err } } @@ -1372,7 +1391,7 @@ func (sc *ServerContext) migrateV30Configs(ctx context.Context) error { if getErr == base.ErrNotFound { continue } else if getErr != nil { - return fmt.Errorf("Error retrieving 3.0 config for bucket: %s, groupID: %s: %w", bucketName, groupID, err) + return fmt.Errorf("Error retrieving 3.0 config for bucket: %s, groupID: %s: %w", bucketName, groupID, getErr) } base.InfofCtx(ctx, base.KeyConfig, "Found legacy persisted config for database %s - migrating to db registry.", base.MD(dbConfig.Name)) @@ -1480,6 +1499,9 @@ func (sc *ServerContext) bucketNameFromDbName(dbName string) (bucketName string, return dbc.Bucket.GetName(), true } + if sc.BootstrapContext.Connection == nil { + return "", false + } // To search for database with the specified name, need to iterate over all buckets: // - look for dbName-scoped config file // - fetch default config file (backward compatibility, check internal DB name) @@ -1610,7 +1632,7 @@ func (sc *ServerContext) FetchConfigs(ctx context.Context, isInitialStartup bool // _applyConfigs takes a map of dbName->DatabaseConfig and loads them into the ServerContext where necessary. func (sc *ServerContext) _applyConfigs(ctx context.Context, dbNameConfigs map[string]DatabaseConfig, isInitialStartup bool) (count int) { for dbName, cnf := range dbNameConfigs { - applied, err := sc._applyConfig(base.NewNonCancelCtx(), cnf, false, isInitialStartup) + applied, err := sc._applyConfig(base.NewNonCancelCtx(), cnf, true, isInitialStartup) if err != nil { base.ErrorfCtx(ctx, "Couldn't apply config for database %q: %v", base.MD(dbName), err) continue diff --git a/rest/config_database.go b/rest/config_database.go index 335192a0e0..8d10f75ac2 100644 --- a/rest/config_database.go +++ b/rest/config_database.go @@ -90,6 +90,10 @@ func MergeDatabaseConfigWithDefaults(sc *StartupConfig, dbConfig *DbConfig) (*Db // to provide defaults to include_runtime config endpoints. // Note that this does not include unsupported options func DefaultDbConfig(sc *StartupConfig) *DbConfig { + var partitions *uint16 + if base.IsEnterpriseEdition() { + partitions = base.Uint16Ptr(base.GetDefaultImportPartitions(sc.IsServerless())) + } dbConfig := DbConfig{ BucketConfig: BucketConfig{}, Name: "", @@ -98,7 +102,7 @@ func DefaultDbConfig(sc *StartupConfig) *DbConfig { Roles: nil, RevsLimit: nil, // Set this below struct AutoImport: base.BoolPtr(base.DefaultAutoImport), - ImportPartitions: base.Uint16Ptr(base.GetDefaultImportPartitions(sc.IsServerless())), + ImportPartitions: partitions, ImportFilter: nil, ImportBackupOldRev: base.BoolPtr(false), EventHandlers: nil, diff --git a/rest/config_flags.go b/rest/config_flags.go index 8c69c71521..c53b32c635 100644 --- a/rest/config_flags.go +++ b/rest/config_flags.go @@ -122,8 +122,9 @@ func registerConfigFlags(config *StartupConfig, fs *flag.FlagSet) map[string]con "auth.bcrypt_cost": {&config.Auth.BcryptCost, fs.Int("auth.bcrypt_cost", 0, "Cost to use for bcrypt password hashes")}, - "replicator.max_heartbeat": {&config.Replicator.MaxHeartbeat, fs.String("replicator.max_heartbeat", "", "Max heartbeat value for _changes request")}, - "replicator.blip_compression": {&config.Replicator.BLIPCompression, fs.Int("replicator.blip_compression", 0, "BLIP data compression level (0-9)")}, + "replicator.max_heartbeat": {&config.Replicator.MaxHeartbeat, fs.String("replicator.max_heartbeat", "", "Max heartbeat value for _changes request")}, + "replicator.blip_compression": {&config.Replicator.BLIPCompression, fs.Int("replicator.blip_compression", 0, "BLIP data compression level (0-9)")}, + "replicator.max_concurrent_replications": {&config.Replicator.MaxConcurrentReplications, fs.Int("replicator.max_concurrent_replications", 0, "Maximum number of replication connections to the node")}, "unsupported.stats_log_frequency": {&config.Unsupported.StatsLogFrequency, fs.String("unsupported.stats_log_frequency", "", "How often should stats be written to stats logs")}, "unsupported.use_stdlib_json": {&config.Unsupported.UseStdlibJSON, fs.Bool("unsupported.use_stdlib_json", false, "Bypass the jsoniter package and use Go's stdlib instead")}, diff --git a/rest/config_startup.go b/rest/config_startup.go index fc32247b89..5da211f21d 100644 --- a/rest/config_startup.go +++ b/rest/config_startup.go @@ -136,8 +136,9 @@ type AuthConfig struct { } type ReplicatorConfig struct { - MaxHeartbeat *base.ConfigDuration `json:"max_heartbeat,omitempty" help:"Max heartbeat value for _changes request"` - BLIPCompression *int `json:"blip_compression,omitempty" help:"BLIP data compression level (0-9)"` + MaxHeartbeat *base.ConfigDuration `json:"max_heartbeat,omitempty" help:"Max heartbeat value for _changes request"` + BLIPCompression *int `json:"blip_compression,omitempty" help:"BLIP data compression level (0-9)"` + MaxConcurrentReplications int `json:"max_concurrent_replications,omitempty" help:"Maximum number of replication connections to the node"` } type UnsupportedConfig struct { diff --git a/rest/config_test.go b/rest/config_test.go index a8a5475447..80cf461d40 100644 --- a/rest/config_test.go +++ b/rest/config_test.go @@ -34,6 +34,7 @@ import ( "golang.org/x/crypto/bcrypt" "gopkg.in/square/go-jose.v2" + "github.com/couchbase/sg-bucket/js" "github.com/couchbase/sync_gateway/auth" "github.com/couchbase/sync_gateway/base" "github.com/couchbase/sync_gateway/db" @@ -2117,8 +2118,10 @@ func TestWebhookFilterFunctionLoad(t *testing.T) { terminator := make(chan bool) defer close(terminator) ctx := &db.DatabaseContext{EventMgr: db.NewEventManager(terminator)} + testCtx := base.TestCtx(t) + ctx.JS.Init(testCtx, js.EngineNamed(db.DefaultJavaScriptEngine), 4) sc := &ServerContext{} - err := sc.initEventHandlers(base.TestCtx(t), ctx, &dbConfig) + err := sc.initEventHandlers(testCtx, ctx, &dbConfig) if test.errExpected != nil { requireErrorWithX509UnknownAuthority(t, err, test.errExpected) } else { @@ -2191,19 +2194,19 @@ func TestInvalidJavascriptFunctions(t *testing.T) { }, { "Valid Sync Fn No Import", - base.StringPtr(`function(){}`), + base.StringPtr(`function(doc){}`), nil, 0, - base.StringPtr(`function(){}`), + base.StringPtr(`function(doc){}`), nil, }, { "Valid Import Fn No Sync", nil, - base.StringPtr(`function(){}`), + base.StringPtr(`function(doc){}`), 0, nil, - base.StringPtr(`function(){}`), + base.StringPtr(`function(doc){}`), }, { "Both empty", @@ -2223,7 +2226,7 @@ func TestInvalidJavascriptFunctions(t *testing.T) { }, { "Invalid Sync Fn No Import", - base.StringPtr(`function(){`), + base.StringPtr(`function(doc){`), nil, 1, nil, @@ -2242,15 +2245,15 @@ func TestInvalidJavascriptFunctions(t *testing.T) { { "Invalid Import Fn No Sync", nil, - base.StringPtr(`function(){`), + base.StringPtr(`function(doc){`), 1, nil, nil, }, { "Both invalid", - base.StringPtr(`function(){`), - base.StringPtr(`function(){`), + base.StringPtr(`function(doc){`), + base.StringPtr(`function(doc){`), 2, nil, nil, @@ -2384,15 +2387,17 @@ func Test_validateJavascriptFunction(t *testing.T) { wantErr: assert.NoError, }, } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - gotIsEmpty, err := validateJavascriptFunction(test.jsFunc) - if !test.wantErr(t, err, fmt.Sprintf("validateJavascriptFunction(%v)", test.jsFunc)) { - return - } - assert.Equalf(t, test.wantIsEmpty, gotIsEmpty, "validateJavascriptFunction(%v)", test.jsFunc) - }) - } + js.TestWithVMs(t, func(t *testing.T, vm js.VM) { + for _, test := range tests { + t.Run(test.name, func(t *testing.T) { + gotIsEmpty, err := validateJavascriptFunction(vm, test.jsFunc, 0, 0) + if !test.wantErr(t, err, fmt.Sprintf("validateJavascriptFunction(%v)", test.jsFunc)) { + return + } + assert.Equalf(t, test.wantIsEmpty, gotIsEmpty, "validateJavascriptFunction(%v)", test.jsFunc) + }) + } + }) } func TestBucketCredentialsValidation(t *testing.T) { diff --git a/rest/cors_test.go b/rest/cors_test.go index 5c46d660eb..506669e9d1 100644 --- a/rest/cors_test.go +++ b/rest/cors_test.go @@ -44,8 +44,12 @@ func TestCORSDynamicSet(t *testing.T) { response := rt.SendRequestWithHeaders(method, "/{{.keyspace}}/", "", reqHeaders) require.Equal(t, "http://example.com", response.Header().Get("Access-Control-Allow-Origin")) if method == http.MethodGet { - RequireStatus(t, response, http.StatusBadRequest) - require.Contains(t, response.Body.String(), invalidDatabaseName) + if base.TestsUseNamedCollections() { + RequireStatus(t, response, http.StatusBadRequest) + require.Contains(t, response.Body.String(), invalidDatabaseName) + } else { // CBG-2978, should not be different from GSI/collections + RequireStatus(t, response, http.StatusUnauthorized) + } } else { RequireStatus(t, response, http.StatusNoContent) } @@ -92,8 +96,12 @@ func TestCORSDynamicSet(t *testing.T) { response := rt.SendRequestWithHeaders(method, "/{{.keyspace}}/", "", reqHeaders) if method == http.MethodGet { require.Equal(t, "http://example.com", response.Header().Get("Access-Control-Allow-Origin")) - RequireStatus(t, response, http.StatusBadRequest) - require.Contains(t, response.Body.String(), invalidDatabaseName) + if base.TestsUseNamedCollections() { + RequireStatus(t, response, http.StatusBadRequest) + require.Contains(t, response.Body.String(), invalidDatabaseName) + } else { // CBG-2978, should not be different from GSI/collections + RequireStatus(t, response, http.StatusUnauthorized) + } } else { // information leak: the options request knows about the database and knows it doesn't match require.Equal(t, "", response.Header().Get("Access-Control-Allow-Origin")) diff --git a/rest/doc_api_test.go b/rest/doc_api_test.go index 78e19886d4..febbd30222 100644 --- a/rest/doc_api_test.go +++ b/rest/doc_api_test.go @@ -36,19 +36,19 @@ func TestDocumentNumbers(t *testing.T) { {"maxInt64", `{"number": 9223372036854775807}`, "9223372036854775807", - "string"}, + "number"}, {"minInt64", `{"number": -9223372036854775808}`, "-9223372036854775808", - "string"}, + "number"}, {"greaterThanMaxInt64", `{"number": 9223372036854775808}`, "9223372036854775808", - "string"}, + "number"}, {"lessThanMinInt64", `{"number": -9223372036854775809}`, "9223372036854775809", - "string"}, + "number"}, {"javascriptMaxSafeInt", `{"number": 9007199254740991}`, "9007199254740991", @@ -60,11 +60,11 @@ func TestDocumentNumbers(t *testing.T) { {"javascriptGreaterThanMaxSafeInt", `{"number": 9007199254740992}`, "9007199254740992", - "string"}, + "number"}, {"javascriptLessThanMinSafeInt", `{"number": -9007199254740992}`, "-9007199254740992", - "string"}, + "number"}, {"simpleFloat", `{"number": -234.56}`, "-234.56", @@ -87,6 +87,14 @@ func TestDocumentNumbers(t *testing.T) { `"array":[12.34]`, "number", }, + {"bigInt", + `{"number": 123456789012345678901234567890}`, + "123456789012345678901234567890", + "number"}, + {"bigIntArray", + `{"array": [123456789012345678901234567890]}`, + `"array":[123456789012345678901234567890]`, + "number"}, } // Use channels to ensure numbers are making it to sync function with expected formats @@ -116,18 +124,21 @@ func TestDocumentNumbers(t *testing.T) { RequireStatus(ts, getResponse, 200) // Check the raw bytes, because unmarshalling the response would be another opportunity for the number to get modified - responseString := string(getResponse.Body.Bytes()) + responseString := getResponse.Body.String() if !strings.Contains(responseString, test.expectedString) { ts.Errorf("Response does not contain the expected number format (%s). Response: %s", test.name, responseString) } // Check channel assignment + // NOTE: Now that we use V8 instead of Otto, this is kind of pointless: V8 supports + // JavaScript "bigints" -- arbitrary-size integers -- so it's no longer necessary to + // marshal large integers to strings before passing them to the sync function. getRawResponse := rt.SendAdminRequest("GET", fmt.Sprintf("/{{.keyspace}}/_raw/%s?redact=false", test.name), "") var rawResponse RawResponse require.NoError(ts, base.JSONUnmarshal(getRawResponse.Body.Bytes(), &rawResponse)) log.Printf("raw response: %s", getRawResponse.Body.Bytes()) assert.Equal(ts, 1, len(rawResponse.Sync.Channels)) - assert.True(ts, HasActiveChannel(rawResponse.Sync.Channels, test.expectedFormatChannel), fmt.Sprintf("Expected channel %s was not found in document channels (%s)", test.expectedFormatChannel, test.name)) + assert.True(ts, HasActiveChannel(rawResponse.Sync.Channels, test.expectedFormatChannel), fmt.Sprintf("Expected channel %s was not found in document channels %s (%s)", test.expectedFormatChannel, rawResponse.Sync.Channels, test.name)) }) } diff --git a/rest/functions_api.go b/rest/functions_api.go index 4a40c007c2..2ac489000e 100644 --- a/rest/functions_api.go +++ b/rest/functions_api.go @@ -31,8 +31,8 @@ const kGraphQLVariablesParam = "variables" // HTTP handler for GET or POST `/$db/_function/$name` func (h *handler) handleFunctionCall() error { var maxRequestSize *int - if h.db.Options.UserFunctions != nil { - maxRequestSize = h.db.Options.UserFunctions.MaxRequestSize + if h.db.UserFunctions != nil { + maxRequestSize = h.db.UserFunctions.MaxRequestSize } fnName, fnParams, err := h.getFunctionArgs(maxRequestSize) if err != nil { @@ -163,10 +163,10 @@ func (h *handler) handleGraphQL() error { var variables map[string]interface{} canMutate := false - if h.db.Options.GraphQL == nil { + if h.db.GraphQL == nil { return base.HTTPErrorf(http.StatusServiceUnavailable, "GraphQL is not configured") } - maxSize := h.db.Options.GraphQL.MaxRequestSize() + maxSize := h.db.GraphQL.MaxRequestSize() if h.rq.Method == "POST" { if h.rq.ContentLength >= 0 { diff --git a/rest/functionsapitest/graphql_admin_test.go b/rest/functionsapitest/graphql_admin_test.go index 79a0a2dd95..3a93310996 100644 --- a/rest/functionsapitest/graphql_admin_test.go +++ b/rest/functionsapitest/graphql_admin_test.go @@ -6,6 +6,8 @@ // software will be governed by the Apache License, Version 2.0, included in // the file licenses/APL2.txt. +//go:build cb_sg_v8 + package functionsapitest import ( @@ -21,11 +23,26 @@ import ( "github.com/stretchr/testify/require" ) -const kDummyGraphQLSchema = ` +// Dummy GraphQL schema: +var kDummyGraphQLSchema = ` type Query { square(n: Int!) : Int! }` +// Dummy GraphQL configuration: +var kDummyGraphQLConfig = functions.GraphQLConfig{ + Schema: &kDummyGraphQLSchema, + Resolvers: map[string]functions.GraphQLResolverConfig{ + "Query": { + "square": { + Type: "javascript", + Code: `function(parent, args, context, info) { return null; }`, + Allow: allowAll, + }, + }, + }, +} + var allowAll = &functions.Allow{Channels: []string{"*"}} // The GraphQL schema: @@ -55,9 +72,9 @@ var kTestGraphQLConfig = functions.GraphQLConfig{ "getUser": { Type: "javascript", Code: `function(parent, args, context, info) { - if (Object.keys(parent).length != 0) throw "Unexpected parent"; + if (parent !== undefined) throw "Unexpectedly-defined parent"; if (Object.keys(args).length != 1) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; + if (!info.selectedFieldNames) throw "No info.selectedFieldNames"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; return context.user.function("getUserWithID", {id: args.id});}`, @@ -66,9 +83,9 @@ var kTestGraphQLConfig = functions.GraphQLConfig{ "getEmails": { Type: "javascript", Code: `function(parent, args, context, info) { - if (Object.keys(parent).length != 0) throw "Unexpected parent"; + if (parent !== undefined) throw "Unexpectedly-defined parent"; if (Object.keys(args).length != 1) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; + if (!info.selectedFieldNames) throw "No info.selectedFieldNames"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; return context.user.function("getEmailsWithName", {name: args.name});}`, @@ -77,9 +94,9 @@ var kTestGraphQLConfig = functions.GraphQLConfig{ "getAllUsers": { Type: "javascript", Code: `function(parent, args, context, info) { - if (Object.keys(parent).length != 0) throw "Unexpected parent"; + if (parent !== undefined) throw "Unexpectedly-defined parent"; if (Object.keys(args).length != 0) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; + if (!info.selectedFieldNames) throw "No info.selectedFieldNames"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; return context.user.function("all");}`, @@ -90,12 +107,12 @@ var kTestGraphQLConfig = functions.GraphQLConfig{ "updateName": { Type: "javascript", Code: `function(parent, args, context, info){ - if (Object.keys(parent).length != 0) throw "Unexpected parent"; + if (parent !== undefined) throw "Unexpectedly-defined parent"; if (Object.keys(args).length != 2) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; + if (!info.selectedFieldNames) throw "No info.selectedFieldNames"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; - + var currentUser = context.user.function("getUserWithID", {id: args.id}); if (!currentUser) return undefined; currentUser.name = args.name; @@ -108,7 +125,7 @@ var kTestGraphQLConfig = functions.GraphQLConfig{ Code: `function(parent, args, context, info){ //if (!parent.id) throw "Invalid parent"; if (Object.keys(args).length != 2) throw "Unexpected args"; - if (Object.keys(info) != "selectedFieldNames") throw "Unexpected info"; + if (!info.selectedFieldNames) throw "No info.selectedFieldNames"; if (!context.user) throw "Missing context.user"; if (!context.admin) throw "Missing context.admin"; context.requireMutating(); @@ -116,7 +133,7 @@ var kTestGraphQLConfig = functions.GraphQLConfig{ if (!currentUser) return undefined; //case: args.email already present in the Emails array - + for (var i = 0; i < currentUser.Emails.length; i++) { console.log(currentUser.Emails[i]); if(currentUser.Emails[i]==args.email){ @@ -196,7 +213,9 @@ func runTestFunctionsConfigMVCC(t *testing.T, rt *rest.RestTester, uri string, n // Update config, just to change its etag: response = rt.SendAdminRequest("PUT", uri, newValue) - assert.Equal(t, 200, response.Result().StatusCode) + if !assert.Equal(t, 200, response.Result().StatusCode) { + return + } newEtag := response.HeaderMap.Get("Etag") assert.Regexp(t, `"[^"]+"`, newEtag) assert.NotEqual(t, etag, newEtag) @@ -232,21 +251,15 @@ func runTestFunctionsConfigMVCC(t *testing.T, rt *rest.RestTester, uri string, n // Test use of "Etag" and "If-Match" headers to safely update graphql config. func TestFunctionsConfigMVCCGraphQL(t *testing.T) { - rt := rest.NewRestTesterForUserQueries(t, rest.DbConfig{ - GraphQL: &functions.GraphQLConfig{ - Schema: base.StringPtr(kDummyGraphQLSchema), - Resolvers: nil, - }, - }) + rt := rest.NewRestTesterForUserQueries(t, rest.DbConfig{GraphQL: &kDummyGraphQLConfig}) if rt == nil { return } defer rt.Close() + configJSON, _ := json.Marshal(kDummyGraphQLConfig) t.Run("GraphQL", func(t *testing.T) { - runTestFunctionsConfigMVCC(t, rt, "/db/_config/graphql", `{ - "schema": "type Query {square(n: Int!) : Int!}", "resolvers":{} - }`) + runTestFunctionsConfigMVCC(t, rt, "/db/_config/graphql", string(configJSON)) }) } @@ -268,12 +281,7 @@ func TestFunctionsConfigGraphQLGetEmpty(t *testing.T) { } func TestFunctionsConfigGraphQLGet(t *testing.T) { - rt := rest.NewRestTesterForUserQueries(t, rest.DbConfig{ - GraphQL: &functions.GraphQLConfig{ - Schema: base.StringPtr(kTestGraphQLSchema), - Resolvers: nil, - }, - }) + rt := rest.NewRestTesterForUserQueries(t, rest.DbConfig{GraphQL: &kTestGraphQLConfig}) if rt == nil { return } @@ -291,12 +299,7 @@ func TestFunctionsConfigGraphQLGet(t *testing.T) { }) } func TestFunctionsConfigGraphQLPut(t *testing.T) { - rt := rest.NewRestTesterForUserQueries(t, rest.DbConfig{ - GraphQL: &functions.GraphQLConfig{ - Schema: base.StringPtr(kTestGraphQLSchema), - Resolvers: nil, - }, - }) + rt := rest.NewRestTesterForUserQueries(t, rest.DbConfig{GraphQL: &kTestGraphQLConfig}) if rt == nil { return } @@ -336,7 +339,7 @@ func TestFunctionsConfigGraphQLPut(t *testing.T) { response := rt.SendAdminRequest("DELETE", "/db/_config/graphql", "") assert.Equal(t, 200, response.Result().StatusCode) - assert.Nil(t, rt.GetDatabase().Options.GraphQL) + assert.Nil(t, rt.GetFunctionsConfig().GraphQL) response = rt.SendAdminRequest("POST", "/db/_graphql", `{"query": "query{ sum(n:3) }"}`) assert.Equal(t, 503, response.Result().StatusCode) @@ -345,12 +348,7 @@ func TestFunctionsConfigGraphQLPut(t *testing.T) { // Test for GraphQL Valid Configuration Schema func TestValidGraphQLConfigurationValues(t *testing.T) { - rt := rest.NewRestTesterForUserQueries(t, rest.DbConfig{ - GraphQL: &functions.GraphQLConfig{ - Schema: base.StringPtr(kDummyGraphQLSchema), - Resolvers: nil, - }, - }) + rt := rest.NewRestTesterForUserQueries(t, rest.DbConfig{GraphQL: &kDummyGraphQLConfig}) if rt == nil { return } @@ -475,12 +473,7 @@ func TestValidGraphQLConfigurationValues(t *testing.T) { // This function checks for failure when invalid GraphQL configuration // values are provided. func TestInvalidGraphQLConfigurationValues(t *testing.T) { - rt := rest.NewRestTesterForUserQueries(t, rest.DbConfig{ - GraphQL: &functions.GraphQLConfig{ - Schema: base.StringPtr(kDummyGraphQLSchema), - Resolvers: nil, - }, - }) + rt := rest.NewRestTesterForUserQueries(t, rest.DbConfig{GraphQL: &kDummyGraphQLConfig}) if rt == nil { return } @@ -638,7 +631,7 @@ func TestInvalidGraphQLConfigurationValues(t *testing.T) { assert.NoError(t, err) assert.Equal(t, 400, response.Result().StatusCode) - assert.Contains(t, responseMap["reason"], "Syntax Error GraphQL") + assert.Contains(t, responseMap["reason"], "Syntax Error") assert.Contains(t, responseMap["reason"], "Unexpected Name") assert.Contains(t, responseMap["error"], "Bad Request") diff --git a/rest/functionsapitest/graphql_queries_test.go b/rest/functionsapitest/graphql_queries_test.go index 223cb2fe79..ed0ebf7ce8 100644 --- a/rest/functionsapitest/graphql_queries_test.go +++ b/rest/functionsapitest/graphql_queries_test.go @@ -6,6 +6,8 @@ // software will be governed by the Apache License, Version 2.0, included in // the file licenses/APL2.txt. +//go:build cb_sg_v8 + package functionsapitest import ( @@ -15,9 +17,8 @@ import ( "testing" "time" - "github.com/graphql-go/graphql" - "github.com/couchbase/sync_gateway/base" + "github.com/couchbase/sync_gateway/db" "github.com/couchbase/sync_gateway/db/functions" "github.com/couchbase/sync_gateway/rest" "github.com/stretchr/testify/assert" @@ -76,7 +77,7 @@ func TestGraphQLQueryAdminOnly(t *testing.T) { t.Run("POST request", func(t *testing.T) { requestBody := fmt.Sprintf(`{ "query": "%s", - "variables": %s, + "variables": %s, "operationName": "%s" }`, queryParam, variableParam, operationParam) response := rt.SendAdminRequest("POST", "/db/_graphql", requestBody) @@ -188,7 +189,7 @@ func TestGraphQLMutationsAdminOnly(t *testing.T) { expectedResponse := `{"data":{"addEmail":{"Emails":["xyz@gmail.com","def@gmail.com","newEmail@gmail.com"],"id":"2","name":"user2"},"updateName":{"id":"1","name":"newUser"}}}` requestBody := fmt.Sprintf(`{ "query": "%s", - "variables": %s, + "variables": %s, "operationName": "%s" }`, queryParam, variableParam, operationParam) @@ -227,7 +228,7 @@ func TestGraphQLMutationsCustomUser(t *testing.T) { response = rt.SendUserRequestWithHeaders("POST", "/db/_graphql", `{"query": "mutation($id:ID!, $email: String!){ addEmail(id:$id, email:$email) {id,name,Emails} }" , "variables": {"id": 2, "email":"pqr@gmail.com"}}`, nil, "jinesh", "password") assert.Equal(t, 200, response.Result().StatusCode) - testErrorMessage(t, response, "403 you are not allowed to call GraphQL resolver") + testErrorMessage(t, response, "[403] Access forbidden") response = rt.SendAdminRequest("DELETE", "/db/_user/jinesh", "") assert.Equal(t, 200, response.Result().StatusCode) @@ -290,11 +291,10 @@ func TestContextDeadline(t *testing.T) { requestQuery := fmt.Sprintf(`{"query": "query{ checkContextDeadline(Timeout:%d) }"}`, timeout.Milliseconds()*2) response := rt.SendAdminRequest("POST", "/db/_graphql", requestQuery) - assert.Equal(t, 200, response.Result().StatusCode) - testErrorMessage(t, response, "context deadline exceeded") + assert.Equal(t, 500, response.Result().StatusCode) }) t.Run("AsAdmin - doNotExceedContextDeadline", func(t *testing.T) { - requestQuery := `{"query": "query{ checkContextDeadline(Timeout:1) }"}` + requestQuery := fmt.Sprintf(`{"query": "query{ checkContextDeadline(Timeout:%d) }"}`, timeout.Milliseconds()/2) response := rt.SendAdminRequest("POST", "/db/_graphql", requestQuery) assert.Equal(t, 200, response.Result().StatusCode) @@ -303,7 +303,7 @@ func TestContextDeadline(t *testing.T) { } func testErrorMessage(t *testing.T, response *rest.TestResponse, expectedErrorText string) { - graphQLResponse := graphql.Result{} + var graphQLResponse db.GraphQLResult err := json.Unmarshal(response.BodyBytes(), &graphQLResponse) assert.NoError(t, err) assert.NotZero(t, len(graphQLResponse.Errors), "Expected GraphQL error but got none; data is %s", graphQLResponse.Data) @@ -312,6 +312,5 @@ func testErrorMessage(t *testing.T, response *rest.TestResponse, expectedErrorTe return } } - t.Logf("GraphQL error did not contain expected string %q: actually %#v", expectedErrorText, graphQLResponse.Errors) - t.Fail() + assert.FailNowf(t, "GraphQL error did not contain expected string", "Expected to find %q: actually %s", expectedErrorText, response.BodyBytes()) } diff --git a/rest/functionsapitest/main_test.go b/rest/functionsapitest/main_test.go index 5ad62e91dd..3bfe45dc8b 100644 --- a/rest/functionsapitest/main_test.go +++ b/rest/functionsapitest/main_test.go @@ -7,6 +7,7 @@ file, in accordance with the Business Source License, use of this software will be governed by the Apache License, Version 2.0, included in the file licenses/APL2.txt. */ +// go:build cb_sg_v8 package functionsapitest diff --git a/rest/functionsapitest/user_functions_admin_test.go b/rest/functionsapitest/user_functions_admin_test.go index 49fc44ed01..b1d8629b4a 100644 --- a/rest/functionsapitest/user_functions_admin_test.go +++ b/rest/functionsapitest/user_functions_admin_test.go @@ -6,6 +6,8 @@ // software will be governed by the Apache License, Version 2.0, included in // the file licenses/APL2.txt. +//go:build cb_sg_v8 + package functionsapitest import ( @@ -48,7 +50,7 @@ func TestFunctionsConfigMVCC(t *testing.T) { Definitions: functions.FunctionsDefs{ "xxx": { Type: "javascript", - Code: "function(){return 42;}", + Code: "function(context,args){return 42;}", }, "xxxN1QL": { Type: "query", @@ -69,7 +71,7 @@ func TestFunctionsConfigMVCC(t *testing.T) { t.Run("Function", func(t *testing.T) { runTestFunctionsConfigMVCC(t, rt, "/db/_config/functions/xxx", `{ "type": "javascript", - "code": "function(){return 69;}" + "code": "function(context,args){return 69;}" }`) }) @@ -83,7 +85,7 @@ func TestFunctionsConfigMVCC(t *testing.T) { t.Run("Functions", func(t *testing.T) { runTestFunctionsConfigMVCC(t, rt, "/db/_config/functions", `{ "definitions": { - "zzz": {"type": "javascript", "code": "function(){return 69;}"} } }`) + "zzz": {"type": "javascript", "code": "function(context,args){return 69;}"} } }`) }) } @@ -183,8 +185,8 @@ func TestFunctionsConfigPut(t *testing.T) { "allow": {"channels": ["*"]}} } }`) assert.Equal(t, 200, response.Result().StatusCode) - assert.NotNil(t, rt.GetDatabase().Options.UserFunctions.Definitions["sum"]) - assert.Nil(t, rt.GetDatabase().Options.UserFunctions.Definitions["square"]) + assert.NotNil(t, rt.GetFunctionsConfig().Functions.Definitions["sum"]) + assert.Nil(t, rt.GetFunctionsConfig().Functions.Definitions["square"]) response = rt.SendAdminRequest("GET", "/db/_function/sum?numero=13", "") assert.Equal(t, 200, response.Result().StatusCode) @@ -197,7 +199,7 @@ func TestFunctionsConfigPut(t *testing.T) { response := rt.SendAdminRequest("DELETE", "/db/_config/functions", "") assert.Equal(t, 200, response.Result().StatusCode) - assert.Nil(t, rt.GetDatabase().Options.UserFunctions) + assert.Nil(t, rt.GetFunctionsConfig().Functions) response = rt.SendAdminRequest("GET", "/db/_function/square?numero=13", "") assert.Equal(t, 404, response.Result().StatusCode) @@ -243,8 +245,8 @@ func TestFunctionsConfigPutOne(t *testing.T) { }`) assert.Equal(t, 200, response.Result().StatusCode) - assert.NotNil(t, rt.GetDatabase().Options.UserFunctions.Definitions["sum"]) - assert.NotNil(t, rt.GetDatabase().Options.UserFunctions.Definitions["square"]) + assert.NotNil(t, rt.GetFunctionsConfig().Functions.Definitions["sum"]) + assert.NotNil(t, rt.GetFunctionsConfig().Functions.Definitions["square"]) response = rt.SendAdminRequest("GET", "/db/_function/sum?numero=13", "") assert.Equal(t, "26", string(response.BodyBytes())) @@ -258,8 +260,8 @@ func TestFunctionsConfigPutOne(t *testing.T) { }`) assert.Equal(t, 200, response.Result().StatusCode) - assert.NotNil(t, rt.GetDatabase().Options.UserFunctions.Definitions["sum"]) - assert.NotNil(t, rt.GetDatabase().Options.UserFunctions.Definitions["square"]) + assert.NotNil(t, rt.GetFunctionsConfig().Functions.Definitions["sum"]) + assert.NotNil(t, rt.GetFunctionsConfig().Functions.Definitions["square"]) response = rt.SendAdminRequest("GET", "/db/_function/square?n=13", "") assert.Equal(t, "-169", string(response.BodyBytes())) @@ -268,8 +270,8 @@ func TestFunctionsConfigPutOne(t *testing.T) { response := rt.SendAdminRequest("DELETE", "/db/_config/functions/square", "") assert.Equal(t, 200, response.Result().StatusCode) - assert.Nil(t, rt.GetDatabase().Options.UserFunctions.Definitions["square"]) - assert.Equal(t, 1, len(rt.GetDatabase().Options.UserFunctions.Definitions)) + assert.Nil(t, rt.GetFunctionsConfig().Functions.Definitions["square"]) + assert.Equal(t, 1, len(rt.GetFunctionsConfig().Functions.Definitions)) response = rt.SendAdminRequest("GET", "/db/_function/square?n=13", "") assert.Equal(t, 404, response.Result().StatusCode) diff --git a/rest/functionsapitest/user_functions_queries_test.go b/rest/functionsapitest/user_functions_queries_test.go index 5b0c618fd4..ca36bcc673 100644 --- a/rest/functionsapitest/user_functions_queries_test.go +++ b/rest/functionsapitest/user_functions_queries_test.go @@ -6,6 +6,8 @@ // software will be governed by the Apache License, Version 2.0, included in // the file licenses/APL2.txt. +//go:build cb_sg_v8 + package functionsapitest import ( @@ -99,16 +101,15 @@ func TestJSFunctionAsGuest(t *testing.T) { }) t.Run("user required", func(t *testing.T) { - t.Skip("Does not work with SG_TEST_USE_DEFAULT_COLLECTION=true CBG-2702") response := sendReqFn("POST", "/db/_function/square", `{"numero": 42}`) assert.Equal(t, 401, response.Result().StatusCode) - assert.Contains(t, string(response.BodyBytes()), "login required") + assert.Contains(t, string(response.BodyBytes()), "Login required") }) t.Run("admin-only", func(t *testing.T) { response := sendReqFn("GET", "/db/_function/admin_only", "") assert.Equal(t, 401, response.Result().StatusCode) - assert.Contains(t, string(response.BodyBytes()), "login required") + assert.Contains(t, string(response.BodyBytes()), "Login required") }) } @@ -243,13 +244,13 @@ func TestN1QLFunctionAsGuest(t *testing.T) { t.Skip("Does not work with SG_TEST_USE_DEFAULT_COLLECTION=true CBG-2702") response := sendReqFn("POST", "/db/_function/square", `{"numero": 16}`) assert.Equal(t, 401, response.Result().StatusCode) - assert.Contains(t, string(response.BodyBytes()), "login required") + assert.Contains(t, string(response.BodyBytes()), "Login required") }) t.Run("admin only", func(t *testing.T) { response := sendReqFn("GET", "/db/_function/admin_only", "") assert.Equal(t, 401, response.Result().StatusCode) - assert.Contains(t, string(response.BodyBytes()), "login required") + assert.Contains(t, string(response.BodyBytes()), "Login required") }) t.Run("unconfigured query", func(t *testing.T) { @@ -264,7 +265,7 @@ func testUserQueriesCommon(t *testing.T, rt *rest.RestTester, sendReqFn func(str t.Run("commons/passing a param", func(t *testing.T) { response := sendReqFn("POST", "/db/_function/square", `{"numero": 16}`) assert.Equal(t, 200, response.Result().StatusCode) - assert.EqualValues(t, "[{\"square\":256}\n]\n", string(response.BodyBytes())) + assert.EqualValues(t, "[{\"square\":256}]", string(response.BodyBytes())) }) } @@ -275,13 +276,13 @@ func testUserQueriesAsAdmin(t *testing.T, rt *rest.RestTester) { t.Run("select user", func(t *testing.T) { response := rt.SendAdminRequest("GET", "/db/_function/user", "") assert.Equal(t, 200, response.Result().StatusCode) - assert.EqualValues(t, "[{\"user\":{}}\n]\n", string(response.BodyBytes())) + assert.EqualValues(t, "[{\"user\":{}}]", string(response.BodyBytes())) }) t.Run("admin only", func(t *testing.T) { response := rt.SendAdminRequest("GET", "/db/_function/admin_only", "") assert.Equal(t, 200, response.Result().StatusCode) - assert.EqualValues(t, "[{\"status\":\"ok\"}\n]\n", string(response.BodyBytes())) + assert.EqualValues(t, "[{\"status\":\"ok\"}]", string(response.BodyBytes())) }) //negative cases: @@ -302,8 +303,7 @@ func testUserQueriesAsUser(t *testing.T, rt *rest.RestTester) { t.Run("select user", func(t *testing.T) { response := sendReqFn("GET", "/db/_function/user", "") assert.Equal(t, 200, response.Result().StatusCode) - assert.True(t, strings.HasPrefix(string(response.BodyBytes()), `[{"user":{"channels":["`)) - assert.True(t, strings.HasSuffix(string(response.BodyBytes()), "\"],\"email\":\"\",\"name\":\"alice\"}}\n]\n")) + assert.True(t, strings.HasPrefix(string(response.BodyBytes()), `[{"user":{"channels":["`) && strings.HasSuffix(string(response.BodyBytes()), "\"],\"name\":\"alice\"}}]"), "Unexpected response: %s", response.BodyBytes()) }) //negative cases: @@ -401,15 +401,16 @@ func TestFunctionMutability(t *testing.T) { assert.Equal(t, http.StatusForbidden, response.Result().StatusCode) }) - //Mutability of the function being called is false. Will fail as once you’ve lost the ability to mutate, you can’t get it back. + //Positive Cases + + //Mutability of the function being called is false. Still succeeds because it was called through the 'admin' object. t.Run("context.admin to call a Non-mutating function", func(t *testing.T) { putFuncName = "putDocMutabilityFalse" callerFuncName = "callerOverride" response := rt.SendAdminRequest("POST", fmt.Sprintf("/db/_function/%s", callerFuncName), fmt.Sprintf(body, putFuncName)) - assert.Equal(t, http.StatusForbidden, response.Result().StatusCode) + assert.Equal(t, http.StatusOK, response.Result().StatusCode) }) - //Positive Cases t.Run("Func with mutating True calls another function with a mutating value of True", func(t *testing.T) { putFuncName = "putDocMutabilityTrue" callerFuncName = "callerMutabilityTrue" @@ -456,15 +457,15 @@ func TestFunctionTimeout(t *testing.T) { timeout := 500 * time.Millisecond rt.GetDatabase().UserFunctionTimeout = timeout // positive case: + reqBody := fmt.Sprintf(`{"ms": %d}`, timeout.Milliseconds()/2) t.Run("under time limit", func(t *testing.T) { - reqBody := `{"ms": 1}` response := rt.SendAdminRequest("POST", "/db/_function/sleep", reqBody) assert.Equal(t, 200, response.Result().StatusCode) }) // negative case: + reqBody = fmt.Sprintf(`{"ms": %d}`, 2*timeout.Milliseconds()) t.Run("over time limit", func(t *testing.T) { - reqBody := fmt.Sprintf(`{"ms": %d}`, 2*timeout) response := rt.SendAdminRequest("POST", "/db/_function/sleep", reqBody) assert.Equal(t, 500, response.Result().StatusCode) }) diff --git a/rest/handler.go b/rest/handler.go index 3f30b4bd85..7e8edc0017 100644 --- a/rest/handler.go +++ b/rest/handler.go @@ -1,4 +1,4 @@ -// Copyright 2012-Present Couchbase, Inc. +/// Copyright 2012-Present Couchbase, Inc. // // Use of this software is governed by the Business Source License included // in the file licenses/BSL-Couchbase.txt. As of the Change Date specified @@ -100,7 +100,8 @@ type handler struct { serialNumber uint64 formattedSerialNumber string loggedDuration bool - runOffline bool + runOffline bool // allows running on an offline database + allowNilDBContext bool // allow acceess to a database based only on name, looking up in metadata registry queryValues url.Values // Copy of results of rq.URL.Query() permissionsResults map[string]bool authScopeFunc authScopeFunc @@ -123,8 +124,7 @@ type handlerMethod func(*handler) error // Creates an http.Handler that will run a handler with the given method func makeHandler(server *ServerContext, privs handlerPrivs, accessPermissions []Permission, responsePermissions []Permission, method handlerMethod) http.Handler { return http.HandlerFunc(func(r http.ResponseWriter, rq *http.Request) { - runOffline := false - h := newHandler(server, privs, r, rq, runOffline) + h := newHandler(server, privs, r, rq, handlerOptions{}) err := h.invoke(method, accessPermissions, responsePermissions) h.writeError(err) h.logDuration(true) @@ -134,8 +134,24 @@ func makeHandler(server *ServerContext, privs handlerPrivs, accessPermissions [] // Creates an http.Handler that will run a handler with the given method even if the target DB is offline func makeOfflineHandler(server *ServerContext, privs handlerPrivs, accessPermissions []Permission, responsePermissions []Permission, method handlerMethod) http.Handler { return http.HandlerFunc(func(r http.ResponseWriter, rq *http.Request) { - runOffline := true - h := newHandler(server, privs, r, rq, runOffline) + options := handlerOptions{ + runOffline: true, + } + h := newHandler(server, privs, r, rq, options) + err := h.invoke(method, accessPermissions, responsePermissions) + h.writeError(err) + h.logDuration(true) + }) +} + +// makeMetadataDBOfflineHandler creates an http.Handler that will run a handler with the given method even if the target DB is not able to be instantiated +func makeMetadataDBOfflineHandler(server *ServerContext, privs handlerPrivs, accessPermissions []Permission, responsePermissions []Permission, method handlerMethod) http.Handler { + return http.HandlerFunc(func(r http.ResponseWriter, rq *http.Request) { + options := handlerOptions{ + runOffline: true, + allowNilDBContext: true, + } + h := newHandler(server, privs, r, rq, options) err := h.invoke(method, accessPermissions, responsePermissions) h.writeError(err) h.logDuration(true) @@ -146,8 +162,7 @@ func makeOfflineHandler(server *ServerContext, privs handlerPrivs, accessPermiss // given the endpoint payload returns an auth scope. func makeHandlerSpecificAuthScope(server *ServerContext, privs handlerPrivs, accessPermissions []Permission, responsePermissions []Permission, method handlerMethod, dbAuthStringFunc func([]byte) (string, error)) http.Handler { return http.HandlerFunc(func(r http.ResponseWriter, rq *http.Request) { - runOffline := false - h := newHandler(server, privs, r, rq, runOffline) + h := newHandler(server, privs, r, rq, handlerOptions{}) h.authScopeFunc = dbAuthStringFunc err := h.invoke(method, accessPermissions, responsePermissions) h.writeError(err) @@ -155,16 +170,22 @@ func makeHandlerSpecificAuthScope(server *ServerContext, privs handlerPrivs, acc }) } -func newHandler(server *ServerContext, privs handlerPrivs, r http.ResponseWriter, rq *http.Request, runOffline bool) *handler { +type handlerOptions struct { + runOffline bool // if true, allow handler to run when a database is offline + allowNilDBContext bool // if true, allow a db-scoped handler to be invoked with a nil dbContext in cases where the database config exists but has an error preventing dbContext initialization" +} + +func newHandler(server *ServerContext, privs handlerPrivs, r http.ResponseWriter, rq *http.Request, options handlerOptions) *handler { h := &handler{ - server: server, - privs: privs, - rq: rq, - response: r, - status: http.StatusOK, - serialNumber: atomic.AddUint64(&lastSerialNum, 1), - startTime: time.Now(), - runOffline: runOffline, + server: server, + privs: privs, + rq: rq, + response: r, + status: http.StatusOK, + serialNumber: atomic.AddUint64(&lastSerialNum, 1), + startTime: time.Now(), + runOffline: options.runOffline, + allowNilDBContext: options.allowNilDBContext, } // initialize h.rqCtx @@ -300,13 +321,14 @@ func (h *handler) validateAndWriteHeaders(method handlerMethod, accessPermission var dbContext *db.DatabaseContext + var bucketName string + // look up the database context: if keyspaceDb != "" { h.addDatabaseLogContext(keyspaceDb) var err error if dbContext, err = h.server.GetActiveDatabase(keyspaceDb); err != nil { if err == base.ErrNotFound { - if shouldCheckAdminAuth { // Check if authenticated before attempting to get inactive database authorized, err := h.checkAdminAuthenticationOnly() @@ -317,10 +339,11 @@ func (h *handler) validateAndWriteHeaders(method handlerMethod, accessPermission return ErrInvalidLogin } } - dbContext, err = h.server.GetInactiveDatabase(h.ctx(), keyspaceDb) + var dbConfigFound bool + dbContext, dbConfigFound, err = h.server.GetInactiveDatabase(h.ctx(), keyspaceDb) if err != nil { if httpError, ok := err.(*base.HTTPError); ok && httpError.Status == http.StatusNotFound { - if shouldCheckAdminAuth { + if shouldCheckAdminAuth && (!h.allowNilDBContext || !dbConfigFound) { return base.HTTPErrorf(http.StatusForbidden, "") } else if h.privs == regularPrivs || h.privs == publicPrivs { if !h.providedAuthCredentials() { @@ -330,8 +353,11 @@ func (h *handler) validateAndWriteHeaders(method handlerMethod, accessPermission return ErrInvalidLogin } } - base.InfofCtx(h.ctx(), base.KeyHTTP, "Error trying to get db %s: %v", base.MD(keyspaceDb), err) - return err + if !h.allowNilDBContext || !dbConfigFound { + base.InfofCtx(h.ctx(), base.KeyHTTP, "Error trying to get db %s: %v", base.MD(keyspaceDb), err) + return err + } + bucketName, _ = h.server.bucketNameFromDbName(keyspaceDb) } } else { return err @@ -398,7 +424,6 @@ func (h *handler) validateAndWriteHeaders(method handlerMethod, accessPermission } } } - if shouldCheckAdminAuth { // If server is walrus but auth is enabled we should just kick the user out as invalid as we have nothing to // validate credentials against @@ -425,13 +450,12 @@ func (h *handler) validateAndWriteHeaders(method handlerMethod, accessPermission authScope = dbContext.Bucket.GetName() } else { managementEndpoints, httpClient, err = h.server.ObtainManagementEndpointsAndHTTPClient() - authScope = "" + authScope = bucketName } if err != nil { base.WarnfCtx(h.ctx(), "An error occurred whilst obtaining management endpoints: %v", err) return base.HTTPErrorf(http.StatusInternalServerError, "") } - if h.authScopeFunc != nil { body, err := h.readBody() if err != nil { diff --git a/rest/persistent_config_test.go b/rest/persistent_config_test.go index 663082616e..4b5e69f4a2 100644 --- a/rest/persistent_config_test.go +++ b/rest/persistent_config_test.go @@ -389,7 +389,7 @@ func TestImportFilterEndpoint(t *testing.T) { resp.RequireStatus(http.StatusOK) // Modify the import filter to always reject import - resp = BootstrapAdminRequest(t, http.MethodPut, "/db1/_config/import_filter", `function(){return false}`) + resp = BootstrapAdminRequest(t, http.MethodPut, "/db1/_config/import_filter", `function(doc){return false}`) resp.RequireStatus(http.StatusOK) // Add a document diff --git a/rest/replicatortest/replicator_test.go b/rest/replicatortest/replicator_test.go index 6b05397154..00be55a832 100644 --- a/rest/replicatortest/replicator_test.go +++ b/rest/replicatortest/replicator_test.go @@ -545,6 +545,147 @@ func TestPullReplicationAPI(t *testing.T) { assert.Equal(t, "rt2", doc2Body["source"]) } +func TestStopServerlessConnectionLimitingDuringReplications(t *testing.T) { + base.RequireNumTestBuckets(t, 2) + base.SetUpTestLogging(t, base.LevelInfo, base.KeyReplicate, base.KeyHTTP, base.KeyHTTPResp, base.KeySync, base.KeySyncMsg) + + rt1, rt2, remoteURLString, teardown := rest.SetupSGRPeers(t) + defer teardown() + + resp := rt2.SendAdminRequest(http.MethodPut, "/_config", `{"max_concurrent_replications" : 2}`) + rest.RequireStatus(t, resp, http.StatusOK) + + for i := 0; i < 10; i++ { + _ = rt2.PutDoc(fmt.Sprint(i), `{"source":"rt2","channels":["alice"]}`) + } + + // create two replications to take us to the limit + replicationID := t.Name() + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, true, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateRunning) + replicationID = t.Name() + "1" + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, true, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateRunning) + rt1.WaitForActiveReplicatorInitialization(2) + + // try create a new replication to take it beyond the threshold set by runtime config call + // assert it enter error state + replicationID = t.Name() + "2" + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, true, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateError) + + // change limit to 0 (turning limiting off) and assert that the replications currently running continue as normal and reject any new ones being added + resp = rt2.SendAdminRequest(http.MethodPut, "/_config", `{"max_concurrent_replications" : 0}`) + rest.RequireStatus(t, resp, http.StatusOK) + + // assert the replications aren't killed as result of change in limit + rt2.WaitForActiveReplicatorCount(2) + // assert we still can create a new replication given that originally the limit was 2 replications + replicationID = t.Name() + "3" + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, true, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateRunning) + +} + +func TestServerlessConnectionLimitingOneshotFeed(t *testing.T) { + base.RequireNumTestBuckets(t, 2) + base.SetUpTestLogging(t, base.LevelInfo, base.KeyReplicate, base.KeyHTTP, base.KeyHTTPResp, base.KeySync, base.KeySyncMsg) + + rt1, rt2, remoteURLString, teardown := rest.SetupSGRPeers(t) + defer teardown() + + // update runtime config to limit to 2 concurrent replication connections + resp := rt2.SendAdminRequest(http.MethodPut, "/_config", `{"max_concurrent_replications" : 2}`) + rest.RequireStatus(t, resp, http.StatusOK) + + for i := 0; i < 200; i++ { + _ = rt2.PutDoc(fmt.Sprint(i), `{"source":"rt2","channels":["alice"]}`) + } + + replicationID := t.Name() + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, false, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateRunning) + replicationID = t.Name() + "1" + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, false, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateRunning) + + rt1.WaitForActiveReplicatorInitialization(2) + // assert the active replicator count has increased by 2 + rt2.WaitForActiveReplicatorCount(2) + replicationID = t.Name() + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateStopped) + replicationID = t.Name() + "1" + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateStopped) + + // assert that the count for active replicators has decreased by 2 as both replications have finished + rt2.WaitForActiveReplicatorCount(0) + + // assert we can create a new replication as count has decreased below threshold + replicationID = t.Name() + "2" + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, false, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateRunning) + +} + +func TestServerlessConnectionLimitingContinuous(t *testing.T) { + base.RequireNumTestBuckets(t, 2) + base.SetUpTestLogging(t, base.LevelInfo, base.KeyReplicate, base.KeyHTTP, base.KeyHTTPResp, base.KeySync, base.KeySyncMsg) + + rt1, rt2, remoteURLString, teardown := rest.SetupSGRPeers(t) + defer teardown() + + // update runtime config to limit to 2 concurrent replication connections + resp := rt2.SendAdminRequest(http.MethodPut, "/_config", `{"max_concurrent_replications" : 2}`) + rest.RequireStatus(t, resp, http.StatusOK) + + for i := 0; i < 200; i++ { + _ = rt2.PutDoc(fmt.Sprint(i), `{"source":"rt2","channels":["alice"]}`) + } + + // create two replications to take us to the limit + replicationID := t.Name() + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, true, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateRunning) + replicationID = t.Name() + "1" + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, true, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateRunning) + rt1.WaitForActiveReplicatorInitialization(2) + + // try create a new replication to take it beyond the threshold set by runtime config call + // assert it enter error state + replicationID = t.Name() + "2" + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, true, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateError) + + // assert on stats + dbstats := rt2.GetDatabase().DbStats + assert.Equal(t, int64(2), dbstats.DatabaseStats.NumReplicationsRejectedLimit.Value()) + + // change limit to 1 and assert that the replications currently running continue as normal and reject any new ones being added + resp = rt2.SendAdminRequest(http.MethodPut, "/_config", `{"max_concurrent_replications" : 1}`) + rest.RequireStatus(t, resp, http.StatusOK) + + // assert the replications aren't killed as result of change in limit + rt2.WaitForActiveReplicatorCount(2) + // assert we still can't create a new replication + replicationID = t.Name() + "3" + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, true, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateError) + + // stop one of the replicators currently running + resp = rt1.SendAdminRequest(http.MethodPut, "/{{.db}}/_replicationStatus/"+t.Name()+"1?action=stop", "") + rest.RequireStatus(t, resp, http.StatusOK) + rt1.WaitForReplicationStatus(t.Name()+"1", db.ReplicationStateStopped) + // assert the count has been decremented + rt2.WaitForActiveReplicatorCount(1) + + // assert we still can't create new replication (new limit is 1) + replicationID = t.Name() + "4" + rt1.CreateReplication(replicationID, remoteURLString, db.ActiveReplicatorTypePull, nil, true, db.ConflictResolverDefault) + rt1.WaitForReplicationStatus(replicationID, db.ReplicationStateError) + +} + // TestPullReplicationAPI // - Starts 2 RestTesters, one active, and one passive. // - Creates a continuous pull replication on rt1 via the REST API @@ -640,7 +781,8 @@ func TestReplicationStatusActions(t *testing.T) { } -func TestStatusAfterReplicationRebalanceFail(t *testing.T) { +// TestReplicationRebalanceToZeroNodes checks that the replication goes into an unassigned state when there are no nodes available to run replications. +func TestReplicationRebalanceToZeroNodes(t *testing.T) { base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) activeRT, remoteRT, _, teardown := rest.SetupSGRPeers(t) defer teardown() @@ -1759,8 +1901,8 @@ func TestDBReplicationStatsTeardown(t *testing.T) { // If CE, recreate the replication if !base.IsEnterpriseEdition() { - rt.CreateReplication("repl1", db2Url.String(), db.ActiveReplicatorTypePush, nil, true, db.ConflictResolverDefault) - rt.WaitForReplicationStatus("repl1", db.ReplicationStateRunning) + rt.CreateReplicationForDB("{{.db1}}", "repl1", db2Url.String(), db.ActiveReplicatorTypePush, nil, true, db.ConflictResolverDefault) + rt.WaitForReplicationStatusForDB("{{.db1}}", "repl1", db.ReplicationStateRunning) } // Wait for second document to replicate to confirm replication restart @@ -2025,8 +2167,7 @@ func TestActiveReplicatorPullBasic(t *testing.T) { assert.Equal(t, revID, doc.SyncData.CurrentRev) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt2", body["source"]) assert.Equal(t, strconv.FormatUint(remoteDoc.Sequence, 10), ar.GetStatus().LastSeqPull) @@ -2274,8 +2415,7 @@ func TestActiveReplicatorPullAttachments(t *testing.T) { assert.NoError(t, err) assert.Equal(t, revID, doc.SyncData.CurrentRev) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt2", body["source"]) assert.Equal(t, int64(1), ar.Pull.GetStats().GetAttachment.Value()) @@ -2296,8 +2436,7 @@ func TestActiveReplicatorPullAttachments(t *testing.T) { assert.Equal(t, revID, doc2.SyncData.CurrentRev) - body, err = doc.GetDeepMutableBody() - require.NoError(t, err) + body = doc.Body() assert.Equal(t, "rt2", body["source"]) // When targeting a Hydrogen node that supports proveAttachments, we typically end up sending @@ -2597,8 +2736,7 @@ func TestActiveReplicatorPullFromCheckpoint(t *testing.T) { doc, err := rt1.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) assert.NoError(t, err) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt2", body["source"]) } @@ -2657,8 +2795,7 @@ func TestActiveReplicatorPullFromCheckpoint(t *testing.T) { doc, err := rt1.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) assert.NoError(t, err) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt2", body["source"]) } @@ -2929,8 +3066,7 @@ func TestActiveReplicatorPullOneshot(t *testing.T) { assert.Equal(t, revID, doc.SyncData.CurrentRev) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt2", body["source"]) assert.Equal(t, strconv.FormatUint(remoteDoc.Sequence, 10), ar.GetStatus().LastSeqPull) */ @@ -3010,8 +3146,7 @@ func TestActiveReplicatorPushBasic(t *testing.T) { assert.Equal(t, revID, doc.SyncData.CurrentRev) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt1", body["source"]) assert.Equal(t, strconv.FormatUint(localDoc.Sequence, 10), ar.GetStatus().LastSeqPush) @@ -3093,8 +3228,7 @@ func TestActiveReplicatorPushAttachments(t *testing.T) { assert.Equal(t, revID, doc.SyncData.CurrentRev) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt1", body["source"]) assert.Equal(t, int64(1), ar.Push.GetStats().HandleGetAttachment.Value()) @@ -3115,8 +3249,7 @@ func TestActiveReplicatorPushAttachments(t *testing.T) { assert.Equal(t, revID, doc2.SyncData.CurrentRev) - body, err = doc.GetDeepMutableBody() - require.NoError(t, err) + body = doc.Body() assert.Equal(t, "rt1", body["source"]) // When targeting a Hydrogen node that supports proveAttachments, we typically end up sending @@ -3213,8 +3346,7 @@ func TestActiveReplicatorPushFromCheckpoint(t *testing.T) { doc, err := rt1.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) assert.NoError(t, err) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt1", body["source"]) } @@ -3274,8 +3406,7 @@ func TestActiveReplicatorPushFromCheckpoint(t *testing.T) { doc, err := rt2.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) assert.NoError(t, err) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt1", body["source"]) } @@ -3389,8 +3520,7 @@ func TestActiveReplicatorEdgeCheckpointNameCollisions(t *testing.T) { doc, err := edge1.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) assert.NoError(t, err) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt1", body["source"]) } @@ -3569,8 +3699,7 @@ func TestActiveReplicatorPushOneshot(t *testing.T) { assert.Equal(t, revID, doc.SyncData.CurrentRev) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt1", body["source"]) assert.Equal(t, strconv.FormatUint(localDoc.Sequence, 10), ar.GetStatus().LastSeqPush) @@ -3656,8 +3785,7 @@ func TestActiveReplicatorPullTombstone(t *testing.T) { assert.Equal(t, revID, doc.SyncData.CurrentRev) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt2", body["source"]) // Tombstone the doc in rt2 @@ -3757,8 +3885,7 @@ func TestActiveReplicatorPullPurgeOnRemoval(t *testing.T) { assert.Equal(t, revID, doc.SyncData.CurrentRev) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt2", body["source"]) resp = rt2.SendAdminRequest(http.MethodPut, "/{{.keyspace}}/"+docID+"?rev="+revID, `{"source":"rt2","channels":["bob"]}`) @@ -3903,7 +4030,7 @@ func TestActiveReplicatorPullConflict(t *testing.T) { rt1revID := rest.RespRevID(t, resp) assert.Equal(t, test.localRevID, rt1revID) - customConflictResolver, err := db.NewCustomConflictResolver(test.conflictResolver, rt1.GetDatabase().Options.JavascriptTimeout) + customConflictResolver, err := db.NewCustomConflictResolver(test.conflictResolver, rt1.GetDatabase().Options.JavascriptTimeout, &rt1.GetDatabase().JS) require.NoError(t, err) stats, err := base.SyncGatewayStats.NewDBStats(t.Name(), false, false, false, nil, nil) require.NoError(t, err) @@ -4137,7 +4264,7 @@ func TestActiveReplicatorPushAndPullConflict(t *testing.T) { localDoc, err := rt1.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalSync) require.NoError(t, err) - customConflictResolver, err := db.NewCustomConflictResolver(test.conflictResolver, rt1.GetDatabase().Options.JavascriptTimeout) + customConflictResolver, err := db.NewCustomConflictResolver(test.conflictResolver, rt1.GetDatabase().Options.JavascriptTimeout, &rt1.GetDatabase().JS) require.NoError(t, err) stats, err := base.SyncGatewayStats.NewDBStats(t.Name(), false, false, false, nil, nil) @@ -4321,8 +4448,7 @@ func TestActiveReplicatorPushBasicWithInsecureSkipVerifyEnabled(t *testing.T) { assert.Equal(t, revID, doc.SyncData.CurrentRev) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt1", body["source"]) } @@ -4460,8 +4586,7 @@ func TestActiveReplicatorRecoverFromLocalFlush(t *testing.T) { doc, err := rt1.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) assert.NoError(t, err) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt2", body["source"]) // one _changes from seq:0 with initial number of docs sent @@ -4519,8 +4644,7 @@ func TestActiveReplicatorRecoverFromLocalFlush(t *testing.T) { doc, err = rt1.GetSingleTestDatabaseCollectionWithUser().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) require.NoError(t, err) - body, err = doc.GetDeepMutableBody() - require.NoError(t, err) + body = doc.Body() assert.Equal(t, "rt2", body["source"]) // one _changes from seq:0 with initial number of docs sent @@ -4621,8 +4745,7 @@ func TestActiveReplicatorRecoverFromRemoteFlush(t *testing.T) { doc, err := rt2.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) assert.NoError(t, err) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt1", body["source"]) // one _changes from seq:0 with initial number of docs sent @@ -4688,8 +4811,7 @@ func TestActiveReplicatorRecoverFromRemoteFlush(t *testing.T) { doc, err = rt2.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) require.NoError(t, err) - body, err = doc.GetDeepMutableBody() - require.NoError(t, err) + body = doc.Body() assert.Equal(t, "rt1", body["source"]) // one _changes from seq:0 with initial number of docs sent @@ -4798,8 +4920,7 @@ func TestActiveReplicatorRecoverFromRemoteRollback(t *testing.T) { doc, err := rt1.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) assert.NoError(t, err) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt1", body["source"]) // Since we bumped the checkpointer interval, we're only setting checkpoints on replicator close. @@ -4833,8 +4954,7 @@ func TestActiveReplicatorRecoverFromRemoteRollback(t *testing.T) { doc, err = rt2.GetSingleTestDatabaseCollection().GetDocument(ctx2, docID, db.DocUnmarshalAll) require.NoError(t, err) - body, err = doc.GetDeepMutableBody() - require.NoError(t, err) + body = doc.Body() assert.Equal(t, "rt1", body["source"]) assert.Equal(t, int64(1), pushCheckpointer.Stats().SetCheckpointCount) @@ -4867,8 +4987,7 @@ func TestActiveReplicatorRecoverFromRemoteRollback(t *testing.T) { doc, err = rt2collection.GetDocument(ctx2, docID, db.DocUnmarshalAll) require.NoError(t, err) - body, err = doc.GetDeepMutableBody() - require.NoError(t, err) + body = doc.Body() assert.Equal(t, "rt1", body["source"]) assert.Equal(t, int64(0), pushCheckpointer.Stats().SetCheckpointCount) @@ -5068,8 +5187,7 @@ func TestActiveReplicatorIgnoreNoConflicts(t *testing.T) { assert.Equal(t, rt1revID, doc.SyncData.CurrentRev) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt1", body["source"]) // write a doc on rt2 ... @@ -5090,8 +5208,7 @@ func TestActiveReplicatorIgnoreNoConflicts(t *testing.T) { assert.Equal(t, rt2revID, doc.SyncData.CurrentRev) - body, err = doc.GetDeepMutableBody() - require.NoError(t, err) + body = doc.Body() assert.Equal(t, "rt2", body["source"]) } @@ -5248,8 +5365,7 @@ func TestActiveReplicatorPullModifiedHash(t *testing.T) { doc, err := rt1.GetSingleTestDatabaseCollection().GetDocument(base.TestCtx(t), docID, db.DocUnmarshalAll) assert.NoError(t, err) - body, err := doc.GetDeepMutableBody() - require.NoError(t, err) + body := doc.Body() assert.Equal(t, "rt2", body["source"]) } @@ -5826,7 +5942,7 @@ func TestActiveReplicatorPullConflictReadWriteIntlProps(t *testing.T) { rt1revID := rest.RespRevID(t, resp) assert.Equal(t, test.localRevID, rt1revID) - customConflictResolver, err := db.NewCustomConflictResolver(test.conflictResolver, rt1.GetDatabase().Options.JavascriptTimeout) + customConflictResolver, err := db.NewCustomConflictResolver(test.conflictResolver, rt1.GetDatabase().Options.JavascriptTimeout, &rt1.GetDatabase().JS) require.NoError(t, err) dbstats, err := base.SyncGatewayStats.NewDBStats(t.Name(), false, false, false, nil, nil) require.NoError(t, err) @@ -6287,7 +6403,7 @@ func TestDefaultConflictResolverWithTombstoneLocal(t *testing.T) { ctx1 := rt1.Context() defaultConflictResolver, err := db.NewCustomConflictResolver( - `function(conflict) { return defaultPolicy(conflict); }`, rt1.GetDatabase().Options.JavascriptTimeout) + `function(conflict) { return defaultPolicy(conflict); }`, rt1.GetDatabase().Options.JavascriptTimeout, &rt1.GetDatabase().JS) require.NoError(t, err, "Error creating custom conflict resolver") sgwStats, err := base.SyncGatewayStats.NewDBStats(t.Name(), false, false, false, nil, nil) require.NoError(t, err) @@ -6442,7 +6558,7 @@ func TestDefaultConflictResolverWithTombstoneRemote(t *testing.T) { ctx1 := rt1.Context() defaultConflictResolver, err := db.NewCustomConflictResolver( - `function(conflict) { return defaultPolicy(conflict); }`, rt1.GetDatabase().Options.JavascriptTimeout) + `function(conflict) { return defaultPolicy(conflict); }`, rt1.GetDatabase().Options.JavascriptTimeout, &rt1.GetDatabase().JS) require.NoError(t, err, "Error creating custom conflict resolver") sgwStats, err := base.SyncGatewayStats.NewDBStats(t.Name(), false, false, false, nil, nil) require.NoError(t, err) @@ -6946,7 +7062,7 @@ func TestConflictResolveMergeWithMutatedRev(t *testing.T) { mutatedLocal["_deleted"] = true; mutatedLocal["_rev"] = ""; return mutatedLocal; - }`, rt1.GetDatabase().Options.JavascriptTimeout) + }`, rt1.GetDatabase().Options.JavascriptTimeout, &rt1.GetDatabase().JS) require.NoError(t, err) sgwStats, err := base.SyncGatewayStats.NewDBStats(t.Name(), false, false, false, nil, nil) diff --git a/rest/rest_tester_cluster_test.go b/rest/rest_tester_cluster_test.go index fa57e00e57..5addaf4991 100644 --- a/rest/rest_tester_cluster_test.go +++ b/rest/rest_tester_cluster_test.go @@ -100,9 +100,9 @@ func NewRestTesterCluster(t *testing.T, config *RestTesterClusterConfig) *RestTe // Set group ID for each RestTester from cluster if config.rtConfig == nil { - config.rtConfig = &RestTesterConfig{groupID: config.groupID} + config.rtConfig = &RestTesterConfig{GroupID: config.groupID} } else { - config.rtConfig.groupID = config.groupID + config.rtConfig.GroupID = config.groupID } // only persistent mode is supported for a RestTesterCluster config.rtConfig.PersistentConfig = true diff --git a/rest/revocation_test.go b/rest/revocation_test.go index bf0e50e2b5..c211cf39fc 100644 --- a/rest/revocation_test.go +++ b/rest/revocation_test.go @@ -159,22 +159,22 @@ func InitScenario(t *testing.T, rtConfig *RestTesterConfig) (ChannelRevocationTe defaultSyncFn := ` function (doc, oldDoc){ - if (doc._id === 'userRoles'){ + if (doc._id === 'userRoles'){ for (var key in doc.roles){ role(key, doc.roles[key]); } } - if (doc._id === 'roleChannels'){ + if (doc._id === 'roleChannels'){ for (var key in doc.channels){ access(key, doc.channels[key]); } } - if (doc._id === 'userChannels'){ + if (doc._id === 'userChannels'){ for (var key in doc.channels){ access(key, doc.channels[key]); } } - if (doc._id.indexOf("doc") >= 0){ + if (doc._id.indexOf("doc") >= 0){ channel(doc.channels); } }` @@ -1437,12 +1437,12 @@ func TestRevocationWithUserXattrs(t *testing.T) { }}, SyncFn: ` function (doc, oldDoc, meta){ - if (doc._id === 'accessDoc' && meta.xattrs.channelInfo !== undefined){ + if (doc._id === 'accessDoc' && meta.xattrs.channelInfo){ for (var key in meta.xattrs.channelInfo.userChannels){ access(key, meta.xattrs.channelInfo.userChannels[key]); } } - if (doc._id.indexOf("doc") >= 0){ + if (doc._id.indexOf("doc") >= 0){ channel(doc.channels); } }`, diff --git a/rest/routing.go b/rest/routing.go index 79a511b219..895c534643 100644 --- a/rest/routing.go +++ b/rest/routing.go @@ -327,7 +327,7 @@ func CreateAdminRouter(sc *ServerContext) *mux.Router { r.Handle("/{newdb:"+dbRegex+"}/", makeHandlerSpecificAuthScope(sc, adminPrivs, []Permission{PermCreateDb}, nil, (*handler).handleCreateDB, getAuthScopeHandleCreateDB)).Methods("PUT") r.Handle("/{db:"+dbRegex+"}/", - makeOfflineHandler(sc, adminPrivs, []Permission{PermDeleteDb}, nil, (*handler).handleDeleteDB)).Methods("DELETE") + makeMetadataDBOfflineHandler(sc, adminPrivs, []Permission{PermDeleteDb}, nil, (*handler).handleDeleteDB)).Methods("DELETE") r.Handle("/_all_dbs", makeHandler(sc, adminPrivs, []Permission{PermDevOps}, nil, (*handler).handleAllDbs)).Methods("GET", "HEAD") @@ -364,7 +364,7 @@ func wrapRouter(sc *ServerContext, privs handlerPrivs, router *mux.Router) http. router.ServeHTTP(response, rq) } else { // Log the request - h := newHandler(sc, privs, response, rq, false) + h := newHandler(sc, privs, response, rq, handlerOptions{}) h.logRequestLine() // Inject CORS if enabled and requested and not admin port diff --git a/rest/server_context.go b/rest/server_context.go index 483d7d5953..0e2d3d837e 100644 --- a/rest/server_context.go +++ b/rest/server_context.go @@ -41,6 +41,9 @@ const kStatsReportInterval = time.Hour const kDefaultSlowQueryWarningThreshold = 500 // ms const KDefaultNumShards = 16 +// defaultBlipStatsReportingInterval is the default interval when to report blip stats, at the end of a message handler. +const defaultBlipStatsReportingInterval = 30 * time.Second + var errCollectionsUnsupported = base.HTTPErrorf(http.StatusBadRequest, "Named collections specified in database config, but not supported by connected Couchbase Server.") var ErrSuspendingDisallowed = errors.New("database does not allow suspending") @@ -70,6 +73,13 @@ type ServerContext struct { LogContextID string // ID to differentiate log messages from different server context fetchConfigsLastUpdate time.Time // The last time fetchConfigsWithTTL() updated dbConfigs allowScopesInPersistentConfig bool // Test only backdoor to allow scopes in persistent config, not supported for multiple databases with different collections targeting the same bucket + ActiveReplicationsCounter +} + +type ActiveReplicationsCounter struct { + activeReplicatorCount int // The count of concurrent active replicators + activeReplicatorLimit int // The limit on number of active replicators allowed + lock sync.RWMutex // Lock for managing access to shared memory location } // defaultConfigRetryTimeout is the total retry time when waiting for in-flight config updates. Set as a multiple of kv op timeout, @@ -83,10 +93,19 @@ type bootstrapContext struct { doneChan chan struct{} // doneChan is closed when the bootstrap polling goroutine finishes. } +type getOrAddDatabaseConfigOptions struct { + failFast bool // if set, a failure to connect to a bucket of collection will immediately fail + useExisting bool // if true, return an existing DatabaseContext vs return an error + connectToBucketFn db.OpenBucketFn // supply a custom function for buckets, used for testing only +} + func (sc *ServerContext) CreateLocalDatabase(ctx context.Context, dbs DbConfigMap) error { for _, dbConfig := range dbs { dbc := dbConfig.ToDatabaseConfig() - _, err := sc._getOrAddDatabaseFromConfig(ctx, *dbc, false, db.GetConnectToBucketFn(false)) + _, err := sc._getOrAddDatabaseFromConfig(ctx, *dbc, getOrAddDatabaseConfigOptions{ + useExisting: false, + failFast: false, + }) if err != nil { return err } @@ -133,6 +152,9 @@ func NewServerContext(ctx context.Context, config *StartupConfig, persistentConf sc.Config.API.MetricsInterfaceAuthentication = base.BoolPtr(false) } } + if config.Replicator.MaxConcurrentReplications != 0 { + sc.ActiveReplicationsCounter.activeReplicatorLimit = config.Replicator.MaxConcurrentReplications + } sc.startStatsLogger(ctx) @@ -214,7 +236,8 @@ func (sc *ServerContext) Close(ctx context.Context) { func (sc *ServerContext) GetDatabase(ctx context.Context, name string) (*db.DatabaseContext, error) { dbc, err := sc.GetActiveDatabase(name) if err == base.ErrNotFound { - return sc.GetInactiveDatabase(ctx, name) + dbc, _, err := sc.GetInactiveDatabase(ctx, name) + return dbc, err } return dbc, err } @@ -235,35 +258,35 @@ func (sc *ServerContext) GetActiveDatabase(name string) (*db.DatabaseContext, er // GetInactiveDatabase attempts to load the database and return it's DatabaseContext. It will first attempt to unsuspend the // database, and if that fails, try to load the database from the buckets. -// This should be used if GetActiveDatabase fails. -func (sc *ServerContext) GetInactiveDatabase(ctx context.Context, name string) (*db.DatabaseContext, error) { +// This should be used if GetActiveDatabase fails. Turns the database context, a variable to say if the config exists, and an error. +func (sc *ServerContext) GetInactiveDatabase(ctx context.Context, name string) (*db.DatabaseContext, bool, error) { dbc, err := sc.unsuspendDatabase(ctx, name) if err != nil && err != base.ErrNotFound && err != ErrSuspendingDisallowed { - return nil, err + return nil, false, err } else if err == nil { - return dbc, nil + return dbc, true, nil } + var dbConfigFound bool // database not loaded, fallback to fetching it from cluster if sc.BootstrapContext.Connection != nil { - var found bool if sc.Config.IsServerless() { - found, _ = sc.fetchAndLoadDatabaseSince(ctx, name, sc.Config.Unsupported.Serverless.MinConfigFetchInterval) + dbConfigFound, _ = sc.fetchAndLoadDatabaseSince(ctx, name, sc.Config.Unsupported.Serverless.MinConfigFetchInterval) } else { - found, _ = sc.fetchAndLoadDatabase(base.NewNonCancelCtx(), name) + dbConfigFound, _ = sc.fetchAndLoadDatabase(base.NewNonCancelCtx(), name) } - if found { + if dbConfigFound { sc.lock.RLock() defer sc.lock.RUnlock() dbc := sc.databases_[name] if dbc != nil { - return dbc, nil + return dbc, dbConfigFound, nil } } } - return nil, base.HTTPErrorf(http.StatusNotFound, "no such database %q", name) + return nil, dbConfigFound, base.HTTPErrorf(http.StatusNotFound, "no such database %q", name) } func (sc *ServerContext) GetDbConfig(name string) *DbConfig { @@ -343,7 +366,9 @@ func (sc *ServerContext) PostUpgrade(ctx context.Context, preview bool) (postUpg func (sc *ServerContext) _reloadDatabase(ctx context.Context, reloadDbName string, failFast bool) (*db.DatabaseContext, error) { sc._unloadDatabase(ctx, reloadDbName) config := sc.dbConfigs[reloadDbName] - return sc._getOrAddDatabaseFromConfig(ctx, config.DatabaseConfig, true, db.GetConnectToBucketFn(failFast)) + return sc._getOrAddDatabaseFromConfig(ctx, config.DatabaseConfig, getOrAddDatabaseConfigOptions{ + useExisting: true, + failFast: failFast}) } // Removes and re-adds a database to the ServerContext. @@ -364,18 +389,21 @@ func (sc *ServerContext) ReloadDatabaseWithConfig(nonContextStruct base.NonCance func (sc *ServerContext) _reloadDatabaseWithConfig(ctx context.Context, config DatabaseConfig, failFast bool) error { sc._removeDatabase(ctx, config.Name) - _, err := sc._getOrAddDatabaseFromConfig(ctx, config, false, db.GetConnectToBucketFn(failFast)) + _, err := sc._getOrAddDatabaseFromConfig(ctx, config, getOrAddDatabaseConfigOptions{ + useExisting: false, + failFast: failFast, + }) return err } // Adds a database to the ServerContext. Attempts a read after it gets the write // lock to see if it's already been added by another process. If so, returns either the // existing DatabaseContext or an error based on the useExisting flag. -func (sc *ServerContext) getOrAddDatabaseFromConfig(ctx context.Context, config DatabaseConfig, useExisting bool, openBucketFn db.OpenBucketFn) (*db.DatabaseContext, error) { +func (sc *ServerContext) getOrAddDatabaseFromConfig(ctx context.Context, config DatabaseConfig, options getOrAddDatabaseConfigOptions) (*db.DatabaseContext, error) { // Obtain write lock during add database, to avoid race condition when creating based on ConfigServer sc.lock.Lock() defer sc.lock.Unlock() - return sc._getOrAddDatabaseFromConfig(ctx, config, useExisting, openBucketFn) + return sc._getOrAddDatabaseFromConfig(ctx, config, options) } func GetBucketSpec(ctx context.Context, config *DatabaseConfig, serverConfig *StartupConfig) (spec base.BucketSpec, err error) { @@ -419,8 +447,7 @@ func GetBucketSpec(ctx context.Context, config *DatabaseConfig, serverConfig *St // lock to see if it's already been added by another process. If so, returns either the // existing DatabaseContext or an error based on the useExisting flag. // Pass in a bucketFromBucketSpecFn to replace the default ConnectToBucket function. This will cause the failFast argument to be ignored -func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config DatabaseConfig, useExisting bool, openBucketFn db.OpenBucketFn) (*db.DatabaseContext, error) { - +func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config DatabaseConfig, options getOrAddDatabaseConfigOptions) (*db.DatabaseContext, error) { // Generate bucket spec and validate whether db already exists spec, err := GetBucketSpec(ctx, &config, sc.Config) if err != nil { @@ -454,7 +481,7 @@ func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config } if sc.databases_[dbName] != nil { - if useExisting { + if options.useExisting { return sc.databases_[dbName], nil } else { return nil, base.HTTPErrorf(http.StatusPreconditionFailed, // what CouchDB returns @@ -469,11 +496,18 @@ func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config // Connect to bucket base.InfofCtx(ctx, base.KeyAll, "Opening db /%s as bucket %q, pool %q, server <%s>", base.MD(dbName), base.MD(spec.BucketName), base.SD(base.DefaultPool), base.SD(spec.Server)) - bucket, err := openBucketFn(ctx, spec) + + // the connectToBucketFn is used for testing seam + var bucket base.Bucket + if options.connectToBucketFn != nil { + // the connectToBucketFn is used for testing seam + bucket, err = options.connectToBucketFn(ctx, spec, options.failFast) + } else { + bucket, err = db.ConnectToBucket(ctx, spec, options.failFast) + } if err != nil { return nil, err } - // If using a walrus bucket, force use of views useViews := base.BoolDefault(config.UseViews, false) if !useViews && spec.IsWalrusBucket() { @@ -544,10 +578,21 @@ func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config for scopeName, scopeConfig := range config.Scopes { for collectionName, _ := range scopeConfig.Collections { var dataStore sgbucket.DataStore - err := base.WaitForNoError(func() error { + + var err error + if options.failFast { dataStore, err = bucket.NamedDataStore(base.ScopeAndCollectionName{Scope: scopeName, Collection: collectionName}) - return err - }) + } else { + waitForCollection := func() (bool, error, interface{}) { + dataStore, err = bucket.NamedDataStore(base.ScopeAndCollectionName{Scope: scopeName, Collection: collectionName}) + return err != nil, err, nil + } + + err, _ = base.RetryLoop( + fmt.Sprintf("waiting for %s.%s.%s to exist", base.MD(bucket.GetName()), base.MD(scopeName), base.MD(collectionName)), + waitForCollection, + base.CreateMaxDoublingSleeperFunc(30, 10, 1000)) + } if err != nil { return nil, fmt.Errorf("error attempting to create/update database: %w", err) } @@ -643,8 +688,6 @@ func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config } contextOptions.UseViews = useViews - javascriptTimeout := getJavascriptTimeout(&config.DbConfig) - fqCollections := make([]string, 0) if len(config.Scopes) > 0 { if !sc.persistentConfig && !sc.allowScopesInPersistentConfig { @@ -656,23 +699,18 @@ func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config Collections: make(map[string]db.CollectionOptions, len(scopeCfg.Collections)), } for collName, collCfg := range scopeCfg.Collections { - var importFilter *db.ImportFilterFunction - if collCfg.ImportFilter != nil { - importFilter = db.NewImportFilterFunction(*collCfg.ImportFilter, javascriptTimeout) - } - contextOptions.Scopes[scopeName].Collections[collName] = db.CollectionOptions{ Sync: collCfg.SyncFn, - ImportFilter: importFilter, + ImportFilter: collCfg.ImportFilter, } fqCollections = append(fqCollections, base.FullyQualifiedCollectionName(spec.BucketName, scopeName, collName)) } } } else { // Set up default import filter - var importFilter *db.ImportFilterFunction + var importFilter *string if config.ImportFilter != nil { - importFilter = db.NewImportFilterFunction(*config.ImportFilter, javascriptTimeout) + importFilter = config.ImportFilter } contextOptions.Scopes = map[string]db.ScopeOptions{ @@ -704,6 +742,7 @@ func (sc *ServerContext) _getOrAddDatabaseFromConfig(ctx context.Context, config contextOptions.MetadataID = config.MetadataID } + contextOptions.BlipStatsReportingInterval = defaultBlipStatsReportingInterval.Milliseconds() // Create the DB Context dbcontext, err := db.NewDatabaseContext(ctx, dbName, bucket, autoImport, contextOptions) if err != nil { @@ -1034,26 +1073,17 @@ func dbcOptionsFromConfig(ctx context.Context, sc *ServerContext, config *DbConf ClientPartitionWindow: clientPartitionWindow, BcryptCost: bcryptCost, GroupID: groupID, + JavaScriptEngine: config.JavaScriptEngine, JavascriptTimeout: javascriptTimeout, Serverless: sc.Config.IsServerless(), - // UserQueries: config.UserQueries, // behind feature flag (see below) - // UserFunctions: config.UserFunctions, // behind feature flag (see below) - // GraphQL: config.GraphQL, // behind feature flag (see below) + ChangesRequestPlus: base.BoolDefault(config.ChangesRequestPlus, false), + // FunctionsConfig: // behind feature flag (see below) } if sc.Config.Unsupported.UserQueries != nil && *sc.Config.Unsupported.UserQueries { - var err error - if config.UserFunctions != nil { - contextOptions.UserFunctions, err = functions.CompileFunctions(*config.UserFunctions) - if err != nil { - return contextOptions, err - } - } - if config.GraphQL != nil { - contextOptions.GraphQL, err = functions.CompileGraphQL(config.GraphQL) - if err != nil { - return contextOptions, err - } + contextOptions.FunctionsConfig = &functions.Config{ + Functions: config.UserFunctions, + GraphQL: config.GraphQL, } } else if config.UserFunctions != nil || config.GraphQL != nil { base.WarnfCtx(context.TODO(), `Database config options "functions" and "graphql" ignored because unsupported.user_queries feature flag is not enabled`) @@ -1203,13 +1233,15 @@ func (sc *ServerContext) initEventHandlers(ctx context.Context, dbcontext *db.Da // Adds a database to the ServerContext given its configuration. If an existing config is found // for the name, returns an error. func (sc *ServerContext) AddDatabaseFromConfig(ctx context.Context, config DatabaseConfig) (*db.DatabaseContext, error) { - return sc.getOrAddDatabaseFromConfig(ctx, config, false, db.GetConnectToBucketFn(false)) + failFast := false + return sc.getOrAddDatabaseFromConfig(ctx, config, getOrAddDatabaseConfigOptions{useExisting: false, failFast: failFast}) } // AddDatabaseFromConfigFailFast adds a database to the ServerContext given its configuration and fails fast. // If an existing config is found for the name, returns an error. func (sc *ServerContext) AddDatabaseFromConfigFailFast(nonContextStruct base.NonCancellableContext, config DatabaseConfig) (*db.DatabaseContext, error) { - return sc.getOrAddDatabaseFromConfig(nonContextStruct.Ctx, config, false, db.GetConnectToBucketFn(true)) + failFast := true + return sc.getOrAddDatabaseFromConfig(nonContextStruct.Ctx, config, getOrAddDatabaseConfigOptions{useExisting: false, failFast: failFast}) } func (sc *ServerContext) processEventHandlersForEvent(ctx context.Context, events []*EventConfig, eventType db.EventType, dbcontext *db.DatabaseContext) error { @@ -1217,7 +1249,7 @@ func (sc *ServerContext) processEventHandlersForEvent(ctx context.Context, event for _, event := range events { switch event.HandlerType { case "webhook": - wh, err := db.NewWebhook(event.Url, event.Filter, event.Timeout, event.Options) + wh, err := db.NewWebhook(event.Url, event.Filter, &dbcontext.JS, event.Timeout, event.Options) if err != nil { base.WarnfCtx(ctx, "Error creating webhook %v", err) return err @@ -1335,7 +1367,10 @@ func (sc *ServerContext) _unsuspendDatabase(ctx context.Context, dbName string) return nil, fmt.Errorf("unsuspending db %q failed due to an error while trying to retrieve latest config from bucket %q: %w", base.MD(dbName).Redact(), base.MD(bucket).Redact(), err) } dbConfig.cfgCas = cas - dbCtx, err = sc._getOrAddDatabaseFromConfig(ctx, dbConfig.DatabaseConfig, false, db.GetConnectToBucketFn(false)) + failFast := false + dbCtx, err = sc._getOrAddDatabaseFromConfig(ctx, dbConfig.DatabaseConfig, getOrAddDatabaseConfigOptions{ + useExisting: false, + failFast: failFast}) if err != nil { return nil, err } @@ -1508,10 +1543,17 @@ func initClusterAgent(ctx context.Context, clusterAddress, clusterUser, clusterP }, } + base.DebugfCtx(ctx, base.KeyAll, "Parsing cluster connection string %q", base.UD(clusterAddress)) + beforeFromConnStr := time.Now() err = config.FromConnStr(clusterAddress) if err != nil { return nil, err } + if d := time.Since(beforeFromConnStr); d > base.FromConnStrWarningThreshold { + base.WarnfCtx(ctx, "Parsed cluster connection string %q in: %v", base.UD(clusterAddress), d) + } else { + base.DebugfCtx(ctx, base.KeyAll, "Parsed cluster connection string %q in: %v", base.UD(clusterAddress), d) + } agent, err := gocbcore.CreateAgent(&config) if err != nil { @@ -1822,10 +1864,10 @@ func (sc *ServerContext) Database(ctx context.Context, name string) *db.Database return db } -func (sc *ServerContext) initializeCouchbaseServerConnections(ctx context.Context) error { - base.InfofCtx(ctx, base.KeyAll, "initializing server connections") +func (sc *ServerContext) initializeCouchbaseServerConnections(ctx context.Context, failFast bool) error { + base.InfofCtx(ctx, base.KeyAll, "Initializing server connections") defer func() { - base.InfofCtx(ctx, base.KeyAll, "finished initializing server connections") + base.InfofCtx(ctx, base.KeyAll, "Finished initializing server connections") }() goCBAgent, err := sc.initializeGoCBAgent(ctx) if err != nil { diff --git a/rest/server_context_test.go b/rest/server_context_test.go index 03a1224b6e..210c4e9129 100644 --- a/rest/server_context_test.go +++ b/rest/server_context_test.go @@ -22,7 +22,6 @@ import ( "time" "github.com/couchbase/sync_gateway/auth" - "github.com/couchbase/sync_gateway/db" "github.com/couchbase/gocbcore/v10/connstr" sgbucket "github.com/couchbase/sg-bucket" @@ -168,7 +167,7 @@ func TestGetOrAddDatabaseFromConfig(t *testing.T) { // Get or add database name from config without valid database name; throws 400 Illegal database name error dbConfig := DbConfig{OldRevExpirySeconds: &oldRevExpirySeconds, LocalDocExpirySecs: &localDocExpirySecs} - dbContext, err := serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, false, db.GetConnectToBucketFn(false)) + dbContext, err := serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, getOrAddDatabaseConfigOptions{useExisting: false, failFast: false}) assert.Nil(t, dbContext, "Can't create database context without a valid database name") assert.Error(t, err, "It should throw 400 Illegal database name") assert.Contains(t, err.Error(), strconv.Itoa(http.StatusBadRequest)) @@ -187,7 +186,10 @@ func TestGetOrAddDatabaseFromConfig(t *testing.T) { BucketConfig: BucketConfig{Server: &server, Bucket: &bucketName}, } - dbContext, err = serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, false, db.GetConnectToBucketFn(false)) + dbContext, err = serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, getOrAddDatabaseConfigOptions{ + failFast: false, + useExisting: false, + }) assert.Nil(t, dbContext, "Can't create database context from config with unrecognized value for import_docs") assert.Error(t, err, "It should throw Unrecognized value for import_docs") @@ -214,14 +216,22 @@ func TestGetOrAddDatabaseFromConfig(t *testing.T) { AutoImport: false, } - dbContext, err = serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, false, db.GetConnectToBucketFn(false)) + dbContext, err = serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, getOrAddDatabaseConfigOptions{ + failFast: false, + useExisting: false, + }) assert.Nil(t, dbContext, "Can't create database context with duplicate database name") assert.Error(t, err, "It should throw 412 Duplicate database names") assert.Contains(t, err.Error(), strconv.Itoa(http.StatusPreconditionFailed)) // Get or add database from config with duplicate database name and useExisting as true // Existing database context should be returned - dbContext, err = serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, true, db.GetConnectToBucketFn(false)) + dbContext, err = serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, + getOrAddDatabaseConfigOptions{ + failFast: false, + useExisting: true, + }) + assert.NoError(t, err, "No error while trying to get the existing database name") assert.Equal(t, server, dbContext.BucketSpec.Server) assert.Equal(t, bucketName, dbContext.BucketSpec.BucketName) @@ -615,7 +625,12 @@ func TestServerContextSetupCollectionsSupport(t *testing.T) { }, }, } - _, err := serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, false, db.GetConnectToBucketFn(true)) + _, err := serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, + getOrAddDatabaseConfigOptions{ + failFast: false, + useExisting: false, + }) + require.ErrorIs(t, err, errCollectionsUnsupported) } @@ -790,7 +805,11 @@ func TestDisableScopesInLegacyConfig(t *testing.T) { } dbConfig.Scopes = GetCollectionsConfigWithSyncFn(t, bucket, nil, 1) } - dbContext, err := serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, false, db.GetConnectToBucketFn(false)) + dbContext, err := serverContext._getOrAddDatabaseFromConfig(ctx, DatabaseConfig{DbConfig: dbConfig}, + getOrAddDatabaseConfigOptions{ + failFast: false, + useExisting: false, + }) if persistentConfig || scopes == false { require.NoError(t, err) require.NotNil(t, dbContext) diff --git a/rest/serverless_test.go b/rest/serverless_test.go index cfd0c49376..23ab48c109 100644 --- a/rest/serverless_test.go +++ b/rest/serverless_test.go @@ -51,7 +51,7 @@ func TestServerlessPollBuckets(t *testing.T) { assert.Empty(t, configs) // Create a database - rt2 := NewRestTester(t, &RestTesterConfig{CustomTestBucket: tb1.NoCloseClone(), PersistentConfig: true, groupID: &sc.Config.Bootstrap.ConfigGroupID}) + rt2 := NewRestTester(t, &RestTesterConfig{CustomTestBucket: tb1.NoCloseClone(), PersistentConfig: true, GroupID: &sc.Config.Bootstrap.ConfigGroupID}) defer rt2.Close() // Create a new db on the RT to confirm fetch won't retrieve it (due to bucket not being in BucketCredentials) resp := rt2.SendAdminRequest(http.MethodPut, "/db/", fmt.Sprintf(`{ diff --git a/rest/upgradetest/remove_collection_test.go b/rest/upgradetest/remove_collection_test.go new file mode 100644 index 0000000000..ca090396ae --- /dev/null +++ b/rest/upgradetest/remove_collection_test.go @@ -0,0 +1,112 @@ +// Copyright 2023-Present Couchbase, Inc. +// +// Use of this software is governed by the Business Source License included +// in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +// in that file, in accordance with the Business Source License, use of this +// software will be governed by the Apache License, Version 2.0, included in +// the file licenses/APL2.txt. + +package upgradetest + +import ( + "fmt" + "net/http" + "testing" + + "github.com/couchbase/sync_gateway/base" + "github.com/couchbase/sync_gateway/rest" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// TestRemoveCollection tests when a collection has been removed from CBS, and the server is restarted. We should be able to modify or delete the database. +func TestRemoveCollection(t *testing.T) { + if base.UnitTestUrlIsWalrus() { + t.Skip("test relies on bootstrap connection and needs CBS") + } + base.TestRequiresCollections(t) + base.RequireNumTestBuckets(t, 2) + numCollections := 2 + bucket := base.GetPersistentTestBucket(t) + defer bucket.Close() + base.RequireNumTestDataStores(t, numCollections) + rtConfig := &rest.RestTesterConfig{ + CustomTestBucket: bucket.NoCloseClone(), + PersistentConfig: true, + GroupID: base.StringPtr(t.Name()), + AdminInterfaceAuthentication: true, + } + rt := rest.NewRestTesterMultipleCollections(t, rtConfig, 2) + + dbConfig := rt.NewDbConfig() + dbConfig.Scopes = rest.GetCollectionsConfig(t, rt.TestBucket, numCollections) + + dbName := "removecollectiondb" + + dbcJSON, err := base.JSONMarshal(dbConfig) + require.NoError(t, err) + resp := rt.SendAdminRequestWithAuth(http.MethodPut, "/"+dbName+"/", string(dbcJSON), base.TestClusterUsername(), base.TestClusterPassword()) + rest.RequireStatus(t, resp, http.StatusCreated) + + dataStores := rt.TestBucket.GetNonDefaultDatastoreNames() + deletedDataStore := dataStores[1] + + defer func() { + assert.NoError(t, bucket.CreateDataStore(deletedDataStore)) + + }() + // drop a data store + require.NoError(t, rt.TestBucket.DropDataStore(deletedDataStore)) + require.Len(t, rt.TestBucket.GetNonDefaultDatastoreNames(), len(dataStores)-1) + + rt.Close() + rtConfig = &rest.RestTesterConfig{ + CustomTestBucket: bucket.NoCloseClone(), + PersistentConfig: true, + GroupID: base.StringPtr(t.Name()), + AdminInterfaceAuthentication: true, + } + + rt = rest.NewRestTesterMultipleCollections(t, rtConfig, 2) + defer rt.Close() + + bucket2Role := rest.RouteRole{ + RoleName: rest.MobileSyncGatewayRole.RoleName, + DatabaseScoped: true, + } + if base.TestsUseServerCE() { + bucket2Role = rest.RouteRole{ + RoleName: rest.BucketFullAccessRole.RoleName, + DatabaseScoped: true, + } + } + + eps, httpClient, err := rt.ServerContext().ObtainManagementEndpointsAndHTTPClient() + require.NoError(t, err) + + altBucket := base.GetTestBucket(t) + defer altBucket.Close() + const password = "password2" + rest.MakeUser(t, httpClient, eps[0], bucket2Role.RoleName, password, []string{fmt.Sprintf("%s[%s]", bucket2Role.RoleName, altBucket.GetName())}) + defer rest.DeleteUser(t, httpClient, eps[0], bucket2Role.RoleName) + + delete(dbConfig.Scopes[deletedDataStore.ScopeName()].Collections, deletedDataStore.CollectionName()) + + dbcJSON, err = base.JSONMarshal(dbConfig) + require.NoError(t, err) + + resp = rt.SendAdminRequestWithAuth(http.MethodPost, "/"+dbName+"/", string(dbcJSON), base.TestClusterUsername(), base.TestClusterPassword()) + rest.RequireStatus(t, resp, http.StatusForbidden) + + // wrong RBAC user + resp = rt.SendAdminRequestWithAuth(http.MethodDelete, "/"+dbName+"/", "", bucket2Role.RoleName, password) + rest.RequireStatus(t, resp, http.StatusForbidden) + + // bad credentials + resp = rt.SendAdminRequestWithAuth(http.MethodDelete, "/"+dbName+"/", "", "baduser", "badpassword") + rest.RequireStatus(t, resp, http.StatusUnauthorized) + + resp = rt.SendAdminRequestWithAuth(http.MethodDelete, "/"+dbName+"/", "", base.TestClusterUsername(), base.TestClusterPassword()) + rest.RequireStatus(t, resp, http.StatusOK) + +} diff --git a/rest/utilities_testing.go b/rest/utilities_testing.go index 1960d983e1..e5998974f2 100644 --- a/rest/utilities_testing.go +++ b/rest/utilities_testing.go @@ -37,6 +37,7 @@ import ( "github.com/couchbase/sync_gateway/base" "github.com/couchbase/sync_gateway/channels" "github.com/couchbase/sync_gateway/db" + "github.com/couchbase/sync_gateway/db/functions" "github.com/google/uuid" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -66,7 +67,7 @@ type RestTesterConfig struct { enableAdminAuthPermissionsCheck bool useTLSServer bool // If true, TLS will be required for communications with CBS. Default: false PersistentConfig bool - groupID *string + GroupID *string serverless bool // Runs SG in serverless mode. Must be used in conjunction with persistent config collectionConfig collectionConfiguration numCollections int @@ -227,8 +228,8 @@ func (rt *RestTester) Bucket() base.Bucket { } } - if rt.RestTesterConfig.groupID != nil { - sc.Bootstrap.ConfigGroupID = *rt.RestTesterConfig.groupID + if rt.RestTesterConfig.GroupID != nil { + sc.Bootstrap.ConfigGroupID = *rt.RestTesterConfig.GroupID } else if rt.RestTesterConfig.PersistentConfig { // If running in persistent config mode, the database has to be manually created. If the db name is the same as a // past tests db name, a db already exists error could happen if the past tests bucket is still flushing. Prevent this @@ -246,8 +247,6 @@ func (rt *RestTester) Bucket() base.Bucket { rt.MutateStartupConfig(&sc) } - sc.Unsupported.UserQueries = base.BoolPtr(rt.EnableUserQueries) - // Allow EE-only config even in CE for testing using group IDs. if err := sc.Validate(true); err != nil { panic("invalid RestTester StartupConfig: " + err.Error()) @@ -270,7 +269,7 @@ func (rt *RestTester) Bucket() base.Bucket { rt.TestBucket.BucketSpec.TLSSkipVerify = base.TestTLSSkipVerify() - if err := rt.RestTesterServerContext.initializeCouchbaseServerConnections(ctx); err != nil { + if err := rt.RestTesterServerContext.initializeCouchbaseServerConnections(ctx, true); err != nil { panic("Couldn't initialize Couchbase Server connection: " + err.Error()) } } @@ -331,6 +330,10 @@ func (rt *RestTester) Bucket() base.Bucket { rt.DatabaseConfig.ImportPartitions = base.Uint16Ptr(1) } + if rt.EnableUserQueries { + rt.DatabaseConfig.JavaScriptEngine = base.StringPtr("V8") + } + _, isLeaky := base.AsLeakyBucket(rt.TestBucket) if rt.leakyBucketConfig != nil || isLeaky { _, err = rt.RestTesterServerContext.AddDatabaseFromConfigWithBucket(ctx, rt.TB, *rt.DatabaseConfig, testBucket.Bucket) @@ -1181,9 +1184,14 @@ func (s *SlowResponseRecorder) Write(buf []byte) (int, error) { // AddDatabaseFromConfigWithBucket adds a database to the ServerContext and sets a specific bucket on the database context. // If an existing config is found for the name, returns an error. func (sc *ServerContext) AddDatabaseFromConfigWithBucket(ctx context.Context, tb testing.TB, config DatabaseConfig, bucket base.Bucket) (*db.DatabaseContext, error) { - return sc.getOrAddDatabaseFromConfig(ctx, config, false, func(ctx context.Context, spec base.BucketSpec) (base.Bucket, error) { - return bucket, nil - }) + options := getOrAddDatabaseConfigOptions{ + useExisting: false, + failFast: false, + connectToBucketFn: func(_ context.Context, spec base.BucketSpec, _ bool) (base.Bucket, error) { + return bucket, nil + }, + } + return sc.getOrAddDatabaseFromConfig(ctx, config, options) } // The parameters used to create a BlipTester @@ -2457,6 +2465,7 @@ func (rt *RestTester) GetChangesOneShot(t testing.TB, keyspace string, since int } func (rt *RestTester) NewDbConfig() DbConfig { + // make sure bucket has been initialized config := DbConfig{ BucketConfig: BucketConfig{ Bucket: base.StringPtr(rt.Bucket().GetName()), @@ -2476,6 +2485,10 @@ func (rt *RestTester) NewDbConfig() DbConfig { } config.Scopes = GetCollectionsConfigWithSyncFn(rt.TB, rt.TestBucket, syncFn, rt.numCollections) } + return config +} +func (rt *RestTester) GetFunctionsConfig() *functions.Config { + config, _ := rt.GetDatabase().Options.FunctionsConfig.(*functions.Config) return config } diff --git a/rest/utilities_testing_functions_api.go b/rest/utilities_testing_functions_api.go index 61bb8aa01b..c7a3c7e623 100644 --- a/rest/utilities_testing_functions_api.go +++ b/rest/utilities_testing_functions_api.go @@ -27,6 +27,7 @@ func NewRestTesterForUserQueries(t *testing.T, queryConfig DbConfig) *RestTester dbConfig := rt.NewDbConfig() + dbConfig.JavaScriptEngine = base.StringPtr("V8") dbConfig.UserFunctions = queryConfig.UserFunctions dbConfig.GraphQL = queryConfig.GraphQL diff --git a/rest/utilities_testing_functions_api_test.go b/rest/utilities_testing_functions_api_test.go index 7ddcad2f99..6f99ff9936 100644 --- a/rest/utilities_testing_functions_api_test.go +++ b/rest/utilities_testing_functions_api_test.go @@ -6,10 +6,14 @@ // software will be governed by the Apache License, Version 2.0, included in // the file licenses/APL2.txt. +//go:build cb_sg_v8 + package rest import ( + "context" "log" + "runtime" "sync" "testing" "time" @@ -50,64 +54,61 @@ var kGraphQLTestConfig = &DatabaseConfig{DbConfig: DbConfig{ }, }, }, + JavaScriptEngine: base.StringPtr("V8"), }} -// Asserts that running testFunc in 100 concurrent goroutines is no more than 10% slower -// than running it 100 times in succession. A low bar indeed, but can detect some serious -// bottlenecks, or of course deadlocks. -func testConcurrently(t *testing.T, rt *RestTester, testFunc func() bool) bool { - const numTasks = 100 - - // Run testFunc once to prime the pump: - if !testFunc() { - return false - } - - // 100 sequential calls: +func runSequentially(rt *RestTester, testFunc func() bool, numTasks int) time.Duration { startTime := time.Now() for i := 0; i < numTasks; i++ { - if !testFunc() { - return false - } + testFunc() } - sequentialDuration := time.Since(startTime) + return time.Since(startTime) +} - // Now run 100 concurrent calls: +func runConcurrently(rt *RestTester, testFunc func() bool, numTasks int, numThreads int) time.Duration { + tasksPerThread := numTasks / numThreads var wg sync.WaitGroup - startTime = time.Now() - for i := 0; i < numTasks; i++ { + startTime := time.Now() + for i := 0; i < numThreads; i++ { wg.Add(1) go func() { defer wg.Done() - testFunc() + for i := 0; i < tasksPerThread; i++ { + testFunc() + } }() } wg.Wait() - concurrentDuration := time.Since(startTime) + return time.Since(startTime) +} + +// Asserts that running testFunc in 100 concurrent goroutines is no more than 10% slower +// than running it 100 times in succession. A low bar indeed, but can detect some serious +// bottlenecks, or of course deadlocks. +func testConcurrently(t *testing.T, rt *RestTester, testFunc func() bool) bool { + const numTasks = 10000 + const numThreads = 4 + + assert.GreaterOrEqual(t, runtime.GOMAXPROCS(0), 2, "Not enough OS threads available") + + // prime the pump: + runSequentially(rt, testFunc, 5) + + base.WarnfCtx(context.TODO(), "---- Starting sequential tasks ----") + sequentialDuration := runSequentially(rt, testFunc, numTasks) + base.WarnfCtx(context.TODO(), "---- Starting concurrent tasks ----") + concurrentDuration := runConcurrently(rt, testFunc, numTasks, numThreads) + base.WarnfCtx(context.TODO(), "---- End ----") log.Printf("---- %d sequential took %v, concurrent took %v ... speedup is %f", numTasks, sequentialDuration, concurrentDuration, float64(sequentialDuration)/float64(concurrentDuration)) - return assert.LessOrEqual(t, concurrentDuration, 1.1*numTasks*sequentialDuration) -} - -func TestFunctions(t *testing.T) { - rt := NewRestTester(t, &RestTesterConfig{GuestEnabled: true, EnableUserQueries: true, DatabaseConfig: kGraphQLTestConfig}) - defer rt.Close() - - t.Run("GraphQL with variables", func(t *testing.T) { - testConcurrently(t, rt, func() bool { - response := rt.SendRequest("POST", "/{{.db}}/_graphql", - `{"query": "query($number:Int!){ square(n:$number) }", - "variables": {"number": 13}}`) - return assert.Equal(t, 200, response.Result().StatusCode) && - assert.Equal(t, "{\"data\":{\"square\":169}}", string(response.BodyBytes())) - }) - }) + return assert.LessOrEqual(t, float64(concurrentDuration), 1.1*float64(sequentialDuration)) } func TestFunctionsConcurrently(t *testing.T) { - rt := NewRestTester(t, &RestTesterConfig{GuestEnabled: true, EnableUserQueries: true, DatabaseConfig: kGraphQLTestConfig}) + //TODO: Switch back to NewRestTester() + rt := NewRestTesterDefaultCollection(t, &RestTesterConfig{GuestEnabled: true, EnableUserQueries: true, DatabaseConfig: kGraphQLTestConfig}) defer rt.Close() t.Run("Function", func(t *testing.T) { @@ -126,6 +127,16 @@ func TestFunctionsConcurrently(t *testing.T) { }) }) + t.Run("GraphQL with variables", func(t *testing.T) { + testConcurrently(t, rt, func() bool { + response := rt.SendRequest("POST", "/{{.db}}/_graphql", + `{"query": "query($number:Int!){ square(n:$number) }", + "variables": {"number": 13}}`) + return assert.Equal(t, 200, response.Result().StatusCode) && + assert.Equal(t, "{\"data\":{\"square\":169}}", string(response.BodyBytes())) + }) + }) + t.Run("Query", func(t *testing.T) { if base.UnitTestUrlIsWalrus() { t.Skip("Skipping query subtest") @@ -133,7 +144,7 @@ func TestFunctionsConcurrently(t *testing.T) { testConcurrently(t, rt, func() bool { response := rt.SendRequest("GET", "/{{.db}}/_function/squareN1QL?n=13", "") return assert.Equal(t, 200, response.Result().StatusCode) && - assert.Equal(t, "[{\"square\":169}\n]\n", string(response.BodyBytes())) + assert.Equal(t, "[{\"square\":169}]", string(response.BodyBytes())) }) } }) diff --git a/rest/utilities_testing_resttester.go b/rest/utilities_testing_resttester.go index b5790205a5..6f1aee79a1 100644 --- a/rest/utilities_testing_resttester.go +++ b/rest/utilities_testing_resttester.go @@ -167,6 +167,21 @@ func (rt *RestTester) WaitForAssignedReplications(count int) { require.NoError(rt.TB, rt.WaitForCondition(successFunc)) } +func (rt *RestTester) GetActiveReplicatorCount() int { + rt.ServerContext().ActiveReplicationsCounter.lock.Lock() + defer rt.ServerContext().ActiveReplicationsCounter.lock.Unlock() + return rt.ServerContext().ActiveReplicationsCounter.activeReplicatorCount +} + +func (rt *RestTester) WaitForActiveReplicatorCount(expCount int) { + var count int + successFunc := func() bool { + count = rt.GetActiveReplicatorCount() + return count == expCount + } + require.NoError(rt.TB, rt.WaitForCondition(successFunc), "Mismatch in active replicator count, expected count %d actual %d", expCount, count) +} + func (rt *RestTester) WaitForReplicationStatusForDB(dbName string, replicationID string, targetStatus string) { var status db.ReplicationStatus successFunc := func() bool { diff --git a/test.sh b/test.sh index 03152d5cb2..61182f976a 100755 --- a/test.sh +++ b/test.sh @@ -32,8 +32,12 @@ doTest () { buildTags="" if [ "$1" = "EE" ]; then buildTags="-tags cb_sg_enterprise" + if [ -n "${SG_V8:-}" ]; then + buildTags="${buildTags},cb_sg_v8" + fi + elif [ -n "${SG_V8:-}" ]; then + buildTags="-tags cb_sg_v8" fi - EXTRA_FLAGS="" if [ "$SG_TEST_BACKING_STORE" == "Couchbase" ] || [ "$SG_TEST_BACKING_STORE" == "couchbase" ]; then ./test-integration-init.sh @@ -64,6 +68,16 @@ doTest () { } for edition in "${build_editions[@]}"; do - echo " Testing edition: ${edition}" - doTest $edition "$@" + if [[ -z "${SG_V8:-}" ]]; then + echo " Testing edition: ${edition} without V8" + else + echo " Testing edition: ${edition} with V8" + fi + (doTest $edition "$@") + if [[ -z "${SG_V8:-}" ]]; then + echo " Testing edition: ${edition} with V8" + SG_V8=1 + (doTest $edition "$@") + unset SG_V8 + fi done