@ankhorage/contracts 1.3.1 → 1.5.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/CHANGELOG.md +12 -0
- package/dist/types.d.ts +37 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
- package/src/contracts.test.ts +115 -0
- package/src/types.ts +72 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @ankhorage/contracts
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 524a288: Add normalized component event DTO contracts for stable component-emitted event envelopes, including form submit, button press, and collection item press events.
|
|
8
|
+
|
|
9
|
+
## 1.4.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- 3172bd4: Add manifest node event bindings so `UiNode` can declare provider-neutral event-to-action mappings such as `submit` actions for email and database persistence.
|
|
14
|
+
|
|
3
15
|
## 1.3.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/types.d.ts
CHANGED
|
@@ -53,6 +53,42 @@ export interface FilterAction {
|
|
|
53
53
|
};
|
|
54
54
|
}
|
|
55
55
|
export type Action = AlertAction | ConsoleAction | FilterAction | NavigateAction | SearchAction | SetLanguageAction | ToggleDarkModeAction;
|
|
56
|
+
export type ManifestValue = string | number | boolean | null | readonly ManifestValue[] | {
|
|
57
|
+
readonly [key: string]: ManifestValue;
|
|
58
|
+
};
|
|
59
|
+
export type ActionBindingPayload = Record<string, ManifestValue>;
|
|
60
|
+
export type ActionConditionSource = 'context' | 'event' | 'state';
|
|
61
|
+
export type ActionConditionOperator = 'eq' | 'exists' | 'neq' | 'notExists';
|
|
62
|
+
export interface ActionCondition {
|
|
63
|
+
readonly source: ActionConditionSource;
|
|
64
|
+
readonly path: string;
|
|
65
|
+
readonly operator: ActionConditionOperator;
|
|
66
|
+
readonly value?: ManifestValue;
|
|
67
|
+
}
|
|
68
|
+
export interface ActionBinding {
|
|
69
|
+
readonly type: string;
|
|
70
|
+
readonly payload?: ActionBindingPayload;
|
|
71
|
+
readonly when?: ActionCondition;
|
|
72
|
+
}
|
|
73
|
+
export type UiNodeEventBindings = Record<string, readonly ActionBinding[]>;
|
|
74
|
+
export type ComponentEventPayloadValue = ManifestValue;
|
|
75
|
+
export interface ComponentEventDto<TType extends string = string, TPayload extends object = Record<string, ComponentEventPayloadValue>> {
|
|
76
|
+
readonly type: TType;
|
|
77
|
+
readonly sourceNodeId: string;
|
|
78
|
+
readonly payload: TPayload;
|
|
79
|
+
}
|
|
80
|
+
export type FormSubmitValues = Record<string, ComponentEventPayloadValue>;
|
|
81
|
+
export type FormSubmitEventDto = ComponentEventDto<'form.submit', {
|
|
82
|
+
readonly values: FormSubmitValues;
|
|
83
|
+
}>;
|
|
84
|
+
export type ButtonPressEventDto = ComponentEventDto<'button.press', Record<string, never>>;
|
|
85
|
+
export interface CollectionItemPressPayload {
|
|
86
|
+
readonly itemId: string | number;
|
|
87
|
+
readonly item: Record<string, ComponentEventPayloadValue>;
|
|
88
|
+
}
|
|
89
|
+
export type CollectionItemPressEventDto = ComponentEventDto<'collection.itemPress', CollectionItemPressPayload>;
|
|
90
|
+
export type ComponentEventDtoKind = ButtonPressEventDto['type'] | CollectionItemPressEventDto['type'] | FormSubmitEventDto['type'];
|
|
91
|
+
export type KnownComponentEventDto = ButtonPressEventDto | CollectionItemPressEventDto | FormSubmitEventDto;
|
|
56
92
|
export declare const NAVIGATOR_TYPES: readonly ["stack", "tabs", "drawer"];
|
|
57
93
|
export type NavigatorType = (typeof NAVIGATOR_TYPES)[number];
|
|
58
94
|
export declare const APP_CATEGORIES: readonly ["books_reading", "business_productivity", "developer_tools", "education_learning", "entertainment_media", "finance_money", "food_drink", "games", "graphics_design", "health_fitness", "kids_family", "lifestyle", "medical", "music_audio", "navigation_travel", "news_magazines", "photo_video", "reference", "shopping_commerce", "social_community", "sports", "utilities_tools", "weather"];
|
|
@@ -96,6 +132,7 @@ export interface UiNode {
|
|
|
96
132
|
props?: Record<string, unknown>;
|
|
97
133
|
children?: UiNode[];
|
|
98
134
|
style?: Record<string, number | string>;
|
|
135
|
+
events?: UiNodeEventBindings;
|
|
99
136
|
}
|
|
100
137
|
export interface ScreenSpec {
|
|
101
138
|
id: string;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAElF,MAAM,WAAW,eAAe;IAC9B,YAAY,EAAE,MAAM,CAAC;IACrB,OAAO,EAAE,YAAY,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,eAAe,CAAC;IACvB,IAAI,EAAE,eAAe,CAAC;CACvB;AAED,MAAM,MAAM,UAAU,GAClB,UAAU,GACV,OAAO,GACP,SAAS,GACT,gBAAgB,GAChB,aAAa,GACb,QAAQ,GACR,QAAQ,CAAC;AAEb,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;KAC1C,CAAC;CACH;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE;QACR,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;CACH;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,SA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EAAE,OAAO,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,WAAW,EAAE,CAAC;IACtB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC,KAAK,EAAE,aAAa,CAAC;IACrB,SAAS,EAAE,aAAa,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACpC,QAAQ,EAAE;QACR,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE;YACZ,aAAa,EAAE,MAAM,CAAC;YACtB,OAAO,EAAE,MAAM,EAAE,CAAC;SACnB,CAAC;QACF,QAAQ,EAAE,cAAc,CAAC;KAC1B,CAAC;CACH"}
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAyJA,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAU,CAAC;AAGpE,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,eAAe;IACf,uBAAuB;IACvB,iBAAiB;IACjB,oBAAoB;IACpB,qBAAqB;IACrB,eAAe;IACf,YAAY;IACZ,OAAO;IACP,iBAAiB;IACjB,gBAAgB;IAChB,aAAa;IACb,WAAW;IACX,SAAS;IACT,aAAa;IACb,mBAAmB;IACnB,gBAAgB;IAChB,aAAa;IACb,WAAW;IACX,mBAAmB;IACnB,kBAAkB;IAClB,QAAQ;IACR,iBAAiB;IACjB,SAAS;CACD,CAAC;AAGX,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,UAAU,CAAU,CAAC;AAIxD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,UAAU,CAAU,CAAC;AAIxD,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAK,EAAE,MAAM,CAAU,CAAC;AAGvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAU,CAAC;AAG/D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,MAAM,EAAE,MAAM,CAAU,CAAC;AAGrD,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAU,CAAC;AAG3D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAU,CAAC;AAGrE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAAU,CAAU,CAAC;AAIpD,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAU,CAAC;AAGhF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,YAAY,EAAE,qBAAqB,CAAU,CAAC;AAGpF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,GAAG,wBAAwB;IAC3B,WAAW;IACX,UAAU;IACV,aAAa;IACb,WAAW;CACH,CAAC","sourcesContent":["import type { ColorHarmony } from '@ankhorage/color-theory';\n\nimport type { AuthFlowConfig, AuthIdentifierKind, AuthSignUpField } from './auth';\n\nexport interface ThemeModeConfig {\n primaryColor: string;\n harmony: ColorHarmony;\n}\n\nexport interface ThemeConfig {\n id: string;\n name: string;\n light: ThemeModeConfig;\n dark: ThemeModeConfig;\n}\n\nexport type ActionType =\n | 'navigate'\n | 'alert'\n | 'console'\n | 'toggleDarkMode'\n | 'setLanguage'\n | 'search'\n | 'filter';\n\nexport interface NavigateAction {\n type: 'navigate';\n payload: {\n route: string;\n params?: Record<string, number | string>;\n };\n}\n\nexport interface AlertAction {\n type: 'alert';\n payload?: {\n message?: string;\n };\n}\n\nexport interface ConsoleAction {\n type: 'console';\n payload?: Record<string, unknown>;\n}\n\nexport interface ToggleDarkModeAction {\n type: 'toggleDarkMode';\n payload?: never;\n}\n\nexport interface SetLanguageAction {\n type: 'setLanguage';\n payload: {\n locale: string;\n };\n}\n\nexport interface SearchAction {\n type: 'search';\n payload: {\n query: string;\n scope?: string;\n };\n}\n\nexport interface FilterAction {\n type: 'filter';\n payload: {\n filterKey: string;\n filterValue: string;\n };\n}\n\nexport type Action =\n | AlertAction\n | ConsoleAction\n | FilterAction\n | NavigateAction\n | SearchAction\n | SetLanguageAction\n | ToggleDarkModeAction;\n\nexport type ManifestValue =\n | string\n | number\n | boolean\n | null\n | readonly ManifestValue[]\n | { readonly [key: string]: ManifestValue };\n\nexport type ActionBindingPayload = Record<string, ManifestValue>;\n\nexport type ActionConditionSource = 'context' | 'event' | 'state';\n\nexport type ActionConditionOperator = 'eq' | 'exists' | 'neq' | 'notExists';\n\nexport interface ActionCondition {\n readonly source: ActionConditionSource;\n readonly path: string;\n readonly operator: ActionConditionOperator;\n readonly value?: ManifestValue;\n}\n\nexport interface ActionBinding {\n readonly type: string;\n readonly payload?: ActionBindingPayload;\n readonly when?: ActionCondition;\n}\n\nexport type UiNodeEventBindings = Record<string, readonly ActionBinding[]>;\n\nexport type ComponentEventPayloadValue = ManifestValue;\n\nexport interface ComponentEventDto<\n TType extends string = string,\n TPayload extends object = Record<string, ComponentEventPayloadValue>,\n> {\n readonly type: TType;\n readonly sourceNodeId: string;\n readonly payload: TPayload;\n}\n\nexport type FormSubmitValues = Record<string, ComponentEventPayloadValue>;\n\nexport type FormSubmitEventDto = ComponentEventDto<\n 'form.submit',\n {\n readonly values: FormSubmitValues;\n }\n>;\n\nexport type ButtonPressEventDto = ComponentEventDto<'button.press', Record<string, never>>;\n\nexport interface CollectionItemPressPayload {\n readonly itemId: string | number;\n readonly item: Record<string, ComponentEventPayloadValue>;\n}\n\nexport type CollectionItemPressEventDto = ComponentEventDto<\n 'collection.itemPress',\n CollectionItemPressPayload\n>;\n\nexport type ComponentEventDtoKind =\n | ButtonPressEventDto['type']\n | CollectionItemPressEventDto['type']\n | FormSubmitEventDto['type'];\n\nexport type KnownComponentEventDto =\n | ButtonPressEventDto\n | CollectionItemPressEventDto\n | FormSubmitEventDto;\n\nexport const NAVIGATOR_TYPES = ['stack', 'tabs', 'drawer'] as const;\nexport type NavigatorType = (typeof NAVIGATOR_TYPES)[number];\n\nexport const APP_CATEGORIES = [\n 'books_reading',\n 'business_productivity',\n 'developer_tools',\n 'education_learning',\n 'entertainment_media',\n 'finance_money',\n 'food_drink',\n 'games',\n 'graphics_design',\n 'health_fitness',\n 'kids_family',\n 'lifestyle',\n 'medical',\n 'music_audio',\n 'navigation_travel',\n 'news_magazines',\n 'photo_video',\n 'reference',\n 'shopping_commerce',\n 'social_community',\n 'sports',\n 'utilities_tools',\n 'weather',\n] as const;\nexport type AppCategory = (typeof APP_CATEGORIES)[number];\n\nexport const DEPLOYMENT_TARGETS = ['minikube'] as const;\nexport type KnownDeploymentTarget = (typeof DEPLOYMENT_TARGETS)[number];\nexport type DeploymentTarget = KnownDeploymentTarget | (string & {});\n\nexport const DATABASE_PROVIDERS = ['supabase'] as const;\nexport type KnownDatabaseProvider = (typeof DATABASE_PROVIDERS)[number];\nexport type DatabaseProvider = KnownDatabaseProvider | (string & {});\n\nexport const DATABASE_TIERS = ['dev', 'prod'] as const;\nexport type DatabaseTier = (typeof DATABASE_TIERS)[number];\n\nexport const STORAGE_PROVIDERS = ['auto', 's3', 'r2'] as const;\nexport type StorageProvider = (typeof STORAGE_PROVIDERS)[number];\n\nexport const AUTHZ_KINDS = ['RBAC', 'ABAC'] as const;\nexport type AuthzKind = (typeof AUTHZ_KINDS)[number];\n\nexport const AUTHZ_ENGINES = ['cerbos', 'native'] as const;\nexport type AuthzEngine = (typeof AUTHZ_ENGINES)[number];\n\nexport const AUTH_SCOPES = ['global', 'none', 'integrated'] as const;\nexport type AuthScope = (typeof AUTH_SCOPES)[number];\n\nexport const AUTH_PROVIDERS = ['supabase'] as const;\nexport type KnownAuthProvider = (typeof AUTH_PROVIDERS)[number];\nexport type AuthProvider = KnownAuthProvider | (string & {});\n\nexport const AUTH_SIGN_IN_IDENTIFIERS = ['email', 'username', 'phone'] as const;\nexport type AuthSignInIdentifier = AuthIdentifierKind;\n\nexport const AUTH_SIGN_UP_POLICIES = ['autoSignIn', 'requireVerification'] as const;\nexport type AuthSignUpPolicy = (typeof AUTH_SIGN_UP_POLICIES)[number];\n\nexport const AUTH_PROFILE_FIELDS = [\n ...AUTH_SIGN_IN_IDENTIFIERS,\n 'firstName',\n 'lastName',\n 'displayName',\n 'avatarUrl',\n] as const;\nexport type KnownAuthProfileField = (typeof AUTH_PROFILE_FIELDS)[number];\nexport type AuthProfileField = KnownAuthProfileField | (string & {});\n\nexport interface IconSpec {\n name: string;\n provider?: string;\n size?: number | string;\n color?: string;\n}\n\nexport interface UiNode {\n id: string;\n type: string;\n alias?: string;\n props?: Record<string, unknown>;\n children?: UiNode[];\n style?: Record<string, number | string>;\n events?: UiNodeEventBindings;\n}\n\nexport interface ScreenSpec {\n id: string;\n name: string;\n title?: string;\n description?: string;\n root: UiNode;\n}\n\nexport interface NavigatorSpec {\n type: NavigatorType;\n initialRouteName?: string;\n routes: RouteDefinition[];\n options?: Record<string, unknown>;\n}\n\nexport interface RouteDefinition {\n name: string;\n path?: string;\n label?: string;\n icon?: IconSpec;\n hideInTabBar?: boolean;\n guards?: string[];\n screenId?: string;\n navigator?: NavigatorSpec;\n}\n\nexport interface DeploymentSpec {\n target: DeploymentTarget;\n monitoring: boolean;\n}\n\nexport interface DatabaseSpec {\n provider: DatabaseProvider;\n tier: DatabaseTier;\n}\n\nexport interface StorageSpec {\n provider: StorageProvider;\n buckets: string[];\n}\n\nexport interface AuthzSpec {\n kind: AuthzKind;\n engine: AuthzEngine;\n}\n\nexport interface AuthSignInSpec {\n identifiers: AuthSignInIdentifier[];\n}\n\nexport interface AuthSignUpSpec {\n requiredFields: AuthSignUpField[];\n optionalFields?: AuthSignUpField[];\n signUpPolicy?: AuthSignUpPolicy;\n}\n\nexport interface AuthProfileSpec {\n fields: AuthProfileField[];\n}\n\nexport interface AuthSpec {\n scope: AuthScope;\n provider: AuthProvider;\n authorization: AuthzSpec;\n flow?: AuthFlowConfig;\n signIn?: AuthSignInSpec;\n signUp?: AuthSignUpSpec;\n profile?: AuthProfileSpec;\n}\n\nexport interface NetworkingSpec {\n domain?: string;\n cdn: boolean;\n}\n\nexport interface InfraManifest {\n deployment?: DeploymentSpec;\n auth?: AuthSpec;\n database?: DatabaseSpec;\n storage?: StorageSpec;\n networking?: NetworkingSpec;\n plugins: string[];\n pluginsConfig?: Record<string, unknown>;\n}\n\nexport interface AppManifest {\n metadata: {\n name: string;\n slug: string;\n version: string;\n themeId: string;\n created?: string;\n updated?: string;\n };\n themes: ThemeConfig[];\n activeThemeId: string;\n activeThemeMode?: 'dark' | 'light';\n infra: InfraManifest;\n navigator: NavigatorSpec;\n screens: Record<string, ScreenSpec>;\n settings: {\n apiBaseUrl?: string;\n localization: {\n defaultLocale: string;\n locales: string[];\n };\n authFlow: AuthFlowConfig;\n };\n}\n"]}
|
package/package.json
CHANGED
package/src/contracts.test.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { COLOR_HARMONIES } from '@ankhorage/color-theory';
|
|
|
5
5
|
import { describe, expect, it } from 'bun:test';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
|
+
type ActionBinding,
|
|
8
9
|
APP_CATEGORIES,
|
|
9
10
|
type AppCategory,
|
|
10
11
|
AUTH_PROVIDERS,
|
|
@@ -12,11 +13,16 @@ import {
|
|
|
12
13
|
AUTH_SIGN_UP_POLICIES,
|
|
13
14
|
type AuthFlowConfig,
|
|
14
15
|
type AuthSpec,
|
|
16
|
+
type ButtonPressEventDto,
|
|
17
|
+
type CollectionItemPressEventDto,
|
|
18
|
+
type ComponentEventDto,
|
|
19
|
+
type ComponentEventDtoKind,
|
|
15
20
|
type DbAdapter,
|
|
16
21
|
type DbAdminAdapter,
|
|
17
22
|
type DbChangeEvent,
|
|
18
23
|
type DbRealtimeAdapter,
|
|
19
24
|
DEPLOYMENT_TARGETS,
|
|
25
|
+
type FormSubmitEventDto,
|
|
20
26
|
type ImageAssetSource,
|
|
21
27
|
NAVIGATOR_TYPES,
|
|
22
28
|
type StoragePublicUrlResult,
|
|
@@ -24,6 +30,7 @@ import {
|
|
|
24
30
|
type StorageUploadResult,
|
|
25
31
|
type ThemeConfig,
|
|
26
32
|
type ThemeModeConfig,
|
|
33
|
+
type UiNode,
|
|
27
34
|
} from './index';
|
|
28
35
|
|
|
29
36
|
async function collectTypeScriptFiles(directory: string): Promise<string[]> {
|
|
@@ -223,6 +230,114 @@ describe('contracts', () => {
|
|
|
223
230
|
expect(JSON.parse(JSON.stringify(source))).toEqual(source);
|
|
224
231
|
});
|
|
225
232
|
|
|
233
|
+
it('serializes node event bindings for submit actions', () => {
|
|
234
|
+
const node: UiNode = {
|
|
235
|
+
id: 'contact-form',
|
|
236
|
+
type: 'Form',
|
|
237
|
+
props: {
|
|
238
|
+
title: 'Contact us',
|
|
239
|
+
},
|
|
240
|
+
events: {
|
|
241
|
+
submit: [
|
|
242
|
+
{
|
|
243
|
+
type: 'email.send',
|
|
244
|
+
payload: {
|
|
245
|
+
to: 'info@example.com',
|
|
246
|
+
subject: 'New contact message',
|
|
247
|
+
bodyFrom: 'payload.values.message',
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
type: 'db.persist',
|
|
252
|
+
payload: {
|
|
253
|
+
collection: 'contact_messages',
|
|
254
|
+
mode: 'columns',
|
|
255
|
+
},
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
};
|
|
260
|
+
|
|
261
|
+
expect(JSON.parse(JSON.stringify(node))).toEqual(node);
|
|
262
|
+
expect(node.events?.submit?.map((action) => action.type)).toEqual(['email.send', 'db.persist']);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('accepts conditional node event bindings', () => {
|
|
266
|
+
const binding: ActionBinding = {
|
|
267
|
+
type: 'db.persist',
|
|
268
|
+
payload: {
|
|
269
|
+
collection: 'contact_messages',
|
|
270
|
+
},
|
|
271
|
+
when: {
|
|
272
|
+
source: 'event',
|
|
273
|
+
path: 'payload.values.email',
|
|
274
|
+
operator: 'exists',
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
|
|
278
|
+
expect(binding.when?.operator).toBe('exists');
|
|
279
|
+
expect(binding.payload?.collection).toBe('contact_messages');
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
it('serializes normalized form submit event DTOs', () => {
|
|
283
|
+
const event: FormSubmitEventDto = {
|
|
284
|
+
type: 'form.submit',
|
|
285
|
+
sourceNodeId: 'contact-form',
|
|
286
|
+
payload: {
|
|
287
|
+
values: {
|
|
288
|
+
firstname: 'Fabio',
|
|
289
|
+
message: 'This is my contact message',
|
|
290
|
+
newsletter: true,
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
};
|
|
294
|
+
|
|
295
|
+
expect(JSON.parse(JSON.stringify(event))).toEqual(event);
|
|
296
|
+
expect(event.payload.values.message).toBe('This is my contact message');
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('serializes normalized button press event DTOs', () => {
|
|
300
|
+
const event: ButtonPressEventDto = {
|
|
301
|
+
type: 'button.press',
|
|
302
|
+
sourceNodeId: 'submit-button',
|
|
303
|
+
payload: {},
|
|
304
|
+
};
|
|
305
|
+
|
|
306
|
+
expect(JSON.parse(JSON.stringify(event))).toEqual(event);
|
|
307
|
+
expect(event.type).toBe('button.press');
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('serializes normalized collection item press event DTOs', () => {
|
|
311
|
+
const event: CollectionItemPressEventDto = {
|
|
312
|
+
type: 'collection.itemPress',
|
|
313
|
+
sourceNodeId: 'posts-list',
|
|
314
|
+
payload: {
|
|
315
|
+
itemId: 'post-1',
|
|
316
|
+
item: {
|
|
317
|
+
id: 'post-1',
|
|
318
|
+
title: 'Hello',
|
|
319
|
+
},
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
expect(JSON.parse(JSON.stringify(event))).toEqual(event);
|
|
324
|
+
expect(event.payload.item.title).toBe('Hello');
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('accepts custom component event DTOs through the same envelope', () => {
|
|
328
|
+
const event: ComponentEventDto<'media.play', { readonly mediaId: string }> = {
|
|
329
|
+
type: 'media.play',
|
|
330
|
+
sourceNodeId: 'hero-video',
|
|
331
|
+
payload: {
|
|
332
|
+
mediaId: 'video-1',
|
|
333
|
+
},
|
|
334
|
+
};
|
|
335
|
+
const knownEventType: ComponentEventDtoKind = 'form.submit';
|
|
336
|
+
|
|
337
|
+
expect(event.payload.mediaId).toBe('video-1');
|
|
338
|
+
expect(knownEventType).toBe('form.submit');
|
|
339
|
+
});
|
|
340
|
+
|
|
226
341
|
it('accepts a provider-neutral CRUD database adapter', async () => {
|
|
227
342
|
const adapter: DbAdapter = {
|
|
228
343
|
capabilities: {
|
package/src/types.ts
CHANGED
|
@@ -80,6 +80,77 @@ export type Action =
|
|
|
80
80
|
| SetLanguageAction
|
|
81
81
|
| ToggleDarkModeAction;
|
|
82
82
|
|
|
83
|
+
export type ManifestValue =
|
|
84
|
+
| string
|
|
85
|
+
| number
|
|
86
|
+
| boolean
|
|
87
|
+
| null
|
|
88
|
+
| readonly ManifestValue[]
|
|
89
|
+
| { readonly [key: string]: ManifestValue };
|
|
90
|
+
|
|
91
|
+
export type ActionBindingPayload = Record<string, ManifestValue>;
|
|
92
|
+
|
|
93
|
+
export type ActionConditionSource = 'context' | 'event' | 'state';
|
|
94
|
+
|
|
95
|
+
export type ActionConditionOperator = 'eq' | 'exists' | 'neq' | 'notExists';
|
|
96
|
+
|
|
97
|
+
export interface ActionCondition {
|
|
98
|
+
readonly source: ActionConditionSource;
|
|
99
|
+
readonly path: string;
|
|
100
|
+
readonly operator: ActionConditionOperator;
|
|
101
|
+
readonly value?: ManifestValue;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface ActionBinding {
|
|
105
|
+
readonly type: string;
|
|
106
|
+
readonly payload?: ActionBindingPayload;
|
|
107
|
+
readonly when?: ActionCondition;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export type UiNodeEventBindings = Record<string, readonly ActionBinding[]>;
|
|
111
|
+
|
|
112
|
+
export type ComponentEventPayloadValue = ManifestValue;
|
|
113
|
+
|
|
114
|
+
export interface ComponentEventDto<
|
|
115
|
+
TType extends string = string,
|
|
116
|
+
TPayload extends object = Record<string, ComponentEventPayloadValue>,
|
|
117
|
+
> {
|
|
118
|
+
readonly type: TType;
|
|
119
|
+
readonly sourceNodeId: string;
|
|
120
|
+
readonly payload: TPayload;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export type FormSubmitValues = Record<string, ComponentEventPayloadValue>;
|
|
124
|
+
|
|
125
|
+
export type FormSubmitEventDto = ComponentEventDto<
|
|
126
|
+
'form.submit',
|
|
127
|
+
{
|
|
128
|
+
readonly values: FormSubmitValues;
|
|
129
|
+
}
|
|
130
|
+
>;
|
|
131
|
+
|
|
132
|
+
export type ButtonPressEventDto = ComponentEventDto<'button.press', Record<string, never>>;
|
|
133
|
+
|
|
134
|
+
export interface CollectionItemPressPayload {
|
|
135
|
+
readonly itemId: string | number;
|
|
136
|
+
readonly item: Record<string, ComponentEventPayloadValue>;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type CollectionItemPressEventDto = ComponentEventDto<
|
|
140
|
+
'collection.itemPress',
|
|
141
|
+
CollectionItemPressPayload
|
|
142
|
+
>;
|
|
143
|
+
|
|
144
|
+
export type ComponentEventDtoKind =
|
|
145
|
+
| ButtonPressEventDto['type']
|
|
146
|
+
| CollectionItemPressEventDto['type']
|
|
147
|
+
| FormSubmitEventDto['type'];
|
|
148
|
+
|
|
149
|
+
export type KnownComponentEventDto =
|
|
150
|
+
| ButtonPressEventDto
|
|
151
|
+
| CollectionItemPressEventDto
|
|
152
|
+
| FormSubmitEventDto;
|
|
153
|
+
|
|
83
154
|
export const NAVIGATOR_TYPES = ['stack', 'tabs', 'drawer'] as const;
|
|
84
155
|
export type NavigatorType = (typeof NAVIGATOR_TYPES)[number];
|
|
85
156
|
|
|
@@ -167,6 +238,7 @@ export interface UiNode {
|
|
|
167
238
|
props?: Record<string, unknown>;
|
|
168
239
|
children?: UiNode[];
|
|
169
240
|
style?: Record<string, number | string>;
|
|
241
|
+
events?: UiNodeEventBindings;
|
|
170
242
|
}
|
|
171
243
|
|
|
172
244
|
export interface ScreenSpec {
|