'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var sdkV6 = require('@cognite/sdk-v6');
var runtime = require('@genql/runtime');

/******************************************************************************
Copyright (c) Microsoft Corporation.

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */

var __assign = function() {
    __assign = Object.assign || function __assign(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};

function __awaiter(thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
}

function __generator(thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
}

var types = {
    "scalars": [
        4,
        6,
        7,
        8,
        9,
        10,
        11,
        19,
        20,
        22,
        50,
        52
    ],
    "types": {
        "Actor": {
            "name": [
                20
            ],
            "age": [
                9
            ],
            "externalId": [
                8
            ],
            "__typename": [
                20
            ]
        },
        "ActorAggregateConnection": {
            "edges": [
                23
            ],
            "items": [
                2
            ],
            "pageInfo": [
                17
            ],
            "__typename": [
                20
            ]
        },
        "ActorAggregateResult": {
            "group": [
                11
            ],
            "avg": [
                25
            ],
            "min": [
                25
            ],
            "max": [
                25
            ],
            "count": [
                24
            ],
            "sum": [
                25
            ],
            "histogram": [
                26,
                {
                    "interval": [
                        9,
                        "Int!"
                    ]
                }
            ],
            "__typename": [
                20
            ]
        },
        "ActorConnection": {
            "edges": [
                27
            ],
            "items": [
                0
            ],
            "pageInfo": [
                17
            ],
            "__typename": [
                20
            ]
        },
        "Boolean": {},
        "DataPoint": {
            "timestamp": [
                22
            ],
            "value": [
                6
            ],
            "__typename": [
                20
            ]
        },
        "DataPointValue": {},
        "Float": {},
        "ID": {},
        "Int": {},
        "Int64": {},
        "JSONObject": {},
        "Movie": {
            "name": [
                20
            ],
            "actors": [
                3,
                {
                    "first": [
                        9
                    ],
                    "after": [
                        20
                    ],
                    "filter": [
                        35
                    ],
                    "sort": [
                        28,
                        "[_ActorSort!]"
                    ]
                }
            ],
            "watchedIt": [
                4
            ],
            "externalId": [
                8
            ],
            "__typename": [
                20
            ]
        },
        "MovieAggregateConnection": {
            "edges": [
                44
            ],
            "items": [
                14
            ],
            "pageInfo": [
                17
            ],
            "__typename": [
                20
            ]
        },
        "MovieAggregateResult": {
            "group": [
                11
            ],
            "avg": [
                46
            ],
            "min": [
                46
            ],
            "max": [
                46
            ],
            "count": [
                45
            ],
            "sum": [
                46
            ],
            "histogram": [
                47,
                {
                    "interval": [
                        9,
                        "Int!"
                    ]
                }
            ],
            "__typename": [
                20
            ]
        },
        "MovieConnection": {
            "edges": [
                48
            ],
            "items": [
                12
            ],
            "pageInfo": [
                17
            ],
            "__typename": [
                20
            ]
        },
        "Mutation": {
            "_empty": [
                4
            ],
            "__typename": [
                20
            ]
        },
        "PageInfo": {
            "hasPreviousPage": [
                4
            ],
            "hasNextPage": [
                4
            ],
            "startCursor": [
                20
            ],
            "endCursor": [
                20
            ],
            "__typename": [
                20
            ]
        },
        "Query": {
            "listMovie": [
                15,
                {
                    "first": [
                        9
                    ],
                    "after": [
                        20
                    ],
                    "filter": [
                        41
                    ],
                    "sort": [
                        49,
                        "[_MovieSort!]"
                    ]
                }
            ],
            "searchMovie": [
                15,
                {
                    "query": [
                        20,
                        "String!"
                    ],
                    "fields": [
                        52,
                        "[_SearchMovieFields!]"
                    ],
                    "filter": [
                        53
                    ],
                    "first": [
                        9
                    ]
                }
            ],
            "aggregateMovie": [
                13,
                {
                    "query": [
                        20
                    ],
                    "fields": [
                        52,
                        "[_SearchMovieFields!]"
                    ],
                    "groupBy": [
                        52,
                        "[_SearchMovieFields!]"
                    ],
                    "filter": [
                        53
                    ],
                    "after": [
                        20
                    ]
                }
            ],
            "listActor": [
                3,
                {
                    "first": [
                        9
                    ],
                    "after": [
                        20
                    ],
                    "filter": [
                        35
                    ],
                    "sort": [
                        28,
                        "[_ActorSort!]"
                    ]
                }
            ],
            "searchActor": [
                3,
                {
                    "query": [
                        20,
                        "String!"
                    ],
                    "fields": [
                        50,
                        "[_SearchActorFields!]"
                    ],
                    "filter": [
                        51
                    ],
                    "first": [
                        9
                    ]
                }
            ],
            "aggregateActor": [
                1,
                {
                    "query": [
                        20
                    ],
                    "fields": [
                        50,
                        "[_SearchActorFields!]"
                    ],
                    "groupBy": [
                        50,
                        "[_SearchActorFields!]"
                    ],
                    "filter": [
                        51
                    ],
                    "after": [
                        20
                    ]
                }
            ],
            "__typename": [
                20
            ]
        },
        "SortDirection": {},
        "String": {},
        "TimeSeries": {
            "id": [
                10
            ],
            "externalId": [
                20
            ],
            "name": [
                20
            ],
            "isString": [
                4
            ],
            "metadata": [
                11
            ],
            "unit": [
                20
            ],
            "assetId": [
                10
            ],
            "isStep": [
                4
            ],
            "description": [
                20
            ],
            "securityCategories": [
                10
            ],
            "datasetId": [
                10
            ],
            "dataPoints": [
                5,
                {
                    "start": [
                        10
                    ],
                    "end": [
                        10
                    ],
                    "limit": [
                        9
                    ]
                }
            ],
            "__typename": [
                20
            ]
        },
        "Timestamp": {},
        "_ActorAggregateEdge": {
            "node": [
                2
            ],
            "cursor": [
                20
            ],
            "__typename": [
                20
            ]
        },
        "_ActorAggregateFieldCountResult": {
            "externalId": [
                9
            ],
            "name": [
                9
            ],
            "age": [
                9
            ],
            "__typename": [
                20
            ]
        },
        "_ActorAggregateFieldResult": {
            "age": [
                7
            ],
            "__typename": [
                20
            ]
        },
        "_ActorAggregateHistogramFieldResult": {
            "age": [
                29
            ],
            "__typename": [
                20
            ]
        },
        "_ActorEdge": {
            "node": [
                0
            ],
            "cursor": [
                20
            ],
            "__typename": [
                20
            ]
        },
        "_ActorSort": {
            "externalId": [
                19
            ],
            "name": [
                19
            ],
            "age": [
                19
            ],
            "__typename": [
                20
            ]
        },
        "_AggregateHistogramObjectType": {
            "start": [
                9
            ],
            "count": [
                9
            ],
            "__typename": [
                20
            ]
        },
        "_BooleanCondition": {
            "eq": [
                4
            ],
            "isNull": [
                4
            ],
            "in": [
                4
            ],
            "__typename": [
                20
            ]
        },
        "_FloatCondition": {
            "eq": [
                7
            ],
            "isNull": [
                4
            ],
            "in": [
                7
            ],
            "gt": [
                7
            ],
            "lt": [
                7
            ],
            "gte": [
                7
            ],
            "lte": [
                7
            ],
            "__typename": [
                20
            ]
        },
        "_IDCondition": {
            "eq": [
                8
            ],
            "isNull": [
                4
            ],
            "in": [
                8
            ],
            "__typename": [
                20
            ]
        },
        "_Int64Condition": {
            "eq": [
                10
            ],
            "isNull": [
                4
            ],
            "in": [
                10
            ],
            "gt": [
                10
            ],
            "lt": [
                10
            ],
            "gte": [
                10
            ],
            "lte": [
                10
            ],
            "__typename": [
                20
            ]
        },
        "_IntCondition": {
            "eq": [
                9
            ],
            "isNull": [
                4
            ],
            "in": [
                9
            ],
            "gt": [
                9
            ],
            "lt": [
                9
            ],
            "gte": [
                9
            ],
            "lte": [
                9
            ],
            "__typename": [
                20
            ]
        },
        "_ListActorFilter": {
            "and": [
                35
            ],
            "or": [
                35
            ],
            "not": [
                35
            ],
            "externalId": [
                32
            ],
            "name": [
                54
            ],
            "age": [
                34
            ],
            "__typename": [
                20
            ]
        },
        "_ListBooleanFilter": {
            "containsAll": [
                4
            ],
            "containsAny": [
                4
            ],
            "__typename": [
                20
            ]
        },
        "_ListFloatFilter": {
            "containsAll": [
                7
            ],
            "containsAny": [
                7
            ],
            "__typename": [
                20
            ]
        },
        "_ListIDFilter": {
            "containsAll": [
                8
            ],
            "containsAny": [
                8
            ],
            "__typename": [
                20
            ]
        },
        "_ListInt64Filter": {
            "containsAll": [
                10
            ],
            "containsAny": [
                10
            ],
            "__typename": [
                20
            ]
        },
        "_ListIntFilter": {
            "containsAll": [
                9
            ],
            "containsAny": [
                9
            ],
            "__typename": [
                20
            ]
        },
        "_ListMovieFilter": {
            "and": [
                41
            ],
            "or": [
                41
            ],
            "not": [
                41
            ],
            "externalId": [
                32
            ],
            "name": [
                54
            ],
            "watchedIt": [
                30
            ],
            "__typename": [
                20
            ]
        },
        "_ListStringFilter": {
            "containsAll": [
                20
            ],
            "containsAny": [
                20
            ],
            "__typename": [
                20
            ]
        },
        "_ListTimestampFilter": {
            "containsAll": [
                22
            ],
            "containsAny": [
                22
            ],
            "__typename": [
                20
            ]
        },
        "_MovieAggregateEdge": {
            "node": [
                14
            ],
            "cursor": [
                20
            ],
            "__typename": [
                20
            ]
        },
        "_MovieAggregateFieldCountResult": {
            "externalId": [
                9
            ],
            "name": [
                9
            ],
            "watchedIt": [
                9
            ],
            "__typename": [
                20
            ]
        },
        "_MovieAggregateFieldResult": {
            "_empty": [
                9
            ],
            "__typename": [
                20
            ]
        },
        "_MovieAggregateHistogramFieldResult": {
            "_empty": [
                29
            ],
            "__typename": [
                20
            ]
        },
        "_MovieEdge": {
            "node": [
                12
            ],
            "cursor": [
                20
            ],
            "__typename": [
                20
            ]
        },
        "_MovieSort": {
            "externalId": [
                19
            ],
            "name": [
                19
            ],
            "watchedIt": [
                19
            ],
            "__typename": [
                20
            ]
        },
        "_SearchActorFields": {},
        "_SearchActorFilter": {
            "and": [
                51
            ],
            "or": [
                51
            ],
            "not": [
                51
            ],
            "externalId": [
                32
            ],
            "name": [
                54
            ],
            "age": [
                34
            ],
            "__typename": [
                20
            ]
        },
        "_SearchMovieFields": {},
        "_SearchMovieFilter": {
            "and": [
                53
            ],
            "or": [
                53
            ],
            "not": [
                53
            ],
            "externalId": [
                32
            ],
            "name": [
                54
            ],
            "watchedIt": [
                30
            ],
            "__typename": [
                20
            ]
        },
        "_StringCondition": {
            "eq": [
                20
            ],
            "isNull": [
                4
            ],
            "in": [
                20
            ],
            "gt": [
                20
            ],
            "lt": [
                20
            ],
            "gte": [
                20
            ],
            "lte": [
                20
            ],
            "prefix": [
                20
            ],
            "__typename": [
                20
            ]
        },
        "_TimestampCondition": {
            "eq": [
                22
            ],
            "isNull": [
                4
            ],
            "in": [
                22
            ],
            "gt": [
                22
            ],
            "lt": [
                22
            ],
            "gte": [
                22
            ],
            "lte": [
                22
            ],
            "__typename": [
                20
            ]
        }
    }
};

var typeMap$1 = runtime.linkTypeMap(types);

var version$1 = '2.10.0';
runtime.assertSameVersion(version$1);

var generateQueryOp = function(fields) {
  return runtime.generateGraphqlOperation('query', typeMap$1.Query, fields)
};

const {
  linkTypeMap,
  createClient: createClientOriginal,
  generateGraphqlOperation,
  assertSameVersion,
} = require('@genql/runtime');
var typeMap = linkTypeMap(require('./types.cjs'));

var version = '2.10.0';
assertSameVersion(version);

module.exports.version = version;

module.exports.createClient = function(options) {
  options = options || {};
  var optionsCopy = {
    url:
      'https://bluefield.cognitedata.com/api/v1/projects/david/schema/api/moviedm/1/graphql',
    queryRoot: typeMap.Query,
    mutationRoot: typeMap.Mutation,
    subscriptionRoot: typeMap.Subscription,
  };
  for (var name in options) {
    optionsCopy[name] = options[name];
  }
  return createClientOriginal(optionsCopy)
};

module.exports.enumSortDirection = {
  ASC: 'ASC',
  DESC: 'DESC',
};

module.exports.enumSearchActorFields = {
  name: 'name',
  age: 'age',
  externalId: 'externalId',
};

module.exports.enumSearchMovieFields = {
  name: 'name',
  watchedIt: 'watchedIt',
  externalId: 'externalId',
};

module.exports.generateQueryOp = function(fields) {
  return generateGraphqlOperation('query', typeMap.Query, fields)
};
module.exports.generateMutationOp = function(fields) {
  return generateGraphqlOperation('mutation', typeMap.Mutation, fields)
};
module.exports.generateSubscriptionOp = function(fields) {
  return generateGraphqlOperation('subscription', typeMap.Subscription, fields)
};
module.exports.everything = {
  __scalar: true,
};

var schemaExports = require('./guards.cjs');
for (var k in schemaExports) {
  module.exports[k] = schemaExports[k];
}

var Actor_possibleTypes = ['Actor'];
var isActor = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isActor"');
    return Actor_possibleTypes.includes(obj.__typename);
};
var ActorAggregateConnection_possibleTypes = ['ActorAggregateConnection'];
var isActorAggregateConnection = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isActorAggregateConnection"');
    return ActorAggregateConnection_possibleTypes.includes(obj.__typename);
};
var ActorAggregateResult_possibleTypes = ['ActorAggregateResult'];
var isActorAggregateResult = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isActorAggregateResult"');
    return ActorAggregateResult_possibleTypes.includes(obj.__typename);
};
var ActorConnection_possibleTypes = ['ActorConnection'];
var isActorConnection = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isActorConnection"');
    return ActorConnection_possibleTypes.includes(obj.__typename);
};
var DataPoint_possibleTypes = ['DataPoint'];
var isDataPoint = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isDataPoint"');
    return DataPoint_possibleTypes.includes(obj.__typename);
};
var Movie_possibleTypes = ['Movie'];
var isMovie = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isMovie"');
    return Movie_possibleTypes.includes(obj.__typename);
};
var MovieAggregateConnection_possibleTypes = ['MovieAggregateConnection'];
var isMovieAggregateConnection = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isMovieAggregateConnection"');
    return MovieAggregateConnection_possibleTypes.includes(obj.__typename);
};
var MovieAggregateResult_possibleTypes = ['MovieAggregateResult'];
var isMovieAggregateResult = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isMovieAggregateResult"');
    return MovieAggregateResult_possibleTypes.includes(obj.__typename);
};
var MovieConnection_possibleTypes = ['MovieConnection'];
var isMovieConnection = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isMovieConnection"');
    return MovieConnection_possibleTypes.includes(obj.__typename);
};
var Mutation_possibleTypes = ['Mutation'];
var isMutation = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isMutation"');
    return Mutation_possibleTypes.includes(obj.__typename);
};
var PageInfo_possibleTypes = ['PageInfo'];
var isPageInfo = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isPageInfo"');
    return PageInfo_possibleTypes.includes(obj.__typename);
};
var Query_possibleTypes = ['Query'];
var isQuery = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isQuery"');
    return Query_possibleTypes.includes(obj.__typename);
};
var TimeSeries_possibleTypes = ['TimeSeries'];
var isTimeSeries = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "isTimeSeries"');
    return TimeSeries_possibleTypes.includes(obj.__typename);
};
var _ActorAggregateEdge_possibleTypes = ['_ActorAggregateEdge'];
var is_ActorAggregateEdge = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_ActorAggregateEdge"');
    return _ActorAggregateEdge_possibleTypes.includes(obj.__typename);
};
var _ActorAggregateFieldCountResult_possibleTypes = ['_ActorAggregateFieldCountResult'];
var is_ActorAggregateFieldCountResult = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_ActorAggregateFieldCountResult"');
    return _ActorAggregateFieldCountResult_possibleTypes.includes(obj.__typename);
};
var _ActorAggregateFieldResult_possibleTypes = ['_ActorAggregateFieldResult'];
var is_ActorAggregateFieldResult = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_ActorAggregateFieldResult"');
    return _ActorAggregateFieldResult_possibleTypes.includes(obj.__typename);
};
var _ActorAggregateHistogramFieldResult_possibleTypes = ['_ActorAggregateHistogramFieldResult'];
var is_ActorAggregateHistogramFieldResult = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_ActorAggregateHistogramFieldResult"');
    return _ActorAggregateHistogramFieldResult_possibleTypes.includes(obj.__typename);
};
var _ActorEdge_possibleTypes = ['_ActorEdge'];
var is_ActorEdge = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_ActorEdge"');
    return _ActorEdge_possibleTypes.includes(obj.__typename);
};
var _AggregateHistogramObjectType_possibleTypes = ['_AggregateHistogramObjectType'];
var is_AggregateHistogramObjectType = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_AggregateHistogramObjectType"');
    return _AggregateHistogramObjectType_possibleTypes.includes(obj.__typename);
};
var _MovieAggregateEdge_possibleTypes = ['_MovieAggregateEdge'];
var is_MovieAggregateEdge = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_MovieAggregateEdge"');
    return _MovieAggregateEdge_possibleTypes.includes(obj.__typename);
};
var _MovieAggregateFieldCountResult_possibleTypes = ['_MovieAggregateFieldCountResult'];
var is_MovieAggregateFieldCountResult = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_MovieAggregateFieldCountResult"');
    return _MovieAggregateFieldCountResult_possibleTypes.includes(obj.__typename);
};
var _MovieAggregateFieldResult_possibleTypes = ['_MovieAggregateFieldResult'];
var is_MovieAggregateFieldResult = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_MovieAggregateFieldResult"');
    return _MovieAggregateFieldResult_possibleTypes.includes(obj.__typename);
};
var _MovieAggregateHistogramFieldResult_possibleTypes = ['_MovieAggregateHistogramFieldResult'];
var is_MovieAggregateHistogramFieldResult = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_MovieAggregateHistogramFieldResult"');
    return _MovieAggregateHistogramFieldResult_possibleTypes.includes(obj.__typename);
};
var _MovieEdge_possibleTypes = ['_MovieEdge'];
var is_MovieEdge = function (obj) {
    if (!(obj === null || obj === void 0 ? void 0 : obj.__typename))
        throw new Error('__typename is missing in "is_MovieEdge"');
    return _MovieEdge_possibleTypes.includes(obj.__typename);
};
var RelationshipMap = {
    Movie: {
        actors: "Actor"
    }
};

var getTypeKey = function (typeName, version) {
    return "".concat(typeName, "_").concat(version);
};
var getRelationshipKey = function (typeName, attr, version) { return "".concat(typeName, "_").concat(attr, "_").concat(version); };
var CDF_ALPHA_VERSION_HEADERS = { 'cdf-version': 'alpha' };
var FDMQueryClient = /** @class */ (function () {
    function FDMQueryClient(client) {
        var _this = this;
        this.runQuery = function (query) { return __awaiter(_this, void 0, void 0, function () {
            var response;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this._client.post("/api/v1/projects/".concat(PROJECT, "/schema/api/").concat(DM_NAME, "/").concat(DM_VERSION, "/graphql"), { data: generateQueryOp(query) })];
                    case 1:
                        response = _a.sent();
                        return [2 /*return*/, response];
                }
            });
        }); };
        this._client = client;
    }
    FDMQueryClient.prototype.upsertNodes = function (key, items) {
        return __awaiter(this, void 0, void 0, function () {
            var data, res;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        data = {
                            items: items,
                            spaceExternalId: DM_NAME,
                            model: [DM_NAME, getTypeKey(key, DM_VERSION)],
                            overwrite: true
                        };
                        return [4 /*yield*/, this._client.post("/api/v1/projects/".concat(this._client.project, "/datamodelstorage/nodes"), {
                                data: data,
                                headers: CDF_ALPHA_VERSION_HEADERS,
                                responseType: 'json',
                                withCredentials: true
                            })];
                    case 1:
                        res = _a.sent();
                        return [2 /*return*/, res.data.items];
                }
            });
        });
    };
    FDMQueryClient.prototype.upsertRelationships = function (type, property, items) {
        return __awaiter(this, void 0, void 0, function () {
            var relationshipKey, data, res;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        relationshipKey = getRelationshipKey(type, 
                        // @ts-ignore
                        property, DM_VERSION);
                        data = {
                            items: items.map(function (el) { return (__assign(__assign({}, el), { type: relationshipKey, dummy: '', externalId: "".concat(el.startNode, "_").concat(el.endNode) })); }),
                            spaceExternalId: DM_NAME,
                            model: [DM_NAME, relationshipKey],
                            overwrite: true,
                            autoCreateStartNodes: true,
                            autoCreateEndNodes: true
                        };
                        return [4 /*yield*/, this._client.post("/api/v1/projects/".concat(this._client.project, "/datamodelstorage/edges"), {
                                data: data,
                                headers: CDF_ALPHA_VERSION_HEADERS,
                                responseType: 'json',
                                withCredentials: true
                            })];
                    case 1:
                        res = _a.sent();
                        return [2 /*return*/, res.data.items];
                }
            });
        });
    };
    return FDMQueryClient;
}());
var FDMQueryClientBuilder = {
    fromToken: function (appId) {
        if (appId === void 0) { appId = 'FDMQueryClient'; }
        return new FDMQueryClient(new sdkV6.CogniteClient({
            appId: appId,
            // @ts-ignore
            getToken: function () { return Promise.resolve(BEARER_TOKEN); },
            project: PROJECT,
            baseUrl: "https://".concat(CLUSTER, ".cognitedata.com")
        }));
    },
    fromClient: function (client) {
        return new FDMQueryClient(client);
    }
};
var BEARER_TOKEN = "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSIsImtpZCI6IjJaUXBKM1VwYmpBWVhZR2FYRUpsOGxWMFRPSSJ9.eyJhdWQiOiJodHRwczovL2JsdWVmaWVsZC5jb2duaXRlZGF0YS5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC9lNTQxNjI2Yi1kNTUyLTQ4OGItODY3NC0yNDk0N2MyYzM0MmUvIiwiaWF0IjoxNjYxOTUxNTAyLCJuYmYiOjE2NjE5NTE1MDIsImV4cCI6MTY2MTk1NzExMiwiYWNyIjoiMSIsImFpbyI6IkFRUUIrLzRUQUFBQXZaOHNHU2lTTExvelNONmlyeVNpNFpCb3Z6R2dyTWdZcWFoQjY3TmQrV3N1bWl2bEFTYWpqNWJybVkzSEI2eEZJeVNGMkhpbG1BZ3dZZDlpQWVaSzFPdzFQQ21EUmgrQVFndE03VnZYeWtiK3lZVVdLOFlYd3k1Vm5JelFza21iMVNlcmwwMFFGL1VJM2xjVHpFcmlSSVEwWHhNcjhaQjFmZHRpeWVjVzNjZ3BlYTNSVHdiQWhDTW02OUpOWEpnY1FpeSs3RE1JNWVPQlNROTc0QmU0SnVsQXpyWTRTeHczMEo1dThaRGJtTnB3TkNVM25OTENyejJFdFRNZFJmSVFoK3VxZ01JNkMya1hDR0kwZ3pYbG1ZWkRxRzdBTWdtY3g3emlOMzFGTWJYbUlTdnZhT2I0eFE3TkJSeVRPc0N3MTFYZXlyNUFGNzh3eFY3bm45RHZxZz09IiwiYW1yIjpbInB3ZCIsIm1mYSJdLCJhcHBpZCI6ImE3ODY5NDU1LTMyZjItNGEwNy1iNTY4LTg0ODViOWI4ODdmMCIsImFwcGlkYWNyIjoiMCIsImVtYWlsIjoiZGF2aWQubGl1QGNvZ25pdGVkYXRhLmNvbSIsImZhbWlseV9uYW1lIjoiZXZlciIsImdpdmVuX25hbWUiOiJncmVhdGVzdCIsImdyb3VwcyI6WyI1M2FjZGQ1Yi00OGMwLTQyMTEtYmVlNy1kODZiYjdiYjk0YTMiLCJmMjRiNmU4NC00YmNlLTRjNTAtOGEwZi03YjU1ODQ1MjNkZmIiLCJkZmQ3NzhjMi1hMDE2LTRhZGQtODExOS1jMDk1YjBmZGMxZTQiXSwiaWRwIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvYTlhZTViNTQtMzYwMC00OTE3LWE5ZGMtMzAyMDcyMzM2MGIzLyIsImlwYWRkciI6Ijg0LjIxMC4xNTkuNTkiLCJuYW1lIjoieWEgYm9pIiwib2lkIjoiYWE0ZThmMmEtNTdhZC00NjNkLWI4ZTctNjQxNGNiNTE3Y2FiIiwicmgiOiIwLkFZSUFhMkpCNVZMVmkwaUdkQ1NVZkN3MEx2QjdCanFDU19aR2xQNUJIOUV5MlR1Q0FHby4iLCJzY3AiOiJJREVOVElUWSB1c2VyX2ltcGVyc29uYXRpb24iLCJzdWIiOiJjbGR4anBMV2R4WkpyLW9TUjBUNE1ldEhmT1g5RUJ0Z0g3bjR0N201em5jIiwidGlkIjoiZTU0MTYyNmItZDU1Mi00ODhiLTg2NzQtMjQ5NDdjMmMzNDJlIiwidW5pcXVlX25hbWUiOiJkYXZpZC5saXVAY29nbml0ZWRhdGEuY29tIiwidXRpIjoib2kwRk84TjBYMC1NUVo1NUNpTVpBQSIsInZlciI6IjEuMCJ9.ngHyZzAHFrgk9Uwy1ACunq5pT3LeNyp7mE5KUGIOrkImjApH2aumueTV1rBYqZpeTPIHgEIUgnqOfmhkvmJ2UuvgewVsSzTgIcr2pb6VJVEdwqztsYntn2OMtIIC4m4oQ65njSE4EukBGIZoZth9B-GfuXaWLx2WZKkGd9KTjvoX-xN95vlr9Wi1yGVLhF3gfhuSOOQzsajFHPPh5otdLYB5KE47-SrdnuEhEEL4BDDPaD8OKMH5XqtznagNN48aEgMnRuasDMbCFbxUPGyktKwfuwXIURZt9-ku0eBRkFFErS7NXSYrP4Y4EaU-GJCp6o3BciANbumTm0gaUL3XsA";
var CLUSTER = "bluefield";
var PROJECT = "david";
var DM_NAME = "moviedm";
var DM_VERSION = "1";

exports.FDMQueryClient = FDMQueryClient;
exports.FDMQueryClientBuilder = FDMQueryClientBuilder;
exports.RelationshipMap = RelationshipMap;
exports.isActor = isActor;
exports.isActorAggregateConnection = isActorAggregateConnection;
exports.isActorAggregateResult = isActorAggregateResult;
exports.isActorConnection = isActorConnection;
exports.isDataPoint = isDataPoint;
exports.isMovie = isMovie;
exports.isMovieAggregateConnection = isMovieAggregateConnection;
exports.isMovieAggregateResult = isMovieAggregateResult;
exports.isMovieConnection = isMovieConnection;
exports.isMutation = isMutation;
exports.isPageInfo = isPageInfo;
exports.isQuery = isQuery;
exports.isTimeSeries = isTimeSeries;
exports.is_ActorAggregateEdge = is_ActorAggregateEdge;
exports.is_ActorAggregateFieldCountResult = is_ActorAggregateFieldCountResult;
exports.is_ActorAggregateFieldResult = is_ActorAggregateFieldResult;
exports.is_ActorAggregateHistogramFieldResult = is_ActorAggregateHistogramFieldResult;
exports.is_ActorEdge = is_ActorEdge;
exports.is_AggregateHistogramObjectType = is_AggregateHistogramObjectType;
exports.is_MovieAggregateEdge = is_MovieAggregateEdge;
exports.is_MovieAggregateFieldCountResult = is_MovieAggregateFieldCountResult;
exports.is_MovieAggregateFieldResult = is_MovieAggregateFieldResult;
exports.is_MovieAggregateHistogramFieldResult = is_MovieAggregateHistogramFieldResult;
exports.is_MovieEdge = is_MovieEdge;
