@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,166 @@
|
|
|
1
|
+
// Copied from sn-uxf-formula-parser-library - https://code.devsnc.com/dev/uxf-formula-parser
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* https://code.devsnc.com/dev/uxf-formula-parser/blob/ci/master/src/uxf-formula-parser/grammar-parser/api.js
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { tokenSpan, getBinarySpan, getUnarySpan, getBindingSpan } from './spanHelpers'
|
|
8
|
+
import { getErrorMsg } from '../utils/getErrorMsg'
|
|
9
|
+
import functionTransformMap from './clientTransformMap'
|
|
10
|
+
|
|
11
|
+
let contextMetadata = null
|
|
12
|
+
|
|
13
|
+
const setContextMetadata = (cm) => {
|
|
14
|
+
contextMetadata = cm
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const api = {
|
|
18
|
+
binding: (bindingType, address, token, category = null) => {
|
|
19
|
+
if (category) {
|
|
20
|
+
return {
|
|
21
|
+
type: bindingType,
|
|
22
|
+
binding: {
|
|
23
|
+
address,
|
|
24
|
+
category,
|
|
25
|
+
},
|
|
26
|
+
_span: getBindingSpan(token, address),
|
|
27
|
+
}
|
|
28
|
+
} else {
|
|
29
|
+
return {
|
|
30
|
+
type: bindingType,
|
|
31
|
+
binding: {
|
|
32
|
+
address,
|
|
33
|
+
},
|
|
34
|
+
_span: getBindingSpan(token, address),
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
unknownBinding: (context, path, token) => {
|
|
39
|
+
// Compare
|
|
40
|
+
const metadata = contextMetadata?.find((cm) => cm.bindingLabel === context)
|
|
41
|
+
if (!metadata) {
|
|
42
|
+
throw new Error(`Unknown binding type '${context}'`)
|
|
43
|
+
}
|
|
44
|
+
const address = [...(metadata.source.binding.address ?? []), ...path]
|
|
45
|
+
return {
|
|
46
|
+
type: metadata.source.type,
|
|
47
|
+
binding: {
|
|
48
|
+
category: metadata.source.binding.category,
|
|
49
|
+
address,
|
|
50
|
+
},
|
|
51
|
+
_span: getBindingSpan(token, address),
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
completeParse: function (uxValue) {
|
|
55
|
+
const returnVal = {
|
|
56
|
+
uxValue,
|
|
57
|
+
errors: [],
|
|
58
|
+
}
|
|
59
|
+
return returnVal
|
|
60
|
+
},
|
|
61
|
+
translationLiteral: function (operands, functionToken, endToken) {
|
|
62
|
+
return {
|
|
63
|
+
type: 'TRANSLATION_LITERAL',
|
|
64
|
+
value: {
|
|
65
|
+
message: operands.container[0].value,
|
|
66
|
+
comment: '',
|
|
67
|
+
},
|
|
68
|
+
_span: tokenSpan(functionToken, endToken),
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
binaryOperator: function (operator, left, right) {
|
|
72
|
+
return {
|
|
73
|
+
type: 'BINARY',
|
|
74
|
+
operation: {
|
|
75
|
+
operator,
|
|
76
|
+
left,
|
|
77
|
+
right,
|
|
78
|
+
},
|
|
79
|
+
_span: getBinarySpan(left, right),
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
unaryOperator: (operator, operand, startToken) => {
|
|
83
|
+
return {
|
|
84
|
+
type: 'UNARY',
|
|
85
|
+
operation: {
|
|
86
|
+
operator,
|
|
87
|
+
operand,
|
|
88
|
+
},
|
|
89
|
+
_span: getUnarySpan(startToken, operand),
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
listContainer: (items, startToken, endToken) => {
|
|
93
|
+
return {
|
|
94
|
+
type: 'LIST_CONTAINER',
|
|
95
|
+
container: items,
|
|
96
|
+
_span: startToken ? tokenSpan(startToken, endToken) : null,
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
mapContainer: (params, startToken, endToken) => {
|
|
100
|
+
// TODO: Error handling for duplicate keys?
|
|
101
|
+
const mapContainer = {}
|
|
102
|
+
params.forEach((param) => (mapContainer[param.name] = param.value))
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
type: 'MAP_CONTAINER',
|
|
106
|
+
container: mapContainer,
|
|
107
|
+
_span: tokenSpan(startToken, endToken),
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
transformFunc: function (functionToken, operands, endToken) {
|
|
111
|
+
const funcName = functionToken.value
|
|
112
|
+
if (funcName === 'TRANSLATE') {
|
|
113
|
+
if (operands.container.length !== 1) {
|
|
114
|
+
throw getErrorMsg(
|
|
115
|
+
`Error: TRANSLATE expects exactly 1 argument; given ${operands.container.length}.`,
|
|
116
|
+
tokenSpan(functionToken, endToken)
|
|
117
|
+
)
|
|
118
|
+
} else if (operands.container[0].type !== 'JSON_LITERAL') {
|
|
119
|
+
throw getErrorMsg(
|
|
120
|
+
'Error: TRANSLATE expects a string to be passed in.',
|
|
121
|
+
tokenSpan(functionToken, endToken)
|
|
122
|
+
)
|
|
123
|
+
} else {
|
|
124
|
+
return this.translationLiteral(operands, functionToken, endToken)
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
const mappedFunctionDef = functionTransformMap[funcName]
|
|
128
|
+
|
|
129
|
+
if (!mappedFunctionDef) {
|
|
130
|
+
throw getErrorMsg(`Error: ${funcName} is not a supported function.`, tokenSpan(functionToken, endToken))
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return {
|
|
134
|
+
type: mappedFunctionDef.type || 'CLIENT_TRANSFORM',
|
|
135
|
+
transform: {
|
|
136
|
+
operator: mappedFunctionDef.name,
|
|
137
|
+
operands,
|
|
138
|
+
},
|
|
139
|
+
_span: tokenSpan(functionToken, endToken),
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
|
|
143
|
+
literal: function (literalToken) {
|
|
144
|
+
const val = literalToken.value
|
|
145
|
+
const _span = tokenSpan(literalToken)
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
type: 'JSON_LITERAL',
|
|
149
|
+
value: val,
|
|
150
|
+
_span,
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
boolean: function (token) {
|
|
155
|
+
const val = JSON.parse(token.value)
|
|
156
|
+
const _span = tokenSpan(token)
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
type: 'JSON_LITERAL',
|
|
160
|
+
value: val,
|
|
161
|
+
_span,
|
|
162
|
+
}
|
|
163
|
+
},
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export { api, setContextMetadata }
|