Comparing version 2.2.0 to 2.3.0-alpha-2a632b3.0
@@ -65,3 +65,3 @@ 'use strict'; | ||
}), | ||
selections: selections[0].length || selections[1].length ? selections : void 0 | ||
selections: selections[0].length ? selections : void 0 | ||
}) | ||
@@ -68,0 +68,0 @@ }; |
{ | ||
"name": "gqty", | ||
"version": "2.2.0", | ||
"version": "2.3.0-alpha-2a632b3.0", | ||
"description": "gqty client without queries", | ||
@@ -15,2 +15,3 @@ "sideEffects": false, | ||
"dependencies": { | ||
"@gqty/utils": "^1.0.0-alpha-2a632b3.0", | ||
"lodash": "^4.17.21" | ||
@@ -41,4 +42,3 @@ }, | ||
"./package.json": "./package.json" | ||
}, | ||
"readme": "# [GQty](https://gqty.dev) [![Documentation](https://img.shields.io/badge/documentation-documentation?color=C00B84)](https://gqty.dev)\n\n> GQty is a fully-featured GraphQL client, which lowers the barrier of entry towards using GraphQL.\n\nData requirements within your application are picked up automatically, freeing you from having to maintain GraphQL queries by-hand. It offers a first-class TypeScript experience. See API documentation at all times within autocomplete.\n\nMake breaking changes to your API, and see type-errors exactly where things are breaking, in realtime. No more running a separate validation step.\n\n**More documentation is available at [gqty.dev/docs/getting-started](https://gqty.dev/docs/getting-started).**\n\n<a href=\"https://gqty.dev\">\n <img alt=\"Example usage\" src=\"https://user-images.githubusercontent.com/13242392/112103674-fddc4980-8ba1-11eb-8c83-b527dcb0243d.PNG\" />\n</a>\n" | ||
} | ||
} |
@@ -9,3 +9,3 @@ import type { Selection } from '../Selection'; | ||
type: 'query' | 'mutation' | 'subscription'; | ||
}, normalization?: boolean | undefined, isGlobalCache?: boolean | undefined) => BuiltQuery; | ||
}, normalization?: boolean, isGlobalCache?: boolean) => BuiltQuery; | ||
export {}; |
@@ -15,14 +15,7 @@ import { Selection, SelectionConstructorArgs } from './selection'; | ||
} | ||
export declare type AliasBackupTuple = [aliasKey: string, alias: string]; | ||
export declare type VariableHashTuple = [ | ||
serializedVariables: string, | ||
incVariablesStringId: number | ||
variablesStringId: string | ||
]; | ||
export declare type AliasIncTuple = [key: string | number, incId: number]; | ||
export declare type SelectionsBackup = [ | ||
AliasBackupTuple[], | ||
VariableHashTuple[], | ||
AliasIncTuple[], | ||
string | ||
]; | ||
export declare type SelectionsBackup = [VariableHashTuple[], string]; | ||
export declare function createSelectionManager(): SelectionManager; |
@@ -5,2 +5,3 @@ 'use strict'; | ||
const sha1 = require('@gqty/utils/sha1'); | ||
const cachedJSON = require('../Utils/cachedJSON.js'); | ||
@@ -38,3 +39,3 @@ const selection = require('./selection.js'); | ||
} | ||
const selectionsBackupVersion = "v0"; | ||
const selectionsBackupVersion = "v1"; | ||
function isSelectionsBackup(selectionsBackup) { | ||
@@ -46,5 +47,2 @@ return Array.isArray(selectionsBackup) && Array.isArray(selectionsBackup[0]) && Array.isArray(selectionsBackup[1]) && Array.isArray(selectionsBackup[2]) && selectionsBackup[3] === selectionsBackupVersion; | ||
const selectionCache = /* @__PURE__ */ new Map(); | ||
const incIds = {}; | ||
const aliasMap = /* @__PURE__ */ new Map(); | ||
let incHashId = -1; | ||
const stringsHash = {}; | ||
@@ -56,17 +54,8 @@ let restoredBackup; | ||
if ((hashId = stringsHash[serializedVariables]) === void 0) { | ||
hashId = stringsHash[serializedVariables] = ++incHashId; | ||
hashId = stringsHash[serializedVariables] = sha1.sha1(serializedVariables).slice(0, 5); | ||
if (restoredBackup) | ||
restoredBackup[1].push([serializedVariables, hashId]); | ||
restoredBackup[0].push([serializedVariables, hashId]); | ||
} | ||
return hashId; | ||
} | ||
function getKeyHashId(key) { | ||
let hashId; | ||
if ((hashId = stringsHash[key]) === void 0) { | ||
hashId = stringsHash[key] = ++incHashId; | ||
if (restoredBackup) | ||
restoredBackup[1].push([key, hashId]); | ||
} | ||
return hashId; | ||
} | ||
function restore(backup2) { | ||
@@ -76,44 +65,19 @@ if (!isSelectionsBackup(backup2)) | ||
restoredBackup = backup2; | ||
for (const [aliasKey, alias] of backup2[0]) { | ||
aliasMap.set(aliasKey, alias); | ||
for (const [stringKey, hashIdValue] of backup2[1]) { | ||
stringsHash[stringKey] = hashIdValue; | ||
} | ||
for (const [stringKey, incHashIdValue] of backup2[1]) { | ||
stringsHash[stringKey] = incHashIdValue; | ||
incHashId = incHashIdValue; | ||
} | ||
for (const [key, incId] of backup2[2]) { | ||
incIds[key] = incId; | ||
} | ||
} | ||
function backup() { | ||
if (restoredBackup) { | ||
restoredBackup[2] = []; | ||
for (const key in incIds) | ||
restoredBackup[2].push([~~key, incIds[key]]); | ||
restoredBackup[0] = []; | ||
return restoredBackup; | ||
} | ||
const backup2 = [[], [], [], selectionsBackupVersion]; | ||
for (const [aliasKey, alias] of aliasMap.entries()) { | ||
backup2[0].push([aliasKey, alias]); | ||
} | ||
const backup2 = [[], selectionsBackupVersion]; | ||
for (const serializedVariables in stringsHash) { | ||
backup2[1].push([serializedVariables, stringsHash[serializedVariables]]); | ||
backup2[0].push([serializedVariables, stringsHash[serializedVariables]]); | ||
} | ||
for (const key in incIds) | ||
backup2[2].push([~~key, incIds[key]]); | ||
return restoredBackup = backup2; | ||
} | ||
function getVariableAlias(key, variables, variableTypes) { | ||
var _a; | ||
const hashedKey = typeof key === "string" ? getKeyHashId(key) : key; | ||
const aliasKey = `${hashedKey}-${getSerializedVariablesId(variables)}-${getSerializedVariablesId(variableTypes)}`; | ||
let alias = aliasMap.get(aliasKey); | ||
if (alias == null) { | ||
(_a = incIds[hashedKey]) != null ? _a : incIds[hashedKey] = -1; | ||
alias = `${key}${++incIds[hashedKey]}`; | ||
aliasMap.set(aliasKey, alias); | ||
if (restoredBackup) | ||
restoredBackup[0].push([aliasKey, alias]); | ||
} | ||
return alias; | ||
return key + "_" + getSerializedVariablesId(variableTypes) + "_" + getSerializedVariablesId(variables); | ||
} | ||
@@ -120,0 +84,0 @@ function getSelection({ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
239819
3
6647
1
+ Added@gqty/utils@1.0.0(transitive)