@api-client/core 0.3.1 → 0.3.4

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 (183) hide show
  1. package/build/browser.d.ts +1 -1
  2. package/build/index.d.ts +2 -2
  3. package/build/index.js.map +1 -1
  4. package/build/src/models/Backend.d.ts +22 -0
  5. package/build/src/runtime/store/StoreSdk.d.ts +192 -12
  6. package/build/src/runtime/store/StoreSdk.js +592 -53
  7. package/build/src/runtime/store/StoreSdk.js.map +1 -1
  8. package/package.json +3 -1
  9. package/src/data/DataReader.ts +11 -0
  10. package/src/data/DataUtils.ts +108 -0
  11. package/src/data/JmesparthReader.ts +26 -0
  12. package/src/data/Json2Xml.ts +190 -0
  13. package/src/data/JsonReader.ts +41 -0
  14. package/src/data/PayloadPointer.ts +48 -0
  15. package/src/data/RequestDataExtractor.ts +133 -0
  16. package/src/data/UrlEncodedReader.ts +20 -0
  17. package/src/data/XmlReader.ts +103 -0
  18. package/src/events/BaseEvents.ts +259 -0
  19. package/src/events/CustomEvent.ts +27 -0
  20. package/src/events/EventTypes.ts +19 -0
  21. package/src/events/Events.ts +19 -0
  22. package/src/events/authorization/AuthorizationEventTypes.ts +22 -0
  23. package/src/events/authorization/AuthorizationEvents.ts +61 -0
  24. package/src/events/cookies/CookieEventTypes.ts +13 -0
  25. package/src/events/cookies/CookieEvents.ts +157 -0
  26. package/src/events/encryption/EncryptionEventTypes.ts +4 -0
  27. package/src/events/encryption/EncryptionEvents.ts +51 -0
  28. package/src/events/environment/EnvironmentEventTypes.ts +3 -0
  29. package/src/events/environment/EnvironmentEvents.ts +24 -0
  30. package/src/events/models/ClientCertificateEvents.ts +87 -0
  31. package/src/events/models/ModelEventTypes.ts +47 -0
  32. package/src/events/models/ModelEvents.ts +7 -0
  33. package/src/events/models/ProjectEvents.ts +331 -0
  34. package/src/events/process/ProcessEventTypes.ts +5 -0
  35. package/src/events/process/ProcessEvents.ts +76 -0
  36. package/src/events/readme.md +22 -0
  37. package/src/events/reporting/ReportingEventTypes.ts +3 -0
  38. package/src/events/reporting/ReportingEvents.ts +28 -0
  39. package/src/events/telemetry/TelemetryEventTypes.ts +10 -0
  40. package/src/events/telemetry/TelemetryEvents.ts +156 -0
  41. package/src/lib/cookies/Cookie.ts +312 -0
  42. package/src/lib/cookies/Cookies.ts +326 -0
  43. package/src/lib/cookies/Utils.ts +168 -0
  44. package/src/lib/headers/Headers.ts +219 -0
  45. package/src/lib/logging/DefaultLogger.ts +19 -0
  46. package/src/lib/logging/DummyLogger.ts +21 -0
  47. package/src/lib/logging/Logger.ts +16 -0
  48. package/src/lib/transformers/PayloadSerializer.ts +332 -0
  49. package/src/lib/transformers/Utils.ts +18 -0
  50. package/src/lib/uuid.ts +40 -0
  51. package/src/mocking/LegacyInterfaces.ts +52 -0
  52. package/src/mocking/LegacyMock.ts +37 -0
  53. package/src/mocking/legacy/Authorization.ts +39 -0
  54. package/src/mocking/legacy/Certificates.ts +145 -0
  55. package/src/mocking/legacy/Cookies.ts +51 -0
  56. package/src/mocking/legacy/HostRules.ts +43 -0
  57. package/src/mocking/legacy/Http.ts +236 -0
  58. package/src/mocking/legacy/HttpResponse.ts +106 -0
  59. package/src/mocking/legacy/RestApi.ts +68 -0
  60. package/src/mocking/legacy/Urls.ts +44 -0
  61. package/src/mocking/legacy/Variables.ts +53 -0
  62. package/src/models/ArcResponse.ts +166 -0
  63. package/src/models/Authorization.ts +481 -0
  64. package/src/models/AuthorizationData.ts +60 -0
  65. package/src/models/Backend.ts +107 -0
  66. package/src/models/ClientCertificate.ts +68 -0
  67. package/src/models/Environment.ts +279 -0
  68. package/src/models/ErrorResponse.ts +101 -0
  69. package/src/models/HistoryIndex.ts +76 -0
  70. package/src/models/HistoryRequest.ts +28 -0
  71. package/src/models/HostRule.ts +163 -0
  72. package/src/models/HttpCookie.ts +285 -0
  73. package/src/models/HttpProject.ts +1294 -0
  74. package/src/models/HttpProjectListItem.ts +23 -0
  75. package/src/models/HttpRequest.ts +124 -0
  76. package/src/models/HttpResponse.ts +143 -0
  77. package/src/models/License.ts +113 -0
  78. package/src/models/ProjectDefinitionProperty.ts +40 -0
  79. package/src/models/ProjectFolder.ts +439 -0
  80. package/src/models/ProjectItem.ts +135 -0
  81. package/src/models/ProjectParent.ts +113 -0
  82. package/src/models/ProjectRequest.ts +277 -0
  83. package/src/models/ProjectSchema.ts +202 -0
  84. package/src/models/Property.ts +423 -0
  85. package/src/models/Provider.ts +98 -0
  86. package/src/models/README.md +20 -0
  87. package/src/models/Request.ts +452 -0
  88. package/src/models/RequestActions.ts +163 -0
  89. package/src/models/RequestAuthorization.ts +115 -0
  90. package/src/models/RequestConfig.ts +317 -0
  91. package/src/models/RequestLog.ts +159 -0
  92. package/src/models/RequestTime.ts +108 -0
  93. package/src/models/RequestUiMeta.ts +258 -0
  94. package/src/models/RequestsSize.ts +65 -0
  95. package/src/models/ResponseAuthorization.ts +104 -0
  96. package/src/models/ResponseRedirect.ts +158 -0
  97. package/src/models/RevisionInfo.ts +37 -0
  98. package/src/models/SentRequest.ts +125 -0
  99. package/src/models/SerializablePayload.ts +68 -0
  100. package/src/models/Server.ts +153 -0
  101. package/src/models/Thing.ts +110 -0
  102. package/src/models/Url.ts +90 -0
  103. package/src/models/User.ts +120 -0
  104. package/src/models/WebApi.ts +234 -0
  105. package/src/models/WebApiIndex.ts +122 -0
  106. package/src/models/Workspace.ts +182 -0
  107. package/src/models/actions/Action.ts +213 -0
  108. package/src/models/actions/ActionView.ts +40 -0
  109. package/src/models/actions/Condition.ts +207 -0
  110. package/src/models/actions/ConditionView.ts +42 -0
  111. package/src/models/actions/Enums.ts +29 -0
  112. package/src/models/actions/RunnableAction.ts +144 -0
  113. package/src/models/actions/runnable/DeleteCookieAction.ts +113 -0
  114. package/src/models/actions/runnable/Runnable.ts +9 -0
  115. package/src/models/actions/runnable/SetCookieAction.ts +216 -0
  116. package/src/models/actions/runnable/SetVariableAction.ts +81 -0
  117. package/src/models/legacy/DataExport.ts +172 -0
  118. package/src/models/legacy/Normalizer.ts +110 -0
  119. package/src/models/legacy/actions/Actions.ts +269 -0
  120. package/src/models/legacy/authorization/Authorization.ts +572 -0
  121. package/src/models/legacy/models/ApiTypes.ts +202 -0
  122. package/src/models/legacy/models/ArcLegacyProject.ts +39 -0
  123. package/src/models/legacy/models/AuthData.ts +17 -0
  124. package/src/models/legacy/models/ClientCertificate.ts +95 -0
  125. package/src/models/legacy/models/Cookies.ts +52 -0
  126. package/src/models/legacy/models/HostRule.ts +35 -0
  127. package/src/models/legacy/models/RestApi.ts +49 -0
  128. package/src/models/legacy/models/UrlHistory.ts +37 -0
  129. package/src/models/legacy/models/Variable.ts +43 -0
  130. package/src/models/legacy/models/base.d.ts +95 -0
  131. package/src/models/legacy/request/ArcRequest.ts +405 -0
  132. package/src/models/legacy/request/ArcResponse.ts +177 -0
  133. package/src/models/legacy/request/HistoryData.ts +47 -0
  134. package/src/models/legacy/request/Legacy.ts +45 -0
  135. package/src/models/legacy/request/RequestBody.ts +87 -0
  136. package/src/models/transformers/ArcDexieTransformer.ts +323 -0
  137. package/src/models/transformers/ArcLegacyNormalizer.ts +85 -0
  138. package/src/models/transformers/ArcLegacyTransformer.ts +200 -0
  139. package/src/models/transformers/ArcPouchTransformer.ts +184 -0
  140. package/src/models/transformers/BaseTransformer.ts +116 -0
  141. package/src/models/transformers/ImportUtils.ts +141 -0
  142. package/src/models/transformers/LegacyDataExportToApiProject.ts +76 -0
  143. package/src/models/transformers/LegacyExportProcessor.ts +252 -0
  144. package/src/models/transformers/PostmanBackupTransformer.ts +306 -0
  145. package/src/models/transformers/PostmanDataTransformer.ts +50 -0
  146. package/src/models/transformers/PostmanTransformer.ts +106 -0
  147. package/src/models/transformers/PostmanV21Transformer.ts +311 -0
  148. package/src/models/transformers/PostmanV2Transformer.ts +308 -0
  149. package/src/models/transformers/har.ts +865 -0
  150. package/src/runtime/actions/ActionRunner.ts +83 -0
  151. package/src/runtime/actions/ConditionRunner.ts +194 -0
  152. package/src/runtime/actions/RunnableCondition.ts +57 -0
  153. package/src/runtime/actions/runnable/ActionRunnable.ts +19 -0
  154. package/src/runtime/actions/runnable/DeleteCookieRunnable.ts +39 -0
  155. package/src/runtime/actions/runnable/SetCookieRunnable.ts +92 -0
  156. package/src/runtime/actions/runnable/SetVariableRunnable.ts +53 -0
  157. package/src/runtime/http-engine/ArcEngine.ts +1064 -0
  158. package/src/runtime/http-engine/Errors.ts +13 -0
  159. package/src/runtime/http-engine/FormData.ts +85 -0
  160. package/src/runtime/http-engine/HttpEngine.ts +874 -0
  161. package/src/runtime/http-engine/HttpErrorCodes.ts +270 -0
  162. package/src/runtime/http-engine/NodeEngine.ts +787 -0
  163. package/src/runtime/http-engine/NodeEngineDirect.ts +476 -0
  164. package/src/runtime/http-engine/PayloadSupport.ts +84 -0
  165. package/src/runtime/http-engine/RequestUtils.ts +164 -0
  166. package/src/runtime/http-engine/ntlm/Des.ts +345 -0
  167. package/src/runtime/http-engine/ntlm/MD4.ts +135 -0
  168. package/src/runtime/http-engine/ntlm/NtlmAuth.ts +186 -0
  169. package/src/runtime/http-engine/ntlm/NtlmMessage.ts +57 -0
  170. package/src/runtime/modules/BasicAuthCache.ts +133 -0
  171. package/src/runtime/modules/ExecutionResponse.ts +4 -0
  172. package/src/runtime/modules/ModulesRegistry.ts +136 -0
  173. package/src/runtime/modules/RequestAuthorization.ts +110 -0
  174. package/src/runtime/modules/RequestCookies.ts +145 -0
  175. package/src/runtime/node/ProjectRunner.ts +275 -0
  176. package/src/runtime/node/RequestFactory.ts +422 -0
  177. package/src/runtime/node/VariablesStore.ts +25 -0
  178. package/src/runtime/store/StoreSdk.ts +838 -0
  179. package/src/runtime/variables/Cache.ts +53 -0
  180. package/src/runtime/variables/EvalFunctions.ts +132 -0
  181. package/src/runtime/variables/ProjectVariables.ts +6 -0
  182. package/src/runtime/variables/VariablesProcessor.ts +543 -0
  183. package/src/runtime/variables/VariablesTokenizer.ts +55 -0
@@ -0,0 +1,423 @@
1
+ import { ApiType } from './legacy/models/ApiTypes.js';
2
+
3
+ export type PropertyType = 'string' | 'integer' | 'float' | 'nil' | 'boolean' | 'date' | 'datetime' | 'time' | 'int32' | 'int64' | 'uint32' | 'uint64' | 'sint32' | 'sint64' | 'fixed32' | 'fixed64' | 'sfixed32' | 'sfixed64' | 'double' | 'bytes';
4
+
5
+ export interface IProperty {
6
+ kind: 'ARC#Property';
7
+ /**
8
+ * Property name
9
+ */
10
+ name: string;
11
+ /**
12
+ * Property value
13
+ */
14
+ value: unknown | IProperty[];
15
+ /**
16
+ * Property data type
17
+ */
18
+ type: PropertyType;
19
+ /**
20
+ * Whether the property is enabled. If not set it is assumed the property is enabled.
21
+ */
22
+ enabled?: boolean;
23
+ /**
24
+ * The default value for the property
25
+ */
26
+ default?: unknown;
27
+ /**
28
+ * Enum values for the property.
29
+ */
30
+ enum?: unknown;
31
+ /**
32
+ * The description of the property
33
+ */
34
+ description?: string;
35
+ /**
36
+ * Whether the value id required to be provided. This is used with validation.
37
+ */
38
+ required?: boolean;
39
+ /**
40
+ * When set to `true` it represents a property that is an array.
41
+ */
42
+ repeated?: boolean;
43
+ }
44
+
45
+ export const Kind = 'ARC#Property';
46
+
47
+ /**
48
+ * A property of an HTTP request.
49
+ */
50
+ export class Property {
51
+ kind = Kind;
52
+ /**
53
+ * Property name
54
+ */
55
+ name = '';
56
+ /**
57
+ * Property data type
58
+ */
59
+ type: PropertyType = 'string';
60
+ /**
61
+ * Property value
62
+ */
63
+ value: unknown = '';
64
+ /**
65
+ * The description of the property
66
+ */
67
+ description?: string;
68
+ /**
69
+ * The default value for the property
70
+ */
71
+ default?: unknown;
72
+ /**
73
+ * Whether the property is enabled. If not set it is assumed the property is enabled.
74
+ */
75
+ enabled?: boolean;
76
+ /**
77
+ * Enum values for the property.
78
+ */
79
+ enum?: unknown;
80
+ /**
81
+ * Whether the value id required to be provided. This is used with validation.
82
+ */
83
+ required?: boolean;
84
+ /**
85
+ * When set to `true` it represents a property that is an array.
86
+ */
87
+ repeated?: boolean;
88
+
89
+ static get supportedTypes(): PropertyType[] {
90
+ return [
91
+ 'string', 'integer', 'float', 'nil', 'boolean', 'date', 'datetime', 'time',
92
+ 'int32' , 'int64' , 'uint32' , 'uint64' , 'sint32' , 'sint64' , 'fixed32', 'fixed64' ,
93
+ 'sfixed32' , 'sfixed64' , 'double' , 'bytes'
94
+ ];
95
+ }
96
+
97
+ /**
98
+ * Creates an instance of a property recognizing the type of the `value`.
99
+ * It only works for primitive values.
100
+ *
101
+ * @param name The name of the property
102
+ * @param value The value of the property. Default to an empty string which is the same as calling `Property.String()`.
103
+ * @param enabled Whether the property is enabled.
104
+ */
105
+ static fromType(name = '', value: unknown = '', enabled = true): Property {
106
+ const type = typeof value;
107
+ if (type === 'boolean') {
108
+ return Property.Boolean(name, value as boolean, enabled);
109
+ }
110
+ if (type === 'number') {
111
+ return Property.Integer(name, value as number, enabled);
112
+ }
113
+ return Property.String(name, value as string, enabled);
114
+ }
115
+
116
+ static fromTypeDefault(name = '', type: PropertyType): Property {
117
+ let result: Property | undefined;
118
+ switch (type) {
119
+ case 'string': result = Property.String(name); break;
120
+ case 'boolean': result = Property.Boolean(name); break;
121
+ case 'date': result = Property.Date(name); break;
122
+ case 'datetime': result = Property.Datetime(name); break;
123
+ case 'time': result = Property.Time(name); break;
124
+ case 'float': result = Property.Float(name); break;
125
+ case 'double': result = Property.Double(name); break;
126
+ case 'int32': result = Property.Int32(name); break;
127
+ case 'int64': result = Property.Int64(name); break;
128
+ case 'uint32': result = Property.Uint32(name); break;
129
+ case 'uint64': result = Property.Uint64(name); break;
130
+ case 'sint32': result = Property.Sint32(name); break;
131
+ case 'sint64': result = Property.Sint64(name); break;
132
+ case 'fixed32': result = Property.Fixed32(name); break;
133
+ case 'fixed64': result = Property.Fixed64(name); break;
134
+ case 'sfixed32': result = Property.Sfixed32(name); break;
135
+ case 'sfixed64': result = Property.Sfixed64(name); break;
136
+ case 'integer': result = Property.Integer(name); break;
137
+ case 'bytes': result = Property.Bytes(name); break;
138
+ }
139
+ if (!result) {
140
+ throw new Error(`The type ${type} is not yet supported.`)
141
+ }
142
+ return result;
143
+ }
144
+
145
+ static String(name = '', value?: string, enabled = true): Property {
146
+ return new Property({
147
+ kind: Kind,
148
+ name,
149
+ value: value || '',
150
+ type: 'string',
151
+ enabled,
152
+ });
153
+ }
154
+
155
+ static Integer(name = '', value?: number, enabled = true): Property {
156
+ return new Property({
157
+ kind: Kind,
158
+ name,
159
+ value: value || 0,
160
+ type: 'integer',
161
+ enabled,
162
+ });
163
+ }
164
+
165
+ static Int32(name = '', value?: number, enabled = true): Property {
166
+ return new Property({
167
+ kind: Kind,
168
+ name,
169
+ value: value || 0,
170
+ type: 'int32',
171
+ enabled,
172
+ });
173
+ }
174
+
175
+ static Int64(name = '', value?: number, enabled = true): Property {
176
+ return new Property({
177
+ kind: Kind,
178
+ name,
179
+ value: value || 0,
180
+ type: 'int64',
181
+ enabled,
182
+ });
183
+ }
184
+
185
+ static Uint32(name = '', value?: number, enabled = true): Property {
186
+ return new Property({
187
+ kind: Kind,
188
+ name,
189
+ value: value || 0,
190
+ type: 'uint32',
191
+ enabled,
192
+ });
193
+ }
194
+
195
+ static Uint64(name = '', value?: number, enabled = true): Property {
196
+ return new Property({
197
+ kind: Kind,
198
+ name,
199
+ value: value || 0,
200
+ type: 'uint64',
201
+ enabled,
202
+ });
203
+ }
204
+
205
+ static Sint32(name = '', value?: number, enabled = true): Property {
206
+ return new Property({
207
+ kind: Kind,
208
+ name,
209
+ value: value || 0,
210
+ type: 'sint32',
211
+ enabled,
212
+ });
213
+ }
214
+
215
+ static Sint64(name = '', value?: number, enabled = true): Property {
216
+ return new Property({
217
+ kind: Kind,
218
+ name,
219
+ value: value || 0,
220
+ type: 'sint64',
221
+ enabled,
222
+ });
223
+ }
224
+
225
+ static Fixed32(name = '', value?: number, enabled = true): Property {
226
+ return new Property({
227
+ kind: Kind,
228
+ name,
229
+ value: value || 0,
230
+ type: 'fixed32',
231
+ enabled,
232
+ });
233
+ }
234
+
235
+ static Fixed64(name = '', value?: number, enabled = true): Property {
236
+ return new Property({
237
+ kind: Kind,
238
+ name,
239
+ value: value || 0,
240
+ type: 'fixed64',
241
+ enabled,
242
+ });
243
+ }
244
+
245
+ static Sfixed32(name = '', value?: number, enabled = true): Property {
246
+ return new Property({
247
+ kind: Kind,
248
+ name,
249
+ value: value || 0,
250
+ type: 'sfixed32',
251
+ enabled,
252
+ });
253
+ }
254
+
255
+ static Sfixed64(name = '', value?: number, enabled = true): Property {
256
+ return new Property({
257
+ kind: Kind,
258
+ name,
259
+ value: value || 0,
260
+ type: 'sfixed64',
261
+ enabled,
262
+ });
263
+ }
264
+
265
+ static Float(name = '', value?: number, enabled = true): Property {
266
+ return new Property({
267
+ kind: Kind,
268
+ name,
269
+ value: value || 0.0,
270
+ type: 'float',
271
+ enabled,
272
+ });
273
+ }
274
+
275
+ static Double(name = '', value?: number, enabled = true): Property {
276
+ return new Property({
277
+ kind: Kind,
278
+ name,
279
+ value: value || 0.0,
280
+ type: 'double',
281
+ enabled,
282
+ });
283
+ }
284
+
285
+ static Boolean(name = '', value = false, enabled = true): Property {
286
+ return new Property({
287
+ kind: Kind,
288
+ name,
289
+ value: value,
290
+ type: 'boolean',
291
+ enabled,
292
+ });
293
+ }
294
+
295
+ static Date(name = ''): Property {
296
+ return new Property({
297
+ kind: Kind,
298
+ name,
299
+ value: '',
300
+ type: 'date',
301
+ enabled: true,
302
+ });
303
+ }
304
+
305
+ static Datetime(name = ''): Property {
306
+ return new Property({
307
+ kind: Kind,
308
+ name,
309
+ value: '',
310
+ type: 'datetime',
311
+ enabled: true,
312
+ });
313
+ }
314
+
315
+ static Time(name = ''): Property {
316
+ return new Property({
317
+ kind: Kind,
318
+ name,
319
+ value: '',
320
+ type: 'time',
321
+ enabled: true,
322
+ });
323
+ }
324
+
325
+ static Bytes(name = ''): Property {
326
+ return new Property({
327
+ kind: Kind,
328
+ name,
329
+ value: '',
330
+ type: 'bytes',
331
+ enabled: true,
332
+ });
333
+ }
334
+
335
+ static fromApiType(type: ApiType): Property {
336
+ const init: IProperty = { ...type, kind: Kind, type: type.type as PropertyType || 'string' };
337
+ return new Property(init);
338
+ }
339
+
340
+ /**
341
+ * @param input The property definition used to restore the state.
342
+ */
343
+ constructor(input?: string | IProperty) {
344
+ let init: IProperty;
345
+ if (typeof input === 'string') {
346
+ init = JSON.parse(input);
347
+ } else if (typeof input === 'object') {
348
+ init = input;
349
+ } else {
350
+ init = {
351
+ kind: Kind,
352
+ name: '',
353
+ value: '',
354
+ type: 'string',
355
+ };
356
+ }
357
+ this.new(init);
358
+ }
359
+
360
+ /**
361
+ * Creates a new environment clearing anything that is so far defined.
362
+ *
363
+ * Note, this throws an error when the property is not an ARC environment.
364
+ */
365
+ new(init: IProperty): void {
366
+ if (!Property.isProperty(init)) {
367
+ throw new Error(`Not an ARC property.`);
368
+ }
369
+ const { name, value, default: defaultValue, description, enabled, enum: enumValue, required, type, repeated } = init;
370
+ this.kind = Kind;
371
+ this.name = name;
372
+ this.value = value;
373
+ this.description = description;
374
+ this.default = defaultValue;
375
+ this.enabled = enabled;
376
+ this.enum = enumValue;
377
+ this.required = required;
378
+ this.type = type;
379
+ this.repeated = repeated;
380
+ }
381
+
382
+ /**
383
+ * Checks whether the input is a definition of a property.
384
+ */
385
+ static isProperty(input: unknown): boolean {
386
+ const typed = input as IProperty;
387
+ if (!input || typeof typed.name !== 'string' || typeof typed.type !== 'string' || typed.kind !== Kind) {
388
+ return false;
389
+ }
390
+ if (!Property.supportedTypes.includes(typed.type)) {
391
+ return false;
392
+ }
393
+ return true;
394
+ }
395
+
396
+ toJSON(): IProperty {
397
+ const result:IProperty = {
398
+ kind: Kind,
399
+ name: this.name,
400
+ value: this.value,
401
+ type: this.type,
402
+ };
403
+ if (this.description) {
404
+ result.description = this.description;
405
+ }
406
+ if (typeof this.default !== 'undefined') {
407
+ result.default = this.default;
408
+ }
409
+ if (this.enum) {
410
+ result.enum = this.enum;
411
+ }
412
+ if (typeof this.enabled === 'boolean') {
413
+ result.enabled = this.enabled;
414
+ }
415
+ if (typeof this.required === 'boolean') {
416
+ result.required = this.required;
417
+ }
418
+ if (typeof this.repeated === 'boolean') {
419
+ result.repeated = this.repeated;
420
+ }
421
+ return result;
422
+ }
423
+ }
@@ -0,0 +1,98 @@
1
+ /**
2
+ * An interface describing a provider of a thing.
3
+ */
4
+ export declare interface IProvider {
5
+ /**
6
+ * The data kind. The application ignores the input with an unknown `kind`, unless it can be determined from the context.
7
+ */
8
+ kind: 'ARC#Provider';
9
+ /**
10
+ * The URL to the provider
11
+ */
12
+ url?: string;
13
+ /**
14
+ * The name to the provider
15
+ */
16
+ name?: string;
17
+ /**
18
+ * The email to the provider
19
+ */
20
+ email?: string;
21
+ }
22
+
23
+ export const Kind = 'ARC#Provider';
24
+
25
+ export class Provider {
26
+ kind = Kind;
27
+ /**
28
+ * The URL to the provider
29
+ */
30
+ url?: string;
31
+ /**
32
+ * The name to the provider
33
+ */
34
+ name?: string;
35
+ /**
36
+ * The email to the provider
37
+ */
38
+ email?: string;
39
+ /**
40
+ * @param input The provider definition used to restore the state.
41
+ */
42
+ constructor(input?: string|IProvider) {
43
+ let init: IProvider;
44
+ if (typeof input === 'string') {
45
+ init = JSON.parse(input);
46
+ } else if (typeof input === 'object') {
47
+ init = input;
48
+ } else {
49
+ init = {
50
+ kind: Kind,
51
+ };
52
+ }
53
+ this.new(init);
54
+ }
55
+
56
+ /**
57
+ * Creates a new provider clearing anything that is so far defined.
58
+ *
59
+ * Note, this throws an error when the provider is not an ARC provider object.
60
+ */
61
+ new(init: IProvider): void {
62
+ if (!Provider.isProvider(init)) {
63
+ throw new Error(`Not an ARC provider.`);
64
+ }
65
+ const { url, email, name } = init;
66
+ this.kind = Kind;
67
+ this.name = name;
68
+ this.email = email;
69
+ this.url = url;
70
+ }
71
+
72
+ /**
73
+ * Checks whether the input is a definition of a provider.
74
+ */
75
+ static isProvider(input: unknown): boolean {
76
+ const typed = input as IProvider;
77
+ if (input && typed.kind === Kind) {
78
+ return true;
79
+ }
80
+ return false;
81
+ }
82
+
83
+ toJSON(): IProvider {
84
+ const result:IProvider = {
85
+ kind: Kind,
86
+ };
87
+ if (this.url) {
88
+ result.url = this.url;
89
+ }
90
+ if (this.email) {
91
+ result.email = this.email;
92
+ }
93
+ if (this.name) {
94
+ result.name = this.name;
95
+ }
96
+ return result;
97
+ }
98
+ }
@@ -0,0 +1,20 @@
1
+ # API Client/ARC models
2
+
3
+ ## Principles for designing a data model
4
+
5
+ ### No view definition
6
+
7
+ Data models should only contain the data related to the functionality, and not view.
8
+ Each application should keep separate metadata related to the view configuration.
9
+
10
+ ### Translatable from a YAML format
11
+
12
+ We aim to be interoperable with AMF so when designing a data model first design a YAML example with the data and then create a type definition. Additionally, you need to design an AML dialect for the data.
13
+
14
+ ### The "kind" as the object type identifier
15
+
16
+ Each data object that can exist by itself or in multiple contexts' should contain the `kind` property that uniquely identifies the type. For example, the `HttpProject` class has the `ARC#HttpProject`. These kinds are used by other libraries to identify which data types they are given as the input.
17
+
18
+ ### Validation
19
+
20
+ THe data models should contain validators that produce the validation report. This ensures the support libraries can perform a validation of the data model they are receiving as an input to keep integrity of the data.