@voyant-travel/core 0.109.0 → 0.110.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/custom-fields.d.ts +149 -0
- package/dist/custom-fields.d.ts.map +1 -0
- package/dist/custom-fields.js +196 -0
- package/dist/custom-fields.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom fields — a typed, validated, visibility-aware extension-field registry
|
|
3
|
+
* for core entities (consolidated-deployments RFC, the "20%": custom fields
|
|
4
|
+
* without forking).
|
|
5
|
+
*
|
|
6
|
+
* The common client ask is "add a few fields to bookings / people / products".
|
|
7
|
+
* The free-form `metadata` jsonb most entities already carry is the unstructured
|
|
8
|
+
* escape hatch (Medusa's model); this registry turns a *declared* subset of that
|
|
9
|
+
* space into fields that are:
|
|
10
|
+
* - **validated** on write (type / required / options / custom rule),
|
|
11
|
+
* - **visibility-aware** — each field declares whether it surfaces in exports,
|
|
12
|
+
* invoices, and search, so those readers can consult the registry instead of
|
|
13
|
+
* dumping or hiding everything,
|
|
14
|
+
* - **PII-aware** — flagged fields can be encrypted at rest / redacted in logs.
|
|
15
|
+
*
|
|
16
|
+
* The registry is **deployment config**: a deployment declares its fields (often
|
|
17
|
+
* discovered from `src/custom-fields/*` via {@link customFieldsFromGlob}) and the
|
|
18
|
+
* framework injects the registry into the services that read/write entities.
|
|
19
|
+
* This module is intentionally dependency-free (no zod / drizzle) so it can live
|
|
20
|
+
* in `@voyant-travel/core` and be imported anywhere.
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* The supported types a custom field can hold — the canonical superset across
|
|
24
|
+
* code-declared and runtime (DB-defined) fields (see the custom-fields
|
|
25
|
+
* unification ADR). Runtime equivalents map in: `varchar`→`text`, `double`→
|
|
26
|
+
* `number`, `enum`→`select`, `set`→`multiselect`, `address`/`phone`→`json`.
|
|
27
|
+
*/
|
|
28
|
+
export type CustomFieldType = "text" | "number" | "boolean" | "date"
|
|
29
|
+
/** One of `options`. */
|
|
30
|
+
| "select"
|
|
31
|
+
/** A subset of `options`, stored as `string[]`. */
|
|
32
|
+
| "multiselect"
|
|
33
|
+
/** Money as `{ amountCents: number, currency: string }` (ISO-4217). */
|
|
34
|
+
| "monetary"
|
|
35
|
+
/** Arbitrary JSON (object/array) — also the home for `address`/`phone`. */
|
|
36
|
+
| "json";
|
|
37
|
+
/** A monetary custom-field value: integer minor units + an ISO-4217 currency. */
|
|
38
|
+
export interface CustomFieldMonetaryValue {
|
|
39
|
+
amountCents: number;
|
|
40
|
+
currency: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Per-channel visibility. Defaults (when a channel is unset) are deliberately
|
|
44
|
+
* conservative: visible in exports, hidden from invoices and search.
|
|
45
|
+
*/
|
|
46
|
+
export interface CustomFieldVisibility {
|
|
47
|
+
/** Surface in data exports (CSV/JSON). Default `true`. */
|
|
48
|
+
export?: boolean;
|
|
49
|
+
/** Render on generated invoices. Default `false` (invoices are customer-facing). */
|
|
50
|
+
invoice?: boolean;
|
|
51
|
+
/** Index for search. Default `false`. */
|
|
52
|
+
search?: boolean;
|
|
53
|
+
}
|
|
54
|
+
/** A single custom-field declaration attached to one entity. */
|
|
55
|
+
export interface CustomFieldDefinition {
|
|
56
|
+
/** Entity the field attaches to, e.g. `"booking"`, `"person"`, `"product"`. */
|
|
57
|
+
entity: string;
|
|
58
|
+
/** Stable key within the entity's custom-field namespace (typo-proof). */
|
|
59
|
+
key: string;
|
|
60
|
+
type: CustomFieldType;
|
|
61
|
+
/** Human label — an i18n key or literal. */
|
|
62
|
+
label: string;
|
|
63
|
+
/** Reject writes that omit this field. Default `false`. */
|
|
64
|
+
required?: boolean;
|
|
65
|
+
/** Allowed values for `type: "select"`. */
|
|
66
|
+
options?: ReadonlyArray<string>;
|
|
67
|
+
/** Sensitive data — the deployment should encrypt at rest / redact in logs. */
|
|
68
|
+
pii?: boolean;
|
|
69
|
+
visibility?: CustomFieldVisibility;
|
|
70
|
+
/**
|
|
71
|
+
* Extra validation beyond type/required/options. Return an error message to
|
|
72
|
+
* reject, or `null` to accept. Runs only when a value is present.
|
|
73
|
+
*/
|
|
74
|
+
validate?: (value: unknown) => string | null;
|
|
75
|
+
}
|
|
76
|
+
/** Identity helper for authoring a field with full type-checking. */
|
|
77
|
+
export declare function defineCustomField<T extends CustomFieldDefinition>(definition: T): T;
|
|
78
|
+
/** A resolved, indexed set of custom-field declarations. */
|
|
79
|
+
export interface CustomFieldRegistry {
|
|
80
|
+
/** All fields declared for `entity`, in declaration order. */
|
|
81
|
+
forEntity(entity: string): CustomFieldDefinition[];
|
|
82
|
+
/** A single field by `(entity, key)`, or `undefined`. */
|
|
83
|
+
field(entity: string, key: string): CustomFieldDefinition | undefined;
|
|
84
|
+
/** Entities that have at least one field. */
|
|
85
|
+
entities(): string[];
|
|
86
|
+
/** Every declared field. */
|
|
87
|
+
all(): CustomFieldDefinition[];
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Resolve the registry for a request. The unified system's definitions come
|
|
91
|
+
* from two sources (code-declared + the runtime `custom_field_definitions`
|
|
92
|
+
* table), and the runtime set is read from the DB — so the registry is resolved
|
|
93
|
+
* per request from a `db` handle rather than being a boot-time constant. `db` is
|
|
94
|
+
* `unknown` to keep `core` free of a Drizzle dependency; the deployment's
|
|
95
|
+
* resolver casts it. See the custom-fields unification ADR.
|
|
96
|
+
*/
|
|
97
|
+
export type CustomFieldRegistryResolver = (db: unknown) => CustomFieldRegistry | Promise<CustomFieldRegistry>;
|
|
98
|
+
/**
|
|
99
|
+
* Build a {@link CustomFieldRegistry} from declarations. Throws on a duplicate
|
|
100
|
+
* `(entity, key)` — a collision is a config bug, not something to resolve
|
|
101
|
+
* silently.
|
|
102
|
+
*/
|
|
103
|
+
export declare function createCustomFieldRegistry(definitions: ReadonlyArray<CustomFieldDefinition>): CustomFieldRegistry;
|
|
104
|
+
/**
|
|
105
|
+
* Merge custom-field declarations from several sources into one duplicate-free
|
|
106
|
+
* list (feed it to {@link createCustomFieldRegistry}). On a `(entity, key)`
|
|
107
|
+
* collision the **earlier** source wins — pass code-declared fields before
|
|
108
|
+
* runtime/DB-defined ones so the framework contract is authoritative. The
|
|
109
|
+
* `onShadow` callback (if given) is notified of each dropped collision.
|
|
110
|
+
*
|
|
111
|
+
* The unification's single registry is built as
|
|
112
|
+
* `createCustomFieldRegistry(mergeCustomFieldDefinitions(codeFields, dbFields))`.
|
|
113
|
+
*/
|
|
114
|
+
export declare function mergeCustomFieldDefinitions(sources: ReadonlyArray<ReadonlyArray<CustomFieldDefinition>>, onShadow?: (shadowed: CustomFieldDefinition, winner: CustomFieldDefinition) => void): CustomFieldDefinition[];
|
|
115
|
+
/** Fields of `entity` visible in `channel` (export / invoice / search). */
|
|
116
|
+
export declare function customFieldsVisibleIn(registry: CustomFieldRegistry, entity: string, channel: keyof CustomFieldVisibility): CustomFieldDefinition[];
|
|
117
|
+
/** One field's validation failure. */
|
|
118
|
+
export interface CustomFieldError {
|
|
119
|
+
key: string;
|
|
120
|
+
message: string;
|
|
121
|
+
}
|
|
122
|
+
/** The outcome of {@link validateCustomFields}. */
|
|
123
|
+
export interface CustomFieldValidationResult {
|
|
124
|
+
ok: boolean;
|
|
125
|
+
/** Validated values, unknown/absent keys dropped. Only meaningful when `ok`. */
|
|
126
|
+
value: Record<string, unknown>;
|
|
127
|
+
errors: CustomFieldError[];
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Validate a custom-fields payload for `entity` against the registry. Unknown
|
|
131
|
+
* keys are rejected (typo-proofing), missing required fields error, present
|
|
132
|
+
* values are type/options/custom-rule checked. `null`/`undefined` values for a
|
|
133
|
+
* non-required field are treated as "omitted". Returns the cleaned value and any
|
|
134
|
+
* errors — callers persist `value` (e.g. into the entity's `custom_fields` or
|
|
135
|
+
* `metadata` jsonb) only when `ok`.
|
|
136
|
+
*/
|
|
137
|
+
export declare function validateCustomFields(registry: CustomFieldRegistry, entity: string, input: Record<string, unknown> | null | undefined): CustomFieldValidationResult;
|
|
138
|
+
/**
|
|
139
|
+
* Discover deployment-local custom-field declarations from a Vite
|
|
140
|
+
* `import.meta.glob` (eager) of `src/custom-fields/*.ts` files — the custom-field
|
|
141
|
+
* half of the "extend without forking" seam (mirrors `modulesFromGlob` etc.).
|
|
142
|
+
* Each file's `default` export is a {@link CustomFieldDefinition} or an array of
|
|
143
|
+
* them; the results flatten into one list to feed
|
|
144
|
+
* {@link createCustomFieldRegistry}. Empty until a deployment adds one.
|
|
145
|
+
*
|
|
146
|
+
* @throws if a matched file has no default export.
|
|
147
|
+
*/
|
|
148
|
+
export declare function customFieldsFromGlob(glob: Record<string, unknown>): CustomFieldDefinition[];
|
|
149
|
+
//# sourceMappingURL=custom-fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-fields.d.ts","sourceRoot":"","sources":["../src/custom-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,QAAQ,GACR,SAAS,GACT,MAAM;AACR,wBAAwB;GACtB,QAAQ;AACV,mDAAmD;GACjD,aAAa;AACf,uEAAuE;GACrE,UAAU;AACZ,2EAA2E;GACzE,MAAM,CAAA;AAEV,iFAAiF;AACjF,MAAM,WAAW,wBAAwB;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACpC,0DAA0D;IAC1D,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,oFAAoF;IACpF,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,yCAAyC;IACzC,MAAM,CAAC,EAAE,OAAO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BAAgB,2BAA2B,CACzC,OAAO,EAAE,aAAa,CAAC,aAAa,CAAC,qBAAqB,CAAC,CAAC,EAC5D,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,qBAAqB,EAAE,MAAM,EAAE,qBAAqB,KAAK,IAAI,GAClF,qBAAqB,EAAE,CAczB;AAED,2EAA2E;AAC3E,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,mBAAmB,EAC7B,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,qBAAqB,GACnC,qBAAqB,EAAE,CAIzB;AAED,sCAAsC;AACtC,MAAM,WAAW,gBAAgB;IAC/B,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,mDAAmD;AACnD,MAAM,WAAW,2BAA2B;IAC1C,EAAE,EAAE,OAAO,CAAA;IACX,gFAAgF;IAChF,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,MAAM,EAAE,gBAAgB,EAAE,CAAA;CAC3B;AAiDD;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,mBAAmB,EAC7B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,GAChD,2BAA2B,CAoC7B;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,qBAAqB,EAAE,CAe3F"}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom fields — a typed, validated, visibility-aware extension-field registry
|
|
3
|
+
* for core entities (consolidated-deployments RFC, the "20%": custom fields
|
|
4
|
+
* without forking).
|
|
5
|
+
*
|
|
6
|
+
* The common client ask is "add a few fields to bookings / people / products".
|
|
7
|
+
* The free-form `metadata` jsonb most entities already carry is the unstructured
|
|
8
|
+
* escape hatch (Medusa's model); this registry turns a *declared* subset of that
|
|
9
|
+
* space into fields that are:
|
|
10
|
+
* - **validated** on write (type / required / options / custom rule),
|
|
11
|
+
* - **visibility-aware** — each field declares whether it surfaces in exports,
|
|
12
|
+
* invoices, and search, so those readers can consult the registry instead of
|
|
13
|
+
* dumping or hiding everything,
|
|
14
|
+
* - **PII-aware** — flagged fields can be encrypted at rest / redacted in logs.
|
|
15
|
+
*
|
|
16
|
+
* The registry is **deployment config**: a deployment declares its fields (often
|
|
17
|
+
* discovered from `src/custom-fields/*` via {@link customFieldsFromGlob}) and the
|
|
18
|
+
* framework injects the registry into the services that read/write entities.
|
|
19
|
+
* This module is intentionally dependency-free (no zod / drizzle) so it can live
|
|
20
|
+
* in `@voyant-travel/core` and be imported anywhere.
|
|
21
|
+
*/
|
|
22
|
+
/** Identity helper for authoring a field with full type-checking. */
|
|
23
|
+
export function defineCustomField(definition) {
|
|
24
|
+
return definition;
|
|
25
|
+
}
|
|
26
|
+
const VISIBILITY_DEFAULTS = {
|
|
27
|
+
export: true,
|
|
28
|
+
invoice: false,
|
|
29
|
+
search: false,
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Build a {@link CustomFieldRegistry} from declarations. Throws on a duplicate
|
|
33
|
+
* `(entity, key)` — a collision is a config bug, not something to resolve
|
|
34
|
+
* silently.
|
|
35
|
+
*/
|
|
36
|
+
export function createCustomFieldRegistry(definitions) {
|
|
37
|
+
const byEntity = new Map();
|
|
38
|
+
const seen = new Set();
|
|
39
|
+
for (const def of definitions) {
|
|
40
|
+
const id = `${def.entity}.${def.key}`;
|
|
41
|
+
if (seen.has(id)) {
|
|
42
|
+
throw new Error(`[voyant-custom-fields] duplicate custom field "${id}"`);
|
|
43
|
+
}
|
|
44
|
+
seen.add(id);
|
|
45
|
+
const list = byEntity.get(def.entity) ?? [];
|
|
46
|
+
list.push(def);
|
|
47
|
+
byEntity.set(def.entity, list);
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
forEntity: (entity) => [...(byEntity.get(entity) ?? [])],
|
|
51
|
+
field: (entity, key) => byEntity.get(entity)?.find((f) => f.key === key),
|
|
52
|
+
entities: () => [...byEntity.keys()],
|
|
53
|
+
all: () => [...definitions],
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Merge custom-field declarations from several sources into one duplicate-free
|
|
58
|
+
* list (feed it to {@link createCustomFieldRegistry}). On a `(entity, key)`
|
|
59
|
+
* collision the **earlier** source wins — pass code-declared fields before
|
|
60
|
+
* runtime/DB-defined ones so the framework contract is authoritative. The
|
|
61
|
+
* `onShadow` callback (if given) is notified of each dropped collision.
|
|
62
|
+
*
|
|
63
|
+
* The unification's single registry is built as
|
|
64
|
+
* `createCustomFieldRegistry(mergeCustomFieldDefinitions(codeFields, dbFields))`.
|
|
65
|
+
*/
|
|
66
|
+
export function mergeCustomFieldDefinitions(sources, onShadow) {
|
|
67
|
+
const winners = new Map();
|
|
68
|
+
for (const source of sources) {
|
|
69
|
+
for (const def of source) {
|
|
70
|
+
const id = `${def.entity}.${def.key}`;
|
|
71
|
+
const existing = winners.get(id);
|
|
72
|
+
if (existing) {
|
|
73
|
+
onShadow?.(def, existing);
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
winners.set(id, def);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return [...winners.values()];
|
|
80
|
+
}
|
|
81
|
+
/** Fields of `entity` visible in `channel` (export / invoice / search). */
|
|
82
|
+
export function customFieldsVisibleIn(registry, entity, channel) {
|
|
83
|
+
return registry
|
|
84
|
+
.forEntity(entity)
|
|
85
|
+
.filter((f) => f.visibility?.[channel] ?? VISIBILITY_DEFAULTS[channel]);
|
|
86
|
+
}
|
|
87
|
+
function checkType(def, value) {
|
|
88
|
+
switch (def.type) {
|
|
89
|
+
case "text":
|
|
90
|
+
return typeof value === "string" ? null : "must be a string";
|
|
91
|
+
case "number":
|
|
92
|
+
return typeof value === "number" && Number.isFinite(value) ? null : "must be a finite number";
|
|
93
|
+
case "boolean":
|
|
94
|
+
return typeof value === "boolean" ? null : "must be a boolean";
|
|
95
|
+
case "date":
|
|
96
|
+
if (value instanceof Date) {
|
|
97
|
+
return Number.isNaN(value.getTime()) ? "must be a valid date" : null;
|
|
98
|
+
}
|
|
99
|
+
return typeof value === "string" && !Number.isNaN(Date.parse(value))
|
|
100
|
+
? null
|
|
101
|
+
: "must be an ISO date string";
|
|
102
|
+
case "select":
|
|
103
|
+
return typeof value === "string" && (def.options ?? []).includes(value)
|
|
104
|
+
? null
|
|
105
|
+
: `must be one of: ${(def.options ?? []).join(", ")}`;
|
|
106
|
+
case "multiselect": {
|
|
107
|
+
const allowed = def.options ?? [];
|
|
108
|
+
if (!Array.isArray(value) ||
|
|
109
|
+
value.some((v) => typeof v !== "string" || !allowed.includes(v))) {
|
|
110
|
+
return `must be a subset of: ${allowed.join(", ")}`;
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
case "monetary": {
|
|
115
|
+
const v = value;
|
|
116
|
+
const ok = typeof value === "object" &&
|
|
117
|
+
value !== null &&
|
|
118
|
+
typeof v.amountCents === "number" &&
|
|
119
|
+
Number.isInteger(v.amountCents) &&
|
|
120
|
+
typeof v.currency === "string" &&
|
|
121
|
+
v.currency.length === 3;
|
|
122
|
+
return ok ? null : "must be { amountCents: integer, currency: 3-letter code }";
|
|
123
|
+
}
|
|
124
|
+
case "json":
|
|
125
|
+
// Arbitrary JSON (incl. address/phone). Reject only `undefined`; `null`
|
|
126
|
+
// is already handled as "omitted" by the caller.
|
|
127
|
+
return value === undefined ? "must be a JSON value" : null;
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Validate a custom-fields payload for `entity` against the registry. Unknown
|
|
132
|
+
* keys are rejected (typo-proofing), missing required fields error, present
|
|
133
|
+
* values are type/options/custom-rule checked. `null`/`undefined` values for a
|
|
134
|
+
* non-required field are treated as "omitted". Returns the cleaned value and any
|
|
135
|
+
* errors — callers persist `value` (e.g. into the entity's `custom_fields` or
|
|
136
|
+
* `metadata` jsonb) only when `ok`.
|
|
137
|
+
*/
|
|
138
|
+
export function validateCustomFields(registry, entity, input) {
|
|
139
|
+
const provided = input ?? {};
|
|
140
|
+
const fields = registry.forEntity(entity);
|
|
141
|
+
const known = new Set(fields.map((f) => f.key));
|
|
142
|
+
const errors = [];
|
|
143
|
+
const value = {};
|
|
144
|
+
for (const key of Object.keys(provided)) {
|
|
145
|
+
if (!known.has(key)) {
|
|
146
|
+
errors.push({ key, message: `unknown custom field for "${entity}"` });
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
for (const def of fields) {
|
|
150
|
+
const raw = provided[def.key];
|
|
151
|
+
const absent = raw === null || raw === undefined;
|
|
152
|
+
if (absent) {
|
|
153
|
+
if (def.required) {
|
|
154
|
+
errors.push({ key: def.key, message: "is required" });
|
|
155
|
+
}
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const typeError = checkType(def, raw);
|
|
159
|
+
if (typeError) {
|
|
160
|
+
errors.push({ key: def.key, message: typeError });
|
|
161
|
+
continue;
|
|
162
|
+
}
|
|
163
|
+
const customError = def.validate?.(raw);
|
|
164
|
+
if (customError) {
|
|
165
|
+
errors.push({ key: def.key, message: customError });
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
value[def.key] = raw;
|
|
169
|
+
}
|
|
170
|
+
return { ok: errors.length === 0, value, errors };
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Discover deployment-local custom-field declarations from a Vite
|
|
174
|
+
* `import.meta.glob` (eager) of `src/custom-fields/*.ts` files — the custom-field
|
|
175
|
+
* half of the "extend without forking" seam (mirrors `modulesFromGlob` etc.).
|
|
176
|
+
* Each file's `default` export is a {@link CustomFieldDefinition} or an array of
|
|
177
|
+
* them; the results flatten into one list to feed
|
|
178
|
+
* {@link createCustomFieldRegistry}. Empty until a deployment adds one.
|
|
179
|
+
*
|
|
180
|
+
* @throws if a matched file has no default export.
|
|
181
|
+
*/
|
|
182
|
+
export function customFieldsFromGlob(glob) {
|
|
183
|
+
return Object.entries(glob)
|
|
184
|
+
.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
|
|
185
|
+
.flatMap(([path, namespace]) => {
|
|
186
|
+
const declaration = namespace.default;
|
|
187
|
+
if (declaration == null) {
|
|
188
|
+
throw new Error(`[voyant-custom-fields] "${path}" has no default export — ` +
|
|
189
|
+
"export default defineCustomField(...) (or an array of them)");
|
|
190
|
+
}
|
|
191
|
+
return Array.isArray(declaration)
|
|
192
|
+
? declaration
|
|
193
|
+
: [declaration];
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=custom-fields.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-fields.js","sourceRoot":"","sources":["../src/custom-fields.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAgEH,qEAAqE;AACrE,MAAM,UAAU,iBAAiB,CAAkC,UAAa;IAC9E,OAAO,UAAU,CAAA;AACnB,CAAC;AA0BD,MAAM,mBAAmB,GAAoC;IAC3D,MAAM,EAAE,IAAI;IACZ,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,KAAK;CACd,CAAA;AAED;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,WAAiD;IAEjD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAmC,CAAA;IAC3D,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAA;IAC9B,KAAK,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,MAAM,EAAE,GAAG,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,GAAG,EAAE,CAAA;QACrC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,kDAAkD,EAAE,GA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,WAAW,CAAC;YAC/B,CAAC,CAAE,WAAuC;YAC1C,CAAC,CAAC,CAAC,WAAoC,CAAC,CAAA;IAC5C,CAAC,CAAC,CAAA;AACN,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export type { AdminConfig, AdminRoutesConfig, ConfigValidationIssue, ConfigValid
|
|
|
2
2
|
export { defineVoyantConfig, resolveEntry, validateVoyantConfig } from "./config.js";
|
|
3
3
|
export type { ModuleContainer } from "./container.js";
|
|
4
4
|
export { createContainer } from "./container.js";
|
|
5
|
+
export type { CustomFieldDefinition, CustomFieldError, CustomFieldMonetaryValue, CustomFieldRegistry, CustomFieldRegistryResolver, CustomFieldType, CustomFieldValidationResult, CustomFieldVisibility, } from "./custom-fields.js";
|
|
6
|
+
export { createCustomFieldRegistry, customFieldsFromGlob, customFieldsVisibleIn, defineCustomField, mergeCustomFieldDefinitions, validateCustomFields, } from "./custom-fields.js";
|
|
5
7
|
export type { Actor, VoyantAuthContext, VoyantCallerType, VoyantPermission, VoyantVariables, } from "./env.js";
|
|
6
8
|
export type { DeliveryResult, EmitOptions, EventBus, EventBusOptions, EventCategory, EventEnvelope, EventHandler, EventMetadata, EventSource, OutboxEventStore, SubscribeOptions, Subscription, } from "./events.js";
|
|
7
9
|
export { createEventBus, generateEventId } from "./events.js";
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,WAAW,EACX,iBAAiB,EACjB,qBAAqB,EACrB,sBAAsB,EACtB,gBAAgB,EAChB,WAAW,EACX,WAAW,EACX,aAAa,EACb,YAAY,GACb,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AACpF,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,EAA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AAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAA;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,YAAY,EACV,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,SAAS,EACT,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,kBAAkB,GACnB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { defineVoyantConfig, resolveEntry, validateVoyantConfig } from "./config.js";
|
|
2
2
|
export { createContainer } from "./container.js";
|
|
3
|
+
export { createCustomFieldRegistry, customFieldsFromGlob, customFieldsVisibleIn, defineCustomField, mergeCustomFieldDefinitions, validateCustomFields, } from "./custom-fields.js";
|
|
3
4
|
export { createEventBus, generateEventId } from "./events.js";
|
|
4
5
|
export { hooks } from "./hooks.js";
|
|
5
6
|
export { defineLink, generateLinkTableSql, resolveLinkFromSpec } from "./links.js";
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEpF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAWhD,OAAO,EACL,yBAAyB,EACzB,oBAAoB,EACpB,qBAAqB,EACrB,iBAAiB,EACjB,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,oBAAoB,CAAA;AAsB3B,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7D,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAA;AAgBlC,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAKlF,OAAO,EAAE,kCAAkC,EAAE,MAAM,cAAc,CAAA;AAgBjE,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAa3D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE9E,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAW9C,OAAO,EAAE,cAAc,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voyant-travel/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.110.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -49,6 +49,11 @@
|
|
|
49
49
|
"import": "./dist/orchestration.js",
|
|
50
50
|
"default": "./dist/orchestration.js"
|
|
51
51
|
},
|
|
52
|
+
"./custom-fields": {
|
|
53
|
+
"types": "./dist/custom-fields.d.ts",
|
|
54
|
+
"import": "./dist/custom-fields.js",
|
|
55
|
+
"default": "./dist/custom-fields.js"
|
|
56
|
+
},
|
|
52
57
|
"./links": {
|
|
53
58
|
"types": "./dist/links.d.ts",
|
|
54
59
|
"import": "./dist/links.js",
|