@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,116 +0,0 @@
1
- import { OrmClient, } from '../codegen/orm/client';
2
- import { ApiModel, DomainModel } from '../codegen/orm/models';
3
- import { createQueryOperations } from '../codegen/orm/query';
4
- export const connectionFirst = 1000;
5
- export const apiSelect = {
6
- databaseId: true,
7
- dbname: true,
8
- roleName: true,
9
- anonRole: true,
10
- isPublic: true,
11
- domains: {
12
- select: {
13
- subdomain: true,
14
- domain: true,
15
- },
16
- first: connectionFirst,
17
- },
18
- schemasByApiSchemaApiIdAndSchemaId: {
19
- select: { schemaName: true },
20
- first: connectionFirst,
21
- },
22
- rlsModule: {
23
- select: {
24
- privateSchema: { select: { schemaName: true } },
25
- authenticateStrict: true,
26
- authenticate: true,
27
- currentRole: true,
28
- currentRoleId: true,
29
- },
30
- },
31
- apiModules: {
32
- select: { name: true, data: true },
33
- first: connectionFirst,
34
- },
35
- };
36
- export const domainSelect = {
37
- domain: true,
38
- subdomain: true,
39
- api: { select: apiSelect },
40
- };
41
- export const apiListSelect = {
42
- id: true,
43
- databaseId: true,
44
- name: true,
45
- dbname: true,
46
- roleName: true,
47
- anonRole: true,
48
- isPublic: true,
49
- domains: {
50
- select: { domain: true, subdomain: true },
51
- first: connectionFirst,
52
- },
53
- };
54
- class GraphileOrmClient extends OrmClient {
55
- graphile;
56
- constructor(graphile) {
57
- super({ endpoint: 'http://localhost/graphql' });
58
- this.graphile = graphile;
59
- }
60
- async execute(document, variables) {
61
- const result = await this.graphile.query({
62
- role: 'administrator',
63
- query: document,
64
- variables,
65
- });
66
- if (result.errors?.length) {
67
- return {
68
- ok: false,
69
- data: null,
70
- errors: result.errors,
71
- };
72
- }
73
- return {
74
- ok: true,
75
- data: result.data,
76
- errors: undefined,
77
- };
78
- }
79
- }
80
- export const createGraphileOrm = (graphile) => {
81
- const client = new GraphileOrmClient(graphile);
82
- return {
83
- api: new ApiModel(client),
84
- domain: new DomainModel(client),
85
- query: createQueryOperations(client),
86
- };
87
- };
88
- export const normalizeApiRecord = (api) => {
89
- const schemaNames = (api.schemasByApiSchemaApiIdAndSchemaId?.nodes ?? []).flatMap((node) => (node.schemaName ? [node.schemaName] : []));
90
- let domains = [];
91
- if (api.domains?.nodes?.length) {
92
- domains = api.domains.nodes.reduce((acc, domain) => {
93
- if (!domain.domain)
94
- return acc;
95
- const hostname = domain.subdomain
96
- ? `${domain.subdomain}.${domain.domain}`
97
- : domain.domain;
98
- const protocol = domain.domain === 'localhost' ? 'http://' : 'https://';
99
- return [...acc, protocol + hostname];
100
- }, []);
101
- }
102
- return {
103
- dbname: api.dbname,
104
- anonRole: api.anonRole,
105
- roleName: api.roleName,
106
- schema: schemaNames,
107
- apiModules: api.apiModules?.nodes?.map((node) => ({
108
- name: node.name,
109
- data: node.data,
110
- })) || [],
111
- rlsModule: api.rlsModule,
112
- domains,
113
- databaseId: api.databaseId,
114
- isPublic: api.isPublic,
115
- };
116
- };
@@ -1,114 +0,0 @@
1
- import { gql, makeExtendSchemaPlugin } from 'graphile-utils';
2
- import pgQueryWithContext from 'pg-query-context';
3
- export const PublicKeySignature = (pubkey_challenge) => {
4
- const { schema, crypto_network, sign_up_with_key, sign_in_request_challenge, sign_in_record_failure, sign_in_with_challenge } = pubkey_challenge;
5
- return makeExtendSchemaPlugin(() => ({
6
- typeDefs: gql `
7
- input CreateUserAccountWithPublicKeyInput {
8
- publicKey: String!
9
- }
10
-
11
- input GetMessageForSigningInput {
12
- publicKey: String!
13
- }
14
-
15
- input VerifyMessageForSigningInput {
16
- publicKey: String!
17
- message: String!
18
- signature: String!
19
- }
20
-
21
- type createUserAccountWithPublicKeyPayload {
22
- message: String!
23
- }
24
-
25
- type getMessageForSigningPayload {
26
- message: String!
27
- }
28
-
29
- type verifyMessageForSigningPayload {
30
- access_token: String!
31
- access_token_expires_at: Datetime!
32
- }
33
-
34
- extend type Mutation {
35
- createUserAccountWithPublicKey(
36
- input: CreateUserAccountWithPublicKeyInput
37
- ): createUserAccountWithPublicKeyPayload
38
-
39
- getMessageForSigning(
40
- input: GetMessageForSigningInput
41
- ): getMessageForSigningPayload
42
-
43
- verifyMessageForSigning(
44
- input: VerifyMessageForSigningInput
45
- ): verifyMessageForSigningPayload
46
- }
47
- `,
48
- resolvers: {
49
- Mutation: {
50
- async createUserAccountWithPublicKey(_parent, args, context) {
51
- const { pgClient } = context;
52
- const { publicKey } = args.input;
53
- await pgQueryWithContext({
54
- client: pgClient,
55
- context: { role: 'anonymous' },
56
- query: `SELECT * FROM "${schema}".${sign_up_with_key}($1)`,
57
- variables: [publicKey]
58
- });
59
- const { rows: [{ [sign_in_request_challenge]: message }] } = await pgQueryWithContext({
60
- client: pgClient,
61
- context: { role: 'anonymous' },
62
- query: `SELECT * FROM "${schema}".${sign_in_request_challenge}($1)`,
63
- variables: [publicKey]
64
- });
65
- return { message };
66
- },
67
- async getMessageForSigning(_parent, args, context) {
68
- const { pgClient } = context;
69
- const { publicKey } = args.input;
70
- const { rows: [{ [sign_in_request_challenge]: message }] } = await pgQueryWithContext({
71
- client: pgClient,
72
- context: { role: 'anonymous' },
73
- query: `SELECT * FROM "${schema}".${sign_in_request_challenge}($1)`,
74
- variables: [publicKey]
75
- });
76
- if (!message)
77
- throw new Error('NO_ACCOUNT_EXISTS');
78
- return { message };
79
- },
80
- async verifyMessageForSigning(_parent, args, context) {
81
- const { pgClient } = context;
82
- const { publicKey, message, signature } = args.input;
83
- // const network = Networks[crypto_network];
84
- const network = 'btc';
85
- // const result = verifyMessage(message, publicKey, signature, network);
86
- // TODO implement using interchainJS?
87
- const result = false;
88
- if (!result) {
89
- await pgQueryWithContext({
90
- client: pgClient,
91
- context: { role: 'anonymous' },
92
- query: `SELECT * FROM "${schema}".${sign_in_record_failure}($1)`,
93
- variables: [publicKey]
94
- });
95
- throw new Error('BAD_SIGNIN');
96
- }
97
- const { rows: [token] } = await pgQueryWithContext({
98
- client: pgClient,
99
- context: { role: 'anonymous' },
100
- query: `SELECT * FROM "${schema}".${sign_in_with_challenge}($1, $2)`,
101
- variables: [publicKey, message]
102
- });
103
- if (!token?.access_token)
104
- throw new Error('BAD_SIGNIN');
105
- return {
106
- access_token: token.access_token,
107
- access_token_expires_at: token.access_token_expires_at
108
- };
109
- }
110
- }
111
- }
112
- }));
113
- };
114
- export default PublicKeySignature;
@@ -1,71 +0,0 @@
1
- import { getEnvOptions } from '@constructive-io/graphql-env';
2
- import { Logger } from '@pgpmjs/logger';
3
- import { getGraphileSettings } from 'graphile-settings';
4
- import { getPgPool } from 'pg-cache';
5
- import { getSchema } from 'graphile-query';
6
- import { printSchema } from 'graphql';
7
- import { promises as fs } from 'node:fs';
8
- import path from 'node:path';
9
- const log = new Logger('codegen-schema');
10
- const getSchemaOutputPath = () => process.env.CODEGEN_SCHEMA_OUT ??
11
- path.resolve(__dirname, '../../codegen/schema.graphql');
12
- (async () => {
13
- try {
14
- const opts = getEnvOptions();
15
- const apiOpts = opts.api || {};
16
- const metaSchemas = Array.isArray(apiOpts.metaSchemas)
17
- ? apiOpts.metaSchemas
18
- : [];
19
- let schemas;
20
- let usingFallback = false;
21
- const dbName = process.env.CODEGEN_DATABASE || process.env.PGDATABASE || 'constructive';
22
- const pgConfig = { ...opts.pg, database: dbName };
23
- log.info(`Target database for codegen: ${dbName}`);
24
- if (metaSchemas.length) {
25
- schemas = metaSchemas;
26
- log.info(`Using meta schemas: ${schemas.join(', ')}`);
27
- const pool = getPgPool(pgConfig);
28
- const checkResult = await pool.query(`SELECT schema_name FROM information_schema.schemata
29
- WHERE schema_name = ANY($1::text[])
30
- ORDER BY schema_name`, [schemas]);
31
- const foundSchemas = checkResult.rows.map((r) => r.schema_name);
32
- const missing = schemas.filter((s) => !foundSchemas.includes(s));
33
- if (missing.length > 0) {
34
- log.warn(`Missing schemas: ${missing.join(', ')}. Falling back to 'public'.`);
35
- schemas = ['public'];
36
- usingFallback = true;
37
- }
38
- }
39
- else {
40
- schemas = ['public'];
41
- log.info('No meta schemas configured, using: public');
42
- usingFallback = true;
43
- }
44
- if (usingFallback) {
45
- log.warn('Schema will be generated from public schema only. To generate full meta schema, ensure meta tables exist.');
46
- }
47
- const settings = getGraphileSettings({
48
- ...opts,
49
- pg: pgConfig,
50
- graphile: {
51
- ...opts.graphile,
52
- schema: schemas,
53
- },
54
- });
55
- const pool = getPgPool(pgConfig);
56
- log.debug(`Connecting to database: ${dbName}`);
57
- log.debug(`Connecting to host: ${opts.pg?.host || '(default)'}`);
58
- const dbInfo = await pool.query('SELECT current_database() AS current_database, current_user AS current_user');
59
- log.info(`Connected to database: ${dbInfo.rows[0]?.current_database} as user: ${dbInfo.rows[0]?.current_user}`);
60
- const graphqlSchema = await getSchema(pool, settings);
61
- const sdl = printSchema(graphqlSchema);
62
- const outputPath = getSchemaOutputPath();
63
- await fs.mkdir(path.dirname(outputPath), { recursive: true });
64
- await fs.writeFile(outputPath, sdl, 'utf8');
65
- log.success(`Schema written to ${outputPath}`);
66
- }
67
- catch (error) {
68
- log.error('Failed to write schema', error?.stack || error);
69
- process.exitCode = 1;
70
- }
71
- })();
@@ -1,40 +0,0 @@
1
- // Minimal script to create a bucket in MinIO/S3 using @constructive-io/s3-utils
2
- // Avoid strict type coupling between different @aws-sdk/client-s3 versions
3
- import { S3Client } from '@aws-sdk/client-s3';
4
- import { createS3Bucket } from '@constructive-io/s3-utils';
5
- import { getEnvOptions } from '@constructive-io/graphql-env';
6
- import { Logger } from '@pgpmjs/logger';
7
- const log = new Logger('create-bucket');
8
- (async () => {
9
- try {
10
- const opts = getEnvOptions();
11
- const { cdn } = opts;
12
- const provider = cdn?.provider || 'minio';
13
- const isMinio = provider === 'minio';
14
- const bucket = cdn?.bucketName || 'test-bucket';
15
- const region = cdn?.awsRegion || 'us-east-1';
16
- const accessKey = cdn?.awsAccessKey || 'minioadmin';
17
- const secretKey = cdn?.awsSecretKey || 'minioadmin';
18
- const endpoint = cdn?.minioEndpoint || 'http://localhost:9000';
19
- const client = new S3Client({
20
- region,
21
- credentials: { accessKeyId: accessKey, secretAccessKey: secretKey },
22
- ...(isMinio ? {
23
- endpoint,
24
- forcePathStyle: true,
25
- } : {}),
26
- });
27
- const res = await createS3Bucket(client, bucket, { provider });
28
- if (res.success) {
29
- log.success(`${bucket} (provider: ${provider})`);
30
- }
31
- else {
32
- log.error(`Failed to create bucket ${bucket}`);
33
- }
34
- client.destroy();
35
- }
36
- catch (e) {
37
- log.error('error', e);
38
- process.exitCode = 1;
39
- }
40
- })();
@@ -1,164 +0,0 @@
1
- import { GraphileQuery } from 'graphile-query';
2
- import { type ApiSelect, type ApiWithRelations, type DomainFilter, type DomainWithRelations } from '../codegen/orm/input-types';
3
- import { type QueryResult } from '../codegen/orm/client';
4
- import { ApiModel, DomainModel } from '../codegen/orm/models';
5
- import type { InferSelectResult } from '../codegen/orm/select-types';
6
- import { ApiStructure } from '../types';
7
- export declare const connectionFirst = 1000;
8
- export declare const apiSelect: {
9
- databaseId: true;
10
- dbname: true;
11
- roleName: true;
12
- anonRole: true;
13
- isPublic: true;
14
- domains: {
15
- select: {
16
- subdomain: true;
17
- domain: true;
18
- };
19
- first: number;
20
- };
21
- schemasByApiSchemaApiIdAndSchemaId: {
22
- select: {
23
- schemaName: true;
24
- };
25
- first: number;
26
- };
27
- rlsModule: {
28
- select: {
29
- privateSchema: {
30
- select: {
31
- schemaName: true;
32
- };
33
- };
34
- authenticateStrict: true;
35
- authenticate: true;
36
- currentRole: true;
37
- currentRoleId: true;
38
- };
39
- };
40
- apiModules: {
41
- select: {
42
- name: true;
43
- data: true;
44
- };
45
- first: number;
46
- };
47
- };
48
- export declare const domainSelect: {
49
- domain: true;
50
- subdomain: true;
51
- api: {
52
- select: {
53
- databaseId: true;
54
- dbname: true;
55
- roleName: true;
56
- anonRole: true;
57
- isPublic: true;
58
- domains: {
59
- select: {
60
- subdomain: true;
61
- domain: true;
62
- };
63
- first: number;
64
- };
65
- schemasByApiSchemaApiIdAndSchemaId: {
66
- select: {
67
- schemaName: true;
68
- };
69
- first: number;
70
- };
71
- rlsModule: {
72
- select: {
73
- privateSchema: {
74
- select: {
75
- schemaName: true;
76
- };
77
- };
78
- authenticateStrict: true;
79
- authenticate: true;
80
- currentRole: true;
81
- currentRoleId: true;
82
- };
83
- };
84
- apiModules: {
85
- select: {
86
- name: true;
87
- data: true;
88
- };
89
- first: number;
90
- };
91
- };
92
- };
93
- };
94
- export declare const apiListSelect: {
95
- id: true;
96
- databaseId: true;
97
- name: true;
98
- dbname: true;
99
- roleName: true;
100
- anonRole: true;
101
- isPublic: true;
102
- domains: {
103
- select: {
104
- domain: true;
105
- subdomain: true;
106
- };
107
- first: number;
108
- };
109
- };
110
- export type ApiRecord = InferSelectResult<ApiWithRelations, typeof apiSelect>;
111
- export type DomainRecord = InferSelectResult<DomainWithRelations, typeof domainSelect>;
112
- export type ApiListRecord = InferSelectResult<ApiWithRelations, typeof apiListSelect>;
113
- type ApiByNameResult = QueryResult<{
114
- apiByDatabaseIdAndName: ApiRecord;
115
- }>;
116
- export type ApiQueryOps = {
117
- apiByDatabaseIdAndName: (args: {
118
- databaseId: string;
119
- name: string;
120
- }, options: {
121
- select: typeof apiSelect;
122
- }) => {
123
- execute: () => Promise<ApiByNameResult>;
124
- };
125
- };
126
- type DomainLookupResult = QueryResult<{
127
- domains: {
128
- nodes: DomainRecord[];
129
- };
130
- }>;
131
- export type DomainLookupModel = {
132
- findFirst: (args: {
133
- select: typeof domainSelect;
134
- where: DomainFilter;
135
- }) => {
136
- execute: () => Promise<DomainLookupResult>;
137
- };
138
- };
139
- type ApiListResult = QueryResult<{
140
- apis: {
141
- nodes: ApiListRecord[];
142
- };
143
- }>;
144
- export type ApiListModel = {
145
- findMany: (args: {
146
- select: typeof apiListSelect;
147
- first: number;
148
- }) => {
149
- execute: () => Promise<ApiListResult>;
150
- };
151
- };
152
- export declare const createGraphileOrm: (graphile: GraphileQuery) => {
153
- api: ApiModel;
154
- domain: DomainModel;
155
- query: {
156
- apiByDatabaseIdAndName: <const S extends ApiSelect>(args: import("../codegen/orm/query").ApiByDatabaseIdAndNameVariables, options?: {
157
- select?: import("../codegen/orm/select-types").DeepExact<S, ApiSelect>;
158
- }) => import("../codegen/orm").QueryBuilder<{
159
- apiByDatabaseIdAndName: InferSelectResult<import("../codegen/orm/input-types").Api, S>;
160
- }>;
161
- };
162
- };
163
- export declare const normalizeApiRecord: (api: ApiRecord) => ApiStructure;
164
- export {};
package/middleware/gql.js DELETED
@@ -1,121 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeApiRecord = exports.createGraphileOrm = exports.apiListSelect = exports.domainSelect = exports.apiSelect = exports.connectionFirst = void 0;
4
- const client_1 = require("../codegen/orm/client");
5
- const models_1 = require("../codegen/orm/models");
6
- const query_1 = require("../codegen/orm/query");
7
- exports.connectionFirst = 1000;
8
- exports.apiSelect = {
9
- databaseId: true,
10
- dbname: true,
11
- roleName: true,
12
- anonRole: true,
13
- isPublic: true,
14
- domains: {
15
- select: {
16
- subdomain: true,
17
- domain: true,
18
- },
19
- first: exports.connectionFirst,
20
- },
21
- schemasByApiSchemaApiIdAndSchemaId: {
22
- select: { schemaName: true },
23
- first: exports.connectionFirst,
24
- },
25
- rlsModule: {
26
- select: {
27
- privateSchema: { select: { schemaName: true } },
28
- authenticateStrict: true,
29
- authenticate: true,
30
- currentRole: true,
31
- currentRoleId: true,
32
- },
33
- },
34
- apiModules: {
35
- select: { name: true, data: true },
36
- first: exports.connectionFirst,
37
- },
38
- };
39
- exports.domainSelect = {
40
- domain: true,
41
- subdomain: true,
42
- api: { select: exports.apiSelect },
43
- };
44
- exports.apiListSelect = {
45
- id: true,
46
- databaseId: true,
47
- name: true,
48
- dbname: true,
49
- roleName: true,
50
- anonRole: true,
51
- isPublic: true,
52
- domains: {
53
- select: { domain: true, subdomain: true },
54
- first: exports.connectionFirst,
55
- },
56
- };
57
- class GraphileOrmClient extends client_1.OrmClient {
58
- graphile;
59
- constructor(graphile) {
60
- super({ endpoint: 'http://localhost/graphql' });
61
- this.graphile = graphile;
62
- }
63
- async execute(document, variables) {
64
- const result = await this.graphile.query({
65
- role: 'administrator',
66
- query: document,
67
- variables,
68
- });
69
- if (result.errors?.length) {
70
- return {
71
- ok: false,
72
- data: null,
73
- errors: result.errors,
74
- };
75
- }
76
- return {
77
- ok: true,
78
- data: result.data,
79
- errors: undefined,
80
- };
81
- }
82
- }
83
- const createGraphileOrm = (graphile) => {
84
- const client = new GraphileOrmClient(graphile);
85
- return {
86
- api: new models_1.ApiModel(client),
87
- domain: new models_1.DomainModel(client),
88
- query: (0, query_1.createQueryOperations)(client),
89
- };
90
- };
91
- exports.createGraphileOrm = createGraphileOrm;
92
- const normalizeApiRecord = (api) => {
93
- const schemaNames = (api.schemasByApiSchemaApiIdAndSchemaId?.nodes ?? []).flatMap((node) => (node.schemaName ? [node.schemaName] : []));
94
- let domains = [];
95
- if (api.domains?.nodes?.length) {
96
- domains = api.domains.nodes.reduce((acc, domain) => {
97
- if (!domain.domain)
98
- return acc;
99
- const hostname = domain.subdomain
100
- ? `${domain.subdomain}.${domain.domain}`
101
- : domain.domain;
102
- const protocol = domain.domain === 'localhost' ? 'http://' : 'https://';
103
- return [...acc, protocol + hostname];
104
- }, []);
105
- }
106
- return {
107
- dbname: api.dbname,
108
- anonRole: api.anonRole,
109
- roleName: api.roleName,
110
- schema: schemaNames,
111
- apiModules: api.apiModules?.nodes?.map((node) => ({
112
- name: node.name,
113
- data: node.data,
114
- })) || [],
115
- rlsModule: api.rlsModule,
116
- domains,
117
- databaseId: api.databaseId,
118
- isPublic: api.isPublic,
119
- };
120
- };
121
- exports.normalizeApiRecord = normalizeApiRecord;
@@ -1,11 +0,0 @@
1
- import type { Plugin } from 'graphile-build';
2
- export interface PublicKeyChallengeConfig {
3
- schema: string;
4
- crypto_network: string;
5
- sign_up_with_key: string;
6
- sign_in_request_challenge: string;
7
- sign_in_record_failure: string;
8
- sign_in_with_challenge: string;
9
- }
10
- export declare const PublicKeySignature: (pubkey_challenge: PublicKeyChallengeConfig) => Plugin;
11
- export default PublicKeySignature;