@servicenow/sdk-build-core 3.0.3 → 4.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.
Files changed (252) hide show
  1. package/dist/app.d.ts +25 -0
  2. package/dist/app.js +8 -0
  3. package/dist/app.js.map +1 -0
  4. package/dist/compiler.d.ts +60 -0
  5. package/dist/compiler.js +320 -0
  6. package/dist/compiler.js.map +1 -0
  7. package/dist/compression.d.ts +7 -0
  8. package/dist/compression.js +79 -0
  9. package/dist/compression.js.map +1 -0
  10. package/dist/crypto.d.ts +1 -0
  11. package/dist/crypto.js +9 -0
  12. package/dist/crypto.js.map +1 -0
  13. package/dist/diagnostic.d.ts +41 -0
  14. package/dist/diagnostic.js +130 -0
  15. package/dist/diagnostic.js.map +1 -0
  16. package/dist/{plugins/Diagnostic.d.ts → fluent-diagnostic.d.ts} +3 -2
  17. package/dist/fluent-diagnostic.js +23 -0
  18. package/dist/fluent-diagnostic.js.map +1 -0
  19. package/dist/fluent-directive.d.ts +8 -0
  20. package/dist/fluent-directive.js +54 -0
  21. package/dist/fluent-directive.js.map +1 -0
  22. package/dist/fluent-file.d.ts +5 -0
  23. package/dist/fluent-file.js +15 -0
  24. package/dist/fluent-file.js.map +1 -0
  25. package/dist/formatter.d.ts +11 -0
  26. package/dist/formatter.js +77 -0
  27. package/dist/formatter.js.map +1 -0
  28. package/dist/fs.d.ts +174 -0
  29. package/dist/fs.js +313 -0
  30. package/dist/fs.js.map +1 -0
  31. package/dist/guid.d.ts +2 -0
  32. package/dist/{GUID.js → guid.js} +3 -6
  33. package/dist/guid.js.map +1 -0
  34. package/dist/index.d.ts +19 -5
  35. package/dist/index.js +19 -5
  36. package/dist/index.js.map +1 -1
  37. package/dist/json.d.ts +5 -0
  38. package/dist/json.js +43 -0
  39. package/dist/json.js.map +1 -0
  40. package/dist/keys-registry.d.ts +64 -0
  41. package/dist/keys-registry.js +339 -0
  42. package/dist/keys-registry.js.map +1 -0
  43. package/dist/logger.d.ts +8 -0
  44. package/dist/logger.js +17 -0
  45. package/dist/logger.js.map +1 -0
  46. package/dist/now-config.d.ts +348 -0
  47. package/dist/now-config.js +283 -0
  48. package/dist/now-config.js.map +1 -0
  49. package/dist/path.d.ts +3 -0
  50. package/dist/path.js +12 -0
  51. package/dist/path.js.map +1 -0
  52. package/dist/plugins/cache.d.ts +20 -0
  53. package/dist/plugins/cache.js +46 -0
  54. package/dist/plugins/cache.js.map +1 -0
  55. package/dist/plugins/context.d.ts +85 -0
  56. package/dist/plugins/{Context.js → context.js} +1 -1
  57. package/dist/plugins/context.js.map +1 -0
  58. package/dist/plugins/database.d.ts +27 -0
  59. package/dist/plugins/database.js +102 -0
  60. package/dist/plugins/database.js.map +1 -0
  61. package/dist/plugins/file.d.ts +10 -0
  62. package/dist/plugins/{behaviors/Arranger.js → file.js} +1 -1
  63. package/dist/plugins/file.js.map +1 -0
  64. package/dist/plugins/index.d.ts +9 -5
  65. package/dist/plugins/index.js +9 -6
  66. package/dist/plugins/index.js.map +1 -1
  67. package/dist/plugins/plugin.d.ts +478 -0
  68. package/dist/plugins/plugin.js +533 -0
  69. package/dist/plugins/plugin.js.map +1 -0
  70. package/dist/plugins/product.d.ts +15 -0
  71. package/dist/plugins/product.js +38 -0
  72. package/dist/plugins/product.js.map +1 -0
  73. package/dist/plugins/project.d.ts +25 -0
  74. package/dist/plugins/{behaviors/Generator.js → project.js} +1 -1
  75. package/dist/plugins/project.js.map +1 -0
  76. package/dist/plugins/shape.d.ts +424 -0
  77. package/dist/plugins/shape.js +1181 -0
  78. package/dist/plugins/shape.js.map +1 -0
  79. package/dist/plugins/time.d.ts +12 -0
  80. package/dist/plugins/time.js +84 -0
  81. package/dist/plugins/time.js.map +1 -0
  82. package/dist/plugins/usage.d.ts +11 -0
  83. package/dist/plugins/usage.js +26 -0
  84. package/dist/plugins/usage.js.map +1 -0
  85. package/dist/prettier/config-loader.d.ts +13 -0
  86. package/dist/prettier/config-loader.js +105 -0
  87. package/dist/prettier/config-loader.js.map +1 -0
  88. package/dist/telemetry/index.d.ts +25 -0
  89. package/dist/telemetry/index.js +18 -0
  90. package/dist/telemetry/index.js.map +1 -0
  91. package/dist/typescript.d.ts +293 -0
  92. package/dist/typescript.js +454 -0
  93. package/dist/typescript.js.map +1 -0
  94. package/dist/util/get-file-type.d.ts +2 -0
  95. package/dist/util/get-file-type.js +13 -0
  96. package/dist/util/get-file-type.js.map +1 -0
  97. package/dist/util/index.d.ts +2 -6
  98. package/dist/util/index.js +2 -6
  99. package/dist/util/index.js.map +1 -1
  100. package/dist/util/{Scope.js → is-sn-scope.js} +1 -1
  101. package/dist/util/is-sn-scope.js.map +1 -0
  102. package/dist/xml.d.ts +24 -0
  103. package/dist/xml.js +71 -0
  104. package/dist/xml.js.map +1 -0
  105. package/now.config.schema.json +336 -0
  106. package/package.json +22 -12
  107. package/src/app.ts +33 -0
  108. package/src/compiler.ts +384 -0
  109. package/src/compression.ts +93 -0
  110. package/src/crypto.ts +5 -0
  111. package/src/diagnostic.ts +108 -0
  112. package/src/{plugins/Diagnostic.ts → fluent-diagnostic.ts} +3 -10
  113. package/src/fluent-directive.ts +63 -0
  114. package/src/fluent-file.ts +13 -0
  115. package/src/formatter.ts +58 -0
  116. package/src/fs.ts +438 -0
  117. package/src/{GUID.ts → guid.ts} +2 -6
  118. package/src/index.ts +19 -5
  119. package/src/json.ts +20 -0
  120. package/src/keys-registry.ts +384 -0
  121. package/src/logger.ts +20 -0
  122. package/src/now-config.ts +337 -0
  123. package/src/path.ts +9 -0
  124. package/src/plugins/cache.ts +45 -0
  125. package/src/plugins/context.ts +93 -0
  126. package/src/plugins/database.ts +121 -0
  127. package/src/plugins/file.ts +19 -0
  128. package/src/plugins/index.ts +9 -5
  129. package/src/plugins/plugin.ts +995 -0
  130. package/src/plugins/product.ts +44 -0
  131. package/src/plugins/project.ts +39 -0
  132. package/src/plugins/shape.ts +1532 -0
  133. package/src/plugins/time.ts +108 -0
  134. package/src/plugins/usage.ts +26 -0
  135. package/src/prettier/config-loader.ts +130 -0
  136. package/src/telemetry/index.ts +27 -0
  137. package/src/typescript.ts +502 -0
  138. package/src/util/get-file-type.ts +11 -0
  139. package/src/util/index.ts +2 -6
  140. package/src/xml.ts +86 -0
  141. package/dist/GUID.d.ts +0 -2
  142. package/dist/GUID.js.map +0 -1
  143. package/dist/IncludePaths.d.ts +0 -25
  144. package/dist/IncludePaths.js +0 -97
  145. package/dist/IncludePaths.js.map +0 -1
  146. package/dist/Keys.d.ts +0 -32
  147. package/dist/Keys.js +0 -245
  148. package/dist/Keys.js.map +0 -1
  149. package/dist/TypeScript.d.ts +0 -5
  150. package/dist/TypeScript.js +0 -58
  151. package/dist/TypeScript.js.map +0 -1
  152. package/dist/XML.d.ts +0 -32
  153. package/dist/XML.js +0 -83
  154. package/dist/XML.js.map +0 -1
  155. package/dist/plugins/Context.d.ts +0 -190
  156. package/dist/plugins/Context.js.map +0 -1
  157. package/dist/plugins/Diagnostic.js +0 -28
  158. package/dist/plugins/Diagnostic.js.map +0 -1
  159. package/dist/plugins/Plugin.d.ts +0 -175
  160. package/dist/plugins/Plugin.js +0 -15
  161. package/dist/plugins/Plugin.js.map +0 -1
  162. package/dist/plugins/behaviors/Arranger.d.ts +0 -26
  163. package/dist/plugins/behaviors/Arranger.js.map +0 -1
  164. package/dist/plugins/behaviors/Composer.d.ts +0 -102
  165. package/dist/plugins/behaviors/Composer.js +0 -15
  166. package/dist/plugins/behaviors/Composer.js.map +0 -1
  167. package/dist/plugins/behaviors/Diagnostics.d.ts +0 -7
  168. package/dist/plugins/behaviors/Diagnostics.js +0 -3
  169. package/dist/plugins/behaviors/Diagnostics.js.map +0 -1
  170. package/dist/plugins/behaviors/Generator.d.ts +0 -21
  171. package/dist/plugins/behaviors/Generator.js.map +0 -1
  172. package/dist/plugins/behaviors/OwnedTables.d.ts +0 -6
  173. package/dist/plugins/behaviors/OwnedTables.js +0 -3
  174. package/dist/plugins/behaviors/OwnedTables.js.map +0 -1
  175. package/dist/plugins/behaviors/PostProcessor.d.ts +0 -5
  176. package/dist/plugins/behaviors/PostProcessor.js +0 -3
  177. package/dist/plugins/behaviors/PostProcessor.js.map +0 -1
  178. package/dist/plugins/behaviors/Serializer.d.ts +0 -30
  179. package/dist/plugins/behaviors/Serializer.js +0 -3
  180. package/dist/plugins/behaviors/Serializer.js.map +0 -1
  181. package/dist/plugins/behaviors/Transformer.d.ts +0 -23
  182. package/dist/plugins/behaviors/Transformer.js +0 -3
  183. package/dist/plugins/behaviors/Transformer.js.map +0 -1
  184. package/dist/plugins/behaviors/extractors/Data.d.ts +0 -119
  185. package/dist/plugins/behaviors/extractors/Data.js +0 -244
  186. package/dist/plugins/behaviors/extractors/Data.js.map +0 -1
  187. package/dist/plugins/behaviors/extractors/Extractors.d.ts +0 -63
  188. package/dist/plugins/behaviors/extractors/Extractors.js +0 -3
  189. package/dist/plugins/behaviors/extractors/Extractors.js.map +0 -1
  190. package/dist/plugins/behaviors/extractors/index.d.ts +0 -2
  191. package/dist/plugins/behaviors/extractors/index.js +0 -19
  192. package/dist/plugins/behaviors/extractors/index.js.map +0 -1
  193. package/dist/plugins/behaviors/index.d.ts +0 -9
  194. package/dist/plugins/behaviors/index.js +0 -26
  195. package/dist/plugins/behaviors/index.js.map +0 -1
  196. package/dist/plugins/util/CallExpression.d.ts +0 -5
  197. package/dist/plugins/util/CallExpression.js +0 -88
  198. package/dist/plugins/util/CallExpression.js.map +0 -1
  199. package/dist/plugins/util/CodeTransformation.d.ts +0 -95
  200. package/dist/plugins/util/CodeTransformation.js +0 -624
  201. package/dist/plugins/util/CodeTransformation.js.map +0 -1
  202. package/dist/plugins/util/ObjectLiteral.d.ts +0 -9
  203. package/dist/plugins/util/ObjectLiteral.js +0 -37
  204. package/dist/plugins/util/ObjectLiteral.js.map +0 -1
  205. package/dist/plugins/util/index.d.ts +0 -3
  206. package/dist/plugins/util/index.js +0 -20
  207. package/dist/plugins/util/index.js.map +0 -1
  208. package/dist/util/Debug.d.ts +0 -4
  209. package/dist/util/Debug.js +0 -20
  210. package/dist/util/Debug.js.map +0 -1
  211. package/dist/util/Directive.d.ts +0 -16
  212. package/dist/util/Directive.js +0 -107
  213. package/dist/util/Directive.js.map +0 -1
  214. package/dist/util/RuntimeTableSchema.d.ts +0 -5
  215. package/dist/util/RuntimeTableSchema.js +0 -58
  216. package/dist/util/RuntimeTableSchema.js.map +0 -1
  217. package/dist/util/Scope.js.map +0 -1
  218. package/dist/util/Util.d.ts +0 -1
  219. package/dist/util/Util.js +0 -12
  220. package/dist/util/Util.js.map +0 -1
  221. package/dist/util/XMLUploadParser.d.ts +0 -22
  222. package/dist/util/XMLUploadParser.js +0 -67
  223. package/dist/util/XMLUploadParser.js.map +0 -1
  224. package/src/IncludePaths.ts +0 -122
  225. package/src/Keys.ts +0 -274
  226. package/src/TypeScript.ts +0 -65
  227. package/src/XML.ts +0 -98
  228. package/src/plugins/Context.ts +0 -239
  229. package/src/plugins/Plugin.ts +0 -278
  230. package/src/plugins/behaviors/Arranger.ts +0 -42
  231. package/src/plugins/behaviors/Composer.ts +0 -125
  232. package/src/plugins/behaviors/Diagnostics.ts +0 -12
  233. package/src/plugins/behaviors/Generator.ts +0 -31
  234. package/src/plugins/behaviors/OwnedTables.ts +0 -5
  235. package/src/plugins/behaviors/PostProcessor.ts +0 -6
  236. package/src/plugins/behaviors/Serializer.ts +0 -40
  237. package/src/plugins/behaviors/Transformer.ts +0 -32
  238. package/src/plugins/behaviors/extractors/Data.ts +0 -332
  239. package/src/plugins/behaviors/extractors/Extractors.ts +0 -73
  240. package/src/plugins/behaviors/extractors/index.ts +0 -2
  241. package/src/plugins/behaviors/index.ts +0 -9
  242. package/src/plugins/util/CallExpression.ts +0 -110
  243. package/src/plugins/util/CodeTransformation.ts +0 -731
  244. package/src/plugins/util/ObjectLiteral.ts +0 -37
  245. package/src/plugins/util/index.ts +0 -3
  246. package/src/util/Debug.ts +0 -24
  247. package/src/util/Directive.ts +0 -123
  248. package/src/util/RuntimeTableSchema.ts +0 -44
  249. package/src/util/Util.ts +0 -7
  250. package/src/util/XMLUploadParser.ts +0 -90
  251. /package/dist/util/{Scope.d.ts → is-sn-scope.d.ts} +0 -0
  252. /package/src/util/{Scope.ts → is-sn-scope.ts} +0 -0
@@ -1,278 +0,0 @@
1
- import { SupportedKindName } from '@servicenow/sdk-project'
2
- import {
3
- Extractors,
4
- Composers,
5
- Serializers,
6
- Transformers,
7
- Generators,
8
- Arrangers,
9
- PostProcessors,
10
- Diagnostics,
11
- TableOwnership,
12
- } from './behaviors'
13
-
14
- import type {
15
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
16
- EntityComposerFunction,
17
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
18
- XmlComposerFunction,
19
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
20
- ArrangerFunction,
21
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
22
- SerializerFunction,
23
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
- GeneratorFunction,
25
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
- TransformerFunction,
27
- } from './behaviors'
28
-
29
- /**
30
- * A plugin is an object that defines any number of behaviors that will
31
- * be invoked by the build system during various operations.
32
- *
33
- * The order of build operations during a normal build (code to XML) is
34
- * as follows:
35
- *
36
- * Extract -> Compose -> Arrange -> Serialize
37
- *
38
- * The order of build operations during a transform (XML to code, AKA
39
- * "bi-directional sync") is as follows:
40
- *
41
- * Extract -> Compose -> Arrange -> Generate -> Transform
42
- *
43
- * During each operation, all plugins which define behaviors for that
44
- * operation will be invoked. Therefore, plugins should always "fail
45
- * fast" to minimize performance impact. For example, if a plugin defines
46
- * an extractor for calls to a function named "exampleFunction", that
47
- * plugin should first validate the function name and return immediately
48
- * if the name is anything but "exampleFunction".
49
- *
50
- * @see {@linkcode Extractors}
51
- * @see {@linkcode Composers}
52
- * @see {@linkcode Arrangers}
53
- * @see {@linkcode Serializers}
54
- * @see {@linkcode Generators}
55
- * @see {@linkcode Transformers}
56
- */
57
- export type Plugin<
58
- DiagnosticsNodeKinds extends SupportedKindName | 'Node' = any,
59
- FluentRawNodeKinds extends SupportedKindName = any,
60
- ModuleRawNodeKinds extends SupportedKindName = any,
61
- JsonRawNodeKinds extends SupportedKindName = any,
62
- AnyRawNodeKinds extends SupportedKindName = any,
63
- FluentEntityNodeKinds extends SupportedKindName = any,
64
- ModuleEntityNodeKinds extends SupportedKindName = any,
65
- JsonEntityNodeKinds extends SupportedKindName = any,
66
- AnyEntityNodeKinds extends SupportedKindName = any,
67
- ArrangerDocumentKinds extends string = any,
68
- SerializerDocumentKinds extends string = any,
69
- GeneratorDocumentKinds extends string = any,
70
- TransformerDocumentKinds extends string = any,
71
- > = {
72
- /**
73
- * Name of the plugin
74
- */
75
- name: string
76
-
77
- diagnostics?: Diagnostics<DiagnosticsNodeKinds>
78
-
79
- /**
80
- * ServiceNow tables that this plugin handles and should not be serialized
81
- * by generic plugins, and the appropriate diagnostic level to enforce on
82
- * this relationship
83
- */
84
- ownedTables?: TableOwnership
85
-
86
- /**
87
- * Plugins may define extractors which extract raw data or entity data from
88
- * AST nodes, or XML data from parsed XML files. The build system will take
89
- * any entity data produced by an extractor and pass it along to any plugin
90
- * that implements a composer for that kind of entity.
91
- *
92
- * An extractors object is an object with any of the keys 'xml', 'raw', or
93
- * 'entity', where the values of those keys are nested objects where each
94
- * key is the name of a kind of AST node, and the value is one of the types
95
- * of extractor functions.
96
- *
97
- * @example
98
- * const extractors = {
99
- * entity: {
100
- * CallExpression(node, context) { ... }
101
- * ClassDeclaration(node, context) { ... }
102
- * }
103
- * }
104
- */
105
- extractors?: Extractors<
106
- FluentRawNodeKinds,
107
- ModuleRawNodeKinds,
108
- JsonRawNodeKinds,
109
- AnyRawNodeKinds,
110
- FluentEntityNodeKinds,
111
- ModuleEntityNodeKinds,
112
- JsonEntityNodeKinds,
113
- AnyEntityNodeKinds
114
- >
115
-
116
- /**
117
- * Plugins may define composers for both entity data (from the
118
- * source code) and XML data (from XML files). The job of a
119
- * composer is to turn a piece of extracted data into one or more
120
- * documents which can then be serialized or transformed.
121
- *
122
- * A composers object that has two optional keys: 'entity' and 'xml'. The
123
- * value of the 'xml' key is a {@linkcode XmlComposerFunction}. The value of
124
- * the 'entity' key is another object where each key is the name of a kind
125
- * of entity, and the value is a {@linkcode EntityComposerFunction}.
126
- *
127
- * @example
128
- * const composers = {
129
- * entity: {
130
- * MyFirstEntity(data, context) { ... }
131
- * MyOtherEntity(data, context) { ... }
132
- * },
133
- * xml: {
134
- * record(data, context) { ... }
135
- * }
136
- * }
137
- */
138
- composers?: Composers
139
-
140
- /**
141
- * Plugins may define arrangers which take documents and return their parents
142
- * so that the build system can arrange them in a tree structure.
143
- *
144
- * An arrangers object is an object where each key is the name of a kind of
145
- * document, and the value is a {@linkcode ArrangerFunction}.
146
- *
147
- * @example
148
- * const arrangers = {
149
- * MyFirstDocument(document, context) { ... },
150
- * MyOtherDocument(document, context) { ... }
151
- * }
152
- */
153
- arrangers?: Arrangers<ArrangerDocumentKinds>
154
-
155
- /**
156
- * Plugins may define serializers which turn documents into files which the
157
- * build system will write to the filesystem as output.
158
- *
159
- * A serializers object is an object where each key is the name of a kind of
160
- * document, and the value is a {@linkcode SerializerFunction}.
161
- *
162
- * @example
163
- * const serializers = {
164
- * MyFirstDocument(document, context) { ... },
165
- * MyOtherDocument(document, context) { ... }
166
- * }
167
- */
168
- serializers?: Serializers<SerializerDocumentKinds>
169
-
170
- /**
171
- * Plugins may define generators which create new nodes for documents that
172
- * don't have nodes, usually because they were extracted from XML files and
173
- * aren't defined yet in the source code. The build system will pass each
174
- * document without a node to any plugin which implements a generator for
175
- * that kind of document. These documents are then passed along to the
176
- * transformers along with all the other documents which already had nodes.
177
- *
178
- * A generators object is an object where each key is the name of a kind of
179
- * document, and the value is a {@linkcode GeneratorFunction}.
180
- *
181
- * @example
182
- * const generators = {
183
- * MyFirstDocument(document, context) { ... },
184
- * MyOtherDocument(document, context) { ... }
185
- * }
186
- */
187
- generators?: Generators<GeneratorDocumentKinds>
188
-
189
- /**
190
- * Plugins may define transformers which take linked documents and perform
191
- * transformations on their linked nodes to ensure each document is fully
192
- * represented in the source code.
193
- *
194
- * A transformers object is an object where each key is the name of a kind of
195
- * document, and the value is another object where each key is the name of a
196
- * kind of AST node, and the value is a {@linkcode TransformerFunction}.
197
- *
198
- * @example
199
- * const transformers = {
200
- * MyFirstDocument: {
201
- * CallExpression(document, context) { ... },
202
- * ClassDeclaration(document, context) { ... }
203
- * },
204
- * MyOtherDocument: {
205
- * CallExpression(document, context) { ... },
206
- * ClassDeclaration(document, context) { ... }
207
- * }
208
- * }
209
- */
210
- transformers?: Transformers<TransformerDocumentKinds>
211
-
212
- /**
213
- * Plugins may define post-processors for data from certain stages of the build
214
- * process. For example, a post-processor for entities will be called after the
215
- * extraction stage and will receive all entities extracted by all plugins.
216
- * These can be used for arbitrary operations based on extracted data.
217
- *
218
- * @example
219
- * const postProcessors = {
220
- * entities(entities, context) { ... }
221
- * }
222
- */
223
- postProcessors?: PostProcessors
224
- }
225
-
226
- /**
227
- * Utility function to create a new {@linkcode Plugin} object. Provides
228
- * the simplest and most type-safe experience for defining a plugin, but
229
- * is not required.
230
- *
231
- * @param plugin The {@linkcode Plugin} configuration
232
- * @returns a {@linkcode Plugin} object
233
- */
234
- export function Plugin<
235
- const DiagnosticsNodeKinds extends SupportedKindName | 'Node',
236
- const FluentRawNodeKinds extends SupportedKindName,
237
- const ModuleRawNodeKinds extends SupportedKindName,
238
- const JsonRawNodeKinds extends SupportedKindName,
239
- const AnyRawNodeKinds extends SupportedKindName,
240
- const FluentEntityNodeKinds extends SupportedKindName,
241
- const ModuleEntityNodeKinds extends SupportedKindName,
242
- const JsonEntityNodeKinds extends SupportedKindName,
243
- const AnyEntityNodeKinds extends SupportedKindName,
244
- const SerializerDocumentKinds extends string,
245
- const GeneratorDocumentKinds extends string,
246
- const TransformerDocumentKinds extends string,
247
- const P extends Plugin<
248
- DiagnosticsNodeKinds,
249
- FluentRawNodeKinds,
250
- ModuleRawNodeKinds,
251
- JsonRawNodeKinds,
252
- AnyRawNodeKinds,
253
- FluentEntityNodeKinds,
254
- ModuleEntityNodeKinds,
255
- JsonEntityNodeKinds,
256
- AnyEntityNodeKinds,
257
- SerializerDocumentKinds,
258
- GeneratorDocumentKinds,
259
- TransformerDocumentKinds
260
- >,
261
- >(
262
- plugin: P &
263
- Plugin<
264
- DiagnosticsNodeKinds,
265
- FluentRawNodeKinds,
266
- ModuleRawNodeKinds,
267
- JsonRawNodeKinds,
268
- AnyRawNodeKinds,
269
- FluentEntityNodeKinds,
270
- ModuleEntityNodeKinds,
271
- JsonEntityNodeKinds,
272
- AnyEntityNodeKinds,
273
- GeneratorDocumentKinds,
274
- TransformerDocumentKinds
275
- >
276
- ) {
277
- return plugin as P
278
- }
@@ -1,42 +0,0 @@
1
- import { Document, DocumentPointer, LinkedDocument } from './Composer'
2
- import { Context } from '../Context'
3
-
4
- export type Arranged<Status extends 'unresolved' | 'resolved' = 'resolved'> = {
5
- parent?: Status extends 'unresolved' ? DocumentPointer & Arranged<'unresolved'> : LinkedDocument & Arranged // Parent is always linked because document trees are processed from top to bottom
6
- }
7
-
8
- // TODO: Use this return type for all behaviors. It solves the ambiguity
9
- // between `undefined` as a valid return value and `undefined` as an indicator
10
- // that the input was not handled.
11
- export type Result<T> =
12
- | {
13
- handled: false
14
- result?: never
15
- }
16
- | {
17
- handled: true
18
- result: T
19
- }
20
-
21
- /**
22
- * An arranger function is a function which accepts a document of a known
23
- * kind as input and returns a pointer to its parent, if applicable.
24
- *
25
- * @see {@linkcode Document}
26
- * @see {@linkcode DocumentPointer}
27
- */
28
- export type ArrangerFunction<DocumentKind extends string = string> = (
29
- document: Document<DocumentKind>,
30
- context: Context
31
- ) => Result<DocumentPointer | undefined>
32
-
33
- // This is only imported so it can be referenced in the JS doc below
34
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
35
- import type { Plugin } from '../Plugin'
36
-
37
- /**
38
- * @see {@linkcode Plugin#arrangers}
39
- */
40
- export type Arrangers<DocumentKinds extends string = string> = {
41
- [K in DocumentKinds]: ArrangerFunction<K>
42
- }
@@ -1,125 +0,0 @@
1
- import { SupportedNode } from '@servicenow/sdk-project'
2
- import { XmlData, PrimitiveData, Action, EntityData } from './extractors'
3
- import { Context } from '../Context'
4
-
5
- /**
6
- * An unlinked document is a document that does not have an
7
- * association with any AST node.
8
- *
9
- * @see {@linkcode Document}
10
- */
11
- export type UnlinkedDocument<DocumentKind extends string = string> = Omit<Document<DocumentKind>, 'node'>
12
-
13
- /**
14
- * A linked document is a document that has an association
15
- * with an AST node.
16
- *
17
- * @see {@linkcode Document}
18
- */
19
- export type LinkedDocument<DocumentKind extends string = string, Node extends SupportedNode = SupportedNode> = Document<
20
- DocumentKind,
21
- Node
22
- > & {
23
- entity?: EntityData
24
- node: Node
25
- }
26
-
27
- /**
28
- * A document is a data structure that has a known kind, an ID,
29
- * and an action (insert/update or delete). It may also have an
30
- * associated AST node if the data originated from source code.
31
- *
32
- * @see {@linkcode LinkedDocument}
33
- * @see {@linkcode UnlinkedDocument}
34
- */
35
- export type Document<DocumentKind extends string = string, Node extends SupportedNode = SupportedNode> = {
36
- guid: string
37
- kind: DocumentKind
38
- data: unknown
39
- changedData?: unknown
40
- xmlFilePath?: string
41
- xmlData?: unknown
42
- node?: Node
43
- action?: Action
44
- }
45
-
46
- /**
47
- * A document pointer is an object that represents a document
48
- * via its ID and kind. Document pointers can be resolved to
49
- * actual documents after all documents have been composed.
50
- *
51
- * @see {@linkcode Document}
52
- */
53
- export type DocumentPointer<DocumentKind extends string = string> = {
54
- guid: string
55
- kind: DocumentKind
56
- }
57
-
58
- /**
59
- * A document map is an object where documents are accessible
60
- * by their kind and ID. The keys of the object are document
61
- * kinds, and the values are sub-objects where the keys are
62
- * document IDs and the values are the corresponding documents.
63
- *
64
- * @see {@linkcode Document}
65
- */
66
- export type DocumentMap<D extends Document = Document> = {
67
- [kinds: string]: {
68
- [guids: string]: D
69
- }
70
- }
71
-
72
- /**
73
- * An entity composer function is a function that accepts a
74
- * piece of entity data from the source code and returns one
75
- * or more linked documents derived from that entity, or returns
76
- * undefined to indicate that it did not handle the data.
77
- *
78
- * @see {@linkcode Entity}
79
- * @see {@linkcode EntityData}
80
- */
81
- export type EntityComposerFunction<Data extends Record<string, unknown> = Record<string, unknown>> = (
82
- entityData: EntityData<Data>,
83
- context: Context
84
- ) => Promise<LinkedDocument | LinkedDocument[] | undefined>
85
-
86
- /**
87
- * An XML composer function is a function that accepts a piece
88
- * of data from an XML file and returns one or more unlinked
89
- * documents derived from that data, or returns undefined to
90
- * indicate that it did not handle the data.
91
- *
92
- * @see {@linkcode PrimitiveData}
93
- * @see {@linkcode XmlData}
94
- */
95
- export type XmlComposerFunction<Data extends PrimitiveData = PrimitiveData> = (
96
- xmlData: XmlData<Data>,
97
- context: Context
98
- ) => UnlinkedDocument | UnlinkedDocument[] | undefined
99
-
100
- // This is only imported so it can be referenced in the JS doc below
101
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
102
- import type { Plugin } from '../Plugin'
103
-
104
- /**
105
- * @see {@linkcode Plugin#composers}
106
- */
107
- export type Composers = {
108
- entity?: { [kind: string]: EntityComposerFunction }
109
- xml?: { [kind: string]: XmlComposerFunction }
110
- }
111
-
112
- /**
113
- * Utility which takes an unlinked document and a node and returns the
114
- * same document linked to the provided node.
115
- *
116
- * @param document The {@linkcode UnlinkedDocument} to link
117
- * @param node The AST node to link the document to
118
- * @returns A {@linkcode LinkedDocument}
119
- */
120
- export function linkDocument<const K extends string, const N extends SupportedNode>(
121
- document: UnlinkedDocument<K>,
122
- node: N
123
- ): LinkedDocument<K, N> {
124
- return { ...document, node }
125
- }
@@ -1,12 +0,0 @@
1
- import { SupportedKindName, SupportedNodeByKindName, ts } from '@servicenow/sdk-project'
2
- import { Context } from '../Context'
3
- import { FluentDiagnostic } from '../Diagnostic'
4
-
5
- export type DiagnosticsFunction<K extends SupportedKindName | 'Node' = SupportedKindName> = (
6
- node: K extends SupportedKindName ? SupportedNodeByKindName<K> : K extends 'Node' ? ts.Node : any,
7
- context: Context
8
- ) => FluentDiagnostic[]
9
-
10
- export type Diagnostics<NodeKinds extends SupportedKindName | 'Node'> = {
11
- [K in NodeKinds]: DiagnosticsFunction<K>
12
- }
@@ -1,31 +0,0 @@
1
- import { LinkedDocument, UnlinkedDocument } from './Composer'
2
- import { Arranged } from './Arranger'
3
- import { Context } from '../Context'
4
-
5
- /**
6
- * A generator function is a function that accepts an unlinked document of
7
- * a known kind as input and returns the same document as a linked document.
8
- * In practice, this means the generator's job is to create new AST nodes
9
- * for documents that are not linked to any node. Documents without nodes
10
- * are usually from XML files containing records that aren't defined in the
11
- * source code yet.
12
- *
13
- * @see {@linkcode UnlinkedDocument}
14
- * @see {@linkcode LinkedDocument}
15
- */
16
- export type GeneratorFunction<DocumentKind extends string = string> = (
17
- document: UnlinkedDocument<DocumentKind> & Arranged,
18
- context: Context,
19
- linkedDocuments: LinkedDocument[]
20
- ) => LinkedDocument<DocumentKind> | undefined
21
-
22
- // This is only imported so it can be referenced in the JS doc below
23
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
24
- import type { Plugin } from '../Plugin'
25
-
26
- /**
27
- * @see {@linkcode Plugin#generators}
28
- */
29
- export type Generators<DocumentKinds extends string = string> = {
30
- [K in DocumentKinds]: GeneratorFunction<K>
31
- }
@@ -1,5 +0,0 @@
1
- import { Diagnostic } from '@servicenow/sdk-project'
2
-
3
- export type TableOwnership = {
4
- [table: string]: { diagnosticLevel: Diagnostic.Level }
5
- }
@@ -1,6 +0,0 @@
1
- import { Context } from '../Context'
2
- import { EntityData } from './extractors'
3
-
4
- export type PostProcessors = {
5
- entities?: (entities: EntityData[], context: Context) => void
6
- }
@@ -1,40 +0,0 @@
1
- import { Document } from './Composer'
2
- import { Arranged } from './Arranger'
3
- import { Context } from '../Context'
4
-
5
- /**
6
- * A file is a data structure with a name, a target directory, and content
7
- * as a string. The target directory must be the name of one of the magic
8
- * directories that exist within a ServiceNow installable app package.
9
- */
10
- export type File = {
11
- name: `${string}.xml`
12
- directory: Directories
13
- content: string
14
- }
15
- export type Directories = 'dictionary' | 'unload' | 'unload.demo' | 'update' | 'apply_once' | 'scope' | ''
16
-
17
- /**
18
- * A serializer function is a function which accepts a document of a known
19
- * kind as input and returns one or more files derived from that document,
20
- * or returns undefined to indicate it did not handle the document. In practice,
21
- * this means generating the XML content that the build system will write to
22
- * the filesystem during the final stages of a build.
23
- *
24
- * @see {@linkcode Document}
25
- */
26
- export type SerializerFunction<DocumentKind extends string = string> = (
27
- document: Document<DocumentKind> & Arranged,
28
- context: Context
29
- ) => File | File[] | undefined
30
-
31
- // This is only imported so it can be referenced in the JS doc below
32
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
33
- import type { Plugin } from '../Plugin'
34
-
35
- /**
36
- * @see {@linkcode Plugin#serializers}
37
- */
38
- export type Serializers<DocumentKinds extends string = string> = {
39
- [K in DocumentKinds]: SerializerFunction<K>
40
- }
@@ -1,32 +0,0 @@
1
- import { SupportedKindName, SupportedNode, SupportedNodeByKindName } from '@servicenow/sdk-project'
2
- import { LinkedDocument } from './Composer'
3
- import { Arranged } from './Arranger'
4
- import { Context } from '../Context'
5
-
6
- /**
7
- * A transformer function is a function which accepts a linked document of
8
- * a known kind as input and returns a boolean indicating whether or not it
9
- * handled the document. The implementation of a transformer function, if it
10
- * chooses to handle the document, should perform the necessary transformations
11
- * on the document's linked node to ensure the document's data is fully
12
- * represented in the source code.
13
- *
14
- * @see {@linkcode LinkedDocument}
15
- */
16
- export type TransformerFunction<DocumentKind extends string = string, Node extends SupportedNode = SupportedNode> = (
17
- document: LinkedDocument<DocumentKind, Node> & Arranged,
18
- context: Context
19
- ) => boolean
20
-
21
- // This is only imported so it can be referenced in the JS doc below
22
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
- import type { Plugin } from '../Plugin'
24
-
25
- /**
26
- * @see {@linkcode Plugin#transformers}
27
- */
28
- export type Transformers<DocumentKinds extends string = string> = {
29
- [DK in DocumentKinds]: {
30
- [NK in SupportedKindName]?: TransformerFunction<DK, SupportedNodeByKindName<NK>>
31
- }
32
- }