fraiseql 2.2.1 → 2.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.
package/dist/index.d.mts CHANGED
@@ -855,14 +855,8 @@ declare function Type(_config?: TypeConfig): <T extends {
855
855
  /**
856
856
  * Configuration for Query and Mutation decorators.
857
857
  */
858
- interface SqlSourceDispatchConfig {
859
- argument: string;
860
- mapping?: Record<string, string>;
861
- template?: string;
862
- }
863
858
  interface OperationConfig {
864
859
  sqlSource?: string;
865
- sqlSourceDispatch?: SqlSourceDispatchConfig;
866
860
  autoParams?: Record<string, boolean>;
867
861
  operation?: string;
868
862
  jsonbColumn?: string;
@@ -912,6 +906,42 @@ declare function Query(config?: OperationConfig): (_target: any, propertyKey: st
912
906
  */
913
907
  interface MutationConfig extends OperationConfig {
914
908
  operation?: "CREATE" | "UPDATE" | "DELETE" | "CUSTOM";
909
+ /**
910
+ * Whether a successful run of this mutation writes a Change-Spine change-log row.
911
+ *
912
+ * Defaults to `true`. Set `changelog: false` to opt this single mutation out of the
913
+ * in-transaction change-log outbox while the rest of the schema keeps logging.
914
+ * Omitting it leaves the key out of the JSON, and the compiler defaults it to `true`
915
+ * (a row is written only when the global `[changelog]` switch and this per-mutation
916
+ * flag are both on).
917
+ */
918
+ changelog?: boolean;
919
+ /**
920
+ * Whether a successful, state-changing run of this mutation also records the
921
+ * changed entity's pre-image (before-state) into the Change-Spine
922
+ * `object_data_before` column, alongside the after-state in `object_data` —
923
+ * sourced from an optional `entity_before` on the mutation's
924
+ * `app.mutation_response`.
925
+ *
926
+ * Defaults to `false`. Set `changelogPreImage: true` for audit-sensitive
927
+ * mutations that need an inline Debezium-style `{before, after}` on the single
928
+ * change event. Omitting it leaves the key out of the JSON, and the compiler
929
+ * defaults it to `false` (after-image only, today's behavior).
930
+ */
931
+ changelogPreImage?: boolean;
932
+ /**
933
+ * How the GraphQL `input` argument is passed to the SQL function:
934
+ * `"flatten"` (positional columns, the default) or `"jsonb"` (the whole input
935
+ * as one `jsonb` argument).
936
+ *
937
+ * Orthogonal to `operation`: set `inputStyle: "jsonb"` so a backend using the
938
+ * single-`jsonb`-wrapper convention (`fn(input_payload jsonb, …)`) can register
939
+ * the real DML verb (`CREATE`/`DELETE`/`CUSTOM`) instead of being forced to
940
+ * `UPDATE` purely to opt into single-JSONB input passing — the Change Spine then
941
+ * records the true `modification_type`. Omitting it leaves the key out of the
942
+ * JSON, and the compiler defaults it to `"flatten"`.
943
+ */
944
+ inputStyle?: "flatten" | "jsonb";
915
945
  }
916
946
  /**
917
947
  * Decorator to mark a function as a GraphQL mutation.
@@ -1114,46 +1144,34 @@ declare function registerTypeFields(typeName: string, fields: Field[], descripti
1114
1144
  crud?: boolean | string[];
1115
1145
  cascade?: boolean;
1116
1146
  }): void;
1117
- /**
1118
- * Config object form for registerQuery.
1119
- */
1120
- interface RegisterQueryConfig {
1121
- returnType: string;
1122
- returnsList?: boolean;
1123
- nullable?: boolean;
1124
- arguments?: ArgumentDefinition[];
1125
- description?: string;
1126
- sqlSource?: string;
1127
- sqlSourceDispatch?: {
1128
- argument: string;
1129
- mapping?: Record<string, string>;
1130
- template?: string;
1131
- };
1132
- [key: string]: unknown;
1133
- }
1134
1147
  /**
1135
1148
  * Helper function to manually register query with full metadata.
1136
1149
  *
1137
- * Accepts either the classic positional style:
1138
- * registerQuery(name, returnType, returnsList, nullable, args, description?, config?)
1139
- *
1140
- * Or a compact object style:
1141
- * registerQuery(name, { returnType, returnsList?, nullable?, arguments?, sqlSourceDispatch?, ... })
1150
+ * @param name - Query name
1151
+ * @param returnType - Return type name
1152
+ * @param returnsList - Whether query returns a list
1153
+ * @param nullable - Whether result can be null
1154
+ * @param args - Argument definitions
1155
+ * @param description - Optional query description
1156
+ * @param config - Additional configuration
1142
1157
  *
1143
1158
  * @example
1144
1159
  * ```ts
1145
- * registerQuery("orders", {
1146
- * returnType: "Order",
1147
- * returnsList: true,
1148
- * sqlSourceDispatch: {
1149
- * argument: "interval",
1150
- * mapping: { DAY: "tf_orders_day", WEEK: "tf_orders_week" },
1151
- * },
1152
- * arguments: [{ name: "interval", type: "TimeInterval", nullable: false }],
1153
- * });
1160
+ * registerQuery(
1161
+ * "users",
1162
+ * "User",
1163
+ * true,
1164
+ * false,
1165
+ * [
1166
+ * { name: "limit", type: "Int", nullable: false, default: 10 },
1167
+ * { name: "offset", type: "Int", nullable: false, default: 0 }
1168
+ * ],
1169
+ * "Get list of users",
1170
+ * { sql_source: "v_user" }
1171
+ * );
1154
1172
  * ```
1155
1173
  */
1156
- declare function registerQuery(name: string, returnTypeOrConfig: string | RegisterQueryConfig, returnsList?: boolean, nullable?: boolean, args?: ArgumentDefinition[], description?: string, config?: Record<string, unknown>): void;
1174
+ declare function registerQuery(name: string, returnType: string, returnsList: boolean, nullable: boolean, args: ArgumentDefinition[], description?: string, config?: Record<string, unknown>): void;
1157
1175
  /**
1158
1176
  * Helper function to manually register mutation with full metadata.
1159
1177
  *
@@ -1323,39 +1341,6 @@ declare function generateCrudOperations(typeName: string, fields: Field[], crud:
1323
1341
  * that can be consumed by the fraiseql-cli compiler.
1324
1342
  */
1325
1343
 
1326
- /**
1327
- * Configuration helper for queries and mutations.
1328
- *
1329
- * This function is called inside decorated functions to specify SQL mapping
1330
- * and other configuration. The config is stored temporarily and applied by
1331
- * the decorator.
1332
- *
1333
- * @param config - Configuration options:
1334
- * - sqlSource: SQL view name (queries) or function name (mutations)
1335
- * - operation: Mutation operation type (CREATE, UPDATE, DELETE, CUSTOM)
1336
- * - autoParams: Auto-parameter configuration (limit, offset, where, order_by)
1337
- * - jsonbColumn: JSONB column name for flexible schemas
1338
- *
1339
- * @example
1340
- * ```ts
1341
- * @Query()
1342
- * function users(limit: number = 10) {
1343
- * return config({
1344
- * sqlSource: "v_user",
1345
- * autoParams: { limit: true, offset: true, where: true }
1346
- * });
1347
- * }
1348
- *
1349
- * @Mutation()
1350
- * function createUser(name: string, email: string) {
1351
- * return config({
1352
- * sqlSource: "fn_create_user",
1353
- * operation: "CREATE"
1354
- * });
1355
- * }
1356
- * ```
1357
- */
1358
- declare function config(configObj: Record<string, unknown>): void;
1359
1344
  /**
1360
1345
  * Export the schema registry to a JSON file.
1361
1346
  *
@@ -1702,6 +1687,6 @@ declare class FraiseQLClient {
1702
1687
  *
1703
1688
  * @packageDocumentation
1704
1689
  */
1705
- declare const version = "2.0.0-alpha.1";
1690
+ declare const version = "2.9.0";
1706
1691
 
1707
- export { type APIKey, type AirportCode, type ArgumentDefinition, type ArgumentInfo, AuthenticationError, type CIDR, type CUSIP, type Color, type ContainerNumber, type Coordinates, type CountryCode, type CurrencyCode, CustomScalar, DEFAULT_RETRY_CONFIG, type Date, type DateRange, type DateTime, type Decimal, type DomainName, type Duration, type Email, type EnumConfig, type EnumDefinition, type EnumValue, type ExchangeCode, type ExchangeRate, type Field, type FieldInfo, type FieldMetadata, type File, type FlightNumber, FraiseQLClient, type FraiseQLClientConfig, FraiseQLError, type FunctionSignature, GraphQLError, type GraphQLErrorEntry, type HTML, type HashSHA256, type Hostname, type HttpRetryConfig, type IBAN, type ID, type IPAddress, type IPv4, type IPv6, type ISIN, type Image, type InputConfig, type InputTypeDefinition, type InterfaceConfig, type InterfaceDefinition, type Json, type LEI, type LTree, type LanguageCode, type Latitude, type LicensePlate, type LocaleCode, type Longitude, type MACAddress, type MIC, type Markdown, type MimeType, type Money, Mutation, type MutationConfig, type MutationDefinition, NetworkError, Observer, type OperationConfig, type Percentage, type PhoneNumber, type Port, type PortCode, type PostalCode, Query, type QueryDefinition, RateLimitError, type RetryConfig, type ReturnTypeInfo, SCALAR_NAMES, type SEDOL, Scalar, ScalarValidationError, type Schema, SchemaRegistry, type SemanticVersion, type Slug, type StockSymbol, Subscription, type SubscriptionConfig, type SubscriptionDefinition, type Time, TimeoutError, type Timezone, type TrackingNumber, Type, type TypeConfig, type TypeDefinition, type URL, type UUID, type UnionConfig, type UnionDefinition, type VIN, type Vector, config, email, enum_, executeWithRetry, exportSchema, exportSchemaToString, exportTypes, extractFieldInfo, extractFunctionSignature, field, generateCrudOperations, getAllCustomScalars, getSchemaDict, input, interface_, isScalarType, registerMutation, registerQuery, registerSubscription, registerTypeFields, slack, typeToGraphQL, union, validateCustomScalar, version, webhook };
1692
+ export { type APIKey, type AirportCode, type ArgumentDefinition, type ArgumentInfo, AuthenticationError, type CIDR, type CUSIP, type Color, type ContainerNumber, type Coordinates, type CountryCode, type CurrencyCode, CustomScalar, DEFAULT_RETRY_CONFIG, type Date, type DateRange, type DateTime, type Decimal, type DomainName, type Duration, type Email, type EnumConfig, type EnumDefinition, type EnumValue, type ExchangeCode, type ExchangeRate, type Field, type FieldInfo, type FieldMetadata, type File, type FlightNumber, FraiseQLClient, type FraiseQLClientConfig, FraiseQLError, type FunctionSignature, GraphQLError, type GraphQLErrorEntry, type HTML, type HashSHA256, type Hostname, type HttpRetryConfig, type IBAN, type ID, type IPAddress, type IPv4, type IPv6, type ISIN, type Image, type InputConfig, type InputTypeDefinition, type InterfaceConfig, type InterfaceDefinition, type Json, type LEI, type LTree, type LanguageCode, type Latitude, type LicensePlate, type LocaleCode, type Longitude, type MACAddress, type MIC, type Markdown, type MimeType, type Money, Mutation, type MutationConfig, type MutationDefinition, NetworkError, Observer, type OperationConfig, type Percentage, type PhoneNumber, type Port, type PortCode, type PostalCode, Query, type QueryDefinition, RateLimitError, type RetryConfig, type ReturnTypeInfo, SCALAR_NAMES, type SEDOL, Scalar, ScalarValidationError, type Schema, SchemaRegistry, type SemanticVersion, type Slug, type StockSymbol, Subscription, type SubscriptionConfig, type SubscriptionDefinition, type Time, TimeoutError, type Timezone, type TrackingNumber, Type, type TypeConfig, type TypeDefinition, type URL, type UUID, type UnionConfig, type UnionDefinition, type VIN, type Vector, email, enum_, executeWithRetry, exportSchema, exportSchemaToString, exportTypes, extractFieldInfo, extractFunctionSignature, field, generateCrudOperations, getAllCustomScalars, getSchemaDict, input, interface_, isScalarType, registerMutation, registerQuery, registerSubscription, registerTypeFields, slack, typeToGraphQL, union, validateCustomScalar, version, webhook };
package/dist/index.d.ts CHANGED
@@ -855,14 +855,8 @@ declare function Type(_config?: TypeConfig): <T extends {
855
855
  /**
856
856
  * Configuration for Query and Mutation decorators.
857
857
  */
858
- interface SqlSourceDispatchConfig {
859
- argument: string;
860
- mapping?: Record<string, string>;
861
- template?: string;
862
- }
863
858
  interface OperationConfig {
864
859
  sqlSource?: string;
865
- sqlSourceDispatch?: SqlSourceDispatchConfig;
866
860
  autoParams?: Record<string, boolean>;
867
861
  operation?: string;
868
862
  jsonbColumn?: string;
@@ -912,6 +906,42 @@ declare function Query(config?: OperationConfig): (_target: any, propertyKey: st
912
906
  */
913
907
  interface MutationConfig extends OperationConfig {
914
908
  operation?: "CREATE" | "UPDATE" | "DELETE" | "CUSTOM";
909
+ /**
910
+ * Whether a successful run of this mutation writes a Change-Spine change-log row.
911
+ *
912
+ * Defaults to `true`. Set `changelog: false` to opt this single mutation out of the
913
+ * in-transaction change-log outbox while the rest of the schema keeps logging.
914
+ * Omitting it leaves the key out of the JSON, and the compiler defaults it to `true`
915
+ * (a row is written only when the global `[changelog]` switch and this per-mutation
916
+ * flag are both on).
917
+ */
918
+ changelog?: boolean;
919
+ /**
920
+ * Whether a successful, state-changing run of this mutation also records the
921
+ * changed entity's pre-image (before-state) into the Change-Spine
922
+ * `object_data_before` column, alongside the after-state in `object_data` —
923
+ * sourced from an optional `entity_before` on the mutation's
924
+ * `app.mutation_response`.
925
+ *
926
+ * Defaults to `false`. Set `changelogPreImage: true` for audit-sensitive
927
+ * mutations that need an inline Debezium-style `{before, after}` on the single
928
+ * change event. Omitting it leaves the key out of the JSON, and the compiler
929
+ * defaults it to `false` (after-image only, today's behavior).
930
+ */
931
+ changelogPreImage?: boolean;
932
+ /**
933
+ * How the GraphQL `input` argument is passed to the SQL function:
934
+ * `"flatten"` (positional columns, the default) or `"jsonb"` (the whole input
935
+ * as one `jsonb` argument).
936
+ *
937
+ * Orthogonal to `operation`: set `inputStyle: "jsonb"` so a backend using the
938
+ * single-`jsonb`-wrapper convention (`fn(input_payload jsonb, …)`) can register
939
+ * the real DML verb (`CREATE`/`DELETE`/`CUSTOM`) instead of being forced to
940
+ * `UPDATE` purely to opt into single-JSONB input passing — the Change Spine then
941
+ * records the true `modification_type`. Omitting it leaves the key out of the
942
+ * JSON, and the compiler defaults it to `"flatten"`.
943
+ */
944
+ inputStyle?: "flatten" | "jsonb";
915
945
  }
916
946
  /**
917
947
  * Decorator to mark a function as a GraphQL mutation.
@@ -1114,46 +1144,34 @@ declare function registerTypeFields(typeName: string, fields: Field[], descripti
1114
1144
  crud?: boolean | string[];
1115
1145
  cascade?: boolean;
1116
1146
  }): void;
1117
- /**
1118
- * Config object form for registerQuery.
1119
- */
1120
- interface RegisterQueryConfig {
1121
- returnType: string;
1122
- returnsList?: boolean;
1123
- nullable?: boolean;
1124
- arguments?: ArgumentDefinition[];
1125
- description?: string;
1126
- sqlSource?: string;
1127
- sqlSourceDispatch?: {
1128
- argument: string;
1129
- mapping?: Record<string, string>;
1130
- template?: string;
1131
- };
1132
- [key: string]: unknown;
1133
- }
1134
1147
  /**
1135
1148
  * Helper function to manually register query with full metadata.
1136
1149
  *
1137
- * Accepts either the classic positional style:
1138
- * registerQuery(name, returnType, returnsList, nullable, args, description?, config?)
1139
- *
1140
- * Or a compact object style:
1141
- * registerQuery(name, { returnType, returnsList?, nullable?, arguments?, sqlSourceDispatch?, ... })
1150
+ * @param name - Query name
1151
+ * @param returnType - Return type name
1152
+ * @param returnsList - Whether query returns a list
1153
+ * @param nullable - Whether result can be null
1154
+ * @param args - Argument definitions
1155
+ * @param description - Optional query description
1156
+ * @param config - Additional configuration
1142
1157
  *
1143
1158
  * @example
1144
1159
  * ```ts
1145
- * registerQuery("orders", {
1146
- * returnType: "Order",
1147
- * returnsList: true,
1148
- * sqlSourceDispatch: {
1149
- * argument: "interval",
1150
- * mapping: { DAY: "tf_orders_day", WEEK: "tf_orders_week" },
1151
- * },
1152
- * arguments: [{ name: "interval", type: "TimeInterval", nullable: false }],
1153
- * });
1160
+ * registerQuery(
1161
+ * "users",
1162
+ * "User",
1163
+ * true,
1164
+ * false,
1165
+ * [
1166
+ * { name: "limit", type: "Int", nullable: false, default: 10 },
1167
+ * { name: "offset", type: "Int", nullable: false, default: 0 }
1168
+ * ],
1169
+ * "Get list of users",
1170
+ * { sql_source: "v_user" }
1171
+ * );
1154
1172
  * ```
1155
1173
  */
1156
- declare function registerQuery(name: string, returnTypeOrConfig: string | RegisterQueryConfig, returnsList?: boolean, nullable?: boolean, args?: ArgumentDefinition[], description?: string, config?: Record<string, unknown>): void;
1174
+ declare function registerQuery(name: string, returnType: string, returnsList: boolean, nullable: boolean, args: ArgumentDefinition[], description?: string, config?: Record<string, unknown>): void;
1157
1175
  /**
1158
1176
  * Helper function to manually register mutation with full metadata.
1159
1177
  *
@@ -1323,39 +1341,6 @@ declare function generateCrudOperations(typeName: string, fields: Field[], crud:
1323
1341
  * that can be consumed by the fraiseql-cli compiler.
1324
1342
  */
1325
1343
 
1326
- /**
1327
- * Configuration helper for queries and mutations.
1328
- *
1329
- * This function is called inside decorated functions to specify SQL mapping
1330
- * and other configuration. The config is stored temporarily and applied by
1331
- * the decorator.
1332
- *
1333
- * @param config - Configuration options:
1334
- * - sqlSource: SQL view name (queries) or function name (mutations)
1335
- * - operation: Mutation operation type (CREATE, UPDATE, DELETE, CUSTOM)
1336
- * - autoParams: Auto-parameter configuration (limit, offset, where, order_by)
1337
- * - jsonbColumn: JSONB column name for flexible schemas
1338
- *
1339
- * @example
1340
- * ```ts
1341
- * @Query()
1342
- * function users(limit: number = 10) {
1343
- * return config({
1344
- * sqlSource: "v_user",
1345
- * autoParams: { limit: true, offset: true, where: true }
1346
- * });
1347
- * }
1348
- *
1349
- * @Mutation()
1350
- * function createUser(name: string, email: string) {
1351
- * return config({
1352
- * sqlSource: "fn_create_user",
1353
- * operation: "CREATE"
1354
- * });
1355
- * }
1356
- * ```
1357
- */
1358
- declare function config(configObj: Record<string, unknown>): void;
1359
1344
  /**
1360
1345
  * Export the schema registry to a JSON file.
1361
1346
  *
@@ -1702,6 +1687,6 @@ declare class FraiseQLClient {
1702
1687
  *
1703
1688
  * @packageDocumentation
1704
1689
  */
1705
- declare const version = "2.0.0-alpha.1";
1690
+ declare const version = "2.9.0";
1706
1691
 
1707
- export { type APIKey, type AirportCode, type ArgumentDefinition, type ArgumentInfo, AuthenticationError, type CIDR, type CUSIP, type Color, type ContainerNumber, type Coordinates, type CountryCode, type CurrencyCode, CustomScalar, DEFAULT_RETRY_CONFIG, type Date, type DateRange, type DateTime, type Decimal, type DomainName, type Duration, type Email, type EnumConfig, type EnumDefinition, type EnumValue, type ExchangeCode, type ExchangeRate, type Field, type FieldInfo, type FieldMetadata, type File, type FlightNumber, FraiseQLClient, type FraiseQLClientConfig, FraiseQLError, type FunctionSignature, GraphQLError, type GraphQLErrorEntry, type HTML, type HashSHA256, type Hostname, type HttpRetryConfig, type IBAN, type ID, type IPAddress, type IPv4, type IPv6, type ISIN, type Image, type InputConfig, type InputTypeDefinition, type InterfaceConfig, type InterfaceDefinition, type Json, type LEI, type LTree, type LanguageCode, type Latitude, type LicensePlate, type LocaleCode, type Longitude, type MACAddress, type MIC, type Markdown, type MimeType, type Money, Mutation, type MutationConfig, type MutationDefinition, NetworkError, Observer, type OperationConfig, type Percentage, type PhoneNumber, type Port, type PortCode, type PostalCode, Query, type QueryDefinition, RateLimitError, type RetryConfig, type ReturnTypeInfo, SCALAR_NAMES, type SEDOL, Scalar, ScalarValidationError, type Schema, SchemaRegistry, type SemanticVersion, type Slug, type StockSymbol, Subscription, type SubscriptionConfig, type SubscriptionDefinition, type Time, TimeoutError, type Timezone, type TrackingNumber, Type, type TypeConfig, type TypeDefinition, type URL, type UUID, type UnionConfig, type UnionDefinition, type VIN, type Vector, config, email, enum_, executeWithRetry, exportSchema, exportSchemaToString, exportTypes, extractFieldInfo, extractFunctionSignature, field, generateCrudOperations, getAllCustomScalars, getSchemaDict, input, interface_, isScalarType, registerMutation, registerQuery, registerSubscription, registerTypeFields, slack, typeToGraphQL, union, validateCustomScalar, version, webhook };
1692
+ export { type APIKey, type AirportCode, type ArgumentDefinition, type ArgumentInfo, AuthenticationError, type CIDR, type CUSIP, type Color, type ContainerNumber, type Coordinates, type CountryCode, type CurrencyCode, CustomScalar, DEFAULT_RETRY_CONFIG, type Date, type DateRange, type DateTime, type Decimal, type DomainName, type Duration, type Email, type EnumConfig, type EnumDefinition, type EnumValue, type ExchangeCode, type ExchangeRate, type Field, type FieldInfo, type FieldMetadata, type File, type FlightNumber, FraiseQLClient, type FraiseQLClientConfig, FraiseQLError, type FunctionSignature, GraphQLError, type GraphQLErrorEntry, type HTML, type HashSHA256, type Hostname, type HttpRetryConfig, type IBAN, type ID, type IPAddress, type IPv4, type IPv6, type ISIN, type Image, type InputConfig, type InputTypeDefinition, type InterfaceConfig, type InterfaceDefinition, type Json, type LEI, type LTree, type LanguageCode, type Latitude, type LicensePlate, type LocaleCode, type Longitude, type MACAddress, type MIC, type Markdown, type MimeType, type Money, Mutation, type MutationConfig, type MutationDefinition, NetworkError, Observer, type OperationConfig, type Percentage, type PhoneNumber, type Port, type PortCode, type PostalCode, Query, type QueryDefinition, RateLimitError, type RetryConfig, type ReturnTypeInfo, SCALAR_NAMES, type SEDOL, Scalar, ScalarValidationError, type Schema, SchemaRegistry, type SemanticVersion, type Slug, type StockSymbol, Subscription, type SubscriptionConfig, type SubscriptionDefinition, type Time, TimeoutError, type Timezone, type TrackingNumber, Type, type TypeConfig, type TypeDefinition, type URL, type UUID, type UnionConfig, type UnionDefinition, type VIN, type Vector, email, enum_, executeWithRetry, exportSchema, exportSchemaToString, exportTypes, extractFieldInfo, extractFunctionSignature, field, generateCrudOperations, getAllCustomScalars, getSchemaDict, input, interface_, isScalarType, registerMutation, registerQuery, registerSubscription, registerTypeFields, slack, typeToGraphQL, union, validateCustomScalar, version, webhook };