@judo/actions 0.30.0 → 0.31.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.
@@ -1,4 +1,12 @@
1
- var ValidationError = class extends Error {
1
+ //#region \0rolldown/runtime.js
2
+ var e = Object.defineProperty, t = /* @__PURE__ */ ((t, n) => {
3
+ let r = {};
4
+ for (var i in t) e(r, i, {
5
+ get: t[i],
6
+ enumerable: !0
7
+ });
8
+ return n || e(r, Symbol.toStringTag, { value: "Module" }), r;
9
+ })({ ValidationError: () => n }), n = class extends Error {
2
10
  feedbackItems;
3
11
  status = 400;
4
12
  constructor(e) {
@@ -11,4 +19,5 @@ var ValidationError = class extends Error {
11
19
  return e;
12
20
  }
13
21
  };
14
- export { ValidationError as t };
22
+ //#endregion
23
+ export { t as n, n as t };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types-BRqo2AHD.js","names":[],"sources":["../src/api/types.ts"],"sourcesContent":["/**\n * JUDO REST API types.\n * Based on REST_REQUEST_MAPPING_SPECIFICATION.md\n */\n\n// ============================================\n// HTTP/Response Types\n// ============================================\n\n/**\n * HTTP method types used in the REST layer.\n * GET is used for template retrieval, file downloads, metadata, principal.\n * POST is used for all other operations (CRUD, list, range, operations, validation).\n */\nexport type HttpMethod = \"GET\" | \"POST\";\n\n/**\n * Response type indicating how to handle the response body.\n */\nexport type ResponseType = \"json\" | \"blob\";\n\n/**\n * How to deserialize the response.\n * - single: Deserialize as a single transfer\n * - array: Deserialize as an array of transfers\n * - void: No deserialization needed (response is empty)\n * - nullable: Deserialize as single transfer or null\n */\nexport type DeserializationType = \"single\" | \"array\" | \"void\" | \"nullable\";\n\n/**\n * Service type categories.\n */\nexport type ServiceType = \"class\" | \"relation\" | \"access\";\n\n// ============================================\n// Serialization/Deserialization\n// ============================================\n\n/**\n * Configuration for deserializing the response.\n */\nexport interface ResponseDeserializerConfig {\n\t/** Type of deserialization to apply */\n\ttype: DeserializationType;\n\t/** Target class FQName for deserialization (if applicable) */\n\ttargetClassFqName?: string;\n\t/** Whether the target is a stored (persisted) transfer */\n\tisStored: boolean;\n}\n\n/**\n * Transfer serializer interface for transforming transfers before sending.\n * The input type is unknown to support any transfer type.\n */\nexport interface TransferSerializer {\n\t/** Serialize an transfer for sending in request body */\n\tserialize(transfer: unknown): unknown;\n}\n\n/**\n * Transfer deserializer interface for transforming responses.\n * The output type is unknown to support any transfer type.\n */\nexport interface TransferDeserializer {\n\t/** Deserialize a response into an transfer */\n\tdeserialize(data: unknown): unknown;\n}\n\n// ============================================\n// Temporal Field Types\n// ============================================\n\n/**\n * Classification of temporal (date/time) field types.\n *\n * - `date`: Date-only value (`YYYY-MM-DD`) — converted to `Date` at local midnight\n * - `time`: Time-only value (`HH:mm[:ss]`) — kept as `string` (no `Date` conversion)\n * - `timestamp`: Full datetime with timezone (`YYYY-MM-DDTHH:mm:ss[.SSS]Z`) — converted to `Date`\n */\nexport type TemporalFieldType = \"date\" | \"time\" | \"timestamp\";\n\n/**\n * Registry mapping transfer type FQNs to their temporal field declarations.\n *\n * Keys match `__entityType` values from API responses (e.g., `\"Demo::OrderDTO\"`).\n * Values map field names to their temporal type for serialization/deserialization.\n *\n * @example\n * ```typescript\n * const registry: TemporalFieldRegistry = {\n * \"Demo::OrderDTO\": { orderDate: \"date\", createdAt: \"timestamp\" },\n * \"Demo::MissionDTO\": { startDate: \"date\", endDate: \"date\" },\n * };\n * ```\n */\nexport type TemporalFieldRegistry = Record<string, Record<string, TemporalFieldType>>;\n\n// ============================================\n// API Configuration\n// ============================================\n\n/**\n * Configuration for JUDO REST API client.\n */\nexport interface JudoRestApiConfig {\n\t/** Base URL for the API (e.g., http://localhost:8080) */\n\tbaseUrl: string;\n\t/** Application base path (e.g., /api) */\n\tbasePath: string;\n\t/** Application model name (e.g., edemokracia) */\n\tmodelName: string;\n\t/** Actor path (e.g., admin/Admin) */\n\tactorPath: string;\n\t/** Request timeout in milliseconds */\n\ttimeout?: number;\n\t/** Default headers to include in all requests */\n\tdefaultHeaders?: Record<string, string>;\n\t/** Optional custom fetch implementation */\n\tfetch?: typeof fetch;\n\t/** Optional request interceptor */\n\tonRequest?: (request: RequestInit) => RequestInit | Promise<RequestInit>;\n\t/** Optional response interceptor */\n\tonResponse?: (response: Response) => Response | Promise<Response>;\n\t/** Optional error handler */\n\tonError?: (error: Error) => void;\n\t/**\n\t * Optional transfer serializer for transforming transfers before sending.\n\t * If not provided, transfers are sent as-is (JSON.stringify).\n\t */\n\ttransferSerializer?: TransferSerializer;\n\t/**\n\t * Optional transfer deserializer for transforming responses.\n\t * If not provided, responses are used as-is (JSON.parse result).\n\t */\n\ttransferDeserializer?: TransferDeserializer;\n}\n\n/**\n * Query customizer for list/get operations.\n */\nexport interface QueryCustomizer {\n\t_mask?: string;\n\t_orderBy?: Array<{ attribute: string; descending?: boolean }>;\n\t_seek?: { limit?: number; lastItem?: unknown };\n\t_filter?: unknown;\n\t_identifier?: string;\n}\n\n/**\n * Base transfer data interface.\n *\n */\nexport interface TransferData {\n\t[key: string]: unknown;\n}\n\n/**\n * Strict transfer data — a TransferData whose *own* properties conform to `T`.\n *\n * Use in generated code and userland APIs where the exact field set is known.\n *\n * @typeParam T - Strict field definitions (e.g. `{ name: string; age: number }`)\n */\nexport type StrictTransferData<T extends Record<string, unknown> = Record<string, unknown>> = TransferData & T;\n\n/**\n * Stored transfer with identifiers.\n */\nexport interface TransferStored extends TransferData {\n\t__identifier?: string;\n\t__signedIdentifier?: string;\n\t__typename?: string;\n\t__entityType?: string;\n}\n\n/**\n * Strict stored transfer — a TransferStored with compile-time field types from `T`.\n *\n * @typeParam T - Strict field definitions\n */\nexport type StrictTransferStored<T extends Record<string, unknown> = Record<string, unknown>> = TransferStored & T;\n\n/**\n * Response wrapper for JUDO REST responses.\n */\nexport interface JudoRestResponse<T> {\n\tdata: T;\n\tstatus: number;\n\theaders: Headers;\n}\n\n/**\n * Path context for building REST paths.\n */\nexport interface PathContext {\n\t/** Package name tokens (e.g., [\"admin\"]) */\n\tpackageNameTokens: string[];\n\t/** Simple name (e.g., \"Issue\") */\n\tsimpleName: string;\n}\n\n/**\n * Class type metadata for path building.\n */\nexport interface ClassTypeMetadata extends PathContext {\n\t/** Fully qualified name */\n\tfqName?: string;\n\t/** Whether the class is mapped */\n\tisMapped?: boolean;\n}\n\n/**\n * Relation type metadata for path building.\n */\nexport interface RelationMetadata {\n\t/** Relation name */\n\tname: string;\n\t/** Owner class metadata */\n\towner: ClassTypeMetadata;\n\t/** Target class metadata */\n\ttarget: ClassTypeMetadata;\n\t/** Whether this is an access relation */\n\tisAccess?: boolean;\n\t/** Whether this is a collection relation */\n\tisCollection?: boolean;\n}\n\n/**\n * Operation type metadata.\n */\nexport interface OperationMetadata {\n\t/** Operation name */\n\tname: string;\n\t/** Whether the operation is static */\n\tisStatic?: boolean;\n\t/** Whether the operation is mapped */\n\tisMapped?: boolean;\n\t/** Whether the operation has input */\n\thasInput?: boolean;\n\t/** Whether the operation has output */\n\thasOutput?: boolean;\n\t/** Input type metadata */\n\tinputType?: ClassTypeMetadata;\n\t/** Output type metadata */\n\toutputType?: ClassTypeMetadata;\n}\n\n/**\n * Range request body structure.\n */\nexport interface RangeRequestBody {\n\towner?: TransferStored;\n\tqueryCustomizer?: QueryCustomizer;\n}\n\n// ============================================\n// Validation & Error Types\n// ============================================\n\n/**\n * Validation feedback item from REST API.\n * Returned in response body for 400 validation errors.\n */\nexport interface FeedbackItem {\n\t/** Error code identifier */\n\tcode: string;\n\t/** Severity level of the feedback */\n\tlevel: \"ERROR\" | \"WARNING\" | \"INFO\";\n\t/**\n\t * Location of the error - typically the attribute path.\n\t * For nested properties, format is: \"relationName.attributeName\"\n\t * For simple attributes, format is: \"attributeName\"\n\t */\n\tlocation: string;\n\t/** Human-readable error message */\n\tmessage?: string;\n}\n\n/**\n * Validation error thrown when API returns 400 status.\n * Contains array of FeedbackItem with field-level error details.\n */\nexport class ValidationError extends Error {\n\treadonly feedbackItems: FeedbackItem[];\n\treadonly status: number = 400;\n\n\tconstructor(feedbackItems: FeedbackItem[]) {\n\t\tconst firstError = feedbackItems.find((f) => f.level === \"ERROR\");\n\t\tsuper(firstError?.message ?? \"Validation failed\");\n\t\tthis.name = \"ValidationError\";\n\t\tthis.feedbackItems = feedbackItems;\n\t}\n\n\t/**\n\t * Get errors as a map of field location to error message.\n\t * Useful for setting form field errors.\n\t */\n\ttoFieldErrors(): Record<string, string> {\n\t\tconst errors: Record<string, string> = {};\n\t\tfor (const item of this.feedbackItems) {\n\t\t\tif (item.level === \"ERROR\" && item.location) {\n\t\t\t\terrors[item.location] = item.message ?? item.code;\n\t\t\t}\n\t\t}\n\t\treturn errors;\n\t}\n}\n\n// ============================================\n// Dialog Response Types\n// ============================================\n\n/**\n * Result type for dialog submission.\n * Used for create dialogs opened from eager/lazy components.\n */\nexport type DialogResult<T = TransferData> = { outcome: \"cancel\" } | { outcome: \"submit\"; data: T };\n\n/**\n * Callback for dialog submission.\n * Called when user submits the create form.\n */\nexport type OnDialogSubmit<T = TransferData> = (data: T) => Promise<void>;\n\n/**\n * Callback for dialog validation.\n * Called before submission to validate form data.\n * Returns field errors or null if valid.\n */\nexport type OnDialogValidate<T = TransferData> = (data: T) => Promise<Record<string, string> | null>;\n"],"mappings":";;;;;;;;kCA2Ra,IAAb,cAAqC,MAAM;CAC1C;CACA,SAA0B;CAE1B,YAAY,GAA+B;EAC1C,IAAM,IAAa,EAAc,MAAM,MAAM,EAAE,UAAU,QAAQ;AAGjE,EAFA,MAAM,GAAY,WAAW,oBAAoB,EACjD,KAAK,OAAO,mBACZ,KAAK,gBAAgB;;CAOtB,gBAAwC;EACvC,IAAM,IAAiC,EAAE;AACzC,OAAK,IAAM,KAAQ,KAAK,cACvB,CAAI,EAAK,UAAU,WAAW,EAAK,aAClC,EAAO,EAAK,YAAY,EAAK,WAAW,EAAK;AAG/C,SAAO"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@judo/actions",
3
- "version": "0.30.0",
3
+ "version": "0.31.0",
4
4
  "license": "EPL-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -26,13 +26,13 @@
26
26
  "access": "public"
27
27
  },
28
28
  "dependencies": {
29
- "@judo/model-api": "0.30.0"
29
+ "@judo/model-api": "0.31.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "@testing-library/react": "^16.3.2",
33
33
  "@types/react": "^19.2.14",
34
- "typescript": "^5.9.3",
35
- "vitest": "^4.0.18"
34
+ "typescript": "^6.0.2",
35
+ "vitest": "^4.1.2"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": "^19.0.0"
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-BsQmyhQI.js","names":["errors: Record<string, string>"],"sources":["../src/api/types.ts"],"sourcesContent":["/**\n * JUDO REST API types.\n * Based on REST_REQUEST_MAPPING_SPECIFICATION.md\n */\n\n// ============================================\n// HTTP/Response Types\n// ============================================\n\n/**\n * HTTP method types used in the REST layer.\n * GET is used for template retrieval, file downloads, metadata, principal.\n * POST is used for all other operations (CRUD, list, range, operations, validation).\n */\nexport type HttpMethod = \"GET\" | \"POST\";\n\n/**\n * Response type indicating how to handle the response body.\n */\nexport type ResponseType = \"json\" | \"blob\";\n\n/**\n * How to deserialize the response.\n * - single: Deserialize as a single transfer\n * - array: Deserialize as an array of transfers\n * - void: No deserialization needed (response is empty)\n * - nullable: Deserialize as single transfer or null\n */\nexport type DeserializationType = \"single\" | \"array\" | \"void\" | \"nullable\";\n\n/**\n * Service type categories.\n */\nexport type ServiceType = \"class\" | \"relation\" | \"access\";\n\n// ============================================\n// Serialization/Deserialization\n// ============================================\n\n/**\n * Configuration for deserializing the response.\n */\nexport interface ResponseDeserializerConfig {\n\t/** Type of deserialization to apply */\n\ttype: DeserializationType;\n\t/** Target class FQName for deserialization (if applicable) */\n\ttargetClassFqName?: string;\n\t/** Whether the target is a stored (persisted) transfer */\n\tisStored: boolean;\n}\n\n/**\n * Transfer serializer interface for transforming transfers before sending.\n * The input type is unknown to support any transfer type.\n */\nexport interface TransferSerializer {\n\t/** Serialize an transfer for sending in request body */\n\tserialize(transfer: unknown): unknown;\n}\n\n/**\n * Transfer deserializer interface for transforming responses.\n * The output type is unknown to support any transfer type.\n */\nexport interface TransferDeserializer {\n\t/** Deserialize a response into an transfer */\n\tdeserialize(data: unknown): unknown;\n}\n\n// ============================================\n// Temporal Field Types\n// ============================================\n\n/**\n * Classification of temporal (date/time) field types.\n *\n * - `date`: Date-only value (`YYYY-MM-DD`) — converted to `Date` at local midnight\n * - `time`: Time-only value (`HH:mm[:ss]`) — kept as `string` (no `Date` conversion)\n * - `timestamp`: Full datetime with timezone (`YYYY-MM-DDTHH:mm:ss[.SSS]Z`) — converted to `Date`\n */\nexport type TemporalFieldType = \"date\" | \"time\" | \"timestamp\";\n\n/**\n * Registry mapping transfer type FQNs to their temporal field declarations.\n *\n * Keys match `__entityType` values from API responses (e.g., `\"Demo::OrderDTO\"`).\n * Values map field names to their temporal type for serialization/deserialization.\n *\n * @example\n * ```typescript\n * const registry: TemporalFieldRegistry = {\n * \"Demo::OrderDTO\": { orderDate: \"date\", createdAt: \"timestamp\" },\n * \"Demo::MissionDTO\": { startDate: \"date\", endDate: \"date\" },\n * };\n * ```\n */\nexport type TemporalFieldRegistry = Record<string, Record<string, TemporalFieldType>>;\n\n// ============================================\n// API Configuration\n// ============================================\n\n/**\n * Configuration for JUDO REST API client.\n */\nexport interface JudoRestApiConfig {\n\t/** Base URL for the API (e.g., http://localhost:8080) */\n\tbaseUrl: string;\n\t/** Application base path (e.g., /api) */\n\tbasePath: string;\n\t/** Application model name (e.g., edemokracia) */\n\tmodelName: string;\n\t/** Actor path (e.g., admin/Admin) */\n\tactorPath: string;\n\t/** Request timeout in milliseconds */\n\ttimeout?: number;\n\t/** Default headers to include in all requests */\n\tdefaultHeaders?: Record<string, string>;\n\t/** Optional custom fetch implementation */\n\tfetch?: typeof fetch;\n\t/** Optional request interceptor */\n\tonRequest?: (request: RequestInit) => RequestInit | Promise<RequestInit>;\n\t/** Optional response interceptor */\n\tonResponse?: (response: Response) => Response | Promise<Response>;\n\t/** Optional error handler */\n\tonError?: (error: Error) => void;\n\t/**\n\t * Optional transfer serializer for transforming transfers before sending.\n\t * If not provided, transfers are sent as-is (JSON.stringify).\n\t */\n\ttransferSerializer?: TransferSerializer;\n\t/**\n\t * Optional transfer deserializer for transforming responses.\n\t * If not provided, responses are used as-is (JSON.parse result).\n\t */\n\ttransferDeserializer?: TransferDeserializer;\n}\n\n/**\n * Query customizer for list/get operations.\n */\nexport interface QueryCustomizer {\n\t_mask?: string;\n\t_orderBy?: Array<{ attribute: string; descending?: boolean }>;\n\t_seek?: { limit?: number; lastItem?: unknown };\n\t_filter?: unknown;\n\t_identifier?: string;\n}\n\n/**\n * Base transfer data interface.\n *\n */\nexport interface TransferData {\n\t[key: string]: unknown;\n}\n\n/**\n * Strict transfer data — a TransferData whose *own* properties conform to `T`.\n *\n * Use in generated code and userland APIs where the exact field set is known.\n *\n * @typeParam T - Strict field definitions (e.g. `{ name: string; age: number }`)\n */\nexport type StrictTransferData<T extends Record<string, unknown> = Record<string, unknown>> = TransferData & T;\n\n/**\n * Stored transfer with identifiers.\n */\nexport interface TransferStored extends TransferData {\n\t__identifier?: string;\n\t__signedIdentifier?: string;\n\t__typename?: string;\n\t__entityType?: string;\n}\n\n/**\n * Strict stored transfer — a TransferStored with compile-time field types from `T`.\n *\n * @typeParam T - Strict field definitions\n */\nexport type StrictTransferStored<T extends Record<string, unknown> = Record<string, unknown>> = TransferStored & T;\n\n/**\n * Response wrapper for JUDO REST responses.\n */\nexport interface JudoRestResponse<T> {\n\tdata: T;\n\tstatus: number;\n\theaders: Headers;\n}\n\n/**\n * Path context for building REST paths.\n */\nexport interface PathContext {\n\t/** Package name tokens (e.g., [\"admin\"]) */\n\tpackageNameTokens: string[];\n\t/** Simple name (e.g., \"Issue\") */\n\tsimpleName: string;\n}\n\n/**\n * Class type metadata for path building.\n */\nexport interface ClassTypeMetadata extends PathContext {\n\t/** Fully qualified name */\n\tfqName?: string;\n\t/** Whether the class is mapped */\n\tisMapped?: boolean;\n}\n\n/**\n * Relation type metadata for path building.\n */\nexport interface RelationMetadata {\n\t/** Relation name */\n\tname: string;\n\t/** Owner class metadata */\n\towner: ClassTypeMetadata;\n\t/** Target class metadata */\n\ttarget: ClassTypeMetadata;\n\t/** Whether this is an access relation */\n\tisAccess?: boolean;\n\t/** Whether this is a collection relation */\n\tisCollection?: boolean;\n}\n\n/**\n * Operation type metadata.\n */\nexport interface OperationMetadata {\n\t/** Operation name */\n\tname: string;\n\t/** Whether the operation is static */\n\tisStatic?: boolean;\n\t/** Whether the operation is mapped */\n\tisMapped?: boolean;\n\t/** Whether the operation has input */\n\thasInput?: boolean;\n\t/** Whether the operation has output */\n\thasOutput?: boolean;\n\t/** Input type metadata */\n\tinputType?: ClassTypeMetadata;\n\t/** Output type metadata */\n\toutputType?: ClassTypeMetadata;\n}\n\n/**\n * Range request body structure.\n */\nexport interface RangeRequestBody {\n\towner?: TransferStored;\n\tqueryCustomizer?: QueryCustomizer;\n}\n\n// ============================================\n// Validation & Error Types\n// ============================================\n\n/**\n * Validation feedback item from REST API.\n * Returned in response body for 400 validation errors.\n */\nexport interface FeedbackItem {\n\t/** Error code identifier */\n\tcode: string;\n\t/** Severity level of the feedback */\n\tlevel: \"ERROR\" | \"WARNING\" | \"INFO\";\n\t/**\n\t * Location of the error - typically the attribute path.\n\t * For nested properties, format is: \"relationName.attributeName\"\n\t * For simple attributes, format is: \"attributeName\"\n\t */\n\tlocation: string;\n\t/** Human-readable error message */\n\tmessage?: string;\n}\n\n/**\n * Validation error thrown when API returns 400 status.\n * Contains array of FeedbackItem with field-level error details.\n */\nexport class ValidationError extends Error {\n\treadonly feedbackItems: FeedbackItem[];\n\treadonly status: number = 400;\n\n\tconstructor(feedbackItems: FeedbackItem[]) {\n\t\tconst firstError = feedbackItems.find((f) => f.level === \"ERROR\");\n\t\tsuper(firstError?.message ?? \"Validation failed\");\n\t\tthis.name = \"ValidationError\";\n\t\tthis.feedbackItems = feedbackItems;\n\t}\n\n\t/**\n\t * Get errors as a map of field location to error message.\n\t * Useful for setting form field errors.\n\t */\n\ttoFieldErrors(): Record<string, string> {\n\t\tconst errors: Record<string, string> = {};\n\t\tfor (const item of this.feedbackItems) {\n\t\t\tif (item.level === \"ERROR\" && item.location) {\n\t\t\t\terrors[item.location] = item.message ?? item.code;\n\t\t\t}\n\t\t}\n\t\treturn errors;\n\t}\n}\n\n// ============================================\n// Dialog Response Types\n// ============================================\n\n/**\n * Result type for dialog submission.\n * Used for create dialogs opened from eager/lazy components.\n */\nexport type DialogResult<T = TransferData> = { outcome: \"cancel\" } | { outcome: \"submit\"; data: T };\n\n/**\n * Callback for dialog submission.\n * Called when user submits the create form.\n */\nexport type OnDialogSubmit<T = TransferData> = (data: T) => Promise<void>;\n\n/**\n * Callback for dialog validation.\n * Called before submission to validate form data.\n * Returns field errors or null if valid.\n */\nexport type OnDialogValidate<T = TransferData> = (data: T) => Promise<Record<string, string> | null>;\n"],"mappings":"AA2RA,IAAa,kBAAb,cAAqC,MAAM;CAC1C;CACA,SAA0B;CAE1B,YAAY,GAA+B;EAC1C,IAAM,IAAa,EAAc,MAAM,MAAM,EAAE,UAAU,QAAQ;AAGjE,EAFA,MAAM,GAAY,WAAW,oBAAoB,EACjD,KAAK,OAAO,mBACZ,KAAK,gBAAgB;;CAOtB,gBAAwC;EACvC,IAAMA,IAAiC,EAAE;AACzC,OAAK,IAAM,KAAQ,KAAK,cACvB,CAAI,EAAK,UAAU,WAAW,EAAK,aAClC,EAAO,EAAK,YAAY,EAAK,WAAW,EAAK;AAG/C,SAAO"}
@@ -1,2 +0,0 @@
1
- import { t as ValidationError } from "./types-BsQmyhQI.js";
2
- export { ValidationError };