@pothos/plugin-relay
Advanced tools
Comparing version 3.20.0 to 3.21.0
# Change Log | ||
## 3.21.0 | ||
### Minor Changes | ||
- 33789284: Update cursor encoding to work in deno | ||
## 3.20.0 | ||
@@ -4,0 +10,0 @@ |
export * from './connections'; | ||
export * from './global-ids'; | ||
export * from './resolve-nodes'; | ||
export declare function encodeGlobalID(typename: string, id: bigint | number | string): string; | ||
export declare function decodeGlobalID(globalID: string): { | ||
typename: string; | ||
id: string; | ||
}; | ||
export declare function capitalize(s: string): string; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -0,1 +1,2 @@ | ||
import { decodeBase64, encodeBase64 } from '@pothos/core'; | ||
const OFFSET_CURSOR_PREFIX = "OffsetConnection:"; | ||
@@ -72,3 +73,3 @@ const DEFAULT_MAX_SIZE = 100; | ||
export function cursorToOffset(cursor) { | ||
const string = Buffer.from(cursor, "base64").toString(); | ||
const string = decodeBase64(cursor); | ||
if (!string.startsWith(OFFSET_CURSOR_PREFIX)) { | ||
@@ -80,3 +81,3 @@ throw new Error(`Invalid offset cursor ${OFFSET_CURSOR_PREFIX}`); | ||
export function offsetToCursor(offset) { | ||
return Buffer.from(`${OFFSET_CURSOR_PREFIX}${offset}`).toString("base64"); | ||
return encodeBase64(`${OFFSET_CURSOR_PREFIX}${offset}`); | ||
} | ||
@@ -83,0 +84,0 @@ export function resolveArrayConnection(options, array) { |
export * from './connections.js'; | ||
export * from './global-ids.js'; | ||
export * from './resolve-nodes.js'; | ||
export function encodeGlobalID(typename, id) { | ||
return Buffer.from(`${typename}:${id}`).toString("base64"); | ||
} | ||
export function decodeGlobalID(globalID) { | ||
const [typename, id] = Buffer.from(globalID, "base64").toString().split(":"); | ||
if (!typename || !id) { | ||
throw new TypeError(`Invalid global ID: ${globalID}`); | ||
} | ||
return { | ||
typename, | ||
id | ||
}; | ||
} | ||
export function capitalize(s) { | ||
@@ -17,0 +5,0 @@ return `${s.slice(0, 1).toUpperCase()}${s.slice(1)}`; |
@@ -1,2 +0,2 @@ | ||
import { decodeGlobalID, encodeGlobalID } from './index.js'; | ||
import { decodeGlobalID, encodeGlobalID } from './global-ids.js'; | ||
export function internalEncodeGlobalID(builder, typename, id) { | ||
@@ -3,0 +3,0 @@ if (builder.options.relayOptions.encodeGlobalID) { |
@@ -18,2 +18,3 @@ "use strict"; | ||
}); | ||
const _core = require("@pothos/core"); | ||
const OFFSET_CURSOR_PREFIX = 'OffsetConnection:'; | ||
@@ -90,3 +91,3 @@ const DEFAULT_MAX_SIZE = 100; | ||
function cursorToOffset(cursor) { | ||
const string = Buffer.from(cursor, 'base64').toString(); | ||
const string = (0, _core.decodeBase64)(cursor); | ||
if (!string.startsWith(OFFSET_CURSOR_PREFIX)) { | ||
@@ -98,3 +99,3 @@ throw new Error(`Invalid offset cursor ${OFFSET_CURSOR_PREFIX}`); | ||
function offsetToCursor(offset) { | ||
return Buffer.from(`${OFFSET_CURSOR_PREFIX}${offset}`).toString('base64'); | ||
return (0, _core.encodeBase64)(`${OFFSET_CURSOR_PREFIX}${offset}`); | ||
} | ||
@@ -101,0 +102,0 @@ function resolveArrayConnection(options, array) { |
@@ -5,14 +5,8 @@ "use strict"; | ||
}); | ||
function _export(target, all) { | ||
for(var name in all)Object.defineProperty(target, name, { | ||
enumerable: true, | ||
get: all[name] | ||
}); | ||
} | ||
_export(exports, { | ||
encodeGlobalID: ()=>encodeGlobalID, | ||
decodeGlobalID: ()=>decodeGlobalID, | ||
capitalize: ()=>capitalize | ||
Object.defineProperty(exports, "capitalize", { | ||
enumerable: true, | ||
get: ()=>capitalize | ||
}); | ||
_exportStar(require("./connections"), exports); | ||
_exportStar(require("./global-ids"), exports); | ||
_exportStar(require("./resolve-nodes"), exports); | ||
@@ -30,15 +24,2 @@ function _exportStar(from, to) { | ||
} | ||
function encodeGlobalID(typename, id) { | ||
return Buffer.from(`${typename}:${id}`).toString('base64'); | ||
} | ||
function decodeGlobalID(globalID) { | ||
const [typename, id] = Buffer.from(globalID, 'base64').toString().split(':'); | ||
if (!typename || !id) { | ||
throw new TypeError(`Invalid global ID: ${globalID}`); | ||
} | ||
return { | ||
typename, | ||
id | ||
}; | ||
} | ||
function capitalize(s) { | ||
@@ -45,0 +26,0 @@ return `${s.slice(0, 1).toUpperCase()}${s.slice(1)}`; |
@@ -15,3 +15,3 @@ "use strict"; | ||
}); | ||
const _ = require("."); | ||
const _globalIds = require("./global-ids"); | ||
function internalEncodeGlobalID(builder, typename, id) { | ||
@@ -21,3 +21,3 @@ if (builder.options.relayOptions.encodeGlobalID) { | ||
} | ||
return (0, _.encodeGlobalID)(typename, id); | ||
return (0, _globalIds.encodeGlobalID)(typename, id); | ||
} | ||
@@ -28,5 +28,5 @@ function internalDecodeGlobalID(builder, globalID) { | ||
} | ||
return (0, _.decodeGlobalID)(globalID); | ||
return (0, _globalIds.decodeGlobalID)(globalID); | ||
} | ||
//# sourceMappingURL=internal.js.map |
{ | ||
"name": "@pothos/plugin-relay", | ||
"version": "3.20.0", | ||
"version": "3.21.0", | ||
"description": "A Pothos plugin for adding relay style connections, nodes, and cursor based pagination to your GraphQL schema", | ||
@@ -40,4 +40,4 @@ "main": "./lib/index.js", | ||
"devDependencies": { | ||
"@pothos/core": "3.13.0", | ||
"@pothos/plugin-complexity": "3.6.0", | ||
"@pothos/core": "3.15.0", | ||
"@pothos/plugin-complexity": "3.6.1", | ||
"@pothos/test-utils": "1.3.0", | ||
@@ -44,0 +44,0 @@ "graphql": "16.5.0", |
@@ -1,2 +0,2 @@ | ||
import { MaybePromise, SchemaTypes } from '@pothos/core'; | ||
import { decodeBase64, encodeBase64, MaybePromise, SchemaTypes } from '@pothos/core'; | ||
import { ConnectionShape, DefaultConnectionArguments } from '../types'; | ||
@@ -131,3 +131,3 @@ | ||
export function cursorToOffset(cursor: string): number { | ||
const string = Buffer.from(cursor, 'base64').toString(); | ||
const string = decodeBase64(cursor); | ||
@@ -142,3 +142,3 @@ if (!string.startsWith(OFFSET_CURSOR_PREFIX)) { | ||
export function offsetToCursor(offset: number): string { | ||
return Buffer.from(`${OFFSET_CURSOR_PREFIX}${offset}`).toString('base64'); | ||
return encodeBase64(`${OFFSET_CURSOR_PREFIX}${offset}`); | ||
} | ||
@@ -145,0 +145,0 @@ |
export * from './connections'; | ||
export * from './global-ids'; | ||
export * from './resolve-nodes'; | ||
export function encodeGlobalID(typename: string, id: bigint | number | string) { | ||
return Buffer.from(`${typename}:${id}`).toString('base64'); | ||
} | ||
export function decodeGlobalID(globalID: string) { | ||
const [typename, id] = Buffer.from(globalID, 'base64').toString().split(':'); | ||
if (!typename || !id) { | ||
throw new TypeError(`Invalid global ID: ${globalID}`); | ||
} | ||
return { typename, id }; | ||
} | ||
export function capitalize(s: string) { | ||
return `${s.slice(0, 1).toUpperCase()}${s.slice(1)}`; | ||
} |
import { SchemaTypes } from '@pothos/core'; | ||
import { decodeGlobalID, encodeGlobalID } from '.'; | ||
import { decodeGlobalID, encodeGlobalID } from './global-ids'; | ||
@@ -4,0 +4,0 @@ export function internalEncodeGlobalID<Types extends SchemaTypes>( |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
372285
86
4211