@xylex-group/athena 1.9.0 → 2.0.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/package.json CHANGED
@@ -79,6 +79,19 @@
79
79
  "type": "git",
80
80
  "url": "git+https://github.com/xylex-group/athena-js.git"
81
81
  },
82
+ "type": "module",
83
+ "types": "./dist/index.d.ts",
84
+ "typesVersions": {
85
+ "*": {
86
+ "*": [
87
+ "dist/index.d.ts"
88
+ ],
89
+ "react": [
90
+ "dist/react.d.ts"
91
+ ]
92
+ }
93
+ },
94
+ "version": "2.0.0",
82
95
  "scripts": {
83
96
  "build": "tsup",
84
97
  "check:all": "pnpm lint && pnpm typecheck && pnpm test && pnpm build",
@@ -92,24 +105,10 @@
92
105
  "example:retry-patterns": "cd examples/retry-patterns && bun run start",
93
106
  "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
94
107
  "lint:fix": "pnpm lint -- --fix",
95
- "prepublishOnly": "pnpm typecheck && pnpm build",
96
108
  "publish:token": "node scripts/publish.js",
97
- "test": "node --import tsx --test test/*.test.ts",
109
+ "test": "node --preserve-symlinks --import tsx --test --test-force-exit test/*.test.ts",
98
110
  "test:integration:postgres": "node scripts/run-postgres-introspection-test.mjs",
99
- "test:watch": "node --import tsx --test --watch test/*.test.ts",
111
+ "test:watch": "node --preserve-symlinks --import tsx --test --watch test/*.test.ts",
100
112
  "typecheck": "tsc -p tsconfig.typecheck.json"
101
- },
102
- "type": "module",
103
- "types": "./dist/index.d.ts",
104
- "typesVersions": {
105
- "*": {
106
- "*": [
107
- "dist/index.d.ts"
108
- ],
109
- "react": [
110
- "dist/react.d.ts"
111
- ]
112
- }
113
- },
114
- "version": "1.9.0"
113
+ }
115
114
  }
@@ -1,92 +0,0 @@
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 };
@@ -1,92 +0,0 @@
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 };