@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,190 +0,0 @@
1
- import { Document, File, LinkedDocument, UnlinkedDocument, Xml, XmlData, EntityData, Arranged, DocumentMap, ExtractionResult } from './behaviors';
2
- import { Keys } from '../Keys';
3
- import { Plugin } from './Plugin';
4
- import { FluentDiagnostic } from './Diagnostic';
5
- import { ProjectContext, SupportedNode, ts, type Diagnostic } from '@servicenow/sdk-project';
6
- import type { Data } from './behaviors';
7
- /**
8
- * The context object is a collection of contextual information and methods
9
- * passed into all the various behaviors of a plugin when those behaviors are
10
- * invoked. It is also used by the build system to orchestrate the build.
11
- *
12
- * Each behavioral method on the context can accept an array of plugins as
13
- * an argument to control which plugins are used for that request. If no
14
- * plugins are provided as input, all available plugins will be used.
15
- */
16
- export type Context = ProjectContext & {
17
- /**
18
- * Accepts a parsed XML object and returns an array of {@linkcode XmlData}
19
- * extracted from that object.
20
- *
21
- * @see {@linkcode Extractors}
22
- * @param xml The parsed XML to extract.
23
- * @param plugins An optional array of {@linkcode Plugin}s to use.
24
- * @returns an array of extracted data.
25
- */
26
- extractXml(this: Context, xml: Xml, plugins?: Plugin[]): XmlData[];
27
- /**
28
- * Accepts an AST node and returns a result containing an array of
29
- * {@linkcode RawData} or {@linkcode EntityData} extracted from that node.
30
- *
31
- * @see {@linkcode Extractors}
32
- * @param node The node to extract.
33
- * @param plugins An optional array of {@linkcode Plugin}s to use.
34
- * @returns a result object containing an array of extracted data.
35
- */
36
- extractAst(this: Context, node: ts.Node, plugins?: Plugin[]): ExtractionResult;
37
- /**
38
- * Accepts an AST node and returns a result containing an array of
39
- * {@linkcode RawData} extracted from that node.
40
- *
41
- * @see {@linkcode Extractors}
42
- * @param node The node to extract.
43
- * @param plugins An optional array of {@linkcode Plugin}s to use.
44
- * @returns a result object containing an array of extracted data.
45
- */
46
- extractRaw(this: Context, node: ts.Node, plugins?: Plugin[]): ExtractionResult<Data>;
47
- /**
48
- * Accepts an AST node and returns a result containing an array of
49
- * {@linkcode EntityData} extracted from that node.
50
- *
51
- * @see {@linkcode Extractors}
52
- * @param node The node to extract.
53
- * @param plugins An optional array of {@linkcode Plugin}s to use.
54
- * @returns a result object containing an array of extracted entities.
55
- */
56
- extractEntities(this: Context, node: ts.Node, plugins?: Plugin[]): ExtractionResult<EntityData>;
57
- /**
58
- * Accepts an array of entity data and returns a {@linkcode LinkedDocument}
59
- * array.
60
- *
61
- * @see {@linkcode Composers}
62
- * @param data The {@linkcode EntityData} to compose.
63
- * @param plugins An optional array of {@linkcode Plugin}s to use.
64
- * @returns a {@linkcode LinkedDocument} array.
65
- */
66
- composeEntities(this: Context, data: EntityData[], plugins?: Plugin[]): Promise<LinkedDocument[]>;
67
- /**
68
- * Accepts an array of XML data and returns an {@linkcode UnlinkedDocument}
69
- * array.
70
- *
71
- * @see {@linkcode Composers}
72
- * @param data The {@linkcode XmlData} to compose.
73
- * @param context The {@linkcode Context} object.
74
- * @param plugins An optional array of {@linkcode Plugin}s to use.
75
- * @returns an {@linkcode UnlinkedDocument} array.
76
- */
77
- composeXml(this: Context, data: XmlData[], plugins?: Plugin[]): UnlinkedDocument[];
78
- /**
79
- * Accepts an array of documents and returns the same documents
80
- * as unresolved arranged documents.
81
- *
82
- * @see {@linkcode Arrangers}
83
- * @param documents The {@linkcode Document}s to arrange.
84
- * @param plugins An optional array of {@linkcode Plugin}s to use.
85
- * @returns a {@linkcode Document} & {@linkcode Arranged} array.
86
- */
87
- arrange<D extends Document>(this: Context, documents: D[], plugins?: Plugin[]): (D & Arranged<'unresolved'>)[];
88
- /**
89
- * Accepts an array of documents and returns an array of files.
90
- *
91
- * @see {@linkcode Serializers}
92
- * @param documents The {@linkcode Document}s to serialize.
93
- * @param plugins An optional array of {@linkcode Plugin}s to use.
94
- * @returns a {@linkcode File} array.
95
- */
96
- serialize(this: Context, documents: (Document & Arranged)[], plugins?: Plugin[]): File[];
97
- /**
98
- * Accepts an array of documents, generates new AST nodes for those
99
- * documents, and returns the same documents as linked documents.
100
- *
101
- * @see {@linkcode Generators}
102
- * @param documents The {@linkcode Document}s to generate AST nodes for.
103
- * @param plugins An optional array of {@linkcode Plugin}s to use.
104
- * @returns a {@linkcode LinkedDocument} array.
105
- */
106
- generate(this: Context, documents: (UnlinkedDocument & Arranged)[], plugins?: Plugin[]): LinkedDocument[];
107
- /**
108
- * Accepts an array of linked documents and performs transformations on
109
- * their original nodes to reflect any changes that may have been made to
110
- * those documents' data.
111
- *
112
- * @see {@linkcode Transformers}
113
- * @param documents The {@linkcode LinkedDocument}s to transform.
114
- * @param plugins An optional array of {@linkcode Plugin}s to use.
115
- */
116
- transform(this: Context, documents: (LinkedDocument & Arranged)[], plugins?: Plugin[]): void;
117
- /**
118
- * Accepts an array of extracted entities and runs post-processors on that
119
- * data. Post-processors may perform a variety of arbitrary operations.
120
- *
121
- * @see {@linkcode PostProcessors}
122
- * @param data The {@linkcode EntityData} to process.
123
- * @param plugins An optional array of {@linkcode Plugin}s to use.
124
- */
125
- postProcessEntities(this: Context, data: EntityData[], plugins?: Plugin[]): void;
126
- /**
127
- * Accepts an AST node and returns an array of {@linkcode FluentDiagnostic}s
128
- * for that node.
129
- *
130
- * @see {@linkcode Diagnostics}
131
- * @param node The node to get diagnostics for.
132
- * @param plugins An optional array of {@linkcode Plugin}s to use.
133
- * @returns an array of diagnostics.
134
- */
135
- getAstDiagnostics(this: Context, node: ts.Node, plugins?: Plugin[]): FluentDiagnostic[];
136
- /**
137
- * An object with metadata related to plugin like list of all tables that are claimed to be handled by a specific plugin, and
138
- * the level of enforcement they apply to that table
139
- * and API that the plugin is responsible for.
140
- */
141
- getPluginForTable(table: string): {
142
- logLevel: Diagnostic.Level;
143
- api: string;
144
- } | undefined;
145
- /**
146
- * An array of plugins that will be used (unless overridden) during various
147
- * build process operations.
148
- *
149
- * @see {@link Plugin}
150
- */
151
- plugins: Plugin[];
152
- /**
153
- * An array of plugins which implement entity-handling behaviors which will
154
- * be used during various build process operations. These plugins are always
155
- * executed BEFORE the plugins in the {@link Context#plugins} array.
156
- *
157
- * @see {@link Plugin}
158
- */
159
- entityPlugins: Plugin[];
160
- usageCount: {
161
- [key: string]: number;
162
- };
163
- /**
164
- * Returns an object of XML file names that was marked as handled or ignored by code transformation during the build process.
165
- */
166
- getHandledXmls: () => Record<string, HandledInfo>;
167
- updateHandledXMLs: (xml: string | undefined, status: HandledStates, info?: string, node?: SupportedNode) => void;
168
- setAllDocuments: (documents: Document[]) => void;
169
- getAllDocuments: () => Document[];
170
- getDocumentMap: () => DocumentMap;
171
- getDocument: (sysId: string, kind?: string) => Document | undefined;
172
- argTypesToFix: ts.CallExpression[];
173
- fixTypeArguments: () => void;
174
- /**
175
- * @deprecated Use the key methods on the context object instead.
176
- */
177
- keys: Keys;
178
- explicitKeyExists: Keys['explicitKeyExists'];
179
- getIdUsingExplicitKey: Keys['getIdUsingExplicitKey'];
180
- registerExplicitId: Keys['registerExplicitId'];
181
- registerCompositeId: Keys['registerCompositeId'];
182
- getDeletedAndUnusedIds: Keys['getDeletedAndUnusedIds'];
183
- getKeysSourceFile(): ts.SourceFile;
184
- };
185
- export type HandledInfo = {
186
- state: HandledStates;
187
- info?: string | undefined;
188
- node?: SupportedNode | undefined;
189
- };
190
- export type HandledStates = 'handled' | 'handled as record' | 'ignored' | 'skipped' | 'unchanged';
@@ -1 +0,0 @@
1
- {"version":3,"file":"Context.js","sourceRoot":"","sources":["../../src/plugins/Context.ts"],"names":[],"mappings":""}
@@ -1,28 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FluentDiagnostic = void 0;
4
- exports.findObjectPropertyValue = findObjectPropertyValue;
5
- const sdk_project_1 = require("@servicenow/sdk-project");
6
- class FluentDiagnostic extends sdk_project_1.Diagnostic {
7
- constructor(node, message, { level = sdk_project_1.Diagnostic.Level.Error, code = node.getKind() } = {}) {
8
- super(message, node.getSourceFile(), { start: node.getStart(), end: node.getEnd() }, code, 'fluent', level);
9
- }
10
- asTypeScriptDiagnostic() {
11
- return {
12
- messageText: this.message,
13
- category: sdk_project_1.Diagnostic.Level.toCategory(this.level),
14
- code: this.code,
15
- file: this.file.compilerNode,
16
- start: this.position.start,
17
- length: this.position.end - this.position.start,
18
- };
19
- }
20
- }
21
- exports.FluentDiagnostic = FluentDiagnostic;
22
- function findObjectPropertyValue(callExpression, field) {
23
- const property = callExpression
24
- .getFirstDescendantByKind(sdk_project_1.ts.SyntaxKind.ObjectLiteralExpression)
25
- ?.getProperty(field);
26
- return property?.getInitializer() || callExpression;
27
- }
28
- //# sourceMappingURL=Diagnostic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Diagnostic.js","sourceRoot":"","sources":["../../src/plugins/Diagnostic.ts"],"names":[],"mappings":";;;AAuBA,0DAMC;AA7BD,yDAA6D;AAE7D,MAAa,gBAAiB,SAAQ,wBAAU;IAC5C,YACI,IAAa,EACb,OAAe,EACf,EAAE,KAAK,GAAG,wBAAU,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,KAAkD,EAAE;QAE3G,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,EAAE,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,CAAC,CAAA;IAC/G,CAAC;IAEe,sBAAsB;QAClC,OAAO;YACH,WAAW,EAAE,IAAI,CAAC,OAAO;YACzB,QAAQ,EAAE,wBAAU,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC;YACjD,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY;YAC5B,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,KAAK;YAC1B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK;SAClD,CAAA;IACL,CAAC;CACJ;AAnBD,4CAmBC;AAED,SAAgB,uBAAuB,CAAC,cAAiC,EAAE,KAAa;IACpF,MAAM,QAAQ,GAAG,cAAc;SAC1B,wBAAwB,CAAC,gBAAE,CAAC,UAAU,CAAC,uBAAuB,CAAC;QAChE,EAAE,WAAW,CAAC,KAAK,CAA0B,CAAA;IAEjD,OAAO,QAAQ,EAAE,cAAc,EAAE,IAAI,cAAc,CAAA;AACvD,CAAC"}
@@ -1,175 +0,0 @@
1
- import { SupportedKindName } from '@servicenow/sdk-project';
2
- import { Extractors, Composers, Serializers, Transformers, Generators, Arrangers, PostProcessors, Diagnostics, TableOwnership } from './behaviors';
3
- /**
4
- * A plugin is an object that defines any number of behaviors that will
5
- * be invoked by the build system during various operations.
6
- *
7
- * The order of build operations during a normal build (code to XML) is
8
- * as follows:
9
- *
10
- * Extract -> Compose -> Arrange -> Serialize
11
- *
12
- * The order of build operations during a transform (XML to code, AKA
13
- * "bi-directional sync") is as follows:
14
- *
15
- * Extract -> Compose -> Arrange -> Generate -> Transform
16
- *
17
- * During each operation, all plugins which define behaviors for that
18
- * operation will be invoked. Therefore, plugins should always "fail
19
- * fast" to minimize performance impact. For example, if a plugin defines
20
- * an extractor for calls to a function named "exampleFunction", that
21
- * plugin should first validate the function name and return immediately
22
- * if the name is anything but "exampleFunction".
23
- *
24
- * @see {@linkcode Extractors}
25
- * @see {@linkcode Composers}
26
- * @see {@linkcode Arrangers}
27
- * @see {@linkcode Serializers}
28
- * @see {@linkcode Generators}
29
- * @see {@linkcode Transformers}
30
- */
31
- export type Plugin<DiagnosticsNodeKinds extends SupportedKindName | 'Node' = any, FluentRawNodeKinds extends SupportedKindName = any, ModuleRawNodeKinds extends SupportedKindName = any, JsonRawNodeKinds extends SupportedKindName = any, AnyRawNodeKinds extends SupportedKindName = any, FluentEntityNodeKinds extends SupportedKindName = any, ModuleEntityNodeKinds extends SupportedKindName = any, JsonEntityNodeKinds extends SupportedKindName = any, AnyEntityNodeKinds extends SupportedKindName = any, ArrangerDocumentKinds extends string = any, SerializerDocumentKinds extends string = any, GeneratorDocumentKinds extends string = any, TransformerDocumentKinds extends string = any> = {
32
- /**
33
- * Name of the plugin
34
- */
35
- name: string;
36
- diagnostics?: Diagnostics<DiagnosticsNodeKinds>;
37
- /**
38
- * ServiceNow tables that this plugin handles and should not be serialized
39
- * by generic plugins, and the appropriate diagnostic level to enforce on
40
- * this relationship
41
- */
42
- ownedTables?: TableOwnership;
43
- /**
44
- * Plugins may define extractors which extract raw data or entity data from
45
- * AST nodes, or XML data from parsed XML files. The build system will take
46
- * any entity data produced by an extractor and pass it along to any plugin
47
- * that implements a composer for that kind of entity.
48
- *
49
- * An extractors object is an object with any of the keys 'xml', 'raw', or
50
- * 'entity', where the values of those keys are nested objects where each
51
- * key is the name of a kind of AST node, and the value is one of the types
52
- * of extractor functions.
53
- *
54
- * @example
55
- * const extractors = {
56
- * entity: {
57
- * CallExpression(node, context) { ... }
58
- * ClassDeclaration(node, context) { ... }
59
- * }
60
- * }
61
- */
62
- extractors?: Extractors<FluentRawNodeKinds, ModuleRawNodeKinds, JsonRawNodeKinds, AnyRawNodeKinds, FluentEntityNodeKinds, ModuleEntityNodeKinds, JsonEntityNodeKinds, AnyEntityNodeKinds>;
63
- /**
64
- * Plugins may define composers for both entity data (from the
65
- * source code) and XML data (from XML files). The job of a
66
- * composer is to turn a piece of extracted data into one or more
67
- * documents which can then be serialized or transformed.
68
- *
69
- * A composers object that has two optional keys: 'entity' and 'xml'. The
70
- * value of the 'xml' key is a {@linkcode XmlComposerFunction}. The value of
71
- * the 'entity' key is another object where each key is the name of a kind
72
- * of entity, and the value is a {@linkcode EntityComposerFunction}.
73
- *
74
- * @example
75
- * const composers = {
76
- * entity: {
77
- * MyFirstEntity(data, context) { ... }
78
- * MyOtherEntity(data, context) { ... }
79
- * },
80
- * xml: {
81
- * record(data, context) { ... }
82
- * }
83
- * }
84
- */
85
- composers?: Composers;
86
- /**
87
- * Plugins may define arrangers which take documents and return their parents
88
- * so that the build system can arrange them in a tree structure.
89
- *
90
- * An arrangers object is an object where each key is the name of a kind of
91
- * document, and the value is a {@linkcode ArrangerFunction}.
92
- *
93
- * @example
94
- * const arrangers = {
95
- * MyFirstDocument(document, context) { ... },
96
- * MyOtherDocument(document, context) { ... }
97
- * }
98
- */
99
- arrangers?: Arrangers<ArrangerDocumentKinds>;
100
- /**
101
- * Plugins may define serializers which turn documents into files which the
102
- * build system will write to the filesystem as output.
103
- *
104
- * A serializers object is an object where each key is the name of a kind of
105
- * document, and the value is a {@linkcode SerializerFunction}.
106
- *
107
- * @example
108
- * const serializers = {
109
- * MyFirstDocument(document, context) { ... },
110
- * MyOtherDocument(document, context) { ... }
111
- * }
112
- */
113
- serializers?: Serializers<SerializerDocumentKinds>;
114
- /**
115
- * Plugins may define generators which create new nodes for documents that
116
- * don't have nodes, usually because they were extracted from XML files and
117
- * aren't defined yet in the source code. The build system will pass each
118
- * document without a node to any plugin which implements a generator for
119
- * that kind of document. These documents are then passed along to the
120
- * transformers along with all the other documents which already had nodes.
121
- *
122
- * A generators object is an object where each key is the name of a kind of
123
- * document, and the value is a {@linkcode GeneratorFunction}.
124
- *
125
- * @example
126
- * const generators = {
127
- * MyFirstDocument(document, context) { ... },
128
- * MyOtherDocument(document, context) { ... }
129
- * }
130
- */
131
- generators?: Generators<GeneratorDocumentKinds>;
132
- /**
133
- * Plugins may define transformers which take linked documents and perform
134
- * transformations on their linked nodes to ensure each document is fully
135
- * represented in the source code.
136
- *
137
- * A transformers object is an object where each key is the name of a kind of
138
- * document, and the value is another object where each key is the name of a
139
- * kind of AST node, and the value is a {@linkcode TransformerFunction}.
140
- *
141
- * @example
142
- * const transformers = {
143
- * MyFirstDocument: {
144
- * CallExpression(document, context) { ... },
145
- * ClassDeclaration(document, context) { ... }
146
- * },
147
- * MyOtherDocument: {
148
- * CallExpression(document, context) { ... },
149
- * ClassDeclaration(document, context) { ... }
150
- * }
151
- * }
152
- */
153
- transformers?: Transformers<TransformerDocumentKinds>;
154
- /**
155
- * Plugins may define post-processors for data from certain stages of the build
156
- * process. For example, a post-processor for entities will be called after the
157
- * extraction stage and will receive all entities extracted by all plugins.
158
- * These can be used for arbitrary operations based on extracted data.
159
- *
160
- * @example
161
- * const postProcessors = {
162
- * entities(entities, context) { ... }
163
- * }
164
- */
165
- postProcessors?: PostProcessors;
166
- };
167
- /**
168
- * Utility function to create a new {@linkcode Plugin} object. Provides
169
- * the simplest and most type-safe experience for defining a plugin, but
170
- * is not required.
171
- *
172
- * @param plugin The {@linkcode Plugin} configuration
173
- * @returns a {@linkcode Plugin} object
174
- */
175
- export declare function Plugin<const DiagnosticsNodeKinds extends SupportedKindName | 'Node', const FluentRawNodeKinds extends SupportedKindName, const ModuleRawNodeKinds extends SupportedKindName, const JsonRawNodeKinds extends SupportedKindName, const AnyRawNodeKinds extends SupportedKindName, const FluentEntityNodeKinds extends SupportedKindName, const ModuleEntityNodeKinds extends SupportedKindName, const JsonEntityNodeKinds extends SupportedKindName, const AnyEntityNodeKinds extends SupportedKindName, const SerializerDocumentKinds extends string, const GeneratorDocumentKinds extends string, const TransformerDocumentKinds extends string, const P extends Plugin<DiagnosticsNodeKinds, FluentRawNodeKinds, ModuleRawNodeKinds, JsonRawNodeKinds, AnyRawNodeKinds, FluentEntityNodeKinds, ModuleEntityNodeKinds, JsonEntityNodeKinds, AnyEntityNodeKinds, SerializerDocumentKinds, GeneratorDocumentKinds, TransformerDocumentKinds>>(plugin: P & Plugin<DiagnosticsNodeKinds, FluentRawNodeKinds, ModuleRawNodeKinds, JsonRawNodeKinds, AnyRawNodeKinds, FluentEntityNodeKinds, ModuleEntityNodeKinds, JsonEntityNodeKinds, AnyEntityNodeKinds, GeneratorDocumentKinds, TransformerDocumentKinds>): P;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Plugin = Plugin;
4
- /**
5
- * Utility function to create a new {@linkcode Plugin} object. Provides
6
- * the simplest and most type-safe experience for defining a plugin, but
7
- * is not required.
8
- *
9
- * @param plugin The {@linkcode Plugin} configuration
10
- * @returns a {@linkcode Plugin} object
11
- */
12
- function Plugin(plugin) {
13
- return plugin;
14
- }
15
- //# sourceMappingURL=Plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Plugin.js","sourceRoot":"","sources":["../../src/plugins/Plugin.ts"],"names":[],"mappings":";;AAyOA,wBA4CC;AApDD;;;;;;;GAOG;AACH,SAAgB,MAAM,CA4BlB,MAaK;IAEL,OAAO,MAAW,CAAA;AACtB,CAAC"}
@@ -1,26 +0,0 @@
1
- import { Document, DocumentPointer, LinkedDocument } from './Composer';
2
- import { Context } from '../Context';
3
- export type Arranged<Status extends 'unresolved' | 'resolved' = 'resolved'> = {
4
- parent?: Status extends 'unresolved' ? DocumentPointer & Arranged<'unresolved'> : LinkedDocument & Arranged;
5
- };
6
- export type Result<T> = {
7
- handled: false;
8
- result?: never;
9
- } | {
10
- handled: true;
11
- result: T;
12
- };
13
- /**
14
- * An arranger function is a function which accepts a document of a known
15
- * kind as input and returns a pointer to its parent, if applicable.
16
- *
17
- * @see {@linkcode Document}
18
- * @see {@linkcode DocumentPointer}
19
- */
20
- export type ArrangerFunction<DocumentKind extends string = string> = (document: Document<DocumentKind>, context: Context) => Result<DocumentPointer | undefined>;
21
- /**
22
- * @see {@linkcode Plugin#arrangers}
23
- */
24
- export type Arrangers<DocumentKinds extends string = string> = {
25
- [K in DocumentKinds]: ArrangerFunction<K>;
26
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"Arranger.js","sourceRoot":"","sources":["../../../src/plugins/behaviors/Arranger.ts"],"names":[],"mappings":""}
@@ -1,102 +0,0 @@
1
- import { SupportedNode } from '@servicenow/sdk-project';
2
- import { XmlData, PrimitiveData, Action, EntityData } from './extractors';
3
- import { Context } from '../Context';
4
- /**
5
- * An unlinked document is a document that does not have an
6
- * association with any AST node.
7
- *
8
- * @see {@linkcode Document}
9
- */
10
- export type UnlinkedDocument<DocumentKind extends string = string> = Omit<Document<DocumentKind>, 'node'>;
11
- /**
12
- * A linked document is a document that has an association
13
- * with an AST node.
14
- *
15
- * @see {@linkcode Document}
16
- */
17
- export type LinkedDocument<DocumentKind extends string = string, Node extends SupportedNode = SupportedNode> = Document<DocumentKind, Node> & {
18
- entity?: EntityData;
19
- node: Node;
20
- };
21
- /**
22
- * A document is a data structure that has a known kind, an ID,
23
- * and an action (insert/update or delete). It may also have an
24
- * associated AST node if the data originated from source code.
25
- *
26
- * @see {@linkcode LinkedDocument}
27
- * @see {@linkcode UnlinkedDocument}
28
- */
29
- export type Document<DocumentKind extends string = string, Node extends SupportedNode = SupportedNode> = {
30
- guid: string;
31
- kind: DocumentKind;
32
- data: unknown;
33
- changedData?: unknown;
34
- xmlFilePath?: string;
35
- xmlData?: unknown;
36
- node?: Node;
37
- action?: Action;
38
- };
39
- /**
40
- * A document pointer is an object that represents a document
41
- * via its ID and kind. Document pointers can be resolved to
42
- * actual documents after all documents have been composed.
43
- *
44
- * @see {@linkcode Document}
45
- */
46
- export type DocumentPointer<DocumentKind extends string = string> = {
47
- guid: string;
48
- kind: DocumentKind;
49
- };
50
- /**
51
- * A document map is an object where documents are accessible
52
- * by their kind and ID. The keys of the object are document
53
- * kinds, and the values are sub-objects where the keys are
54
- * document IDs and the values are the corresponding documents.
55
- *
56
- * @see {@linkcode Document}
57
- */
58
- export type DocumentMap<D extends Document = Document> = {
59
- [kinds: string]: {
60
- [guids: string]: D;
61
- };
62
- };
63
- /**
64
- * An entity composer function is a function that accepts a
65
- * piece of entity data from the source code and returns one
66
- * or more linked documents derived from that entity, or returns
67
- * undefined to indicate that it did not handle the data.
68
- *
69
- * @see {@linkcode Entity}
70
- * @see {@linkcode EntityData}
71
- */
72
- export type EntityComposerFunction<Data extends Record<string, unknown> = Record<string, unknown>> = (entityData: EntityData<Data>, context: Context) => Promise<LinkedDocument | LinkedDocument[] | undefined>;
73
- /**
74
- * An XML composer function is a function that accepts a piece
75
- * of data from an XML file and returns one or more unlinked
76
- * documents derived from that data, or returns undefined to
77
- * indicate that it did not handle the data.
78
- *
79
- * @see {@linkcode PrimitiveData}
80
- * @see {@linkcode XmlData}
81
- */
82
- export type XmlComposerFunction<Data extends PrimitiveData = PrimitiveData> = (xmlData: XmlData<Data>, context: Context) => UnlinkedDocument | UnlinkedDocument[] | undefined;
83
- /**
84
- * @see {@linkcode Plugin#composers}
85
- */
86
- export type Composers = {
87
- entity?: {
88
- [kind: string]: EntityComposerFunction;
89
- };
90
- xml?: {
91
- [kind: string]: XmlComposerFunction;
92
- };
93
- };
94
- /**
95
- * Utility which takes an unlinked document and a node and returns the
96
- * same document linked to the provided node.
97
- *
98
- * @param document The {@linkcode UnlinkedDocument} to link
99
- * @param node The AST node to link the document to
100
- * @returns A {@linkcode LinkedDocument}
101
- */
102
- export declare function linkDocument<const K extends string, const N extends SupportedNode>(document: UnlinkedDocument<K>, node: N): LinkedDocument<K, N>;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.linkDocument = linkDocument;
4
- /**
5
- * Utility which takes an unlinked document and a node and returns the
6
- * same document linked to the provided node.
7
- *
8
- * @param document The {@linkcode UnlinkedDocument} to link
9
- * @param node The AST node to link the document to
10
- * @returns A {@linkcode LinkedDocument}
11
- */
12
- function linkDocument(document, node) {
13
- return { ...document, node };
14
- }
15
- //# sourceMappingURL=Composer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Composer.js","sourceRoot":"","sources":["../../../src/plugins/behaviors/Composer.ts"],"names":[],"mappings":";;AAuHA,oCAKC;AAbD;;;;;;;GAOG;AACH,SAAgB,YAAY,CACxB,QAA6B,EAC7B,IAAO;IAEP,OAAO,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,CAAA;AAChC,CAAC"}
@@ -1,7 +0,0 @@
1
- import { SupportedKindName, SupportedNodeByKindName, ts } from '@servicenow/sdk-project';
2
- import { Context } from '../Context';
3
- import { FluentDiagnostic } from '../Diagnostic';
4
- export type DiagnosticsFunction<K extends SupportedKindName | 'Node' = SupportedKindName> = (node: K extends SupportedKindName ? SupportedNodeByKindName<K> : K extends 'Node' ? ts.Node : any, context: Context) => FluentDiagnostic[];
5
- export type Diagnostics<NodeKinds extends SupportedKindName | 'Node'> = {
6
- [K in NodeKinds]: DiagnosticsFunction<K>;
7
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=Diagnostics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Diagnostics.js","sourceRoot":"","sources":["../../../src/plugins/behaviors/Diagnostics.ts"],"names":[],"mappings":""}
@@ -1,21 +0,0 @@
1
- import { LinkedDocument, UnlinkedDocument } from './Composer';
2
- import { Arranged } from './Arranger';
3
- import { Context } from '../Context';
4
- /**
5
- * A generator function is a function that accepts an unlinked document of
6
- * a known kind as input and returns the same document as a linked document.
7
- * In practice, this means the generator's job is to create new AST nodes
8
- * for documents that are not linked to any node. Documents without nodes
9
- * are usually from XML files containing records that aren't defined in the
10
- * source code yet.
11
- *
12
- * @see {@linkcode UnlinkedDocument}
13
- * @see {@linkcode LinkedDocument}
14
- */
15
- export type GeneratorFunction<DocumentKind extends string = string> = (document: UnlinkedDocument<DocumentKind> & Arranged, context: Context, linkedDocuments: LinkedDocument[]) => LinkedDocument<DocumentKind> | undefined;
16
- /**
17
- * @see {@linkcode Plugin#generators}
18
- */
19
- export type Generators<DocumentKinds extends string = string> = {
20
- [K in DocumentKinds]: GeneratorFunction<K>;
21
- };
@@ -1 +0,0 @@
1
- {"version":3,"file":"Generator.js","sourceRoot":"","sources":["../../../src/plugins/behaviors/Generator.ts"],"names":[],"mappings":""}
@@ -1,6 +0,0 @@
1
- import { Diagnostic } from '@servicenow/sdk-project';
2
- export type TableOwnership = {
3
- [table: string]: {
4
- diagnosticLevel: Diagnostic.Level;
5
- };
6
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=OwnedTables.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OwnedTables.js","sourceRoot":"","sources":["../../../src/plugins/behaviors/OwnedTables.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import { Context } from '../Context';
2
- import { EntityData } from './extractors';
3
- export type PostProcessors = {
4
- entities?: (entities: EntityData[], context: Context) => void;
5
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=PostProcessor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PostProcessor.js","sourceRoot":"","sources":["../../../src/plugins/behaviors/PostProcessor.ts"],"names":[],"mappings":""}