Socket
Socket
Sign inDemoInstall

graphile-build-pg

Package Overview
Dependencies
Maintainers
1
Versions
208
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graphile-build-pg - npm Package Compare versions

Comparing version 5.0.0-alpha.18 to 5.0.0-alpha.19

5

dist/plugins/PgCustomTypeFieldPlugin.js

@@ -96,4 +96,5 @@ "use strict";

}
const name = details.resource.name;
const codecName = details.resource.parameters[0].codec.extensions?.pg?.name;
const name = details.resource.extensions?.pg?.name ?? details.resource.name;
const codecName = details.resource.parameters[0].codec.extensions?.pg?.name ??
details.resource.parameters[0].codec.name;
const legacyPrefix = codecName + "_";

@@ -100,0 +101,0 @@ if (name.startsWith(legacyPrefix)) {

23

dist/plugins/PgJWTPlugin.d.ts
import "graphile-config";
import type { PgCodec } from "@dataplan/pg";
import type { Secret, SignOptions } from "jsonwebtoken";
declare global {
namespace GraphileBuild {
interface SchemaOptions {
pgJwtSecret?: any;
pgJwtSignOptions?: any;
pgJwtSecret?: Secret;
pgJwtSignOptions?: SignOptions;
}
interface GatherOptions {
/** @deprecated use pgJwtTypes instead */
pgJwtType?: string | [string, string];
/**
* If you would like PostGraphile to automatically recognize a PostgreSQL
* type as a JWT, you should pass a tuple of the
* `["<schema name>", "<type name>"]` so we can recognize it. This is
* case sensitive.
* If you would like PostGraphile to automatically recognize certain
* PostgreSQL types as a JWT, you should pass a list of their identifiers
* here:
* `pgJwtTypes: ['my_schema.my_jwt_type', 'my_schema."myOtherJwtType"']`
*
* Parsing is similar to PostgreSQL's parsing, so identifiers are
* lower-cased unless they are escaped via double quotes.
*
* You can alternatively supply a comma-separated list if you prefer:
* `pgJwtTypes: 'my_schema.my_jwt_type,my_schema."myOtherJwtType"'`
*/
pgJwtType?: [string, string];
pgJwtTypes?: string | string[];
}

@@ -18,0 +27,0 @@ interface ScopeScalar {

@@ -7,4 +7,24 @@ "use strict";

const jsonwebtoken_1 = require("jsonwebtoken");
const utils_js_1 = require("../utils.js");
const version_js_1 = require("../version.js");
const EMPTY_OBJECT = Object.freeze({});
function getPgJwtTypeDigests(options) {
const digests = [];
if (Array.isArray(options.pgJwtType)) {
digests.push(options.pgJwtType);
}
else if (typeof options.pgJwtType === "string") {
const tuples = (0, utils_js_1.parseDatabaseIdentifiers)(options.pgJwtType, 2, "public");
digests.push(...tuples);
}
if (typeof options.pgJwtTypes === "string") {
const tuples = (0, utils_js_1.parseDatabaseIdentifiers)(options.pgJwtTypes, 2, "public");
digests.push(...tuples);
}
if (Array.isArray(options.pgJwtTypes)) {
const tuples = options.pgJwtTypes.map((type) => (0, utils_js_1.parseDatabaseIdentifier)(type, 2, "public"));
digests.push(...tuples);
}
return digests;
}
exports.PgJWTPlugin = {

@@ -26,4 +46,4 @@ name: "PgJWTPlugin",

pgCodecs_PgCodec(info, { pgCodec, pgType }) {
if (info.options.pgJwtType?.[1] === pgType.typname &&
info.options.pgJwtType?.[0] === pgType.getNamespace().nspname) {
const pgJwtTypeDigests = getPgJwtTypeDigests(info.options);
if (pgJwtTypeDigests.some(([nsp, typ]) => typ === pgType.typname && nsp === pgType.getNamespace().nspname)) {
// It's a JWT type!

@@ -42,3 +62,3 @@ pgCodec.extensions ||= Object.create(null);

const jwtCodec = [...build.pgCodecMetaLookup.keys()].find((codec) => build.behavior.pgCodecMatches(codec, "jwt"));
if (!jwtCodec) {
if (!jwtCodec || !pgJwtSecret) {
return _;

@@ -45,0 +65,0 @@ }

@@ -383,2 +383,34 @@ "use strict";

},
pgCodecRelation: {
provides: ["inferred"],
after: ["default", "PgRelationsPlugin"],
before: ["override"],
callback(behavior, entity, build) {
const { input: { pgRegistry: { pgRelations }, }, } = build;
const { localCodec, remoteResource, isUnique, isReferencee } = entity;
const remoteCodec = remoteResource.codec;
// Hide relation from a concrete type back to the abstract root table.
if (isUnique &&
!isReferencee &&
remoteCodec.polymorphism?.mode === "relational") {
const localTypeName = build.inflection.tableType(localCodec);
const polymorphicTypeDefinitionEntry = Object.entries(remoteCodec.polymorphism.types).find(([, val]) => val.name === localTypeName);
if (polymorphicTypeDefinitionEntry) {
const [, { relationName }] = polymorphicTypeDefinitionEntry;
const relation = pgRelations[remoteCodec.name]?.[relationName];
if ((0, grafast_1.arraysMatch)(relation.remoteAttributes, entity.localAttributes)) {
return [behavior, "-connection -list -single"];
}
}
}
// Hide relation from abstract root table to related elements
if (isReferencee && localCodec.polymorphism?.mode === "relational") {
const relations = Object.values(localCodec.polymorphism.types).map((t) => pgRelations[localCodec.name]?.[t.relationName]);
if (relations.includes(entity)) {
return [behavior, "-connection -list -single"];
}
}
return behavior;
},
},
},

@@ -450,13 +482,13 @@ hooks: {

}), `PgPolymorphismPlugin single table type for ${codec.name}`);
build.registerCursorConnection({
typeName: tableTypeName,
connectionTypeName: inflection.connectionType(tableTypeName),
edgeTypeName: inflection.edgeType(tableTypeName),
scope: {
isPgConnectionRelated: true,
pgCodec: codec,
},
nonNullNode: pgForbidSetofFunctionsToReturnNull,
});
}
build.registerCursorConnection({
typeName: tableTypeName,
connectionTypeName: inflection.connectionType(tableTypeName),
edgeTypeName: inflection.edgeType(tableTypeName),
scope: {
isPgConnectionRelated: true,
pgCodec: codec,
},
nonNullNode: pgForbidSetofFunctionsToReturnNull,
});
}

@@ -463,0 +495,0 @@ }

@@ -216,5 +216,9 @@ "use strict";

codec: argCodec,
extensions: {
variant,
},
...(variant
? {
extensions: {
variant,
},
}
: null),
});

@@ -310,3 +314,3 @@ }

else {
const options = {
const options = (0, graphile_build_1.EXPORTABLE)((description, executor, extensions, fromCallback, identifier, isMutation, name, parameters, returnCodec, returnsSetof) => ({
executor,

@@ -323,3 +327,14 @@ name,

description,
};
}), [
description,
executor,
extensions,
fromCallback,
identifier,
isMutation,
name,
parameters,
returnCodec,
returnsSetof,
]);
await info.process("pgProcedures_PgResourceOptions", {

@@ -326,0 +341,0 @@ serviceName,

@@ -19,6 +19,6 @@ "use strict";

const pgService = options.pgServices?.find((db) => db.name === serviceName);
const databasePrefix = serviceName === pgService?.name ? "" : `${serviceName}-`;
const databasePrefix = serviceName === pgService?.name ? "" : `${serviceName}_`;
const schemaPrefix = pgNamespace.nspname === pgService?.schemas?.[0]
? ""
: `${pgNamespace.nspname}-`;
: `${pgNamespace.nspname}_`;
return `${databasePrefix}${schemaPrefix}`;

@@ -25,0 +25,0 @@ },

@@ -34,28 +34,28 @@ "use strict";

// why it's not global).
build.registerScalarType(inflection.builtin("Time"), {}, () => stringTypeSpec(build.wrapDescription("The exact time of day, does not include the date. May or may not have a timezone offset.", "type")), "graphile-build-pg built-in (Time)");
build.registerScalarType(inflection.builtin("Time"), {}, () => stringTypeSpec(build.wrapDescription("The exact time of day, does not include the date. May or may not have a timezone offset.", "type"), undefined, inflection.builtin("Time")), "graphile-build-pg built-in (Time)");
doConnection("Time");
// A bunch more postgres-specific types
build.registerScalarType(inflection.builtin("BitString"), {}, () => stringTypeSpec(build.wrapDescription("A string representing a series of binary bits", "type")), "graphile-build-pg built-in (BitString)");
build.registerScalarType(inflection.builtin("BitString"), {}, () => stringTypeSpec(build.wrapDescription("A string representing a series of binary bits", "type"), undefined, inflection.builtin("BitString")), "graphile-build-pg built-in (BitString)");
doConnection("BitString");
build.registerScalarType(inflection.builtin("InternetAddress"), {}, () => stringTypeSpec(build.wrapDescription("An IPv4 or IPv6 host address, and optionally its subnet.", "type")), "graphile-build-pg built-in (InternetAddress)");
build.registerScalarType(inflection.builtin("InternetAddress"), {}, () => stringTypeSpec(build.wrapDescription("An IPv4 or IPv6 host address, and optionally its subnet.", "type"), undefined, inflection.builtin("InternetAddress")), "graphile-build-pg built-in (InternetAddress)");
doConnection("InternetAddress");
build.registerScalarType(inflection.builtin("RegProc"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a function name", "type")), "graphile-build-pg built-in (RegProc)");
build.registerScalarType(inflection.builtin("RegProc"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a function name", "type"), undefined, inflection.builtin("RegProc")), "graphile-build-pg built-in (RegProc)");
doConnection("RegProc");
build.registerScalarType(inflection.builtin("RegProcedure"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a function with argument types", "type")), "graphile-build-pg built-in (RegProcedure)");
build.registerScalarType(inflection.builtin("RegProcedure"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a function with argument types", "type"), undefined, inflection.builtin("RegProcedure")), "graphile-build-pg built-in (RegProcedure)");
doConnection("RegProcedure");
build.registerScalarType(inflection.builtin("RegOper"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for an operator", "type")), "graphile-build-pg built-in (RegOper)");
build.registerScalarType(inflection.builtin("RegOper"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for an operator", "type"), undefined, inflection.builtin("RegOper")), "graphile-build-pg built-in (RegOper)");
doConnection("RegOper");
build.registerScalarType(inflection.builtin("RegOperator"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for an operator with argument types", "type")), "graphile-build-pg built-in (RegOperator)");
build.registerScalarType(inflection.builtin("RegOperator"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for an operator with argument types", "type"), undefined, inflection.builtin("RegOperator")), "graphile-build-pg built-in (RegOperator)");
doConnection("RegOperator");
build.registerScalarType(inflection.builtin("RegClass"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a relation name", "type")), "graphile-build-pg built-in (RegClass)");
build.registerScalarType(inflection.builtin("RegClass"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a relation name", "type"), undefined, inflection.builtin("RegClass")), "graphile-build-pg built-in (RegClass)");
doConnection("RegClass");
build.registerScalarType(inflection.builtin("RegType"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a data type name", "type")), "graphile-build-pg built-in (RegType)");
build.registerScalarType(inflection.builtin("RegType"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a data type name", "type"), undefined, inflection.builtin("RegType")), "graphile-build-pg built-in (RegType)");
doConnection("RegType");
build.registerScalarType(inflection.builtin("RegRole"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a role name", "type")), "graphile-build-pg built-in (RegRole)");
build.registerScalarType(inflection.builtin("RegRole"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a role name", "type"), undefined, inflection.builtin("RegRole")), "graphile-build-pg built-in (RegRole)");
doConnection("RegRole");
build.registerScalarType(inflection.builtin("RegNamespace"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a namespace name", "type")), "graphile-build-pg built-in (RegNamespace)");
build.registerScalarType(inflection.builtin("RegNamespace"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a namespace name", "type"), undefined, inflection.builtin("RegNamespace")), "graphile-build-pg built-in (RegNamespace)");
doConnection("RegNamespace");
build.registerScalarType(inflection.builtin("RegConfig"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a text search configuration", "type")), "graphile-build-pg built-in (RegConfig)");
build.registerScalarType(inflection.builtin("RegConfig"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a text search configuration", "type"), undefined, inflection.builtin("RegConfig")), "graphile-build-pg built-in (RegConfig)");
doConnection("RegConfig");
build.registerScalarType(inflection.builtin("RegDictionary"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a text search dictionary", "type")), "graphile-build-pg built-in (RegDictionary)");
build.registerScalarType(inflection.builtin("RegDictionary"), {}, () => stringTypeSpec(build.wrapDescription("A builtin object identifier type for a text search dictionary", "type"), undefined, inflection.builtin("RegDictionary")), "graphile-build-pg built-in (RegDictionary)");
doConnection("RegDictionary");

@@ -90,7 +90,7 @@ build.registerScalarType(inflection.builtin("Base64EncodedBinary"), {}, () => ({

if (pgUseCustomNetworkScalars !== false) {
build.registerScalarType(inflection.builtin("CidrAddress"), {}, () => stringTypeSpec(build.wrapDescription("An IPv4 or IPv6 CIDR address.", "type")), "graphile-build-pg built-in (CidrAddress)");
build.registerScalarType(inflection.builtin("CidrAddress"), {}, () => stringTypeSpec(build.wrapDescription("An IPv4 or IPv6 CIDR address.", "type"), undefined, inflection.builtin("CidrAddress")), "graphile-build-pg built-in (CidrAddress)");
doConnection("CidrAddress");
build.registerScalarType(inflection.builtin("MacAddress"), {}, () => stringTypeSpec(build.wrapDescription("A 6-byte MAC address.", "type")), "graphile-build-pg built-in (MacAddress)");
build.registerScalarType(inflection.builtin("MacAddress"), {}, () => stringTypeSpec(build.wrapDescription("A 6-byte MAC address.", "type"), undefined, inflection.builtin("MacAddress")), "graphile-build-pg built-in (MacAddress)");
doConnection("MacAddress");
build.registerScalarType(inflection.builtin("MacAddress8"), {}, () => stringTypeSpec(build.wrapDescription("An 8-byte MAC address.", "type")), "graphile-build-pg built-in (MacAddress8)");
build.registerScalarType(inflection.builtin("MacAddress8"), {}, () => stringTypeSpec(build.wrapDescription("An 8-byte MAC address.", "type"), undefined, inflection.builtin("MacAddress8")), "graphile-build-pg built-in (MacAddress8)");
doConnection("MacAddress8");

@@ -97,0 +97,0 @@ }

@@ -1,2 +0,2 @@

export declare const version = "5.0.0-alpha.17";
export declare const version = "5.0.0-alpha.19";
//# sourceMappingURL=version.d.ts.map

@@ -5,3 +5,3 @@ "use strict";

// This file is autogenerated by /scripts/postversion.mjs
exports.version = "5.0.0-alpha.17";
exports.version = "5.0.0-alpha.19";
//# sourceMappingURL=version.js.map
{
"name": "graphile-build-pg",
"version": "5.0.0-alpha.18",
"version": "5.0.0-alpha.19",
"description": "PostgreSQL plugins for Graphile Build - build a supercharged GraphQL schema by reflection over a PostgreSQL database and executed by Grafast.",

@@ -49,3 +49,3 @@ "type": "commonjs",

"debug": "^4.3.3",
"graphile-config": "^0.0.1-alpha.6",
"graphile-config": "^0.0.1-alpha.7",
"jsonwebtoken": "^8.5.1",

@@ -56,6 +56,6 @@ "pg-introspection": "^0.0.1-alpha.4",

"peerDependencies": {
"@dataplan/pg": "^0.0.1-alpha.15",
"grafast": "^0.0.1-alpha.14",
"graphile-build": "5.0.0-alpha.16",
"graphile-config": "^0.0.1-alpha.6",
"@dataplan/pg": "^0.0.1-alpha.16",
"grafast": "^0.0.1-alpha.15",
"graphile-build": "5.0.0-alpha.17",
"graphile-config": "^0.0.1-alpha.7",
"graphql": "^16.1.0-experimental-stream-defer.6",

@@ -92,3 +92,3 @@ "pg": "^8.7.1",

"fastify-static": "^4.5.0",
"graphile-export": "^0.0.2-alpha.7",
"graphile-export": "^0.0.2-alpha.8",
"graphql": "16.1.0-experimental-stream-defer.6",

@@ -99,3 +99,3 @@ "graphql-helix": "^1.11.0",

"pg": "^8.7.1",
"ruru": "^2.0.0-alpha.10",
"ruru": "^2.0.0-alpha.11",
"ts-node": "^10.9.1",

@@ -102,0 +102,0 @@ "typescript": "^5.0.4",

@@ -48,2 +48,3 @@ # graphile-build-pg

<td align="center"><a href="https://stellate.co/"><img src="https://graphile.org/images/sponsors/Stellate.png" width="90" height="90" alt="Stellate" /><br />Stellate</a> *</td>
<td align="center"><a href="https://www.accenture.com/"><img src="https://graphile.org/images/sponsors/accenture.svg" width="90" height="90" alt="Accenture" /><br />Accenture</a> *</td>
</tr></table>

@@ -50,0 +51,0 @@

Sorry, the diff of this file is too big to display

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc