@danielfgray/pg-sourcerer 0.3.0 → 0.5.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/bin/pgsourcerer +2 -0
- package/dist/__tests__/fixtures/index.d.ts +15 -0
- package/dist/__tests__/fixtures/index.d.ts.map +1 -0
- package/dist/__tests__/fixtures/index.js +19 -0
- package/dist/__tests__/fixtures/index.js.map +1 -0
- package/dist/__tests__/fixtures/introspection.json +40522 -0
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +7 -46
- package/dist/cli.js.map +1 -1
- package/dist/config.d.ts +38 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +13 -2
- package/dist/config.js.map +1 -1
- package/dist/{lib/conjure.d.ts → conjure/index.d.ts} +62 -3
- package/dist/conjure/index.d.ts.map +1 -0
- package/dist/{lib/conjure.js → conjure/index.js} +124 -3
- package/dist/conjure/index.js.map +1 -0
- package/dist/conjure/signature.d.ts +85 -0
- package/dist/conjure/signature.d.ts.map +1 -0
- package/dist/conjure/signature.js +130 -0
- package/dist/conjure/signature.js.map +1 -0
- package/dist/conjure/types.d.ts +97 -0
- package/dist/conjure/types.d.ts.map +1 -0
- package/dist/conjure/types.js +206 -0
- package/dist/conjure/types.js.map +1 -0
- package/dist/errors.d.ts +114 -139
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +82 -36
- package/dist/errors.js.map +1 -1
- package/dist/generate.d.ts +45 -46
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +86 -59
- package/dist/generate.js.map +1 -1
- package/dist/hex/builder.d.ts +12 -0
- package/dist/hex/builder.d.ts.map +1 -0
- package/dist/hex/builder.js +64 -0
- package/dist/hex/builder.js.map +1 -0
- package/dist/hex/ddl.d.ts +53 -0
- package/dist/hex/ddl.d.ts.map +1 -0
- package/dist/hex/ddl.js +306 -0
- package/dist/hex/ddl.js.map +1 -0
- package/dist/hex/index.d.ts +105 -0
- package/dist/hex/index.d.ts.map +1 -0
- package/dist/hex/index.js +81 -0
- package/dist/hex/index.js.map +1 -0
- package/dist/hex/primitives.d.ts +23 -0
- package/dist/hex/primitives.d.ts.map +1 -0
- package/dist/hex/primitives.js +38 -0
- package/dist/hex/primitives.js.map +1 -0
- package/dist/hex/query.d.ts +116 -0
- package/dist/hex/query.d.ts.map +1 -0
- package/dist/hex/query.js +219 -0
- package/dist/hex/query.js.map +1 -0
- package/dist/hex/types.d.ts +287 -0
- package/dist/hex/types.d.ts.map +1 -0
- package/dist/hex/types.js +431 -0
- package/dist/hex/types.js.map +1 -0
- package/dist/index.d.ts +17 -25
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +33 -44
- package/dist/index.js.map +1 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +76 -140
- package/dist/init.js.map +1 -1
- package/dist/ir/extensions/queries.d.ts +6 -6
- package/dist/ir/extensions/queries.d.ts.map +1 -1
- package/dist/ir/extensions/queries.js +6 -4
- package/dist/ir/extensions/queries.js.map +1 -1
- package/dist/ir/extensions/schema-builder.d.ts.map +1 -1
- package/dist/ir/extensions/schema-builder.js.map +1 -1
- package/dist/ir/index.d.ts.map +1 -1
- package/dist/ir/index.js.map +1 -1
- package/dist/ir/relation-graph.d.ts.map +1 -1
- package/dist/ir/relation-graph.js +8 -8
- package/dist/ir/relation-graph.js.map +1 -1
- package/dist/ir/semantic-ir.d.ts +38 -0
- package/dist/ir/semantic-ir.d.ts.map +1 -1
- package/dist/ir/semantic-ir.js +50 -2
- package/dist/ir/semantic-ir.js.map +1 -1
- package/dist/ir/smart-tags.d.ts.map +1 -1
- package/dist/ir/smart-tags.js.map +1 -1
- package/dist/lib/field-utils.d.ts.map +1 -1
- package/dist/lib/field-utils.js +7 -7
- package/dist/lib/field-utils.js.map +1 -1
- package/dist/lib/join-graph.d.ts +95 -0
- package/dist/lib/join-graph.d.ts.map +1 -0
- package/dist/lib/join-graph.js +305 -0
- package/dist/lib/join-graph.js.map +1 -0
- package/dist/lib/picker.d.ts +60 -0
- package/dist/lib/picker.d.ts.map +1 -0
- package/dist/lib/picker.js +325 -0
- package/dist/lib/picker.js.map +1 -0
- package/dist/plugins/arktype.d.ts +20 -24
- package/dist/plugins/arktype.d.ts.map +1 -1
- package/dist/plugins/arktype.js +462 -386
- package/dist/plugins/arktype.js.map +1 -1
- package/dist/plugins/effect/http.d.ts +7 -0
- package/dist/plugins/effect/http.d.ts.map +1 -0
- package/dist/plugins/effect/http.js +460 -0
- package/dist/plugins/effect/http.js.map +1 -0
- package/dist/plugins/effect/index.d.ts +22 -0
- package/dist/plugins/effect/index.d.ts.map +1 -0
- package/dist/plugins/effect/index.js +65 -0
- package/dist/plugins/effect/index.js.map +1 -0
- package/dist/plugins/effect/models.d.ts +6 -0
- package/dist/plugins/effect/models.d.ts.map +1 -0
- package/dist/plugins/effect/models.js +116 -0
- package/dist/plugins/effect/models.js.map +1 -0
- package/dist/plugins/effect/repos.d.ts +21 -0
- package/dist/plugins/effect/repos.d.ts.map +1 -0
- package/dist/plugins/effect/repos.js +131 -0
- package/dist/plugins/effect/repos.js.map +1 -0
- package/dist/plugins/effect/schemas.d.ts +7 -0
- package/dist/plugins/effect/schemas.d.ts.map +1 -0
- package/dist/plugins/effect/schemas.js +75 -0
- package/dist/plugins/effect/schemas.js.map +1 -0
- package/dist/plugins/effect/shared.d.ts +116 -0
- package/dist/plugins/effect/shared.d.ts.map +1 -0
- package/dist/plugins/effect/shared.js +164 -0
- package/dist/plugins/effect/shared.js.map +1 -0
- package/dist/plugins/http-elysia.d.ts +20 -27
- package/dist/plugins/http-elysia.d.ts.map +1 -1
- package/dist/plugins/http-elysia.js +350 -475
- package/dist/plugins/http-elysia.js.map +1 -1
- package/dist/plugins/http-express.d.ts +20 -31
- package/dist/plugins/http-express.d.ts.map +1 -1
- package/dist/plugins/http-express.js +281 -268
- package/dist/plugins/http-express.js.map +1 -1
- package/dist/plugins/http-hono.d.ts +17 -33
- package/dist/plugins/http-hono.d.ts.map +1 -1
- package/dist/plugins/http-hono.js +317 -341
- package/dist/plugins/http-hono.js.map +1 -1
- package/dist/plugins/http-orpc.d.ts +34 -33
- package/dist/plugins/http-orpc.d.ts.map +1 -1
- package/dist/plugins/http-orpc.js +345 -257
- package/dist/plugins/http-orpc.js.map +1 -1
- package/dist/plugins/http-trpc.d.ts +33 -35
- package/dist/plugins/http-trpc.d.ts.map +1 -1
- package/dist/plugins/http-trpc.js +337 -241
- package/dist/plugins/http-trpc.js.map +1 -1
- package/dist/plugins/kysely.d.ts +54 -59
- package/dist/plugins/kysely.d.ts.map +1 -1
- package/dist/plugins/kysely.js +826 -687
- package/dist/plugins/kysely.js.map +1 -1
- package/dist/plugins/sql-queries.d.ts +38 -44
- package/dist/plugins/sql-queries.d.ts.map +1 -1
- package/dist/plugins/sql-queries.js +497 -897
- package/dist/plugins/sql-queries.js.map +1 -1
- package/dist/plugins/types.d.ts +12 -20
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/plugins/types.js +84 -227
- package/dist/plugins/types.js.map +1 -1
- package/dist/plugins/valibot.d.ts +7 -44
- package/dist/plugins/valibot.d.ts.map +1 -1
- package/dist/plugins/valibot.js +376 -382
- package/dist/plugins/valibot.js.map +1 -1
- package/dist/plugins/zod.d.ts +20 -24
- package/dist/plugins/zod.d.ts.map +1 -1
- package/dist/plugins/zod.js +370 -367
- package/dist/plugins/zod.js.map +1 -1
- package/dist/runtime/emit.d.ts +64 -0
- package/dist/runtime/emit.d.ts.map +1 -0
- package/dist/runtime/emit.js +445 -0
- package/dist/runtime/emit.js.map +1 -0
- package/dist/runtime/errors.d.ts +36 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +29 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/file-assignment.d.ts +161 -0
- package/dist/runtime/file-assignment.d.ts.map +1 -0
- package/dist/runtime/file-assignment.js +195 -0
- package/dist/runtime/file-assignment.js.map +1 -0
- package/dist/runtime/orchestrator.d.ts +62 -0
- package/dist/runtime/orchestrator.d.ts.map +1 -0
- package/dist/runtime/orchestrator.js +99 -0
- package/dist/runtime/orchestrator.js.map +1 -0
- package/dist/runtime/registry.d.ts +268 -0
- package/dist/runtime/registry.d.ts.map +1 -0
- package/dist/runtime/registry.js +436 -0
- package/dist/runtime/registry.js.map +1 -0
- package/dist/runtime/types.d.ts +182 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/runtime/validation.d.ts +41 -0
- package/dist/runtime/validation.d.ts.map +1 -0
- package/dist/runtime/validation.js +70 -0
- package/dist/runtime/validation.js.map +1 -0
- package/dist/services/config-loader.d.ts.map +1 -1
- package/dist/services/config-loader.js +15 -6
- package/dist/services/config-loader.js.map +1 -1
- package/dist/services/config.d.ts +55 -25
- package/dist/services/config.d.ts.map +1 -1
- package/dist/services/config.js +60 -34
- package/dist/services/config.js.map +1 -1
- package/dist/services/file-writer.d.ts +3 -3
- package/dist/services/file-writer.d.ts.map +1 -1
- package/dist/services/file-writer.js +6 -8
- package/dist/services/file-writer.js.map +1 -1
- package/dist/services/inflection.d.ts +126 -27
- package/dist/services/inflection.d.ts.map +1 -1
- package/dist/services/inflection.js +300 -72
- package/dist/services/inflection.js.map +1 -1
- package/dist/services/introspection.d.ts.map +1 -1
- package/dist/services/introspection.js +6 -6
- package/dist/services/introspection.js.map +1 -1
- package/dist/services/ir-builder.d.ts.map +1 -1
- package/dist/services/ir-builder.js +73 -77
- package/dist/services/ir-builder.js.map +1 -1
- package/dist/services/ir.d.ts.map +1 -1
- package/dist/services/ir.js.map +1 -1
- package/dist/services/pg-types.d.ts.map +1 -1
- package/dist/services/pg-types.js +3 -3
- package/dist/services/pg-types.js.map +1 -1
- package/dist/services/smart-tags-parser.d.ts.map +1 -1
- package/dist/services/smart-tags-parser.js +4 -4
- package/dist/services/smart-tags-parser.js.map +1 -1
- package/dist/services/type-hints.d.ts.map +1 -1
- package/dist/services/type-hints.js +1 -1
- package/dist/services/type-hints.js.map +1 -1
- package/dist/services/user-module-parser.d.ts +46 -0
- package/dist/services/user-module-parser.d.ts.map +1 -0
- package/dist/services/user-module-parser.js +181 -0
- package/dist/services/user-module-parser.js.map +1 -0
- package/dist/shared/converters.d.ts +60 -0
- package/dist/shared/converters.d.ts.map +1 -0
- package/dist/shared/converters.js +168 -0
- package/dist/shared/converters.js.map +1 -0
- package/dist/shared/query-types.d.ts +95 -0
- package/dist/shared/query-types.d.ts.map +1 -0
- package/dist/shared/query-types.js +9 -0
- package/dist/shared/query-types.js.map +1 -0
- package/dist/testing.d.ts +125 -37
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +134 -42
- package/dist/testing.js.map +1 -1
- package/dist/user-module.d.ts +86 -0
- package/dist/user-module.d.ts.map +1 -0
- package/dist/user-module.js +55 -0
- package/dist/user-module.js.map +1 -0
- package/package.json +10 -6
- package/dist/lib/conjure.d.ts.map +0 -1
- package/dist/lib/conjure.js.map +0 -1
- package/dist/lib/hex.d.ts +0 -119
- package/dist/lib/hex.d.ts.map +0 -1
- package/dist/lib/hex.js +0 -188
- package/dist/lib/hex.js.map +0 -1
- package/dist/plugins/effect.d.ts +0 -53
- package/dist/plugins/effect.d.ts.map +0 -1
- package/dist/plugins/effect.js +0 -1074
- package/dist/plugins/effect.js.map +0 -1
- package/dist/plugins/kysely/queries.d.ts +0 -92
- package/dist/plugins/kysely/queries.d.ts.map +0 -1
- package/dist/plugins/kysely/queries.js +0 -1169
- package/dist/plugins/kysely/queries.js.map +0 -1
- package/dist/plugins/kysely/shared.d.ts +0 -59
- package/dist/plugins/kysely/shared.d.ts.map +0 -1
- package/dist/plugins/kysely/shared.js +0 -247
- package/dist/plugins/kysely/shared.js.map +0 -1
- package/dist/plugins/kysely/types.d.ts +0 -22
- package/dist/plugins/kysely/types.d.ts.map +0 -1
- package/dist/plugins/kysely/types.js +0 -428
- package/dist/plugins/kysely/types.js.map +0 -1
- package/dist/services/artifact-store.d.ts +0 -65
- package/dist/services/artifact-store.d.ts.map +0 -1
- package/dist/services/artifact-store.js +0 -57
- package/dist/services/artifact-store.js.map +0 -1
- package/dist/services/core-providers.d.ts +0 -15
- package/dist/services/core-providers.d.ts.map +0 -1
- package/dist/services/core-providers.js +0 -23
- package/dist/services/core-providers.js.map +0 -1
- package/dist/services/emissions.d.ts +0 -103
- package/dist/services/emissions.d.ts.map +0 -1
- package/dist/services/emissions.js +0 -241
- package/dist/services/emissions.js.map +0 -1
- package/dist/services/execution.d.ts +0 -35
- package/dist/services/execution.d.ts.map +0 -1
- package/dist/services/execution.js +0 -86
- package/dist/services/execution.js.map +0 -1
- package/dist/services/file-builder.d.ts +0 -85
- package/dist/services/file-builder.d.ts.map +0 -1
- package/dist/services/file-builder.js +0 -112
- package/dist/services/file-builder.js.map +0 -1
- package/dist/services/plugin-meta.d.ts +0 -33
- package/dist/services/plugin-meta.d.ts.map +0 -1
- package/dist/services/plugin-meta.js +0 -24
- package/dist/services/plugin-meta.js.map +0 -1
- package/dist/services/plugin-runner.d.ts +0 -42
- package/dist/services/plugin-runner.d.ts.map +0 -1
- package/dist/services/plugin-runner.js +0 -84
- package/dist/services/plugin-runner.js.map +0 -1
- package/dist/services/plugin.d.ts +0 -421
- package/dist/services/plugin.d.ts.map +0 -1
- package/dist/services/plugin.js +0 -197
- package/dist/services/plugin.js.map +0 -1
- package/dist/services/resolution.d.ts +0 -38
- package/dist/services/resolution.d.ts.map +0 -1
- package/dist/services/resolution.js +0 -242
- package/dist/services/resolution.js.map +0 -1
- package/dist/services/service-registry.d.ts +0 -74
- package/dist/services/service-registry.d.ts.map +0 -1
- package/dist/services/service-registry.js +0 -61
- package/dist/services/service-registry.js.map +0 -1
- package/dist/services/symbols.d.ts +0 -144
- package/dist/services/symbols.d.ts.map +0 -1
- package/dist/services/symbols.js +0 -144
- package/dist/services/symbols.js.map +0 -1
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query descriptor types for SQL code generation
|
|
3
|
+
*
|
|
4
|
+
* These types describe SQL queries in a way that plugins can consume
|
|
5
|
+
* to generate typed function wrappers. They are produced by `hex` (the SQL
|
|
6
|
+
* template builder) and consumed by query plugins.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Complete description of a generated query.
|
|
10
|
+
*
|
|
11
|
+
* This is the primary type that `hex.build()` produces and query plugins consume.
|
|
12
|
+
*/
|
|
13
|
+
export interface QueryDescriptor {
|
|
14
|
+
/** Function name, e.g., "findUserById", "insertUser" */
|
|
15
|
+
readonly name: string;
|
|
16
|
+
/** Entity this query operates on, e.g., "User" */
|
|
17
|
+
readonly entityName: string;
|
|
18
|
+
/** SQL operation type */
|
|
19
|
+
readonly operation: QueryOperation;
|
|
20
|
+
/** Lookup variant, e.g., "byId", "byEmail" (for distinguishing similar queries) */
|
|
21
|
+
readonly variant?: string;
|
|
22
|
+
/** SQL template with positional parameters ($1, $2, etc.) */
|
|
23
|
+
readonly sql: string;
|
|
24
|
+
/** Input parameters */
|
|
25
|
+
readonly params: readonly ParamDescriptor[];
|
|
26
|
+
/** Return type description */
|
|
27
|
+
readonly returns: ReturnDescriptor;
|
|
28
|
+
/** Optional metadata for advanced use cases */
|
|
29
|
+
readonly meta?: QueryMetadata;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Describes a single query parameter.
|
|
33
|
+
*/
|
|
34
|
+
export interface ParamDescriptor {
|
|
35
|
+
/** Parameter name, e.g., "id", "email" */
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/** TypeScript type string, e.g., "string", "number", "string | null" */
|
|
38
|
+
readonly tsType: string;
|
|
39
|
+
/** PostgreSQL type, e.g., "uuid", "text", "integer" */
|
|
40
|
+
readonly pgType: string;
|
|
41
|
+
/** Whether the parameter accepts null */
|
|
42
|
+
readonly nullable: boolean;
|
|
43
|
+
/** Whether the parameter has a default value (can be omitted) */
|
|
44
|
+
readonly hasDefault?: boolean;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Describes the return type of a query.
|
|
48
|
+
*/
|
|
49
|
+
export interface ReturnDescriptor {
|
|
50
|
+
/** How many rows are expected */
|
|
51
|
+
readonly mode: ReturnMode;
|
|
52
|
+
/** Fields in the return type (empty for 'affected' or 'void') */
|
|
53
|
+
readonly fields: readonly FieldDescriptor[];
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Describes a field in the query return type.
|
|
57
|
+
*/
|
|
58
|
+
export interface FieldDescriptor {
|
|
59
|
+
/** Column name or alias */
|
|
60
|
+
readonly name: string;
|
|
61
|
+
/** TypeScript type string */
|
|
62
|
+
readonly tsType: string;
|
|
63
|
+
/** PostgreSQL type */
|
|
64
|
+
readonly pgType: string;
|
|
65
|
+
/** Whether the field can be null */
|
|
66
|
+
readonly nullable: boolean;
|
|
67
|
+
/** Whether this is an array type */
|
|
68
|
+
readonly isArray?: boolean;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Optional metadata for advanced query use cases.
|
|
72
|
+
*/
|
|
73
|
+
export interface QueryMetadata {
|
|
74
|
+
/** Fully qualified table name (schema.table) */
|
|
75
|
+
readonly table: string;
|
|
76
|
+
/** Indexes used by this query */
|
|
77
|
+
readonly indexes?: readonly string[];
|
|
78
|
+
/** Generated from table/column comments */
|
|
79
|
+
readonly comment?: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* SQL operation categories.
|
|
83
|
+
*/
|
|
84
|
+
export type QueryOperation = "select" | "insert" | "update" | "delete" | "upsert";
|
|
85
|
+
/**
|
|
86
|
+
* Query return cardinality modes.
|
|
87
|
+
*
|
|
88
|
+
* - `one`: Exactly one row expected (throws if 0 or >1)
|
|
89
|
+
* - `oneOrNone`: Zero or one row (returns T | null)
|
|
90
|
+
* - `many`: Zero or more rows (returns T[])
|
|
91
|
+
* - `affected`: Returns affected row count (number)
|
|
92
|
+
* - `void`: Returns nothing
|
|
93
|
+
*/
|
|
94
|
+
export type ReturnMode = "one" | "oneOrNone" | "many" | "affected" | "void";
|
|
95
|
+
//# sourceMappingURL=query-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-types.d.ts","sourceRoot":"","sources":["../../src/shared/query-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,kDAAkD;IAClD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAE5B,yBAAyB;IACzB,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IAEnC,mFAAmF;IACnF,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAE1B,6DAA6D;IAC7D,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IAErB,uBAAuB;IACvB,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;IAE5C,8BAA8B;IAC9B,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC;IAEnC,+CAA+C;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC;CAC/B;AAMD;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,0CAA0C;IAC1C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,yCAAyC;IACzC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,iEAAiE;IACjE,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,iCAAiC;IACjC,QAAQ,CAAC,IAAI,EAAE,UAAU,CAAC;IAE1B,iEAAiE;IACjE,QAAQ,CAAC,MAAM,EAAE,SAAS,eAAe,EAAE,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,6BAA6B;IAC7B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,sBAAsB;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB,oCAAoC;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B,oCAAoC;IACpC,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,gDAAgD;IAChD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB,iCAAiC;IACjC,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAErC,2CAA2C;IAC3C,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;AAMD;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElF;;;;;;;;GAQG;AACH,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query descriptor types for SQL code generation
|
|
3
|
+
*
|
|
4
|
+
* These types describe SQL queries in a way that plugins can consume
|
|
5
|
+
* to generate typed function wrappers. They are produced by `hex` (the SQL
|
|
6
|
+
* template builder) and consumed by query plugins.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=query-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"query-types.js","sourceRoot":"","sources":["../../src/shared/query-types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,56 +1,144 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Testing Utilities
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Helpers for testing plugins and the generation pipeline.
|
|
5
|
+
*
|
|
6
|
+
* ## Plugin Testing
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { testPlugin, testIR, testConfig } from "pg-sourcerer/testing"
|
|
10
|
+
*
|
|
11
|
+
* it.effect("generates types", () =>
|
|
12
|
+
* Effect.gen(function* () {
|
|
13
|
+
* const result = yield* testPlugin(myPlugin, {
|
|
14
|
+
* ir: testIR({ entities: [...] }),
|
|
15
|
+
* })
|
|
16
|
+
* expect(result.declarations).toHaveLength(1)
|
|
17
|
+
* })
|
|
18
|
+
* )
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ## IR Building
|
|
22
|
+
*
|
|
23
|
+
* Use testIRWithEntities with real entities from ir-builder, or create
|
|
24
|
+
* minimal stubs for unit tests that don't need full introspection data.
|
|
5
25
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import type
|
|
26
|
+
import { Effect } from "effect";
|
|
27
|
+
import type { Plugin } from "./runtime/types.js";
|
|
28
|
+
import { type OrchestratorConfig, type OrchestratorResult } from "./runtime/orchestrator.js";
|
|
29
|
+
import { type EmittedFile } from "./runtime/emit.js";
|
|
30
|
+
import type { SemanticIR, Entity } from "./ir/semantic-ir.js";
|
|
31
|
+
import { type CoreInflection } from "./services/inflection.js";
|
|
32
|
+
import { type TypeHintRegistry } from "./services/type-hints.js";
|
|
10
33
|
/**
|
|
11
|
-
*
|
|
34
|
+
* Create a minimal SemanticIR for testing.
|
|
12
35
|
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
36
|
+
* Most tests just need an empty or partial IR. For tests that don't need
|
|
37
|
+
* real entity structures, use actual IRBuilder or provide entities directly.
|
|
38
|
+
*/
|
|
39
|
+
export declare function testIR(overrides?: Partial<SemanticIR>): SemanticIR;
|
|
40
|
+
/**
|
|
41
|
+
* Create a SemanticIR with entities from a map or array.
|
|
15
42
|
*
|
|
16
|
-
*
|
|
43
|
+
* @example
|
|
17
44
|
* ```typescript
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
45
|
+
* // From array (uses entity.name as key)
|
|
46
|
+
* const ir = testIRWithEntities([userEntity, postEntity])
|
|
47
|
+
*
|
|
48
|
+
* // From map
|
|
49
|
+
* const ir = testIRWithEntities(new Map([["User", userEntity]]))
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function testIRWithEntities(entities: ReadonlyMap<string, Entity> | readonly Entity[]): SemanticIR;
|
|
53
|
+
/**
|
|
54
|
+
* Load introspection fixture and build IR from it.
|
|
55
|
+
*
|
|
56
|
+
* Returns an Effect that loads the pre-captured introspection data
|
|
57
|
+
* and builds IR using the real IR builder service.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* it.effect("uses fixture data", () =>
|
|
62
|
+
* Effect.gen(function* () {
|
|
63
|
+
* const ir = yield* testIRFromFixture(["app_public"]);
|
|
64
|
+
* const userEntity = ir.entities.get("User");
|
|
65
|
+
* expect(userEntity).toBeDefined();
|
|
66
|
+
* })
|
|
22
67
|
* )
|
|
23
68
|
* ```
|
|
24
69
|
*/
|
|
25
|
-
export declare
|
|
70
|
+
export declare function testIRFromFixture(schemas?: readonly string[]): Effect.Effect<SemanticIR, unknown>;
|
|
71
|
+
/**
|
|
72
|
+
* Options for testConfig.
|
|
73
|
+
*/
|
|
74
|
+
export interface TestConfigOptions {
|
|
75
|
+
/** IR to use (defaults to empty testIR) */
|
|
76
|
+
ir?: SemanticIR;
|
|
77
|
+
/** Inflection config */
|
|
78
|
+
inflection?: CoreInflection;
|
|
79
|
+
/** Type hints */
|
|
80
|
+
typeHints?: TypeHintRegistry;
|
|
81
|
+
/** Default file for unmatched symbols */
|
|
82
|
+
defaultFile?: string;
|
|
83
|
+
/** Output directory */
|
|
84
|
+
outputDir?: string;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Create an OrchestratorConfig for testing.
|
|
88
|
+
*/
|
|
89
|
+
export declare function testConfig(options?: TestConfigOptions): OrchestratorConfig;
|
|
90
|
+
/**
|
|
91
|
+
* Options for testing a plugin.
|
|
92
|
+
*/
|
|
93
|
+
export interface TestPluginOptions {
|
|
94
|
+
/** IR to use (defaults to empty testIR) */
|
|
95
|
+
ir?: SemanticIR;
|
|
96
|
+
/** Inflection config */
|
|
97
|
+
inflection?: CoreInflection;
|
|
98
|
+
/** Type hints */
|
|
99
|
+
typeHints?: TypeHintRegistry;
|
|
100
|
+
/** Default file for unmatched symbols */
|
|
101
|
+
defaultFile?: string;
|
|
102
|
+
/** Output directory */
|
|
103
|
+
outputDir?: string;
|
|
104
|
+
/** Additional plugins to run before this one (for dependencies) */
|
|
105
|
+
dependencies?: readonly Plugin[];
|
|
106
|
+
}
|
|
26
107
|
/**
|
|
27
|
-
*
|
|
108
|
+
* Run a single plugin through the orchestrator and return results.
|
|
28
109
|
*
|
|
29
|
-
*
|
|
30
|
-
* @param pluginName - The plugin name for PluginMeta
|
|
31
|
-
* @returns Layer with all services for plugin testing
|
|
110
|
+
* Useful for unit testing plugins in isolation.
|
|
32
111
|
*
|
|
33
|
-
*
|
|
112
|
+
* @example
|
|
34
113
|
* ```typescript
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
114
|
+
* it.effect("declares User type", () =>
|
|
115
|
+
* Effect.gen(function* () {
|
|
116
|
+
* const result = yield* testPlugin(typesPlugin)
|
|
117
|
+
* expect(result.declarations).toContainEqual(
|
|
118
|
+
* expect.objectContaining({ name: "User" })
|
|
119
|
+
* )
|
|
120
|
+
* })
|
|
121
|
+
* )
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
124
|
+
export declare function testPlugin(plugin: Plugin, options?: TestPluginOptions): Effect.Effect<OrchestratorResult, unknown>;
|
|
125
|
+
/**
|
|
126
|
+
* Run a plugin and emit files, returning both orchestration and emit results.
|
|
127
|
+
*
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* it.effect("generates valid TypeScript", () =>
|
|
131
|
+
* Effect.gen(function* () {
|
|
132
|
+
* const { files } = yield* testPluginEmit(typesPlugin, {
|
|
133
|
+
* ir: testIRWithEntities([...]),
|
|
44
134
|
* })
|
|
45
|
-
*
|
|
46
|
-
*
|
|
135
|
+
* expect(files[0].content).toContain("export type User")
|
|
136
|
+
* })
|
|
137
|
+
* )
|
|
47
138
|
* ```
|
|
48
139
|
*/
|
|
49
|
-
export declare function
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export { Symbols } from "./services/symbols.js";
|
|
54
|
-
export { runPlugins } from "./services/plugin-runner.js";
|
|
55
|
-
export { createIRBuilder, freezeIR } from "./ir/semantic-ir.js";
|
|
140
|
+
export declare function testPluginEmit(plugin: Plugin, options?: TestPluginOptions): Effect.Effect<{
|
|
141
|
+
result: OrchestratorResult;
|
|
142
|
+
files: readonly EmittedFile[];
|
|
143
|
+
}, unknown>;
|
|
56
144
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CA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E,cAAc,CAAC;IAC5B,iBAAiB;IACjB,SAAS,CAAC,EAAE,gBAAgB,CAAC;IAC7B,yCAAyC;IACzC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,uBAAuB;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mEAAmE;IACnE,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,UAAU,CACxB,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAY5C;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAAC,MAAM,CAAC;IAAE,MAAM,EAAE,kBAAkB,CAAC;IAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAA;CAAE,EAAE,OAAO,CAAC,CAOvF"}
|
package/dist/testing.js
CHANGED
|
@@ -1,63 +1,155 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Testing Utilities
|
|
3
3
|
*
|
|
4
|
-
*
|
|
4
|
+
* Helpers for testing plugins and the generation pipeline.
|
|
5
|
+
*
|
|
6
|
+
* ## Plugin Testing
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { testPlugin, testIR, testConfig } from "pg-sourcerer/testing"
|
|
10
|
+
*
|
|
11
|
+
* it.effect("generates types", () =>
|
|
12
|
+
* Effect.gen(function* () {
|
|
13
|
+
* const result = yield* testPlugin(myPlugin, {
|
|
14
|
+
* ir: testIR({ entities: [...] }),
|
|
15
|
+
* })
|
|
16
|
+
* expect(result.declarations).toHaveLength(1)
|
|
17
|
+
* })
|
|
18
|
+
* )
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ## IR Building
|
|
22
|
+
*
|
|
23
|
+
* Use testIRWithEntities with real entities from ir-builder, or create
|
|
24
|
+
* minimal stubs for unit tests that don't need full introspection data.
|
|
5
25
|
*/
|
|
6
|
-
import {
|
|
26
|
+
import { Effect } from "effect";
|
|
27
|
+
import { runPlugins, } from "./runtime/orchestrator.js";
|
|
28
|
+
import { emitFiles } from "./runtime/emit.js";
|
|
29
|
+
import { defaultInflection } from "./services/inflection.js";
|
|
30
|
+
import { emptyTypeHintRegistry } from "./services/type-hints.js";
|
|
31
|
+
import { createIRBuilderService } from "./services/ir-builder.js";
|
|
7
32
|
import { InflectionLive } from "./services/inflection.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
// =============================================================================
|
|
34
|
+
// Test IR Builders
|
|
35
|
+
// =============================================================================
|
|
36
|
+
/**
|
|
37
|
+
* Create a minimal SemanticIR for testing.
|
|
38
|
+
*
|
|
39
|
+
* Most tests just need an empty or partial IR. For tests that don't need
|
|
40
|
+
* real entity structures, use actual IRBuilder or provide entities directly.
|
|
41
|
+
*/
|
|
42
|
+
export function testIR(overrides) {
|
|
43
|
+
return {
|
|
44
|
+
schemas: ["public"],
|
|
45
|
+
entities: new Map(),
|
|
46
|
+
artifacts: new Map(),
|
|
47
|
+
extensions: [],
|
|
48
|
+
introspectedAt: new Date(),
|
|
49
|
+
...overrides,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Create a SemanticIR with entities from a map or array.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* // From array (uses entity.name as key)
|
|
58
|
+
* const ir = testIRWithEntities([userEntity, postEntity])
|
|
59
|
+
*
|
|
60
|
+
* // From map
|
|
61
|
+
* const ir = testIRWithEntities(new Map([["User", userEntity]]))
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export function testIRWithEntities(entities) {
|
|
65
|
+
const entityMap = Array.isArray(entities) ? new Map(entities.map(e => [e.name, e])) : entities;
|
|
66
|
+
return testIR({ entities: entityMap });
|
|
67
|
+
}
|
|
14
68
|
/**
|
|
15
|
-
*
|
|
69
|
+
* Load introspection fixture and build IR from it.
|
|
16
70
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
71
|
+
* Returns an Effect that loads the pre-captured introspection data
|
|
72
|
+
* and builds IR using the real IR builder service.
|
|
19
73
|
*
|
|
20
|
-
*
|
|
74
|
+
* @example
|
|
21
75
|
* ```typescript
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
76
|
+
* it.effect("uses fixture data", () =>
|
|
77
|
+
* Effect.gen(function* () {
|
|
78
|
+
* const ir = yield* testIRFromFixture(["app_public"]);
|
|
79
|
+
* const userEntity = ir.entities.get("User");
|
|
80
|
+
* expect(userEntity).toBeDefined();
|
|
81
|
+
* })
|
|
26
82
|
* )
|
|
27
83
|
* ```
|
|
28
84
|
*/
|
|
29
|
-
export
|
|
85
|
+
export function testIRFromFixture(schemas = ["app_public"]) {
|
|
86
|
+
const builder = createIRBuilderService();
|
|
87
|
+
return Effect.gen(function* () {
|
|
88
|
+
const { loadIntrospectionFixture } = yield* Effect.promise(() => import("./__tests__/fixtures/index.js").then(m => ({ loadIntrospectionFixture: m.loadIntrospectionFixture })));
|
|
89
|
+
const introspection = loadIntrospectionFixture();
|
|
90
|
+
return yield* builder.build(introspection, { schemas });
|
|
91
|
+
}).pipe(Effect.provide(InflectionLive));
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Create an OrchestratorConfig for testing.
|
|
95
|
+
*/
|
|
96
|
+
export function testConfig(options = {}) {
|
|
97
|
+
return {
|
|
98
|
+
plugins: [],
|
|
99
|
+
ir: options.ir ?? testIR(),
|
|
100
|
+
inflection: options.inflection ?? defaultInflection,
|
|
101
|
+
typeHints: options.typeHints ?? emptyTypeHintRegistry,
|
|
102
|
+
defaultFile: options.defaultFile ?? "index.ts",
|
|
103
|
+
outputDir: options.outputDir ?? "src/generated",
|
|
104
|
+
};
|
|
105
|
+
}
|
|
30
106
|
/**
|
|
31
|
-
*
|
|
107
|
+
* Run a single plugin through the orchestrator and return results.
|
|
32
108
|
*
|
|
33
|
-
*
|
|
34
|
-
* @param pluginName - The plugin name for PluginMeta
|
|
35
|
-
* @returns Layer with all services for plugin testing
|
|
109
|
+
* Useful for unit testing plugins in isolation.
|
|
36
110
|
*
|
|
37
|
-
*
|
|
111
|
+
* @example
|
|
38
112
|
* ```typescript
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
113
|
+
* it.effect("declares User type", () =>
|
|
114
|
+
* Effect.gen(function* () {
|
|
115
|
+
* const result = yield* testPlugin(typesPlugin)
|
|
116
|
+
* expect(result.declarations).toContainEqual(
|
|
117
|
+
* expect.objectContaining({ name: "User" })
|
|
118
|
+
* )
|
|
119
|
+
* })
|
|
120
|
+
* )
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export function testPlugin(plugin, options = {}) {
|
|
124
|
+
const config = testConfig({
|
|
125
|
+
ir: options.ir,
|
|
126
|
+
inflection: options.inflection,
|
|
127
|
+
typeHints: options.typeHints,
|
|
128
|
+
defaultFile: options.defaultFile,
|
|
129
|
+
outputDir: options.outputDir,
|
|
130
|
+
});
|
|
131
|
+
const allPlugins = [...(options.dependencies ?? []), plugin];
|
|
132
|
+
return runPlugins({ ...config, plugins: allPlugins });
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Run a plugin and emit files, returning both orchestration and emit results.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* it.effect("generates valid TypeScript", () =>
|
|
140
|
+
* Effect.gen(function* () {
|
|
141
|
+
* const { files } = yield* testPluginEmit(typesPlugin, {
|
|
142
|
+
* ir: testIRWithEntities([...]),
|
|
48
143
|
* })
|
|
49
|
-
*
|
|
50
|
-
*
|
|
144
|
+
* expect(files[0].content).toContain("export type User")
|
|
145
|
+
* })
|
|
146
|
+
* )
|
|
51
147
|
* ```
|
|
52
148
|
*/
|
|
53
|
-
export function
|
|
54
|
-
return
|
|
149
|
+
export function testPluginEmit(plugin, options = {}) {
|
|
150
|
+
return testPlugin(plugin, options).pipe(Effect.map(result => ({
|
|
151
|
+
result,
|
|
152
|
+
files: emitFiles(result),
|
|
153
|
+
})));
|
|
55
154
|
}
|
|
56
|
-
// Re-export commonly needed items for tests
|
|
57
|
-
export { IR } from "./services/ir.js";
|
|
58
|
-
export { PluginMeta } from "./services/plugin-meta.js";
|
|
59
|
-
export { Emissions } from "./services/emissions.js";
|
|
60
|
-
export { Symbols } from "./services/symbols.js";
|
|
61
|
-
export { runPlugins } from "./services/plugin-runner.js";
|
|
62
|
-
export { createIRBuilder, freezeIR } from "./ir/semantic-ir.js";
|
|
63
155
|
//# sourceMappingURL=testing.js.map
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"testing.js","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EACL,UAAU,GAGX,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,SAAS,EAAoB,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,iBAAiB,EAAuB,MAAM,0BAA0B,CAAC;AAClF,OAAO,EAAE,qBAAqB,EAAyB,MAAM,0BAA0B,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE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M;QACN,KAAK,EAAE,SAAS,CAAC,MAAM,CAAC;KACzB,CAAC,CAAC,CACJ,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User Module Reference
|
|
3
|
+
*
|
|
4
|
+
* Provides a structured way to import user-defined modules in generated code.
|
|
5
|
+
* Paths are relative to the config file, and the system computes correct
|
|
6
|
+
* relative imports for each output file at emit time.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Reference to a user-defined module for import in generated code.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* // In pgsourcerer.config.ts
|
|
14
|
+
* import { userModule } from "pg-sourcerer";
|
|
15
|
+
*
|
|
16
|
+
* kysely({
|
|
17
|
+
* dbImport: userModule("./db.ts", { named: ["db"] }),
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export interface UserModuleRef {
|
|
22
|
+
readonly _tag: "UserModuleRef";
|
|
23
|
+
/** Path to the module, relative to the config file */
|
|
24
|
+
readonly path: string;
|
|
25
|
+
/** Named exports to import: import { foo, bar } from "..." */
|
|
26
|
+
readonly named?: readonly string[];
|
|
27
|
+
/** Default import binding: import db from "..." */
|
|
28
|
+
readonly default?: string;
|
|
29
|
+
/** Namespace import binding: import * as Db from "..." */
|
|
30
|
+
readonly namespace?: string;
|
|
31
|
+
/**
|
|
32
|
+
* Whether to validate that the requested exports exist in the module.
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
readonly validate?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Options for creating a user module reference.
|
|
39
|
+
*/
|
|
40
|
+
export interface UserModuleOptions {
|
|
41
|
+
/** Named exports to import: import { foo, bar } from "..." */
|
|
42
|
+
readonly named?: readonly string[];
|
|
43
|
+
/** Default import binding: import db from "..." */
|
|
44
|
+
readonly default?: string;
|
|
45
|
+
/** Namespace import binding: import * as Db from "..." */
|
|
46
|
+
readonly namespace?: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to validate that the requested exports exist in the module.
|
|
49
|
+
* @default true
|
|
50
|
+
*/
|
|
51
|
+
readonly validate?: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Create a reference to a user module for import in generated code.
|
|
55
|
+
*
|
|
56
|
+
* The path is relative to the config file location. At emit time, the system
|
|
57
|
+
* computes the correct relative import path for each generated file.
|
|
58
|
+
*
|
|
59
|
+
* @param path - Path to the module, relative to the config file
|
|
60
|
+
* @param options - Import options (what to import from the module)
|
|
61
|
+
* @returns A UserModuleRef that can be passed to plugin config
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* // Named imports
|
|
66
|
+
* userModule("./db.ts", { named: ["db", "Kysely"] })
|
|
67
|
+
* // Generates: import { db, Kysely } from "../db.js"
|
|
68
|
+
*
|
|
69
|
+
* // Default import
|
|
70
|
+
* userModule("./db.ts", { default: "db" })
|
|
71
|
+
* // Generates: import db from "../db.js"
|
|
72
|
+
*
|
|
73
|
+
* // Namespace import
|
|
74
|
+
* userModule("./db.ts", { namespace: "Db" })
|
|
75
|
+
* // Generates: import * as Db from "../db.js"
|
|
76
|
+
*
|
|
77
|
+
* // Skip validation (not recommended)
|
|
78
|
+
* userModule("./db.ts", { named: ["db"], validate: false })
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
export declare function userModule(path: string, options: UserModuleOptions): UserModuleRef;
|
|
82
|
+
/**
|
|
83
|
+
* Type guard to check if a value is a UserModuleRef.
|
|
84
|
+
*/
|
|
85
|
+
export declare function isUserModuleRef(value: unknown): value is UserModuleRef;
|
|
86
|
+
//# sourceMappingURL=user-module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-module.d.ts","sourceRoot":"","sources":["../src/user-module.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,eAAe,CAAC;IAC/B,sDAAsD;IACtD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,8DAA8D;IAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,mDAAmD;IACnD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,0DAA0D;IAC1D,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAC5B;;;OAGG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,GAAG,aAAa,CASlF;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,aAAa,CAOtE"}
|