@iyio/protogen 0.0.9 → 0.0.11
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/esm/src/index.d.ts +6 -0
- package/esm/src/index.js +6 -0
- package/esm/src/index.js.map +1 -1
- package/esm/src/lib/ProtoExpressionEngine.d.ts +16 -0
- package/esm/src/lib/ProtoExpressionEngine.js +358 -0
- package/esm/src/lib/ProtoExpressionEngine.js.map +1 -0
- package/esm/src/lib/executeProtoPipelineAsync.js +22 -11
- package/esm/src/lib/executeProtoPipelineAsync.js.map +1 -1
- package/esm/src/lib/markdown.d.ts +1 -0
- package/esm/src/lib/markdown.js +36 -7
- package/esm/src/lib/markdown.js.map +1 -1
- package/esm/src/lib/protogen-expression-ctrls.d.ts +2 -0
- package/esm/src/lib/protogen-expression-ctrls.js +284 -0
- package/esm/src/lib/protogen-expression-ctrls.js.map +1 -0
- package/esm/src/lib/protogen-expression-lib.d.ts +16 -0
- package/esm/src/lib/protogen-expression-lib.js +101 -0
- package/esm/src/lib/protogen-expression-lib.js.map +1 -0
- package/esm/src/lib/protogen-expression-types.d.ts +160 -0
- package/esm/src/lib/protogen-expression-types.js +46 -0
- package/esm/src/lib/protogen-expression-types.js.map +1 -0
- package/esm/src/lib/protogen-lib.d.ts +17 -1
- package/esm/src/lib/protogen-lib.js +67 -0
- package/esm/src/lib/protogen-lib.js.map +1 -1
- package/esm/src/lib/protogen-pipeline-types.d.ts +17 -1
- package/esm/src/lib/protogen-pipeline-types.js.map +1 -1
- package/esm/src/lib/protogen-pipeline.js +0 -2
- package/esm/src/lib/protogen-pipeline.js.map +1 -1
- package/esm/src/lib/protogen-plugin-util.d.ts +4 -1
- package/esm/src/lib/protogen-plugin-util.js +65 -2
- package/esm/src/lib/protogen-plugin-util.js.map +1 -1
- package/esm/src/lib/protogen-types.d.ts +72 -0
- package/esm/src/lib/protogen-types.js +8 -1
- package/esm/src/lib/protogen-types.js.map +1 -1
- package/esm/src/lib/protogen-workflow-lib.d.ts +7 -0
- package/esm/src/lib/protogen-workflow-lib.js +53 -0
- package/esm/src/lib/protogen-workflow-lib.js.map +1 -0
- package/esm/src/lib/protogen-workflow-types.d.ts +95 -0
- package/esm/src/lib/protogen-workflow-types.js +2 -0
- package/esm/src/lib/protogen-workflow-types.js.map +1 -0
- package/esm/src/lib/typescript-utils.js +1 -1
- package/esm/src/lib/typescript-utils.js.map +1 -1
- package/package.json +18 -8
- package/src/index.d.ts +6 -0
- package/src/index.js +6 -0
- package/src/index.js.map +1 -1
- package/src/lib/ProtoExpressionEngine.d.ts +16 -0
- package/src/lib/ProtoExpressionEngine.js +363 -0
- package/src/lib/ProtoExpressionEngine.js.map +1 -0
- package/src/lib/executeProtoPipelineAsync.js +22 -11
- package/src/lib/executeProtoPipelineAsync.js.map +1 -1
- package/src/lib/markdown.d.ts +1 -0
- package/src/lib/markdown.js +38 -8
- package/src/lib/markdown.js.map +1 -1
- package/src/lib/protogen-expression-ctrls.d.ts +2 -0
- package/src/lib/protogen-expression-ctrls.js +288 -0
- package/src/lib/protogen-expression-ctrls.js.map +1 -0
- package/src/lib/protogen-expression-lib.d.ts +16 -0
- package/src/lib/protogen-expression-lib.js +114 -0
- package/src/lib/protogen-expression-lib.js.map +1 -0
- package/src/lib/protogen-expression-types.d.ts +160 -0
- package/src/lib/protogen-expression-types.js +50 -0
- package/src/lib/protogen-expression-types.js.map +1 -0
- package/src/lib/protogen-lib.d.ts +17 -1
- package/src/lib/protogen-lib.js +72 -1
- package/src/lib/protogen-lib.js.map +1 -1
- package/src/lib/protogen-pipeline-types.d.ts +17 -1
- package/src/lib/protogen-pipeline-types.js.map +1 -1
- package/src/lib/protogen-pipeline.js +0 -2
- package/src/lib/protogen-pipeline.js.map +1 -1
- package/src/lib/protogen-plugin-util.d.ts +4 -1
- package/src/lib/protogen-plugin-util.js +68 -3
- package/src/lib/protogen-plugin-util.js.map +1 -1
- package/src/lib/protogen-types.d.ts +72 -0
- package/src/lib/protogen-types.js +11 -0
- package/src/lib/protogen-types.js.map +1 -1
- package/src/lib/protogen-workflow-lib.d.ts +7 -0
- package/src/lib/protogen-workflow-lib.js +59 -0
- package/src/lib/protogen-workflow-lib.js.map +1 -0
- package/src/lib/protogen-workflow-types.d.ts +95 -0
- package/src/lib/protogen-workflow-types.js +3 -0
- package/src/lib/protogen-workflow-types.js.map +1 -0
- package/src/lib/typescript-utils.js +1 -1
- package/src/lib/typescript-utils.js.map +1 -1
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getProtoExpressionValueByPath = exports.getCallableProtoExpressions = exports.UnableToFindProtoExpressionResumeId = exports.ProtoExpressionPauseNotAllowedError = exports.MaxProtoExpressionEvalCountError = exports.InvalidProtoExpressionSyntaxError = exports.ProtoExpressionError = exports.getDirectExpressionValue = exports.createProtoExpressionControlFlowResult = exports.parseProtoExpression = void 0;
|
|
4
|
+
const common_1 = require("@iyio/common");
|
|
5
|
+
const protogen_expression_types_1 = require("./protogen-expression-types");
|
|
6
|
+
const protogen_lib_1 = require("./protogen-lib");
|
|
7
|
+
const parseProtoExpression = ({ node, filterPaths }) => {
|
|
8
|
+
return _parseProtoExpression(node, node.name, filterPaths, null);
|
|
9
|
+
};
|
|
10
|
+
exports.parseProtoExpression = parseProtoExpression;
|
|
11
|
+
const typeDefiners = ['vars', 'props'];
|
|
12
|
+
const _parseProtoExpression = (node, path, filterPaths, parent) => {
|
|
13
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
14
|
+
const definesTypes = typeDefiners.includes(parent === null || parent === void 0 ? void 0 : parent.ctrl);
|
|
15
|
+
const isDotPath = (_b = (_a = node.types) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.dot;
|
|
16
|
+
const isRefType = !isDotPath && ((_d = (_c = node.types) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.isRefType);
|
|
17
|
+
const copySource = (_f = (_e = node.types) === null || _e === void 0 ? void 0 : _e[0]) === null || _f === void 0 ? void 0 : _f.copySource;
|
|
18
|
+
const expression = (definesTypes ? {
|
|
19
|
+
name: path,
|
|
20
|
+
type: node.type || 'any',
|
|
21
|
+
value: node.valueEq ? (0, protogen_lib_1.parseProtoPrimitiveUndefined)(node.value) : undefined
|
|
22
|
+
}
|
|
23
|
+
: (!filterPaths || filterPaths.some(p => path.startsWith(p))) ?
|
|
24
|
+
{
|
|
25
|
+
name: node.name,
|
|
26
|
+
path: isDotPath ? ((_g = node.value) === null || _g === void 0 ? void 0 : _g.startsWith('.')) ? node.value.substring(1) : node.value : undefined,
|
|
27
|
+
address: isDotPath || copySource ? undefined : (_j = (_h = node.links) === null || _h === void 0 ? void 0 : _h[0]) === null || _j === void 0 ? void 0 : _j.address,
|
|
28
|
+
value: ((isRefType && !copySource) || isDotPath) ? undefined : (0, protogen_lib_1.parseProtoPrimitiveUndefined)((_k = node.value) === null || _k === void 0 ? void 0 : _k.replace(/^@/, '')),
|
|
29
|
+
invert: ((_m = (_l = node.types) === null || _l === void 0 ? void 0 : _l[0]) === null || _m === void 0 ? void 0 : _m.ex) === true ? true : undefined,
|
|
30
|
+
ctrl: protogen_expression_types_1.builtInProtoExpressionCtrlTypes.includes(node.name) ? node.name : undefined,
|
|
31
|
+
}
|
|
32
|
+
:
|
|
33
|
+
{
|
|
34
|
+
name: node.name,
|
|
35
|
+
});
|
|
36
|
+
if (node.tags) {
|
|
37
|
+
if (node.tags.includes('map')) {
|
|
38
|
+
expression.map = true;
|
|
39
|
+
}
|
|
40
|
+
if (node.tags.includes('set')) {
|
|
41
|
+
const i = node.address.indexOf('.');
|
|
42
|
+
expression.setAs = i === -1 ? node.address : node.address.substring(i + 1);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (node.children) {
|
|
46
|
+
for (const n in node.children) {
|
|
47
|
+
const child = node.children[n];
|
|
48
|
+
if (!child || child.isContent || child.special) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
const sub = _parseProtoExpression(child, path ? path + '.' + n : n, filterPaths, expression);
|
|
52
|
+
if (!expression.sub) {
|
|
53
|
+
expression.sub = [];
|
|
54
|
+
}
|
|
55
|
+
expression.sub.push(sub);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return expression;
|
|
59
|
+
};
|
|
60
|
+
const createProtoExpressionControlFlowResult = (result) => (Object.assign({ typeFlag: protogen_expression_types_1.ProtoExpressionControlFlowFlag }, result));
|
|
61
|
+
exports.createProtoExpressionControlFlowResult = createProtoExpressionControlFlowResult;
|
|
62
|
+
const getDirectExpressionValue = (expression, context) => {
|
|
63
|
+
let value;
|
|
64
|
+
if (expression.path) {
|
|
65
|
+
value = context.vars[expression.path];
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
value = expression.value;
|
|
69
|
+
}
|
|
70
|
+
if (expression.invert) {
|
|
71
|
+
value = !value;
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
};
|
|
75
|
+
exports.getDirectExpressionValue = getDirectExpressionValue;
|
|
76
|
+
class ProtoExpressionError extends Error {
|
|
77
|
+
}
|
|
78
|
+
exports.ProtoExpressionError = ProtoExpressionError;
|
|
79
|
+
class InvalidProtoExpressionSyntaxError extends ProtoExpressionError {
|
|
80
|
+
}
|
|
81
|
+
exports.InvalidProtoExpressionSyntaxError = InvalidProtoExpressionSyntaxError;
|
|
82
|
+
class MaxProtoExpressionEvalCountError extends ProtoExpressionError {
|
|
83
|
+
}
|
|
84
|
+
exports.MaxProtoExpressionEvalCountError = MaxProtoExpressionEvalCountError;
|
|
85
|
+
class ProtoExpressionPauseNotAllowedError extends ProtoExpressionError {
|
|
86
|
+
}
|
|
87
|
+
exports.ProtoExpressionPauseNotAllowedError = ProtoExpressionPauseNotAllowedError;
|
|
88
|
+
class UnableToFindProtoExpressionResumeId extends ProtoExpressionError {
|
|
89
|
+
}
|
|
90
|
+
exports.UnableToFindProtoExpressionResumeId = UnableToFindProtoExpressionResumeId;
|
|
91
|
+
const getCallableProtoExpressions = (expression, append = []) => {
|
|
92
|
+
if (expression.address) {
|
|
93
|
+
append.push(expression);
|
|
94
|
+
}
|
|
95
|
+
if (expression.sub) {
|
|
96
|
+
for (const sub of expression.sub) {
|
|
97
|
+
(0, exports.getCallableProtoExpressions)(sub, append);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return append;
|
|
101
|
+
};
|
|
102
|
+
exports.getCallableProtoExpressions = getCallableProtoExpressions;
|
|
103
|
+
const getProtoExpressionValueByPath = (path, context) => {
|
|
104
|
+
if (path.startsWith('.')) {
|
|
105
|
+
path = path.substring(1);
|
|
106
|
+
}
|
|
107
|
+
let val = context.vars[path];
|
|
108
|
+
if (val === undefined) {
|
|
109
|
+
val = (0, common_1.getValueByPath)(context.vars, path, undefined);
|
|
110
|
+
}
|
|
111
|
+
return val;
|
|
112
|
+
};
|
|
113
|
+
exports.getProtoExpressionValueByPath = getProtoExpressionValueByPath;
|
|
114
|
+
//# sourceMappingURL=protogen-expression-lib.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protogen-expression-lib.js","sourceRoot":"","sources":["../../../../../packages/protogen/src/lib/protogen-expression-lib.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAC9C,2EAAsP;AACtP,iDAA8D;AAGvD,MAAM,oBAAoB,GAAC,CAAC,EAC/B,IAAI,EACJ,WAAW,EACW,EAAiB,EAAE;IACzC,OAAO,qBAAqB,CAAC,IAAI,EAAC,IAAI,CAAC,IAAI,EAAC,WAAW,EAAC,IAAI,CAAC,CAAC;AAClE,CAAC,CAAA;AALY,QAAA,oBAAoB,wBAKhC;AAED,MAAM,YAAY,GAA2B,CAAC,MAAM,EAAC,OAAO,CAAC,CAAC;AAE9D,MAAM,qBAAqB,GAAC,CAAC,IAAc,EAAC,IAAW,EAAC,WAA8B,EAAC,M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Aa,mCAAoC,SAAQ,oBAAoB;CAG5E;AAHD,kFAGC;AAEM,MAAM,2BAA2B,GAAC,CAAC,UAA0B,EAAE,SAAyB,EAAE,EAAmB,EAAE;IAElH,IAAG,UAAU,CAAC,OAAO,EAAC;QAClB,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;KAC3B;IAED,IAAG,UAAU,CAAC,GAAG,EAAC;QACd,KAAI,MAAM,GAAG,IAAI,UAAU,CAAC,GAAG,EAAC;YAC5B,IAAA,mCAA2B,EAAC,GAAG,EAAC,MAAM,CAAC,CAAC;SAC3C;KACJ;IAED,OAAO,MAAM,CAAC;AAClB,CAAC,CAAA;AAbY,QAAA,2BAA2B,+BAavC;AAEM,MAAM,6BAA6B,GAAC,CAAC,IAAW,EAAE,OAAwB,EAAgB,EAAE;IAC/F,IAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAC;QACpB,IAAI,GAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAA;KACzB;IACD,IAAI,GAAG,GAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3B,IAAG,GAAG,KAAG,SAAS,EAAC;QACf,GAAG,GAAC,IAAA,uBAAc,EAAC,OAAO,CAAC,IAAI,EAAC,IAAI,EAAC,SAAS,CAAC,CAAC;KACnD;IACD,OAAO,GAAG,CAAC;AACf,CAAC,CAAA;AATY,QAAA,6BAA6B,iCASzC"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import { CancelToken, TimeInterval } from "@iyio/common";
|
|
2
|
+
import { ProtoCallable, ProtoNode } from "./protogen-types";
|
|
3
|
+
/**
|
|
4
|
+
* A ProtoExpression is a representation of a ProtoNode that returns a value when evaluated.
|
|
5
|
+
*
|
|
6
|
+
* Evaluation order:
|
|
7
|
+
* - If the expression's ctrl defines a evalExpression method then return the value returned from the ctrl.
|
|
8
|
+
* - eval subs
|
|
9
|
+
* - if expression is callable call its target with sub values as params and return returned value
|
|
10
|
+
* - if expression defines a path return the value pointed to by the path
|
|
11
|
+
* - if expression static value isn't undefined return static value
|
|
12
|
+
* - return last sub's return value or undefined if no subs defined
|
|
13
|
+
*/
|
|
14
|
+
export interface ProtoExpression {
|
|
15
|
+
/**
|
|
16
|
+
* The expressions name.
|
|
17
|
+
*/
|
|
18
|
+
name?: string;
|
|
19
|
+
/**
|
|
20
|
+
* A dot notated path to the value to return for this expression. The path is relative to the root
|
|
21
|
+
* node
|
|
22
|
+
*/
|
|
23
|
+
path?: string;
|
|
24
|
+
/**
|
|
25
|
+
* The static value of the expression. This value will be returned if the expression does
|
|
26
|
+
* not define a callAddress
|
|
27
|
+
*/
|
|
28
|
+
value?: ProtoEvalValue;
|
|
29
|
+
/**
|
|
30
|
+
* If true the sub values of the expresses will be join together as a object or map where the
|
|
31
|
+
* names of the subs will be used as keys in the object.
|
|
32
|
+
*/
|
|
33
|
+
map?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* If true the result of the expressions will be set as a variable with a name that matches the
|
|
36
|
+
* value of setAs
|
|
37
|
+
*/
|
|
38
|
+
setAs?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Only used by sub expressions that use subs as definitions. props and vars expressions use
|
|
41
|
+
* the type property
|
|
42
|
+
*/
|
|
43
|
+
type?: string;
|
|
44
|
+
/**
|
|
45
|
+
* If true the returned value of the expression should be inverted. For example a return value of
|
|
46
|
+
* true would be inverted to false.
|
|
47
|
+
*/
|
|
48
|
+
invert?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* Address of a node to call. This should be the address of a server function or domain function
|
|
51
|
+
* or any other callable node.
|
|
52
|
+
*/
|
|
53
|
+
address?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Sub expressions of this expression. If the expression does not define a value the value of the
|
|
56
|
+
* last sub expression is return as the return value of this expression.
|
|
57
|
+
*/
|
|
58
|
+
sub?: ProtoExpression[];
|
|
59
|
+
/**
|
|
60
|
+
* Controls the evaluation of the expression. Expression controls are used to implement
|
|
61
|
+
* control flow statements, logic operator and other language features.
|
|
62
|
+
*/
|
|
63
|
+
ctrl?: ProtoExpressionCtrlType | ProtoExpressionCtrl;
|
|
64
|
+
}
|
|
65
|
+
export declare const builtInProtoExpressionCtrlTypes: readonly ["or", "and", "return", "vars", "set", "inc", "dec", "pause", "resume", "props", "throw", "if", "in", "loop", "break", "continue", "add", "sub", "mul", "div", "mod", "not", "eq", "neq", "lt", "mt", "lte", "mte", "bit-and", "bit-or", "bit-xor", "bit-not", "bit-shift-left", "bit-shift-right", "bit-zero-right", "condition"];
|
|
66
|
+
export type ProtoExpressionCtrlType = typeof builtInProtoExpressionCtrlTypes[number];
|
|
67
|
+
export type ProtoExpressionCtrlBeforeOp = 'continue' | 'skip' | 'reset' | 'break';
|
|
68
|
+
export type ProtoExpressionCtrlAfterOp = 'continue' | 'break' | 'reset';
|
|
69
|
+
export interface ProtoExpressionCtrl {
|
|
70
|
+
canResume?(resumeId: string, expression: ProtoExpression): boolean;
|
|
71
|
+
beforeSub?(ctrlData: Record<string, ProtoEvalValue>, sub: ProtoExpression, expression: ProtoExpression, context: ProtoEvalContext): ProtoExpressionCtrlBeforeOp;
|
|
72
|
+
afterSub?(subValue: ProtoEvalValue | ProtoExpressionControlFlowResult, ctrlData: Record<string, ProtoEvalValue>, sub: ProtoExpression, expression: ProtoExpression, context: ProtoEvalContext): ProtoExpressionCtrlAfterOp;
|
|
73
|
+
mergeSubValues?(prevSubValue: ProtoEvalValue, subValue: ProtoEvalValue, ctrlData: Record<string, ProtoEvalValue>, sub: ProtoExpression, expression: ProtoExpression, context: ProtoEvalContext): ProtoEvalValue;
|
|
74
|
+
loop?(_continue: boolean, loopCount: number, ctrlData: Record<string, ProtoEvalValue>, expression: ProtoExpression, context: ProtoEvalContext): boolean;
|
|
75
|
+
result?(value: ProtoEvalValue | ProtoExpressionControlFlowResult, ctrlData: Record<string, ProtoEvalValue>, expression: ProtoExpression, context: ProtoEvalContext): Promise<ProtoEvalValue | ProtoExpressionControlFlowResult> | ProtoEvalValue | ProtoExpressionControlFlowResult;
|
|
76
|
+
skipSubs?: boolean;
|
|
77
|
+
ignorePath?: boolean;
|
|
78
|
+
ignoreValue?: boolean;
|
|
79
|
+
ignoreCall?: boolean;
|
|
80
|
+
ignoreInvert?: boolean;
|
|
81
|
+
}
|
|
82
|
+
export type ProtoEvalPrimitive = string | number | boolean | null | undefined;
|
|
83
|
+
export type ProtoEvalValue = ProtoEvalPrimitive | ProtoEvalValue[] | {
|
|
84
|
+
[key: string]: ProtoEvalValue;
|
|
85
|
+
};
|
|
86
|
+
export interface ProtoEvalFrame {
|
|
87
|
+
sub?: number;
|
|
88
|
+
ctrlData?: Record<string, ProtoEvalValue>;
|
|
89
|
+
subResults?: Record<string, ProtoEvalValue>;
|
|
90
|
+
}
|
|
91
|
+
export interface ProtoEvalContext {
|
|
92
|
+
/**
|
|
93
|
+
* The time when evaluation started
|
|
94
|
+
*/
|
|
95
|
+
startTime?: number;
|
|
96
|
+
/**
|
|
97
|
+
* The time when evaluation ended
|
|
98
|
+
*/
|
|
99
|
+
endTime?: number;
|
|
100
|
+
lastPause?: number;
|
|
101
|
+
lastResume?: number;
|
|
102
|
+
lastResumeId?: string;
|
|
103
|
+
resumeAfter?: TimeInterval;
|
|
104
|
+
/**
|
|
105
|
+
* Value of all stored variable values. Keys of the vars property are the full dot path
|
|
106
|
+
* to a variable. For example if a variable is accessed using an address of trigger.vars.saved
|
|
107
|
+
* then the keys is 'trigger.vars.saved'. vars can also include data set by external triggers
|
|
108
|
+
* and or providers.
|
|
109
|
+
*/
|
|
110
|
+
vars: Record<string, ProtoEvalValue>;
|
|
111
|
+
/**
|
|
112
|
+
* The number of expressions that have been evaluated
|
|
113
|
+
*/
|
|
114
|
+
evalCount: number;
|
|
115
|
+
/**
|
|
116
|
+
* The maximum number of expressions that should be allowed to execute.
|
|
117
|
+
*/
|
|
118
|
+
maxEvalCount?: number;
|
|
119
|
+
frames: ProtoEvalFrame[];
|
|
120
|
+
}
|
|
121
|
+
export type ProtoEvalState = 'complete' | 'paused' | 'failed' | 'canceled';
|
|
122
|
+
export interface ProtoEvalResult {
|
|
123
|
+
state: ProtoEvalState;
|
|
124
|
+
context: ProtoEvalContext;
|
|
125
|
+
value?: ProtoEvalValue;
|
|
126
|
+
error?: any;
|
|
127
|
+
errorMessage?: string;
|
|
128
|
+
}
|
|
129
|
+
export interface ParseProtoExpressOptions {
|
|
130
|
+
node: ProtoNode;
|
|
131
|
+
filterPaths?: string[];
|
|
132
|
+
}
|
|
133
|
+
export declare const ProtoExpressionControlFlowFlag: unique symbol;
|
|
134
|
+
export interface ProtoExpressionControlFlowResult {
|
|
135
|
+
typeFlag: typeof ProtoExpressionControlFlowFlag;
|
|
136
|
+
complete?: boolean;
|
|
137
|
+
continue?: boolean;
|
|
138
|
+
break?: boolean;
|
|
139
|
+
exit?: boolean;
|
|
140
|
+
returnValue?: ProtoEvalValue;
|
|
141
|
+
error?: any;
|
|
142
|
+
errorMessage?: string;
|
|
143
|
+
/**
|
|
144
|
+
* Id of a pause or resume statement
|
|
145
|
+
*/
|
|
146
|
+
resumeId?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Time interval after which to resume
|
|
149
|
+
*/
|
|
150
|
+
resumeAfter?: TimeInterval;
|
|
151
|
+
canceled?: boolean;
|
|
152
|
+
}
|
|
153
|
+
export declare const isProtoExpressionControlFlowResult: (value: any) => value is ProtoExpressionControlFlowResult;
|
|
154
|
+
export interface ProtoExpressionEngineOptions {
|
|
155
|
+
context: Partial<ProtoEvalContext>;
|
|
156
|
+
expression: ProtoExpression;
|
|
157
|
+
callableExpressions?: Record<string, ProtoExpression>;
|
|
158
|
+
callables?: Record<string, ProtoCallable>;
|
|
159
|
+
cancel?: CancelToken;
|
|
160
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isProtoExpressionControlFlowResult = exports.ProtoExpressionControlFlowFlag = exports.builtInProtoExpressionCtrlTypes = void 0;
|
|
4
|
+
exports.builtInProtoExpressionCtrlTypes = [
|
|
5
|
+
'or',
|
|
6
|
+
'and',
|
|
7
|
+
'return',
|
|
8
|
+
'vars',
|
|
9
|
+
'set',
|
|
10
|
+
'inc',
|
|
11
|
+
'dec',
|
|
12
|
+
'pause',
|
|
13
|
+
'resume',
|
|
14
|
+
'props',
|
|
15
|
+
'throw',
|
|
16
|
+
'if',
|
|
17
|
+
'in',
|
|
18
|
+
'loop',
|
|
19
|
+
'break',
|
|
20
|
+
'continue',
|
|
21
|
+
'add',
|
|
22
|
+
'sub',
|
|
23
|
+
'mul',
|
|
24
|
+
'div',
|
|
25
|
+
'mod',
|
|
26
|
+
'not',
|
|
27
|
+
'eq',
|
|
28
|
+
'neq',
|
|
29
|
+
'lt',
|
|
30
|
+
'mt',
|
|
31
|
+
'lte',
|
|
32
|
+
'mte',
|
|
33
|
+
'bit-and',
|
|
34
|
+
'bit-or',
|
|
35
|
+
'bit-xor',
|
|
36
|
+
'bit-not',
|
|
37
|
+
'bit-shift-left',
|
|
38
|
+
'bit-shift-right',
|
|
39
|
+
'bit-zero-right',
|
|
40
|
+
'condition',
|
|
41
|
+
];
|
|
42
|
+
exports.ProtoExpressionControlFlowFlag = Symbol('ProtoExpressionControlFlowFlag');
|
|
43
|
+
const isProtoExpressionControlFlowResult = (value) => {
|
|
44
|
+
if (!value) {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return (value === null || value === void 0 ? void 0 : value.typeFlag) === exports.ProtoExpressionControlFlowFlag;
|
|
48
|
+
};
|
|
49
|
+
exports.isProtoExpressionControlFlowResult = isProtoExpressionControlFlowResult;
|
|
50
|
+
//# sourceMappingURL=protogen-expression-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protogen-expression-types.js","sourceRoot":"","sources":["../../../../../packages/protogen/src/lib/protogen-expression-types.ts"],"names":[],"mappings":";;;AA6Ea,QAAA,+BAA+B,GAAC;IACzC,IAAI;IACJ,KAAK;IACL,QAAQ;IACR,MAAM;IACN,KAAK;IACL,KAAK;IACL,KAAK;IACL,OAAO;IACP,QAAQ;IACR,OAAO;IACP,OAAO;IACP,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,OAAO;IACP,UAAU;IACV,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,SAAS;IACT,QAAQ;IACR,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,iBAAiB;IACjB,gBAAgB;IAChB,WAAW;CACL,CAAC;AA4FE,QAAA,8BAA8B,GAAC,MAAM,CAAC,gCAAgC,CAAC,CAAC;AAyB9E,MAAM,kCAAkC,GAAC,CAAC,KAAS,EAA2C,EAAE;IAEnG,IAAG,CAAC,KAAK,EAAC;QACN,OAAO,KAAK,CAAC;KAChB;IACD,OAAO,CAAC,KAAoD,aAApD,KAAK,uBAAL,KAAK,CAAiD,QAAQ,MAAG,sCAA8B,CAAC;AAC5G,CAAC,CAAA;AANY,QAAA,kCAAkC,sCAM9C"}
|
|
@@ -1,5 +1,21 @@
|
|
|
1
|
-
import { ProtoLayout, ProtoNode } from "./protogen-types";
|
|
1
|
+
import { ProtoCallable, ProtoLayout, ProtoNode, ProtoTypeInfo } from "./protogen-types";
|
|
2
|
+
export declare const commonProtoFeatures: {
|
|
3
|
+
readonly callables: "callables";
|
|
4
|
+
};
|
|
2
5
|
export declare const protoGetLayout: (node: ProtoNode) => ProtoLayout | null;
|
|
3
6
|
export declare const protoGetLayoutOrDefault: (node: ProtoNode) => ProtoLayout;
|
|
4
7
|
export declare const protoSetLayout: (node: ProtoNode, layout: ProtoLayout | null) => void;
|
|
5
8
|
export declare const protoGetEmptyLayout: () => ProtoLayout;
|
|
9
|
+
export declare const parseProtoPrimitiveUndefined: (value: string | null | undefined) => string | number | boolean | null | undefined;
|
|
10
|
+
export declare const parseProtoPrimitive: (value: string | null | undefined) => string | number | boolean | null | undefined;
|
|
11
|
+
/**
|
|
12
|
+
* Returns a copy of the passed in type with package info populated. If the type is not found
|
|
13
|
+
* in the import map a copy without package info is returned.
|
|
14
|
+
*/
|
|
15
|
+
export declare const addPackageInfoToProtoType: (type: ProtoTypeInfo, importMap: Record<string, string>, varName?: string) => ProtoTypeInfo;
|
|
16
|
+
/**
|
|
17
|
+
* Invokes a callable. If the callable defines an argScheme the provided namedArgs are validated
|
|
18
|
+
* before invoking the callables implementation. If the callable does not define an implementation
|
|
19
|
+
* a ProtoCallableNotImplementedError is thrown.
|
|
20
|
+
*/
|
|
21
|
+
export declare const invokeProtoCallable: (callable: ProtoCallable, namedArgs: Record<string, any>) => any;
|
package/src/lib/protogen-lib.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.protoGetEmptyLayout = exports.protoSetLayout = exports.protoGetLayoutOrDefault = exports.protoGetLayout = void 0;
|
|
3
|
+
exports.invokeProtoCallable = exports.addPackageInfoToProtoType = exports.parseProtoPrimitive = exports.parseProtoPrimitiveUndefined = exports.protoGetEmptyLayout = exports.protoSetLayout = exports.protoGetLayoutOrDefault = exports.protoGetLayout = exports.commonProtoFeatures = void 0;
|
|
4
|
+
const protogen_types_1 = require("./protogen-types");
|
|
4
5
|
const layoutKey = Symbol('protoLayout');
|
|
6
|
+
exports.commonProtoFeatures = {
|
|
7
|
+
callables: 'callables'
|
|
8
|
+
};
|
|
5
9
|
const protoGetLayout = (node) => { var _a; return (_a = node[layoutKey]) !== null && _a !== void 0 ? _a : null; };
|
|
6
10
|
exports.protoGetLayout = protoGetLayout;
|
|
7
11
|
const protoGetLayoutOrDefault = (node) => { var _a; return (_a = node[layoutKey]) !== null && _a !== void 0 ? _a : (0, exports.protoGetEmptyLayout)(); };
|
|
@@ -23,4 +27,71 @@ const protoGetEmptyLayout = () => ({
|
|
|
23
27
|
y: 0,
|
|
24
28
|
});
|
|
25
29
|
exports.protoGetEmptyLayout = protoGetEmptyLayout;
|
|
30
|
+
const parseProtoPrimitiveUndefined = (value) => {
|
|
31
|
+
const v = (0, exports.parseProtoPrimitive)(value);
|
|
32
|
+
return v === '' ? undefined : v;
|
|
33
|
+
};
|
|
34
|
+
exports.parseProtoPrimitiveUndefined = parseProtoPrimitiveUndefined;
|
|
35
|
+
const parseProtoPrimitive = (value) => {
|
|
36
|
+
if (!value) {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
39
|
+
if (value.startsWith('!')) {
|
|
40
|
+
value = value.substring(1).trim();
|
|
41
|
+
if (!value) {
|
|
42
|
+
return value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (/^[0-9-]/.test(value)) {
|
|
46
|
+
const num = Number(value);
|
|
47
|
+
if (isFinite(num)) {
|
|
48
|
+
return num;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
switch (value) {
|
|
52
|
+
case 'true': return true;
|
|
53
|
+
case 'false': return false;
|
|
54
|
+
case 'null': return null;
|
|
55
|
+
case 'undefined': return undefined;
|
|
56
|
+
default: return value;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
exports.parseProtoPrimitive = parseProtoPrimitive;
|
|
60
|
+
/**
|
|
61
|
+
* Returns a copy of the passed in type with package info populated. If the type is not found
|
|
62
|
+
* in the import map a copy without package info is returned.
|
|
63
|
+
*/
|
|
64
|
+
const addPackageInfoToProtoType = (type, importMap, varName) => {
|
|
65
|
+
const pkg = importMap[type.type];
|
|
66
|
+
if (!pkg) {
|
|
67
|
+
return Object.assign({ varName }, type);
|
|
68
|
+
}
|
|
69
|
+
return Object.assign(Object.assign({ varName }, type), { package: pkg, exportName: type.type });
|
|
70
|
+
};
|
|
71
|
+
exports.addPackageInfoToProtoType = addPackageInfoToProtoType;
|
|
72
|
+
/**
|
|
73
|
+
* Invokes a callable. If the callable defines an argScheme the provided namedArgs are validated
|
|
74
|
+
* before invoking the callables implementation. If the callable does not define an implementation
|
|
75
|
+
* a ProtoCallableNotImplementedError is thrown.
|
|
76
|
+
*/
|
|
77
|
+
const invokeProtoCallable = (callable, namedArgs) => {
|
|
78
|
+
if (!callable.implementation) {
|
|
79
|
+
throw new protogen_types_1.ProtoCallableNotImplementedError(`Callable ${callable.name} does not define an implementation`);
|
|
80
|
+
}
|
|
81
|
+
if (callable.argsScheme) {
|
|
82
|
+
const r = callable.argsScheme.safeParse(namedArgs);
|
|
83
|
+
if (!r.success) {
|
|
84
|
+
throw new protogen_types_1.InvalidProtoCallableArgsError(`Provided args for callable ${callable.name} are invalid`, r.error);
|
|
85
|
+
}
|
|
86
|
+
namedArgs = r.data;
|
|
87
|
+
}
|
|
88
|
+
const args = [];
|
|
89
|
+
for (const arg of callable.args) {
|
|
90
|
+
if (arg.varName) {
|
|
91
|
+
args.push(namedArgs[arg.varName]);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return callable.implementation(...args);
|
|
95
|
+
};
|
|
96
|
+
exports.invokeProtoCallable = invokeProtoCallable;
|
|
26
97
|
//# sourceMappingURL=protogen-lib.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protogen-lib.js","sourceRoot":"","sources":["../../../../../packages/protogen/src/lib/protogen-lib.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"protogen-lib.js","sourceRoot":"","sources":["../../../../../packages/protogen/src/lib/protogen-lib.ts"],"names":[],"mappings":";;;AAAA,qDAAyJ;AAEzJ,MAAM,SAAS,GAAC,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,QAAA,mBAAmB,GAAC;IAC7B,SAAS,EAAC,WAAW;CACf,CAAC;AAEJ,MAAM,cAAc,GAAC,CAAC,IAAc,EAAkB,EAAE,WAAA,OAAA,MAAC,IAAY,CAAC,SAAS,CAAC,mCAAE,IAAI,CAAA,EAAA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CAAC,8BAA8B,QAAQ,CAAC,IAAI,cAAc,EAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SAC9G;QACD,SAAS,GAAC,CAAC,CAAC,IAAI,CAAC;KACpB;IAED,MAAM,IAAI,GAAO,EAAE,CAAC;IACpB,KAAI,MAAM,GAAG,IAAI,QAAQ,CAAC,IAAI,EAAC;QAC3B,IAAG,GAAG,CAAC,OAAO,EAAC;YACX,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;SACrC;KACJ;IAED,OAAO,QAAQ,CAAC,cAAc,CAAC,GAAG,IAAI,CAAC,CAAC;AAC5C,CAAC,CAAA;AApBY,QAAA,mBAAmB,uBAoB/B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CliArgsAliasMap, CliArgsConverter, HashMap } from "@iyio/common";
|
|
2
2
|
import { ZodSchema, z } from "zod";
|
|
3
3
|
import { ProtoSourceCodeMerger } from "./output-utils";
|
|
4
|
-
import { ProtoNode } from "./protogen-types";
|
|
4
|
+
import { ProtoCallable, ProtoNode } from "./protogen-types";
|
|
5
5
|
export type ProtoStage = 'init' | 'input' | 'preprocess' | 'parse' | 'generate' | 'output';
|
|
6
6
|
export declare const allProtoLibStyles: readonly ["dir", "nx"];
|
|
7
7
|
export type ProtoLibStyle = typeof allProtoLibStyles[number];
|
|
@@ -34,6 +34,7 @@ export interface ProtoOutput {
|
|
|
34
34
|
* file newlines.
|
|
35
35
|
*/
|
|
36
36
|
raw?: boolean;
|
|
37
|
+
metadata?: Record<string | symbol, any>;
|
|
37
38
|
}
|
|
38
39
|
export interface ProtoSource {
|
|
39
40
|
input?: string;
|
|
@@ -54,6 +55,11 @@ export interface ProtoContext {
|
|
|
54
55
|
sources: ProtoSource[];
|
|
55
56
|
nodes: ProtoNode[];
|
|
56
57
|
outputs: ProtoOutput[];
|
|
58
|
+
writtenOutputs: ProtoOutput[];
|
|
59
|
+
/**
|
|
60
|
+
* Starts a zero
|
|
61
|
+
*/
|
|
62
|
+
generationStage: number;
|
|
57
63
|
verbose: boolean;
|
|
58
64
|
tab: string;
|
|
59
65
|
stage: ProtoStage;
|
|
@@ -70,11 +76,21 @@ export interface ProtoContext {
|
|
|
70
76
|
paramPackage: string;
|
|
71
77
|
paramPackageName: string;
|
|
72
78
|
cdkProjectDir: string;
|
|
79
|
+
dataOutputs: Record<string, any>;
|
|
80
|
+
callables: ProtoCallable[];
|
|
81
|
+
requiredFeatures: Set<string>;
|
|
73
82
|
log: (...values: any[]) => void;
|
|
74
83
|
}
|
|
75
84
|
export type ProtoPipelineCallback<TConfig> = (ctx: ProtoContext, config: TConfig, pluginInfo: ProtoPipelinePluginInfo) => void | Promise<void>;
|
|
76
85
|
export interface ProtoPipelineConfigurablePlugin<TConfigScheme extends ZodSchema, TConfig = z.infer<TConfigScheme>> {
|
|
77
86
|
configScheme: TConfigScheme;
|
|
87
|
+
/**
|
|
88
|
+
* Allows the plugins to be executed in stages. Each stage is written before the next. This
|
|
89
|
+
* allows the generation of code that depends on other plugins written code.
|
|
90
|
+
* @default 0
|
|
91
|
+
*/
|
|
92
|
+
generationStage?: number;
|
|
93
|
+
setGenerationStage?: (context: ProtoContext, plugins: ProtoPipelinePluginInfo[]) => number;
|
|
78
94
|
beforeAll?: ProtoPipelineCallback<TConfig>;
|
|
79
95
|
beforeEach?: ProtoPipelineCallback<TConfig>;
|
|
80
96
|
stage?: ProtoPipelineCallback<TConfig>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protogen-pipeline-types.js","sourceRoot":"","sources":["../../../../../packages/protogen/src/lib/protogen-pipeline-types.ts"],"names":[],"mappings":";;;AAOa,QAAA,iBAAiB,GAAC,CAAC,KAAK,EAAC,IAAI,CAAU,CAAC;AAIxC,QAAA,oBAAoB,GAAe,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"protogen-pipeline-types.js","sourceRoot":"","sources":["../../../../../packages/protogen/src/lib/protogen-pipeline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-
import { AccessRequestDescription } from "@iyio/cdk-common";
|
|
1
|
+
import type { AccessRequestDescription, PassiveAccessGrantDescription } from "@iyio/cdk-common";
|
|
2
2
|
import { HashMap } from "@iyio/common";
|
|
3
3
|
import { ProtoLibStyle, ProtoParamType } from "./protogen-pipeline-types";
|
|
4
4
|
import { ProtoNode } from "./protogen-types";
|
|
@@ -11,6 +11,7 @@ export interface ProtoPluginPackagePathIndex extends ProtoPluginPackagePath {
|
|
|
11
11
|
* Full path to index file
|
|
12
12
|
*/
|
|
13
13
|
indexFilename: string;
|
|
14
|
+
removePackage: () => void;
|
|
14
15
|
}
|
|
15
16
|
export interface ProtoPackageIndex {
|
|
16
17
|
packagePaths: HashMap<string[]>;
|
|
@@ -24,4 +25,6 @@ export declare const getProtoPluginPackAndPath: getProtoPluginPackAndPathOverloa
|
|
|
24
25
|
export declare const protoAddContextParam: (baseName: string, paramPackage: string, paramMap: Record<string, ProtoParamType>, importMap: Record<string, string>, type?: ProtoParamType) => string;
|
|
25
26
|
export declare const protoGetParamName: (baseName: string) => string;
|
|
26
27
|
export declare const protoAddIndexPathToPaths: (packageName: string, indexPath: string, paths: Record<string, string[]>) => string[];
|
|
28
|
+
export declare const protoRemoveIndexPathFromPaths: (packageName: string, indexPath: string, paths: Record<string, string[]>) => boolean;
|
|
27
29
|
export declare const protoNodeChildrenToAccessRequests: (node: ProtoNode) => AccessRequestDescription[];
|
|
30
|
+
export declare const protoNodeChildrenToGrantAccessRequests: (parentName: string, node: ProtoNode) => PassiveAccessGrantDescription[];
|