@xylex-group/athena 1.6.2 → 1.9.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.
@@ -0,0 +1,92 @@
1
+ import { r as AthenaGatewayErrorCode, X as AthenaGatewayEndpointPath, Y as AthenaGatewayMethod, g as AthenaGatewayErrorDetails, Q as AthenaGatewayResponse, j as AnyModelDef, m as RowOf, I as InsertOf, U as UpdateOf } from './types-BnzoaNRC.js';
2
+
3
+ interface AthenaGatewayErrorInput {
4
+ code: AthenaGatewayErrorCode;
5
+ message: string;
6
+ status?: number;
7
+ endpoint?: AthenaGatewayEndpointPath;
8
+ method?: AthenaGatewayMethod;
9
+ requestId?: string;
10
+ hint?: string;
11
+ cause?: string;
12
+ }
13
+ /**
14
+ * Canonical error for gateway failures.
15
+ * Holds request context and machine-readable classification.
16
+ */
17
+ declare class AthenaGatewayError extends Error {
18
+ readonly code: AthenaGatewayErrorCode;
19
+ readonly status: number;
20
+ readonly endpoint?: AthenaGatewayEndpointPath;
21
+ readonly method?: AthenaGatewayMethod;
22
+ readonly requestId?: string;
23
+ readonly hint?: string;
24
+ readonly causeDetail?: string;
25
+ constructor(input: AthenaGatewayErrorInput);
26
+ toDetails(): AthenaGatewayErrorDetails;
27
+ static fromResponse<T>(response: AthenaGatewayResponse<T>, fallback: Omit<AthenaGatewayErrorInput, 'code' | 'message' | 'status'>): AthenaGatewayError;
28
+ }
29
+ declare function isAthenaGatewayError(error: unknown): error is AthenaGatewayError;
30
+
31
+ type ModelFormNullishMode = 'empty-string' | 'undefined' | 'null';
32
+ type NullishValueByMode = {
33
+ 'empty-string': '';
34
+ undefined: undefined;
35
+ null: null;
36
+ };
37
+ type MapNullableToFormValue<TField, TMode extends ModelFormNullishMode> = null extends TField ? Exclude<TField, null> | NullishValueByMode[TMode] : TField;
38
+ /**
39
+ * Form value shape derived from a model insert payload.
40
+ * Nullable fields are remapped to the selected nullish representation.
41
+ */
42
+ type ModelFormValues<TModel extends AnyModelDef, TMode extends ModelFormNullishMode = 'empty-string'> = {
43
+ [K in keyof InsertOf<TModel>]: MapNullableToFormValue<InsertOf<TModel>[K], TMode>;
44
+ };
45
+ /**
46
+ * Default value shape for form initialization.
47
+ */
48
+ type ModelFormDefaults<TModel extends AnyModelDef, TMode extends ModelFormNullishMode = 'empty-string'> = Partial<ModelFormValues<TModel, TMode>>;
49
+ interface ToModelFormDefaultsOptions<TMode extends ModelFormNullishMode = 'empty-string'> {
50
+ /**
51
+ * Controls how nullable model values are represented in form defaults.
52
+ * - `empty-string` (default): `null -> ""`
53
+ * - `undefined`: `null -> undefined`
54
+ * - `null`: keeps `null`
55
+ */
56
+ nullishMode?: TMode;
57
+ }
58
+ interface ToModelPayloadOptions {
59
+ /**
60
+ * Converts `""` into `null` for nullable model fields.
61
+ * Defaults to `true`.
62
+ */
63
+ emptyStringAsNull?: boolean;
64
+ /**
65
+ * Omits `undefined` keys from the outgoing payload.
66
+ * Defaults to `true`.
67
+ */
68
+ stripUndefined?: boolean;
69
+ }
70
+ /**
71
+ * Normalizes model data into form-safe defaults using model nullability metadata.
72
+ */
73
+ declare function toModelFormDefaults<TModel extends AnyModelDef, TMode extends ModelFormNullishMode = 'empty-string'>(model: TModel, values?: Partial<RowOf<TModel>> | Partial<InsertOf<TModel>> | null, options?: ToModelFormDefaultsOptions<TMode>): ModelFormDefaults<TModel, TMode>;
74
+ /**
75
+ * Normalizes form values back into model-compatible insert/update payloads.
76
+ */
77
+ declare function toModelPayload<TModel extends AnyModelDef>(model: TModel, formValues: Partial<ModelFormValues<TModel, 'empty-string' | 'undefined' | 'null'>>, options?: ToModelPayloadOptions): Partial<InsertOf<TModel>>;
78
+ /**
79
+ * Runtime form adapter bound to a model contract.
80
+ */
81
+ interface ModelFormAdapter<TModel extends AnyModelDef> {
82
+ model: TModel;
83
+ toDefaults<TMode extends ModelFormNullishMode = 'empty-string'>(values?: Partial<RowOf<TModel>> | Partial<InsertOf<TModel>> | null, options?: ToModelFormDefaultsOptions<TMode>): ModelFormDefaults<TModel, TMode>;
84
+ toInsert(values: Partial<ModelFormValues<TModel, 'empty-string' | 'undefined' | 'null'>>, options?: ToModelPayloadOptions): Partial<InsertOf<TModel>>;
85
+ toUpdate(values: Partial<ModelFormValues<TModel, 'empty-string' | 'undefined' | 'null'>>, options?: ToModelPayloadOptions): Partial<UpdateOf<TModel>>;
86
+ }
87
+ /**
88
+ * Creates a small model-aware adapter for form defaults and payload normalization.
89
+ */
90
+ declare function createModelFormAdapter<TModel extends AnyModelDef>(model: TModel): ModelFormAdapter<TModel>;
91
+
92
+ export { AthenaGatewayError as A, type ModelFormAdapter as M, type ToModelFormDefaultsOptions as T, type ModelFormDefaults as a, type ModelFormNullishMode as b, type ModelFormValues as c, type ToModelPayloadOptions as d, createModelFormAdapter as e, toModelPayload as f, isAthenaGatewayError as i, toModelFormDefaults as t };
@@ -0,0 +1,92 @@
1
+ import { r as AthenaGatewayErrorCode, X as AthenaGatewayEndpointPath, Y as AthenaGatewayMethod, g as AthenaGatewayErrorDetails, Q as AthenaGatewayResponse, j as AnyModelDef, m as RowOf, I as InsertOf, U as UpdateOf } from './types-BnzoaNRC.cjs';
2
+
3
+ interface AthenaGatewayErrorInput {
4
+ code: AthenaGatewayErrorCode;
5
+ message: string;
6
+ status?: number;
7
+ endpoint?: AthenaGatewayEndpointPath;
8
+ method?: AthenaGatewayMethod;
9
+ requestId?: string;
10
+ hint?: string;
11
+ cause?: string;
12
+ }
13
+ /**
14
+ * Canonical error for gateway failures.
15
+ * Holds request context and machine-readable classification.
16
+ */
17
+ declare class AthenaGatewayError extends Error {
18
+ readonly code: AthenaGatewayErrorCode;
19
+ readonly status: number;
20
+ readonly endpoint?: AthenaGatewayEndpointPath;
21
+ readonly method?: AthenaGatewayMethod;
22
+ readonly requestId?: string;
23
+ readonly hint?: string;
24
+ readonly causeDetail?: string;
25
+ constructor(input: AthenaGatewayErrorInput);
26
+ toDetails(): AthenaGatewayErrorDetails;
27
+ static fromResponse<T>(response: AthenaGatewayResponse<T>, fallback: Omit<AthenaGatewayErrorInput, 'code' | 'message' | 'status'>): AthenaGatewayError;
28
+ }
29
+ declare function isAthenaGatewayError(error: unknown): error is AthenaGatewayError;
30
+
31
+ type ModelFormNullishMode = 'empty-string' | 'undefined' | 'null';
32
+ type NullishValueByMode = {
33
+ 'empty-string': '';
34
+ undefined: undefined;
35
+ null: null;
36
+ };
37
+ type MapNullableToFormValue<TField, TMode extends ModelFormNullishMode> = null extends TField ? Exclude<TField, null> | NullishValueByMode[TMode] : TField;
38
+ /**
39
+ * Form value shape derived from a model insert payload.
40
+ * Nullable fields are remapped to the selected nullish representation.
41
+ */
42
+ type ModelFormValues<TModel extends AnyModelDef, TMode extends ModelFormNullishMode = 'empty-string'> = {
43
+ [K in keyof InsertOf<TModel>]: MapNullableToFormValue<InsertOf<TModel>[K], TMode>;
44
+ };
45
+ /**
46
+ * Default value shape for form initialization.
47
+ */
48
+ type ModelFormDefaults<TModel extends AnyModelDef, TMode extends ModelFormNullishMode = 'empty-string'> = Partial<ModelFormValues<TModel, TMode>>;
49
+ interface ToModelFormDefaultsOptions<TMode extends ModelFormNullishMode = 'empty-string'> {
50
+ /**
51
+ * Controls how nullable model values are represented in form defaults.
52
+ * - `empty-string` (default): `null -> ""`
53
+ * - `undefined`: `null -> undefined`
54
+ * - `null`: keeps `null`
55
+ */
56
+ nullishMode?: TMode;
57
+ }
58
+ interface ToModelPayloadOptions {
59
+ /**
60
+ * Converts `""` into `null` for nullable model fields.
61
+ * Defaults to `true`.
62
+ */
63
+ emptyStringAsNull?: boolean;
64
+ /**
65
+ * Omits `undefined` keys from the outgoing payload.
66
+ * Defaults to `true`.
67
+ */
68
+ stripUndefined?: boolean;
69
+ }
70
+ /**
71
+ * Normalizes model data into form-safe defaults using model nullability metadata.
72
+ */
73
+ declare function toModelFormDefaults<TModel extends AnyModelDef, TMode extends ModelFormNullishMode = 'empty-string'>(model: TModel, values?: Partial<RowOf<TModel>> | Partial<InsertOf<TModel>> | null, options?: ToModelFormDefaultsOptions<TMode>): ModelFormDefaults<TModel, TMode>;
74
+ /**
75
+ * Normalizes form values back into model-compatible insert/update payloads.
76
+ */
77
+ declare function toModelPayload<TModel extends AnyModelDef>(model: TModel, formValues: Partial<ModelFormValues<TModel, 'empty-string' | 'undefined' | 'null'>>, options?: ToModelPayloadOptions): Partial<InsertOf<TModel>>;
78
+ /**
79
+ * Runtime form adapter bound to a model contract.
80
+ */
81
+ interface ModelFormAdapter<TModel extends AnyModelDef> {
82
+ model: TModel;
83
+ toDefaults<TMode extends ModelFormNullishMode = 'empty-string'>(values?: Partial<RowOf<TModel>> | Partial<InsertOf<TModel>> | null, options?: ToModelFormDefaultsOptions<TMode>): ModelFormDefaults<TModel, TMode>;
84
+ toInsert(values: Partial<ModelFormValues<TModel, 'empty-string' | 'undefined' | 'null'>>, options?: ToModelPayloadOptions): Partial<InsertOf<TModel>>;
85
+ toUpdate(values: Partial<ModelFormValues<TModel, 'empty-string' | 'undefined' | 'null'>>, options?: ToModelPayloadOptions): Partial<UpdateOf<TModel>>;
86
+ }
87
+ /**
88
+ * Creates a small model-aware adapter for form defaults and payload normalization.
89
+ */
90
+ declare function createModelFormAdapter<TModel extends AnyModelDef>(model: TModel): ModelFormAdapter<TModel>;
91
+
92
+ export { AthenaGatewayError as A, type ModelFormAdapter as M, type ToModelFormDefaultsOptions as T, type ModelFormDefaults as a, type ModelFormNullishMode as b, type ModelFormValues as c, type ToModelPayloadOptions as d, createModelFormAdapter as e, toModelPayload as f, isAthenaGatewayError as i, toModelFormDefaults as t };
@@ -0,0 +1,164 @@
1
+ import { a as BackendType, p as IntrospectionSnapshot, o as SchemaIntrospectionProvider } from './types-BnzoaNRC.cjs';
2
+
3
+ /**
4
+ * Supported case transformations for generated symbols and path token variants.
5
+ */
6
+ type NamingStyle = 'preserve' | 'camel' | 'pascal' | 'snake' | 'kebab';
7
+ /**
8
+ * Naming configuration for generated TypeScript identifiers.
9
+ */
10
+ interface GeneratorNamingConfig {
11
+ modelType: NamingStyle;
12
+ modelConst: NamingStyle;
13
+ schemaConst: NamingStyle;
14
+ databaseConst: NamingStyle;
15
+ registryConst: NamingStyle;
16
+ }
17
+ /**
18
+ * Stable feature flags for generator output behavior.
19
+ */
20
+ interface GeneratorFeatureFlags {
21
+ emitRelations: boolean;
22
+ emitRegistry: boolean;
23
+ }
24
+ /**
25
+ * Experimental toggles for optional/forward-compatible generator behavior.
26
+ */
27
+ interface GeneratorExperimentalFlags {
28
+ /**
29
+ * Legacy compatibility toggle from the initial scaffold.
30
+ * Gateway introspection is now implemented; this flag is retained for additive config compatibility.
31
+ */
32
+ postgresGatewayIntrospection: boolean;
33
+ /**
34
+ * Enables contract placeholders for future Scylla provider work.
35
+ */
36
+ scyllaProviderContracts: boolean;
37
+ }
38
+ /**
39
+ * Path templates for each generated artifact category.
40
+ */
41
+ interface GeneratorOutputTargets {
42
+ model: string;
43
+ schema: string;
44
+ database: string;
45
+ registry: string;
46
+ }
47
+ /**
48
+ * Output configuration including dynamic placeholder aliases.
49
+ */
50
+ interface GeneratorOutputConfig {
51
+ targets: GeneratorOutputTargets;
52
+ placeholderMap: Record<string, string>;
53
+ }
54
+ /**
55
+ * Schemas selected for PostgreSQL introspection. Strings may be comma-separated
56
+ * to support env-driven configs such as `process.env.GENERATOR_SCHEMAS`.
57
+ */
58
+ type GeneratorSchemaSelection = string | readonly string[];
59
+ /**
60
+ * Direct PostgreSQL introspection mode (implemented).
61
+ */
62
+ interface PostgresDirectProviderConfig {
63
+ kind: 'postgres';
64
+ mode: 'direct';
65
+ connectionString: string;
66
+ database?: string;
67
+ schemas?: GeneratorSchemaSelection;
68
+ }
69
+ /**
70
+ * Athena gateway-backed PostgreSQL introspection mode using `/gateway/query`.
71
+ */
72
+ interface PostgresGatewayProviderConfig {
73
+ kind: 'postgres';
74
+ mode: 'gateway';
75
+ gatewayUrl: string;
76
+ apiKey: string;
77
+ database: string;
78
+ schemas?: GeneratorSchemaSelection;
79
+ backend?: BackendType;
80
+ }
81
+ /**
82
+ * Scylla introspection provider contract placeholder (phase-two scaffold).
83
+ */
84
+ interface ScyllaDirectProviderConfig {
85
+ kind: 'scylla';
86
+ mode: 'direct';
87
+ contactPoints: string[];
88
+ keyspace: string;
89
+ datacenter?: string;
90
+ }
91
+ type GeneratorProviderConfig = PostgresDirectProviderConfig | PostgresGatewayProviderConfig | ScyllaDirectProviderConfig;
92
+ /**
93
+ * Root config contract loaded from `athena.config.ts`.
94
+ */
95
+ interface AthenaGeneratorConfig {
96
+ provider: GeneratorProviderConfig;
97
+ output: GeneratorOutputConfig;
98
+ naming?: Partial<GeneratorNamingConfig>;
99
+ features?: Partial<GeneratorFeatureFlags>;
100
+ experimental?: Partial<GeneratorExperimentalFlags>;
101
+ }
102
+ /**
103
+ * Normalized generator config with defaults applied.
104
+ */
105
+ interface NormalizedAthenaGeneratorConfig {
106
+ provider: GeneratorProviderConfig;
107
+ output: GeneratorOutputConfig;
108
+ naming: GeneratorNamingConfig;
109
+ features: GeneratorFeatureFlags;
110
+ experimental: GeneratorExperimentalFlags;
111
+ }
112
+ /**
113
+ * Config loader options for CLI/programmatic usage.
114
+ */
115
+ interface LoadGeneratorConfigOptions {
116
+ cwd?: string;
117
+ configPath?: string;
118
+ }
119
+ /**
120
+ * Fully loaded config result including resolved file path.
121
+ */
122
+ interface LoadedGeneratorConfig {
123
+ configPath: string;
124
+ config: NormalizedAthenaGeneratorConfig;
125
+ }
126
+ type GeneratorArtifactKind = 'model' | 'schema' | 'database' | 'registry';
127
+ /**
128
+ * One generated output file.
129
+ */
130
+ interface GeneratedArtifact {
131
+ kind: GeneratorArtifactKind;
132
+ path: string;
133
+ content: string;
134
+ }
135
+ /**
136
+ * In-memory generator output payload.
137
+ */
138
+ interface GeneratedArtifacts {
139
+ snapshot: IntrospectionSnapshot;
140
+ files: GeneratedArtifact[];
141
+ }
142
+ /**
143
+ * Runtime options for executing the generator pipeline.
144
+ */
145
+ interface RunGeneratorOptions {
146
+ cwd?: string;
147
+ configPath?: string;
148
+ dryRun?: boolean;
149
+ provider?: SchemaIntrospectionProvider;
150
+ }
151
+ /**
152
+ * Generator execution result including files written to disk.
153
+ */
154
+ interface RunGeneratorResult extends GeneratedArtifacts {
155
+ configPath: string;
156
+ writtenFiles: string[];
157
+ }
158
+
159
+ /**
160
+ * End-to-end generator execution: load config, introspect, render, and optionally write files.
161
+ */
162
+ declare function runSchemaGenerator(options?: RunGeneratorOptions): Promise<RunGeneratorResult>;
163
+
164
+ export { type AthenaGeneratorConfig as A, type GeneratedArtifacts as G, type LoadGeneratorConfigOptions as L, type NormalizedAthenaGeneratorConfig as N, type RunGeneratorOptions as R, type LoadedGeneratorConfig as a, type GeneratorProviderConfig as b, type GeneratorExperimentalFlags as c, type GeneratorSchemaSelection as d, type GeneratedArtifact as e, type GeneratorArtifactKind as f, type GeneratorFeatureFlags as g, type GeneratorNamingConfig as h, type GeneratorOutputConfig as i, type GeneratorOutputTargets as j, type NamingStyle as k, type RunGeneratorResult as l, runSchemaGenerator as r };
@@ -0,0 +1,164 @@
1
+ import { a as BackendType, p as IntrospectionSnapshot, o as SchemaIntrospectionProvider } from './types-BnzoaNRC.js';
2
+
3
+ /**
4
+ * Supported case transformations for generated symbols and path token variants.
5
+ */
6
+ type NamingStyle = 'preserve' | 'camel' | 'pascal' | 'snake' | 'kebab';
7
+ /**
8
+ * Naming configuration for generated TypeScript identifiers.
9
+ */
10
+ interface GeneratorNamingConfig {
11
+ modelType: NamingStyle;
12
+ modelConst: NamingStyle;
13
+ schemaConst: NamingStyle;
14
+ databaseConst: NamingStyle;
15
+ registryConst: NamingStyle;
16
+ }
17
+ /**
18
+ * Stable feature flags for generator output behavior.
19
+ */
20
+ interface GeneratorFeatureFlags {
21
+ emitRelations: boolean;
22
+ emitRegistry: boolean;
23
+ }
24
+ /**
25
+ * Experimental toggles for optional/forward-compatible generator behavior.
26
+ */
27
+ interface GeneratorExperimentalFlags {
28
+ /**
29
+ * Legacy compatibility toggle from the initial scaffold.
30
+ * Gateway introspection is now implemented; this flag is retained for additive config compatibility.
31
+ */
32
+ postgresGatewayIntrospection: boolean;
33
+ /**
34
+ * Enables contract placeholders for future Scylla provider work.
35
+ */
36
+ scyllaProviderContracts: boolean;
37
+ }
38
+ /**
39
+ * Path templates for each generated artifact category.
40
+ */
41
+ interface GeneratorOutputTargets {
42
+ model: string;
43
+ schema: string;
44
+ database: string;
45
+ registry: string;
46
+ }
47
+ /**
48
+ * Output configuration including dynamic placeholder aliases.
49
+ */
50
+ interface GeneratorOutputConfig {
51
+ targets: GeneratorOutputTargets;
52
+ placeholderMap: Record<string, string>;
53
+ }
54
+ /**
55
+ * Schemas selected for PostgreSQL introspection. Strings may be comma-separated
56
+ * to support env-driven configs such as `process.env.GENERATOR_SCHEMAS`.
57
+ */
58
+ type GeneratorSchemaSelection = string | readonly string[];
59
+ /**
60
+ * Direct PostgreSQL introspection mode (implemented).
61
+ */
62
+ interface PostgresDirectProviderConfig {
63
+ kind: 'postgres';
64
+ mode: 'direct';
65
+ connectionString: string;
66
+ database?: string;
67
+ schemas?: GeneratorSchemaSelection;
68
+ }
69
+ /**
70
+ * Athena gateway-backed PostgreSQL introspection mode using `/gateway/query`.
71
+ */
72
+ interface PostgresGatewayProviderConfig {
73
+ kind: 'postgres';
74
+ mode: 'gateway';
75
+ gatewayUrl: string;
76
+ apiKey: string;
77
+ database: string;
78
+ schemas?: GeneratorSchemaSelection;
79
+ backend?: BackendType;
80
+ }
81
+ /**
82
+ * Scylla introspection provider contract placeholder (phase-two scaffold).
83
+ */
84
+ interface ScyllaDirectProviderConfig {
85
+ kind: 'scylla';
86
+ mode: 'direct';
87
+ contactPoints: string[];
88
+ keyspace: string;
89
+ datacenter?: string;
90
+ }
91
+ type GeneratorProviderConfig = PostgresDirectProviderConfig | PostgresGatewayProviderConfig | ScyllaDirectProviderConfig;
92
+ /**
93
+ * Root config contract loaded from `athena.config.ts`.
94
+ */
95
+ interface AthenaGeneratorConfig {
96
+ provider: GeneratorProviderConfig;
97
+ output: GeneratorOutputConfig;
98
+ naming?: Partial<GeneratorNamingConfig>;
99
+ features?: Partial<GeneratorFeatureFlags>;
100
+ experimental?: Partial<GeneratorExperimentalFlags>;
101
+ }
102
+ /**
103
+ * Normalized generator config with defaults applied.
104
+ */
105
+ interface NormalizedAthenaGeneratorConfig {
106
+ provider: GeneratorProviderConfig;
107
+ output: GeneratorOutputConfig;
108
+ naming: GeneratorNamingConfig;
109
+ features: GeneratorFeatureFlags;
110
+ experimental: GeneratorExperimentalFlags;
111
+ }
112
+ /**
113
+ * Config loader options for CLI/programmatic usage.
114
+ */
115
+ interface LoadGeneratorConfigOptions {
116
+ cwd?: string;
117
+ configPath?: string;
118
+ }
119
+ /**
120
+ * Fully loaded config result including resolved file path.
121
+ */
122
+ interface LoadedGeneratorConfig {
123
+ configPath: string;
124
+ config: NormalizedAthenaGeneratorConfig;
125
+ }
126
+ type GeneratorArtifactKind = 'model' | 'schema' | 'database' | 'registry';
127
+ /**
128
+ * One generated output file.
129
+ */
130
+ interface GeneratedArtifact {
131
+ kind: GeneratorArtifactKind;
132
+ path: string;
133
+ content: string;
134
+ }
135
+ /**
136
+ * In-memory generator output payload.
137
+ */
138
+ interface GeneratedArtifacts {
139
+ snapshot: IntrospectionSnapshot;
140
+ files: GeneratedArtifact[];
141
+ }
142
+ /**
143
+ * Runtime options for executing the generator pipeline.
144
+ */
145
+ interface RunGeneratorOptions {
146
+ cwd?: string;
147
+ configPath?: string;
148
+ dryRun?: boolean;
149
+ provider?: SchemaIntrospectionProvider;
150
+ }
151
+ /**
152
+ * Generator execution result including files written to disk.
153
+ */
154
+ interface RunGeneratorResult extends GeneratedArtifacts {
155
+ configPath: string;
156
+ writtenFiles: string[];
157
+ }
158
+
159
+ /**
160
+ * End-to-end generator execution: load config, introspect, render, and optionally write files.
161
+ */
162
+ declare function runSchemaGenerator(options?: RunGeneratorOptions): Promise<RunGeneratorResult>;
163
+
164
+ export { type AthenaGeneratorConfig as A, type GeneratedArtifacts as G, type LoadGeneratorConfigOptions as L, type NormalizedAthenaGeneratorConfig as N, type RunGeneratorOptions as R, type LoadedGeneratorConfig as a, type GeneratorProviderConfig as b, type GeneratorExperimentalFlags as c, type GeneratorSchemaSelection as d, type GeneratedArtifact as e, type GeneratorArtifactKind as f, type GeneratorFeatureFlags as g, type GeneratorNamingConfig as h, type GeneratorOutputConfig as i, type GeneratorOutputTargets as j, type NamingStyle as k, type RunGeneratorResult as l, runSchemaGenerator as r };
package/dist/react.cjs CHANGED
@@ -1494,12 +1494,76 @@ function useMutation(options) {
1494
1494
  };
1495
1495
  }
1496
1496
 
1497
+ // src/schema/model-form.ts
1498
+ function resolveNullishValue(mode) {
1499
+ if (mode === "undefined") return void 0;
1500
+ if (mode === "null") return null;
1501
+ return "";
1502
+ }
1503
+ function isRecord3(value) {
1504
+ return Boolean(value) && typeof value === "object" && !Array.isArray(value);
1505
+ }
1506
+ function isNullableColumn(model, key) {
1507
+ const nullable = model.meta.nullable;
1508
+ return nullable?.[key] === true;
1509
+ }
1510
+ function toModelFormDefaults(model, values, options) {
1511
+ const source = values;
1512
+ if (!isRecord3(source)) {
1513
+ return {};
1514
+ }
1515
+ const mode = options?.nullishMode ?? "empty-string";
1516
+ const nullishValue = resolveNullishValue(mode);
1517
+ const result = {};
1518
+ for (const [key, value] of Object.entries(source)) {
1519
+ if (value === null && isNullableColumn(model, key)) {
1520
+ result[key] = nullishValue;
1521
+ continue;
1522
+ }
1523
+ result[key] = value;
1524
+ }
1525
+ return result;
1526
+ }
1527
+ function toModelPayload(model, formValues, options) {
1528
+ const emptyStringAsNull = options?.emptyStringAsNull ?? true;
1529
+ const stripUndefined = options?.stripUndefined ?? true;
1530
+ const result = {};
1531
+ for (const [key, rawValue] of Object.entries(formValues)) {
1532
+ if (rawValue === void 0 && stripUndefined) {
1533
+ continue;
1534
+ }
1535
+ if (emptyStringAsNull && rawValue === "" && isNullableColumn(model, key)) {
1536
+ result[key] = null;
1537
+ continue;
1538
+ }
1539
+ result[key] = rawValue;
1540
+ }
1541
+ return result;
1542
+ }
1543
+ function createModelFormAdapter(model) {
1544
+ return {
1545
+ model,
1546
+ toDefaults(values, options) {
1547
+ return toModelFormDefaults(model, values, options);
1548
+ },
1549
+ toInsert(values, options) {
1550
+ return toModelPayload(model, values, options);
1551
+ },
1552
+ toUpdate(values, options) {
1553
+ return toModelPayload(model, values, options);
1554
+ }
1555
+ };
1556
+ }
1557
+
1497
1558
  exports.AthenaGatewayError = AthenaGatewayError;
1498
1559
  exports.AthenaQueryClient = AthenaQueryClient;
1499
1560
  exports.AthenaQueryClientProvider = AthenaQueryClientProvider;
1500
1561
  exports.attachStateAdapter = attachStateAdapter;
1501
1562
  exports.createAthenaQueryClient = createAthenaQueryClient;
1563
+ exports.createModelFormAdapter = createModelFormAdapter;
1502
1564
  exports.isAthenaGatewayError = isAthenaGatewayError;
1565
+ exports.toModelFormDefaults = toModelFormDefaults;
1566
+ exports.toModelPayload = toModelPayload;
1503
1567
  exports.useAthenaGateway = useAthenaGateway;
1504
1568
  exports.useAthenaQueryClient = useAthenaQueryClient;
1505
1569
  exports.useMutation = useMutation;