@process.co/element-types 0.0.17 → 0.0.19

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,69 @@
1
+ /**
2
+ * Compile-only checks for defineAction (not emitted).
3
+ */
4
+ import {
5
+ defineAction,
6
+ defineApp,
7
+ type ActionRunOptions,
8
+ type DeriveActionInstance,
9
+ type DeriveEmbeddedAppPropInstance,
10
+ } from './index';
11
+
12
+ const httpApp = defineApp({
13
+ type: 'app',
14
+ app: 'http',
15
+ propDefinitions: {
16
+ httpRequest: { type: 'http_request', label: 'HTTP Request' },
17
+ },
18
+ } as const);
19
+
20
+ const _action = defineAction({
21
+ type: 'action',
22
+ key: 'test-action',
23
+ version: '1.0.0',
24
+ props: {
25
+ label: { type: 'string', default: '' },
26
+ http: httpApp,
27
+ },
28
+ methods: {
29
+ async run({ $, steps }) {
30
+ void steps;
31
+ $.export('out', {});
32
+ void $.flow;
33
+ this.label;
34
+ this.http.httpRequest.execute;
35
+ },
36
+ },
37
+ });
38
+
39
+ export type _actionType = typeof _action;
40
+
41
+ type _runParams = Parameters<NonNullable<typeof _action.methods>['run']>[0];
42
+ type _runDollar = _runParams['$'];
43
+ type _assertRunDollar = _runDollar extends ActionRunOptions['$'] ? true : false;
44
+ const _runDollarCheck: _assertRunDollar = true;
45
+
46
+ type _httpOnThis = DeriveActionInstance<typeof _action>['http'];
47
+ type _httpRuntime = DeriveEmbeddedAppPropInstance<typeof httpApp>;
48
+ type _assertHttpProp = _httpOnThis extends _httpRuntime ? true : false;
49
+ const _httpPropCheck: _assertHttpProp = true;
50
+ type _assertNotDefinition = 'type' extends keyof _httpOnThis ? false : true;
51
+ const _notDefinitionCheck: _assertNotDefinition = true;
52
+ type _assertRunOnThis = typeof _action.methods.run extends DeriveActionInstance<typeof _action>['run']
53
+ ? true
54
+ : false;
55
+ const _runOnThisCheck: _assertRunOnThis = true;
56
+
57
+ /** @deprecated top-level `run` — still accepted for older elements. */
58
+ const _legacyTopLevelRun = defineAction({
59
+ type: 'action',
60
+ key: 'legacy-run',
61
+ version: '1.0.0',
62
+ props: {},
63
+ async run({ $, steps }) {
64
+ void steps;
65
+ $.export('legacy', true);
66
+ },
67
+ });
68
+
69
+ void _legacyTopLevelRun;
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Compile-only: embedded `defineApp` in signal `props` (not emitted).
3
+ */
4
+ import {
5
+ defineApp,
6
+ defineSignal,
7
+ type DeriveEmbeddedAppPropInstance,
8
+ type DeriveSignalInstance,
9
+ } from './index';
10
+
11
+ const httpApp = defineApp({
12
+ type: 'app',
13
+ app: 'http',
14
+ noAuth: true,
15
+ propDefinitions: {
16
+ httpRequest: {
17
+ type: 'http_request',
18
+ label: 'HTTP Request Configuration',
19
+ },
20
+ },
21
+ } as const);
22
+
23
+ const _signal = defineSignal({
24
+ type: 'signal',
25
+ props: {
26
+ httpInterface: { type: '$.interface.http' },
27
+ http: httpApp,
28
+ },
29
+ async run() {
30
+ this.http.httpRequest.execute;
31
+ this.httpInterface.deferHttpResponse;
32
+ },
33
+ });
34
+
35
+ export type _HttpOnThis = DeriveSignalInstance<typeof _signal>['http'];
36
+ export type _HttpRuntime = DeriveEmbeddedAppPropInstance<typeof httpApp>;
37
+ type _assertHttpProp = _HttpOnThis extends _HttpRuntime ? true : false;
38
+ const _httpPropCheck: _assertHttpProp = true;
39
+ type _assertNotDefinition = 'type' extends keyof _HttpOnThis ? false : true;
40
+ const _notDefinitionCheck: _assertNotDefinition = true;
41
+ type _assertHttpRequest = _HttpOnThis['httpRequest'] extends { execute: () => Promise<unknown> }
42
+ ? true
43
+ : false;
44
+ const _httpRequestCheck: _assertHttpRequest = true;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Compile-only checks for defineSignal hook vs run `this` (not emitted).
3
+ */
4
+ import {
5
+ defineSignal,
6
+ type SignalRunHostServices,
7
+ type SignalSaveHostParameters,
8
+ } from './index';
9
+
10
+ const _webhook = defineSignal({
11
+ type: 'signal',
12
+ props: {
13
+ httpInterface: { type: '$.interface.http' },
14
+ cacheMaxAge: { type: '$.interface.duration', default: 86400 },
15
+ authType: { type: 'string', default: 'none' },
16
+ },
17
+ hooks: {
18
+ async save({ $ }) {
19
+ await $.http.configureResponseCaching({
20
+ maxAge: this.cacheMaxAge,
21
+ varyBy: '*',
22
+ });
23
+ // @ts-expect-error — `run` host `$` is not available in hooks.save
24
+ $.enforceSchema;
25
+ // @ts-expect-error — `$emit` is only on `run` `this`, not hooks
26
+ this.$emit;
27
+ // @ts-expect-error — no runtime HTTP interface on hook `this`
28
+ await this.httpInterface.respond({ status: 200, body: {} });
29
+ },
30
+ },
31
+ async run({ $, event }) {
32
+ void event;
33
+ $.enforceSchema;
34
+ // @ts-expect-error — save-only host `$` is not available in run
35
+ $.http;
36
+ await this.httpInterface.deferHttpResponse(30_000);
37
+ },
38
+ });
39
+
40
+ export type _webhookType = typeof _webhook;
41
+
42
+ type _saveParams = Parameters<NonNullable<typeof _webhook.hooks>['save']>[0];
43
+ type _saveDollar = _saveParams['$'];
44
+ type _assertSaveDollar = _saveDollar extends SignalSaveHostParameters['$'] ? true : false;
45
+ const _saveDollarCheck: _assertSaveDollar = true;
46
+ type _saveDollarNotRun = SignalRunHostServices extends _saveDollar ? false : true;
47
+ const _saveDollarNotRunCheck: _saveDollarNotRun = true;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * HTTP response replay cache — policy at save, vary key at runtime.
3
+ */
4
+
5
+ export type HttpRequestCacheMode = 'cache-only' | 'stale-while-revalidate';
6
+
7
+ /** Materialized at save → elementData.$httpRequestCachePolicy */
8
+ export type HttpRequestCachePolicy = {
9
+ mode: HttpRequestCacheMode;
10
+ ttlSeconds: number;
11
+ refreshAfterSeconds?: number;
12
+ vary: HttpRequestCacheVary;
13
+ /** When true, webhook loads trigger so author can call setRequestVaryKey. */
14
+ needsRuntimeVaryKey?: boolean;
15
+ };
16
+
17
+ export type HttpRequestCacheVary = {
18
+ headers?: Array<{ name: string; lowerCase?: boolean }>;
19
+ clientIp?: boolean;
20
+ pathTemplate?: string;
21
+ query?: string[];
22
+ body?: BodyVaryProjection;
23
+ };
24
+
25
+ /** Boolean leaves select fields; nested objects recurse. */
26
+ export type BodyVaryProjection = {
27
+ [key: string]: boolean | BodyVaryProjection;
28
+ };
29
+
30
+ /** Editor wire for $.interface.cacheVaryInfo */
31
+ export type CacheVaryInfoWire = {
32
+ headers?: Array<{ name: string }>;
33
+ query?: string[];
34
+ clientIp?: boolean;
35
+ pathTemplate?: string;
36
+ bodyPaths?: BodyVaryProjection;
37
+ customRuntimeKey?: boolean;
38
+ };
39
+
40
+ /** Seconds (TTL). $.interface.duration */
41
+ export type DurationWire = number;
42
+
43
+ /** Save-only: hooks.save → $.http.configureResponseCaching */
44
+ export type ConfigureResponseCachingOptions = {
45
+ maxAge: number;
46
+ varyBy: HttpRequestCacheVary | CacheVaryInfoWire | '*' | string[];
47
+ mode?: HttpRequestCacheMode;
48
+ refreshAfterSeconds?: number;
49
+ needsRuntimeVaryKey?: boolean;
50
+ };
51
+
52
+ export const HTTP_REQUEST_CACHE_POLICY_KEY = '$httpRequestCachePolicy' as const;
53
+
54
+ export const REPLAY_BINDING_RANGE = '$replayBinding' as const;
55
+
56
+ export const REPLAY_META_RANGE = '$replayMeta' as const;