@atscript/moost-wf 0.1.163 → 0.1.165

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
@@ -3,12 +3,27 @@ import { WfOutlet, WfOutletTriggerConfig, WfOutletTriggerDeps } from "@moostjs/e
3
3
  import { StepRetriableError } from "@wooksjs/event-wf";
4
4
 
5
5
  //#region src/wf-io/serialize.d.ts
6
+ /** Options of {@link serializeFormSchema}. */
7
+ interface SerializeFormSchemaOpts {
8
+ /**
9
+ * Serve the schema in the request's language. Default `true`: with a
10
+ * translator registered (moost's `setTranslator`) and a locale picked for
11
+ * the request, the schema's texts (`@meta.label`, `@ui.form.placeholder`,
12
+ * constraint messages, …) are translated and the schema carries `$i18n` —
13
+ * the validator's and the UI components' message templates in that
14
+ * language and the translated texts of its expressions. `false` serves the
15
+ * source texts (e.g. when the wording depends on more than the locale).
16
+ */
17
+ translate?: boolean;
18
+ }
6
19
  /**
7
20
  * Serialize an atscript annotated type to a JSON-transportable form schema.
8
21
  *
9
22
  * Delegates to `serializeAnnotatedType` from `@atscript/typescript`,
10
23
  * stripping server-only `@wf.context.pass` annotations from the output.
11
- * Results are cached per type identity.
24
+ * Results are cached per type identity — and, translated, per type and
25
+ * locale (see {@link SerializeFormSchemaOpts.translate}). Without a
26
+ * translator the result is the same object for every request.
12
27
  *
13
28
  * FK fields ship with a shallow ref: the target's identity (`id`) and
14
29
  * interface-level `metadata` (including `db.http.path` when present) are
@@ -17,7 +32,7 @@ import { StepRetriableError } from "@wooksjs/event-wf";
17
32
  * endpoints without dragging the full target tree onto the wire. See the
18
33
  * `wf-serialize-shallow-ref` design for rationale.
19
34
  */
20
- declare function serializeFormSchema(type: TAtscriptAnnotatedType): unknown;
35
+ declare function serializeFormSchema(type: TAtscriptAnnotatedType, opts?: SerializeFormSchemaOpts): unknown;
21
36
  //#endregion
22
37
  //#region src/wf-io/context.d.ts
23
38
  interface TFormActions {
@@ -36,6 +51,8 @@ declare function extractPassContext(type: TAtscriptAnnotatedType, wfContext: Rec
36
51
  declare function getFormActions(type: TAtscriptAnnotatedType): TFormActions;
37
52
  //#endregion
38
53
  //#region src/wf-io/use-atscript-wf.d.ts
54
+ /** Options of {@link useAtscriptWf}. */
55
+ type UseAtscriptWfOpts = SerializeFormSchemaOpts;
39
56
  /**
40
57
  * Schema-driven workflow I/O primitives for atscript types. Returned helpers
41
58
  * are pure and independent — composable consumers can interleave their own
@@ -52,8 +69,13 @@ declare function getFormActions(type: TAtscriptAnnotatedType): TFormActions;
52
69
  * `@WfInput` decorator) can throw their own custom failures.
53
70
  *
54
71
  * Validator instances are cached per `(type, opts)` pair.
72
+ *
73
+ * Served in the request's language (moost's `setTranslator`): the form
74
+ * schema (see {@link SerializeFormSchemaOpts.translate}), validation errors
75
+ * (by their code) and `formMessage` / `errors` given to `requireInput` (by
76
+ * their text). The workflow's state is never translated.
55
77
  */
56
- declare function useAtscriptWf<T extends TAtscriptTypeDef>(type: TAtscriptAnnotatedType<T>): {
78
+ declare function useAtscriptWf<T extends TAtscriptTypeDef>(type: TAtscriptAnnotatedType<T>, opts?: UseAtscriptWfOpts): {
57
79
  resolveInput(opts?: {
58
80
  partial?: "deep";
59
81
  }): InferDataType<T>;
@@ -81,6 +103,8 @@ declare function useAtscriptWf<T extends TAtscriptTypeDef>(type: TAtscriptAnnota
81
103
  * `pass: true` opts the step into ignoring the no-data action.
82
104
  * - Unknown action → `StepRetriableError` (propagated from `resolveAction`).
83
105
  *
106
+ * `translate`: see {@link UseAtscriptWfOpts}.
107
+ *
84
108
  * @example
85
109
  * ```ts
86
110
  * @Step('login')
@@ -89,7 +113,7 @@ declare function useAtscriptWf<T extends TAtscriptTypeDef>(type: TAtscriptAnnota
89
113
  * }
90
114
  * ```
91
115
  */
92
- declare function WfInput(opts?: {
116
+ declare function WfInput(opts?: UseAtscriptWfOpts & {
93
117
  pass?: boolean;
94
118
  }): ParameterDecorator;
95
119
  //#endregion
@@ -103,7 +127,8 @@ declare function WfInput(opts?: {
103
127
  * The form type is **required**: the decorator validates the action against
104
128
  * the form's declared `@ui.form.action` / `@wf.action.withData` whitelist and
105
129
  * throws `StepRetriableError` for any unknown action — the step body never
106
- * sees actions that aren't part of the form's contract.
130
+ * sees actions that aren't part of the form's contract. `translate`: see
131
+ * {@link UseAtscriptWfOpts}.
107
132
  *
108
133
  * @example
109
134
  * ```ts
@@ -117,7 +142,7 @@ declare function WfInput(opts?: {
117
142
  * }
118
143
  * ```
119
144
  */
120
- declare function WfAction<T extends TAtscriptTypeDef>(type: TAtscriptAnnotatedType<T>): ParameterDecorator;
145
+ declare function WfAction<T extends TAtscriptTypeDef>(type: TAtscriptAnnotatedType<T>, opts?: UseAtscriptWfOpts): ParameterDecorator;
121
146
  //#endregion
122
147
  //#region src/outlet.d.ts
123
148
  /**
@@ -198,7 +223,9 @@ interface FinishWfOpts<T = unknown> {
198
223
  }
199
224
  /**
200
225
  * Build a `WfFinished` envelope and hand it to wooks. All envelope
201
- * properties are optional; pass `data`, `message`, and/or `next`:
226
+ * properties are optional; pass `data`, `message`, and/or `next`.
227
+ * With moost's translator (`setTranslator`) the message text and button
228
+ * labels are sent in the request's language (each text is its own id):
202
229
  *
203
230
  * finishWf({ data: { id: 42 } });
204
231
  * finishWf({ message: { level: "success", text: "Saved." } });
@@ -224,4 +251,4 @@ declare function finishWf<T = unknown>(opts?: FinishWfOpts<T>): void;
224
251
  */
225
252
  declare function abortWf(reason: string, opts?: FinishWfOpts): void;
226
253
  //#endregion
227
- export { type FinishWfOpts, WfAction, type WfActionRequest, type WfButton, type WfFinished, WfInput, type WfMessage, type WfNext, abortWf, createAsHttpOutlet, extractPassContext, finishWf, getFormActions, handleAsOutletRequest, isWfFinished, serializeFormSchema, useAtscriptWf };
254
+ export { type FinishWfOpts, type SerializeFormSchemaOpts, type UseAtscriptWfOpts, WfAction, type WfActionRequest, type WfButton, type WfFinished, WfInput, type WfMessage, type WfNext, abortWf, createAsHttpOutlet, extractPassContext, finishWf, getFormActions, handleAsOutletRequest, isWfFinished, serializeFormSchema, useAtscriptWf };
package/dist/index.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { isAnnotatedType, serializeAnnotatedType } from "@atscript/typescript/utils";
1
+ import { VALIDATOR_MESSAGES, isAnnotatedType, localizeErrors, serializeAnnotatedType, translateServed } from "@atscript/typescript/utils";
2
+ import { Optional, Resolve, formatMessage, registerMessages, useTranslation } from "moost";
2
3
  import { createHttpOutlet, handleWfOutletRequest, useWfState } from "@moostjs/event-wf";
3
4
  import { StepRetriableError, useWfFinished } from "@wooksjs/event-wf";
4
- import { Optional, Resolve } from "moost";
5
5
  //#region src/wf-io/context.ts
6
6
  const WF_CONTEXT_PASS = "wf.context.pass";
7
7
  const UI_FORM_ACTION = "ui.form.action";
@@ -56,6 +56,373 @@ function getFormActions(type) {
56
56
  return result;
57
57
  }
58
58
  //#endregion
59
+ //#region ../ui/src/messages.ts
60
+ /**
61
+ * The built-in texts of the atscript-ui components, by code: `UI_*` code →
62
+ * English template with `{name}` placeholders. Imports nothing — a server
63
+ * registers it with moost's translation registry:
64
+ *
65
+ * ```ts
66
+ * import { registerMessages } from "moost";
67
+ * import { AS_UI_MESSAGES } from "@atscript/ui/messages";
68
+ *
69
+ * registerMessages(AS_UI_MESSAGES);
70
+ * ```
71
+ *
72
+ * The client renders these texts in English unless the server served a
73
+ * translation for the locale (or your own translator returns one).
74
+ */
75
+ const AS_UI_MESSAGES = Object.freeze({
76
+ UI_YES: "Yes",
77
+ UI_NO: "No",
78
+ UI_ITEM: "item",
79
+ UI_CANCEL: "Cancel",
80
+ UI_APPLY: "Apply",
81
+ UI_SAVE: "Save",
82
+ UI_CLOSE: "Close",
83
+ UI_CONFIRM: "Confirm",
84
+ UI_CONFIRMATION: "Confirmation",
85
+ UI_REMOVE: "Remove",
86
+ UI_CLEAR: "Clear",
87
+ UI_CLEAR_ALL: "Clear all",
88
+ UI_CLEAR_SELECTION: "Clear selection",
89
+ UI_SELECT_ALL: "Select all",
90
+ UI_SELECT_PLACEHOLDER: "Select...",
91
+ UI_SEARCH_PLACEHOLDER: "Search...",
92
+ UI_RESET: "Reset",
93
+ UI_RETRY: "Retry",
94
+ UI_ERROR: "Error",
95
+ UI_MORE: "+{count} more",
96
+ UI_INVALID_VALUE: "Invalid value",
97
+ UI_VALIDATION_FAILED: "Validation failed",
98
+ UI_FORM_SUBMIT: "Submit",
99
+ UI_FORM_DISMISS: "Dismiss",
100
+ UI_FORM_MODIFIED: "Modified",
101
+ UI_FORM_WRONG_VALUE: "Wrong value",
102
+ UI_FORM_ADD: "Add {item}",
103
+ UI_FORM_ITEMS_COUNT: "{count} items",
104
+ UI_FORM_ERRORS_INSIDE_ONE: "{count} error inside",
105
+ UI_FORM_ERRORS_INSIDE: "{count} errors inside",
106
+ UI_FORM_NOT_SET: "Not set",
107
+ UI_FORM_CLICK_TO_EDIT: "Click to edit",
108
+ UI_FORM_UNSET: "Unset",
109
+ UI_FORM_UNSET_VALUE: "Unset value",
110
+ UI_FORM_UNSET_FIELD: "Unset {field}",
111
+ UI_FORM_CLEAR_FIELD: "Clear {field}",
112
+ UI_FORM_REMOVE_VALUE: "Remove {value}",
113
+ UI_FORM_NO_MATCHES: "No matches",
114
+ UI_FORM_NO_RESULTS: "No results",
115
+ UI_FORM_SWITCH: "Switch",
116
+ UI_FORM_SWITCH_TYPE: "Switch type — current: {type}",
117
+ UI_FORM_DECIMALS_OF: "decimals of {field}",
118
+ UI_FORM_HIDDEN_PLACEHOLDER: "(hidden — enter a value to replace)",
119
+ UI_FORM_TYPE_OBJECT: "Object",
120
+ UI_FORM_TYPE_STRING: "String",
121
+ UI_FORM_TYPE_NUMBER: "Number",
122
+ UI_FORM_TYPE_BOOLEAN: "Boolean",
123
+ UI_FORM_TYPE_ITEM: "Item",
124
+ UI_FORM_TYPE_ARRAY: "Array",
125
+ UI_FORM_TYPE_TUPLE: "Tuple",
126
+ UI_TABLE_VALUE: "Value",
127
+ UI_TABLE_ACTIONS: "Actions",
128
+ UI_TABLE_ROW_ACTIONS: "Row actions",
129
+ UI_TABLE_MORE_ACTIONS: "More actions",
130
+ UI_TABLE_MORE_ACTIONS_RUNNING: "More actions, running",
131
+ UI_TABLE_MORE_FILTERS: "More filters",
132
+ UI_TABLE_SELECT_ALL_ROWS: "Select all rows",
133
+ UI_TABLE_SELECT_ROW: "Select row",
134
+ UI_TABLE_SELECT_ROW_REASON: "Select row, {reason}",
135
+ UI_TABLE_SELECT_ROW_DISABLED: "Select row, not selectable",
136
+ UI_TABLE_SELECTED_PAGE_ONE: "The 1 row on this page is selected.",
137
+ UI_TABLE_SELECTED_PAGE: "All {count} rows on this page are selected.",
138
+ UI_TABLE_SELECTED_LOADED_ONE: "The 1 row loaded is selected.",
139
+ UI_TABLE_SELECTED_LOADED: "All {count} rows loaded are selected.",
140
+ UI_TABLE_SELECTED_MATCHING_ONE: "1 matching row is selected.",
141
+ UI_TABLE_SELECTED_MATCHING: "All {count} matching rows are selected.",
142
+ UI_TABLE_SELECT_ALL_MATCHING: "Select all {count} matching",
143
+ UI_TABLE_LOAD_FAILED: "Failed to load values",
144
+ UI_TABLE_NO_MATCHING: "No matching values",
145
+ UI_TABLE_NO_MATCH_SEARCH: "No entries match {term}. Try a different search.",
146
+ UI_TABLE_NO_MATCH_FILTERS: "No entries match the current filters.",
147
+ UI_TABLE_NO_ENTRIES: "No entries available",
148
+ UI_TABLE_CLEAR_FILTERS: "Clear filters",
149
+ UI_TABLE_RECORDS: "{count} records",
150
+ UI_TABLE_VIEW_ITEMS: "View {count} items",
151
+ UI_TABLE_VIEW_OBJECT: "View object",
152
+ UI_TABLE_ROWS_ONE: "{count} row",
153
+ UI_TABLE_ROWS: "{count} rows",
154
+ UI_TABLE_SORT: "Sort",
155
+ UI_TABLE_ASCENDING: "Ascending",
156
+ UI_TABLE_DESCENDING: "Descending",
157
+ UI_TABLE_FILTER_MENU: "Filter...",
158
+ UI_TABLE_RESET_WIDTH: "Reset width",
159
+ UI_TABLE_HIDE_COLUMN: "Hide column",
160
+ UI_TABLE_SETTINGS: "Table Settings",
161
+ UI_TABLE_SETTINGS_DESCRIPTION: "Choose which columns are visible, which fields appear in the filter bar, and the sort order of the table.",
162
+ UI_TABLE_COLUMNS: "Columns",
163
+ UI_TABLE_FILTERS: "Filters",
164
+ UI_TABLE_SORTERS: "Sorters",
165
+ UI_TABLE_CLIENT_SORTER: "client",
166
+ UI_TABLE_COLUMNS_VISIBLE: "{count} of {total} columns visible",
167
+ UI_TABLE_FILTERS_SHOWN: "{count} of {total} filterable columns shown as filter pills",
168
+ UI_TABLE_SORTERS_ACTIVE: "{count} of {total} sortable columns in effect",
169
+ UI_TABLE_COLUMNS_HINT: "Checked columns are rendered in the table. Drag rows to reorder.",
170
+ UI_TABLE_FILTERS_HINT: "Checked columns appear in the filter bar for quick filtering.",
171
+ UI_TABLE_SORTERS_HINT: "Rows are ordered by these fields, top-to-bottom.",
172
+ UI_TABLE_SORT_PRIORITY: "Sort priority {n}",
173
+ UI_TABLE_SORT_DIRECTION: "Sort direction",
174
+ UI_TABLE_ASC: "↑ Asc",
175
+ UI_TABLE_DESC: "↓ Desc",
176
+ UI_TABLE_LOCKED: "Locked",
177
+ UI_TABLE_NONE: "None",
178
+ UI_TABLE_MOVE_TOP: "Move to top",
179
+ UI_TABLE_MOVE_UP: "Move up",
180
+ UI_TABLE_MOVE_DOWN: "Move down",
181
+ UI_TABLE_MOVE_BOTTOM: "Move to bottom",
182
+ UI_FILTER_TITLE: "Filter",
183
+ UI_FILTER_DESCRIPTION: "Build the filter conditions applied to this column.",
184
+ UI_FILTER_VALUES: "Values",
185
+ UI_FILTER_CONDITIONS: "Conditions",
186
+ UI_FILTER_APPLIED_ONE: "{count} condition applied",
187
+ UI_FILTER_APPLIED: "{count} conditions applied",
188
+ UI_FILTER_SEE_ALL: "See All ({count})",
189
+ UI_FILTER_OPEN_DIALOG: "Open filter dialog (F4)",
190
+ UI_FILTER_DATE_PLACEHOLDER: "YYYY-MM-DD",
191
+ UI_FILTER_VALUE_PLACEHOLDER: "Value...",
192
+ UI_FILTER_FROM: "From",
193
+ UI_FILTER_TO: "To",
194
+ UI_FILTER_PICK_TIME: "Pick a time",
195
+ UI_FILTER_CLEAR_VALUE: "Clear value",
196
+ UI_FILTER_ADD_CONDITION: "+ Add condition",
197
+ UI_FILTER_REMOVE_CONDITION: "Remove condition",
198
+ UI_FILTER_QUICK: "Quick:",
199
+ UI_FILTER_SHOW_FILTERS: "Show filters",
200
+ UI_FILTER_HIDE_FILTERS: "Hide filters",
201
+ UI_FILTER_CUSTOM: "Custom filter",
202
+ UI_FILTER_REMOVE_CUSTOM: "Remove custom filter",
203
+ UI_FILTER_COND_EQ: "equals",
204
+ UI_FILTER_COND_NE: "not equals",
205
+ UI_FILTER_COND_GT: "greater than",
206
+ UI_FILTER_COND_GTE: "greater or equal",
207
+ UI_FILTER_COND_LT: "less than",
208
+ UI_FILTER_COND_LTE: "less or equal",
209
+ UI_FILTER_COND_CONTAINS: "contains",
210
+ UI_FILTER_COND_STARTS: "starts with",
211
+ UI_FILTER_COND_ENDS: "ends with",
212
+ UI_FILTER_COND_BW: "between",
213
+ UI_FILTER_COND_NULL: "is empty",
214
+ UI_FILTER_COND_NOT_NULL: "is not empty",
215
+ UI_FILTER_COND_REGEX: "matches pattern",
216
+ UI_FILTER_DATE_EQ: "on",
217
+ UI_FILTER_DATE_NE: "not on",
218
+ UI_FILTER_DATE_LT: "before",
219
+ UI_FILTER_DATE_LTE: "on or before",
220
+ UI_FILTER_DATE_GT: "after",
221
+ UI_FILTER_DATE_GTE: "on or after",
222
+ UI_FILTER_CHIP: "{field} {condition} {value}",
223
+ UI_FILTER_CHIP_EMPTY: "{field}: empty",
224
+ UI_FILTER_CHIP_NOT_EMPTY: "{field}: not empty",
225
+ UI_FILTER_CHIP_BETWEEN: "{field}: {from} – {to}",
226
+ UI_FILTER_CHIP_COUNT: "{field}: {count} conditions",
227
+ UI_FILTER_CHIP_IN: "{field} is one of {values}",
228
+ UI_FILTER_CHIP_NOT_IN: "{field} is none of {values}",
229
+ UI_FILTER_CHIP_SOME: "{field} has some ({filter})",
230
+ UI_FILTER_CHIP_NONE: "{field} has none ({filter})",
231
+ UI_FILTER_CHIP_ANY: "any",
232
+ UI_FILTER_CHIP_NOT: "not ({filter})",
233
+ UI_FILTER_AND: "and",
234
+ UI_FILTER_OR: "or",
235
+ UI_FILTER_EMPTY: "empty",
236
+ UI_FILTER_NOT_EMPTY: "not empty",
237
+ UI_FILTER_ON_DATE: "on {date}",
238
+ UI_FILTER_IN_MONTH: "in {date}",
239
+ UI_FILTER_NOT_ON_DATE: "not on {date}",
240
+ UI_FILTER_BEFORE_DATE: "before {date}",
241
+ UI_FILTER_ON_OR_BEFORE_DATE: "on or before {date}",
242
+ UI_FILTER_AFTER_DATE: "after {date}",
243
+ UI_FILTER_ON_OR_AFTER_DATE: "on or after {date}",
244
+ UI_FILTER_TODAY: "today",
245
+ UI_FILTER_YESTERDAY: "yesterday",
246
+ UI_FILTER_DAYS_AGO: "{count} days ago",
247
+ UI_FILTER_THIS_WEEK: "this week",
248
+ UI_FILTER_LAST_WEEK: "last week",
249
+ UI_FILTER_WEEKS_AGO: "{count} weeks ago",
250
+ UI_FILTER_THIS_MONTH: "this month",
251
+ UI_FILTER_LAST_MONTH: "last month",
252
+ UI_FILTER_MONTHS_AGO: "{count} months ago",
253
+ UI_FILTER_THIS_YEAR: "this year",
254
+ UI_FILTER_LAST_YEAR: "last year",
255
+ UI_FILTER_YEARS_AGO: "{count} years ago",
256
+ UI_DATE_TODAY: "Today",
257
+ UI_DATE_YESTERDAY: "Yesterday",
258
+ UI_DATE_LAST_7_DAYS: "Last 7 days",
259
+ UI_DATE_LAST_30_DAYS: "Last 30 days",
260
+ UI_DATE_THIS_WEEK: "This week",
261
+ UI_DATE_LAST_WEEK: "Last week",
262
+ UI_DATE_THIS_MONTH: "This month",
263
+ UI_DATE_LAST_MONTH: "Last month",
264
+ UI_DATE_THIS_YEAR: "This year",
265
+ UI_DATES_LAST_7_DAYS: "Last 7 Days",
266
+ UI_DATES_LAST_30_DAYS: "Last 30 Days",
267
+ UI_DATES_MONTH_TO_DATE: "Month to Date",
268
+ UI_DATES_LAST_90_DAYS: "Last 90 Days",
269
+ UI_DATES_LAST_6_MONTHS: "Last 6 Months",
270
+ UI_DATES_LAST_12_MONTHS: "Last 12 Months",
271
+ UI_DATES_YEAR_TO_DATE: "Year to Date",
272
+ UI_ACTION_DELETE: "Delete",
273
+ UI_ACTION_DELETE_ONE: "Delete item $1?",
274
+ UI_ACTION_DELETE_MANY: "Delete $N items?",
275
+ UI_ACTION_PROCEED: "Proceed",
276
+ UI_ACTION_NO_FORM: "Action does not declare an input form.",
277
+ UI_ACTION_PROVIDE_INPUT: "Provide the input for {action}.",
278
+ UI_ACTION_LOADING_FORM: "Loading form…",
279
+ UI_ACTION_MORE_IDS: "{count} more…",
280
+ UI_ACTION_AT_MOST: "At most {rows}",
281
+ UI_ACTION_QUERY_UNSUPPORTED: "Not available for all matching rows — select rows individually",
282
+ UI_ACTION_RUN_ON: "Run “{action}” on {rows}?",
283
+ UI_ACTION_TARGET_CHANGED: "The rows matching the query changed. {question}",
284
+ UI_PRESET_STANDARD: "Standard",
285
+ UI_PRESET_SYSTEM: "System",
286
+ UI_PRESET_MINE: "My presets",
287
+ UI_PRESET_FAVORITES: "Favorites",
288
+ UI_PRESET_SHARED: "Shared by others",
289
+ UI_PRESET_COPY_OF: "Copy of {name}",
290
+ UI_PRESET_SAVE_FAILED: "Could not save the preset.",
291
+ UI_PRESET_CHANGE_FAILED: "The change could not be saved.",
292
+ UI_PRESET_FIELDS_UNAVAILABLE: "Some fields in this preset aren't available to you.",
293
+ UI_PRESET_SAVE_AS: "Save as…",
294
+ UI_PRESET_RESET: "Reset changes",
295
+ UI_PRESET_MANAGE: "Manage presets…",
296
+ UI_PRESET_SAVE_AS_TITLE: "Save as new preset",
297
+ UI_PRESET_NAME: "Name",
298
+ UI_PRESET_SAVE_ASPECTS: "Save:",
299
+ UI_PRESET_RESIDUAL_NOT_SAVED: "Custom filter conditions are not saved with presets.",
300
+ UI_PRESET_MAKE_PUBLIC: "Make public",
301
+ UI_PRESET_ASPECT_COLUMNS: "Displayed Columns",
302
+ UI_PRESET_ASPECT_FILTERS: "Displayed Filters",
303
+ UI_PRESET_ASPECT_FILTER_OPS: "Filter conditions",
304
+ UI_PRESET_ASPECT_SORTERS: "Sorters",
305
+ UI_PRESET_ASPECT_PAGE_SIZE: "Page size",
306
+ UI_PRESET_DIALOG_TITLE: "Presets",
307
+ UI_PRESET_DIALOG_DESCRIPTION: "Rename, share, favorite, pin as default or delete your saved table views.",
308
+ UI_PRESET_SEARCH: "Search by name or owner…",
309
+ UI_PRESET_LEGEND_DEFAULT: "default",
310
+ UI_PRESET_LEGEND_FAVORITE: "favorite",
311
+ UI_PRESET_LEGEND_PUBLIC: "public",
312
+ UI_PRESET_LEGEND_DELETE: "delete",
313
+ UI_PRESET_NO_MATCH: "No presets match \"{query}\".",
314
+ UI_PRESET_OWNER_YOU: "you",
315
+ UI_PRESET_WILL_APPLY: "This preset will be applied",
316
+ UI_PRESET_CLICK_TO_APPLY: "Click to apply this preset on Save",
317
+ UI_PRESET_RENAME_PENDING: "Modified — click to keep editing",
318
+ UI_PRESET_CLICK_TO_RENAME: "Click to rename",
319
+ UI_PRESET_FAVORITED: "Favorited — click to remove",
320
+ UI_PRESET_CLICK_TO_FAVORITE: "Click to add to favorites",
321
+ UI_PRESET_DEFAULT: "Default — click to unpin",
322
+ UI_PRESET_CLICK_TO_PIN: "Click to pin as default",
323
+ UI_PRESET_PUBLIC: "Public — click to make private",
324
+ UI_PRESET_PRIVATE: "Private — click to make public",
325
+ UI_PRESET_SHARED_PUBLIC: "Public preset shared with everyone",
326
+ UI_PRESET_MARKED_DELETE: "Marked for deletion — click to undo",
327
+ UI_PRESET_MARK_DELETE: "Mark for deletion (applied on Save)",
328
+ UI_PRESET_UNSAVED: "unsaved changes",
329
+ UI_PRESET_SAVING: "Saving…",
330
+ UI_PRESET_CHANGES_FAILED: "{count} changes could not be saved.",
331
+ UI_AOOTH_COPY: "Copy",
332
+ UI_AOOTH_COPIED: "Copied",
333
+ UI_AOOTH_COPY_FAILED: "Copy failed — select and copy manually",
334
+ UI_AOOTH_QR_FAILED: "Failed to render QR code.",
335
+ UI_AOOTH_OR: "or",
336
+ UI_WF_STATUS_400: "The request was invalid. Please check your input and try again.",
337
+ UI_WF_STATUS_401: "You need to sign in to continue.",
338
+ UI_WF_STATUS_403: "You don't have permission to do that.",
339
+ UI_WF_STATUS_404: "We couldn't find what you're looking for.",
340
+ UI_WF_STATUS_408: "The request took too long. Please try again.",
341
+ UI_WF_STATUS_409: "There's a conflict with the current state. Please refresh and try again.",
342
+ UI_WF_STATUS_410: "This session has expired. Please start over.",
343
+ UI_WF_STATUS_422: "Some of the information you provided couldn't be processed.",
344
+ UI_WF_STATUS_423: "This account is temporarily locked. Please try again later.",
345
+ UI_WF_STATUS_429: "Too many requests. Please wait a moment and try again.",
346
+ UI_WF_STATUS_500: "Something went wrong on our end. Please try again in a moment.",
347
+ UI_WF_STATUS_502: "We're having trouble reaching the server. Please try again shortly.",
348
+ UI_WF_STATUS_503: "The service is temporarily unavailable. Please try again in a few minutes.",
349
+ UI_WF_STATUS_504: "The server took too long to respond. Please try again.",
350
+ UI_WF_REQUEST_FAILED: "Something went wrong with that request. Please try again.",
351
+ UI_WF_UNEXPECTED_RESPONSE: "Unexpected response from the server.",
352
+ UI_WF_UNEXPECTED_FORMAT: "Unexpected response format",
353
+ UI_WF_NETWORK_ERROR: "Network error",
354
+ UI_WF_REDIRECTING: "Redirecting…",
355
+ UI_WF_CONTINUING_IN: "Continuing in {seconds}…"
356
+ });
357
+ //#endregion
358
+ //#region src/wf-io/i18n.ts
359
+ /**
360
+ * The request's language for what a workflow serves: form schemas,
361
+ * validation errors and finish envelopes, translated with moost's
362
+ * translator (`setTranslator`).
363
+ */
364
+ registerMessages(VALIDATOR_MESSAGES);
365
+ registerMessages(AS_UI_MESSAGES);
366
+ /** The current event's translation, `undefined` without one (or outside an event). */
367
+ function currentTranslation() {
368
+ try {
369
+ return useTranslation();
370
+ } catch {
371
+ return;
372
+ }
373
+ }
374
+ /**
375
+ * Localized schemas per serialized schema, then per locale — each with the
376
+ * translation key it was made under. The key changes with every
377
+ * `setTranslator` / `registerMessages` generation: the locale's entry is then
378
+ * replaced, so a schema keeps one output per served locale.
379
+ */
380
+ const memo = /* @__PURE__ */ new WeakMap();
381
+ /**
382
+ * `schema` in the translation's language: its texts translated, `$i18n`
383
+ * holding the translated message templates and the translated literals of
384
+ * its expressions. The schema itself when nothing changes. Memoized per
385
+ * (schema, locale) for the translator's locales; computed per call otherwise.
386
+ */
387
+ function localizeSchema(schema, translation) {
388
+ const { key, locale } = translation;
389
+ if (key === void 0) return build(schema, translation);
390
+ let byLocale = memo.get(schema);
391
+ const hit = byLocale?.get(locale);
392
+ if (hit?.key === key) return hit.out;
393
+ const out = build(schema, translation);
394
+ if (!byLocale) memo.set(schema, byLocale = /* @__PURE__ */ new Map());
395
+ byLocale.set(locale, {
396
+ key,
397
+ out
398
+ });
399
+ return out;
400
+ }
401
+ function build(schema, translation) {
402
+ const { value, texts } = translateServed(schema, textTranslator(translation));
403
+ const messages = translation.messages();
404
+ const i18n = Object.keys(texts).length > 0 ? {
405
+ ...messages,
406
+ ...texts
407
+ } : messages;
408
+ return Object.keys(i18n).length > 0 ? {
409
+ ...value,
410
+ $i18n: i18n
411
+ } : value;
412
+ }
413
+ /** A text's translation, `undefined` when it has none (the source text is the id). */
414
+ function textTranslator(translation) {
415
+ return (text) => {
416
+ const out = translation.t(text, void 0, text);
417
+ return out === text ? void 0 : out;
418
+ };
419
+ }
420
+ /** `text` in the current event's language (the text itself without a translation). */
421
+ function translateText(text, params) {
422
+ const translation = currentTranslation();
423
+ return translation ? translation.t(text, params) : formatMessage(text, params);
424
+ }
425
+ //#endregion
59
426
  //#region src/wf-io/serialize.ts
60
427
  const schemaCache = /* @__PURE__ */ new WeakMap();
61
428
  /**
@@ -63,7 +430,9 @@ const schemaCache = /* @__PURE__ */ new WeakMap();
63
430
  *
64
431
  * Delegates to `serializeAnnotatedType` from `@atscript/typescript`,
65
432
  * stripping server-only `@wf.context.pass` annotations from the output.
66
- * Results are cached per type identity.
433
+ * Results are cached per type identity — and, translated, per type and
434
+ * locale (see {@link SerializeFormSchemaOpts.translate}). Without a
435
+ * translator the result is the same object for every request.
67
436
  *
68
437
  * FK fields ship with a shallow ref: the target's identity (`id`) and
69
438
  * interface-level `metadata` (including `db.http.path` when present) are
@@ -72,15 +441,17 @@ const schemaCache = /* @__PURE__ */ new WeakMap();
72
441
  * endpoints without dragging the full target tree onto the wire. See the
73
442
  * `wf-serialize-shallow-ref` design for rationale.
74
443
  */
75
- function serializeFormSchema(type) {
76
- const cached = schemaCache.get(type);
77
- if (cached) return cached;
78
- const schema = serializeAnnotatedType(type, {
79
- ignoreAnnotations: [WF_CONTEXT_PASS],
80
- refDepth: .5
81
- });
82
- schemaCache.set(type, schema);
83
- return schema;
444
+ function serializeFormSchema(type, opts) {
445
+ let schema = schemaCache.get(type);
446
+ if (!schema) {
447
+ schema = serializeAnnotatedType(type, {
448
+ ignoreAnnotations: [WF_CONTEXT_PASS],
449
+ refDepth: .5
450
+ });
451
+ schemaCache.set(type, schema);
452
+ }
453
+ const translation = opts?.translate === false ? void 0 : currentTranslation();
454
+ return translation ? localizeSchema(schema, translation) : schema;
84
455
  }
85
456
  //#endregion
86
457
  //#region ../ui/src/form/error-utils.ts
@@ -137,28 +508,26 @@ function getCachedValidator(type, opts) {
137
508
  function isValidatorError(err) {
138
509
  return err !== null && typeof err === "object" && "errors" in err && Array.isArray(err.errors);
139
510
  }
140
- function useAtscriptWf(type) {
511
+ function useAtscriptWf(type, opts) {
141
512
  const wfState = useWfState();
142
- function requireInput({ errors, formMessage } = {}) {
143
- const passContext = extractPassContext(type, wfState.ctx() ?? {});
144
- const mergedErrors = errors ? { ...errors } : formMessage ? {} : void 0;
145
- if (formMessage && mergedErrors) mergedErrors[FORM_ERROR_KEY] = formMessage;
146
- const context = mergedErrors ? {
147
- ...passContext,
148
- errors: mergedErrors
149
- } : { ...passContext };
150
- return new StepRetriableError(new Error(formMessage ?? "Input required"), void 0, {
151
- outlet: "http",
152
- payload: serializeFormSchema(type),
153
- context
154
- });
513
+ function requireInput(input = {}) {
514
+ const translation = currentTranslation();
515
+ let { errors, formMessage } = input;
516
+ if (translation) {
517
+ if (formMessage !== void 0) formMessage = translation.t(formMessage);
518
+ if (errors) errors = Object.fromEntries(Object.entries(errors).map(([path, message]) => [path, translation.t(message)]));
519
+ }
520
+ return inputRequired(type, opts, errors, formMessage);
155
521
  }
156
- function validateOrThrow(input, opts) {
157
- const validator = getCachedValidator(type, opts);
522
+ function validateOrThrow(input, validatorOpts) {
523
+ const validator = getCachedValidator(type, validatorOpts);
158
524
  try {
159
525
  validator.validate(input);
160
526
  } catch (err) {
161
- if (isValidatorError(err)) throw requireInput({ errors: validatorErrorsToMap(err.errors) });
527
+ if (isValidatorError(err)) {
528
+ const translation = currentTranslation();
529
+ throw inputRequired(type, opts, validatorErrorsToMap(translation ? localizeErrors(err.errors, (id, params, error) => translation.t(id, params, error.message)) : err.errors));
530
+ }
162
531
  throw err;
163
532
  }
164
533
  }
@@ -175,7 +544,7 @@ function useAtscriptWf(type) {
175
544
  const action = wfState.input()?.action;
176
545
  if (action === void 0) return void 0;
177
546
  const { actions, actionsWithData } = getFormActions(type);
178
- if (!actions.includes(action) && !actionsWithData.includes(action)) throw requireInput({ formMessage: `Action "${action}" is not supported` });
547
+ if (!actions.includes(action) && !actionsWithData.includes(action)) throw actionRefused(type, opts, "Action \"{action}\" is not supported", action);
179
548
  return action;
180
549
  }
181
550
  return {
@@ -184,6 +553,33 @@ function useAtscriptWf(type) {
184
553
  requireInput
185
554
  };
186
555
  }
556
+ /**
557
+ * The `StepRetriableError` refusing `action` with a built-in message: the
558
+ * `template` translated once here with its `{action}` param, then served as is.
559
+ *
560
+ * @internal Shared with `@WfInput`.
561
+ */
562
+ function actionRefused(type, opts, template, action) {
563
+ return inputRequired(type, opts, void 0, translateText(template, { action }));
564
+ }
565
+ /**
566
+ * The `StepRetriableError` asking for `type`'s form, with `errors` /
567
+ * `formMessage` as they are (already in the request's language).
568
+ */
569
+ function inputRequired(type, opts, errors, formMessage) {
570
+ const passContext = extractPassContext(type, useWfState().ctx() ?? {});
571
+ const mergedErrors = errors ? { ...errors } : formMessage ? {} : void 0;
572
+ if (formMessage && mergedErrors) mergedErrors[FORM_ERROR_KEY] = formMessage;
573
+ const context = mergedErrors ? {
574
+ ...passContext,
575
+ errors: mergedErrors
576
+ } : { ...passContext };
577
+ return new StepRetriableError(new Error(formMessage ?? "Input required"), void 0, {
578
+ outlet: "http",
579
+ payload: serializeFormSchema(type, opts),
580
+ context
581
+ });
582
+ }
187
583
  //#endregion
188
584
  //#region src/wf-io/wf-input.decorator.ts
189
585
  /**
@@ -198,6 +594,8 @@ function useAtscriptWf(type) {
198
594
  * `pass: true` opts the step into ignoring the no-data action.
199
595
  * - Unknown action → `StepRetriableError` (propagated from `resolveAction`).
200
596
  *
597
+ * `translate`: see {@link UseAtscriptWfOpts}.
598
+ *
201
599
  * @example
202
600
  * ```ts
203
601
  * @Step('login')
@@ -212,21 +610,23 @@ function WfInput(opts) {
212
610
  Resolve((metas) => {
213
611
  const type = metas?.targetMeta?.type;
214
612
  if (!type || !isAnnotatedType(type)) throw new Error("@WfInput(): no atscript type available on the parameter. Annotate the parameter with an atscript-derived type.");
215
- const wf = useAtscriptWf(type);
613
+ const form = type;
614
+ const wf = useAtscriptWf(form, opts);
615
+ const refuse = (template, action) => actionRefused(form, opts, template, action);
216
616
  const pass = opts?.pass === true;
217
617
  const action = wf.resolveAction();
218
618
  if (action) {
219
619
  const wfInput = useWfState().input()?.formData;
220
- const { actions, actionsWithData } = getFormActions(type);
620
+ const { actions, actionsWithData } = getFormActions(form);
221
621
  const isNoData = actions.includes(action);
222
622
  const isWithData = actionsWithData.includes(action);
223
623
  if (isNoData) {
224
- if (!pass) throw wf.requireInput({ formMessage: wfInput === void 0 ? `Action "${action}" requires no data but this step expects input` : `Action "${action}" requires no data; input not allowed here` });
225
- if (wfInput !== void 0) throw wf.requireInput({ formMessage: `Action "${action}" requires no data; input not allowed here` });
624
+ if (!pass) throw refuse(wfInput === void 0 ? "Action \"{action}\" requires no data but this step expects input" : "Action \"{action}\" requires no data; input not allowed here", action);
625
+ if (wfInput !== void 0) throw refuse("Action \"{action}\" requires no data; input not allowed here", action);
226
626
  return;
227
627
  }
228
628
  if (isWithData) {
229
- if (wfInput === void 0) throw wf.requireInput({ formMessage: `Action "${action}" expects input` });
629
+ if (wfInput === void 0) throw refuse("Action \"{action}\" expects input", action);
230
630
  return wf.resolveInput({ partial: "deep" });
231
631
  }
232
632
  }
@@ -246,7 +646,8 @@ function WfInput(opts) {
246
646
  * The form type is **required**: the decorator validates the action against
247
647
  * the form's declared `@ui.form.action` / `@wf.action.withData` whitelist and
248
648
  * throws `StepRetriableError` for any unknown action — the step body never
249
- * sees actions that aren't part of the form's contract.
649
+ * sees actions that aren't part of the form's contract. `translate`: see
650
+ * {@link UseAtscriptWfOpts}.
250
651
  *
251
652
  * @example
252
653
  * ```ts
@@ -260,10 +661,10 @@ function WfInput(opts) {
260
661
  * }
261
662
  * ```
262
663
  */
263
- function WfAction(type) {
664
+ function WfAction(type, opts) {
264
665
  return (target, key, index) => {
265
666
  if (typeof index !== "number") return;
266
- Resolve(() => useAtscriptWf(type).resolveAction(), "WfAction")(target, key, index);
667
+ Resolve(() => useAtscriptWf(type, opts).resolveAction(), "WfAction")(target, key, index);
267
668
  };
268
669
  }
269
670
  //#endregion
@@ -349,14 +750,51 @@ function isWfFinished(v) {
349
750
  return !!(v && typeof v === "object" && v.finished);
350
751
  }
351
752
  function setEnvelope(envelope) {
753
+ const translation = currentTranslation();
352
754
  useWfFinished().set({
353
755
  type: "data",
354
- value: envelope
756
+ value: translation ? translateEnvelope(envelope, translation.t) : envelope
355
757
  });
356
758
  }
357
759
  /**
760
+ * The envelope's user-facing texts in the request's language (each text is
761
+ * its own id): `message.text`, button labels and `skipButton.label`. The
762
+ * abort `reason` is a machine value (analytics) and stays as it is. A new
763
+ * envelope — the caller's objects (and `data`) stay as they are.
764
+ */
765
+ function translateEnvelope(envelope, t) {
766
+ const out = { ...envelope };
767
+ if (out.message) out.message = {
768
+ ...out.message,
769
+ text: t(out.message.text)
770
+ };
771
+ const next = out.next;
772
+ if (next?.trigger === "auto" && next.skipButton) out.next = {
773
+ ...next,
774
+ skipButton: {
775
+ ...next.skipButton,
776
+ label: t(next.skipButton.label)
777
+ }
778
+ };
779
+ else if (next?.trigger === "manual") {
780
+ const manual = { ...next };
781
+ if (manual.primary) manual.primary = translateButton(manual.primary, t);
782
+ if (manual.options) manual.options = manual.options.map((b) => translateButton(b, t));
783
+ out.next = manual;
784
+ }
785
+ return out;
786
+ }
787
+ function translateButton(button, t) {
788
+ return {
789
+ ...button,
790
+ label: t(button.label)
791
+ };
792
+ }
793
+ /**
358
794
  * Build a `WfFinished` envelope and hand it to wooks. All envelope
359
- * properties are optional; pass `data`, `message`, and/or `next`:
795
+ * properties are optional; pass `data`, `message`, and/or `next`.
796
+ * With moost's translator (`setTranslator`) the message text and button
797
+ * labels are sent in the request's language (each text is its own id):
360
798
  *
361
799
  * finishWf({ data: { id: 42 } });
362
800
  * finishWf({ message: { level: "success", text: "Saved." } });
package/dist/store.d.mts CHANGED
@@ -1,31 +1,7 @@
1
1
  import { TAtscriptAnnotatedType, TAtscriptTypeComplex, TAtscriptTypeObject, TMetadataMap, TValidatorOptions, Validator } from "@atscript/typescript/utils";
2
+ import { WfState, WfStateStore } from "@moostjs/event-wf";
2
3
  import { AtscriptDbTable } from "@atscript/db";
3
4
 
4
- //#region ../../node_modules/.pnpm/@prostojs+wf@0.3.0/node_modules/@prostojs/wf/dist/types-DQ7U9zZ5.d.mts
5
- interface TFlowState<T> {
6
- schemaId: string;
7
- context: T;
8
- indexes: number[];
9
- meta?: Record<string, unknown>;
10
- }
11
- //#endregion
12
- //#region ../../node_modules/.pnpm/@prostojs+wf@0.3.0/node_modules/@prostojs/wf/dist/store-B_dDk2EG.d.mts
13
- //#region src/outlets/types.d.ts
14
- type WfState = TFlowState<unknown>;
15
- //#endregion
16
- //#region src/outlets/state/store.d.ts
17
- interface WfStateStoreEntry {
18
- state: WfState;
19
- expiresAt?: number;
20
- }
21
- interface WfStateStore {
22
- set(handle: string, state: WfState, expiresAt?: number): Promise<void>;
23
- get(handle: string): Promise<WfStateStoreEntry | null>;
24
- delete(handle: string): Promise<void>;
25
- getAndDelete(handle: string): Promise<WfStateStoreEntry | null>;
26
- cleanup?(): Promise<number>;
27
- } //#endregion
28
- //#endregion
29
5
  //#region src/store/wf-store.d.ts
30
6
  /** Internal row shape — only the columns the store reads back from the table. */
31
7
  type StoredRow = {
@@ -49,7 +25,7 @@ interface ShadowFieldSpec {
49
25
  /**
50
26
  * Options for {@link AsWfStore}.
51
27
  *
52
- * The store implements `WfStateStore` from `@prostojs/wf/outlets` against a
28
+ * The store implements the engine's `WfStateStore` (via `@moostjs/event-wf`) against a
53
29
  * consumer-provided `AtscriptDbTable` whose row shape extends
54
30
  * `AsWfStateRecord` with their own `@meta.id`-bearing primary key column.
55
31
  */
package/dist/store.mjs CHANGED
@@ -280,9 +280,9 @@ var AsWfStateRecord = class {
280
280
  throwFeatureDisabled("JSON Schema", "jsonSchema", "emit.jsonSchema");
281
281
  }
282
282
  };
283
- $ak("db.index.fulltext", "db.index.plain", "db.index.unique", "db.view.joins", "expect.pattern", "ui.dict.attr", "ui.form.classes", "ui.form.styles", "ui.literalLabel", "ui.table.classes", "ui.table.selectWith", "ui.table.styles", "wf.context.pass");
284
- $nr("db.agg.avg", "db.agg.count", "db.agg.countDistinct", "db.agg.max", "db.agg.min", "db.agg.sum", "db.alias", "db.amount.currency.ref", "db.column", "db.column.collate", "db.column.derived", "db.column.dimension", "db.column.filterable", "db.column.measure", "db.column.precision", "db.column.renamed", "db.column.searchable", "db.column.sortable", "db.column.version", "db.column.version.exempt", "db.compute", "db.default", "db.default.increment", "db.default.now", "db.default.uuid", "db.depth.limit", "db.encrypted", "db.http.path", "db.ignore", "db.index.fulltext", "db.index.geo", "db.index.plain", "db.index.unique", "db.json", "db.onUpdate.inc", "db.onUpdate.now", "db.patch.strategy", "db.rel.FK", "db.rel.filter", "db.rel.filterable", "db.rel.from", "db.rel.onDelete", "db.rel.onUpdate", "db.rel.to", "db.rel.via", "db.schema", "db.search.filter", "db.search.vector", "db.search.vector.threshold", "db.sort.nulls", "db.space", "db.sync.method", "db.table", "db.table.filterable", "db.table.preferredId.uniqueIndex", "db.table.renamed", "db.table.sortable", "db.unit.ref", "db.view", "db.view.filter", "db.view.for", "db.view.having", "db.view.joins", "db.view.materialized", "db.view.renamed", "db.writeOnly", "meta.default", "meta.id", "meta.readonly", "meta.required", "ui.dict.attr", "ui.dict.descr", "ui.dict.filterable", "ui.dict.label", "ui.dict.searchable", "ui.dict.sortable", "ui.form.disabled", "ui.form.hidden", "ui.form.order", "ui.form.prefix.ref", "ui.form.suffix.ref", "ui.nav.group", "ui.nav.hidden", "ui.nav.order", "ui.table.exclude", "ui.table.order", "ui.table.selectWith", "wf.store.fromContext");
283
+ $ak("db.index.fulltext", "db.index.fulltext.language", "db.index.fulltext.match", "db.index.plain", "db.index.unique", "db.view.joins", "expect.pattern", "ui.dict.attr", "ui.form.classes", "ui.form.styles", "ui.literalLabel", "ui.table.classes", "ui.table.selectWith", "ui.table.styles", "wf.context.pass");
284
+ $nr("db.agg.avg", "db.agg.count", "db.agg.countDistinct", "db.agg.max", "db.agg.min", "db.agg.sum", "db.alias", "db.amount.currency.ref", "db.column", "db.column.collate", "db.column.derived", "db.column.dimension", "db.column.filterable", "db.column.measure", "db.column.precision", "db.column.renamed", "db.column.searchable", "db.column.sortable", "db.column.version", "db.column.version.exempt", "db.compute", "db.default", "db.default.increment", "db.default.now", "db.default.uuid", "db.depth.limit", "db.encrypted", "db.http.path", "db.ignore", "db.index.fulltext", "db.index.fulltext.language", "db.index.fulltext.match", "db.index.geo", "db.index.plain", "db.index.unique", "db.json", "db.onUpdate.inc", "db.onUpdate.now", "db.patch.strategy", "db.rel.FK", "db.rel.filter", "db.rel.filterable", "db.rel.from", "db.rel.onDelete", "db.rel.onUpdate", "db.rel.to", "db.rel.via", "db.schema", "db.search.filter", "db.search.vector", "db.search.vector.threshold", "db.sort.nulls", "db.space", "db.sync.method", "db.table", "db.table.filterable", "db.table.preferredId.uniqueIndex", "db.table.renamed", "db.table.sortable", "db.unit.ref", "db.view", "db.view.filter", "db.view.for", "db.view.having", "db.view.joins", "db.view.materialized", "db.view.renamed", "db.writeOnly", "meta.default", "meta.id", "meta.readonly", "meta.required", "ui.dict.attr", "ui.dict.descr", "ui.dict.filterable", "ui.dict.label", "ui.dict.searchable", "ui.dict.sortable", "ui.form.disabled", "ui.form.hidden", "ui.form.order", "ui.form.prefix.ref", "ui.form.suffix.ref", "ui.nav.group", "ui.nav.hidden", "ui.nav.order", "ui.table.exclude", "ui.table.order", "ui.table.selectWith", "wf.store.fromContext");
285
285
  defineAnnotatedType("union", JsonValue).item(defineAnnotatedType().designType("string").tags("string").$type).item(defineAnnotatedType().designType("number").tags("number").$type).item(defineAnnotatedType().designType("boolean").tags("boolean").$type).item(defineAnnotatedType().designType("null").tags("null").$type).item(defineAnnotatedType("array").of(defineAnnotatedType().ref(JsonValue).$type).$type).item(defineAnnotatedType("object").propPattern(/^.+$/, defineAnnotatedType().ref(JsonValue).$type).$type);
286
- defineAnnotatedType("object", AsWfStateRecord).prop("handle", defineAnnotatedType().designType("string").tags("string").annotate("ui.table.exclude", true).annotate("db.index.unique", "handle_idx", true).annotate("expect.maxLength", { length: 256 }).$type).prop("schemaId", defineAnnotatedType().designType("string").tags("string").annotate("db.index.plain", { name: "schema_idx" }, true).annotate("expect.maxLength", { length: 256 }).$type).prop("state", defineAnnotatedType("object").prop("context", defineAnnotatedType().ref(JsonValue).$type).prop("indexes", defineAnnotatedType("array").of(defineAnnotatedType().designType("number").tags("number").$type).$type).prop("meta", defineAnnotatedType("object").propPattern(/^.+$/, defineAnnotatedType().ref(JsonValue).$type).optional().$type).annotate("ui.table.exclude", true).annotate("db.json", true).$type).prop("expiresAt", defineAnnotatedType().designType("number").tags("timestamp", "number").annotate("db.index.plain", { name: "expires_idx" }, true).annotate("expect.int", true).optional().$type).prop("updatedAt", defineAnnotatedType().designType("number").tags("timestamp", "number").annotate("db.default.now", true).annotate("db.index.plain", { name: "updated_idx" }, true).annotate("expect.int", true).$type).prop("createdAt", defineAnnotatedType().designType("number").tags("timestamp", "number").annotate("expect.int", true).$type).prop("createdBy", defineAnnotatedType().designType("string").tags("string").annotate("ui.table.exclude", true).annotate("expect.maxLength", { length: 128 }).optional().$type).prop("lastUpdatedBy", defineAnnotatedType().designType("string").tags("string").annotate("ui.table.exclude", true).annotate("expect.maxLength", { length: 128 }).optional().$type);
286
+ defineAnnotatedType("object", AsWfStateRecord).prop("handle", defineAnnotatedType().designType("string").tags("string").annotate("ui.table.exclude", true).annotate("db.index.unique", "handle_idx", true).annotate("expect.maxLength", { length: 256 }).$type).prop("schemaId", defineAnnotatedType().designType("string").tags("string").annotate("db.index.plain", { name: "schema_idx" }, true).annotate("expect.maxLength", { length: 256 }).$type).prop("state", defineAnnotatedType("object").prop("context", defineAnnotatedType().ref(JsonValue).$type).prop("indexes", defineAnnotatedType("array").of(defineAnnotatedType().designType("number").tags("number").$type).$type).prop("meta", defineAnnotatedType("object").propPattern(/^.+$/, defineAnnotatedType().ref(JsonValue).$type).optional().$type).annotate("ui.table.exclude", true).annotate("db.json", true).$type).prop("expiresAt", defineAnnotatedType().designType("number").tags("timestamp", "number").annotate("db.index.plain", { name: "expires_idx" }, true).annotate("expect.int", {}).optional().$type).prop("updatedAt", defineAnnotatedType().designType("number").tags("timestamp", "number").annotate("db.default.now", true).annotate("db.index.plain", { name: "updated_idx" }, true).annotate("expect.int", {}).$type).prop("createdAt", defineAnnotatedType().designType("number").tags("timestamp", "number").annotate("expect.int", {}).$type).prop("createdBy", defineAnnotatedType().designType("string").tags("string").annotate("ui.table.exclude", true).annotate("expect.maxLength", { length: 128 }).optional().$type).prop("lastUpdatedBy", defineAnnotatedType().designType("string").tags("string").annotate("ui.table.exclude", true).annotate("expect.maxLength", { length: 128 }).optional().$type);
287
287
  //#endregion
288
288
  export { AsWfStateRecord, AsWfStore };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/moost-wf",
3
- "version": "0.1.163",
3
+ "version": "0.1.165",
4
4
  "description": "Workflow form integration for moost — decorators, interceptors, and serialization driven by atscript type metadata",
5
5
  "keywords": [
6
6
  "atscript",
@@ -56,30 +56,36 @@
56
56
  "access": "public"
57
57
  },
58
58
  "devDependencies": {
59
- "@atscript/core": "^0.2.3",
60
- "@atscript/db": "^0.1.167",
61
- "@atscript/db-sql-tools": "^0.1.167",
62
- "@atscript/db-sqlite": "^0.1.167",
63
- "@atscript/typescript": "^0.2.3",
64
- "@moostjs/event-wf": "^0.7.1",
59
+ "@atscript/core": "^0.2.7",
60
+ "@atscript/db": "^0.1.170",
61
+ "@atscript/db-sql-tools": "^0.1.170",
62
+ "@atscript/db-sqlite": "^0.1.170",
63
+ "@atscript/typescript": "^0.2.7",
64
+ "@moostjs/event-wf": "^0.7.3",
65
65
  "@prostojs/wf": "^0.3.0",
66
- "@uniqu/core": "^0.1.15",
67
- "@wooksjs/event-core": "^0.8.0",
68
- "@wooksjs/event-http": "^0.8.0",
69
- "@wooksjs/event-wf": "^0.8.0",
70
- "@wooksjs/http-body": "^0.8.0",
71
- "moost": "^0.7.1",
72
- "unplugin-atscript": "^0.2.3",
66
+ "@uniqu/core": "^0.2.1",
67
+ "@wooksjs/event-core": "^0.8.1",
68
+ "@wooksjs/event-http": "^0.8.1",
69
+ "@wooksjs/event-wf": "^0.8.1",
70
+ "@wooksjs/http-body": "^0.8.1",
71
+ "moost": "^0.7.3",
72
+ "unplugin-atscript": "^0.2.7",
73
73
  "vitest": "npm:@voidzero-dev/vite-plus-test@0.1.14",
74
- "@atscript/ui": "^0.1.163"
74
+ "@atscript/ui": "^0.1.165"
75
75
  },
76
76
  "peerDependencies": {
77
- "@atscript/core": "^0.2.3",
78
- "@atscript/typescript": "^0.2.3",
79
- "@moostjs/event-wf": "^0.7.1",
80
- "@wooksjs/event-core": "^0.8.0",
81
- "@wooksjs/event-wf": "^0.8.0",
82
- "moost": "^0.7.1"
77
+ "@atscript/core": "^0.2.7",
78
+ "@atscript/db": "^0.1.170",
79
+ "@atscript/typescript": "^0.2.7",
80
+ "@moostjs/event-wf": "^0.7.3",
81
+ "@wooksjs/event-core": "^0.8.1",
82
+ "@wooksjs/event-wf": "^0.8.1",
83
+ "moost": "^0.7.3"
84
+ },
85
+ "peerDependenciesMeta": {
86
+ "@atscript/db": {
87
+ "optional": true
88
+ }
83
89
  },
84
90
  "scripts": {
85
91
  "build": "vp pack",