@servicenow/sdk-build-plugins 2.0.1
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/AttachmentPlugin.d.ts +253 -0
- package/dist/AttachmentPlugin.js +216 -0
- package/dist/AttachmentPlugin.js.map +1 -0
- package/dist/BusinessRulePlugin.d.ts +56 -0
- package/dist/BusinessRulePlugin.js +171 -0
- package/dist/BusinessRulePlugin.js.map +1 -0
- package/dist/CrossScopePrivilegePlugin.d.ts +22 -0
- package/dist/CrossScopePrivilegePlugin.js +42 -0
- package/dist/CrossScopePrivilegePlugin.js.map +1 -0
- package/dist/DefaultPlugin.d.ts +71 -0
- package/dist/DefaultPlugin.js +238 -0
- package/dist/DefaultPlugin.js.map +1 -0
- package/dist/IdPlugin.d.ts +17 -0
- package/dist/IdPlugin.js +45 -0
- package/dist/IdPlugin.js.map +1 -0
- package/dist/ListPlugin.d.ts +91 -0
- package/dist/ListPlugin.js +398 -0
- package/dist/ListPlugin.js.map +1 -0
- package/dist/PropertyPlugin.d.ts +122 -0
- package/dist/PropertyPlugin.js +165 -0
- package/dist/PropertyPlugin.js.map +1 -0
- package/dist/ScriptTemplatePlugin.d.ts +31 -0
- package/dist/ScriptTemplatePlugin.js +208 -0
- package/dist/ScriptTemplatePlugin.js.map +1 -0
- package/dist/UserPreferencePlugin.d.ts +16 -0
- package/dist/UserPreferencePlugin.js +30 -0
- package/dist/UserPreferencePlugin.js.map +1 -0
- package/dist/aclAndRole/AclPlugin.d.ts +117 -0
- package/dist/aclAndRole/AclPlugin.js +285 -0
- package/dist/aclAndRole/AclPlugin.js.map +1 -0
- package/dist/aclAndRole/RolePlugin.d.ts +58 -0
- package/dist/aclAndRole/RolePlugin.js +152 -0
- package/dist/aclAndRole/RolePlugin.js.map +1 -0
- package/dist/aclAndRole/Util.d.ts +3 -0
- package/dist/aclAndRole/Util.js +106 -0
- package/dist/aclAndRole/Util.js.map +1 -0
- package/dist/app/ApplicationMenuPlugin.d.ts +32 -0
- package/dist/app/ApplicationMenuPlugin.js +106 -0
- package/dist/app/ApplicationMenuPlugin.js.map +1 -0
- package/dist/atf/ATFComposer.d.ts +492 -0
- package/dist/atf/ATFComposer.js +2717 -0
- package/dist/atf/ATFComposer.js.map +1 -0
- package/dist/atf/TestPlugin.d.ts +31 -0
- package/dist/atf/TestPlugin.js +95 -0
- package/dist/atf/TestPlugin.js.map +1 -0
- package/dist/atf/index.d.ts +1 -0
- package/dist/atf/index.js +9 -0
- package/dist/atf/index.js.map +1 -0
- package/dist/db/ColumnPlugins.d.ts +278 -0
- package/dist/db/ColumnPlugins.js +112 -0
- package/dist/db/ColumnPlugins.js.map +1 -0
- package/dist/db/RecordPlugin.d.ts +208 -0
- package/dist/db/RecordPlugin.js +287 -0
- package/dist/db/RecordPlugin.js.map +1 -0
- package/dist/db/TablePlugin.d.ts +742 -0
- package/dist/db/TablePlugin.js +1249 -0
- package/dist/db/TablePlugin.js.map +1 -0
- package/dist/db/index.d.ts +3 -0
- package/dist/db/index.js +27 -0
- package/dist/db/index.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -0
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.d.ts +12 -0
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js +371 -0
- package/dist/scriptedRESTAPI/RESTDeserializationUtils.js.map +1 -0
- package/dist/scriptedRESTAPI/RESTSerializationUtils.d.ts +15 -0
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js +177 -0
- package/dist/scriptedRESTAPI/RESTSerializationUtils.js.map +1 -0
- package/dist/scriptedRESTAPI/RestApiPlugin.d.ts +144 -0
- package/dist/scriptedRESTAPI/RestApiPlugin.js +318 -0
- package/dist/scriptedRESTAPI/RestApiPlugin.js.map +1 -0
- package/dist/scriptedRESTAPI/RestSchemaUtils.d.ts +190 -0
- package/dist/scriptedRESTAPI/RestSchemaUtils.js +53 -0
- package/dist/scriptedRESTAPI/RestSchemaUtils.js.map +1 -0
- package/dist/scriptedRESTAPI/RestUtils.d.ts +75 -0
- package/dist/scriptedRESTAPI/RestUtils.js +469 -0
- package/dist/scriptedRESTAPI/RestUtils.js.map +1 -0
- package/dist/scripts/ClientScriptPlugin.d.ts +43 -0
- package/dist/scripts/ClientScriptPlugin.js +190 -0
- package/dist/scripts/ClientScriptPlugin.js.map +1 -0
- package/dist/scripts/scriptUtils.d.ts +15 -0
- package/dist/scripts/scriptUtils.js +83 -0
- package/dist/scripts/scriptUtils.js.map +1 -0
- package/dist/uxf/ExperiencePlugin.d.ts +22 -0
- package/dist/uxf/ExperiencePlugin.js +55 -0
- package/dist/uxf/ExperiencePlugin.js.map +1 -0
- package/dist/uxf/RoutesPlugin.d.ts +22 -0
- package/dist/uxf/RoutesPlugin.js +176 -0
- package/dist/uxf/RoutesPlugin.js.map +1 -0
- package/dist/uxf/UxfFormulaParser/cleanUxValue.d.ts +4 -0
- package/dist/uxf/UxfFormulaParser/cleanUxValue.js +65 -0
- package/dist/uxf/UxfFormulaParser/cleanUxValue.js.map +1 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/api.d.ts +189 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/api.js +158 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/api.js.map +1 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.d.ts +13 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +604 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js.map +1 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.d.ts +12 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js +551 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/grammarParser.js.map +1 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.d.ts +31 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +64 -0
- package/dist/uxf/UxfFormulaParser/grammerParser/spanHelpers.js.map +1 -0
- package/dist/uxf/UxfFormulaParser/index.d.ts +3 -0
- package/dist/uxf/UxfFormulaParser/index.js +11 -0
- package/dist/uxf/UxfFormulaParser/index.js.map +1 -0
- package/dist/uxf/UxfFormulaParser/parser.d.ts +8 -0
- package/dist/uxf/UxfFormulaParser/parser.js +87 -0
- package/dist/uxf/UxfFormulaParser/parser.js.map +1 -0
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.d.ts +8 -0
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js +17 -0
- package/dist/uxf/UxfFormulaParser/utils/getErrorMsg.js.map +1 -0
- package/dist/uxf/constants.d.ts +2 -0
- package/dist/uxf/constants.js +8 -0
- package/dist/uxf/constants.js.map +1 -0
- package/dist/uxf/index.d.ts +2 -0
- package/dist/uxf/index.js +11 -0
- package/dist/uxf/index.js.map +1 -0
- package/dist/uxf/tectonicIdGenerator.d.ts +12 -0
- package/dist/uxf/tectonicIdGenerator.js +102 -0
- package/dist/uxf/tectonicIdGenerator.js.map +1 -0
- package/license +9 -0
- package/package.json +42 -0
- package/src/AttachmentPlugin.ts +262 -0
- package/src/BusinessRulePlugin.ts +251 -0
- package/src/CrossScopePrivilegePlugin.ts +54 -0
- package/src/DefaultPlugin.ts +272 -0
- package/src/IdPlugin.ts +47 -0
- package/src/ListPlugin.ts +497 -0
- package/src/PropertyPlugin.ts +218 -0
- package/src/ScriptTemplatePlugin.ts +223 -0
- package/src/UserPreferencePlugin.ts +36 -0
- package/src/aclAndRole/AclPlugin.ts +410 -0
- package/src/aclAndRole/RolePlugin.ts +225 -0
- package/src/aclAndRole/Util.ts +104 -0
- package/src/app/ApplicationMenuPlugin.ts +158 -0
- package/src/atf/ATFComposer.ts +3356 -0
- package/src/atf/TestPlugin.ts +119 -0
- package/src/atf/index.ts +1 -0
- package/src/db/ColumnPlugins.ts +117 -0
- package/src/db/RecordPlugin.ts +391 -0
- package/src/db/TablePlugin.ts +1581 -0
- package/src/db/index.ts +3 -0
- package/src/index.ts +16 -0
- package/src/scriptedRESTAPI/RESTDeserializationUtils.ts +410 -0
- package/src/scriptedRESTAPI/RESTSerializationUtils.ts +227 -0
- package/src/scriptedRESTAPI/RestApiPlugin.ts +438 -0
- package/src/scriptedRESTAPI/RestSchemaUtils.ts +72 -0
- package/src/scriptedRESTAPI/RestUtils.ts +507 -0
- package/src/scripts/ClientScriptPlugin.ts +251 -0
- package/src/scripts/scriptUtils.ts +81 -0
- package/src/uxf/ExperiencePlugin.ts +64 -0
- package/src/uxf/RoutesPlugin.ts +215 -0
- package/src/uxf/UxfFormulaParser/cleanUxValue.ts +73 -0
- package/src/uxf/UxfFormulaParser/grammerParser/api.js +166 -0
- package/src/uxf/UxfFormulaParser/grammerParser/clientTransformMap.js +606 -0
- package/src/uxf/UxfFormulaParser/grammerParser/grammarParser.js +551 -0
- package/src/uxf/UxfFormulaParser/grammerParser/spanHelpers.js +65 -0
- package/src/uxf/UxfFormulaParser/index.ts +4 -0
- package/src/uxf/UxfFormulaParser/parser.ts +64 -0
- package/src/uxf/UxfFormulaParser/utils/getErrorMsg.ts +13 -0
- package/src/uxf/constants.ts +4 -0
- package/src/uxf/index.ts +2 -0
- package/src/uxf/tectonicIdGenerator.ts +81 -0
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
4
|
+
const app_1 = require("@servicenow/sdk-core/runtime/app");
|
|
5
|
+
const sdk_build_core_1 = require("@servicenow/sdk-build-core");
|
|
6
|
+
const ScriptTemplatePlugin_1 = require("./ScriptTemplatePlugin");
|
|
7
|
+
const scriptUtils_1 = require("./scripts/scriptUtils");
|
|
8
|
+
const RecordPlugin_1 = require("./db/RecordPlugin");
|
|
9
|
+
const lodash_1 = require("lodash");
|
|
10
|
+
const ts_morph_1 = require("ts-morph");
|
|
11
|
+
const sdk_project_1 = require("@servicenow/sdk-project");
|
|
12
|
+
const db_1 = require("@servicenow/sdk-core/runtime/db");
|
|
13
|
+
function businessRuleAsRecord(config) {
|
|
14
|
+
const br = app_1.BusinessRuleSchema.parse(config);
|
|
15
|
+
return (0, db_1.Record)({
|
|
16
|
+
$id: br.$id,
|
|
17
|
+
table: 'sys_script',
|
|
18
|
+
data: {
|
|
19
|
+
name: br.name,
|
|
20
|
+
collection: br.table,
|
|
21
|
+
script: br.script,
|
|
22
|
+
order: br.order ?? 100,
|
|
23
|
+
action_insert: br?.action?.includes('insert') ?? false,
|
|
24
|
+
action_update: br?.action?.includes('update') ?? false,
|
|
25
|
+
action_query: br?.action?.includes('query') ?? false,
|
|
26
|
+
action_delete: br?.action?.includes('delete') ?? false,
|
|
27
|
+
active: br.active ?? true,
|
|
28
|
+
when: br.when ?? 'before',
|
|
29
|
+
message: br.message,
|
|
30
|
+
add_message: br.add_message ?? br.message ? true : false,
|
|
31
|
+
condition: br.condition,
|
|
32
|
+
filter_condition: br.filter_condition,
|
|
33
|
+
template: br.set_field_value,
|
|
34
|
+
description: br.description,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
exports.default = (0, sdk_build_core_1.Plugin)({
|
|
39
|
+
name: 'BusinessRule',
|
|
40
|
+
ownedTables: {
|
|
41
|
+
sys_script: { diagnosticLevel: sdk_project_1.Diagnostic.Level.Warn },
|
|
42
|
+
},
|
|
43
|
+
extractors: {
|
|
44
|
+
entity: {
|
|
45
|
+
CallExpression(node, context) {
|
|
46
|
+
const result = (0, RecordPlugin_1.extractCallExpressionAsRecord)(app_1.BusinessRule, businessRuleAsRecord, (br) => context.registerExplicitId('sys_script', br.$id), node, context);
|
|
47
|
+
if (!result.handled || !(0 in result.data)) {
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
const record = result.data[0];
|
|
51
|
+
const recordData = record.getProperty('data').getValue();
|
|
52
|
+
const scriptData = recordData.script;
|
|
53
|
+
const role_conditions = recordData.role_conditions;
|
|
54
|
+
let scriptVal;
|
|
55
|
+
if (scriptData && scriptData.filePath) {
|
|
56
|
+
const { filePath, functionName, isDefault } = scriptData;
|
|
57
|
+
scriptVal = (0, scriptUtils_1.buildScriptImport)(filePath, functionName, isDefault, context, (funcName) => `${funcName}(current, previous)\n`);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
scriptVal = recordData.script;
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
handled: true,
|
|
64
|
+
diagnostics: result.diagnostics,
|
|
65
|
+
data: [
|
|
66
|
+
new sdk_build_core_1.EntityData(record.getKind(), record.getGuid(), sdk_build_core_1.ObjectData.fromObjectValue((0, lodash_1.merge)(record.getValue(), {
|
|
67
|
+
data: {
|
|
68
|
+
script: scriptVal,
|
|
69
|
+
role_conditions: role_conditions ? (0, app_1.getRolesString)(role_conditions) : '',
|
|
70
|
+
},
|
|
71
|
+
}), record.getNode()), record.getNode()),
|
|
72
|
+
],
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
raw: {
|
|
77
|
+
FunctionDeclaration(node, context) {
|
|
78
|
+
const info = (0, scriptUtils_1.scriptInfo)(node, context, app_1.BusinessRule.name);
|
|
79
|
+
if (!info) {
|
|
80
|
+
return { handled: false };
|
|
81
|
+
}
|
|
82
|
+
return { handled: true, diagnostics: [], data: [info] };
|
|
83
|
+
},
|
|
84
|
+
FunctionExpression(node, context) {
|
|
85
|
+
const info = (0, scriptUtils_1.scriptInfo)(node, context, app_1.BusinessRule.name);
|
|
86
|
+
if (!info) {
|
|
87
|
+
return { handled: false };
|
|
88
|
+
}
|
|
89
|
+
return { handled: true, diagnostics: [], data: [info] };
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
generators: {
|
|
94
|
+
record(document, context) {
|
|
95
|
+
if (!app_1.BusinessRuleSchemaInc.safeParse(document.data['data']).success) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
return (0, sdk_build_core_1.linkDocument)(document, (0, sdk_build_core_1.generateCallExpressionExportForDocument)(context, {
|
|
99
|
+
sourceFile: (0, sdk_build_core_1.getOrCreateEntitySourceFile)(context, (0, sdk_build_core_1.getSysUpdateName)(document, 'sys_script')),
|
|
100
|
+
moduleSpecifier: '@servicenow/sdk/core',
|
|
101
|
+
}, app_1.BusinessRule, { $id: document.guid }).getExpressionIfKindOrThrow(ts_morph_1.SyntaxKind.CallExpression));
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
transformers: {
|
|
105
|
+
record: {
|
|
106
|
+
CallExpression(document, context) {
|
|
107
|
+
if ((0, sdk_build_core_1.getCallExpressionName)(document.node) !== app_1.BusinessRule.name) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
if (document.action === 'DELETE') {
|
|
111
|
+
(0, sdk_build_core_1.removeNode)(document.node);
|
|
112
|
+
return true;
|
|
113
|
+
}
|
|
114
|
+
const modified_properties = app_1.BusinessRuleSchemaInc.deepPartial().safeParse(document.changedData.data);
|
|
115
|
+
const merged_properties = app_1.BusinessRuleSchemaInc.safeParse(document.data.data);
|
|
116
|
+
const incoming_properties = app_1.BusinessRuleSchemaInc.safeParse(document.xmlData.data);
|
|
117
|
+
if (!modified_properties.success || !merged_properties.success || !incoming_properties.success) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
const [args] = document.node.getArguments();
|
|
121
|
+
if (!ts_morph_1.Node.isObjectLiteralExpression(args)) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
const { role_conditions: roles, filter_condition: filters, collection, script, template, action_delete, action_insert, action_query, action_update, ...rest } = modified_properties.data;
|
|
125
|
+
const xml_actions = getActionsArray(incoming_properties.data);
|
|
126
|
+
if (xml_actions.length > 0 || getActionsArray(merged_properties.data).length > 0) {
|
|
127
|
+
(0, sdk_build_core_1.writeCustomProperty)(args, 'action', '[]', (0, sdk_build_core_1.stringify)(xml_actions));
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
const actionsProp = (0, sdk_build_core_1.getOrCreatePropertyAssignment)(args, 'action', '[]');
|
|
131
|
+
actionsProp.remove();
|
|
132
|
+
}
|
|
133
|
+
if (roles) {
|
|
134
|
+
(0, sdk_build_core_1.writeArrayPropertyAsReference)(args, 'role_conditions', '[]', (0, app_1.getRolesArray)(roles));
|
|
135
|
+
}
|
|
136
|
+
if (filters) {
|
|
137
|
+
(0, sdk_build_core_1.writeCustomProperty)(args, 'filter_condition', '', `\`${filters}\``);
|
|
138
|
+
}
|
|
139
|
+
if (script !== undefined) {
|
|
140
|
+
(0, ScriptTemplatePlugin_1.processScript)(args, 'script', script, document.guid, 'sys_script', context);
|
|
141
|
+
}
|
|
142
|
+
if (template) {
|
|
143
|
+
(0, sdk_build_core_1.writeCustomProperty)(args, 'set_field_value', '', (0, sdk_build_core_1.stringify)(template));
|
|
144
|
+
}
|
|
145
|
+
const reqSchema = app_1.BusinessRuleSchemaInc.required();
|
|
146
|
+
const result = (0, sdk_build_core_1.transformFunctionArguments)(document.node, app_1.BusinessRule, {
|
|
147
|
+
table: collection,
|
|
148
|
+
...rest,
|
|
149
|
+
});
|
|
150
|
+
return result;
|
|
151
|
+
},
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
function getActionsArray(data) {
|
|
156
|
+
const actions = [];
|
|
157
|
+
if (data.action_update) {
|
|
158
|
+
actions.push('update');
|
|
159
|
+
}
|
|
160
|
+
if (data.action_delete) {
|
|
161
|
+
actions.push('delete');
|
|
162
|
+
}
|
|
163
|
+
if (data.action_insert) {
|
|
164
|
+
actions.push('insert');
|
|
165
|
+
}
|
|
166
|
+
if (data.action_query) {
|
|
167
|
+
actions.push('query');
|
|
168
|
+
}
|
|
169
|
+
return actions;
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=BusinessRulePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"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AC,OAAO,CAAC,CAAA;IACzB,CAAC;IAED,OAAO,OAAO,CAAA;AAClB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { CrossScopePrivilege } from '@servicenow/sdk-core/runtime/app';
|
|
2
|
+
import { EntityData } from '@servicenow/sdk-build-core';
|
|
3
|
+
import { Diagnostic } from '@servicenow/sdk-project';
|
|
4
|
+
declare const _default: {
|
|
5
|
+
readonly name: "CrossScopePrivilege";
|
|
6
|
+
readonly ownedTables: {
|
|
7
|
+
readonly sys_scope_privilege: {
|
|
8
|
+
readonly diagnosticLevel: Diagnostic.Level.Warn;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
readonly extractors: {
|
|
12
|
+
readonly entity: {
|
|
13
|
+
readonly CallExpression: (node: import("ts-morph").CallExpression<import("ts-morph").ts.CallExpression>, context: import("@servicenow/sdk-build-core").Context) => import("@servicenow/sdk-build-core").ExtractionResult<EntityData<CrossScopePrivilege>>;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
readonly composers: {
|
|
17
|
+
readonly entity: {
|
|
18
|
+
readonly sys_scope_privilege: (entity: EntityData<globalThis.Record<string, unknown>>, context: import("@servicenow/sdk-build-core").Context) => import("@servicenow/sdk-build-core").LinkedDocument[] | undefined;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const app_1 = require("@servicenow/sdk-core/runtime/app");
|
|
4
|
+
const sdk_build_core_1 = require("@servicenow/sdk-build-core");
|
|
5
|
+
const RecordPlugin_1 = require("./db/RecordPlugin");
|
|
6
|
+
const sdk_project_1 = require("@servicenow/sdk-project");
|
|
7
|
+
const db_1 = require("@servicenow/sdk-core/runtime/db");
|
|
8
|
+
exports.default = (0, sdk_build_core_1.Plugin)({
|
|
9
|
+
name: 'CrossScopePrivilege',
|
|
10
|
+
ownedTables: {
|
|
11
|
+
sys_scope_privilege: { diagnosticLevel: sdk_project_1.Diagnostic.Level.Warn },
|
|
12
|
+
},
|
|
13
|
+
extractors: {
|
|
14
|
+
entity: {
|
|
15
|
+
CallExpression: (node, context) => (0, sdk_build_core_1.extractCallExpression)(app_1.CrossScopePrivilege, 'sys_scope_privilege', node, context, (privilege) => context.registerExplicitId('sys_scope_privilege', privilege.$id)),
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
composers: {
|
|
19
|
+
entity: {
|
|
20
|
+
sys_scope_privilege(entity, context) {
|
|
21
|
+
const scopeId = context.app.config.scopeId;
|
|
22
|
+
const privilege = app_1.CrossScopePrivilegeSchema.safeParse(entity.getValue());
|
|
23
|
+
if (!privilege.success) {
|
|
24
|
+
return undefined;
|
|
25
|
+
}
|
|
26
|
+
const { $id, ...rest } = privilege.data;
|
|
27
|
+
const privilegeRecord = (0, db_1.Record)({
|
|
28
|
+
table: 'sys_scope_privilege',
|
|
29
|
+
$id,
|
|
30
|
+
data: {
|
|
31
|
+
source_scope: scopeId,
|
|
32
|
+
...rest,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
return context.composeEntities([
|
|
36
|
+
new sdk_build_core_1.EntityData('record', entity.getGuid(), sdk_build_core_1.ObjectData.fromObjectValue(privilegeRecord, entity.getNode()), entity.getNode()),
|
|
37
|
+
], [RecordPlugin_1.RecordPlugin]);
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
//# sourceMappingURL=CrossScopePrivilegePlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CrossScopePrivilegePlugin.js","sourceRoot":"","sources":["../src/CrossScopePrivilegePlugin.ts"],"names":[],"mappings":";;AAAA,0DAAiG;AACjG,+DAAkG;AAClG,oDAAgD;AAChD,yDAAoD;AACpD,wDAAwD;AAExD,kBAAe,IAAA,uBAAM,EAA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jB,CAAA;YACL,CAAC;SACJ;KACJ;CACJ,CAAC,CAAA"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { BooleanData, FluentDiagnostic, StringData, NumberData, ArrayData, ObjectData } from '@servicenow/sdk-build-core';
|
|
2
|
+
import * as ts from 'ts-morph';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
readonly name: "Default";
|
|
5
|
+
readonly extractors: {
|
|
6
|
+
readonly raw: {
|
|
7
|
+
readonly TrueKeyword: (node: ts.TrueLiteral) => {
|
|
8
|
+
handled: true;
|
|
9
|
+
diagnostics: never[];
|
|
10
|
+
data: BooleanData<true>[];
|
|
11
|
+
};
|
|
12
|
+
readonly FalseKeyword: (node: ts.FalseLiteral) => {
|
|
13
|
+
handled: true;
|
|
14
|
+
diagnostics: never[];
|
|
15
|
+
data: BooleanData<false>[];
|
|
16
|
+
};
|
|
17
|
+
readonly StringLiteral: (node: ts.StringLiteral) => {
|
|
18
|
+
handled: true;
|
|
19
|
+
diagnostics: never[];
|
|
20
|
+
data: StringData<string>[];
|
|
21
|
+
};
|
|
22
|
+
readonly NoSubstitutionTemplateLiteral: (node: ts.NoSubstitutionTemplateLiteral) => {
|
|
23
|
+
handled: true;
|
|
24
|
+
diagnostics: never[];
|
|
25
|
+
data: StringData<string>[];
|
|
26
|
+
};
|
|
27
|
+
readonly NumericLiteral: (node: ts.NumericLiteral) => {
|
|
28
|
+
handled: true;
|
|
29
|
+
diagnostics: never[];
|
|
30
|
+
data: NumberData<number>[];
|
|
31
|
+
};
|
|
32
|
+
readonly AsExpression: (node: ts.AsExpression, context: import("@servicenow/sdk-build-core").Context) => import("@servicenow/sdk-build-core").ExtractionResult;
|
|
33
|
+
readonly ComputedPropertyName: (node: ts.ComputedPropertyName, context: import("@servicenow/sdk-build-core").Context) => import("@servicenow/sdk-build-core").ExtractionResult;
|
|
34
|
+
readonly Identifier: (node: ts.Identifier, context: import("@servicenow/sdk-build-core").Context) => import("@servicenow/sdk-build-core").ExtractionResult;
|
|
35
|
+
readonly PropertyAccessExpression: (node: ts.PropertyAccessExpression<ts.ts.PropertyAccessExpression>, context: import("@servicenow/sdk-build-core").Context) => import("@servicenow/sdk-build-core").ExtractionResult;
|
|
36
|
+
readonly ShorthandPropertyAssignment: (node: ts.ShorthandPropertyAssignment, context: import("@servicenow/sdk-build-core").Context) => import("@servicenow/sdk-build-core").ExtractionResult;
|
|
37
|
+
readonly VariableDeclaration: (node: ts.VariableDeclaration, context: import("@servicenow/sdk-build-core").Context) => import("@servicenow/sdk-build-core").ExtractionResult;
|
|
38
|
+
readonly PropertyAssignment: (node: ts.PropertyAssignment, context: import("@servicenow/sdk-build-core").Context) => import("@servicenow/sdk-build-core").ExtractionResult;
|
|
39
|
+
readonly ArrayLiteralExpression: (node: ts.ArrayLiteralExpression, context: import("@servicenow/sdk-build-core").Context) => {
|
|
40
|
+
handled: true;
|
|
41
|
+
diagnostics: FluentDiagnostic[];
|
|
42
|
+
data: ArrayData<unknown[]>[];
|
|
43
|
+
};
|
|
44
|
+
readonly ObjectLiteralExpression: (node: ts.ObjectLiteralExpression, context: import("@servicenow/sdk-build-core").Context) => {
|
|
45
|
+
handled: true;
|
|
46
|
+
diagnostics: FluentDiagnostic[];
|
|
47
|
+
data: ObjectData<{
|
|
48
|
+
[x: string]: any;
|
|
49
|
+
}>[];
|
|
50
|
+
};
|
|
51
|
+
readonly TemplateExpression: (node: ts.TemplateExpression, context: import("@servicenow/sdk-build-core").Context) => {
|
|
52
|
+
handled: true;
|
|
53
|
+
diagnostics: FluentDiagnostic[];
|
|
54
|
+
data: StringData<string>[];
|
|
55
|
+
};
|
|
56
|
+
readonly PrefixUnaryExpression: (node: ts.PrefixUnaryExpression) => {
|
|
57
|
+
handled: true;
|
|
58
|
+
data: never[];
|
|
59
|
+
diagnostics: FluentDiagnostic[];
|
|
60
|
+
} | {
|
|
61
|
+
handled: true;
|
|
62
|
+
diagnostics: never[];
|
|
63
|
+
data: NumberData<number>[];
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
readonly diagnostics: {
|
|
68
|
+
readonly Node: (node: ts.Node<ts.ts.Node>) => FluentDiagnostic[];
|
|
69
|
+
};
|
|
70
|
+
};
|
|
71
|
+
export default _default;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const sdk_project_1 = require("@servicenow/sdk-project");
|
|
27
|
+
const sdk_build_core_1 = require("@servicenow/sdk-build-core");
|
|
28
|
+
const ts = __importStar(require("ts-morph"));
|
|
29
|
+
exports.default = (0, sdk_build_core_1.Plugin)({
|
|
30
|
+
name: 'Default',
|
|
31
|
+
extractors: {
|
|
32
|
+
raw: {
|
|
33
|
+
TrueKeyword(node) {
|
|
34
|
+
return {
|
|
35
|
+
handled: true,
|
|
36
|
+
diagnostics: [],
|
|
37
|
+
data: [new sdk_build_core_1.BooleanData(true, node)],
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
FalseKeyword(node) {
|
|
41
|
+
return {
|
|
42
|
+
handled: true,
|
|
43
|
+
diagnostics: [],
|
|
44
|
+
data: [new sdk_build_core_1.BooleanData(false, node)],
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
StringLiteral(node) {
|
|
48
|
+
return {
|
|
49
|
+
handled: true,
|
|
50
|
+
diagnostics: [],
|
|
51
|
+
data: [new sdk_build_core_1.StringData(node.getLiteralValue(), node)],
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
NoSubstitutionTemplateLiteral(node) {
|
|
55
|
+
return {
|
|
56
|
+
handled: true,
|
|
57
|
+
diagnostics: [],
|
|
58
|
+
data: [new sdk_build_core_1.StringData(node.getLiteralValue(), node)],
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
NumericLiteral(node) {
|
|
62
|
+
return {
|
|
63
|
+
handled: true,
|
|
64
|
+
diagnostics: [],
|
|
65
|
+
data: [new sdk_build_core_1.NumberData(node.getLiteralValue(), node)],
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
AsExpression(node, context) {
|
|
69
|
+
return context.extractAst(node.getExpression());
|
|
70
|
+
},
|
|
71
|
+
ComputedPropertyName(node, context) {
|
|
72
|
+
return context.extractAst(node.getExpression());
|
|
73
|
+
},
|
|
74
|
+
Identifier(node, context) {
|
|
75
|
+
return context.extractAst((0, sdk_build_core_1.getValueDeclaration)(node));
|
|
76
|
+
},
|
|
77
|
+
PropertyAccessExpression(node, context) {
|
|
78
|
+
return context.extractAst(node.getNameNode());
|
|
79
|
+
},
|
|
80
|
+
ShorthandPropertyAssignment(node, context) {
|
|
81
|
+
return context.extractAst(node.getNameNode());
|
|
82
|
+
},
|
|
83
|
+
VariableDeclaration(node, context) {
|
|
84
|
+
const initializer = node.getInitializer();
|
|
85
|
+
if (!initializer) {
|
|
86
|
+
return {
|
|
87
|
+
handled: true,
|
|
88
|
+
data: [],
|
|
89
|
+
diagnostics: [
|
|
90
|
+
new sdk_build_core_1.FluentDiagnostic(node, `Expected variable declaration to have an initializer: ${node.getText()}`),
|
|
91
|
+
],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return context.extractAst(initializer);
|
|
95
|
+
},
|
|
96
|
+
PropertyAssignment(node, context) {
|
|
97
|
+
const initializer = node.getInitializer();
|
|
98
|
+
if (!initializer) {
|
|
99
|
+
return {
|
|
100
|
+
handled: true,
|
|
101
|
+
data: [],
|
|
102
|
+
diagnostics: [
|
|
103
|
+
new sdk_build_core_1.FluentDiagnostic(node, `Expected property assignment to have an initializer: ${node.getText()}`),
|
|
104
|
+
],
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
return context.extractAst(initializer);
|
|
108
|
+
},
|
|
109
|
+
ArrayLiteralExpression(node, context) {
|
|
110
|
+
const diagnostics = [];
|
|
111
|
+
const data = [];
|
|
112
|
+
for (const element of node.getElements()) {
|
|
113
|
+
const result = context.extractAst(element);
|
|
114
|
+
if (!result.handled) {
|
|
115
|
+
return {
|
|
116
|
+
handled: true,
|
|
117
|
+
data: [],
|
|
118
|
+
diagnostics: [new sdk_build_core_1.FluentDiagnostic(element, 'Unsupported array element')],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
diagnostics.push(...result.diagnostics);
|
|
122
|
+
data.push(...result.data);
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
handled: true,
|
|
126
|
+
diagnostics,
|
|
127
|
+
data: [new sdk_build_core_1.ArrayData(data, node)],
|
|
128
|
+
};
|
|
129
|
+
},
|
|
130
|
+
ObjectLiteralExpression(node, context) {
|
|
131
|
+
const diagnostics = [];
|
|
132
|
+
const data = {};
|
|
133
|
+
for (const prop of node.getProperties()) {
|
|
134
|
+
if (!ts.Node.isPropertyAssignment(prop) && !ts.Node.isShorthandPropertyAssignment(prop)) {
|
|
135
|
+
diagnostics.push(new sdk_build_core_1.FluentDiagnostic(prop, 'Only property assignments are allowed'));
|
|
136
|
+
continue;
|
|
137
|
+
}
|
|
138
|
+
const nameNode = prop.getNameNode();
|
|
139
|
+
const result = context.extractAst(prop);
|
|
140
|
+
if (!result.handled) {
|
|
141
|
+
return {
|
|
142
|
+
handled: true,
|
|
143
|
+
data: [],
|
|
144
|
+
diagnostics: [new sdk_build_core_1.FluentDiagnostic(prop, 'Unsupported property assignment')],
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
diagnostics.push(...result.diagnostics);
|
|
148
|
+
if (!(0 in result.data) || result.data.length !== 1) {
|
|
149
|
+
diagnostics.push(new sdk_build_core_1.FluentDiagnostic(prop, `Property assignment has unsupported structure`));
|
|
150
|
+
continue;
|
|
151
|
+
}
|
|
152
|
+
const name = ts.Node.isStringLiteral(nameNode) ? nameNode.getLiteralValue() : prop.getName();
|
|
153
|
+
data[name] = result.data[0];
|
|
154
|
+
}
|
|
155
|
+
return {
|
|
156
|
+
handled: true,
|
|
157
|
+
diagnostics,
|
|
158
|
+
data: [new sdk_build_core_1.ObjectData(data, node)],
|
|
159
|
+
};
|
|
160
|
+
},
|
|
161
|
+
TemplateExpression(node, context) {
|
|
162
|
+
const diagnostics = [];
|
|
163
|
+
const text = node.getHead().getLiteralText() +
|
|
164
|
+
node
|
|
165
|
+
.getTemplateSpans()
|
|
166
|
+
.map((s) => {
|
|
167
|
+
const result = context.extractAst(s.getExpression());
|
|
168
|
+
if (!result.handled) {
|
|
169
|
+
diagnostics.push(new sdk_build_core_1.FluentDiagnostic(s, 'Unsupported expression in template'));
|
|
170
|
+
return undefined;
|
|
171
|
+
}
|
|
172
|
+
if (!(0 in result.data) || result.data.length !== 1) {
|
|
173
|
+
diagnostics.push(new sdk_build_core_1.FluentDiagnostic(s, `Unsupported expression in template`));
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
diagnostics.push(...result.diagnostics);
|
|
177
|
+
return `${result.data[0].getValue()}${s.getLiteral().getLiteralText()}`;
|
|
178
|
+
})
|
|
179
|
+
.join('');
|
|
180
|
+
return {
|
|
181
|
+
handled: true,
|
|
182
|
+
diagnostics,
|
|
183
|
+
data: [new sdk_build_core_1.StringData(text, node)],
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
//Added support for -ve number alone. Can be upgraded later to support other expressions as required.
|
|
187
|
+
PrefixUnaryExpression(node) {
|
|
188
|
+
if (!ts.Node.isNumericLiteral(node.getOperand()) ||
|
|
189
|
+
node.getOperatorToken() !== ts.SyntaxKind.MinusToken) {
|
|
190
|
+
return {
|
|
191
|
+
handled: true,
|
|
192
|
+
data: [],
|
|
193
|
+
diagnostics: [new sdk_build_core_1.FluentDiagnostic(node, 'Unsupported prefix unary expression')],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
return {
|
|
197
|
+
handled: true,
|
|
198
|
+
diagnostics: [],
|
|
199
|
+
data: [
|
|
200
|
+
new sdk_build_core_1.NumberData(-node.getOperand().asKind(ts.SyntaxKind.NumericLiteral).getLiteralValue(), node),
|
|
201
|
+
],
|
|
202
|
+
};
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
diagnostics: {
|
|
207
|
+
Node(node) {
|
|
208
|
+
if ((0, sdk_project_1.isSupportedNode)(node)) {
|
|
209
|
+
return [];
|
|
210
|
+
}
|
|
211
|
+
return [new sdk_build_core_1.FluentDiagnostic(node, `${getRawKindName(node)} is not allowed`)];
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
let rawKindNames;
|
|
216
|
+
/**
|
|
217
|
+
* This is a hack to get more accurate names for given syntax kinds. TypeScript's
|
|
218
|
+
* `SyntaxKind` enum has a lot of reused numeric values, so when you try to index
|
|
219
|
+
* it with a number, you might get a different name than you expect. For example,
|
|
220
|
+
* `VariableStatement` and `FirstStatement` both have the same numeric value, and
|
|
221
|
+
* you probably never would expect the latter. Thankfully, all the names that you
|
|
222
|
+
* probably never want are towards the end, so this just grabs all the first ones
|
|
223
|
+
* and ignores any duplicates that come after.
|
|
224
|
+
*/
|
|
225
|
+
function getRawKindName(node) {
|
|
226
|
+
if (!rawKindNames) {
|
|
227
|
+
rawKindNames = Object.entries(ts.SyntaxKind)
|
|
228
|
+
.filter(([k]) => isNaN(Number(k)))
|
|
229
|
+
.reduce((names, [name, value]) => {
|
|
230
|
+
if (typeof value === 'number' && !names[value]) {
|
|
231
|
+
names[value] = name; // Only add if it hasn't been added already
|
|
232
|
+
}
|
|
233
|
+
return names;
|
|
234
|
+
}, {});
|
|
235
|
+
}
|
|
236
|
+
return rawKindNames[node.getKind()];
|
|
237
|
+
}
|
|
238
|
+
//# sourceMappingURL=DefaultPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultPlugin.js","sourceRoot":"","sources":["../src/DefaultPlugin.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAAyD;AACzD,+DAUmC;AACnC,6CAA8B;AAE9B,kBAAe,IAAA,uBAAM,EAAC;IAClB,IAAI,EAAE,SAAS;IACf,UAAU,EAAE;QACR,GAAG,EAAE;YACD,WAAW,CAAC,IAAI;gBACZ,OAAO;oBACH,OAAO,EAAE,IAAI;oBACb,WAAW,EAAE,EAAE;oBACf,IAAI,EAAE,CAAC,IAAI,4BAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;iBACtC,CAAA;YACL,CAAC;YAED,YAAY,CAAC,IAAI;gBACb,OAAO;oBACH,OAAO,EAAE,IAAI;oBACb,WAAW,EAAE,EAAE;oBACf,IAAI,EAAE,CAAC,IAAI,4BAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;iBACvC,CAAA;YACL,CAAC;YAED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AAC;YAED,OAAO,CAAC,IAAI,iCAAgB,CAAC,IAAI,EAAE,GAAG,cAAc,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAA;QACjF,CAAC;KACJ;CACJ,CAAC,CAAA;AAEF,IAAI,YAAuD,CAAA;AAE3D;;;;;;;;GAQG;AACH,SAAS,cAAc,CAAC,IAAa;IACjC,IAAI,CAAC,YAAY,EAAE,CAAC;QAChB,YAAY,GAAG,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC;aACvC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;aACjC,MAAM,CACH,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE;YACrB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;gBAC7C,KAAK,CAAC,KAAK,CAAC,GAAG,IAAI,CAAA,CAAC,2CAA2C;YACnE,CAAC;YAED,OAAO,KAAK,CAAA;QAChB,CAAC,EACD,EAAmC,CACtC,CAAA;IACT,CAAC;IAED,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAA;AACvC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ElementAccessExpression } from 'ts-morph';
|
|
2
|
+
import { FluentDiagnostic } from '@servicenow/sdk-build-core';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
readonly name: "NowID";
|
|
5
|
+
readonly extractors: {
|
|
6
|
+
readonly raw: {
|
|
7
|
+
readonly ElementAccessExpression: (node: ElementAccessExpression, context: import("@servicenow/sdk-build-core").Context) => {
|
|
8
|
+
handled: true;
|
|
9
|
+
data: import("@servicenow/sdk-build-core").Data<unknown>[];
|
|
10
|
+
diagnostics: FluentDiagnostic[];
|
|
11
|
+
} | {
|
|
12
|
+
handled: false;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
package/dist/IdPlugin.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const sdk_project_1 = require("@servicenow/sdk-project");
|
|
4
|
+
const ts_morph_1 = require("ts-morph");
|
|
5
|
+
const sdk_build_core_1 = require("@servicenow/sdk-build-core");
|
|
6
|
+
exports.default = (0, sdk_build_core_1.Plugin)({
|
|
7
|
+
name: 'NowID',
|
|
8
|
+
extractors: {
|
|
9
|
+
raw: {
|
|
10
|
+
ElementAccessExpression(node, context) {
|
|
11
|
+
const nowIdExpression = node.getExpressionIfKind(ts_morph_1.SyntaxKind.PropertyAccessExpression);
|
|
12
|
+
if (!nowIdExpression || nowIdExpression.getText() !== 'Now.ID') {
|
|
13
|
+
return {
|
|
14
|
+
handled: false,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const argExpression = node.getArgumentExpression();
|
|
18
|
+
if (!argExpression || !(0, sdk_project_1.isSupportedNode)(argExpression)) {
|
|
19
|
+
return {
|
|
20
|
+
handled: true,
|
|
21
|
+
data: [],
|
|
22
|
+
diagnostics: [new sdk_build_core_1.FluentDiagnostic(node, 'Now.ID must have an argument')],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
const result = context.extractRaw(argExpression);
|
|
26
|
+
if (!result.handled) {
|
|
27
|
+
return {
|
|
28
|
+
handled: true,
|
|
29
|
+
data: [],
|
|
30
|
+
diagnostics: [new sdk_build_core_1.FluentDiagnostic(node, 'Unsupported Now.ID argument')],
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (!(0 in result.data) || result.data.length !== 1) {
|
|
34
|
+
return {
|
|
35
|
+
handled: true,
|
|
36
|
+
data: [],
|
|
37
|
+
diagnostics: [...result.diagnostics, new sdk_build_core_1.FluentDiagnostic(node, 'Unsupported Now.ID argument')],
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=IdPlugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IdPlugin.js","sourceRoot":"","sources":["../src/IdPlugin.ts"],"names":[],"mappings":";;AAAA,yDAAyD;AACzD,uCAA8D;AAC9D,+DAAqE;AAErE,kBAAe,IAAA,uBAAM,EAAC;IAClB,IAAI,EAAE,OAAO;IACb,UAAU,EAAE;QACR,GAAG,EAAE;YACD,uBAAuB,CAAC,IAA6B,EAAE,OAAO;gBAC1D,MAAM,eAAe,GAAG,IAAI,CAAC,mBAAmB,CAAC,qBAAU,CAAC,wBAAwB,CAAC,CAAA;gBACrF,IAAI,CAAC,eAAe,IAAI,eAAe,CAAC,OAAO,EAAE,KAAK,QAAQ,EAAE,CAAC;oBAC7D,OAAO;wBACH,OAAO,EAAE,KAAK;qBACjB,CAAA;gBACL,CAAC;gBAED,MAAM,aAAa,GAAG,IAAI,CAAC,qBAAqB,EAAE,CAAA;gBAClD,IAAI,CAAC,aAAa,IAAI,CAAC,IAAA,6BAAe,EAAC,aAAa,CAAC,EAAE,CAAC;oBACpD,OAAO;wBACH,OAAO,EAAE,IAAI;wBACb,IAAI,EAAE,EAAE;wBACR,WAAW,EAAE,CAAC,IAAI,iCAAgB,CAAC,IAAI,EAAE,8BAA8B,CAAC,CAAC;qBAC5E,CAAA;gBACL,CAAC;gBAED,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAA;gBAChD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;oBAClB,OAAO;wBACH,OAAO,EAAE,IAAI;wBACb,IAAI,EAAE,EAAE;wBACR,WAAW,EAAE,CAAC,IAAI,iCAAgB,CAAC,IAAI,EAAE,6BAA6B,CAAC,CAAC;qBAC3E,CAA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