@process.co/element-types 0.0.18 → 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.
- package/dist/define-action.test-d.d.ts +31 -0
- package/dist/define-action.test-d.d.ts.map +1 -0
- package/dist/define-action.test-d.js +48 -0
- package/dist/define-signal-app-prop.test-d.d.ts +39 -0
- package/dist/define-signal-app-prop.test-d.d.ts.map +1 -0
- package/dist/define-signal-app-prop.test-d.js +32 -0
- package/dist/define-signal-hook-this.test-d.d.ts +27 -0
- package/dist/define-signal-hook-this.test-d.d.ts.map +1 -0
- package/dist/define-signal-hook-this.test-d.js +38 -0
- package/dist/http-request-cache.d.ts +52 -0
- package/dist/http-request-cache.d.ts.map +1 -0
- package/dist/http-request-cache.js +10 -0
- package/dist/index.d.ts +173 -44
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -3
- package/package.json +1 -1
- package/src/define-action.test-d.ts +69 -0
- package/src/define-signal-app-prop.test-d.ts +44 -0
- package/src/define-signal-hook-this.test-d.ts +47 -0
- package/src/http-request-cache.ts +56 -0
- package/src/index.ts +261 -42
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-only checks for defineAction (not emitted).
|
|
3
|
+
*/
|
|
4
|
+
import { type ActionRunOptions } from './index';
|
|
5
|
+
declare const _action: {
|
|
6
|
+
readonly type: "action";
|
|
7
|
+
readonly key: "test-action";
|
|
8
|
+
readonly version: "1.0.0";
|
|
9
|
+
readonly props: {
|
|
10
|
+
readonly label: {
|
|
11
|
+
readonly type: "string";
|
|
12
|
+
readonly default: "";
|
|
13
|
+
};
|
|
14
|
+
readonly http: {
|
|
15
|
+
readonly type: "app";
|
|
16
|
+
readonly app: "http";
|
|
17
|
+
readonly propDefinitions: {
|
|
18
|
+
readonly httpRequest: {
|
|
19
|
+
readonly type: "http_request";
|
|
20
|
+
readonly label: "HTTP Request";
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
readonly methods: {
|
|
26
|
+
readonly run: ({ $, steps }: ActionRunOptions<import("./index").ProcessFunctions>) => Promise<void>;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export type _actionType = typeof _action;
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=define-action.test-d.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-action.test-d.d.ts","sourceRoot":"","sources":["../src/define-action.test-d.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAGH,KAAK,gBAAgB,EAGxB,MAAM,SAAS,CAAC;AAUjB,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;CAiBX,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,OAAO,OAAO,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Compile-only checks for defineAction (not emitted).
|
|
5
|
+
*/
|
|
6
|
+
const index_1 = require("./index");
|
|
7
|
+
const httpApp = (0, index_1.defineApp)({
|
|
8
|
+
type: 'app',
|
|
9
|
+
app: 'http',
|
|
10
|
+
propDefinitions: {
|
|
11
|
+
httpRequest: { type: 'http_request', label: 'HTTP Request' },
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
const _action = (0, index_1.defineAction)({
|
|
15
|
+
type: 'action',
|
|
16
|
+
key: 'test-action',
|
|
17
|
+
version: '1.0.0',
|
|
18
|
+
props: {
|
|
19
|
+
label: { type: 'string', default: '' },
|
|
20
|
+
http: httpApp,
|
|
21
|
+
},
|
|
22
|
+
methods: {
|
|
23
|
+
async run({ $, steps }) {
|
|
24
|
+
void steps;
|
|
25
|
+
$.export('out', {});
|
|
26
|
+
void $.flow;
|
|
27
|
+
this.label;
|
|
28
|
+
this.http.httpRequest.execute;
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
const _runDollarCheck = true;
|
|
33
|
+
const _httpPropCheck = true;
|
|
34
|
+
const _notDefinitionCheck = true;
|
|
35
|
+
const _runOnThisCheck = true;
|
|
36
|
+
/** @deprecated top-level `run` — still accepted for older elements. */
|
|
37
|
+
const _legacyTopLevelRun = (0, index_1.defineAction)({
|
|
38
|
+
type: 'action',
|
|
39
|
+
key: 'legacy-run',
|
|
40
|
+
version: '1.0.0',
|
|
41
|
+
props: {},
|
|
42
|
+
async run({ $, steps }) {
|
|
43
|
+
void steps;
|
|
44
|
+
$.export('legacy', true);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
void _legacyTopLevelRun;
|
|
48
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmaW5lLWFjdGlvbi50ZXN0LWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZGVmaW5lLWFjdGlvbi50ZXN0LWQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQTs7R0FFRztBQUNILG1DQU1pQjtBQUVqQixNQUFNLE9BQU8sR0FBRyxJQUFBLGlCQUFTLEVBQUM7SUFDdEIsSUFBSSxFQUFFLEtBQUs7SUFDWCxHQUFHLEVBQUUsTUFBTTtJQUNYLGVBQWUsRUFBRTtRQUNiLFdBQVcsRUFBRSxFQUFFLElBQUksRUFBRSxjQUFjLEVBQUUsS0FBSyxFQUFFLGNBQWMsRUFBRTtLQUMvRDtDQUNLLENBQUMsQ0FBQztBQUVaLE1BQU0sT0FBTyxHQUFHLElBQUEsb0JBQVksRUFBQztJQUN6QixJQUFJLEVBQUUsUUFBUTtJQUNkLEdBQUcsRUFBRSxhQUFhO0lBQ2xCLE9BQU8sRUFBRSxPQUFPO0lBQ2hCLEtBQUssRUFBRTtRQUNILEtBQUssRUFBRSxFQUFFLElBQUksRUFBRSxRQUFRLEVBQUUsT0FBTyxFQUFFLEVBQUUsRUFBRTtRQUN0QyxJQUFJLEVBQUUsT0FBTztLQUNoQjtJQUNELE9BQU8sRUFBRTtRQUNMLEtBQUssQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEVBQUUsS0FBSyxFQUFFO1lBQ2xCLEtBQUssS0FBSyxDQUFDO1lBQ1gsQ0FBQyxDQUFDLE1BQU0sQ0FBQyxLQUFLLEVBQUUsRUFBRSxDQUFDLENBQUM7WUFDcEIsS0FBSyxDQUFDLENBQUMsSUFBSSxDQUFDO1lBQ1osSUFBSSxDQUFDLEtBQUssQ0FBQztZQUNYLElBQUksQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE9BQU8sQ0FBQztRQUNsQyxDQUFDO0tBQ0o7Q0FDSixDQUFDLENBQUM7QUFPSCxNQUFNLGVBQWUsR0FBcUIsSUFBSSxDQUFDO0FBSy9DLE1BQU0sY0FBYyxHQUFvQixJQUFJLENBQUM7QUFFN0MsTUFBTSxtQkFBbUIsR0FBeUIsSUFBSSxDQUFDO0FBSXZELE1BQU0sZUFBZSxHQUFxQixJQUFJLENBQUM7QUFFL0MsdUVBQXVFO0FBQ3ZFLE1BQU0sa0JBQWtCLEdBQUcsSUFBQSxvQkFBWSxFQUFDO0lBQ3BDLElBQUksRUFBRSxRQUFRO0lBQ2QsR0FBRyxFQUFFLFlBQVk7SUFDakIsT0FBTyxFQUFFLE9BQU87SUFDaEIsS0FBSyxFQUFFLEVBQUU7SUFDVCxLQUFLLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxFQUFFLEtBQUssRUFBRTtRQUNsQixLQUFLLEtBQUssQ0FBQztRQUNYLENBQUMsQ0FBQyxNQUFNLENBQUMsUUFBUSxFQUFFLElBQUksQ0FBQyxDQUFDO0lBQzdCLENBQUM7Q0FDSixDQUFDLENBQUM7QUFFSCxLQUFLLGtCQUFrQixDQUFDIn0=
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-only: embedded `defineApp` in signal `props` (not emitted).
|
|
3
|
+
*/
|
|
4
|
+
import { type DeriveEmbeddedAppPropInstance, type DeriveSignalInstance } from './index';
|
|
5
|
+
declare const httpApp: {
|
|
6
|
+
readonly type: "app";
|
|
7
|
+
readonly app: "http";
|
|
8
|
+
readonly noAuth: true;
|
|
9
|
+
readonly propDefinitions: {
|
|
10
|
+
readonly httpRequest: {
|
|
11
|
+
readonly type: "http_request";
|
|
12
|
+
readonly label: "HTTP Request Configuration";
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
declare const _signal: {
|
|
17
|
+
readonly type: "signal";
|
|
18
|
+
readonly props: {
|
|
19
|
+
readonly httpInterface: {
|
|
20
|
+
readonly type: "$.interface.http";
|
|
21
|
+
};
|
|
22
|
+
readonly http: {
|
|
23
|
+
readonly type: "app";
|
|
24
|
+
readonly app: "http";
|
|
25
|
+
readonly noAuth: true;
|
|
26
|
+
readonly propDefinitions: {
|
|
27
|
+
readonly httpRequest: {
|
|
28
|
+
readonly type: "http_request";
|
|
29
|
+
readonly label: "HTTP Request Configuration";
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
readonly run: () => Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
export type _HttpOnThis = DeriveSignalInstance<typeof _signal>['http'];
|
|
37
|
+
export type _HttpRuntime = DeriveEmbeddedAppPropInstance<typeof httpApp>;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=define-signal-app-prop.test-d.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-signal-app-prop.test-d.d.ts","sourceRoot":"","sources":["../src/define-signal-app-prop.test-d.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAGH,KAAK,6BAA6B,EAClC,KAAK,oBAAoB,EAC5B,MAAM,SAAS,CAAC;AAEjB,QAAA,MAAM,OAAO;;;;;;;;;;CAUF,CAAC;AAEZ,QAAA,MAAM,OAAO;;;;;;;;;;;;;;;;;;;CAUX,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,oBAAoB,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AACvE,MAAM,MAAM,YAAY,GAAG,6BAA6B,CAAC,OAAO,OAAO,CAAC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Compile-only: embedded `defineApp` in signal `props` (not emitted).
|
|
5
|
+
*/
|
|
6
|
+
const index_1 = require("./index");
|
|
7
|
+
const httpApp = (0, index_1.defineApp)({
|
|
8
|
+
type: 'app',
|
|
9
|
+
app: 'http',
|
|
10
|
+
noAuth: true,
|
|
11
|
+
propDefinitions: {
|
|
12
|
+
httpRequest: {
|
|
13
|
+
type: 'http_request',
|
|
14
|
+
label: 'HTTP Request Configuration',
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
const _signal = (0, index_1.defineSignal)({
|
|
19
|
+
type: 'signal',
|
|
20
|
+
props: {
|
|
21
|
+
httpInterface: { type: '$.interface.http' },
|
|
22
|
+
http: httpApp,
|
|
23
|
+
},
|
|
24
|
+
async run() {
|
|
25
|
+
this.http.httpRequest.execute;
|
|
26
|
+
this.httpInterface.deferHttpResponse;
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
const _httpPropCheck = true;
|
|
30
|
+
const _notDefinitionCheck = true;
|
|
31
|
+
const _httpRequestCheck = true;
|
|
32
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmaW5lLXNpZ25hbC1hcHAtcHJvcC50ZXN0LWQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvZGVmaW5lLXNpZ25hbC1hcHAtcHJvcC50ZXN0LWQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQTs7R0FFRztBQUNILG1DQUtpQjtBQUVqQixNQUFNLE9BQU8sR0FBRyxJQUFBLGlCQUFTLEVBQUM7SUFDdEIsSUFBSSxFQUFFLEtBQUs7SUFDWCxHQUFHLEVBQUUsTUFBTTtJQUNYLE1BQU0sRUFBRSxJQUFJO0lBQ1osZUFBZSxFQUFFO1FBQ2IsV0FBVyxFQUFFO1lBQ1QsSUFBSSxFQUFFLGNBQWM7WUFDcEIsS0FBSyxFQUFFLDRCQUE0QjtTQUN0QztLQUNKO0NBQ0ssQ0FBQyxDQUFDO0FBRVosTUFBTSxPQUFPLEdBQUcsSUFBQSxvQkFBWSxFQUFDO0lBQ3pCLElBQUksRUFBRSxRQUFRO0lBQ2QsS0FBSyxFQUFFO1FBQ0gsYUFBYSxFQUFFLEVBQUUsSUFBSSxFQUFFLGtCQUFrQixFQUFFO1FBQzNDLElBQUksRUFBRSxPQUFPO0tBQ2hCO0lBQ0QsS0FBSyxDQUFDLEdBQUc7UUFDTCxJQUFJLENBQUMsSUFBSSxDQUFDLFdBQVcsQ0FBQyxPQUFPLENBQUM7UUFDOUIsSUFBSSxDQUFDLGFBQWEsQ0FBQyxpQkFBaUIsQ0FBQztJQUN6QyxDQUFDO0NBQ0osQ0FBQyxDQUFDO0FBS0gsTUFBTSxjQUFjLEdBQW9CLElBQUksQ0FBQztBQUU3QyxNQUFNLG1CQUFtQixHQUF5QixJQUFJLENBQUM7QUFJdkQsTUFBTSxpQkFBaUIsR0FBdUIsSUFBSSxDQUFDIn0=
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compile-only checks for defineSignal hook vs run `this` (not emitted).
|
|
3
|
+
*/
|
|
4
|
+
import { type SignalSaveHostParameters } from './index';
|
|
5
|
+
declare const _webhook: {
|
|
6
|
+
readonly type: "signal";
|
|
7
|
+
readonly props: {
|
|
8
|
+
readonly httpInterface: {
|
|
9
|
+
readonly type: "$.interface.http";
|
|
10
|
+
};
|
|
11
|
+
readonly cacheMaxAge: {
|
|
12
|
+
readonly type: "$.interface.duration";
|
|
13
|
+
readonly default: 86400;
|
|
14
|
+
};
|
|
15
|
+
readonly authType: {
|
|
16
|
+
readonly type: "string";
|
|
17
|
+
readonly default: "none";
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
readonly hooks: {
|
|
21
|
+
readonly save: ({ $ }: SignalSaveHostParameters) => Promise<void>;
|
|
22
|
+
};
|
|
23
|
+
readonly run: ({ $, event }: import("./index").SignalRunOptions) => Promise<void>;
|
|
24
|
+
};
|
|
25
|
+
export type _webhookType = typeof _webhook;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=define-signal-hook-this.test-d.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-signal-hook-this.test-d.d.ts","sourceRoot":"","sources":["../src/define-signal-hook-this.test-d.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAGH,KAAK,wBAAwB,EAChC,MAAM,SAAS,CAAC;AAEjB,QAAA,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;CA4BZ,CAAC;AAEH,MAAM,MAAM,YAAY,GAAG,OAAO,QAAQ,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
4
|
+
* Compile-only checks for defineSignal hook vs run `this` (not emitted).
|
|
5
|
+
*/
|
|
6
|
+
const index_1 = require("./index");
|
|
7
|
+
const _webhook = (0, index_1.defineSignal)({
|
|
8
|
+
type: 'signal',
|
|
9
|
+
props: {
|
|
10
|
+
httpInterface: { type: '$.interface.http' },
|
|
11
|
+
cacheMaxAge: { type: '$.interface.duration', default: 86400 },
|
|
12
|
+
authType: { type: 'string', default: 'none' },
|
|
13
|
+
},
|
|
14
|
+
hooks: {
|
|
15
|
+
async save({ $ }) {
|
|
16
|
+
await $.http.configureResponseCaching({
|
|
17
|
+
maxAge: this.cacheMaxAge,
|
|
18
|
+
varyBy: '*',
|
|
19
|
+
});
|
|
20
|
+
// @ts-expect-error — `run` host `$` is not available in hooks.save
|
|
21
|
+
$.enforceSchema;
|
|
22
|
+
// @ts-expect-error — `$emit` is only on `run` `this`, not hooks
|
|
23
|
+
this.$emit;
|
|
24
|
+
// @ts-expect-error — no runtime HTTP interface on hook `this`
|
|
25
|
+
await this.httpInterface.respond({ status: 200, body: {} });
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
async run({ $, event }) {
|
|
29
|
+
void event;
|
|
30
|
+
$.enforceSchema;
|
|
31
|
+
// @ts-expect-error — save-only host `$` is not available in run
|
|
32
|
+
$.http;
|
|
33
|
+
await this.httpInterface.deferHttpResponse(30_000);
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
const _saveDollarCheck = true;
|
|
37
|
+
const _saveDollarNotRunCheck = true;
|
|
38
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVmaW5lLXNpZ25hbC1ob29rLXRoaXMudGVzdC1kLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2RlZmluZS1zaWduYWwtaG9vay10aGlzLnRlc3QtZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOztBQUFBOztHQUVHO0FBQ0gsbUNBSWlCO0FBRWpCLE1BQU0sUUFBUSxHQUFHLElBQUEsb0JBQVksRUFBQztJQUMxQixJQUFJLEVBQUUsUUFBUTtJQUNkLEtBQUssRUFBRTtRQUNILGFBQWEsRUFBRSxFQUFFLElBQUksRUFBRSxrQkFBa0IsRUFBRTtRQUMzQyxXQUFXLEVBQUUsRUFBRSxJQUFJLEVBQUUsc0JBQXNCLEVBQUUsT0FBTyxFQUFFLEtBQUssRUFBRTtRQUM3RCxRQUFRLEVBQUUsRUFBRSxJQUFJLEVBQUUsUUFBUSxFQUFFLE9BQU8sRUFBRSxNQUFNLEVBQUU7S0FDaEQ7SUFDRCxLQUFLLEVBQUU7UUFDSCxLQUFLLENBQUMsSUFBSSxDQUFDLEVBQUUsQ0FBQyxFQUFFO1lBQ1osTUFBTSxDQUFDLENBQUMsSUFBSSxDQUFDLHdCQUF3QixDQUFDO2dCQUNsQyxNQUFNLEVBQUUsSUFBSSxDQUFDLFdBQVc7Z0JBQ3hCLE1BQU0sRUFBRSxHQUFHO2FBQ2QsQ0FBQyxDQUFDO1lBQ0gsbUVBQW1FO1lBQ25FLENBQUMsQ0FBQyxhQUFhLENBQUM7WUFDaEIsZ0VBQWdFO1lBQ2hFLElBQUksQ0FBQyxLQUFLLENBQUM7WUFDWCw4REFBOEQ7WUFDOUQsTUFBTSxJQUFJLENBQUMsYUFBYSxDQUFDLE9BQU8sQ0FBQyxFQUFFLE1BQU0sRUFBRSxHQUFHLEVBQUUsSUFBSSxFQUFFLEVBQUUsRUFBRSxDQUFDLENBQUM7UUFDaEUsQ0FBQztLQUNKO0lBQ0QsS0FBSyxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsRUFBRSxLQUFLLEVBQUU7UUFDbEIsS0FBSyxLQUFLLENBQUM7UUFDWCxDQUFDLENBQUMsYUFBYSxDQUFDO1FBQ2hCLGdFQUFnRTtRQUNoRSxDQUFDLENBQUMsSUFBSSxDQUFDO1FBQ1AsTUFBTSxJQUFJLENBQUMsYUFBYSxDQUFDLGlCQUFpQixDQUFDLE1BQU0sQ0FBQyxDQUFDO0lBQ3ZELENBQUM7Q0FDSixDQUFDLENBQUM7QUFPSCxNQUFNLGdCQUFnQixHQUFzQixJQUFJLENBQUM7QUFFakQsTUFBTSxzQkFBc0IsR0FBc0IsSUFBSSxDQUFDIn0=
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP response replay cache — policy at save, vary key at runtime.
|
|
3
|
+
*/
|
|
4
|
+
export type HttpRequestCacheMode = 'cache-only' | 'stale-while-revalidate';
|
|
5
|
+
/** Materialized at save → elementData.$httpRequestCachePolicy */
|
|
6
|
+
export type HttpRequestCachePolicy = {
|
|
7
|
+
mode: HttpRequestCacheMode;
|
|
8
|
+
ttlSeconds: number;
|
|
9
|
+
refreshAfterSeconds?: number;
|
|
10
|
+
vary: HttpRequestCacheVary;
|
|
11
|
+
/** When true, webhook loads trigger so author can call setRequestVaryKey. */
|
|
12
|
+
needsRuntimeVaryKey?: boolean;
|
|
13
|
+
};
|
|
14
|
+
export type HttpRequestCacheVary = {
|
|
15
|
+
headers?: Array<{
|
|
16
|
+
name: string;
|
|
17
|
+
lowerCase?: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
clientIp?: boolean;
|
|
20
|
+
pathTemplate?: string;
|
|
21
|
+
query?: string[];
|
|
22
|
+
body?: BodyVaryProjection;
|
|
23
|
+
};
|
|
24
|
+
/** Boolean leaves select fields; nested objects recurse. */
|
|
25
|
+
export type BodyVaryProjection = {
|
|
26
|
+
[key: string]: boolean | BodyVaryProjection;
|
|
27
|
+
};
|
|
28
|
+
/** Editor wire for $.interface.cacheVaryInfo */
|
|
29
|
+
export type CacheVaryInfoWire = {
|
|
30
|
+
headers?: Array<{
|
|
31
|
+
name: string;
|
|
32
|
+
}>;
|
|
33
|
+
query?: string[];
|
|
34
|
+
clientIp?: boolean;
|
|
35
|
+
pathTemplate?: string;
|
|
36
|
+
bodyPaths?: BodyVaryProjection;
|
|
37
|
+
customRuntimeKey?: boolean;
|
|
38
|
+
};
|
|
39
|
+
/** Seconds (TTL). $.interface.duration */
|
|
40
|
+
export type DurationWire = number;
|
|
41
|
+
/** Save-only: hooks.save → $.http.configureResponseCaching */
|
|
42
|
+
export type ConfigureResponseCachingOptions = {
|
|
43
|
+
maxAge: number;
|
|
44
|
+
varyBy: HttpRequestCacheVary | CacheVaryInfoWire | '*' | string[];
|
|
45
|
+
mode?: HttpRequestCacheMode;
|
|
46
|
+
refreshAfterSeconds?: number;
|
|
47
|
+
needsRuntimeVaryKey?: boolean;
|
|
48
|
+
};
|
|
49
|
+
export declare const HTTP_REQUEST_CACHE_POLICY_KEY: "$httpRequestCachePolicy";
|
|
50
|
+
export declare const REPLAY_BINDING_RANGE: "$replayBinding";
|
|
51
|
+
export declare const REPLAY_META_RANGE: "$replayMeta";
|
|
52
|
+
//# sourceMappingURL=http-request-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http-request-cache.d.ts","sourceRoot":"","sources":["../src/http-request-cache.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG,wBAAwB,CAAC;AAE3E,iEAAiE;AACjE,MAAM,MAAM,sBAAsB,GAAG;IACjC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,IAAI,EAAE,oBAAoB,CAAC;IAC3B,6EAA6E;IAC7E,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IAC/B,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,IAAI,CAAC,EAAE,kBAAkB,CAAC;CAC7B,CAAC;AAEF,4DAA4D;AAC5D,MAAM,MAAM,kBAAkB,GAAG;IAC7B,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,GAAG,kBAAkB,CAAC;CAC/C,CAAC;AAEF,gDAAgD;AAChD,MAAM,MAAM,iBAAiB,GAAG;IAC5B,OAAO,CAAC,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,kBAAkB,CAAC;IAC/B,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC9B,CAAC;AAEF,0CAA0C;AAC1C,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC;AAElC,8DAA8D;AAC9D,MAAM,MAAM,+BAA+B,GAAG;IAC1C,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,oBAAoB,GAAG,iBAAiB,GAAG,GAAG,GAAG,MAAM,EAAE,CAAC;IAClE,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,6BAA6B,EAAG,yBAAkC,CAAC;AAEhF,eAAO,MAAM,oBAAoB,EAAG,gBAAyB,CAAC;AAE9D,eAAO,MAAM,iBAAiB,EAAG,aAAsB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* HTTP response replay cache — policy at save, vary key at runtime.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.REPLAY_META_RANGE = exports.REPLAY_BINDING_RANGE = exports.HTTP_REQUEST_CACHE_POLICY_KEY = void 0;
|
|
7
|
+
exports.HTTP_REQUEST_CACHE_POLICY_KEY = '$httpRequestCachePolicy';
|
|
8
|
+
exports.REPLAY_BINDING_RANGE = '$replayBinding';
|
|
9
|
+
exports.REPLAY_META_RANGE = '$replayMeta';
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaHR0cC1yZXF1ZXN0LWNhY2hlLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vc3JjL2h0dHAtcmVxdWVzdC1jYWNoZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7O0dBRUc7OztBQWlEVSxRQUFBLDZCQUE2QixHQUFHLHlCQUFrQyxDQUFDO0FBRW5FLFFBQUEsb0JBQW9CLEdBQUcsZ0JBQXlCLENBQUM7QUFFakQsUUFBQSxpQkFBaUIsR0FBRyxhQUFzQixDQUFDIn0=
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,7 @@ export type ElementIcon = {
|
|
|
57
57
|
icon: string | ['far' | 'fas' | 'fab' | 'fal' | 'fad', string];
|
|
58
58
|
} | string;
|
|
59
59
|
import type { ISlotInstanceDefinition, ISlotStaticInstanceDefinition, ISlotDefinition } from './slot-definition';
|
|
60
|
+
import { ConfigureResponseCachingOptions } from './http-request-cache';
|
|
60
61
|
export type { ISlotInstanceDefinition, ISlotStaticInstanceDefinition, ISlotDefinition };
|
|
61
62
|
export { builtinActionSlotsRegistry, type BuiltinActionSlotsRegistry, type BuiltinActionSlotsFern, type InferBuiltinActionSlots, } from './builtin-action-slots-registry';
|
|
62
63
|
/** Full **`process-element` CLI** JSON shape (types only; materialize in **`@process.co/compatibility`** **`authoring-spec`**). */
|
|
@@ -65,6 +66,7 @@ export type { ProcessElementPropCliWire, ProcessElementActionCliWire, ProcessEle
|
|
|
65
66
|
export { ELEMENT_AUTHORING_CONTRACT_VERSION } from './authoring-contract-types';
|
|
66
67
|
export type { AuthoringPropWireKind, AuthoringPropContract, SlotBranchAuthoringContract, SlotsAuthoringContract, ActionAuthoringContract, SignalAuthoringContract, ElementAuthoringCatalogContract, ChildStepsPropertyForBranch, ActionPropKeys, ActionContractByFern, FernAuthoringShardFileV1, } from './authoring-contract-types';
|
|
67
68
|
export { PLATFORM_BOUND_LOADER_TYPE_PREFIXES, isPlatformBoundLoaderType, } from './platform-loader-type';
|
|
69
|
+
export { HTTP_REQUEST_CACHE_POLICY_KEY, REPLAY_BINDING_RANGE, REPLAY_META_RANGE, type BodyVaryProjection, type CacheVaryInfoWire, type ConfigureResponseCachingOptions, type DurationWire, type HttpRequestCacheMode, type HttpRequestCachePolicy, type HttpRequestCacheVary, } from './http-request-cache';
|
|
68
70
|
export type ModuleDefinition = {
|
|
69
71
|
type: string;
|
|
70
72
|
app: string;
|
|
@@ -102,7 +104,7 @@ export type SignalEventShape = {
|
|
|
102
104
|
* When {@link HttpInterfaceSchemaWire.validation} is true, the runtime does **not** validate against
|
|
103
105
|
* those JSON blobs alone: it loads the ESM at {@link HttpInterfaceSchemaWire.compiledValidatorKey}
|
|
104
106
|
* (default export = Zod schema) and runs full `safeParse` on the payload via the runner-bound
|
|
105
|
-
* {@link
|
|
107
|
+
* {@link SignalRunHostServices.enforceSchema} RPC (see {@link setSignalEmitValidationHost}).
|
|
106
108
|
*/
|
|
107
109
|
export type HttpInterfaceSchemaWire = {
|
|
108
110
|
/**
|
|
@@ -132,8 +134,11 @@ export type HttpInterfaceSchemaWire = {
|
|
|
132
134
|
*/
|
|
133
135
|
coerceLeafPrimitives?: boolean | 'auto';
|
|
134
136
|
};
|
|
135
|
-
/**
|
|
136
|
-
|
|
137
|
+
/**
|
|
138
|
+
* Host `params.$` during signal **`run`** (live webhook / test execution).
|
|
139
|
+
* Not passed to `hooks.save` — use {@link SignalSaveHookHostServices} there.
|
|
140
|
+
*/
|
|
141
|
+
export type SignalRunHostServices = {
|
|
137
142
|
export: (category: string, message: string) => void | Promise<void>;
|
|
138
143
|
$transitionToSlot: (slots: Array<SlotTransitionDefinition>) => void | Promise<void>;
|
|
139
144
|
/**
|
|
@@ -144,11 +149,23 @@ export type SignalHostServices = {
|
|
|
144
149
|
enforceSchema: <T>(inputSchema: HttpInterfaceSchemaWire | undefined, value: unknown) => Promise<EnforceSchemaResult<T>>;
|
|
145
150
|
/**
|
|
146
151
|
* Wire for the primary `$.interface.schema` property (same persisted object the publish
|
|
147
|
-
* pipeline attaches `compiledValidatorKey` to). Use with {@link
|
|
152
|
+
* pipeline attaches `compiledValidatorKey` to). Use with {@link SignalRunHostServices.enforceSchema},
|
|
148
153
|
* e.g. `await $.enforceSchema($.interfaceEmitSchema, toEmit)`.
|
|
149
154
|
*/
|
|
150
155
|
interfaceEmitSchema?: HttpInterfaceSchemaWire;
|
|
151
156
|
};
|
|
157
|
+
/** @deprecated Use {@link SignalRunHostServices} for `run`; hook `$` types are separate. */
|
|
158
|
+
export type SignalHostServices = SignalRunHostServices;
|
|
159
|
+
/** Host `params.$` during **`hooks.save`** (publish materialization only). */
|
|
160
|
+
export type SignalSaveHookHostServices = {
|
|
161
|
+
http: {
|
|
162
|
+
configureResponseCaching: (options: ConfigureResponseCachingOptions) => Promise<void> | void;
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
/** @deprecated Use {@link SignalSaveHookHostServices} */
|
|
166
|
+
export type HookSaveHostServices = SignalSaveHookHostServices;
|
|
167
|
+
/** Host `params.$` during `hooks.activate` / `hooks.deactivate` (no `run` or `save` surfaces). */
|
|
168
|
+
export type SignalLifecycleHookHostServices = Pick<SignalRunHostServices, 'export'>;
|
|
152
169
|
/** One row from a failed Zod `safeParse` (host / `validateEmitPayload`). */
|
|
153
170
|
export type SchemaValidationIssue = {
|
|
154
171
|
path: string;
|
|
@@ -173,7 +190,7 @@ export type EnforceSchemaResult<T extends unknown = unknown> = {
|
|
|
173
190
|
*/
|
|
174
191
|
export declare const PROCESS_CO_ENFORCE_SCHEMA_HOST_PAYLOAD_MARKER: "enforceSchema";
|
|
175
192
|
export type SignalRunOptions = {
|
|
176
|
-
$:
|
|
193
|
+
$: SignalRunHostServices;
|
|
177
194
|
event: SignalEventShape;
|
|
178
195
|
};
|
|
179
196
|
export type ValidateEmitPayloadResult<T> = {
|
|
@@ -186,9 +203,9 @@ export type ValidateEmitPayloadResult<T> = {
|
|
|
186
203
|
};
|
|
187
204
|
/**
|
|
188
205
|
* Host shape accepted from the runner RPC bridge (`$.enforceSchema` may be typed as
|
|
189
|
-
* returning `Promise<unknown>` while {@link
|
|
206
|
+
* returning `Promise<unknown>` while {@link SignalRunHostServices} uses a generic `T`).
|
|
190
207
|
*/
|
|
191
|
-
export type SignalEmitValidationHostBinding = Pick<
|
|
208
|
+
export type SignalEmitValidationHostBinding = Pick<SignalRunHostServices, 'enforceSchema'> | {
|
|
192
209
|
enforceSchema?: (inputSchema: HttpInterfaceSchemaWire | undefined, value: unknown) => Promise<unknown>;
|
|
193
210
|
};
|
|
194
211
|
/**
|
|
@@ -471,6 +488,11 @@ export type HttpInterfaceType = {
|
|
|
471
488
|
* @param timeoutMs Time to first byte in milliseconds. Defaults to {@link DEFAULT_DEFER_HTTP_RESPONSE_MS} (30s) when omitted.
|
|
472
489
|
*/
|
|
473
490
|
deferHttpResponse: (timeoutMs?: number, options?: HttpDeferResponseOptions) => void;
|
|
491
|
+
/**
|
|
492
|
+
* Optional runtime vary suffix (hashed and appended to the HTTP base scenario key).
|
|
493
|
+
* Call when saved `$httpRequestCachePolicy.needsRuntimeVaryKey` is true.
|
|
494
|
+
*/
|
|
495
|
+
setRequestVaryKey: (value: string) => void;
|
|
474
496
|
/**
|
|
475
497
|
* Append one JSON value to an incremental stream (`ndjson` or `jsonArray` defer modes). Each call is one line (NDJSON) or one array element (json-array).
|
|
476
498
|
*/
|
|
@@ -494,8 +516,29 @@ type PropTypeFromTypeValue<U, T = unknown> = U extends z.ZodObject<any, any> ? I
|
|
|
494
516
|
headers?: Record<string, string>;
|
|
495
517
|
[key: string]: any;
|
|
496
518
|
}>;
|
|
497
|
-
} : U extends "string" ? [PropOptionsValue<T>] extends [never] ? string : PropOptionsValue<T> : U extends "string(html)" ? string : U extends "string(markdown)" ? string : U extends "string(json)" ? string : U extends "string(xml)" ? string : U extends "string(yaml)" ? string : U extends "string(base64)" ? string : U extends "string(javascript)" ? string : U extends "string(csv)" ? string : U extends "string(tsv)" ? string : U extends "string(css)" ? string : U extends "string(sql)" ? string : U extends "string(email)" ? string : U extends "string(emailList)" ? string[] : U extends "string(urlList)" ? string[] : U extends "string(url)" ? string : U extends `$infer<${string}>` ? InferType<U> : U extends "$infer" ? any : U extends "object" ? Record<string, unknown> : U extends `object(${PropObjectDefinitionTypes})` ? any : U extends `file(${PropFileDefinitionTypes})` ? IFile : U extends "number" ? number : U extends "boolean" ? boolean : U extends "integer" ? number : U extends "$.interface.schema" ? HttpInterfaceSchemaWire : U extends "$.interface.http" ? HttpInterfaceType : unknown;
|
|
519
|
+
} : U extends "string" ? [PropOptionsValue<T>] extends [never] ? string : PropOptionsValue<T> : U extends "string(html)" ? string : U extends "string(markdown)" ? string : U extends "string(json)" ? string : U extends "string(xml)" ? string : U extends "string(yaml)" ? string : U extends "string(base64)" ? string : U extends "string(javascript)" ? string : U extends "string(csv)" ? string : U extends "string(tsv)" ? string : U extends "string(css)" ? string : U extends "string(sql)" ? string : U extends "string(email)" ? string : U extends "string(emailList)" ? string[] : U extends "string(urlList)" ? string[] : U extends "string(url)" ? string : U extends `$infer<${string}>` ? InferType<U> : U extends "$infer" ? any : U extends "object" ? Record<string, unknown> : U extends `object(${PropObjectDefinitionTypes})` ? any : U extends `file(${PropFileDefinitionTypes})` ? IFile : U extends "number" ? number : U extends "boolean" ? boolean : U extends "integer" ? number : U extends "$.interface.schema" ? HttpInterfaceSchemaWire : U extends "$.interface.http" ? HttpInterfaceType : U extends "$.interface.duration" ? import('./http-request-cache').DurationWire : U extends "$.interface.cacheVaryInfo" ? import('./http-request-cache').CacheVaryInfoWire : unknown;
|
|
520
|
+
/**
|
|
521
|
+
* Runtime shape of an embedded app prop (`props: { http: httpApp }` on a signal/action).
|
|
522
|
+
* Maps `propDefinitions` / `props` / `methods` to instance fields — not the `defineApp` module metadata (`type`, `app`, …).
|
|
523
|
+
*/
|
|
524
|
+
export type DeriveEmbeddedAppPropInstance<T extends {
|
|
525
|
+
type: 'app';
|
|
526
|
+
}> = Spread<(T extends {
|
|
527
|
+
propDefinitions: Record<string, any>;
|
|
528
|
+
} ? {
|
|
529
|
+
[K in keyof T['propDefinitions']]: PropType<T['propDefinitions'][K]>;
|
|
530
|
+
} : {}) & (T extends {
|
|
531
|
+
props: Record<string, any>;
|
|
532
|
+
} ? {
|
|
533
|
+
[K in keyof T['props']]: PropType<T['props'][K]>;
|
|
534
|
+
} : {}) & (T extends {
|
|
535
|
+
methods: Record<string, any>;
|
|
536
|
+
} ? {
|
|
537
|
+
[K in keyof T['methods']]: T['methods'][K];
|
|
538
|
+
} : {})>;
|
|
498
539
|
export type PropType<T> = T extends {
|
|
540
|
+
type: 'app';
|
|
541
|
+
} ? DeriveEmbeddedAppPropInstance<T> : T extends {
|
|
499
542
|
props: Record<string, any>;
|
|
500
543
|
methods: Record<string, any>;
|
|
501
544
|
} ? DeriveAppInstance<T> : T extends {
|
|
@@ -536,37 +579,69 @@ export type DeriveAppInstance<T> = Spread<Omit<T, "props" | "propDefinitions" |
|
|
|
536
579
|
} : {}) & {
|
|
537
580
|
[K in keyof T as K extends "props" | "propDefinitions" | "methods" ? never : K]: T[K];
|
|
538
581
|
}>;
|
|
539
|
-
|
|
582
|
+
/** True when a prop definition resolves to `$.interface.http` (runtime-only on `run`). */
|
|
583
|
+
type IsHttpInterfacePropDef<P> = P extends {
|
|
584
|
+
type: '$.interface.http';
|
|
585
|
+
} ? true : P extends {
|
|
586
|
+
propDefinition: readonly [infer App, infer PropName];
|
|
587
|
+
} ? App extends {
|
|
588
|
+
propDefinitions: Record<string, any>;
|
|
589
|
+
} ? PropName extends keyof App['propDefinitions'] ? App['propDefinitions'][PropName] extends {
|
|
590
|
+
type: '$.interface.http';
|
|
591
|
+
} ? true : false : false : App extends {
|
|
592
|
+
props: Record<string, any>;
|
|
593
|
+
} ? PropName extends keyof App['props'] ? App['props'][PropName] extends {
|
|
594
|
+
type: '$.interface.http';
|
|
595
|
+
} ? true : false : false : false : false;
|
|
596
|
+
export type DeriveSignalInstance<T> = Spread<Omit<T, SignalInstanceExcludedKeys> & (T extends {
|
|
540
597
|
props: Record<string, any>;
|
|
541
598
|
} ? {
|
|
542
|
-
[K in keyof T[
|
|
599
|
+
[K in keyof T['props']]: PropType<T['props'][K]>;
|
|
543
600
|
} : {}) & (T extends {
|
|
544
601
|
propDefinitions: Record<string, any>;
|
|
545
602
|
} ? {
|
|
546
|
-
[K in keyof T[
|
|
603
|
+
[K in keyof T['propDefinitions']]: PropType<T['propDefinitions'][K]>;
|
|
547
604
|
} : {}) & EmitFunction & (T extends {
|
|
548
605
|
methods: Record<string, any>;
|
|
549
606
|
} ? {
|
|
550
|
-
[K in keyof T[
|
|
607
|
+
[K in keyof T['methods']]: T['methods'][K];
|
|
551
608
|
} : {}) & {
|
|
552
|
-
[K in keyof T as K extends
|
|
609
|
+
[K in keyof T as K extends SignalInstanceExcludedKeys ? never : K]: T[K];
|
|
553
610
|
}>;
|
|
611
|
+
/** Module definition keys that are not instance fields on `this` in `run` or hooks. */
|
|
612
|
+
type SignalInstanceExcludedKeys = 'props' | 'propDefinitions' | 'methods' | 'run' | 'hooks';
|
|
613
|
+
/** Prop names on `T` that are `$.interface.http` (excluded from hook `this`). */
|
|
614
|
+
type HttpInterfacePropKeys<T> = T extends {
|
|
615
|
+
props: infer P extends Record<string, unknown>;
|
|
616
|
+
} ? keyof {
|
|
617
|
+
[K in keyof P as IsHttpInterfacePropDef<P[K]> extends true ? K : never]: true;
|
|
618
|
+
} : never;
|
|
619
|
+
/**
|
|
620
|
+
* `this` inside signal hooks: instance props minus `$.interface.http` and `$emit`.
|
|
621
|
+
* Use `params.$.http.configureResponseCaching` in `save`.
|
|
622
|
+
*/
|
|
623
|
+
export type DeriveSignalHookInstance<T> = Omit<DeriveSignalInstance<T>, HttpInterfacePropKeys<T> | keyof EmitFunction>;
|
|
554
624
|
export type PropDefinitionType<App, PropName extends string> = App extends {
|
|
555
625
|
propDefinitions: Record<string, any>;
|
|
556
626
|
} ? PropName extends keyof App['propDefinitions'] ? PropType<App['propDefinitions'][PropName]> : unknown : unknown;
|
|
557
|
-
|
|
627
|
+
/** Module definition keys that are not instance fields on `this` in `run`. */
|
|
628
|
+
type ActionInstanceExcludedKeys = 'props' | 'propDefinitions' | 'methods' | 'run' | 'type' | 'name' | 'description' | 'icon' | 'noAuth' | 'slots' | 'hasNew' | 'initValue';
|
|
629
|
+
/** Runtime `this` for action `run` (prop values via {@link PropType}, including embedded apps). */
|
|
630
|
+
export type DeriveActionInstance<T> = Spread<Omit<T, ActionInstanceExcludedKeys> & (T extends {
|
|
558
631
|
props: Record<string, any>;
|
|
559
632
|
} ? {
|
|
560
|
-
[K in keyof T[
|
|
633
|
+
[K in keyof T['props']]: PropType<T['props'][K]>;
|
|
561
634
|
} : {}) & (T extends {
|
|
562
635
|
propDefinitions: Record<string, any>;
|
|
563
636
|
} ? {
|
|
564
|
-
[K in keyof T[
|
|
637
|
+
[K in keyof T['propDefinitions']]: PropType<T['propDefinitions'][K]>;
|
|
565
638
|
} : {}) & (T extends {
|
|
566
639
|
methods: Record<string, any>;
|
|
567
640
|
} ? {
|
|
568
|
-
[K in keyof T[
|
|
569
|
-
} : {})
|
|
641
|
+
[K in keyof T['methods']]: T['methods'][K];
|
|
642
|
+
} : {}) & {
|
|
643
|
+
[K in keyof T as K extends ActionInstanceExcludedKeys ? never : K]: T[K];
|
|
644
|
+
}>;
|
|
570
645
|
export type ModuleWithThis<T> = T & ThisType<DeriveActionInstance<T>>;
|
|
571
646
|
export interface Action<P extends Record<string, any> = Record<string, any>> extends ModuleDefinition {
|
|
572
647
|
type: "action";
|
|
@@ -581,9 +656,7 @@ export interface Signal<P extends Record<string, any> = Record<string, any>> ext
|
|
|
581
656
|
export type ActionInstance<A extends Action> = DeriveActionInstance<A>;
|
|
582
657
|
export type SignalInstance<S extends Signal> = DeriveSignalInstance<S>;
|
|
583
658
|
export type SignalMethod<S extends Signal> = (this: SignalInstance<S>, params: SignalRunOptions) => Promise<unknown>;
|
|
584
|
-
export type ActionMethod<A extends Action> = (this: ActionInstance<A>, params:
|
|
585
|
-
$: any;
|
|
586
|
-
}) => Promise<unknown>;
|
|
659
|
+
export type ActionMethod<A extends Action> = (this: ActionInstance<A>, params: ActionRunOptions) => Promise<unknown>;
|
|
587
660
|
export type PropStringDefinitionTypes = "text" | "html" | "markdown" | "json" | "xml" | "yaml" | "csv" | "tsv" | "css" | "sql" | "email" | "emailList" | "urlList" | "url" | "base64" | "javascript";
|
|
588
661
|
export type PropObjectDefinitionTypes = "json" | "base64";
|
|
589
662
|
export type PropFileDefinitionTypes = "url" | "base64";
|
|
@@ -596,30 +669,86 @@ type SchemaPropDefinition<TSchema extends z.ZodTypeAny = z.ZodTypeAny> = BasePro
|
|
|
596
669
|
};
|
|
597
670
|
export type PropDefinition = StringPropDefinition | SchemaPropDefinition;
|
|
598
671
|
export declare function defineApp<const T extends object>(app: T & ThisType<DeriveAppInstance<T>>): T;
|
|
599
|
-
export
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
672
|
+
export type ActionRunFn = (params: ActionRunOptions) => void | Promise<unknown>;
|
|
673
|
+
/** Canonical action entrypoint — implement `run` here (see process-internal loop, etc.). */
|
|
674
|
+
export type ActionMethodsRun = {
|
|
675
|
+
methods: Record<string, unknown> & {
|
|
676
|
+
run: ActionRunFn;
|
|
677
|
+
};
|
|
678
|
+
};
|
|
679
|
+
/**
|
|
680
|
+
* @deprecated Use `methods: { run }` instead of a top-level `run` property.
|
|
681
|
+
* Runtime still accepts this shape via `restructureElement`.
|
|
682
|
+
*/
|
|
683
|
+
export type ActionMethodsLegacyTopLevelRun = {
|
|
684
|
+
/** @deprecated Use `methods.run`. */
|
|
685
|
+
run?: ActionRunFn;
|
|
686
|
+
};
|
|
687
|
+
/** Minimum shape for {@link defineAction}. Prefer {@link ActionMethodsRun}. */
|
|
688
|
+
export type ActionMethods = ActionMethodsRun | ActionMethodsLegacyTopLevelRun;
|
|
689
|
+
/** Structural requirements for an action module (tooling; prefer {@link defineAction}). */
|
|
690
|
+
export type ActionDefinitionShape<T> = {
|
|
691
|
+
methods: Record<string, unknown> & {
|
|
692
|
+
run: (this: DeriveActionInstance<T>, params: ActionRunOptions) => Promise<unknown>;
|
|
693
|
+
};
|
|
694
|
+
/**
|
|
695
|
+
* @deprecated Use `methods.run`.
|
|
696
|
+
*/
|
|
697
|
+
run?: (this: DeriveActionInstance<T>, params: ActionRunOptions) => Promise<unknown>;
|
|
698
|
+
};
|
|
699
|
+
/** Contextual `this` for top-level and `methods.*` action functions. */
|
|
700
|
+
export type ActionMethodsWithThis<T> = T & ThisType<DeriveActionInstance<T>> & (T extends {
|
|
701
|
+
methods?: infer M extends Record<string, unknown>;
|
|
702
|
+
} ? {
|
|
703
|
+
methods: M & ThisType<DeriveActionInstance<T>>;
|
|
704
|
+
} : {});
|
|
705
|
+
export declare function defineAction<const T extends ActionMethods & {
|
|
706
|
+
type: 'action';
|
|
707
|
+
} & Record<string, unknown>>(action: ActionMethodsWithThis<T>): T;
|
|
708
|
+
/** `params.$` for `hooks.activate` / `hooks.deactivate`. */
|
|
709
|
+
export type SignalHostHookParameters = {
|
|
710
|
+
$: SignalLifecycleHookHostServices;
|
|
711
|
+
};
|
|
712
|
+
/** `params.$` for `hooks.save` — publish-only; not {@link SignalRunHostServices}. */
|
|
713
|
+
export type SignalSaveHostParameters = {
|
|
714
|
+
$: SignalSaveHookHostServices;
|
|
715
|
+
};
|
|
716
|
+
export type SignalHostHookMethod<T> = (this: DeriveSignalHookInstance<T>, params: SignalHostHookParameters) => void | Promise<void>;
|
|
717
|
+
export type SignalSaveHookMethod<T> = (this: DeriveSignalHookInstance<T>, params: SignalSaveHostParameters) => void | Promise<void>;
|
|
718
|
+
export type SignalHooksDefinition<T> = {
|
|
719
|
+
deactivate?: SignalHostHookMethod<T>;
|
|
720
|
+
activate?: SignalHostHookMethod<T>;
|
|
721
|
+
save?: SignalSaveHookMethod<T>;
|
|
722
|
+
onDeactivate?: SignalHostHookMethod<T>;
|
|
723
|
+
onActivate?: SignalHostHookMethod<T>;
|
|
724
|
+
onSave?: SignalSaveHookMethod<T>;
|
|
725
|
+
};
|
|
726
|
+
/**
|
|
727
|
+
* Hook implementations for {@link defineSignal}: `params.$` is typed here; `this` comes from
|
|
728
|
+
* {@link ThisType}<{@link DeriveSignalHookInstance}<T>> (avoids circular `T` and empty `this`).
|
|
729
|
+
*/
|
|
730
|
+
export type SignalHooksContextualDefinition = {
|
|
731
|
+
deactivate?: (params: SignalHostHookParameters) => void | Promise<void>;
|
|
732
|
+
activate?: (params: SignalHostHookParameters) => void | Promise<void>;
|
|
733
|
+
save?: (params: SignalSaveHostParameters) => void | Promise<void>;
|
|
734
|
+
onDeactivate?: (params: SignalHostHookParameters) => void | Promise<void>;
|
|
735
|
+
onActivate?: (params: SignalHostHookParameters) => void | Promise<void>;
|
|
736
|
+
onSave?: (params: SignalSaveHostParameters) => void | Promise<void>;
|
|
737
|
+
};
|
|
738
|
+
/** Hook bag for {@link defineSignal}. */
|
|
739
|
+
export type SignalHooksWithThis<T> = SignalHooksContextualDefinition & ThisType<DeriveSignalHookInstance<T>>;
|
|
740
|
+
/** Structural requirements for a signal module (used by tooling; prefer {@link defineSignal}). */
|
|
741
|
+
export type SignalDefinitionShape<T> = {
|
|
742
|
+
run: (this: DeriveSignalInstance<T>, params: SignalRunOptions) => Promise<unknown>;
|
|
743
|
+
hooks?: SignalHooksDefinition<T>;
|
|
744
|
+
};
|
|
745
|
+
/** @deprecated Use {@link defineSignal} — kept for generated lib compatibility. */
|
|
746
|
+
export type SignalMethods = {
|
|
621
747
|
run: (params: SignalRunOptions) => Promise<unknown>;
|
|
622
|
-
}
|
|
748
|
+
};
|
|
749
|
+
export declare function defineSignal<const T extends SignalMethods & Record<string, unknown>>(signal: T & ThisType<DeriveSignalInstance<T>> & {
|
|
750
|
+
hooks?: SignalHooksWithThis<T>;
|
|
751
|
+
}): T;
|
|
623
752
|
export type RunReturn<T> = T extends {
|
|
624
753
|
run: (...args: any[]) => infer R;
|
|
625
754
|
} ? Awaited<R> : never;
|