graphile-pg-aggregates 1.1.0
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/AddAggregateTypesPlugin.d.ts +38 -0
- package/AddAggregateTypesPlugin.js +268 -0
- package/AddConnectionAggregatesPlugin.d.ts +2 -0
- package/AddConnectionAggregatesPlugin.js +56 -0
- package/AddConnectionGroupedAggregatesPlugin.d.ts +10 -0
- package/AddConnectionGroupedAggregatesPlugin.js +118 -0
- package/AddGroupByAggregateEnumValuesForAttributesPlugin.d.ts +10 -0
- package/AddGroupByAggregateEnumValuesForAttributesPlugin.js +116 -0
- package/AddGroupByAggregateEnumsPlugin.d.ts +2 -0
- package/AddGroupByAggregateEnumsPlugin.js +51 -0
- package/AddHavingAggregateTypesPlugin.d.ts +22 -0
- package/AddHavingAggregateTypesPlugin.js +449 -0
- package/AggregateSpecsPlugin.d.ts +1 -0
- package/AggregateSpecsPlugin.js +206 -0
- package/AggregatesSmartTagsPlugin.d.ts +8 -0
- package/AggregatesSmartTagsPlugin.js +65 -0
- package/EXPORTABLE.d.ts +1 -0
- package/EXPORTABLE.js +15 -0
- package/FilterRelationalAggregatesPlugin.d.ts +74 -0
- package/FilterRelationalAggregatesPlugin.js +443 -0
- package/InflectionPlugin.d.ts +67 -0
- package/InflectionPlugin.js +71 -0
- package/LICENSE +23 -0
- package/OrderByAggregatesPlugin.d.ts +31 -0
- package/OrderByAggregatesPlugin.js +205 -0
- package/README.md +128 -0
- package/esm/AddAggregateTypesPlugin.d.ts +38 -0
- package/esm/AddAggregateTypesPlugin.js +265 -0
- package/esm/AddConnectionAggregatesPlugin.d.ts +2 -0
- package/esm/AddConnectionAggregatesPlugin.js +53 -0
- package/esm/AddConnectionGroupedAggregatesPlugin.d.ts +10 -0
- package/esm/AddConnectionGroupedAggregatesPlugin.js +115 -0
- package/esm/AddGroupByAggregateEnumValuesForAttributesPlugin.d.ts +10 -0
- package/esm/AddGroupByAggregateEnumValuesForAttributesPlugin.js +113 -0
- package/esm/AddGroupByAggregateEnumsPlugin.d.ts +2 -0
- package/esm/AddGroupByAggregateEnumsPlugin.js +48 -0
- package/esm/AddHavingAggregateTypesPlugin.d.ts +22 -0
- package/esm/AddHavingAggregateTypesPlugin.js +446 -0
- package/esm/AggregateSpecsPlugin.d.ts +1 -0
- package/esm/AggregateSpecsPlugin.js +203 -0
- package/esm/AggregatesSmartTagsPlugin.d.ts +8 -0
- package/esm/AggregatesSmartTagsPlugin.js +62 -0
- package/esm/EXPORTABLE.d.ts +1 -0
- package/esm/EXPORTABLE.js +12 -0
- package/esm/FilterRelationalAggregatesPlugin.d.ts +74 -0
- package/esm/FilterRelationalAggregatesPlugin.js +440 -0
- package/esm/InflectionPlugin.d.ts +67 -0
- package/esm/InflectionPlugin.js +68 -0
- package/esm/OrderByAggregatesPlugin.d.ts +31 -0
- package/esm/OrderByAggregatesPlugin.js +202 -0
- package/esm/index.d.ts +42 -0
- package/esm/index.js +37 -0
- package/esm/interfaces.d.ts +145 -0
- package/esm/interfaces.js +44 -0
- package/esm/utils.d.ts +23 -0
- package/esm/utils.js +22 -0
- package/index.d.ts +42 -0
- package/index.js +40 -0
- package/interfaces.d.ts +145 -0
- package/interfaces.js +47 -0
- package/package.json +61 -0
- package/utils.d.ts +23 -0
- package/utils.js +25 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PgAggregatesAddAggregateTypesPlugin } from './AddAggregateTypesPlugin';
|
|
2
|
+
import { PgAggregatesAddConnectionAggregatesPlugin } from './AddConnectionAggregatesPlugin';
|
|
3
|
+
import { PgAggregatesAddConnectionGroupedAggregatesPlugin } from './AddConnectionGroupedAggregatesPlugin';
|
|
4
|
+
import { PgAggregatesAddGroupByAggregateEnumsPlugin } from './AddGroupByAggregateEnumsPlugin';
|
|
5
|
+
import { PgAggregatesAddGroupByAggregateEnumValuesForAttributesPlugin } from './AddGroupByAggregateEnumValuesForAttributesPlugin';
|
|
6
|
+
import { PgAggregatesAddHavingAggregateTypesPlugin } from './AddHavingAggregateTypesPlugin';
|
|
7
|
+
import { PgAggregatesSpecsPlugin } from './AggregateSpecsPlugin';
|
|
8
|
+
import { PgAggregatesSmartTagsPlugin } from './AggregatesSmartTagsPlugin';
|
|
9
|
+
import { PgAggregatesFilterRelationalAggregatesPlugin } from './FilterRelationalAggregatesPlugin';
|
|
10
|
+
import { PgAggregatesInflectorsPlugin } from './InflectionPlugin';
|
|
11
|
+
import { PgAggregatesOrderByAggregatesPlugin } from './OrderByAggregatesPlugin';
|
|
12
|
+
export declare const PgAggregatesPreset: GraphileConfig.Preset;
|
|
13
|
+
export { AggregateGroupBySpec, AggregateSpec, AggregateTargetEntity } from './interfaces';
|
|
14
|
+
export { PgAggregatesAddAggregateTypesPlugin };
|
|
15
|
+
export { PgAggregatesAddConnectionAggregatesPlugin };
|
|
16
|
+
export { PgAggregatesAddConnectionGroupedAggregatesPlugin };
|
|
17
|
+
export { PgAggregatesAddGroupByAggregateEnumsPlugin };
|
|
18
|
+
export { PgAggregatesAddGroupByAggregateEnumValuesForAttributesPlugin };
|
|
19
|
+
export { PgAggregatesAddHavingAggregateTypesPlugin };
|
|
20
|
+
export { PgAggregatesSpecsPlugin };
|
|
21
|
+
export { PgAggregatesSmartTagsPlugin };
|
|
22
|
+
export { PgAggregatesFilterRelationalAggregatesPlugin };
|
|
23
|
+
export { PgAggregatesInflectorsPlugin };
|
|
24
|
+
export { PgAggregatesOrderByAggregatesPlugin };
|
|
25
|
+
declare global {
|
|
26
|
+
namespace GraphileBuild {
|
|
27
|
+
interface AggregateSpecIds {
|
|
28
|
+
sum: true;
|
|
29
|
+
distinctCount: true;
|
|
30
|
+
min: true;
|
|
31
|
+
max: true;
|
|
32
|
+
average: true;
|
|
33
|
+
stddevSample: true;
|
|
34
|
+
stddevPopulation: true;
|
|
35
|
+
varianceSample: true;
|
|
36
|
+
variancePopulation: true;
|
|
37
|
+
}
|
|
38
|
+
interface BehaviorStrings {
|
|
39
|
+
'resource:groupedAggregates': true;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
package/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PgAggregatesOrderByAggregatesPlugin = exports.PgAggregatesInflectorsPlugin = exports.PgAggregatesFilterRelationalAggregatesPlugin = exports.PgAggregatesSmartTagsPlugin = exports.PgAggregatesSpecsPlugin = exports.PgAggregatesAddHavingAggregateTypesPlugin = exports.PgAggregatesAddGroupByAggregateEnumValuesForAttributesPlugin = exports.PgAggregatesAddGroupByAggregateEnumsPlugin = exports.PgAggregatesAddConnectionGroupedAggregatesPlugin = exports.PgAggregatesAddConnectionAggregatesPlugin = exports.PgAggregatesAddAggregateTypesPlugin = exports.PgAggregatesPreset = void 0;
|
|
4
|
+
const AddAggregateTypesPlugin_1 = require("./AddAggregateTypesPlugin");
|
|
5
|
+
Object.defineProperty(exports, "PgAggregatesAddAggregateTypesPlugin", { enumerable: true, get: function () { return AddAggregateTypesPlugin_1.PgAggregatesAddAggregateTypesPlugin; } });
|
|
6
|
+
const AddConnectionAggregatesPlugin_1 = require("./AddConnectionAggregatesPlugin");
|
|
7
|
+
Object.defineProperty(exports, "PgAggregatesAddConnectionAggregatesPlugin", { enumerable: true, get: function () { return AddConnectionAggregatesPlugin_1.PgAggregatesAddConnectionAggregatesPlugin; } });
|
|
8
|
+
const AddConnectionGroupedAggregatesPlugin_1 = require("./AddConnectionGroupedAggregatesPlugin");
|
|
9
|
+
Object.defineProperty(exports, "PgAggregatesAddConnectionGroupedAggregatesPlugin", { enumerable: true, get: function () { return AddConnectionGroupedAggregatesPlugin_1.PgAggregatesAddConnectionGroupedAggregatesPlugin; } });
|
|
10
|
+
const AddGroupByAggregateEnumsPlugin_1 = require("./AddGroupByAggregateEnumsPlugin");
|
|
11
|
+
Object.defineProperty(exports, "PgAggregatesAddGroupByAggregateEnumsPlugin", { enumerable: true, get: function () { return AddGroupByAggregateEnumsPlugin_1.PgAggregatesAddGroupByAggregateEnumsPlugin; } });
|
|
12
|
+
const AddGroupByAggregateEnumValuesForAttributesPlugin_1 = require("./AddGroupByAggregateEnumValuesForAttributesPlugin");
|
|
13
|
+
Object.defineProperty(exports, "PgAggregatesAddGroupByAggregateEnumValuesForAttributesPlugin", { enumerable: true, get: function () { return AddGroupByAggregateEnumValuesForAttributesPlugin_1.PgAggregatesAddGroupByAggregateEnumValuesForAttributesPlugin; } });
|
|
14
|
+
const AddHavingAggregateTypesPlugin_1 = require("./AddHavingAggregateTypesPlugin");
|
|
15
|
+
Object.defineProperty(exports, "PgAggregatesAddHavingAggregateTypesPlugin", { enumerable: true, get: function () { return AddHavingAggregateTypesPlugin_1.PgAggregatesAddHavingAggregateTypesPlugin; } });
|
|
16
|
+
const AggregateSpecsPlugin_1 = require("./AggregateSpecsPlugin");
|
|
17
|
+
Object.defineProperty(exports, "PgAggregatesSpecsPlugin", { enumerable: true, get: function () { return AggregateSpecsPlugin_1.PgAggregatesSpecsPlugin; } });
|
|
18
|
+
const AggregatesSmartTagsPlugin_1 = require("./AggregatesSmartTagsPlugin");
|
|
19
|
+
Object.defineProperty(exports, "PgAggregatesSmartTagsPlugin", { enumerable: true, get: function () { return AggregatesSmartTagsPlugin_1.PgAggregatesSmartTagsPlugin; } });
|
|
20
|
+
const FilterRelationalAggregatesPlugin_1 = require("./FilterRelationalAggregatesPlugin");
|
|
21
|
+
Object.defineProperty(exports, "PgAggregatesFilterRelationalAggregatesPlugin", { enumerable: true, get: function () { return FilterRelationalAggregatesPlugin_1.PgAggregatesFilterRelationalAggregatesPlugin; } });
|
|
22
|
+
const InflectionPlugin_1 = require("./InflectionPlugin");
|
|
23
|
+
Object.defineProperty(exports, "PgAggregatesInflectorsPlugin", { enumerable: true, get: function () { return InflectionPlugin_1.PgAggregatesInflectorsPlugin; } });
|
|
24
|
+
const OrderByAggregatesPlugin_1 = require("./OrderByAggregatesPlugin");
|
|
25
|
+
Object.defineProperty(exports, "PgAggregatesOrderByAggregatesPlugin", { enumerable: true, get: function () { return OrderByAggregatesPlugin_1.PgAggregatesOrderByAggregatesPlugin; } });
|
|
26
|
+
exports.PgAggregatesPreset = {
|
|
27
|
+
plugins: [
|
|
28
|
+
InflectionPlugin_1.PgAggregatesInflectorsPlugin,
|
|
29
|
+
AggregatesSmartTagsPlugin_1.PgAggregatesSmartTagsPlugin,
|
|
30
|
+
AggregateSpecsPlugin_1.PgAggregatesSpecsPlugin,
|
|
31
|
+
AddGroupByAggregateEnumsPlugin_1.PgAggregatesAddGroupByAggregateEnumsPlugin,
|
|
32
|
+
AddGroupByAggregateEnumValuesForAttributesPlugin_1.PgAggregatesAddGroupByAggregateEnumValuesForAttributesPlugin,
|
|
33
|
+
AddHavingAggregateTypesPlugin_1.PgAggregatesAddHavingAggregateTypesPlugin,
|
|
34
|
+
AddAggregateTypesPlugin_1.PgAggregatesAddAggregateTypesPlugin,
|
|
35
|
+
AddConnectionAggregatesPlugin_1.PgAggregatesAddConnectionAggregatesPlugin,
|
|
36
|
+
AddConnectionGroupedAggregatesPlugin_1.PgAggregatesAddConnectionGroupedAggregatesPlugin,
|
|
37
|
+
OrderByAggregatesPlugin_1.PgAggregatesOrderByAggregatesPlugin,
|
|
38
|
+
FilterRelationalAggregatesPlugin_1.PgAggregatesFilterRelationalAggregatesPlugin
|
|
39
|
+
]
|
|
40
|
+
};
|
package/interfaces.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type { PgCodec, PgResource, sql } from '@dataplan/pg';
|
|
2
|
+
type SQL = ReturnType<typeof sql>;
|
|
3
|
+
declare global {
|
|
4
|
+
namespace DataplanPg {
|
|
5
|
+
interface PgCodecExtensions {
|
|
6
|
+
isNumberLike?: boolean;
|
|
7
|
+
isIntervalLike?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface PgConditionStepExtensions {
|
|
10
|
+
pgFilterAttribute?: {
|
|
11
|
+
codec: PgCodec<any, any, any, any, any, any, any>;
|
|
12
|
+
expression: SQL;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
namespace GraphileBuild {
|
|
17
|
+
interface Inflection {
|
|
18
|
+
filterTableAggregateType(foreignTable: PgResource<any, any, any, any>, spec: AggregateSpec): string;
|
|
19
|
+
}
|
|
20
|
+
interface Build {
|
|
21
|
+
pgAggregateSpecs: AggregateSpec[];
|
|
22
|
+
pgAggregateGroupBySpecs: AggregateGroupBySpec[];
|
|
23
|
+
pgHavingFilterTypeNameForCodec(codec: PgCodec<any, any, any, any>): string | null;
|
|
24
|
+
}
|
|
25
|
+
interface ScopeObject {
|
|
26
|
+
isPgAggregateContainerType?: boolean;
|
|
27
|
+
isPgAggregateType?: boolean;
|
|
28
|
+
pgAggregateSpec?: AggregateSpec;
|
|
29
|
+
}
|
|
30
|
+
interface ScopeInputObject {
|
|
31
|
+
pgTypeResource?: PgResource<any, any, any, any>;
|
|
32
|
+
isPgHavingFilterInputType?: boolean;
|
|
33
|
+
isPgAggregateHavingInputType?: boolean;
|
|
34
|
+
pgHavingFilterSpec?: string;
|
|
35
|
+
isPgConnectionAggregateFilter?: boolean;
|
|
36
|
+
isPgConnectionAggregateAggregateFilter?: boolean;
|
|
37
|
+
pgConnectionAggregateFilterAggregateSpec?: AggregateSpec;
|
|
38
|
+
}
|
|
39
|
+
interface ScopeObjectFieldsField {
|
|
40
|
+
isPgAggregateField?: boolean;
|
|
41
|
+
isPgConnectionAggregateField?: boolean;
|
|
42
|
+
pgFieldResource?: PgResource<any, any, any, any, any>;
|
|
43
|
+
}
|
|
44
|
+
interface ScopeInputObjectFieldsField {
|
|
45
|
+
isPgConnectionFilterAggregatesField?: boolean;
|
|
46
|
+
}
|
|
47
|
+
interface ScopeEnum {
|
|
48
|
+
pgTypeResource?: PgResource<any, any, any, any, any>;
|
|
49
|
+
isPgAggregateGroupEnum?: boolean;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export type AggregateTargetEntity = {
|
|
54
|
+
type: 'attribute';
|
|
55
|
+
/** table codec - NOT attribute codec! */
|
|
56
|
+
codec: PgCodec<any, any, any, any, any, any, any>;
|
|
57
|
+
/** attribute name available on this codec */
|
|
58
|
+
attributeName: string;
|
|
59
|
+
resource?: never;
|
|
60
|
+
} | {
|
|
61
|
+
type: 'computedAttribute';
|
|
62
|
+
resource: PgResource<any, any, any, any, any>;
|
|
63
|
+
codec?: never;
|
|
64
|
+
attributeName?: never;
|
|
65
|
+
};
|
|
66
|
+
export interface AggregateGroupBySpec {
|
|
67
|
+
/** Must not change since it's used in type names/etc */
|
|
68
|
+
id: string;
|
|
69
|
+
/** Return true if we can process this type */
|
|
70
|
+
isSuitableType: (codec: PgCodec<any, any, any, any, any, any, any>) => boolean;
|
|
71
|
+
/** Return false if we cannot process this attribute (default: true) */
|
|
72
|
+
shouldApplyToEntity?: (entity: AggregateTargetEntity) => boolean;
|
|
73
|
+
/** Wraps the SQL to return a derivative (e.g.:
|
|
74
|
+
* ```
|
|
75
|
+
* sqlFrag => sql.fragment`date_trunc('hour', ${sqlFrag})`)
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
sqlWrap: (sqlFrag: SQL) => SQL;
|
|
79
|
+
/**
|
|
80
|
+
* Which codec represents the type returned by sqlWrap?
|
|
81
|
+
*/
|
|
82
|
+
sqlWrapCodec: (codec: PgCodec<any, any, any, any, any, any, any>) => PgCodec<any, any, any, any, any, any, any>;
|
|
83
|
+
}
|
|
84
|
+
export interface AggregateSpec {
|
|
85
|
+
/** Must not change since it's used in type names/etc */
|
|
86
|
+
id: keyof GraphileBuild.AggregateSpecIds;
|
|
87
|
+
/** Used in descriptions, starts with lowercase */
|
|
88
|
+
humanLabel: string;
|
|
89
|
+
/** Used in descriptions, starts with uppercase */
|
|
90
|
+
HumanLabel: string;
|
|
91
|
+
/** Return true if we can process this type */
|
|
92
|
+
isSuitableType: (codec: PgCodec<any, any, any, any>) => boolean;
|
|
93
|
+
/** Return false if we cannot process this attribute (default: true) */
|
|
94
|
+
shouldApplyToEntity?: (entity: AggregateTargetEntity) => boolean;
|
|
95
|
+
/** Wraps the SQL in an aggregate call */
|
|
96
|
+
sqlAggregateWrap: (sqlFrag: SQL, codec: PgCodec<any, any, any, any>) => SQL;
|
|
97
|
+
/**
|
|
98
|
+
* Used to translate the PostgreSQL return type for the aggregate; for example:
|
|
99
|
+
*
|
|
100
|
+
* - Sum over int should give bigint
|
|
101
|
+
* - Average of int should be float
|
|
102
|
+
* - Median of int should be int
|
|
103
|
+
*/
|
|
104
|
+
pgTypeCodecModifier?: (codec: PgCodec<any, any, any, any>) => PgCodec<any, any, any, any>;
|
|
105
|
+
/** Set true if the result is guaranteed to be non-null */
|
|
106
|
+
isNonNull?: boolean;
|
|
107
|
+
}
|
|
108
|
+
export declare const BIGINT_OID = "20";
|
|
109
|
+
export declare const INT2_OID = "21";
|
|
110
|
+
export declare const INT4_OID = "23";
|
|
111
|
+
export declare const FLOAT4_OID = "700";
|
|
112
|
+
export declare const FLOAT8_OID = "701";
|
|
113
|
+
export declare const NUMERIC_OID = "1700";
|
|
114
|
+
export declare const MONEY_OID = "790";
|
|
115
|
+
export declare const INTERVAL_OID = "1186";
|
|
116
|
+
export declare const DATE_OID = "1082";
|
|
117
|
+
export declare const TIMESTAMP_OID = "1114";
|
|
118
|
+
export declare const TIMESTAMPTZ_OID = "1184";
|
|
119
|
+
export declare const TIME_OID = "1083";
|
|
120
|
+
export declare const TIMETZ_OID = "1266";
|
|
121
|
+
export declare const JSON_OID = "114";
|
|
122
|
+
export declare const JSONB_OID = "3802";
|
|
123
|
+
export declare const UUID_OID = "2950";
|
|
124
|
+
export declare const BIT_OID = "1560";
|
|
125
|
+
export declare const VARBIT_OID = "1562";
|
|
126
|
+
export declare const CHAR_OID = "18";
|
|
127
|
+
export declare const TEXT_OID = "25";
|
|
128
|
+
export declare const VARCHAR_OID = "1043";
|
|
129
|
+
export declare const POINT_OID = "600";
|
|
130
|
+
export declare const INET_OID = "869";
|
|
131
|
+
export declare const CIDR_OID = "650";
|
|
132
|
+
export declare const MAC_ADDR_OID = "829";
|
|
133
|
+
export declare const MAC_ADDR8_OID = "774";
|
|
134
|
+
export declare const REG_PROC_OID = "24";
|
|
135
|
+
export declare const REG_PROCEDURE_OID = "2202";
|
|
136
|
+
export declare const REG_OPER_OID = "2203";
|
|
137
|
+
export declare const REG_OPERATOR_OID = "2204";
|
|
138
|
+
export declare const REG_CLASS_OID = "2205";
|
|
139
|
+
export declare const REG_OID = "2206";
|
|
140
|
+
export declare const REG_ROLE_OID = "4096";
|
|
141
|
+
export declare const REG_NAMESPACE_OID = "4089";
|
|
142
|
+
export declare const REG_CONFIG_OID = "3734";
|
|
143
|
+
export declare const REG_DICTIONARY_OID = "3769";
|
|
144
|
+
export declare const CORE_HAVING_FILTER_SPECS: readonly ["int", "bigint", "float", "bigfloat", "datetime", "string"];
|
|
145
|
+
export {};
|
package/interfaces.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CORE_HAVING_FILTER_SPECS = exports.REG_DICTIONARY_OID = exports.REG_CONFIG_OID = exports.REG_NAMESPACE_OID = exports.REG_ROLE_OID = exports.REG_OID = exports.REG_CLASS_OID = exports.REG_OPERATOR_OID = exports.REG_OPER_OID = exports.REG_PROCEDURE_OID = exports.REG_PROC_OID = exports.MAC_ADDR8_OID = exports.MAC_ADDR_OID = exports.CIDR_OID = exports.INET_OID = exports.POINT_OID = exports.VARCHAR_OID = exports.TEXT_OID = exports.CHAR_OID = exports.VARBIT_OID = exports.BIT_OID = exports.UUID_OID = exports.JSONB_OID = exports.JSON_OID = exports.TIMETZ_OID = exports.TIME_OID = exports.TIMESTAMPTZ_OID = exports.TIMESTAMP_OID = exports.DATE_OID = exports.INTERVAL_OID = exports.MONEY_OID = exports.NUMERIC_OID = exports.FLOAT8_OID = exports.FLOAT4_OID = exports.INT4_OID = exports.INT2_OID = exports.BIGINT_OID = void 0;
|
|
4
|
+
exports.BIGINT_OID = '20';
|
|
5
|
+
exports.INT2_OID = '21';
|
|
6
|
+
exports.INT4_OID = '23';
|
|
7
|
+
exports.FLOAT4_OID = '700';
|
|
8
|
+
exports.FLOAT8_OID = '701';
|
|
9
|
+
exports.NUMERIC_OID = '1700';
|
|
10
|
+
exports.MONEY_OID = '790';
|
|
11
|
+
exports.INTERVAL_OID = '1186';
|
|
12
|
+
exports.DATE_OID = '1082';
|
|
13
|
+
exports.TIMESTAMP_OID = '1114';
|
|
14
|
+
exports.TIMESTAMPTZ_OID = '1184';
|
|
15
|
+
exports.TIME_OID = '1083';
|
|
16
|
+
exports.TIMETZ_OID = '1266';
|
|
17
|
+
exports.JSON_OID = '114';
|
|
18
|
+
exports.JSONB_OID = '3802';
|
|
19
|
+
exports.UUID_OID = '2950';
|
|
20
|
+
exports.BIT_OID = '1560';
|
|
21
|
+
exports.VARBIT_OID = '1562';
|
|
22
|
+
exports.CHAR_OID = '18';
|
|
23
|
+
exports.TEXT_OID = '25';
|
|
24
|
+
exports.VARCHAR_OID = '1043';
|
|
25
|
+
exports.POINT_OID = '600';
|
|
26
|
+
exports.INET_OID = '869';
|
|
27
|
+
exports.CIDR_OID = '650';
|
|
28
|
+
exports.MAC_ADDR_OID = '829';
|
|
29
|
+
exports.MAC_ADDR8_OID = '774';
|
|
30
|
+
exports.REG_PROC_OID = '24';
|
|
31
|
+
exports.REG_PROCEDURE_OID = '2202';
|
|
32
|
+
exports.REG_OPER_OID = '2203';
|
|
33
|
+
exports.REG_OPERATOR_OID = '2204';
|
|
34
|
+
exports.REG_CLASS_OID = '2205';
|
|
35
|
+
exports.REG_OID = '2206';
|
|
36
|
+
exports.REG_ROLE_OID = '4096';
|
|
37
|
+
exports.REG_NAMESPACE_OID = '4089';
|
|
38
|
+
exports.REG_CONFIG_OID = '3734';
|
|
39
|
+
exports.REG_DICTIONARY_OID = '3769';
|
|
40
|
+
exports.CORE_HAVING_FILTER_SPECS = [
|
|
41
|
+
'int',
|
|
42
|
+
'bigint',
|
|
43
|
+
'float',
|
|
44
|
+
'bigfloat',
|
|
45
|
+
'datetime',
|
|
46
|
+
'string'
|
|
47
|
+
];
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "graphile-pg-aggregates",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "PostGraphile v5 aggregate plugin — sum, avg, min, max, stddev, variance, distinctCount, groupedAggregates with groupBy + having, orderBy relational aggregates",
|
|
5
|
+
"author": "Constructive <developers@constructive.io>",
|
|
6
|
+
"homepage": "https://github.com/constructive-io/constructive",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"main": "index.js",
|
|
9
|
+
"module": "esm/index.js",
|
|
10
|
+
"types": "index.d.ts",
|
|
11
|
+
"scripts": {
|
|
12
|
+
"clean": "makage clean",
|
|
13
|
+
"prepack": "npm run build",
|
|
14
|
+
"build": "makage build",
|
|
15
|
+
"build:dev": "makage build --dev",
|
|
16
|
+
"lint": "eslint . --fix",
|
|
17
|
+
"test": "jest",
|
|
18
|
+
"test:watch": "jest --watch"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public",
|
|
22
|
+
"directory": "dist"
|
|
23
|
+
},
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/constructive-io/constructive"
|
|
27
|
+
},
|
|
28
|
+
"keywords": [
|
|
29
|
+
"postgraphile",
|
|
30
|
+
"graphile",
|
|
31
|
+
"constructive",
|
|
32
|
+
"plugin",
|
|
33
|
+
"postgres",
|
|
34
|
+
"graphql",
|
|
35
|
+
"aggregates",
|
|
36
|
+
"group-by",
|
|
37
|
+
"having",
|
|
38
|
+
"v5"
|
|
39
|
+
],
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/constructive-io/constructive/issues"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/node": "^22.19.11",
|
|
45
|
+
"graphile-test": "^4.12.0",
|
|
46
|
+
"makage": "^0.3.0",
|
|
47
|
+
"pgsql-test": "^4.12.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@dataplan/pg": "1.0.0",
|
|
51
|
+
"grafast": "1.0.0",
|
|
52
|
+
"graphile-build": "5.0.0",
|
|
53
|
+
"graphile-build-pg": "5.0.0",
|
|
54
|
+
"graphile-config": "1.0.0",
|
|
55
|
+
"graphile-connection-filter": "^1.8.0",
|
|
56
|
+
"graphql": "16.13.0",
|
|
57
|
+
"pg-sql2": "5.0.0",
|
|
58
|
+
"postgraphile": "5.0.0"
|
|
59
|
+
},
|
|
60
|
+
"gitHead": "b1a89c4ab45fd22a63487cc6dc923a17772fac60"
|
|
61
|
+
}
|
package/utils.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PgResource, PgResourceParameter } from '@dataplan/pg';
|
|
2
|
+
import type { GraphileBuild } from 'graphile-build';
|
|
3
|
+
export declare function getComputedAttributeResources(build: GraphileBuild.Build, resource: PgResource<any, any, any, any>): PgResource<string, import("@dataplan/pg").PgCodecWithAttributes<{
|
|
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
|
+
}>, readonly import("@dataplan/pg").PgResourceUnique<{
|
|
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, {
|
|
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
|
+
}, 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
|
+
[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>;
|
|
11
|
+
}, any, any, any, any, any>>, Record<string, import("@dataplan/pg").PgResourceOptions<string, import("@dataplan/pg").PgCodecWithAttributes<{
|
|
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
|
+
}>, readonly import("@dataplan/pg").PgResourceUnique<{
|
|
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, {
|
|
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
|
+
}, 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
|
+
[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>;
|
|
19
|
+
}, any, any, undefined, any, undefined>, import("@dataplan/pg").PgResourceOptions<any, import("@dataplan/pg").PgCodecWithAttributes<{
|
|
20
|
+
[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>;
|
|
21
|
+
}>, any, any>>>>, {
|
|
22
|
+
[executorName: string]: import("@dataplan/pg").PgExecutor<any, any>;
|
|
23
|
+
}>>[];
|
package/utils.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getComputedAttributeResources = getComputedAttributeResources;
|
|
4
|
+
function getComputedAttributeResources(build, resource) {
|
|
5
|
+
const computedAttributeResources = Object.values(build.input.pgRegistry.pgResources).filter((s) => {
|
|
6
|
+
if (!s.parameters || s.parameters.length < 1) {
|
|
7
|
+
return false;
|
|
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
|
+
});
|
|
24
|
+
return computedAttributeResources;
|
|
25
|
+
}
|