@fibery/expression-utils 9.7.2 → 10.0.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/lib/_virtual/_rolldown/runtime.js +13 -0
- package/lib/index.d.ts +191 -585
- package/lib/index.js +15 -50
- package/lib/src/context-variables.d.ts +27 -22
- package/lib/src/context-variables.js +106 -138
- package/lib/src/errors.d.ts +5 -2
- package/lib/src/errors.js +14 -14
- package/lib/src/field-expression-visitor-type-aware.d.ts +18 -16
- package/lib/src/field-expression-visitor-type-aware.js +116 -131
- package/lib/src/filter-expression/index.d.ts +12 -9
- package/lib/src/filter-expression/index.js +34 -47
- package/lib/src/filter-expression/operator-utils.d.ts +14 -11
- package/lib/src/filter-expression/operator-utils.js +191 -185
- package/lib/src/filter-expression/operators.d.ts +111 -106
- package/lib/src/filter-expression/operators.js +1130 -846
- package/lib/src/filter-expression/pattern-match-placeholders.d.ts +63 -61
- package/lib/src/filter-expression/pattern-match-placeholders.js +107 -138
- package/lib/src/filter-expression/pattern-match.d.ts +17 -15
- package/lib/src/filter-expression/pattern-match.js +118 -130
- package/lib/src/filter-expression/pattern-to-expression.d.ts +13 -11
- package/lib/src/filter-expression/pattern-to-expression.js +42 -45
- package/lib/src/filter-expression/types.d.ts +29 -26
- package/lib/src/filter-expression/types.js +0 -3
- package/lib/src/params-placeholders.d.ts +55 -51
- package/lib/src/params-placeholders.js +199 -192
- package/lib/src/tsfixme.d.ts +4 -1
- package/lib/src/tsfixme.js +0 -3
- package/lib/src/types.d.ts +47 -45
- package/lib/src/types.js +0 -3
- package/lib/src/utils.d.ts +53 -48
- package/lib/src/utils.js +276 -338
- package/lib/src/visitors.d.ts +43 -37
- package/lib/src/visitors.js +306 -365
- package/lib/test-data/schema-mock.d.ts +68 -751
- package/lib/test-data/schema-mock.js +175 -139
- package/package.json +17 -10
- package/lib/index.js.map +0 -1
- package/lib/src/context-variables.js.map +0 -1
- package/lib/src/errors.js.map +0 -1
- package/lib/src/field-expression-visitor-type-aware.js.map +0 -1
- package/lib/src/filter-expression/index.js.map +0 -1
- package/lib/src/filter-expression/operator-utils.js.map +0 -1
- package/lib/src/filter-expression/operators.js.map +0 -1
- package/lib/src/filter-expression/pattern-match-placeholders.js.map +0 -1
- package/lib/src/filter-expression/pattern-match.js.map +0 -1
- package/lib/src/filter-expression/pattern-to-expression.js.map +0 -1
- package/lib/src/filter-expression/types.js.map +0 -1
- package/lib/src/params-placeholders.js.map +0 -1
- package/lib/src/tsfixme.js.map +0 -1
- package/lib/src/types.js.map +0 -1
- package/lib/src/utils.js.map +0 -1
- package/lib/src/visitors.js.map +0 -1
- package/lib/test-data/schema-mock.js.map +0 -1
package/lib/index.js
CHANGED
|
@@ -1,50 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.filterExpression = exports.contextVariables = exports.paramsPlaceholders = exports.visitors = exports.utils = void 0;
|
|
37
|
-
const contextVariables = __importStar(require("./src/context-variables"));
|
|
38
|
-
exports.contextVariables = contextVariables;
|
|
39
|
-
const filter_expression_1 = require("./src/filter-expression");
|
|
40
|
-
const operators = __importStar(require("./src/filter-expression/operators"));
|
|
41
|
-
const pattern_to_expression_1 = require("./src/filter-expression/pattern-to-expression");
|
|
42
|
-
const paramsPlaceholders = __importStar(require("./src/params-placeholders"));
|
|
43
|
-
exports.paramsPlaceholders = paramsPlaceholders;
|
|
44
|
-
const utils = __importStar(require("./src/utils"));
|
|
45
|
-
exports.utils = utils;
|
|
46
|
-
const visitors = __importStar(require("./src/visitors"));
|
|
47
|
-
exports.visitors = visitors;
|
|
48
|
-
const filterExpression = { findMatchedFilter: filter_expression_1.findMatchedFilter, operators, convertToExpression: pattern_to_expression_1.convertToExpression };
|
|
49
|
-
exports.filterExpression = filterExpression;
|
|
50
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { context_variables_exports } from "./src/context-variables.js";
|
|
2
|
+
import { utils_exports } from "./src/utils.js";
|
|
3
|
+
import { findMatchedFilter } from "./src/filter-expression/index.js";
|
|
4
|
+
import { params_placeholders_exports } from "./src/params-placeholders.js";
|
|
5
|
+
import { convertToExpression } from "./src/filter-expression/pattern-to-expression.js";
|
|
6
|
+
import { operators_exports } from "./src/filter-expression/operators.js";
|
|
7
|
+
import { visitors_exports } from "./src/visitors.js";
|
|
8
|
+
//#region index.ts
|
|
9
|
+
const filterExpression = {
|
|
10
|
+
findMatchedFilter,
|
|
11
|
+
operators: operators_exports,
|
|
12
|
+
convertToExpression
|
|
13
|
+
};
|
|
14
|
+
//#endregion
|
|
15
|
+
export { context_variables_exports as contextVariables, filterExpression, params_placeholders_exports as paramsPlaceholders, utils_exports as utils, visitors_exports as visitors };
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { Schema, TypeObject } from "@fibery/schema";
|
|
2
|
+
declare namespace context_variables_d_exports {
|
|
3
|
+
export { ContextVariable, currentUserContextVariableId, getAutomationButtonContextVariables, getAutomationTriggersContextVariables, getEntityQueryVariables, getTriggerCollectionFieldObject, previousTriggeredEntityContextVariableId, triggeredCollectionItemContextVariableId, triggeredEntityContextVariableId };
|
|
4
|
+
}
|
|
5
|
+
type ContextVariable = {
|
|
6
|
+
description: string;
|
|
7
|
+
id: string;
|
|
8
|
+
title: string;
|
|
9
|
+
typeObject: TypeObject;
|
|
10
|
+
isCollection: boolean;
|
|
8
11
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
declare const triggeredEntityContextVariableId = "triggeredEntity";
|
|
13
|
+
declare const previousTriggeredEntityContextVariableId = "previousTriggeredEntity";
|
|
14
|
+
declare const currentUserContextVariableId = "currentUser";
|
|
15
|
+
declare const triggeredCollectionItemContextVariableId = "triggered-collection-item";
|
|
16
|
+
declare const getAutomationButtonContextVariables: (typeId: string, fiberySchema: Schema) => Array<ContextVariable>;
|
|
17
|
+
declare const getTriggerCollectionFieldObject: (typeId: string, collectionFieldId: string, fiberySchema: Schema) => import("@fibery/schema").FieldObject | undefined;
|
|
18
|
+
declare const getAutomationTriggersContextVariables: (triggers: Array<{
|
|
19
|
+
trigger: string;
|
|
20
|
+
args: Record<string, unknown>;
|
|
18
21
|
}>, typeId: string, fiberySchema: Schema) => Array<ContextVariable>;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
declare const getEntityQueryVariables: (schema: Schema) => {
|
|
23
|
+
typeObject: TypeObject;
|
|
24
|
+
id: string;
|
|
25
|
+
title: string;
|
|
26
|
+
isCollection: boolean;
|
|
27
|
+
description: string;
|
|
25
28
|
}[];
|
|
29
|
+
//#endregion
|
|
30
|
+
export { ContextVariable, context_variables_d_exports, currentUserContextVariableId, getAutomationButtonContextVariables, getAutomationTriggersContextVariables, getEntityQueryVariables, getTriggerCollectionFieldObject, previousTriggeredEntityContextVariableId, triggeredCollectionItemContextVariableId, triggeredEntityContextVariableId };
|
|
@@ -1,148 +1,116 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import flatten from "lodash/flatten.js";
|
|
3
|
+
import groupBy from "lodash/groupBy.js";
|
|
4
|
+
import uniqBy from "lodash/uniqBy.js";
|
|
5
|
+
//#region src/context-variables.ts
|
|
6
|
+
var context_variables_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
currentUserContextVariableId: () => currentUserContextVariableId,
|
|
8
|
+
getAutomationButtonContextVariables: () => getAutomationButtonContextVariables,
|
|
9
|
+
getAutomationTriggersContextVariables: () => getAutomationTriggersContextVariables,
|
|
10
|
+
getEntityQueryVariables: () => getEntityQueryVariables,
|
|
11
|
+
getTriggerCollectionFieldObject: () => getTriggerCollectionFieldObject,
|
|
12
|
+
previousTriggeredEntityContextVariableId: () => previousTriggeredEntityContextVariableId,
|
|
13
|
+
triggeredCollectionItemContextVariableId: () => triggeredCollectionItemContextVariableId,
|
|
14
|
+
triggeredEntityContextVariableId: () => triggeredEntityContextVariableId
|
|
15
|
+
});
|
|
16
|
+
const triggeredEntityContextVariableId = "triggeredEntity";
|
|
17
|
+
const previousTriggeredEntityContextVariableId = "previousTriggeredEntity";
|
|
18
|
+
const currentUserContextVariableId = "currentUser";
|
|
19
|
+
const triggeredCollectionItemContextVariableId = "triggered-collection-item";
|
|
14
20
|
const getAutomationButtonContextVariables = (typeId, fiberySchema) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
typeObject: userTypeObject,
|
|
32
|
-
isCollection: false,
|
|
33
|
-
description: `The User who triggered this automation by clicking a Button.`,
|
|
34
|
-
},
|
|
35
|
-
];
|
|
21
|
+
if (!fiberySchema) return [];
|
|
22
|
+
const userTypeObject = fiberySchema.typeObjectsByName["fibery/user"];
|
|
23
|
+
const typeObject = fiberySchema.typeObjectsById[typeId];
|
|
24
|
+
return [{
|
|
25
|
+
id: triggeredEntityContextVariableId,
|
|
26
|
+
title: `Step 1 ${typeObject.singularTitle}`,
|
|
27
|
+
typeObject,
|
|
28
|
+
isCollection: false,
|
|
29
|
+
description: `The ${typeObject.singularTitle} for which the Button was clicked`
|
|
30
|
+
}, {
|
|
31
|
+
id: currentUserContextVariableId,
|
|
32
|
+
title: `User who clicked Button`,
|
|
33
|
+
typeObject: userTypeObject,
|
|
34
|
+
isCollection: false,
|
|
35
|
+
description: `The User who triggered this automation by clicking a Button.`
|
|
36
|
+
}];
|
|
36
37
|
};
|
|
37
|
-
exports.getAutomationButtonContextVariables = getAutomationButtonContextVariables;
|
|
38
38
|
const getTriggerCollectionFieldObject = (typeId, collectionFieldId, fiberySchema) => {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
if (!Object.hasOwn(fiberySchema.typeObjectsById[typeId].fieldObjectsById, collectionFieldId)) {
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
return fiberySchema.typeObjectsById[typeId].fieldObjectsById[collectionFieldId];
|
|
39
|
+
if (!fiberySchema) return;
|
|
40
|
+
if (!Object.hasOwn(fiberySchema.typeObjectsById, typeId)) return;
|
|
41
|
+
if (!Object.hasOwn(fiberySchema.typeObjectsById[typeId].fieldObjectsById, collectionFieldId)) return;
|
|
42
|
+
return fiberySchema.typeObjectsById[typeId].fieldObjectsById[collectionFieldId];
|
|
49
43
|
};
|
|
50
|
-
exports.getTriggerCollectionFieldObject = getTriggerCollectionFieldObject;
|
|
51
44
|
const getTriggerContextVariables = (trigger, typeId, fiberySchema) => {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
return result;
|
|
104
|
-
}
|
|
105
|
-
else if (trigger.trigger === "collection-item-added" || trigger.trigger === "collection-item-removed") {
|
|
106
|
-
const collectionItemFieldObject = (0, exports.getTriggerCollectionFieldObject)(typeId, trigger.args.changedCollectionField, fiberySchema);
|
|
107
|
-
const collectionItemTypeObject = collectionItemFieldObject?.typeObject;
|
|
108
|
-
const variables = [triggeredEntityVar];
|
|
109
|
-
collectionItemTypeObject &&
|
|
110
|
-
variables.push({
|
|
111
|
-
id: exports.triggeredCollectionItemContextVariableId,
|
|
112
|
-
title: `Step 1 ${trigger.trigger === "collection-item-added" ? "linked" : "unlinked"} ${collectionItemTypeObject.singularTitle}`,
|
|
113
|
-
typeObject: collectionItemTypeObject,
|
|
114
|
-
isCollection: false,
|
|
115
|
-
description: `The ${collectionItemTypeObject.singularTitle} from step 1 of this Automation Rule`,
|
|
116
|
-
});
|
|
117
|
-
const disableCurrentUserVar = collectionItemFieldObject?.isReadOnly;
|
|
118
|
-
!disableCurrentUserVar && variables.push(currentUserVar);
|
|
119
|
-
return variables;
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
return [];
|
|
123
|
-
}
|
|
45
|
+
if (!fiberySchema) return [];
|
|
46
|
+
const typeObject = fiberySchema.typeObjectsById[typeId];
|
|
47
|
+
const userTypeObject = fiberySchema.typeObjectsByName["fibery/user"];
|
|
48
|
+
const triggeredEntityVar = {
|
|
49
|
+
id: triggeredEntityContextVariableId,
|
|
50
|
+
title: `Step 1 ${typeObject.singularTitle}`,
|
|
51
|
+
typeObject,
|
|
52
|
+
isCollection: false,
|
|
53
|
+
description: `The ${typeObject.singularTitle} from step 1 of this Automation Rule`
|
|
54
|
+
};
|
|
55
|
+
const currentUserVar = {
|
|
56
|
+
id: currentUserContextVariableId,
|
|
57
|
+
title: `User who triggered Rule`,
|
|
58
|
+
typeObject: userTypeObject,
|
|
59
|
+
isCollection: false,
|
|
60
|
+
description: `The User who made the change which triggered this Automation Rule. Empty in case the change was made by a formula or an integration.`
|
|
61
|
+
};
|
|
62
|
+
if (trigger.trigger === "time-based") return [triggeredEntityVar];
|
|
63
|
+
else if (trigger.trigger === "created") return typeObject.syncSource !== null ? [triggeredEntityVar] : [triggeredEntityVar, currentUserVar];
|
|
64
|
+
else if (trigger.trigger === "updated") {
|
|
65
|
+
const result = [triggeredEntityVar];
|
|
66
|
+
if (!(trigger.args.updatedField && Array.isArray(trigger.args.updatedField) && trigger.args.updatedField.some((fieldId) => {
|
|
67
|
+
if (!Object.hasOwn(typeObject.fieldObjectsById, fieldId)) return false;
|
|
68
|
+
const fieldObject = typeObject.fieldObjectsById[fieldId];
|
|
69
|
+
return fieldObject?.isReadOnly || fieldObject?.type === "Collaboration~Documents/Document";
|
|
70
|
+
}))) result.push(currentUserVar);
|
|
71
|
+
if (trigger.args.updatedField && Array.isArray(trigger.args.updatedField) && trigger.args.updatedField.length === 1) {
|
|
72
|
+
const previousTriggeredEntityContextVariable = {
|
|
73
|
+
id: previousTriggeredEntityContextVariableId,
|
|
74
|
+
title: `Step 1 ${typeObject.singularTitle} (Previous)`,
|
|
75
|
+
typeObject,
|
|
76
|
+
isCollection: false,
|
|
77
|
+
description: `The previous value of ${typeObject.singularTitle} from step 1 of this Automation Rule`
|
|
78
|
+
};
|
|
79
|
+
result.push(previousTriggeredEntityContextVariable);
|
|
80
|
+
}
|
|
81
|
+
return result;
|
|
82
|
+
} else if (trigger.trigger === "collection-item-added" || trigger.trigger === "collection-item-removed") {
|
|
83
|
+
const collectionItemFieldObject = getTriggerCollectionFieldObject(typeId, trigger.args.changedCollectionField, fiberySchema);
|
|
84
|
+
const collectionItemTypeObject = collectionItemFieldObject?.typeObject;
|
|
85
|
+
const variables = [triggeredEntityVar];
|
|
86
|
+
collectionItemTypeObject && variables.push({
|
|
87
|
+
id: "triggered-collection-item",
|
|
88
|
+
title: `Step 1 ${trigger.trigger === "collection-item-added" ? "linked" : "unlinked"} ${collectionItemTypeObject.singularTitle}`,
|
|
89
|
+
typeObject: collectionItemTypeObject,
|
|
90
|
+
isCollection: false,
|
|
91
|
+
description: `The ${collectionItemTypeObject.singularTitle} from step 1 of this Automation Rule`
|
|
92
|
+
});
|
|
93
|
+
!collectionItemFieldObject?.isReadOnly && variables.push(currentUserVar);
|
|
94
|
+
return variables;
|
|
95
|
+
} else return [];
|
|
124
96
|
};
|
|
125
97
|
const getAutomationTriggersContextVariables = (triggers, typeId, fiberySchema) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
? triggerContextVars.filter((variable) => variable.id !== exports.previousTriggeredEntityContextVariableId)
|
|
131
|
-
: triggerContextVars;
|
|
132
|
-
return (0, uniqBy_1.default)(filteredContextVars, (variable) => `${variable.id}_${variable.typeObject.id}`);
|
|
98
|
+
const triggerContextVars = triggers.flatMap((trigger) => {
|
|
99
|
+
return getTriggerContextVariables(trigger, typeId, fiberySchema);
|
|
100
|
+
});
|
|
101
|
+
return uniqBy(triggers.length > 1 ? triggerContextVars.filter((variable) => variable.id !== previousTriggeredEntityContextVariableId) : triggerContextVars, (variable) => `${variable.id}_${variable.typeObject.id}`);
|
|
133
102
|
};
|
|
134
|
-
exports.getAutomationTriggersContextVariables = getAutomationTriggersContextVariables;
|
|
135
103
|
const getEntityQueryVariables = (schema) => {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
104
|
+
const grouped = groupBy(schema.typeObjects.filter((x) => x.isDomain), (typeObject) => typeObject.pluralTitle);
|
|
105
|
+
return flatten(Object.values(grouped).map((group) => {
|
|
106
|
+
return group.map((typeObject) => ({
|
|
107
|
+
typeObject,
|
|
108
|
+
id: `entityQuery_${typeObject.id}`,
|
|
109
|
+
title: group.length > 1 ? `${typeObject.pluralTitle} (${typeObject.nameParts.namespace})` : typeObject.pluralTitle,
|
|
110
|
+
isCollection: true,
|
|
111
|
+
description: `All Entities from "${typeObject.title}" Database`
|
|
112
|
+
}));
|
|
113
|
+
}));
|
|
146
114
|
};
|
|
147
|
-
|
|
148
|
-
|
|
115
|
+
//#endregion
|
|
116
|
+
export { context_variables_exports, currentUserContextVariableId, getAutomationButtonContextVariables, getAutomationTriggersContextVariables, getEntityQueryVariables, getTriggerCollectionFieldObject, previousTriggeredEntityContextVariableId, triggeredCollectionItemContextVariableId, triggeredEntityContextVariableId };
|
package/lib/src/errors.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
//#region src/errors.d.ts
|
|
2
|
+
declare class NotImplementedError extends Error {
|
|
3
|
+
constructor(value: unknown, itemType?: string);
|
|
3
4
|
}
|
|
5
|
+
//#endregion
|
|
6
|
+
export { NotImplementedError };
|
package/lib/src/errors.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotImplementedError = void 0;
|
|
1
|
+
//#region src/errors.ts
|
|
4
2
|
const stringify = (x) => {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
return JSON.stringify(x);
|
|
3
|
+
if (x === void 0) return "undefined";
|
|
4
|
+
return JSON.stringify(x);
|
|
9
5
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
var NotImplementedError = class extends Error {
|
|
7
|
+
constructor(value, itemType) {
|
|
8
|
+
super([
|
|
9
|
+
`"${stringify(value)}"`,
|
|
10
|
+
itemType,
|
|
11
|
+
"is not implemented"
|
|
12
|
+
].filter((x) => x !== void 0).join(" "));
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { NotImplementedError };
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { ExpressionVisitor, FieldExpression, MultiFieldAccess } from "./types.js";
|
|
2
|
+
import { FieldObject, TypeObject } from "@fibery/schema";
|
|
3
|
+
//#region src/field-expression-visitor-type-aware.d.ts
|
|
3
4
|
type FieldAccess = string | MultiFieldAccess;
|
|
4
5
|
type OnFieldResult = {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
typeObject: TypeObject;
|
|
7
|
+
fieldAccess: FieldAccess;
|
|
7
8
|
} | undefined;
|
|
8
9
|
type OnField = (params: {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
fieldAccess: FieldAccess;
|
|
11
|
+
fieldObject: FieldObject;
|
|
12
|
+
typeObject: TypeObject;
|
|
12
13
|
}) => OnFieldResult;
|
|
13
14
|
type OnFieldNotFound = (params: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
currentTypeObject: TypeObject;
|
|
16
|
+
expression: FieldExpression;
|
|
17
|
+
fieldAccess: FieldAccess;
|
|
17
18
|
}) => OnFieldResult;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}) => Required<
|
|
23
|
-
|
|
19
|
+
declare const fieldAccessVisitorTypeAware: ({ typeObject, onField, onFieldNotFound }: {
|
|
20
|
+
typeObject: TypeObject;
|
|
21
|
+
onField?: OnField;
|
|
22
|
+
onFieldNotFound?: OnFieldNotFound;
|
|
23
|
+
}) => Required<ExpressionVisitor>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { fieldAccessVisitorTypeAware };
|