@constructive-io/graphql-env 2.8.4
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/LICENSE +23 -0
- package/README.md +152 -0
- package/env.d.ts +2 -0
- package/env.js +39 -0
- package/esm/env.d.ts +2 -0
- package/esm/env.js +35 -0
- package/esm/index.d.ts +5 -0
- package/esm/index.js +6 -0
- package/esm/merge.d.ts +17 -0
- package/esm/merge.js +42 -0
- package/index.d.ts +5 -0
- package/index.js +21 -0
- package/merge.d.ts +17 -0
- package/merge.js +49 -0
- package/package.json +48 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Dan Lynch <pyramation@gmail.com>
|
|
4
|
+
Copyright (c) 2025 Constructive <developers@constructive.io>
|
|
5
|
+
Copyright (c) 2020-present, Interweb, Inc.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# @constructive-io/graphql-env
|
|
2
|
+
|
|
3
|
+
Constructive environment configuration with GraphQL/Graphile support.
|
|
4
|
+
|
|
5
|
+
This package extends `@pgpmjs/env` with GraphQL-specific environment variable parsing and defaults for Constructive applications.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @constructive-io/graphql-env
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { getEnvOptions } from '@constructive-io/graphql-env';
|
|
17
|
+
|
|
18
|
+
// Get merged options (core PGPM + GraphQL defaults + env vars + config)
|
|
19
|
+
const options = getEnvOptions();
|
|
20
|
+
|
|
21
|
+
// With overrides
|
|
22
|
+
const options = getEnvOptions({
|
|
23
|
+
graphile: { schema: ['public', 'app'] },
|
|
24
|
+
features: { simpleInflection: true }
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Environment Variables
|
|
29
|
+
|
|
30
|
+
In addition to all environment variables supported by `@pgpmjs/env`, this package parses:
|
|
31
|
+
|
|
32
|
+
### GraphQL Schema
|
|
33
|
+
- `GRAPHILE_SCHEMA` - Comma-separated list of PostgreSQL schemas to expose
|
|
34
|
+
|
|
35
|
+
### Feature Flags
|
|
36
|
+
- `FEATURES_SIMPLE_INFLECTION` - Enable simple inflection plugin
|
|
37
|
+
- `FEATURES_OPPOSITE_BASE_NAMES` - Enable opposite base names
|
|
38
|
+
- `FEATURES_POSTGIS` - Enable PostGIS support
|
|
39
|
+
|
|
40
|
+
### API Configuration
|
|
41
|
+
- `API_ENABLE_META` - Enable meta API
|
|
42
|
+
- `API_IS_PUBLIC` - Whether API is public
|
|
43
|
+
- `API_EXPOSED_SCHEMAS` - Comma-separated list of exposed schemas
|
|
44
|
+
- `API_META_SCHEMAS` - Comma-separated list of meta schemas
|
|
45
|
+
- `API_ANON_ROLE` - Anonymous role name
|
|
46
|
+
- `API_ROLE_NAME` - Default role name
|
|
47
|
+
- `API_DEFAULT_DATABASE_ID` - Default database ID
|
|
48
|
+
|
|
49
|
+
## Defaults
|
|
50
|
+
|
|
51
|
+
GraphQL defaults are provided by `@constructive-io/graphql-types`:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
{
|
|
55
|
+
graphile: { schema: [] },
|
|
56
|
+
features: {
|
|
57
|
+
simpleInflection: true,
|
|
58
|
+
oppositeBaseNames: true,
|
|
59
|
+
postgis: true
|
|
60
|
+
},
|
|
61
|
+
api: {
|
|
62
|
+
enableMetaApi: true,
|
|
63
|
+
exposedSchemas: [],
|
|
64
|
+
anonRole: 'administrator',
|
|
65
|
+
roleName: 'administrator',
|
|
66
|
+
defaultDatabaseId: 'hard-coded',
|
|
67
|
+
isPublic: true,
|
|
68
|
+
metaSchemas: ['collections_public', 'meta_public']
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## When to Use
|
|
74
|
+
|
|
75
|
+
- Use `@constructive-io/graphql-env` for Constructive applications that need GraphQL/Graphile configuration
|
|
76
|
+
- Use `@pgpmjs/env` for pure PGPM tooling that doesn't need GraphQL support
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## Education and Tutorials
|
|
81
|
+
|
|
82
|
+
1. 🚀 [Quickstart: Getting Up and Running](https://constructive.io/learn/quickstart)
|
|
83
|
+
Get started with modular databases in minutes. Install prerequisites and deploy your first module.
|
|
84
|
+
|
|
85
|
+
2. 📦 [Modular PostgreSQL Development with Database Packages](https://constructive.io/learn/modular-postgres)
|
|
86
|
+
Learn to organize PostgreSQL projects with pgpm workspaces and reusable database modules.
|
|
87
|
+
|
|
88
|
+
3. ✏️ [Authoring Database Changes](https://constructive.io/learn/authoring-database-changes)
|
|
89
|
+
Master the workflow for adding, organizing, and managing database changes with pgpm.
|
|
90
|
+
|
|
91
|
+
4. 🧪 [End-to-End PostgreSQL Testing with TypeScript](https://constructive.io/learn/e2e-postgres-testing)
|
|
92
|
+
Master end-to-end PostgreSQL testing with ephemeral databases, RLS testing, and CI/CD automation.
|
|
93
|
+
|
|
94
|
+
5. ⚡ [Supabase Testing](https://constructive.io/learn/supabase)
|
|
95
|
+
Use TypeScript-first tools to test Supabase projects with realistic RLS, policies, and auth contexts.
|
|
96
|
+
|
|
97
|
+
6. 💧 [Drizzle ORM Testing](https://constructive.io/learn/drizzle-testing)
|
|
98
|
+
Run full-stack tests with Drizzle ORM, including database setup, teardown, and RLS enforcement.
|
|
99
|
+
|
|
100
|
+
7. 🔧 [Troubleshooting](https://constructive.io/learn/troubleshooting)
|
|
101
|
+
Common issues and solutions for pgpm, PostgreSQL, and testing.
|
|
102
|
+
|
|
103
|
+
## Related Constructive Tooling
|
|
104
|
+
|
|
105
|
+
### 🧪 Testing
|
|
106
|
+
|
|
107
|
+
* [pgsql-test](https://github.com/constructive-io/constructive/tree/main/postgres/pgsql-test): **📊 Isolated testing environments** with per-test transaction rollbacks—ideal for integration tests, complex migrations, and RLS simulation.
|
|
108
|
+
* [supabase-test](https://github.com/constructive-io/constructive/tree/main/postgres/supabase-test): **🧪 Supabase-native test harness** preconfigured for the local Supabase stack—per-test rollbacks, JWT/role context helpers, and CI/GitHub Actions ready.
|
|
109
|
+
* [graphile-test](https://github.com/constructive-io/constructive/tree/main/graphile/graphile-test): **🔐 Authentication mocking** for Graphile-focused test helpers and emulating row-level security contexts.
|
|
110
|
+
* [pg-query-context](https://github.com/constructive-io/constructive/tree/main/postgres/pg-query-context): **🔒 Session context injection** to add session-local context (e.g., `SET LOCAL`) into queries—ideal for setting `role`, `jwt.claims`, and other session settings.
|
|
111
|
+
|
|
112
|
+
### 🧠 Parsing & AST
|
|
113
|
+
|
|
114
|
+
* [pgsql-parser](https://www.npmjs.com/package/pgsql-parser): **🔄 SQL conversion engine** that interprets and converts PostgreSQL syntax.
|
|
115
|
+
* [libpg-query-node](https://www.npmjs.com/package/libpg-query): **🌉 Node.js bindings** for `libpg_query`, converting SQL into parse trees.
|
|
116
|
+
* [pg-proto-parser](https://www.npmjs.com/package/pg-proto-parser): **📦 Protobuf parser** for parsing PostgreSQL Protocol Buffers definitions to generate TypeScript interfaces, utility functions, and JSON mappings for enums.
|
|
117
|
+
* [@pgsql/enums](https://www.npmjs.com/package/@pgsql/enums): **🏷️ TypeScript enums** for PostgreSQL AST for safe and ergonomic parsing logic.
|
|
118
|
+
* [@pgsql/types](https://www.npmjs.com/package/@pgsql/types): **📝 Type definitions** for PostgreSQL AST nodes in TypeScript.
|
|
119
|
+
* [@pgsql/utils](https://www.npmjs.com/package/@pgsql/utils): **🛠️ AST utilities** for constructing and transforming PostgreSQL syntax trees.
|
|
120
|
+
* [pg-ast](https://www.npmjs.com/package/pg-ast): **🔍 Low-level AST tools** and transformations for Postgres query structures.
|
|
121
|
+
|
|
122
|
+
### 🚀 API & Dev Tools
|
|
123
|
+
|
|
124
|
+
* [@constructive-io/graphql-server](https://github.com/constructive-io/constructive/tree/main/graphql/server): **⚡ Express-based API server** powered by PostGraphile to expose a secure, scalable GraphQL API over your Postgres database.
|
|
125
|
+
* [@constructive-io/graphql-explorer](https://github.com/constructive-io/constructive/tree/main/graphql/explorer): **🔎 Visual API explorer** with GraphiQL for browsing across all databases and schemas—useful for debugging, documentation, and API prototyping.
|
|
126
|
+
|
|
127
|
+
### 🔁 Streaming & Uploads
|
|
128
|
+
|
|
129
|
+
* [etag-hash](https://github.com/constructive-io/constructive/tree/main/streaming/etag-hash): **🏷️ S3-compatible ETags** created by streaming and hashing file uploads in chunks.
|
|
130
|
+
* [etag-stream](https://github.com/constructive-io/constructive/tree/main/streaming/etag-stream): **🔄 ETag computation** via Node stream transformer during upload or transfer.
|
|
131
|
+
* [uuid-hash](https://github.com/constructive-io/constructive/tree/main/streaming/uuid-hash): **🆔 Deterministic UUIDs** generated from hashed content, great for deduplication and asset referencing.
|
|
132
|
+
* [uuid-stream](https://github.com/constructive-io/constructive/tree/main/streaming/uuid-stream): **🌊 Streaming UUID generation** based on piped file content—ideal for upload pipelines.
|
|
133
|
+
* [@constructive-io/s3-streamer](https://github.com/constructive-io/constructive/tree/main/streaming/s3-streamer): **📤 Direct S3 streaming** for large files with support for metadata injection and content validation.
|
|
134
|
+
* [@constructive-io/upload-names](https://github.com/constructive-io/constructive/tree/main/streaming/upload-names): **📂 Collision-resistant filenames** utility for structured and unique file names for uploads.
|
|
135
|
+
|
|
136
|
+
### 🧰 CLI & Codegen
|
|
137
|
+
|
|
138
|
+
* [pgpm](https://github.com/constructive-io/constructive/tree/main/pgpm/pgpm): **🖥️ PostgreSQL Package Manager** for modular Postgres development. Works with database workspaces, scaffolding, migrations, seeding, and installing database packages.
|
|
139
|
+
* [@constructive-io/cli](https://github.com/constructive-io/constructive/tree/main/packages/cli): **🖥️ Command-line toolkit** for managing Constructive projects—supports database scaffolding, migrations, seeding, code generation, and automation.
|
|
140
|
+
* [@constructive-io/graphql-codegen](https://github.com/constructive-io/constructive/tree/main/graphql/codegen): **✨ GraphQL code generation** (types, operations, SDK) from schema/endpoint introspection.
|
|
141
|
+
* [@constructive-io/query-builder](https://github.com/constructive-io/constructive/tree/main/packages/query-builder): **🏗️ SQL constructor** providing a robust TypeScript-based query builder for dynamic generation of `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and stored procedure calls—supports advanced SQL features like `JOIN`, `GROUP BY`, and schema-qualified queries.
|
|
142
|
+
* [@constructive-io/graphql-query](https://github.com/constructive-io/constructive/tree/main/graphql/query): **🧩 Fluent GraphQL builder** for PostGraphile schemas. ⚡ Schema-aware via introspection, 🧩 composable and ergonomic for building deeply nested queries.
|
|
143
|
+
|
|
144
|
+
## Credits
|
|
145
|
+
|
|
146
|
+
**🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**
|
|
147
|
+
|
|
148
|
+
## Disclaimer
|
|
149
|
+
|
|
150
|
+
AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.
|
|
151
|
+
|
|
152
|
+
No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.
|
package/env.d.ts
ADDED
package/env.js
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getGraphQLEnvVars = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Parse GraphQL-related environment variables.
|
|
6
|
+
* These are the env vars that Constructive packages need but pgpm doesn't.
|
|
7
|
+
*/
|
|
8
|
+
const parseEnvBoolean = (val) => {
|
|
9
|
+
if (val === undefined)
|
|
10
|
+
return undefined;
|
|
11
|
+
return ['true', '1', 'yes'].includes(val.toLowerCase());
|
|
12
|
+
};
|
|
13
|
+
const getGraphQLEnvVars = () => {
|
|
14
|
+
const { GRAPHILE_SCHEMA, FEATURES_SIMPLE_INFLECTION, FEATURES_OPPOSITE_BASE_NAMES, FEATURES_POSTGIS, API_ENABLE_META, API_IS_PUBLIC, API_EXPOSED_SCHEMAS, API_META_SCHEMAS, API_ANON_ROLE, API_ROLE_NAME, API_DEFAULT_DATABASE_ID, } = process.env;
|
|
15
|
+
return {
|
|
16
|
+
graphile: {
|
|
17
|
+
...(GRAPHILE_SCHEMA && {
|
|
18
|
+
schema: GRAPHILE_SCHEMA.includes(',')
|
|
19
|
+
? GRAPHILE_SCHEMA.split(',').map(s => s.trim())
|
|
20
|
+
: GRAPHILE_SCHEMA
|
|
21
|
+
}),
|
|
22
|
+
},
|
|
23
|
+
features: {
|
|
24
|
+
...(FEATURES_SIMPLE_INFLECTION && { simpleInflection: parseEnvBoolean(FEATURES_SIMPLE_INFLECTION) }),
|
|
25
|
+
...(FEATURES_OPPOSITE_BASE_NAMES && { oppositeBaseNames: parseEnvBoolean(FEATURES_OPPOSITE_BASE_NAMES) }),
|
|
26
|
+
...(FEATURES_POSTGIS && { postgis: parseEnvBoolean(FEATURES_POSTGIS) }),
|
|
27
|
+
},
|
|
28
|
+
api: {
|
|
29
|
+
...(API_ENABLE_META && { enableMetaApi: parseEnvBoolean(API_ENABLE_META) }),
|
|
30
|
+
...(API_IS_PUBLIC && { isPublic: parseEnvBoolean(API_IS_PUBLIC) }),
|
|
31
|
+
...(API_EXPOSED_SCHEMAS && { exposedSchemas: API_EXPOSED_SCHEMAS.split(',').map(s => s.trim()) }),
|
|
32
|
+
...(API_META_SCHEMAS && { metaSchemas: API_META_SCHEMAS.split(',').map(s => s.trim()) }),
|
|
33
|
+
...(API_ANON_ROLE && { anonRole: API_ANON_ROLE }),
|
|
34
|
+
...(API_ROLE_NAME && { roleName: API_ROLE_NAME }),
|
|
35
|
+
...(API_DEFAULT_DATABASE_ID && { defaultDatabaseId: API_DEFAULT_DATABASE_ID }),
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
exports.getGraphQLEnvVars = getGraphQLEnvVars;
|
package/esm/env.d.ts
ADDED
package/esm/env.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse GraphQL-related environment variables.
|
|
3
|
+
* These are the env vars that Constructive packages need but pgpm doesn't.
|
|
4
|
+
*/
|
|
5
|
+
const parseEnvBoolean = (val) => {
|
|
6
|
+
if (val === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
return ['true', '1', 'yes'].includes(val.toLowerCase());
|
|
9
|
+
};
|
|
10
|
+
export const getGraphQLEnvVars = () => {
|
|
11
|
+
const { GRAPHILE_SCHEMA, FEATURES_SIMPLE_INFLECTION, FEATURES_OPPOSITE_BASE_NAMES, FEATURES_POSTGIS, API_ENABLE_META, API_IS_PUBLIC, API_EXPOSED_SCHEMAS, API_META_SCHEMAS, API_ANON_ROLE, API_ROLE_NAME, API_DEFAULT_DATABASE_ID, } = process.env;
|
|
12
|
+
return {
|
|
13
|
+
graphile: {
|
|
14
|
+
...(GRAPHILE_SCHEMA && {
|
|
15
|
+
schema: GRAPHILE_SCHEMA.includes(',')
|
|
16
|
+
? GRAPHILE_SCHEMA.split(',').map(s => s.trim())
|
|
17
|
+
: GRAPHILE_SCHEMA
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
features: {
|
|
21
|
+
...(FEATURES_SIMPLE_INFLECTION && { simpleInflection: parseEnvBoolean(FEATURES_SIMPLE_INFLECTION) }),
|
|
22
|
+
...(FEATURES_OPPOSITE_BASE_NAMES && { oppositeBaseNames: parseEnvBoolean(FEATURES_OPPOSITE_BASE_NAMES) }),
|
|
23
|
+
...(FEATURES_POSTGIS && { postgis: parseEnvBoolean(FEATURES_POSTGIS) }),
|
|
24
|
+
},
|
|
25
|
+
api: {
|
|
26
|
+
...(API_ENABLE_META && { enableMetaApi: parseEnvBoolean(API_ENABLE_META) }),
|
|
27
|
+
...(API_IS_PUBLIC && { isPublic: parseEnvBoolean(API_IS_PUBLIC) }),
|
|
28
|
+
...(API_EXPOSED_SCHEMAS && { exposedSchemas: API_EXPOSED_SCHEMAS.split(',').map(s => s.trim()) }),
|
|
29
|
+
...(API_META_SCHEMAS && { metaSchemas: API_META_SCHEMAS.split(',').map(s => s.trim()) }),
|
|
30
|
+
...(API_ANON_ROLE && { anonRole: API_ANON_ROLE }),
|
|
31
|
+
...(API_ROLE_NAME && { roleName: API_ROLE_NAME }),
|
|
32
|
+
...(API_DEFAULT_DATABASE_ID && { defaultDatabaseId: API_DEFAULT_DATABASE_ID }),
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
};
|
package/esm/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { loadConfigSync, loadConfigFileSync, loadConfigSyncFromDir, resolvePgpmPath, getConnEnvOptions, getDeploymentEnvOptions, getNodeEnv } from '@pgpmjs/env';
|
|
2
|
+
export { getEnvOptions, getConstructiveEnvOptions } from './merge';
|
|
3
|
+
export { getGraphQLEnvVars } from './env';
|
|
4
|
+
export type { ConstructiveOptions, ConstructiveGraphQLOptions } from '@constructive-io/graphql-types';
|
|
5
|
+
export { constructiveDefaults, constructiveGraphqlDefaults } from '@constructive-io/graphql-types';
|
package/esm/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// Re-export core env utilities from @pgpmjs/env
|
|
2
|
+
export { loadConfigSync, loadConfigFileSync, loadConfigSyncFromDir, resolvePgpmPath, getConnEnvOptions, getDeploymentEnvOptions, getNodeEnv } from '@pgpmjs/env';
|
|
3
|
+
// Export Constructive-specific env functions
|
|
4
|
+
export { getEnvOptions, getConstructiveEnvOptions } from './merge';
|
|
5
|
+
export { getGraphQLEnvVars } from './env';
|
|
6
|
+
export { constructiveDefaults, constructiveGraphqlDefaults } from '@constructive-io/graphql-types';
|
package/esm/merge.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ConstructiveOptions } from '@constructive-io/graphql-types';
|
|
2
|
+
/**
|
|
3
|
+
* Get Constructive environment options by merging:
|
|
4
|
+
* 1. Core PGPM defaults (from @pgpmjs/env)
|
|
5
|
+
* 2. GraphQL defaults (from @constructive-io/graphql-types)
|
|
6
|
+
* 3. Config file options (including GraphQL options)
|
|
7
|
+
* 4. Environment variables (both core and GraphQL)
|
|
8
|
+
* 5. Runtime overrides
|
|
9
|
+
*
|
|
10
|
+
* This is the main entry point for Constructive packages that need
|
|
11
|
+
* both core PGPM options and GraphQL/Graphile options.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getEnvOptions: (overrides?: Partial<ConstructiveOptions>, cwd?: string) => ConstructiveOptions;
|
|
14
|
+
/**
|
|
15
|
+
* Alias - same as getEnvOptions
|
|
16
|
+
*/
|
|
17
|
+
export declare const getConstructiveEnvOptions: (overrides?: Partial<ConstructiveOptions>, cwd?: string) => ConstructiveOptions;
|
package/esm/merge.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import deepmerge from 'deepmerge';
|
|
2
|
+
import { constructiveGraphqlDefaults } from '@constructive-io/graphql-types';
|
|
3
|
+
import { getEnvOptions as getPgpmEnvOptions, loadConfigSync } from '@pgpmjs/env';
|
|
4
|
+
import { getGraphQLEnvVars } from './env';
|
|
5
|
+
/**
|
|
6
|
+
* Get Constructive environment options by merging:
|
|
7
|
+
* 1. Core PGPM defaults (from @pgpmjs/env)
|
|
8
|
+
* 2. GraphQL defaults (from @constructive-io/graphql-types)
|
|
9
|
+
* 3. Config file options (including GraphQL options)
|
|
10
|
+
* 4. Environment variables (both core and GraphQL)
|
|
11
|
+
* 5. Runtime overrides
|
|
12
|
+
*
|
|
13
|
+
* This is the main entry point for Constructive packages that need
|
|
14
|
+
* both core PGPM options and GraphQL/Graphile options.
|
|
15
|
+
*/
|
|
16
|
+
export const getEnvOptions = (overrides = {}, cwd = process.cwd()) => {
|
|
17
|
+
// Get core PGPM options (includes pgpmDefaults + config + core env vars)
|
|
18
|
+
const coreOptions = getPgpmEnvOptions({}, cwd);
|
|
19
|
+
// Get GraphQL-specific env vars
|
|
20
|
+
const graphqlEnvOptions = getGraphQLEnvVars();
|
|
21
|
+
// Load config again to get any GraphQL-specific config
|
|
22
|
+
// Config files can contain Constructive options (graphile, features, api)
|
|
23
|
+
// even though loadConfigSync returns PgpmOptions type
|
|
24
|
+
const configOptions = loadConfigSync(cwd);
|
|
25
|
+
// Merge in order: core -> graphql defaults -> config (for graphql keys) -> graphql env -> overrides
|
|
26
|
+
return deepmerge.all([
|
|
27
|
+
coreOptions,
|
|
28
|
+
constructiveGraphqlDefaults,
|
|
29
|
+
// Only merge graphql-related keys from config (if present)
|
|
30
|
+
{
|
|
31
|
+
...(configOptions.graphile && { graphile: configOptions.graphile }),
|
|
32
|
+
...(configOptions.features && { features: configOptions.features }),
|
|
33
|
+
...(configOptions.api && { api: configOptions.api }),
|
|
34
|
+
},
|
|
35
|
+
graphqlEnvOptions,
|
|
36
|
+
overrides
|
|
37
|
+
]);
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Alias - same as getEnvOptions
|
|
41
|
+
*/
|
|
42
|
+
export const getConstructiveEnvOptions = getEnvOptions;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { loadConfigSync, loadConfigFileSync, loadConfigSyncFromDir, resolvePgpmPath, getConnEnvOptions, getDeploymentEnvOptions, getNodeEnv } from '@pgpmjs/env';
|
|
2
|
+
export { getEnvOptions, getConstructiveEnvOptions } from './merge';
|
|
3
|
+
export { getGraphQLEnvVars } from './env';
|
|
4
|
+
export type { ConstructiveOptions, ConstructiveGraphQLOptions } from '@constructive-io/graphql-types';
|
|
5
|
+
export { constructiveDefaults, constructiveGraphqlDefaults } from '@constructive-io/graphql-types';
|
package/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.constructiveGraphqlDefaults = exports.constructiveDefaults = exports.getGraphQLEnvVars = exports.getConstructiveEnvOptions = exports.getEnvOptions = exports.getNodeEnv = exports.getDeploymentEnvOptions = exports.getConnEnvOptions = exports.resolvePgpmPath = exports.loadConfigSyncFromDir = exports.loadConfigFileSync = exports.loadConfigSync = void 0;
|
|
4
|
+
// Re-export core env utilities from @pgpmjs/env
|
|
5
|
+
var env_1 = require("@pgpmjs/env");
|
|
6
|
+
Object.defineProperty(exports, "loadConfigSync", { enumerable: true, get: function () { return env_1.loadConfigSync; } });
|
|
7
|
+
Object.defineProperty(exports, "loadConfigFileSync", { enumerable: true, get: function () { return env_1.loadConfigFileSync; } });
|
|
8
|
+
Object.defineProperty(exports, "loadConfigSyncFromDir", { enumerable: true, get: function () { return env_1.loadConfigSyncFromDir; } });
|
|
9
|
+
Object.defineProperty(exports, "resolvePgpmPath", { enumerable: true, get: function () { return env_1.resolvePgpmPath; } });
|
|
10
|
+
Object.defineProperty(exports, "getConnEnvOptions", { enumerable: true, get: function () { return env_1.getConnEnvOptions; } });
|
|
11
|
+
Object.defineProperty(exports, "getDeploymentEnvOptions", { enumerable: true, get: function () { return env_1.getDeploymentEnvOptions; } });
|
|
12
|
+
Object.defineProperty(exports, "getNodeEnv", { enumerable: true, get: function () { return env_1.getNodeEnv; } });
|
|
13
|
+
// Export Constructive-specific env functions
|
|
14
|
+
var merge_1 = require("./merge");
|
|
15
|
+
Object.defineProperty(exports, "getEnvOptions", { enumerable: true, get: function () { return merge_1.getEnvOptions; } });
|
|
16
|
+
Object.defineProperty(exports, "getConstructiveEnvOptions", { enumerable: true, get: function () { return merge_1.getConstructiveEnvOptions; } });
|
|
17
|
+
var env_2 = require("./env");
|
|
18
|
+
Object.defineProperty(exports, "getGraphQLEnvVars", { enumerable: true, get: function () { return env_2.getGraphQLEnvVars; } });
|
|
19
|
+
var graphql_types_1 = require("@constructive-io/graphql-types");
|
|
20
|
+
Object.defineProperty(exports, "constructiveDefaults", { enumerable: true, get: function () { return graphql_types_1.constructiveDefaults; } });
|
|
21
|
+
Object.defineProperty(exports, "constructiveGraphqlDefaults", { enumerable: true, get: function () { return graphql_types_1.constructiveGraphqlDefaults; } });
|
package/merge.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ConstructiveOptions } from '@constructive-io/graphql-types';
|
|
2
|
+
/**
|
|
3
|
+
* Get Constructive environment options by merging:
|
|
4
|
+
* 1. Core PGPM defaults (from @pgpmjs/env)
|
|
5
|
+
* 2. GraphQL defaults (from @constructive-io/graphql-types)
|
|
6
|
+
* 3. Config file options (including GraphQL options)
|
|
7
|
+
* 4. Environment variables (both core and GraphQL)
|
|
8
|
+
* 5. Runtime overrides
|
|
9
|
+
*
|
|
10
|
+
* This is the main entry point for Constructive packages that need
|
|
11
|
+
* both core PGPM options and GraphQL/Graphile options.
|
|
12
|
+
*/
|
|
13
|
+
export declare const getEnvOptions: (overrides?: Partial<ConstructiveOptions>, cwd?: string) => ConstructiveOptions;
|
|
14
|
+
/**
|
|
15
|
+
* Alias - same as getEnvOptions
|
|
16
|
+
*/
|
|
17
|
+
export declare const getConstructiveEnvOptions: (overrides?: Partial<ConstructiveOptions>, cwd?: string) => ConstructiveOptions;
|
package/merge.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getConstructiveEnvOptions = exports.getEnvOptions = void 0;
|
|
7
|
+
const deepmerge_1 = __importDefault(require("deepmerge"));
|
|
8
|
+
const graphql_types_1 = require("@constructive-io/graphql-types");
|
|
9
|
+
const env_1 = require("@pgpmjs/env");
|
|
10
|
+
const env_2 = require("./env");
|
|
11
|
+
/**
|
|
12
|
+
* Get Constructive environment options by merging:
|
|
13
|
+
* 1. Core PGPM defaults (from @pgpmjs/env)
|
|
14
|
+
* 2. GraphQL defaults (from @constructive-io/graphql-types)
|
|
15
|
+
* 3. Config file options (including GraphQL options)
|
|
16
|
+
* 4. Environment variables (both core and GraphQL)
|
|
17
|
+
* 5. Runtime overrides
|
|
18
|
+
*
|
|
19
|
+
* This is the main entry point for Constructive packages that need
|
|
20
|
+
* both core PGPM options and GraphQL/Graphile options.
|
|
21
|
+
*/
|
|
22
|
+
const getEnvOptions = (overrides = {}, cwd = process.cwd()) => {
|
|
23
|
+
// Get core PGPM options (includes pgpmDefaults + config + core env vars)
|
|
24
|
+
const coreOptions = (0, env_1.getEnvOptions)({}, cwd);
|
|
25
|
+
// Get GraphQL-specific env vars
|
|
26
|
+
const graphqlEnvOptions = (0, env_2.getGraphQLEnvVars)();
|
|
27
|
+
// Load config again to get any GraphQL-specific config
|
|
28
|
+
// Config files can contain Constructive options (graphile, features, api)
|
|
29
|
+
// even though loadConfigSync returns PgpmOptions type
|
|
30
|
+
const configOptions = (0, env_1.loadConfigSync)(cwd);
|
|
31
|
+
// Merge in order: core -> graphql defaults -> config (for graphql keys) -> graphql env -> overrides
|
|
32
|
+
return deepmerge_1.default.all([
|
|
33
|
+
coreOptions,
|
|
34
|
+
graphql_types_1.constructiveGraphqlDefaults,
|
|
35
|
+
// Only merge graphql-related keys from config (if present)
|
|
36
|
+
{
|
|
37
|
+
...(configOptions.graphile && { graphile: configOptions.graphile }),
|
|
38
|
+
...(configOptions.features && { features: configOptions.features }),
|
|
39
|
+
...(configOptions.api && { api: configOptions.api }),
|
|
40
|
+
},
|
|
41
|
+
graphqlEnvOptions,
|
|
42
|
+
overrides
|
|
43
|
+
]);
|
|
44
|
+
};
|
|
45
|
+
exports.getEnvOptions = getEnvOptions;
|
|
46
|
+
/**
|
|
47
|
+
* Alias - same as getEnvOptions
|
|
48
|
+
*/
|
|
49
|
+
exports.getConstructiveEnvOptions = exports.getEnvOptions;
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@constructive-io/graphql-env",
|
|
3
|
+
"version": "2.8.4",
|
|
4
|
+
"author": "Constructive <developers@constructive.io>",
|
|
5
|
+
"description": "Constructive environment configuration with GraphQL/Graphile support",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"module": "esm/index.js",
|
|
8
|
+
"types": "index.d.ts",
|
|
9
|
+
"homepage": "https://github.com/constructive-io/constructive",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"publishConfig": {
|
|
12
|
+
"access": "public",
|
|
13
|
+
"directory": "dist"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/constructive-io/constructive"
|
|
18
|
+
},
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/constructive-io/constructive/issues"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"clean": "makage clean",
|
|
24
|
+
"prepack": "npm run build",
|
|
25
|
+
"build": "makage build",
|
|
26
|
+
"build:dev": "makage build --dev",
|
|
27
|
+
"lint": "eslint . --fix",
|
|
28
|
+
"test": "jest --passWithNoTests",
|
|
29
|
+
"test:watch": "jest --watch"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@constructive-io/graphql-types": "^2.12.4",
|
|
33
|
+
"@pgpmjs/env": "^2.8.4",
|
|
34
|
+
"deepmerge": "^4.3.1"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [
|
|
37
|
+
"env",
|
|
38
|
+
"environment",
|
|
39
|
+
"config",
|
|
40
|
+
"constructive",
|
|
41
|
+
"graphql",
|
|
42
|
+
"postgraphile"
|
|
43
|
+
],
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"makage": "^0.1.8"
|
|
46
|
+
},
|
|
47
|
+
"gitHead": "22cfe32e994e26a6490e04e28bab26d1e7e6345c"
|
|
48
|
+
}
|