@skmtc/core 0.0.367 → 0.0.369

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 (71) hide show
  1. package/esm/context/GenerateContext.d.ts +79 -4
  2. package/esm/context/GenerateContext.d.ts.map +1 -1
  3. package/esm/context/GenerateContext.js +113 -33
  4. package/esm/oas/array/Array.d.ts +32 -8
  5. package/esm/oas/array/Array.d.ts.map +1 -1
  6. package/esm/oas/array/Array.js +60 -30
  7. package/esm/oas/boolean/Boolean.d.ts +24 -6
  8. package/esm/oas/boolean/Boolean.d.ts.map +1 -1
  9. package/esm/oas/boolean/Boolean.js +40 -24
  10. package/esm/oas/integer/Integer.d.ts +29 -8
  11. package/esm/oas/integer/Integer.d.ts.map +1 -1
  12. package/esm/oas/integer/Integer.js +57 -30
  13. package/esm/oas/number/Number.d.ts +24 -6
  14. package/esm/oas/number/Number.d.ts.map +1 -1
  15. package/esm/oas/number/Number.js +40 -24
  16. package/esm/oas/object/Object.d.ts +56 -12
  17. package/esm/oas/object/Object.d.ts.map +1 -1
  18. package/esm/oas/object/Object.js +52 -5
  19. package/esm/oas/string/String.d.ts +32 -8
  20. package/esm/oas/string/String.d.ts.map +1 -1
  21. package/esm/oas/string/String.js +63 -33
  22. package/esm/oas/union/Union.d.ts +38 -8
  23. package/esm/oas/union/Union.d.ts.map +1 -1
  24. package/esm/oas/union/Union.js +66 -30
  25. package/esm/oas/unknown/Unknown.d.ts +24 -5
  26. package/esm/oas/unknown/Unknown.d.ts.map +1 -1
  27. package/esm/oas/unknown/Unknown.js +34 -21
  28. package/esm/oas/void/Void.d.ts +22 -5
  29. package/esm/oas/void/Void.d.ts.map +1 -1
  30. package/esm/oas/void/Void.js +32 -21
  31. package/esm/server/createServer.d.ts.map +1 -1
  32. package/esm/server/createServer.js +2 -1
  33. package/esm/typescript/List.d.ts +19 -3
  34. package/esm/typescript/List.d.ts.map +1 -1
  35. package/esm/typescript/List.js +31 -0
  36. package/package.json +1 -1
  37. package/script/context/GenerateContext.d.ts +79 -4
  38. package/script/context/GenerateContext.d.ts.map +1 -1
  39. package/script/context/GenerateContext.js +113 -33
  40. package/script/oas/array/Array.d.ts +32 -8
  41. package/script/oas/array/Array.d.ts.map +1 -1
  42. package/script/oas/array/Array.js +60 -30
  43. package/script/oas/boolean/Boolean.d.ts +24 -6
  44. package/script/oas/boolean/Boolean.d.ts.map +1 -1
  45. package/script/oas/boolean/Boolean.js +40 -24
  46. package/script/oas/integer/Integer.d.ts +29 -8
  47. package/script/oas/integer/Integer.d.ts.map +1 -1
  48. package/script/oas/integer/Integer.js +57 -30
  49. package/script/oas/number/Number.d.ts +24 -6
  50. package/script/oas/number/Number.d.ts.map +1 -1
  51. package/script/oas/number/Number.js +40 -24
  52. package/script/oas/object/Object.d.ts +56 -12
  53. package/script/oas/object/Object.d.ts.map +1 -1
  54. package/script/oas/object/Object.js +52 -5
  55. package/script/oas/string/String.d.ts +32 -8
  56. package/script/oas/string/String.d.ts.map +1 -1
  57. package/script/oas/string/String.js +63 -33
  58. package/script/oas/union/Union.d.ts +38 -8
  59. package/script/oas/union/Union.d.ts.map +1 -1
  60. package/script/oas/union/Union.js +66 -30
  61. package/script/oas/unknown/Unknown.d.ts +24 -5
  62. package/script/oas/unknown/Unknown.d.ts.map +1 -1
  63. package/script/oas/unknown/Unknown.js +34 -21
  64. package/script/oas/void/Void.d.ts +22 -5
  65. package/script/oas/void/Void.d.ts.map +1 -1
  66. package/script/oas/void/Void.js +32 -21
  67. package/script/server/createServer.d.ts.map +1 -1
  68. package/script/server/createServer.js +2 -1
  69. package/script/typescript/List.d.ts +19 -3
  70. package/script/typescript/List.d.ts.map +1 -1
  71. package/script/typescript/List.js +33 -1
@@ -207,6 +207,20 @@ Object.defineProperty(List, "fromKeys", {
207
207
  return new KeyList(Object.keys(record ?? {}));
208
208
  }
209
209
  });
210
+ /**
211
+ * Create a EntryList using the entries of @param record
212
+ * @afdafg
213
+ * @param record
214
+ * @returns EntryList
215
+ */
216
+ Object.defineProperty(List, "fromEntrys", {
217
+ enumerable: true,
218
+ configurable: true,
219
+ writable: true,
220
+ value: (record) => {
221
+ return new EntryList(Object.entries(record ?? {}));
222
+ }
223
+ });
210
224
  /**
211
225
  * Create a keyValue pair if `value` is not undefined and is not an empty array or List.
212
226
  * Return `undefined` otherwise.
@@ -270,3 +284,20 @@ export class KeyList {
270
284
  return List.toLines(this.keys);
271
285
  }
272
286
  }
287
+ export class EntryList {
288
+ constructor(entries) {
289
+ Object.defineProperty(this, "entries", {
290
+ enumerable: true,
291
+ configurable: true,
292
+ writable: true,
293
+ value: void 0
294
+ });
295
+ this.entries = entries;
296
+ }
297
+ toObject(mapFn) {
298
+ return List.toObject(this.entries.map((entry, index) => mapFn(entry, index)));
299
+ }
300
+ toLines(mapFn) {
301
+ return List.toLines(this.entries.map((key, index) => mapFn(key, index)));
302
+ }
303
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.367",
3
+ "version": "0.0.369",
4
4
  "main": "./script/mod.js",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -3,7 +3,7 @@ import { Definition } from '../dsl/Definition.js';
3
3
  import type { OasDocument } from '../oas/document/Document.js';
4
4
  import type { OasSchema } from '../oas/schema/Schema.js';
5
5
  import type { OasRef } from '../oas/ref/Ref.js';
6
- import type { FileContents, GetFileOptions } from './types.js';
6
+ import type { FileContents } from './types.js';
7
7
  import type { BaseSettings, ClientSettings } from '../types/Settings.js';
8
8
  import type { Method } from '../types/Method.js';
9
9
  import type { OperationInsertable, OperationGateway } from '../dsl/operation/OperationInsertable.js';
@@ -85,18 +85,93 @@ export declare class GenerateContext {
85
85
  callback: (generatorKey: GeneratorKey) => void;
86
86
  captureCurrentResult: (result: SuccessWarningError) => void;
87
87
  constructor({ oasDocument, settings, logger, callback, captureCurrentResult, stackTrail }: ConstructorArgs);
88
+ /**
89
+ * @internal
90
+ */
88
91
  generate(generatorsMap: Record<string, OperationGateway | ModelGateway>): Map<string, FileContents>;
89
92
  trace<T>(token: string | string[], fn: () => T): T;
90
- getFile(filePath: string, { throwIfNotFound }?: GetFileOptions): FileContents;
93
+ /**
94
+ * Converts schema to value using `schemaToValueFn` and creates definition
95
+ * with the given `identifier` at `destinationPath`.
96
+ *
97
+ * If a definition with the same name already exists, it will be returned
98
+ * instead of creating a new one.
99
+ *
100
+ * @param schema - The schema to create the definition for.
101
+ * @param identifier - The identifier for the definition.
102
+ * @param destinationPath - The path to the file where the definition will be registered.
103
+ * @param schemaToValueFn - A function that converts the schema to a value.
104
+ * @returns The created definition or cached definition if it already exists.
105
+ */
91
106
  createAndRegisterDefinition<Schema extends SchemaType>({ schema, identifier, destinationPath, schemaToValueFn }: CreateAndRegisterDefinition<Schema>): Definition<TypeSystemOutput<Schema['type']>>;
107
+ /**
108
+ * Insert supplied `imports` and `definitions` into file at `destinationPath`.
109
+ *
110
+ * If an import from a specified module already exists in the file, the
111
+ * import names are appended to the existing import.
112
+ *
113
+ * Definitions will only be added if there is not already a definition with
114
+ * the same name in the file.
115
+ *
116
+ * @mutates this.files
117
+ */
92
118
  register({ imports, definitions, destinationPath }: RegisterArgs): void;
119
+ /**
120
+ * Insert operation or model into the output file with path `destinationPath`.
121
+ *
122
+ * Insert will perform the following steps:
123
+ * 1. Generate content settings for the supplied operation or model
124
+ * 2. Look up definition in file with path `destinationPath`
125
+ * 3. If definition is not found, it will create a new one and register it
126
+ * 4. If the definition is defined at a location that is different from
127
+ * the current file, it will add an import to the current file from
128
+ * that location
129
+ * 5. Use the content settings to generate the operation/model using the
130
+ * insertable's driver
131
+ * @mutates this.files
132
+ */
93
133
  insert<V extends GeneratedValue, T extends GenerationType>({ generation, destinationPath, ...rest }: InsertArgs<V, T>): Inserted<V, T>;
134
+ /**
135
+ * Generate and return content settings for operation insertable and
136
+ * operation.
137
+ *
138
+ * Content settings are produced by passing base settings and operation
139
+ * through toIdentifier, toExportPath and isSelected static methods on the
140
+ * insertable.
141
+ * @param { operation, insertable }
142
+ * @returns
143
+ */
94
144
  toOperationContentSettings<V>({ operation, insertable }: ToOperationSettingsArgs<V>): ContentSettings;
145
+ /**
146
+ * Generate and return content settings for model insertable and refName.
147
+ *
148
+ * Content settings are produced by passing base settings and refName
149
+ * through toIdentifier, toExportPath and isSelected static methods on the
150
+ * insertable.
151
+ * @param { refName, insertable }
152
+ * @returns Content settings for model
153
+ */
95
154
  toModelContentSettings<V>({ refName, insertable }: BuildModelSettingsArgs<V>): ContentSettings;
155
+ /**
156
+ * Look up operation settings for a given generatorId, path and method.
157
+ * @param { generatorId, path, method }
158
+ * @returns Base settings for operation
159
+ */
96
160
  toOperationBaseSettings({ generatorId, path, method }: GetOperationSettingsArgs): BaseSettings;
97
- addFile(normalisedPath: string): FileContents;
161
+ /**
162
+ * Perform one lookup of schema by `refName`.
163
+ * @param refName
164
+ * @returns Matching schema or ref
165
+ * @throws if schema is not found
166
+ */
98
167
  resolveSchemaRefOnce(refName: RefName): OasSchema | OasRef<'schema'>;
99
- /** Produce external instance and return its name */
168
+ /**
169
+ * Check if definition name `name` in file with path `exportPath`
170
+ * has already been created and registered.
171
+ *
172
+ * @param { name, exportPath }
173
+ * @returns Matching definition if found or `undefined` otherwise
174
+ */
100
175
  findDefinition({ name, exportPath }: PickArgs): Definition | undefined;
101
176
  }
102
177
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"GenerateContext.d.ts","sourceRoot":"","sources":["../../src/context/GenerateContext.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAA;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAA;AAC9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;A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33
33
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
34
34
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
35
35
  };
36
- var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_stackTrail, _GenerateContext_runOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_toModelBaseSettings;
36
+ var _GenerateContext_instances, _GenerateContext_files, _GenerateContext_stackTrail, _GenerateContext_runOperationGenerator, _GenerateContext_runModelGenerator, _GenerateContext_getFile, _GenerateContext_toModelBaseSettings, _GenerateContext_addFile;
37
37
  Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.GenerateContext = void 0;
39
39
  const mod_js_1 = require("../deps/jsr.io/@std/path/1.0.0/mod.js");
@@ -89,6 +89,9 @@ class GenerateContext {
89
89
  __classPrivateFieldSet(this, _GenerateContext_stackTrail, stackTrail, "f");
90
90
  this.captureCurrentResult = captureCurrentResult;
91
91
  }
92
+ /**
93
+ * @internal
94
+ */
92
95
  generate(generatorsMap) {
93
96
  Sentry.startSpan({ name: 'Generate operations' }, () => Object.values(generatorsMap)
94
97
  .filter(generator => generator.type === 'operation')
@@ -115,19 +118,19 @@ class GenerateContext {
115
118
  trace(token, fn) {
116
119
  return (0, tracer_js_1.tracer)(__classPrivateFieldGet(this, _GenerateContext_stackTrail, "f"), token, fn);
117
120
  }
118
- getFile(filePath, { throwIfNotFound = false } = {}) {
119
- const normalisedPath = (0, mod_js_1.normalize)(filePath);
120
- const currentFile = __classPrivateFieldGet(this, _GenerateContext_files, "f").get(normalisedPath);
121
- if (!currentFile) {
122
- if (throwIfNotFound) {
123
- throw new Error(`File not found: '${normalisedPath}'`);
124
- }
125
- else {
126
- return this.addFile(normalisedPath);
127
- }
128
- }
129
- return currentFile;
130
- }
121
+ /**
122
+ * Converts schema to value using `schemaToValueFn` and creates definition
123
+ * with the given `identifier` at `destinationPath`.
124
+ *
125
+ * If a definition with the same name already exists, it will be returned
126
+ * instead of creating a new one.
127
+ *
128
+ * @param schema - The schema to create the definition for.
129
+ * @param identifier - The identifier for the definition.
130
+ * @param destinationPath - The path to the file where the definition will be registered.
131
+ * @param schemaToValueFn - A function that converts the schema to a value.
132
+ * @returns The created definition or cached definition if it already exists.
133
+ */
131
134
  createAndRegisterDefinition({ schema, identifier, destinationPath, schemaToValueFn }) {
132
135
  const cachedDefinition = this.findDefinition({
133
136
  name: identifier.name,
@@ -155,8 +158,20 @@ class GenerateContext {
155
158
  });
156
159
  return responseDefinition;
157
160
  }
161
+ /**
162
+ * Insert supplied `imports` and `definitions` into file at `destinationPath`.
163
+ *
164
+ * If an import from a specified module already exists in the file, the
165
+ * import names are appended to the existing import.
166
+ *
167
+ * Definitions will only be added if there is not already a definition with
168
+ * the same name in the file.
169
+ *
170
+ * @mutates this.files
171
+ */
158
172
  register({ imports = {}, definitions, destinationPath }) {
159
- const currentFile = this.getFile(destinationPath);
173
+ // TODO deduplicate import names and definition names against each other
174
+ const currentFile = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_getFile).call(this, destinationPath);
160
175
  Object.entries(imports).forEach(([importModule, importNames]) => {
161
176
  const module = currentFile.imports.get(importModule);
162
177
  const importItem = new Import_js_1.Import({ module: importModule, importNames });
@@ -167,12 +182,30 @@ class GenerateContext {
167
182
  currentFile.imports.set(importModule, new Set(importItem.importNames.map(n => `${n}`)));
168
183
  }
169
184
  });
170
- definitions
171
- ?.filter((definition) => Boolean(definition))
172
- .forEach(definition => {
173
- currentFile.definitions.set(`${definition.identifier}`, definition);
185
+ definitions?.forEach(definition => {
186
+ if (!definition) {
187
+ return;
188
+ }
189
+ const { name } = definition.identifier;
190
+ if (!currentFile.definitions.has(name)) {
191
+ currentFile.definitions.set(name, definition);
192
+ }
174
193
  });
175
194
  }
195
+ /**
196
+ * Insert operation or model into the output file with path `destinationPath`.
197
+ *
198
+ * Insert will perform the following steps:
199
+ * 1. Generate content settings for the supplied operation or model
200
+ * 2. Look up definition in file with path `destinationPath`
201
+ * 3. If definition is not found, it will create a new one and register it
202
+ * 4. If the definition is defined at a location that is different from
203
+ * the current file, it will add an import to the current file from
204
+ * that location
205
+ * 5. Use the content settings to generate the operation/model using the
206
+ * insertable's driver
207
+ * @mutates this.files
208
+ */
176
209
  insert({ generation, destinationPath, ...rest }) {
177
210
  const { settings, definition } = (0, ts_pattern_1.match)(rest)
178
211
  .with({ operation: ts_pattern_1.P.nonNullable }, ({ insertable, operation }) => {
@@ -196,6 +229,16 @@ class GenerateContext {
196
229
  .exhaustive();
197
230
  return new Inserted_js_1.Inserted({ settings, definition });
198
231
  }
232
+ /**
233
+ * Generate and return content settings for operation insertable and
234
+ * operation.
235
+ *
236
+ * Content settings are produced by passing base settings and operation
237
+ * through toIdentifier, toExportPath and isSelected static methods on the
238
+ * insertable.
239
+ * @param { operation, insertable }
240
+ * @returns
241
+ */
199
242
  toOperationContentSettings({ operation, insertable }) {
200
243
  const baseSettings = this.toOperationBaseSettings({
201
244
  generatorId: insertable.id,
@@ -210,6 +253,15 @@ class GenerateContext {
210
253
  importFrom: baseSettings.importFrom ?? e
211
254
  });
212
255
  }
256
+ /**
257
+ * Generate and return content settings for model insertable and refName.
258
+ *
259
+ * Content settings are produced by passing base settings and refName
260
+ * through toIdentifier, toExportPath and isSelected static methods on the
261
+ * insertable.
262
+ * @param { refName, insertable }
263
+ * @returns Content settings for model
264
+ */
213
265
  toModelContentSettings({ refName, insertable }) {
214
266
  const baseSettings = __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_toModelBaseSettings).call(this, {
215
267
  generatorId: insertable.id,
@@ -223,6 +275,11 @@ class GenerateContext {
223
275
  importFrom: baseSettings.importFrom ?? e
224
276
  });
225
277
  }
278
+ /**
279
+ * Look up operation settings for a given generatorId, path and method.
280
+ * @param { generatorId, path, method }
281
+ * @returns Base settings for operation
282
+ */
226
283
  toOperationBaseSettings({ generatorId, path, method }) {
227
284
  const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
228
285
  const operationSettings = generatorSettings && 'operations' in generatorSettings
@@ -239,18 +296,12 @@ class GenerateContext {
239
296
  };
240
297
  return baseSettings;
241
298
  }
242
- addFile(normalisedPath) {
243
- if (__classPrivateFieldGet(this, _GenerateContext_files, "f").has(normalisedPath)) {
244
- throw new Error(`File already exists: ${normalisedPath}`);
245
- }
246
- const newFile = {
247
- imports: new Map(),
248
- definitions: new Map(),
249
- generatorKeys: new Set()
250
- };
251
- __classPrivateFieldGet(this, _GenerateContext_files, "f").set(normalisedPath, newFile);
252
- return newFile;
253
- }
299
+ /**
300
+ * Perform one lookup of schema by `refName`.
301
+ * @param refName
302
+ * @returns Matching schema or ref
303
+ * @throws if schema is not found
304
+ */
254
305
  resolveSchemaRefOnce(refName) {
255
306
  const schema = this.oasDocument.components?.schemas?.[refName]?.resolveOnce();
256
307
  if (!schema) {
@@ -258,9 +309,15 @@ class GenerateContext {
258
309
  }
259
310
  return schema;
260
311
  }
261
- /** Produce external instance and return its name */
312
+ /**
313
+ * Check if definition name `name` in file with path `exportPath`
314
+ * has already been created and registered.
315
+ *
316
+ * @param { name, exportPath }
317
+ * @returns Matching definition if found or `undefined` otherwise
318
+ */
262
319
  findDefinition({ name, exportPath }) {
263
- return this.getFile(exportPath).definitions.get(name);
320
+ return __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_getFile).call(this, exportPath).definitions.get(name);
264
321
  }
265
322
  }
266
323
  exports.GenerateContext = GenerateContext;
@@ -323,6 +380,18 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMa
323
380
  });
324
381
  });
325
382
  }
383
+ }, _GenerateContext_getFile = function _GenerateContext_getFile(filePath, { throwIfNotFound = false } = {}) {
384
+ const normalisedPath = (0, mod_js_1.normalize)(filePath);
385
+ const currentFile = __classPrivateFieldGet(this, _GenerateContext_files, "f").get(normalisedPath);
386
+ if (!currentFile) {
387
+ if (throwIfNotFound) {
388
+ throw new Error(`File not found: '${normalisedPath}'`);
389
+ }
390
+ else {
391
+ return __classPrivateFieldGet(this, _GenerateContext_instances, "m", _GenerateContext_addFile).call(this, normalisedPath);
392
+ }
393
+ }
394
+ return currentFile;
326
395
  }, _GenerateContext_toModelBaseSettings = function _GenerateContext_toModelBaseSettings({ generatorId, refName }) {
327
396
  const generatorSettings = this.settings?.generators?.find(({ id }) => id === generatorId);
328
397
  const modelSettings = generatorSettings && 'models' in generatorSettings
@@ -338,4 +407,15 @@ _GenerateContext_files = new WeakMap(), _GenerateContext_stackTrail = new WeakMa
338
407
  importFrom: modelSettings?.importFrom
339
408
  };
340
409
  return baseSettings;
410
+ }, _GenerateContext_addFile = function _GenerateContext_addFile(normalisedPath) {
411
+ if (__classPrivateFieldGet(this, _GenerateContext_files, "f").has(normalisedPath)) {
412
+ throw new Error(`File already exists: ${normalisedPath}`);
413
+ }
414
+ const newFile = {
415
+ imports: new Map(),
416
+ definitions: new Map(),
417
+ generatorKeys: new Set()
418
+ };
419
+ __classPrivateFieldGet(this, _GenerateContext_files, "f").set(normalisedPath, newFile);
420
+ return newFile;
341
421
  };
@@ -7,16 +7,40 @@ export type ArrayFields = {
7
7
  nullable?: boolean;
8
8
  uniqueItems?: boolean;
9
9
  };
10
+ /**
11
+ * Object representing an array in the OpenAPI Specification.
12
+ */
10
13
  export declare class OasArray {
11
- #private;
12
- oasType: 'schema';
13
- type: 'array';
14
+ /**
15
+ * Object is part the 'schema' set which is used
16
+ * to define data types in an OpenAPI document.
17
+ */
18
+ oasType: "schema";
19
+ /**
20
+ * Constant value 'array' useful for type narrowing and tagged unions.
21
+ */
22
+ type: "array";
23
+ /**
24
+ * Defines the type of items in the array.
25
+ */
26
+ items: OasSchema | OasRef<'schema'>;
27
+ /**
28
+ * A short summary of the array.
29
+ */
30
+ title: string | undefined;
31
+ /**
32
+ * A description of the array.
33
+ */
34
+ description: string | undefined;
35
+ /**
36
+ * Indicates whether value can be null.
37
+ */
38
+ nullable: boolean | undefined;
39
+ /**
40
+ * Indicates whether the array items must be unique.
41
+ */
42
+ uniqueItems: boolean | undefined;
14
43
  constructor(fields: ArrayFields);
15
- get items(): OasSchema | OasRef<'schema'>;
16
- get title(): string | undefined;
17
- get description(): string | undefined;
18
- get nullable(): boolean | undefined;
19
- get uniqueItems(): boolean | undefined;
20
44
  isRef(): this is OasRef<'schema'>;
21
45
  resolve(): OasArray;
22
46
  resolveOnce(): OasArray;
@@ -1 +1 @@
1
- {"version":3,"file":"Array.d.ts","sourceRoot":"","sources":["../../../src/oas/array/Array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED,qBAAa,QAAQ;;IACnB,OAAO,EAAE,QAAQ,CAAW;IAC5B,IAAI,EAAE,OAAO,CAAU;gBAGX,MAAM,EAAE,WAAW;IAI/B,IAAI,KAAK,IAAI,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAExC;IAED,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;IAED,IAAI,WAAW,IAAI,OAAO,GAAG,SAAS,CAErC;IAED,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,QAAQ;IAInB,WAAW,IAAI,QAAQ;CAGxB"}
1
+ {"version":3,"file":"Array.d.ts","sourceRoot":"","sources":["../../../src/oas/array/Array.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB,CAAA;AAED;;GAEG;AACH,qBAAa,QAAQ;IACnB;;;OAGG;IACH,OAAO,WAAoB;IAC3B;;OAEG;IACH,IAAI,UAAmB;IACvB;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAA;IACnC;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/B;;OAEG;IACH,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAA;IAC7B;;OAEG;IACH,WAAW,EAAE,OAAO,GAAG,SAAS,CAAA;gBAEpB,MAAM,EAAE,WAAW;IAQ/B,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,QAAQ;IAInB,WAAW,IAAI,QAAQ;CAGxB"}
@@ -1,49 +1,80 @@
1
1
  "use strict";
2
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
3
- if (kind === "m") throw new TypeError("Private method is not writable");
4
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
5
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
6
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
7
- };
8
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
9
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
10
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
11
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
12
- };
13
- var _OasArray_fields;
14
2
  Object.defineProperty(exports, "__esModule", { value: true });
15
3
  exports.OasArray = void 0;
4
+ /**
5
+ * Object representing an array in the OpenAPI Specification.
6
+ */
16
7
  class OasArray {
17
8
  constructor(fields) {
9
+ /**
10
+ * Object is part the 'schema' set which is used
11
+ * to define data types in an OpenAPI document.
12
+ */
18
13
  Object.defineProperty(this, "oasType", {
19
14
  enumerable: true,
20
15
  configurable: true,
21
16
  writable: true,
22
17
  value: 'schema'
23
18
  });
19
+ /**
20
+ * Constant value 'array' useful for type narrowing and tagged unions.
21
+ */
24
22
  Object.defineProperty(this, "type", {
25
23
  enumerable: true,
26
24
  configurable: true,
27
25
  writable: true,
28
26
  value: 'array'
29
27
  });
30
- _OasArray_fields.set(this, void 0);
31
- __classPrivateFieldSet(this, _OasArray_fields, fields, "f");
32
- }
33
- get items() {
34
- return __classPrivateFieldGet(this, _OasArray_fields, "f").items;
35
- }
36
- get title() {
37
- return __classPrivateFieldGet(this, _OasArray_fields, "f").title;
38
- }
39
- get description() {
40
- return __classPrivateFieldGet(this, _OasArray_fields, "f").description;
41
- }
42
- get nullable() {
43
- return __classPrivateFieldGet(this, _OasArray_fields, "f").nullable;
44
- }
45
- get uniqueItems() {
46
- return __classPrivateFieldGet(this, _OasArray_fields, "f").uniqueItems;
28
+ /**
29
+ * Defines the type of items in the array.
30
+ */
31
+ Object.defineProperty(this, "items", {
32
+ enumerable: true,
33
+ configurable: true,
34
+ writable: true,
35
+ value: void 0
36
+ });
37
+ /**
38
+ * A short summary of the array.
39
+ */
40
+ Object.defineProperty(this, "title", {
41
+ enumerable: true,
42
+ configurable: true,
43
+ writable: true,
44
+ value: void 0
45
+ });
46
+ /**
47
+ * A description of the array.
48
+ */
49
+ Object.defineProperty(this, "description", {
50
+ enumerable: true,
51
+ configurable: true,
52
+ writable: true,
53
+ value: void 0
54
+ });
55
+ /**
56
+ * Indicates whether value can be null.
57
+ */
58
+ Object.defineProperty(this, "nullable", {
59
+ enumerable: true,
60
+ configurable: true,
61
+ writable: true,
62
+ value: void 0
63
+ });
64
+ /**
65
+ * Indicates whether the array items must be unique.
66
+ */
67
+ Object.defineProperty(this, "uniqueItems", {
68
+ enumerable: true,
69
+ configurable: true,
70
+ writable: true,
71
+ value: void 0
72
+ });
73
+ this.items = fields.items;
74
+ this.title = fields.title;
75
+ this.description = fields.description;
76
+ this.nullable = fields.nullable;
77
+ this.uniqueItems = fields.uniqueItems;
47
78
  }
48
79
  isRef() {
49
80
  return false;
@@ -56,4 +87,3 @@ class OasArray {
56
87
  }
57
88
  }
58
89
  exports.OasArray = OasArray;
59
- _OasArray_fields = new WeakMap();
@@ -4,14 +4,32 @@ export type BooleanFields = {
4
4
  description?: string;
5
5
  nullable?: boolean;
6
6
  };
7
+ /**
8
+ * Object representing a boolean in the OpenAPI Specification.
9
+ */
7
10
  export declare class OasBoolean {
8
- #private;
9
- oasType: 'schema';
10
- type: 'boolean';
11
+ /**
12
+ * Object is part the 'schema' set which is used
13
+ * to define data types in an OpenAPI document.
14
+ */
15
+ oasType: "schema";
16
+ /**
17
+ * Constant value 'boolean' useful for type narrowing and tagged unions.
18
+ */
19
+ type: "boolean";
20
+ /**
21
+ * A short summary of the boolean.
22
+ */
23
+ title: string | undefined;
24
+ /**
25
+ * A description of the boolean.
26
+ */
27
+ description: string | undefined;
28
+ /**
29
+ * Indicates whether value can be null.
30
+ */
31
+ nullable: boolean | undefined;
11
32
  constructor(fields: BooleanFields);
12
- get title(): string | undefined;
13
- get description(): string | undefined;
14
- get nullable(): boolean | undefined;
15
33
  isRef(): this is OasRef<'schema'>;
16
34
  resolve(): OasBoolean;
17
35
  resolveOnce(): OasBoolean;
@@ -1 +1 @@
1
- {"version":3,"file":"Boolean.d.ts","sourceRoot":"","sources":["../../../src/oas/boolean/Boolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED,qBAAa,UAAU;;IACrB,OAAO,EAAE,QAAQ,CAAW;IAC5B,IAAI,EAAE,SAAS,CAAY;gBAGf,MAAM,EAAE,aAAa;IAIjC,IAAI,KAAK,IAAI,MAAM,GAAG,SAAS,CAE9B;IAED,IAAI,WAAW,IAAI,MAAM,GAAG,SAAS,CAEpC;IAED,IAAI,QAAQ,IAAI,OAAO,GAAG,SAAS,CAElC;IAED,KAAK,IAAI,IAAI,IAAI,MAAM,CAAC,QAAQ,CAAC;IAIjC,OAAO,IAAI,UAAU;IAIrB,WAAW,IAAI,UAAU;CAG1B"}
1
+ {"version":3,"file":"Boolean.d.ts","sourceRoot":"","sources":["../../../src/oas/boolean/Boolean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,eAAe,CAAA;AAE3C,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,EAAE,OAAO,CAAA;CACnB,CAAA;AAED;;GAEG;AACH,qBAAa,UAAU;IACrB;;;OAGG;IACH,OAAO,WAAoB;IAC3B;;OAEG;IACH,IAAI,YAAqB;IACzB;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,SAAS,CAAA;IACzB;;OAEG;IACH,WAAW,EAAE,MAAM,GAAG,SAAS,CAAA;IAC/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