@marianmeres/collection-types 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,54 @@
1
+ /**
2
+ * Inbox message type definitions for the `@marianmeres/stack-inbox` notification inbox.
3
+ *
4
+ * Usage with Model:
5
+ * ```typescript
6
+ * import type { Model, InboxMessageData } from "@marianmeres/collection-types";
7
+ * type InboxMessageModel = Model<InboxMessageData>;
8
+ * ```
9
+ */
10
+ /** Discriminator for how a message's content is rendered. */
11
+ export type InboxContentType = "typed" | "freeform";
12
+ /** Origin of a message. */
13
+ export type InboxSenderKind = "system" | "user";
14
+ /** Relative importance; reserved for future prioritized/pinned rendering. */
15
+ export type InboxPriority = "low" | "normal" | "high";
16
+ /**
17
+ * One recipient's own copy of a notification (denormalized model). The collection
18
+ * is owner-scoped: `owner_id` (a collection column, NOT a data field) is the
19
+ * recipient account id. Broadcasts materialize one row per recipient, all sharing
20
+ * the same `broadcast_id`.
21
+ */
22
+ export interface InboxMessageData {
23
+ /**
24
+ * "typed" => render from i18n `template` + `template_data`;
25
+ * "freeform" => show `title`/`body` verbatim.
26
+ */
27
+ content_type: InboxContentType;
28
+ /** i18n key base, e.g. "order_processed" → console renders `inbox.msg.order_processed.{title,body}`. */
29
+ template?: string;
30
+ /** Interpolation values for the typed template. */
31
+ template_data?: Record<string, unknown>;
32
+ /** Freeform title (as authored). */
33
+ title?: string;
34
+ /** Freeform body (as authored). */
35
+ body?: string;
36
+ /** Author's language tag (display hint only; freeform is not translated). */
37
+ lang?: string;
38
+ /** Sender account id; `null` for system-originated messages. */
39
+ sender_id?: string | null;
40
+ /** "system" (automated) or "user" (a person sent it). */
41
+ sender_kind: InboxSenderKind;
42
+ /** Groups all per-recipient copies of one logical send (recall/edit seam). */
43
+ broadcast_id?: string | null;
44
+ /** Reserved; minimal use in v1. */
45
+ priority?: InboxPriority;
46
+ /** Optional auto-expiry (ISO 8601). Expired messages are hidden from the inbox. */
47
+ expires_at?: string | null;
48
+ /** ISO timestamp when the recipient marked it read; null/absent = unread. */
49
+ read_at?: string | null;
50
+ /** ISO timestamp when the recipient archived it; null/absent = in the inbox. */
51
+ archived_at?: string | null;
52
+ /** Index signature for `Model<T>` compatibility. */
53
+ [key: string]: unknown;
54
+ }
package/dist/inbox.js ADDED
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Inbox message type definitions for the `@marianmeres/stack-inbox` notification inbox.
3
+ *
4
+ * Usage with Model:
5
+ * ```typescript
6
+ * import type { Model, InboxMessageData } from "@marianmeres/collection-types";
7
+ * type InboxMessageModel = Model<InboxMessageData>;
8
+ * ```
9
+ */
10
+ export {};
package/dist/mod.d.ts CHANGED
@@ -47,6 +47,7 @@ export * from "./country.js";
47
47
  export * from "./template.js";
48
48
  export * from "./email.js";
49
49
  export * from "./example.js";
50
+ export * from "./inbox.js";
50
51
  export * from "./schema-builder.js";
51
52
  export * from "./navigation.js";
52
53
  export * from "./form-routes.js";
package/dist/mod.js CHANGED
@@ -63,6 +63,8 @@ export * from "./template.js";
63
63
  export * from "./email.js";
64
64
  // Example domain types (reference implementation)
65
65
  export * from "./example.js";
66
+ // Inbox domain types (notification inbox)
67
+ export * from "./inbox.js";
66
68
  // Schema builder utilities (type-safe schema definitions)
67
69
  export * from "./schema-builder.js";
68
70
  // Navigation types (admin UI)
package/dist/order.d.ts CHANGED
@@ -12,7 +12,10 @@
12
12
  import type { AddressData } from "./customer.js";
13
13
  import type { UUID } from "./utils.js";
14
14
  /** Order status progression */
15
- export type OrderStatus = "pending" | "paid" | "processing" | "shipped" | "delivered" | "cancelled";
15
+ export type OrderStatus = "pending" | "paid" | "processing" | "shipped" | "delivered" | "cancelled"
16
+ /** System-set by the abandoned-checkout maintenance sweep (never via the
17
+ * customer/admin transition API); a terminal, off-sequence state. */
18
+ | "abandoned";
16
19
  /** Checkout stages for tracking progress */
17
20
  export type CheckoutStage = "cart" | "addresses" | "delivery" | "confirm" | "payment" | "complete";
18
21
  /** Single order line item (snapshot at purchase time) */
package/dist/payment.d.ts CHANGED
@@ -59,6 +59,10 @@ export interface PaymentIntent {
59
59
  export interface PaymentResult {
60
60
  /** Provider reference ID */
61
61
  provider_reference: string;
62
+ /** Optional provider verification summary (e.g. PayPal payer email/id,
63
+ * capture status, seller-protection eligibility) surfaced for admin review.
64
+ * Provider-specific keys; undefined when the provider supplies none. */
65
+ verification?: Record<string, unknown>;
62
66
  }
63
67
  /**
64
68
  * Result of a refund operation.
@@ -29,6 +29,13 @@ export type ObjectSchema<T> = {
29
29
  _searchable?: boolean;
30
30
  /** Virtual form-only fields (not persisted, excluded from DB validation) */
31
31
  _extra_form_fields?: Record<string, PropertyDefinition>;
32
+ /**
33
+ * Admin list-view hint: append these top-level model timestamp columns to the
34
+ * DataTable (rendered from the model row, not `data.*`). Operational
35
+ * collections (orders, invoices, …) typically want "when was this placed /
36
+ * last touched" in the list.
37
+ */
38
+ _data_table_dates?: ("_created_at" | "_updated_at")[];
32
39
  };
33
40
  /** Extended schema (loose typing for __extends patterns) */
34
41
  export type ExtendedSchema = {
package/dist/schema.d.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
  import type { MaybeLocalized } from "./utils.js";
6
6
  /** HTML field type for UI rendering */
7
- export type SchemaHtmlType = "text" | "textarea" | "wysiwyg" | "markdown" | "number" | "boolean" | "checkbox" | "parent" | "object" | "select" | "multiselect" | "date" | "datetime" | "time" | "color" | "relation" | "asset" | "json" | "code" | "keyvalues" | "password";
7
+ export type SchemaHtmlType = "text" | "textarea" | "wysiwyg" | "markdown" | "number" | "money" | "boolean" | "checkbox" | "parent" | "object" | "select" | "status" | "multiselect" | "date" | "datetime" | "time" | "color" | "relation" | "asset" | "json" | "code" | "keyvalues" | "password";
8
8
  /** Configuration for relation-type fields in schema */
9
9
  export interface RelationTypeConfig {
10
10
  relation_type: string;
@@ -22,11 +22,13 @@ export interface AssetTypeConfig {
22
22
  maxSize?: number;
23
23
  variants?: string[];
24
24
  }
25
- /** Configuration for select/multiselect fields */
25
+ /** Configuration for select/multiselect/status fields */
26
26
  export interface SelectConfig {
27
+ /** `intent` (status fields) carries the per-value badge color. */
27
28
  options: Array<{
28
29
  value: string;
29
30
  label: string;
31
+ intent?: string;
30
32
  }>;
31
33
  multiple?: boolean;
32
34
  }
@@ -37,12 +39,30 @@ export interface KeyValuesConfig {
37
39
  addLabel?: string;
38
40
  emptyMessage?: string;
39
41
  }
42
+ /**
43
+ * Configuration for `money` fields (`_html.type: "money"`).
44
+ *
45
+ * The value is stored as an INTEGER number of minor units (e.g. cents) — the
46
+ * JSON Schema `type` should be `"integer"`. The UI displays/edits it as a major
47
+ * unit decimal (e.g. dollars): display = stored / `scale`, input = entered *
48
+ * `scale` (rounded). Keeping this in the schema makes "this field is money"
49
+ * authoritative for every surface (list display, form input, import transform)
50
+ * instead of guessing from the field name.
51
+ */
52
+ export interface MoneyConfig {
53
+ /** Minor units per major unit. Default 100 (cents → dollars). */
54
+ scale?: number;
55
+ /** Decimal places to display. Default 2. */
56
+ decimals?: number;
57
+ /** Optional ISO currency code, for surfaces that render a symbol (e.g. "USD"). */
58
+ currency?: string;
59
+ }
40
60
  /** Configuration for _html schema keyword */
41
61
  export interface SchemaHtmlConfig {
42
62
  /** Field type for UI rendering */
43
63
  type?: SchemaHtmlType;
44
64
  /** Type-specific configuration */
45
- _type_config?: RelationTypeConfig | AssetTypeConfig | SelectConfig | KeyValuesConfig;
65
+ _type_config?: RelationTypeConfig | AssetTypeConfig | SelectConfig | KeyValuesConfig | MoneyConfig;
46
66
  /** Display label (can be localized) */
47
67
  label?: MaybeLocalized<string>;
48
68
  /** Display description (can be localized) */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marianmeres/collection-types",
3
- "version": "2.0.0",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "main": "dist/mod.js",
6
6
  "types": "dist/mod.d.ts",