@constructive-io/graphql-server 3.1.1 → 4.0.1

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.
Files changed (77) hide show
  1. package/errors/404-message.js +1 -1
  2. package/errors/api-errors.d.ts +200 -0
  3. package/errors/api-errors.js +276 -0
  4. package/esm/errors/404-message.js +1 -1
  5. package/esm/errors/api-errors.js +261 -0
  6. package/esm/index.js +2 -0
  7. package/esm/middleware/api.js +355 -277
  8. package/esm/middleware/auth.js +25 -7
  9. package/esm/middleware/error-handler.js +86 -0
  10. package/esm/middleware/favicon.js +12 -0
  11. package/esm/middleware/graphile.js +149 -64
  12. package/esm/options.js +232 -0
  13. package/esm/schema.js +24 -11
  14. package/esm/server.js +41 -5
  15. package/index.d.ts +1 -0
  16. package/index.js +2 -0
  17. package/middleware/api.d.ts +3 -15
  18. package/middleware/api.js +359 -283
  19. package/middleware/auth.js +25 -7
  20. package/middleware/error-handler.d.ts +4 -0
  21. package/middleware/error-handler.js +94 -0
  22. package/middleware/favicon.d.ts +2 -0
  23. package/middleware/favicon.js +16 -0
  24. package/middleware/graphile.d.ts +14 -0
  25. package/middleware/graphile.js +149 -64
  26. package/options.d.ts +131 -0
  27. package/options.js +244 -0
  28. package/package.json +23 -24
  29. package/schema.d.ts +2 -2
  30. package/schema.js +23 -10
  31. package/server.d.ts +24 -2
  32. package/server.js +39 -3
  33. package/codegen/orm/client.d.ts +0 -55
  34. package/codegen/orm/client.js +0 -75
  35. package/codegen/orm/index.d.ts +0 -36
  36. package/codegen/orm/index.js +0 -59
  37. package/codegen/orm/input-types.d.ts +0 -20140
  38. package/codegen/orm/input-types.js +0 -2
  39. package/codegen/orm/models/api.d.ts +0 -42
  40. package/codegen/orm/models/api.js +0 -76
  41. package/codegen/orm/models/domain.d.ts +0 -42
  42. package/codegen/orm/models/domain.js +0 -76
  43. package/codegen/orm/models/index.d.ts +0 -7
  44. package/codegen/orm/models/index.js +0 -12
  45. package/codegen/orm/mutation/index.d.ts +0 -7
  46. package/codegen/orm/mutation/index.js +0 -7
  47. package/codegen/orm/query/index.d.ts +0 -20
  48. package/codegen/orm/query/index.js +0 -24
  49. package/codegen/orm/query-builder.d.ts +0 -81
  50. package/codegen/orm/query-builder.js +0 -496
  51. package/codegen/orm/select-types.d.ts +0 -83
  52. package/codegen/orm/select-types.js +0 -7
  53. package/codegen/orm/types.d.ts +0 -6
  54. package/codegen/orm/types.js +0 -23
  55. package/esm/codegen/orm/client.js +0 -70
  56. package/esm/codegen/orm/index.js +0 -39
  57. package/esm/codegen/orm/input-types.js +0 -1
  58. package/esm/codegen/orm/models/api.js +0 -72
  59. package/esm/codegen/orm/models/domain.js +0 -72
  60. package/esm/codegen/orm/models/index.js +0 -7
  61. package/esm/codegen/orm/mutation/index.js +0 -4
  62. package/esm/codegen/orm/query/index.js +0 -21
  63. package/esm/codegen/orm/query-builder.js +0 -452
  64. package/esm/codegen/orm/select-types.js +0 -6
  65. package/esm/codegen/orm/types.js +0 -7
  66. package/esm/middleware/gql.js +0 -116
  67. package/esm/plugins/PublicKeySignature.js +0 -114
  68. package/esm/scripts/codegen-schema.js +0 -71
  69. package/esm/scripts/create-bucket.js +0 -40
  70. package/middleware/gql.d.ts +0 -164
  71. package/middleware/gql.js +0 -121
  72. package/plugins/PublicKeySignature.d.ts +0 -11
  73. package/plugins/PublicKeySignature.js +0 -121
  74. package/scripts/codegen-schema.d.ts +0 -1
  75. package/scripts/codegen-schema.js +0 -76
  76. package/scripts/create-bucket.d.ts +0 -1
  77. package/scripts/create-bucket.js +0 -42
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,42 +0,0 @@
1
- /**
2
- * Api model for ORM client
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- import { OrmClient } from '../client';
7
- import { QueryBuilder } from '../query-builder';
8
- import type { ConnectionResult, FindManyArgs, FindFirstArgs, CreateArgs, UpdateArgs, DeleteArgs, InferSelectResult, DeepExact } from '../select-types';
9
- import type { ApiWithRelations, ApiSelect, ApiFilter, ApisOrderBy, CreateApiInput, ApiPatch } from '../input-types';
10
- export declare class ApiModel {
11
- private client;
12
- constructor(client: OrmClient);
13
- findMany<const S extends ApiSelect>(args?: FindManyArgs<DeepExact<S, ApiSelect>, ApiFilter, ApisOrderBy>): QueryBuilder<{
14
- apis: ConnectionResult<InferSelectResult<ApiWithRelations, S>>;
15
- }>;
16
- findFirst<const S extends ApiSelect>(args?: FindFirstArgs<DeepExact<S, ApiSelect>, ApiFilter>): QueryBuilder<{
17
- apis: {
18
- nodes: InferSelectResult<ApiWithRelations, S>[];
19
- };
20
- }>;
21
- create<const S extends ApiSelect>(args: CreateArgs<DeepExact<S, ApiSelect>, CreateApiInput['api']>): QueryBuilder<{
22
- createApi: {
23
- api: InferSelectResult<ApiWithRelations, S>;
24
- };
25
- }>;
26
- update<const S extends ApiSelect>(args: UpdateArgs<DeepExact<S, ApiSelect>, {
27
- id: string;
28
- }, ApiPatch>): QueryBuilder<{
29
- updateApi: {
30
- api: InferSelectResult<ApiWithRelations, S>;
31
- };
32
- }>;
33
- delete(args: DeleteArgs<{
34
- id: string;
35
- }>): QueryBuilder<{
36
- deleteApi: {
37
- api: {
38
- id: string;
39
- };
40
- };
41
- }>;
42
- }
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApiModel = void 0;
4
- const query_builder_1 = require("../query-builder");
5
- class ApiModel {
6
- client;
7
- constructor(client) {
8
- this.client = client;
9
- }
10
- findMany(args) {
11
- const { document, variables } = (0, query_builder_1.buildFindManyDocument)('Api', 'apis', args?.select, {
12
- where: args?.where,
13
- orderBy: args?.orderBy,
14
- first: args?.first,
15
- last: args?.last,
16
- after: args?.after,
17
- before: args?.before,
18
- offset: args?.offset,
19
- }, 'ApiFilter', 'ApisOrderBy');
20
- return new query_builder_1.QueryBuilder({
21
- client: this.client,
22
- operation: 'query',
23
- operationName: 'Api',
24
- fieldName: 'apis',
25
- document,
26
- variables,
27
- });
28
- }
29
- findFirst(args) {
30
- const { document, variables } = (0, query_builder_1.buildFindFirstDocument)('Api', 'apis', args?.select, {
31
- where: args?.where,
32
- }, 'ApiFilter');
33
- return new query_builder_1.QueryBuilder({
34
- client: this.client,
35
- operation: 'query',
36
- operationName: 'Api',
37
- fieldName: 'apis',
38
- document,
39
- variables,
40
- });
41
- }
42
- create(args) {
43
- const { document, variables } = (0, query_builder_1.buildCreateDocument)('Api', 'createApi', 'api', args.select, args.data, 'CreateApiInput');
44
- return new query_builder_1.QueryBuilder({
45
- client: this.client,
46
- operation: 'mutation',
47
- operationName: 'Api',
48
- fieldName: 'createApi',
49
- document,
50
- variables,
51
- });
52
- }
53
- update(args) {
54
- const { document, variables } = (0, query_builder_1.buildUpdateDocument)('Api', 'updateApi', 'api', args.select, args.where, args.data, 'UpdateApiInput');
55
- return new query_builder_1.QueryBuilder({
56
- client: this.client,
57
- operation: 'mutation',
58
- operationName: 'Api',
59
- fieldName: 'updateApi',
60
- document,
61
- variables,
62
- });
63
- }
64
- delete(args) {
65
- const { document, variables } = (0, query_builder_1.buildDeleteDocument)('Api', 'deleteApi', 'api', args.where, 'DeleteApiInput');
66
- return new query_builder_1.QueryBuilder({
67
- client: this.client,
68
- operation: 'mutation',
69
- operationName: 'Api',
70
- fieldName: 'deleteApi',
71
- document,
72
- variables,
73
- });
74
- }
75
- }
76
- exports.ApiModel = ApiModel;
@@ -1,42 +0,0 @@
1
- /**
2
- * Domain model for ORM client
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- import { OrmClient } from '../client';
7
- import { QueryBuilder } from '../query-builder';
8
- import type { ConnectionResult, FindManyArgs, FindFirstArgs, CreateArgs, UpdateArgs, DeleteArgs, InferSelectResult, DeepExact } from '../select-types';
9
- import type { DomainWithRelations, DomainSelect, DomainFilter, DomainsOrderBy, CreateDomainInput, DomainPatch } from '../input-types';
10
- export declare class DomainModel {
11
- private client;
12
- constructor(client: OrmClient);
13
- findMany<const S extends DomainSelect>(args?: FindManyArgs<DeepExact<S, DomainSelect>, DomainFilter, DomainsOrderBy>): QueryBuilder<{
14
- domains: ConnectionResult<InferSelectResult<DomainWithRelations, S>>;
15
- }>;
16
- findFirst<const S extends DomainSelect>(args?: FindFirstArgs<DeepExact<S, DomainSelect>, DomainFilter>): QueryBuilder<{
17
- domains: {
18
- nodes: InferSelectResult<DomainWithRelations, S>[];
19
- };
20
- }>;
21
- create<const S extends DomainSelect>(args: CreateArgs<DeepExact<S, DomainSelect>, CreateDomainInput['domain']>): QueryBuilder<{
22
- createDomain: {
23
- domain: InferSelectResult<DomainWithRelations, S>;
24
- };
25
- }>;
26
- update<const S extends DomainSelect>(args: UpdateArgs<DeepExact<S, DomainSelect>, {
27
- id: string;
28
- }, DomainPatch>): QueryBuilder<{
29
- updateDomain: {
30
- domain: InferSelectResult<DomainWithRelations, S>;
31
- };
32
- }>;
33
- delete(args: DeleteArgs<{
34
- id: string;
35
- }>): QueryBuilder<{
36
- deleteDomain: {
37
- domain: {
38
- id: string;
39
- };
40
- };
41
- }>;
42
- }
@@ -1,76 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DomainModel = void 0;
4
- const query_builder_1 = require("../query-builder");
5
- class DomainModel {
6
- client;
7
- constructor(client) {
8
- this.client = client;
9
- }
10
- findMany(args) {
11
- const { document, variables } = (0, query_builder_1.buildFindManyDocument)('Domain', 'domains', args?.select, {
12
- where: args?.where,
13
- orderBy: args?.orderBy,
14
- first: args?.first,
15
- last: args?.last,
16
- after: args?.after,
17
- before: args?.before,
18
- offset: args?.offset,
19
- }, 'DomainFilter', 'DomainsOrderBy');
20
- return new query_builder_1.QueryBuilder({
21
- client: this.client,
22
- operation: 'query',
23
- operationName: 'Domain',
24
- fieldName: 'domains',
25
- document,
26
- variables,
27
- });
28
- }
29
- findFirst(args) {
30
- const { document, variables } = (0, query_builder_1.buildFindFirstDocument)('Domain', 'domains', args?.select, {
31
- where: args?.where,
32
- }, 'DomainFilter');
33
- return new query_builder_1.QueryBuilder({
34
- client: this.client,
35
- operation: 'query',
36
- operationName: 'Domain',
37
- fieldName: 'domains',
38
- document,
39
- variables,
40
- });
41
- }
42
- create(args) {
43
- const { document, variables } = (0, query_builder_1.buildCreateDocument)('Domain', 'createDomain', 'domain', args.select, args.data, 'CreateDomainInput');
44
- return new query_builder_1.QueryBuilder({
45
- client: this.client,
46
- operation: 'mutation',
47
- operationName: 'Domain',
48
- fieldName: 'createDomain',
49
- document,
50
- variables,
51
- });
52
- }
53
- update(args) {
54
- const { document, variables } = (0, query_builder_1.buildUpdateDocument)('Domain', 'updateDomain', 'domain', args.select, args.where, args.data, 'UpdateDomainInput');
55
- return new query_builder_1.QueryBuilder({
56
- client: this.client,
57
- operation: 'mutation',
58
- operationName: 'Domain',
59
- fieldName: 'updateDomain',
60
- document,
61
- variables,
62
- });
63
- }
64
- delete(args) {
65
- const { document, variables } = (0, query_builder_1.buildDeleteDocument)('Domain', 'deleteDomain', 'domain', args.where, 'DeleteDomainInput');
66
- return new query_builder_1.QueryBuilder({
67
- client: this.client,
68
- operation: 'mutation',
69
- operationName: 'Domain',
70
- fieldName: 'deleteDomain',
71
- document,
72
- variables,
73
- });
74
- }
75
- }
76
- exports.DomainModel = DomainModel;
@@ -1,7 +0,0 @@
1
- /**
2
- * Models barrel export
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- export { ApiModel } from './api';
7
- export { DomainModel } from './domain';
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DomainModel = exports.ApiModel = void 0;
4
- /**
5
- * Models barrel export
6
- * @generated by @constructive-io/graphql-codegen
7
- * DO NOT EDIT - changes will be overwritten
8
- */
9
- var api_1 = require("./api");
10
- Object.defineProperty(exports, "ApiModel", { enumerable: true, get: function () { return api_1.ApiModel; } });
11
- var domain_1 = require("./domain");
12
- Object.defineProperty(exports, "DomainModel", { enumerable: true, get: function () { return domain_1.DomainModel; } });
@@ -1,7 +0,0 @@
1
- /**
2
- * Custom mutation operations
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- import { OrmClient } from '../client';
7
- export declare function createMutationOperations(client: OrmClient): {};
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createMutationOperations = createMutationOperations;
4
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
5
- function createMutationOperations(client) {
6
- return {};
7
- }
@@ -1,20 +0,0 @@
1
- /**
2
- * Custom query operations
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- import { OrmClient } from '../client';
7
- import { QueryBuilder } from '../query-builder';
8
- import type { InferSelectResult, DeepExact } from '../select-types';
9
- import type { Api, ApiSelect } from '../input-types';
10
- export interface ApiByDatabaseIdAndNameVariables {
11
- databaseId: string;
12
- name: string;
13
- }
14
- export declare function createQueryOperations(client: OrmClient): {
15
- apiByDatabaseIdAndName: <const S extends ApiSelect>(args: ApiByDatabaseIdAndNameVariables, options?: {
16
- select?: DeepExact<S, ApiSelect>;
17
- }) => QueryBuilder<{
18
- apiByDatabaseIdAndName: InferSelectResult<Api, S>;
19
- }>;
20
- };
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createQueryOperations = createQueryOperations;
4
- const query_builder_1 = require("../query-builder");
5
- function createQueryOperations(client) {
6
- return {
7
- apiByDatabaseIdAndName: (args, options) => new query_builder_1.QueryBuilder({
8
- client,
9
- operation: 'query',
10
- operationName: 'ApiByDatabaseIdAndName',
11
- fieldName: 'apiByDatabaseIdAndName',
12
- ...(0, query_builder_1.buildCustomDocument)('query', 'ApiByDatabaseIdAndName', 'apiByDatabaseIdAndName', options?.select, args, [
13
- {
14
- name: 'databaseId',
15
- type: 'UUID!',
16
- },
17
- {
18
- name: 'name',
19
- type: 'String!',
20
- },
21
- ]),
22
- }),
23
- };
24
- }
@@ -1,81 +0,0 @@
1
- /**
2
- * Query Builder - Builds and executes GraphQL operations
3
- * @generated by @constructive-io/graphql-codegen
4
- * DO NOT EDIT - changes will be overwritten
5
- */
6
- import type { FieldNode } from 'graphql';
7
- import { OrmClient, QueryResult } from './client';
8
- export interface QueryBuilderConfig {
9
- client: OrmClient;
10
- operation: 'query' | 'mutation';
11
- operationName: string;
12
- fieldName: string;
13
- document: string;
14
- variables?: Record<string, unknown>;
15
- }
16
- export declare class QueryBuilder<TResult> {
17
- private config;
18
- constructor(config: QueryBuilderConfig);
19
- /**
20
- * Execute the query and return a discriminated union result
21
- * Use result.ok to check success, or .unwrap() to throw on error
22
- */
23
- execute(): Promise<QueryResult<TResult>>;
24
- /**
25
- * Execute and unwrap the result, throwing GraphQLRequestError on failure
26
- * @throws {GraphQLRequestError} If the query returns errors
27
- */
28
- unwrap(): Promise<TResult>;
29
- /**
30
- * Execute and unwrap, returning defaultValue on error instead of throwing
31
- */
32
- unwrapOr<D>(defaultValue: D): Promise<TResult | D>;
33
- /**
34
- * Execute and unwrap, calling onError callback on failure
35
- */
36
- unwrapOrElse<D>(onError: (errors: import('./client').GraphQLError[]) => D): Promise<TResult | D>;
37
- toGraphQL(): string;
38
- getVariables(): Record<string, unknown> | undefined;
39
- }
40
- export declare function buildSelections(select: Record<string, unknown> | undefined): FieldNode[];
41
- export declare function buildFindManyDocument<TSelect, TWhere>(operationName: string, queryField: string, select: TSelect, args: {
42
- where?: TWhere;
43
- orderBy?: string[];
44
- first?: number;
45
- last?: number;
46
- after?: string;
47
- before?: string;
48
- offset?: number;
49
- }, filterTypeName: string, orderByTypeName: string): {
50
- document: string;
51
- variables: Record<string, unknown>;
52
- };
53
- export declare function buildFindFirstDocument<TSelect, TWhere>(operationName: string, queryField: string, select: TSelect, args: {
54
- where?: TWhere;
55
- }, filterTypeName: string): {
56
- document: string;
57
- variables: Record<string, unknown>;
58
- };
59
- export declare function buildCreateDocument<TSelect, TData>(operationName: string, mutationField: string, entityField: string, select: TSelect, data: TData, inputTypeName: string): {
60
- document: string;
61
- variables: Record<string, unknown>;
62
- };
63
- export declare function buildUpdateDocument<TSelect, TWhere extends {
64
- id: string;
65
- }, TData>(operationName: string, mutationField: string, entityField: string, select: TSelect, where: TWhere, data: TData, inputTypeName: string): {
66
- document: string;
67
- variables: Record<string, unknown>;
68
- };
69
- export declare function buildDeleteDocument<TWhere extends {
70
- id: string;
71
- }>(operationName: string, mutationField: string, entityField: string, where: TWhere, inputTypeName: string): {
72
- document: string;
73
- variables: Record<string, unknown>;
74
- };
75
- export declare function buildCustomDocument<TSelect, TArgs>(operationType: 'query' | 'mutation', operationName: string, fieldName: string, select: TSelect, args: TArgs, variableDefinitions: Array<{
76
- name: string;
77
- type: string;
78
- }>): {
79
- document: string;
80
- variables: Record<string, unknown>;
81
- };