@skedulo/mex-types 1.60.0 → 1.61.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.
|
@@ -2,7 +2,7 @@ import { ListPageExtraActionType, ButtonGroupItemComponentModel, DataExpressionT
|
|
|
2
2
|
import { BaseListPageViewComponentModel } from '../view';
|
|
3
3
|
import { BaseComponentModel } from '../common';
|
|
4
4
|
import { FlatPageViewComponentTypes } from '../view';
|
|
5
|
-
import { ValidatorDefinitionModel } from '../validator';
|
|
5
|
+
import { SoftValidatorDefinitionModel, ValidatorDefinitionModel } from '../validator';
|
|
6
6
|
/**
|
|
7
7
|
* @area formProperties
|
|
8
8
|
*/
|
|
@@ -388,6 +388,13 @@ export interface FlatPageComponentModel extends BasePageComponentModel {
|
|
|
388
388
|
updateButtonText?: LocalizedKey;
|
|
389
389
|
defaultDataForNewObject?: OneLevelBindingObject;
|
|
390
390
|
validator?: ValidatorDefinitionModel;
|
|
391
|
+
/**
|
|
392
|
+
* Advisory validators, run once `validator` passes. Failing one asks the user to submit anyway
|
|
393
|
+
* or keep editing, instead of blocking the save.
|
|
394
|
+
* @label Soft validator
|
|
395
|
+
* @version 2.5.x
|
|
396
|
+
*/
|
|
397
|
+
softValidator?: SoftValidatorDefinitionModel;
|
|
391
398
|
/**
|
|
392
399
|
* @label Read Only condition
|
|
393
400
|
*/
|
|
@@ -7,6 +7,13 @@ export interface AsyncExpressionValidatorModel extends BaseValidatorModel {
|
|
|
7
7
|
errorMessage: LocalizedKey;
|
|
8
8
|
expression: DataExpressionType;
|
|
9
9
|
query: OnlineFetchDataQuery;
|
|
10
|
+
/**
|
|
11
|
+
* Gates the validator, evaluated before `query` runs, so an unmet condition skips the API call entirely
|
|
12
|
+
* Omit to always validate.
|
|
13
|
+
* @label Condition
|
|
14
|
+
* @version 2.5.x
|
|
15
|
+
*/
|
|
16
|
+
condition?: DataExpressionType | boolean;
|
|
10
17
|
}
|
|
11
18
|
export interface ExpressionValidatorModel extends BaseValidatorModel {
|
|
12
19
|
type: 'expression';
|
|
@@ -17,5 +24,19 @@ export interface CustomFunctionValidatorModel extends BaseValidatorModel {
|
|
|
17
24
|
functionName: string;
|
|
18
25
|
type: 'customFunction';
|
|
19
26
|
}
|
|
20
|
-
export type ValidatorDefinitionModel =
|
|
21
|
-
|
|
27
|
+
export type ValidatorDefinitionModel = HardValidationModel[] | HardValidationModel;
|
|
28
|
+
/**
|
|
29
|
+
* Blocking validation — failing it stops the save until the data is corrected.
|
|
30
|
+
*/
|
|
31
|
+
export type HardValidationModel = ExpressionValidatorModel | AsyncExpressionValidatorModel | CustomFunctionValidatorModel;
|
|
32
|
+
/**
|
|
33
|
+
* Advisory validation — failing it warns the user on submit, who may then save anyway. Same shapes
|
|
34
|
+
* as HardValidationModel; what makes it soft is being declared under `upsert.softValidator` rather
|
|
35
|
+
* than `validator`
|
|
36
|
+
* @version 2.5.x
|
|
37
|
+
*/
|
|
38
|
+
export type SoftValidationModel = ExpressionValidatorModel | AsyncExpressionValidatorModel | CustomFunctionValidatorModel;
|
|
39
|
+
/**
|
|
40
|
+
* @version 2.5.x
|
|
41
|
+
*/
|
|
42
|
+
export type SoftValidatorDefinitionModel = SoftValidationModel[] | SoftValidationModel;
|
package/package.json
CHANGED
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* V2 MEX data-flow contracts (see Linear MEX-116, MEX-117).
|
|
3
|
-
*
|
|
4
|
-
* These types are the shared contract between mex-engine (RN), the mexwex-bridge
|
|
5
|
-
* SDK (web side), native-form-backend, and mobile-edge-service. They are
|
|
6
|
-
* intentionally framework-agnostic — no React, no MobX, no GraphQL helpers.
|
|
7
|
-
*
|
|
8
|
-
* V2 Data Structure is opt-in per form via `metadata.useDataFlowVersion === '2'`.
|
|
9
|
-
* Forms on V1 Data Structure continue to use the legacy `MexInstanceData` /
|
|
10
|
-
* `MexStaticData` blobs and the `instanceFetch.json` / `staticFetch.json`
|
|
11
|
-
* definitions; none of this file applies to them.
|
|
12
|
-
*/
|
|
13
|
-
export type MexDataFlowVersion = '1' | '2';
|
|
14
|
-
export type MexResourceScope = 'Instance' | 'Static';
|
|
15
|
-
/**
|
|
16
|
-
* Shape returned by `defineResource(...)` in the `params.ts` of a form using V2 Data Structure.
|
|
17
|
-
*
|
|
18
|
-
* Two flavours, distinguished by which of `fetch` vs entity-sugar fields is
|
|
19
|
-
* present:
|
|
20
|
-
* - Entity sugar: { entity, select, filter? }
|
|
21
|
-
* - Full custom: { fetch }
|
|
22
|
-
*
|
|
23
|
-
* Both flavours share the common header (`name`, `scope`, `invalidateOn?`).
|
|
24
|
-
* Build-time validation (mex-service-libs) enforces that exactly one flavour
|
|
25
|
-
* is populated.
|
|
26
|
-
*/
|
|
27
|
-
export type MexResourceDefinition = MexResourceDefinitionEntitySugar | MexResourceDefinitionCustom;
|
|
28
|
-
export interface MexResourceDefinitionBase {
|
|
29
|
-
/** Stable, unique name within a form bundle. Form devs reference this from `mexBridge.resource.observe({ resource })`. */
|
|
30
|
-
name: string;
|
|
31
|
-
/**
|
|
32
|
-
* Per-form-context (instance) or per-package (static). Defaults to 'Instance'.
|
|
33
|
-
* Static resources must not reference `ctx.contextObjectId` in their fetch.
|
|
34
|
-
*/
|
|
35
|
-
scope?: MexResourceScope;
|
|
36
|
-
/**
|
|
37
|
-
* Entity types that, when written to, invalidate this resource and force
|
|
38
|
-
* re-materialization. Used by NFB to wire up CB live-query dependencies.
|
|
39
|
-
*/
|
|
40
|
-
invalidateOn?: string[];
|
|
41
|
-
}
|
|
42
|
-
export interface MexResourceDefinitionEntitySugar extends MexResourceDefinitionBase {
|
|
43
|
-
/** GraphQL entity name (e.g. `'Jobs'`, `'JobProducts'`). */
|
|
44
|
-
entity: string;
|
|
45
|
-
/** Fields to select. Same shape as GraphQL `select`. */
|
|
46
|
-
select: Record<string, unknown>;
|
|
47
|
-
/** Optional EQL filter string. */
|
|
48
|
-
filter?: string;
|
|
49
|
-
fetch?: undefined;
|
|
50
|
-
}
|
|
51
|
-
export interface MexResourceDefinitionCustom extends MexResourceDefinitionBase {
|
|
52
|
-
/**
|
|
53
|
-
* Async fetcher invoked by the backend on materialization. Receives a
|
|
54
|
-
* runtime context (graphql client, auth, logger, and `contextObjectId` for
|
|
55
|
-
* instance-scoped resources only).
|
|
56
|
-
*/
|
|
57
|
-
fetch: (ctx: MexResourceFetchContext) => Promise<unknown>;
|
|
58
|
-
entity?: undefined;
|
|
59
|
-
select?: undefined;
|
|
60
|
-
filter?: undefined;
|
|
61
|
-
}
|
|
62
|
-
export interface MexResourceFetchContext {
|
|
63
|
-
/** The form package id. Always present. */
|
|
64
|
-
packageId: string;
|
|
65
|
-
/**
|
|
66
|
-
* The context object id (e.g. a Job UID). Only provided for instance-scoped
|
|
67
|
-
* resources. Undefined for `scope: 'Static'` resources.
|
|
68
|
-
*/
|
|
69
|
-
contextObjectId?: string;
|
|
70
|
-
/** Opaque GraphQL client handle — typed by mex-service-libs at the call site. */
|
|
71
|
-
graphql: unknown;
|
|
72
|
-
/** Opaque auth handle — typed by mex-service-libs at the call site. */
|
|
73
|
-
auth: unknown;
|
|
74
|
-
/** Opaque logger handle. */
|
|
75
|
-
logger: unknown;
|
|
76
|
-
}
|
|
77
|
-
export interface MexChangeSetHandlerDefinition {
|
|
78
|
-
/** Match a ChangeSet by its `name` field. Build-time validation enforces uniqueness within a form. */
|
|
79
|
-
match: {
|
|
80
|
-
name: string;
|
|
81
|
-
};
|
|
82
|
-
/**
|
|
83
|
-
* Primary handler. Returns `{ handled: true, uid? }` to suppress the default
|
|
84
|
-
* mutation, or `{ handled: false }` (or omits the return) to fall through.
|
|
85
|
-
*/
|
|
86
|
-
handle: (input: MexChangeSetHandlerInput, ctx: MexChangeSetHandlerContext) => Promise<MexChangeSetHandlerResult>;
|
|
87
|
-
/**
|
|
88
|
-
* Optional post-mutation hook — fires after `handle` (and after the default
|
|
89
|
-
* mutation, if it ran). Useful for side effects (telemetry, downstream calls).
|
|
90
|
-
*/
|
|
91
|
-
handleAfter?: (input: MexChangeSetHandlerInput, ctx: MexChangeSetHandlerContext) => Promise<void>;
|
|
92
|
-
}
|
|
93
|
-
export interface MexChangeSetHandlerInput {
|
|
94
|
-
/** Operation kind — `'insert' | 'update' | 'delete'` as set by the form. */
|
|
95
|
-
op: MexChangeSetOp;
|
|
96
|
-
/** GraphQL entity type the changeset targets (e.g. `'JobProducts'`). */
|
|
97
|
-
type: string;
|
|
98
|
-
/** Entity UID. May be a `local:...` temp UID for inserts; resolves via IdMapping. */
|
|
99
|
-
uid: string;
|
|
100
|
-
/** Field deltas — only writable fields per the form's contract. */
|
|
101
|
-
fields: Record<string, unknown>;
|
|
102
|
-
}
|
|
103
|
-
export type MexChangeSetOp = 'insert' | 'update' | 'delete';
|
|
104
|
-
export interface MexChangeSetHandlerContext {
|
|
105
|
-
packageId: string;
|
|
106
|
-
contextObjectId?: string;
|
|
107
|
-
graphql: unknown;
|
|
108
|
-
auth: unknown;
|
|
109
|
-
logger: unknown;
|
|
110
|
-
/** Map from temp `local:...` UIDs to real UIDs after server processing. */
|
|
111
|
-
resolveUid: (tempUid: string) => string | undefined;
|
|
112
|
-
}
|
|
113
|
-
export type MexChangeSetHandlerResult = {
|
|
114
|
-
handled: true;
|
|
115
|
-
uid?: string;
|
|
116
|
-
} | {
|
|
117
|
-
handled: false;
|
|
118
|
-
} | void;
|
|
119
|
-
/**
|
|
120
|
-
* V2 fields layered onto the existing `MexDefinition` CB Lite document
|
|
121
|
-
* (one per form package). The doc itself already exists for forms on V1 Data Structure;
|
|
122
|
-
* V2 only adds `v2ResourceDataKeys` at the top level and
|
|
123
|
-
* `useDataFlowVersion` inside the existing `metadata` field. Auto-derived
|
|
124
|
-
* by NFB / mobile-edge-service from the form bundle's `params.resources[]`.
|
|
125
|
-
*
|
|
126
|
-
* This interface is the **slim view** the engine returns to the web via
|
|
127
|
-
* `mexBridge.getMexDefinition()` — not the full MexDefinition shape (which
|
|
128
|
-
* also carries `ui`, `customFunction`, etc. that the form doesn't need).
|
|
129
|
-
*
|
|
130
|
-
* ChangeSet handler names are deliberately NOT mirrored to the engine: the
|
|
131
|
-
* form fires `insertChangeSet({ name })` and the backend resolves the
|
|
132
|
-
* handler. There is no client-side name validation.
|
|
133
|
-
*/
|
|
134
|
-
export interface MexDefinitionDocument {
|
|
135
|
-
/** Form package id — derived from `MexDefinition.uid`. */
|
|
136
|
-
packageId: string;
|
|
137
|
-
/** Mirrors `metadata.useDataFlowVersion`. `'2'` for forms using V2 Data Structure. */
|
|
138
|
-
useDataFlowVersion: MexDataFlowVersion;
|
|
139
|
-
/**
|
|
140
|
-
* Map from resource name to its scope. Engine validates
|
|
141
|
-
* `observe({ resource })` against this map; unknown names are rejected
|
|
142
|
-
* with `INVALID_RESOURCE_NAME`.
|
|
143
|
-
*/
|
|
144
|
-
v2ResourceDataKeys: Record<string, MexResourceScope>;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Document body shape. `data` is set on successful materialization;
|
|
148
|
-
* `hasError`/`error` is set on failure. The two are mutually exclusive at
|
|
149
|
-
* write time — a successful re-materialization overwrites the error body
|
|
150
|
-
* with a fresh `data` payload.
|
|
151
|
-
*/
|
|
152
|
-
export interface MexDataV2Document {
|
|
153
|
-
/** The materialized resource payload — JSON-serializable. */
|
|
154
|
-
data?: unknown;
|
|
155
|
-
/** ISO-8601 timestamp of last successful materialization. */
|
|
156
|
-
materializedAt?: string;
|
|
157
|
-
/** Set when materialization failed; mutually exclusive with `data`. */
|
|
158
|
-
hasError?: boolean;
|
|
159
|
-
/** Populated when `hasError === true`. */
|
|
160
|
-
error?: MexDataV2Error;
|
|
161
|
-
}
|
|
162
|
-
export interface MexDataV2Error {
|
|
163
|
-
code: string;
|
|
164
|
-
message: string;
|
|
165
|
-
details?: unknown;
|
|
166
|
-
}
|
|
167
|
-
/**
|
|
168
|
-
* Payload accepted by `mexBridge.insertChangeSet(...)`. The native side wraps
|
|
169
|
-
* this in a ClientEvent and persists it to the local outbox; the form does not
|
|
170
|
-
* wait for server processing.
|
|
171
|
-
*/
|
|
172
|
-
export interface MexChangeSetPayload {
|
|
173
|
-
/**
|
|
174
|
-
* Handler name resolved server-side. Omit for anonymous changesets that
|
|
175
|
-
* fall through to the default GraphQL mutation. The engine does **not**
|
|
176
|
-
* validate this name locally — typos surface as the backend's "no handler
|
|
177
|
-
* matched" warning, which the form discovers via the resource observe
|
|
178
|
-
* flow (the pending changeset clears when the default mutation completes).
|
|
179
|
-
*/
|
|
180
|
-
name?: string;
|
|
181
|
-
op: MexChangeSetOp;
|
|
182
|
-
type: string;
|
|
183
|
-
/** Entity UID — use a `local:...` temp UID for inserts. */
|
|
184
|
-
uid: string;
|
|
185
|
-
fields: Record<string, unknown>;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* Shape of a pending changeset as observed via `resource.observe({ pendingChangeSets })`.
|
|
189
|
-
* Extends the original payload with bookkeeping the engine layers on.
|
|
190
|
-
*/
|
|
191
|
-
export interface MexPendingChangeSet extends MexChangeSetPayload {
|
|
192
|
-
/** Stable id for the queued CE — used by tests to assert ordering. */
|
|
193
|
-
changeSetId: string;
|
|
194
|
-
/** ISO-8601 timestamp the CE was enqueued locally. */
|
|
195
|
-
enqueuedAt: string;
|
|
196
|
-
}
|
|
197
|
-
/**
|
|
198
|
-
* Error code discriminator for all V2 bridge error paths. Used by the
|
|
199
|
-
* mexwex-bridge SDK's `onError` callbacks and `insertChangeSet` rejections.
|
|
200
|
-
*/
|
|
201
|
-
export type MexBridgeErrorCode = 'INVALID_RESOURCE_NAME' | 'FIRST_RECORD_TIMEOUT' | 'SERVER_ERROR' | 'NATIVE_UNAVAILABLE' | 'SCHEMA_ERROR' | 'BRIDGE_DISCONNECTED';
|
|
202
|
-
export interface MexBridgeError {
|
|
203
|
-
code: MexBridgeErrorCode;
|
|
204
|
-
message: string;
|
|
205
|
-
details?: unknown;
|
|
206
|
-
}
|
|
207
|
-
export type MexResourceObserveStatus = 'loading' | 'ready';
|
|
208
|
-
export interface MexResourceObserveSnapshot<TData = unknown> {
|
|
209
|
-
resourceData?: TData;
|
|
210
|
-
pendingChangeSets: MexPendingChangeSet[];
|
|
211
|
-
status: MexResourceObserveStatus;
|
|
212
|
-
meta?: {
|
|
213
|
-
materializedAt?: string;
|
|
214
|
-
};
|
|
215
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* V2 MEX data-flow contracts (see Linear MEX-116, MEX-117).
|
|
4
|
-
*
|
|
5
|
-
* These types are the shared contract between mex-engine (RN), the mexwex-bridge
|
|
6
|
-
* SDK (web side), native-form-backend, and mobile-edge-service. They are
|
|
7
|
-
* intentionally framework-agnostic — no React, no MobX, no GraphQL helpers.
|
|
8
|
-
*
|
|
9
|
-
* V2 Data Structure is opt-in per form via `metadata.useDataFlowVersion === '2'`.
|
|
10
|
-
* Forms on V1 Data Structure continue to use the legacy `MexInstanceData` /
|
|
11
|
-
* `MexStaticData` blobs and the `instanceFetch.json` / `staticFetch.json`
|
|
12
|
-
* definitions; none of this file applies to them.
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
//# sourceMappingURL=MexDataFlow.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"MexDataFlow.js","sourceRoot":"","sources":["../../src/common/MexDataFlow.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG"}
|