postgraphile 5.0.0-beta.3 → 5.0.0-beta.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1151 -0
- package/README.md +6 -9
- package/dist/cli.d.ts +2 -2
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +12 -11
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/plugins/PgV4BehaviorPlugin.d.ts +3 -0
- package/dist/plugins/PgV4BehaviorPlugin.d.ts.map +1 -1
- package/dist/plugins/PgV4BehaviorPlugin.js +36 -51
- package/dist/plugins/PgV4BehaviorPlugin.js.map +1 -1
- package/dist/plugins/PgV4InflectionPlugin.d.ts +3 -0
- package/dist/plugins/PgV4InflectionPlugin.d.ts.map +1 -1
- package/dist/plugins/PgV4InflectionPlugin.js +6 -4
- package/dist/plugins/PgV4InflectionPlugin.js.map +1 -1
- package/dist/plugins/PgV4SimpleSubscriptionsPlugin.d.ts +2 -0
- package/dist/plugins/PgV4SimpleSubscriptionsPlugin.d.ts.map +1 -0
- package/dist/plugins/PgV4SimpleSubscriptionsPlugin.js +76 -0
- package/dist/plugins/PgV4SimpleSubscriptionsPlugin.js.map +1 -0
- package/dist/plugins/PgV4SmartTagsPlugin.d.ts +6 -0
- package/dist/plugins/PgV4SmartTagsPlugin.d.ts.map +1 -1
- package/dist/plugins/PgV4SmartTagsPlugin.js +34 -15
- package/dist/plugins/PgV4SmartTagsPlugin.js.map +1 -1
- package/dist/presets/lazy-jwt.d.ts +7 -0
- package/dist/presets/lazy-jwt.d.ts.map +1 -1
- package/dist/presets/lazy-jwt.js +17 -10
- package/dist/presets/lazy-jwt.js.map +1 -1
- package/dist/presets/relay.d.ts +7 -0
- package/dist/presets/relay.d.ts.map +1 -1
- package/dist/presets/relay.js +96 -67
- package/dist/presets/relay.js.map +1 -1
- package/dist/presets/v4.d.ts +3 -1
- package/dist/presets/v4.d.ts.map +1 -1
- package/dist/presets/v4.js +37 -21
- package/dist/presets/v4.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/fwd/grafast/mermaid/index.d.ts +1 -0
- package/fwd/grafast/mermaid/index.js +1 -0
- package/fwd/grafserv/envelop/index.d.ts +1 -0
- package/fwd/grafserv/envelop/index.js +1 -0
- package/fwd/grafserv/h3/v1/index.d.ts +1 -0
- package/fwd/grafserv/h3/v1/index.js +1 -0
- package/fwd/grafserv/lambda/v1/index.d.ts +1 -0
- package/fwd/grafserv/lambda/v1/index.js +1 -0
- package/package.json +68 -42
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PgV4SmartTagsPlugin = void 0;
|
|
4
4
|
require("graphile-config");
|
|
5
5
|
const graphile_build_1 = require("graphile-build");
|
|
6
|
-
const graphile_build_pg_1 = require("graphile-build-pg");
|
|
7
6
|
const util_1 = require("util");
|
|
8
7
|
const EMPTY_OBJECT = Object.freeze({});
|
|
9
8
|
exports.PgV4SmartTagsPlugin = {
|
|
@@ -48,7 +47,7 @@ exports.PgV4SmartTagsPlugin = {
|
|
|
48
47
|
const arr = Array.isArray(attrOmit) ? attrOmit : [attrOmit];
|
|
49
48
|
const omitRead = arr.some((omit) => omit === true || expandOmit(omit).includes("read"));
|
|
50
49
|
if (omitRead) {
|
|
51
|
-
|
|
50
|
+
addBehaviorToTags(pgConstraint.getTags(), "-select", true);
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
}
|
|
@@ -71,24 +70,24 @@ exports.default = exports.PgV4SmartTagsPlugin;
|
|
|
71
70
|
function processTags(tags) {
|
|
72
71
|
processUniqueKey(tags);
|
|
73
72
|
processOmit(tags);
|
|
74
|
-
convertBoolean(tags, "sortable", "orderBy order");
|
|
73
|
+
convertBoolean(tags, "sortable", "orderBy order resource:connection:backwards");
|
|
75
74
|
convertBoolean(tags, "filterable", "filter filterBy");
|
|
76
|
-
convertBoolean(tags, "enum", "enum");
|
|
75
|
+
// convertBoolean(tags, "enum", "enum");
|
|
77
76
|
processSimpleCollections(tags);
|
|
78
77
|
}
|
|
79
78
|
function processSimpleCollections(tags) {
|
|
80
79
|
if (tags?.simpleCollections) {
|
|
81
80
|
switch (tags.simpleCollections) {
|
|
82
81
|
case "omit": {
|
|
83
|
-
|
|
82
|
+
addBehaviorToTags(tags, "-list +connection", true);
|
|
84
83
|
break;
|
|
85
84
|
}
|
|
86
85
|
case "both": {
|
|
87
|
-
|
|
86
|
+
addBehaviorToTags(tags, "+list +connection", true);
|
|
88
87
|
break;
|
|
89
88
|
}
|
|
90
89
|
case "only": {
|
|
91
|
-
|
|
90
|
+
addBehaviorToTags(tags, "+list -connection", true);
|
|
92
91
|
break;
|
|
93
92
|
}
|
|
94
93
|
default: {
|
|
@@ -99,7 +98,7 @@ function processSimpleCollections(tags) {
|
|
|
99
98
|
}
|
|
100
99
|
function convertBoolean(tags, key, behavior) {
|
|
101
100
|
if (tags && tags[key]) {
|
|
102
|
-
|
|
101
|
+
addBehaviorToTags(tags, behavior, true);
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
104
|
function processUniqueKey(tags) {
|
|
@@ -155,11 +154,10 @@ function processOmit(tags) {
|
|
|
155
154
|
return;
|
|
156
155
|
}
|
|
157
156
|
const behavior = [];
|
|
158
|
-
const processOmit = (
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
}
|
|
157
|
+
const processOmit = (rawOmit) => {
|
|
158
|
+
const omit = rawOmit === true || rawOmit === "*"
|
|
159
|
+
? "create,read,update,delete,execute,filter,order,all,many,manyToMany"
|
|
160
|
+
: rawOmit;
|
|
163
161
|
if (typeof omit !== "string") {
|
|
164
162
|
throw new Error(`Issue in smart tags; expected omit to be true/string/string[], but found something unexpected: ${(0, util_1.inspect)(omit)}`);
|
|
165
163
|
}
|
|
@@ -171,7 +169,7 @@ function processOmit(tags) {
|
|
|
171
169
|
break;
|
|
172
170
|
}
|
|
173
171
|
case "read": {
|
|
174
|
-
behavior.push("-select -node");
|
|
172
|
+
behavior.push("-select -node -connection -list -array -single");
|
|
175
173
|
break;
|
|
176
174
|
}
|
|
177
175
|
case "update": {
|
|
@@ -228,6 +226,27 @@ function processOmit(tags) {
|
|
|
228
226
|
else {
|
|
229
227
|
processOmit(omit);
|
|
230
228
|
}
|
|
231
|
-
|
|
229
|
+
addBehaviorToTags(tags, behavior.join(" "), true);
|
|
230
|
+
}
|
|
231
|
+
function addBehaviorToTags(tags, behavior, prepend = false) {
|
|
232
|
+
if (Array.isArray(tags.behavior)) {
|
|
233
|
+
if (prepend) {
|
|
234
|
+
tags.behavior = [behavior, ...tags.behavior];
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
tags.behavior = [...tags.behavior, behavior];
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
else if (typeof tags.behavior === "string") {
|
|
241
|
+
tags.behavior = prepend
|
|
242
|
+
? [behavior, tags.behavior]
|
|
243
|
+
: [tags.behavior, behavior];
|
|
244
|
+
}
|
|
245
|
+
else if (!tags.behavior) {
|
|
246
|
+
tags.behavior = [behavior];
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
throw new Error(`Did not understand tags.behavior - it wasn't an array or a string`);
|
|
250
|
+
}
|
|
232
251
|
}
|
|
233
252
|
//# sourceMappingURL=PgV4SmartTagsPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PgV4SmartTagsPlugin.js","sourceRoot":"","sources":["../../src/plugins/PgV4SmartTagsPlugin.ts"],"names":[],"mappings":";;;AAAA,2BAAyB;AAEzB,mDAA8C;
|
|
1
|
+
{"version":3,"file":"PgV4SmartTagsPlugin.js","sourceRoot":"","sources":["../../src/plugins/PgV4SmartTagsPlugin.ts"],"names":[],"mappings":";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AQ,CAAC;YAC3B,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;KAC/B;SAAM,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;QACzB,IAAI,CAAC,QAAQ,GAAG,CAAC,QAAQ,CAAC,CAAC;KAC5B;SAAM;QACL,MAAM,IAAI,KAAK,CACb,mEAAmE,CACpE,CAAC;KACH;AACH,CAAC"}
|
|
@@ -8,6 +8,13 @@ declare global {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
+
declare global {
|
|
12
|
+
namespace GraphileConfig {
|
|
13
|
+
interface Plugins {
|
|
14
|
+
GrafservPgJWTPlugin: true;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
11
18
|
/**
|
|
12
19
|
* You really ought to handle JWTs yourself in the `preset.grafast.context`
|
|
13
20
|
* function; this allows you to control the settings for validation, to ensure
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-jwt.d.ts","sourceRoot":"","sources":["../../src/presets/lazy-jwt.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EACV,oBAAoB,EAEpB,MAAM,EACN,aAAa,EACd,MAAM,cAAc,CAAC;AAKtB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,cAAc,CAAC;QACvB,UAAU,eAAe;YACvB,WAAW,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAAC;YAC5C,kBAAkB,CAAC,EAAE,aAAa,CAAC;SACpC;KACF;CACF;
|
|
1
|
+
{"version":3,"file":"lazy-jwt.d.ts","sourceRoot":"","sources":["../../src/presets/lazy-jwt.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AAIzB,OAAO,KAAK,EACV,oBAAoB,EAEpB,MAAM,EACN,aAAa,EACd,MAAM,cAAc,CAAC;AAKtB,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,cAAc,CAAC;QACvB,UAAU,eAAe;YACvB,WAAW,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAAC;YAC5C,kBAAkB,CAAC,EAAE,aAAa,CAAC;SACpC;KACF;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,cAAc,CAAC;QACvB,UAAU,OAAO;YACf,mBAAmB,EAAE,IAAI,CAAC;SAC3B;KACF;CACF;AA4ED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,CAAC,MAE5C,CAAC"}
|
package/dist/presets/lazy-jwt.js
CHANGED
|
@@ -9,18 +9,20 @@ const GrafservPgJWTPlugin = {
|
|
|
9
9
|
name: "GrafservPgJWTPlugin",
|
|
10
10
|
version: version_js_1.version,
|
|
11
11
|
grafast: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const { args
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
middleware: {
|
|
13
|
+
prepareArgs(next, event) {
|
|
14
|
+
const { args } = event;
|
|
15
|
+
const { resolvedPreset, requestContext: ctx } = args;
|
|
16
|
+
const secret = resolvedPreset?.grafserv?.pgJwtSecret ??
|
|
17
|
+
resolvedPreset?.schema?.pgJwtSecret;
|
|
18
|
+
const pgJwtVerifyOptions = resolvedPreset?.grafserv?.pgJwtVerifyOptions;
|
|
18
19
|
if (secret) {
|
|
19
|
-
const authorization = ctx
|
|
20
|
+
const authorization = ctx?.node?.req?.headers?.authorization;
|
|
20
21
|
if (typeof authorization === "string") {
|
|
21
22
|
const [bearer, token] = authorization.split(" ");
|
|
22
23
|
if (bearer.toLowerCase() === "bearer") {
|
|
23
|
-
return Promise.resolve()
|
|
24
|
+
return Promise.resolve()
|
|
25
|
+
.then(async () => {
|
|
24
26
|
const claims = await new Promise((resolve, reject) => (0, jsonwebtoken_1.verify)(token, secret, {
|
|
25
27
|
algorithms: ["HS256", "HS384"],
|
|
26
28
|
audience: "postgraphile",
|
|
@@ -28,10 +30,13 @@ const GrafservPgJWTPlugin = {
|
|
|
28
30
|
complete: false,
|
|
29
31
|
}, (err, claims) => {
|
|
30
32
|
if (err) {
|
|
33
|
+
err.statusCode = 401;
|
|
31
34
|
reject(err);
|
|
32
35
|
}
|
|
33
36
|
else if (!claims || typeof claims === "string") {
|
|
34
|
-
reject(new Error("Invalid JWT payload")
|
|
37
|
+
reject(Object.assign(new Error("Invalid JWT payload"), {
|
|
38
|
+
statusCode: 401,
|
|
39
|
+
}));
|
|
35
40
|
}
|
|
36
41
|
else {
|
|
37
42
|
resolve(claims);
|
|
@@ -51,10 +56,12 @@ const GrafservPgJWTPlugin = {
|
|
|
51
56
|
pgSettings[`jwt.claims.${key}`] = String(value);
|
|
52
57
|
}
|
|
53
58
|
}
|
|
54
|
-
})
|
|
59
|
+
})
|
|
60
|
+
.then(next);
|
|
55
61
|
}
|
|
56
62
|
}
|
|
57
63
|
}
|
|
64
|
+
return next();
|
|
58
65
|
},
|
|
59
66
|
},
|
|
60
67
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazy-jwt.js","sourceRoot":"","sources":["../../src/presets/lazy-jwt.ts"],"names":[],"mappings":";;;AAAA,2BAAyB;AAGzB,yDAAgD;AAOhD,+CAAmD;AAEnD,8CAAwC;
|
|
1
|
+
{"version":3,"file":"lazy-jwt.js","sourceRoot":"","sources":["../../src/presets/lazy-jwt.ts"],"names":[],"mappings":";;;AAAA,2BAAyB;AAGzB,yDAAgD;AAOhD,+CAAmD;AAEnD,8CAAwC;AAmBxC,MAAM,mBAAmB,GAA0B;IACjD,IAAI,EAAE,qBAAqB;IAC3B,OAAO,EAAP,oBAAO;IAEP,OAAO,EAAE;QACP,UAAU,EAAE;YACV,WAAW,CAAC,IAAI,EAAE,KAAK;gBACrB,MAAM,EAAE,IAAI,EAAE,GAAG,KAAK,CAAC;gBACvB,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;gBACrD,MAAM,MAAM,GACV,cA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AI,CAAC,YAAY,CAAC,UAAU,EAAE;oCACjC,IAAI,CAAC,YAAY,CAAC,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;iCACpD;gCACD,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,UAAW,CAAC;gCACjD,IAAI,MAAM,CAAC,IAAI,EAAE;oCACf,UAAU,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC;iCAC/B;gCACD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE;oCACjD,IACE,KAAK;wCACL,qBAAqB,CAAC,IAAI,CAAC,GAAG,CAAC;wCAC/B,GAAG,CAAC,MAAM,IAAI,EAAE,EAChB;wCACA,UAAU,CAAC,cAAc,GAAG,EAAE,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;qCACjD;iCACF;4BACH,CAAC,CAAC;iCACD,IAAI,CAAC,IAAI,CAAC,CAAC;yBACf;qBACF;iBACF;gBACD,OAAO,IAAI,EAAE,CAAC;YAChB,CAAC;SACF;KACF;CACF,CAAC;AAEF;;;;;;;;;;GAUG;AACU,QAAA,eAAe,GAA0B;IACpD,OAAO,EAAE,CAAC,+BAAW,EAAE,mBAAmB,CAAC;CAC5C,CAAC"}
|
package/dist/presets/relay.d.ts
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import "graphile-config";
|
|
2
2
|
import "graphile-build-pg";
|
|
3
|
+
declare global {
|
|
4
|
+
namespace GraphileConfig {
|
|
5
|
+
interface Plugins {
|
|
6
|
+
PgRelayPlugin: true;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
}
|
|
3
10
|
/** @experimental */
|
|
4
11
|
export declare const PgRelayPlugin: GraphileConfig.Plugin;
|
|
5
12
|
/** @experimental */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/presets/relay.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AACzB,OAAO,mBAAmB,CAAC;AAc3B,oBAAoB;AACpB,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,
|
|
1
|
+
{"version":3,"file":"relay.d.ts","sourceRoot":"","sources":["../../src/presets/relay.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,CAAC;AACzB,OAAO,mBAAmB,CAAC;AAc3B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,cAAc,CAAC;QACvB,UAAU,OAAO;YACf,aAAa,EAAE,IAAI,CAAC;SACrB;KACF;CACF;AAED,oBAAoB;AACpB,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,MAkI1C,CAAC;AAEF,oBAAoB;AACpB,eAAO,MAAM,uBAAuB,EAAE,cAAc,CAAC,MAMpD,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,aAAa,uBAA0B,CAAC"}
|
package/dist/presets/relay.js
CHANGED
|
@@ -23,7 +23,7 @@ exports.PgRelayPlugin = {
|
|
|
23
23
|
return "id";
|
|
24
24
|
},
|
|
25
25
|
attribute(previous, options, details) {
|
|
26
|
-
const name = previous
|
|
26
|
+
const name = previous(details);
|
|
27
27
|
if (name === "id")
|
|
28
28
|
return "rowId";
|
|
29
29
|
return name;
|
|
@@ -32,76 +32,105 @@ exports.PgRelayPlugin = {
|
|
|
32
32
|
ignoreReplaceIfNotExists: ["attribute"],
|
|
33
33
|
},
|
|
34
34
|
schema: {
|
|
35
|
-
globalBehavior:
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
globalBehavior: [
|
|
36
|
+
"node",
|
|
37
|
+
"connection",
|
|
38
|
+
"-list",
|
|
39
|
+
"-query:resource:single",
|
|
40
|
+
"nodeId:filterBy",
|
|
41
|
+
"nodeId:resource:update",
|
|
42
|
+
"-constraint:resource:update",
|
|
43
|
+
"nodeId:resource:delete",
|
|
44
|
+
"-constraint:resource:delete",
|
|
45
|
+
"nodeId:insert",
|
|
46
|
+
"nodeId:update",
|
|
47
|
+
"nodeId:base",
|
|
48
|
+
],
|
|
46
49
|
entityBehavior: {
|
|
47
|
-
pgCodecAttribute
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
if (
|
|
50
|
+
pgCodecAttribute: {
|
|
51
|
+
inferred(behavior, [codec, attributeName], build) {
|
|
52
|
+
const newBehavior = [behavior];
|
|
53
|
+
const attr = codec.attributes[attributeName];
|
|
54
|
+
const resource = codec.polymorphism?.mode === "union"
|
|
55
|
+
? Object.values(build.input.pgRegistry.pgResources).find((r) => {
|
|
56
|
+
if (r.parameters)
|
|
57
|
+
return false;
|
|
58
|
+
if (r.isVirtual)
|
|
59
|
+
return false;
|
|
60
|
+
if (r.isUnique)
|
|
61
|
+
return false;
|
|
62
|
+
if (r.uniques.length === 0)
|
|
63
|
+
return false;
|
|
64
|
+
const name = codec.extensions?.tags?.name ?? codec.name;
|
|
65
|
+
const impl = r.codec.extensions?.tags?.implements;
|
|
66
|
+
const implArr = impl
|
|
67
|
+
? Array.isArray(impl)
|
|
68
|
+
? impl
|
|
69
|
+
: [impl]
|
|
70
|
+
: [];
|
|
71
|
+
if (!implArr.includes(name))
|
|
72
|
+
return false;
|
|
73
|
+
return true;
|
|
74
|
+
})
|
|
75
|
+
: Object.values(build.input.pgRegistry.pgResources).find((r) => {
|
|
76
|
+
if (r.codec !== codec)
|
|
77
|
+
return false;
|
|
78
|
+
if (r.parameters)
|
|
79
|
+
return false;
|
|
80
|
+
if (r.isVirtual)
|
|
81
|
+
return false;
|
|
82
|
+
if (r.isUnique)
|
|
83
|
+
return false;
|
|
84
|
+
if (r.uniques.length === 0)
|
|
85
|
+
return false;
|
|
86
|
+
return true;
|
|
87
|
+
});
|
|
88
|
+
const pk = resource?.uniques.find((u) => u.isPrimary);
|
|
89
|
+
// If the column is a primary key, don't include it (since it will be in the NodeID instead)
|
|
90
|
+
if (pk?.attributes.includes(attributeName)) {
|
|
88
91
|
// Do not include this column in the schema (other than for create)
|
|
89
92
|
newBehavior.push(...RELAY_HIDDEN_COLUMN_BEHAVIORS);
|
|
90
93
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
94
|
+
else {
|
|
95
|
+
// If the column is available via a singular relation, don't include the column itself
|
|
96
|
+
const relationsMap = build.input.pgRegistry.pgRelations[codec.name];
|
|
97
|
+
const relations = relationsMap
|
|
98
|
+
? Object.values(build.input.pgRegistry.pgRelations[codec.name] ?? {})
|
|
99
|
+
: [];
|
|
100
|
+
const singularRelationsUsingThisColumn = relations.filter((r) => {
|
|
101
|
+
// NOTE: We do this even if the end table is not visible, because
|
|
102
|
+
// otherwise making the end table visible would be a breaking schema
|
|
103
|
+
// change. Users should make sure these columns are hidden from the
|
|
104
|
+
// schema if they are also hiding the target table.
|
|
105
|
+
if (!r.isUnique)
|
|
106
|
+
return false;
|
|
107
|
+
if (r.isReferencee)
|
|
108
|
+
return false;
|
|
109
|
+
if (!r.localAttributes.includes(attributeName))
|
|
110
|
+
return false;
|
|
111
|
+
return true;
|
|
112
|
+
});
|
|
113
|
+
if (singularRelationsUsingThisColumn.length > 0 &&
|
|
114
|
+
!attr.codec.extensions?.isEnumTableEnum) {
|
|
115
|
+
// Do not include this column in the schema (other than for create)
|
|
116
|
+
newBehavior.push(...RELAY_HIDDEN_COLUMN_BEHAVIORS);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const relations = Object.values(build.input.pgRegistry.pgRelations[codec.name] ?? {}).filter((r) => !r.isReferencee && r.isUnique);
|
|
120
|
+
const isPartOfRelation = !attr.codec.extensions?.isEnumTableEnum &&
|
|
121
|
+
relations.some((r) => r.localAttributes.includes(attributeName));
|
|
122
|
+
if (isPartOfRelation) {
|
|
123
|
+
// `nodeId:filterBy` handles this
|
|
124
|
+
newBehavior.push(`-attribute:filterBy`);
|
|
125
|
+
// `nodeId:insert` handles this
|
|
126
|
+
newBehavior.push(`-attribute:insert`);
|
|
127
|
+
// `nodeId:update` handles this
|
|
128
|
+
newBehavior.push(`-attribute:update`);
|
|
129
|
+
// `nodeId:base` handles this
|
|
130
|
+
newBehavior.push(`-attribute:base`);
|
|
131
|
+
}
|
|
132
|
+
return newBehavior;
|
|
133
|
+
},
|
|
105
134
|
},
|
|
106
135
|
},
|
|
107
136
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relay.js","sourceRoot":"","sources":["../../src/presets/relay.ts"],"names":[],"mappings":";;;AAAA,2BAAyB;AACzB,6BAA2B;AAI3B,8CAAwC;AAExC,MAAM,6BAA6B,
|
|
1
|
+
{"version":3,"file":"relay.js","sourceRoot":"","sources":["../../src/presets/relay.ts"],"names":[],"mappings":";;;AAAA,2BAAyB;AACzB,6BAA2B;AAI3B,8CAAwC;AAExC,MAAM,6BAA6B,GAA4C;IAC7E,SAAS;IACT,SAAS;IACT,OAAO;IACP,WAAW;IACX,UAAU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AC,IAAI,EAAE,CAEvD,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,YAAY,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;oBAC/C,MAAM,gBAAgB,GACpB,CAAC,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,eAAe;wBACvC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;oBACnE,IAAI,gBAAgB,EAAE;wBACpB,iCAAiC;wBACjC,WAAW,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;wBACxC,+BAA+B;wBAC/B,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;wBACtC,+BAA+B;wBAC/B,WAAW,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC;wBACtC,6BAA6B;wBAC7B,WAAW,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;qBACrC;oBAED,OAAO,WAAW,CAAC;gBACrB,CAAC;aACF;SACF;KACF;CACF,CAAC;AAEF,oBAAoB;AACP,QAAA,uBAAuB,GAA0B;IAC5D,OAAO,EAAE,CAAC,qBAAa,CAAC;IACxB,MAAM,EAAE;QACN,0BAA0B,EAAE,KAAK;QACjC,uBAAuB,EAAE,IAAI;KAC9B;CACF,CAAC;AAEF,8CAA8C;AACjC,QAAA,aAAa,GAAG,+BAAuB,CAAC"}
|
package/dist/presets/v4.d.ts
CHANGED
|
@@ -4,8 +4,9 @@ import type { GraphQLError } from "grafast/graphql";
|
|
|
4
4
|
import type { IncomingMessage, ServerResponse } from "http";
|
|
5
5
|
import { PgV4BehaviorPlugin } from "../plugins/PgV4BehaviorPlugin.js";
|
|
6
6
|
import { PgV4InflectionPlugin } from "../plugins/PgV4InflectionPlugin.js";
|
|
7
|
+
import { PgV4SimpleSubscriptionsPlugin } from "../plugins/PgV4SimpleSubscriptionsPlugin.js";
|
|
7
8
|
import { PgV4SmartTagsPlugin } from "../plugins/PgV4SmartTagsPlugin.js";
|
|
8
|
-
export { PgV4BehaviorPlugin, PgV4InflectionPlugin, PgV4SmartTagsPlugin };
|
|
9
|
+
export { PgV4BehaviorPlugin, PgV4InflectionPlugin, PgV4SimpleSubscriptionsPlugin, PgV4SmartTagsPlugin, };
|
|
9
10
|
type PromiseOrDirect<T> = T | Promise<T>;
|
|
10
11
|
type DirectOrCallback<Request, T> = T | ((req: Request) => PromiseOrDirect<T>);
|
|
11
12
|
export interface V4GraphileBuildOptions {
|
|
@@ -64,6 +65,7 @@ export interface V4Options<Request extends IncomingMessage = IncomingMessage, Re
|
|
|
64
65
|
watchPg?: boolean;
|
|
65
66
|
/** @deprecated Use 'preset.grafast.context' callback instead */
|
|
66
67
|
defaultRole?: never;
|
|
68
|
+
simpleSubscriptions?: boolean;
|
|
67
69
|
}
|
|
68
70
|
export declare const makeV4Preset: (options?: V4Options) => GraphileConfig.Preset;
|
|
69
71
|
export declare const V4Preset: GraphileConfig.Preset;
|
package/dist/presets/v4.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"v4.d.ts","sourceRoot":"","sources":["../../src/presets/v4.ts"],"names":[],"mappings":";AAAA,OAAO,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE5D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"v4.d.ts","sourceRoot":"","sources":["../../src/presets/v4.ts"],"names":[],"mappings":";AAAA,OAAO,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,YAA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AC,EAAE,OAAO,CAAC;IAClB,gEAAgE;IAChE,WAAW,CAAC,EAAE,KAAK,CAAC;IAEpB,mBAAmB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAqGD,eAAO,MAAM,YAAY,aACd,SAAS,KACjB,eAAe,MAkIjB,CAAC;AAEF,eAAO,MAAM,QAAQ,uBAAiB,CAAC;AACvC,eAAe,QAAQ,CAAC"}
|
package/dist/presets/v4.js
CHANGED
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.V4Preset = exports.makeV4Preset = exports.PgV4SmartTagsPlugin = exports.PgV4InflectionPlugin = exports.PgV4BehaviorPlugin = void 0;
|
|
3
|
+
exports.V4Preset = exports.makeV4Preset = exports.PgV4SmartTagsPlugin = exports.PgV4SimpleSubscriptionsPlugin = exports.PgV4InflectionPlugin = exports.PgV4BehaviorPlugin = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
require("graphile-config");
|
|
5
6
|
const grafserv_1 = require("grafserv");
|
|
6
7
|
const PgV4BehaviorPlugin_js_1 = require("../plugins/PgV4BehaviorPlugin.js");
|
|
7
8
|
Object.defineProperty(exports, "PgV4BehaviorPlugin", { enumerable: true, get: function () { return PgV4BehaviorPlugin_js_1.PgV4BehaviorPlugin; } });
|
|
8
9
|
const PgV4InflectionPlugin_js_1 = require("../plugins/PgV4InflectionPlugin.js");
|
|
9
10
|
Object.defineProperty(exports, "PgV4InflectionPlugin", { enumerable: true, get: function () { return PgV4InflectionPlugin_js_1.PgV4InflectionPlugin; } });
|
|
11
|
+
const PgV4SimpleSubscriptionsPlugin_js_1 = require("../plugins/PgV4SimpleSubscriptionsPlugin.js");
|
|
12
|
+
Object.defineProperty(exports, "PgV4SimpleSubscriptionsPlugin", { enumerable: true, get: function () { return PgV4SimpleSubscriptionsPlugin_js_1.PgV4SimpleSubscriptionsPlugin; } });
|
|
10
13
|
const PgV4SmartTagsPlugin_js_1 = require("../plugins/PgV4SmartTagsPlugin.js");
|
|
11
14
|
Object.defineProperty(exports, "PgV4SmartTagsPlugin", { enumerable: true, get: function () { return PgV4SmartTagsPlugin_js_1.PgV4SmartTagsPlugin; } });
|
|
15
|
+
const amber_js_1 = tslib_1.__importDefault(require("./amber.js"));
|
|
12
16
|
function isNotNullish(arg) {
|
|
13
17
|
return arg != null;
|
|
14
18
|
}
|
|
@@ -20,16 +24,16 @@ const makeV4Plugin = (options) => {
|
|
|
20
24
|
const simpleCollectionsBehavior = (() => {
|
|
21
25
|
switch (options.simpleCollections) {
|
|
22
26
|
case "both": {
|
|
23
|
-
return "
|
|
27
|
+
return ["connection", "resource:connection", "list", "resource:list"];
|
|
24
28
|
}
|
|
25
29
|
case "only": {
|
|
26
|
-
return "-connection -resource:connection
|
|
30
|
+
return ["-connection", "-resource:connection", "list", "resource:list"];
|
|
27
31
|
}
|
|
28
32
|
case "omit": {
|
|
29
|
-
return "
|
|
33
|
+
return ["connection", "resource:connection", "-list", "-resource:list"];
|
|
30
34
|
}
|
|
31
35
|
default: {
|
|
32
|
-
return
|
|
36
|
+
return [];
|
|
33
37
|
}
|
|
34
38
|
}
|
|
35
39
|
})();
|
|
@@ -64,24 +68,34 @@ const makeV4Plugin = (options) => {
|
|
|
64
68
|
schema: {
|
|
65
69
|
// We could base this on the legacy relations setting; but how to set deprecated?
|
|
66
70
|
globalBehavior(behavior) {
|
|
67
|
-
return
|
|
71
|
+
return [
|
|
72
|
+
behavior,
|
|
73
|
+
...simpleCollectionsBehavior,
|
|
74
|
+
"-singularRelation:resource:connection",
|
|
75
|
+
"-singularRelation:resource:list",
|
|
76
|
+
"condition:attribute:filterBy",
|
|
77
|
+
"attribute:orderBy",
|
|
78
|
+
"resource:connection:backwards",
|
|
79
|
+
];
|
|
68
80
|
},
|
|
69
81
|
entityBehavior: {
|
|
70
|
-
pgResource: "
|
|
71
|
-
pgCodecAttribute
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
underlyingCodec.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
underlyingCodec.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
pgResource: "delete:resource:select",
|
|
83
|
+
pgCodecAttribute: {
|
|
84
|
+
inferred(behavior, [codec, attributeName]) {
|
|
85
|
+
const attribute = codec.attributes[attributeName];
|
|
86
|
+
const underlyingCodec = attribute.codec.domainOfCodec ?? attribute.codec;
|
|
87
|
+
const newBehavior = [behavior];
|
|
88
|
+
if (underlyingCodec.arrayOfCodec ||
|
|
89
|
+
underlyingCodec.isBinary ||
|
|
90
|
+
underlyingCodec.rangeOfCodec) {
|
|
91
|
+
newBehavior.push("-attribute:orderBy");
|
|
92
|
+
}
|
|
93
|
+
if (underlyingCodec.isBinary ||
|
|
94
|
+
underlyingCodec.arrayOfCodec?.isBinary) {
|
|
95
|
+
newBehavior.push("-condition:attribute:filterBy");
|
|
96
|
+
}
|
|
97
|
+
return newBehavior;
|
|
98
|
+
},
|
|
85
99
|
},
|
|
86
100
|
},
|
|
87
101
|
},
|
|
@@ -96,10 +110,12 @@ const makeV4Preset = (options = {}) => {
|
|
|
96
110
|
const graphiqlPath = options.graphiqlRoute ?? "/graphiql";
|
|
97
111
|
const eventStreamPath = options.eventStreamRoute ?? `${graphqlPath}/stream`;
|
|
98
112
|
return {
|
|
113
|
+
extends: [amber_js_1.default],
|
|
99
114
|
plugins: [
|
|
100
115
|
PgV4InflectionPlugin_js_1.PgV4InflectionPlugin,
|
|
101
116
|
PgV4SmartTagsPlugin_js_1.PgV4SmartTagsPlugin,
|
|
102
117
|
PgV4BehaviorPlugin_js_1.PgV4BehaviorPlugin,
|
|
118
|
+
options.simpleSubscriptions ? PgV4SimpleSubscriptionsPlugin_js_1.PgV4SimpleSubscriptionsPlugin : null,
|
|
103
119
|
makeV4Plugin(options),
|
|
104
120
|
...(options.appendPlugins ? options.appendPlugins : []),
|
|
105
121
|
].filter(isNotNullish),
|