graphile-pg-aggregates 1.9.1 → 1.9.3
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/FilterRelationalAggregatesPlugin.js +2 -17
- package/esm/FilterRelationalAggregatesPlugin.js +1 -16
- package/esm/utils.d.ts +3 -3
- package/esm/utils.js +4 -19
- package/package.json +7 -4
- package/utils.d.ts +3 -3
- package/utils.js +4 -19
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.PgAggregatesFilterRelationalAggregatesPlugin = exports.Plugin = void 0;
|
|
4
|
+
const graphile_plugin_utils_1 = require("graphile-plugin-utils");
|
|
4
5
|
const EXPORTABLE_1 = require("./EXPORTABLE");
|
|
5
6
|
const version = '1.0.0';
|
|
6
7
|
const pgAggregateApplyAttributeOrder = (0, EXPORTABLE_1.EXPORTABLE)(() => (PgCondition, sql, spec, attributeName, attrCodec, rawAttrCodec, $parent, input) => {
|
|
@@ -373,7 +374,7 @@ group by ())`;
|
|
|
373
374
|
}, `Add aggregate '${attributeName}' filter for source '${table.name}' for spec '${spec.id}'`);
|
|
374
375
|
}, Object.create(null))
|
|
375
376
|
}, `Adding per-attribute '${spec.id}' aggregate filters for '${pgTypeResource.name}'`);
|
|
376
|
-
const computedAttributeResources = Object.values(build.input.pgRegistry.pgResources).filter((s) => isComputedScalarAttributeResource(s) &&
|
|
377
|
+
const computedAttributeResources = Object.values(build.input.pgRegistry.pgResources).filter((s) => (0, graphile_plugin_utils_1.isComputedScalarAttributeResource)(s) &&
|
|
377
378
|
s.parameters[0].codec === table.codec &&
|
|
378
379
|
s.parameters.slice(1).every((p) => p.optional));
|
|
379
380
|
fields = extend(fields, {
|
|
@@ -425,19 +426,3 @@ group by ())`;
|
|
|
425
426
|
}
|
|
426
427
|
};
|
|
427
428
|
exports.PgAggregatesFilterRelationalAggregatesPlugin = exports.Plugin;
|
|
428
|
-
function isComputedScalarAttributeResource(s) {
|
|
429
|
-
if (!s.parameters || s.parameters.length < 1) {
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
if (s.codec.attributes) {
|
|
433
|
-
return false;
|
|
434
|
-
}
|
|
435
|
-
if (!s.isUnique) {
|
|
436
|
-
return false;
|
|
437
|
-
}
|
|
438
|
-
const firstParameter = s.parameters[0];
|
|
439
|
-
if (!firstParameter?.codec.attributes) {
|
|
440
|
-
return false;
|
|
441
|
-
}
|
|
442
|
-
return true;
|
|
443
|
-
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isComputedScalarAttributeResource } from 'graphile-plugin-utils';
|
|
1
2
|
import { EXPORTABLE } from './EXPORTABLE';
|
|
2
3
|
const version = '1.0.0';
|
|
3
4
|
const pgAggregateApplyAttributeOrder = EXPORTABLE(() => (PgCondition, sql, spec, attributeName, attrCodec, rawAttrCodec, $parent, input) => {
|
|
@@ -422,19 +423,3 @@ group by ())`;
|
|
|
422
423
|
}
|
|
423
424
|
};
|
|
424
425
|
export { Plugin as PgAggregatesFilterRelationalAggregatesPlugin };
|
|
425
|
-
function isComputedScalarAttributeResource(s) {
|
|
426
|
-
if (!s.parameters || s.parameters.length < 1) {
|
|
427
|
-
return false;
|
|
428
|
-
}
|
|
429
|
-
if (s.codec.attributes) {
|
|
430
|
-
return false;
|
|
431
|
-
}
|
|
432
|
-
if (!s.isUnique) {
|
|
433
|
-
return false;
|
|
434
|
-
}
|
|
435
|
-
const firstParameter = s.parameters[0];
|
|
436
|
-
if (!firstParameter?.codec.attributes) {
|
|
437
|
-
return false;
|
|
438
|
-
}
|
|
439
|
-
return true;
|
|
440
|
-
}
|
package/esm/utils.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { PgResource
|
|
1
|
+
import type { PgResource } from '@dataplan/pg';
|
|
2
2
|
import type { GraphileBuild } from 'graphile-build';
|
|
3
3
|
export declare function getComputedAttributeResources(build: GraphileBuild.Build, resource: PgResource<any, any, any, any>): PgResource<string, import("@dataplan/pg").PgCodecWithAttributes<{
|
|
4
4
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
5
5
|
}>, readonly import("@dataplan/pg").PgResourceUnique<{
|
|
6
6
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
7
|
-
}>[], readonly PgResourceParameter<string, import("@dataplan/pg").PgCodec<string, {
|
|
7
|
+
}>[], readonly import("@dataplan/pg").PgResourceParameter<string, import("@dataplan/pg").PgCodec<string, {
|
|
8
8
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
9
9
|
}, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>>[], import("@dataplan/pg").PgRegistry<Record<string, import("@dataplan/pg").PgCodec<string, {
|
|
10
10
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
@@ -12,7 +12,7 @@ export declare function getComputedAttributeResources(build: GraphileBuild.Build
|
|
|
12
12
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
13
13
|
}>, readonly import("@dataplan/pg").PgResourceUnique<{
|
|
14
14
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
15
|
-
}>[], readonly PgResourceParameter<string, import("@dataplan/pg").PgCodec<string, {
|
|
15
|
+
}>[], readonly import("@dataplan/pg").PgResourceParameter<string, import("@dataplan/pg").PgCodec<string, {
|
|
16
16
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
17
17
|
}, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>>[]>>, Record<string, Record<string, import("@dataplan/pg").PgCodecRelationConfig<import("@dataplan/pg").PgCodec<string, {
|
|
18
18
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
package/esm/utils.js
CHANGED
|
@@ -1,22 +1,7 @@
|
|
|
1
|
+
import { isComputedScalarAttributeResource } from 'graphile-plugin-utils';
|
|
1
2
|
export function getComputedAttributeResources(build, resource) {
|
|
2
|
-
const computedAttributeResources = Object.values(build.input.pgRegistry.pgResources).filter((s) =>
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
if (s.codec.attributes) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
if (!s.isUnique) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
if (s.codec.arrayOfCodec) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
const firstParameter = s.parameters[0];
|
|
16
|
-
if (firstParameter.codec !== resource.codec) {
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
});
|
|
3
|
+
const computedAttributeResources = Object.values(build.input.pgRegistry.pgResources).filter((s) => isComputedScalarAttributeResource(s) &&
|
|
4
|
+
!s.codec.arrayOfCodec &&
|
|
5
|
+
s.parameters[0].codec === resource.codec);
|
|
21
6
|
return computedAttributeResources;
|
|
22
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graphile-pg-aggregates",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.3",
|
|
4
4
|
"description": "PostGraphile v5 aggregate plugin — sum, avg, min, max, stddev, variance, distinctCount, groupedAggregates with groupBy + having, orderBy relational aggregates",
|
|
5
5
|
"author": "Constructive <developers@constructive.io>",
|
|
6
6
|
"homepage": "https://github.com/constructive-io/constructive",
|
|
@@ -40,11 +40,14 @@
|
|
|
40
40
|
"bugs": {
|
|
41
41
|
"url": "https://github.com/constructive-io/constructive/issues"
|
|
42
42
|
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"graphile-plugin-utils": "^1.0.2"
|
|
45
|
+
},
|
|
43
46
|
"devDependencies": {
|
|
44
47
|
"@types/node": "^22.19.11",
|
|
45
|
-
"graphile-test": "^4.20.
|
|
48
|
+
"graphile-test": "^4.20.2",
|
|
46
49
|
"makage": "^0.3.0",
|
|
47
|
-
"pgsql-test": "^4.19.
|
|
50
|
+
"pgsql-test": "^4.19.2"
|
|
48
51
|
},
|
|
49
52
|
"peerDependencies": {
|
|
50
53
|
"@dataplan/pg": "1.0.3",
|
|
@@ -57,5 +60,5 @@
|
|
|
57
60
|
"pg-sql2": "5.0.1",
|
|
58
61
|
"postgraphile": "5.0.3"
|
|
59
62
|
},
|
|
60
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "fe49621d08cbf93d3b75ee7bb9b0849580980369"
|
|
61
64
|
}
|
package/utils.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { PgResource
|
|
1
|
+
import type { PgResource } from '@dataplan/pg';
|
|
2
2
|
import type { GraphileBuild } from 'graphile-build';
|
|
3
3
|
export declare function getComputedAttributeResources(build: GraphileBuild.Build, resource: PgResource<any, any, any, any>): PgResource<string, import("@dataplan/pg").PgCodecWithAttributes<{
|
|
4
4
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
5
5
|
}>, readonly import("@dataplan/pg").PgResourceUnique<{
|
|
6
6
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
7
|
-
}>[], readonly PgResourceParameter<string, import("@dataplan/pg").PgCodec<string, {
|
|
7
|
+
}>[], readonly import("@dataplan/pg").PgResourceParameter<string, import("@dataplan/pg").PgCodec<string, {
|
|
8
8
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
9
9
|
}, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>>[], import("@dataplan/pg").PgRegistry<Record<string, import("@dataplan/pg").PgCodec<string, {
|
|
10
10
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
@@ -12,7 +12,7 @@ export declare function getComputedAttributeResources(build: GraphileBuild.Build
|
|
|
12
12
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
13
13
|
}>, readonly import("@dataplan/pg").PgResourceUnique<{
|
|
14
14
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
15
|
-
}>[], readonly PgResourceParameter<string, import("@dataplan/pg").PgCodec<string, {
|
|
15
|
+
}>[], readonly import("@dataplan/pg").PgResourceParameter<string, import("@dataplan/pg").PgCodec<string, {
|
|
16
16
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
|
17
17
|
}, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>>[]>>, Record<string, Record<string, import("@dataplan/pg").PgCodecRelationConfig<import("@dataplan/pg").PgCodec<string, {
|
|
18
18
|
[x: string]: import("@dataplan/pg").PgCodecAttribute<import("@dataplan/pg").PgCodec<string, /*elided*/ any, any, any, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, any, any, any, any, any, any>, import("@dataplan/pg").PgCodec<string, undefined, any, any, undefined, any, undefined>>, boolean>;
|
package/utils.js
CHANGED
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getComputedAttributeResources = getComputedAttributeResources;
|
|
4
|
+
const graphile_plugin_utils_1 = require("graphile-plugin-utils");
|
|
4
5
|
function getComputedAttributeResources(build, resource) {
|
|
5
|
-
const computedAttributeResources = Object.values(build.input.pgRegistry.pgResources).filter((s) =>
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
if (s.codec.attributes) {
|
|
10
|
-
return false;
|
|
11
|
-
}
|
|
12
|
-
if (!s.isUnique) {
|
|
13
|
-
return false;
|
|
14
|
-
}
|
|
15
|
-
if (s.codec.arrayOfCodec) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
const firstParameter = s.parameters[0];
|
|
19
|
-
if (firstParameter.codec !== resource.codec) {
|
|
20
|
-
return false;
|
|
21
|
-
}
|
|
22
|
-
return true;
|
|
23
|
-
});
|
|
6
|
+
const computedAttributeResources = Object.values(build.input.pgRegistry.pgResources).filter((s) => (0, graphile_plugin_utils_1.isComputedScalarAttributeResource)(s) &&
|
|
7
|
+
!s.codec.arrayOfCodec &&
|
|
8
|
+
s.parameters[0].codec === resource.codec);
|
|
24
9
|
return computedAttributeResources;
|
|
25
10
|
}
|