@skmtc/core 0.0.369 → 0.0.370

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.
@@ -1,5 +1,6 @@
1
1
  /**
2
- * An abstract interface which when implemented provides an interface to read bytes into an array buffer asynchronously.
2
+ * An abstract interface which when implemented provides an interface to read
3
+ * bytes into an array buffer asynchronously.
3
4
  */
4
5
  export interface Reader {
5
6
  /** Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
@@ -28,7 +29,8 @@ export interface Reader {
28
29
  read(p: Uint8Array): Promise<number | null>;
29
30
  }
30
31
  /**
31
- * An abstract interface which when implemented provides an interface to read bytes into an array buffer synchronously.
32
+ * An abstract interface which when implemented provides an interface to read
33
+ * bytes into an array buffer synchronously.
32
34
  */
33
35
  export interface ReaderSync {
34
36
  /** Reads up to `p.byteLength` bytes into `p`. It resolves to the number
@@ -56,7 +58,8 @@ export interface ReaderSync {
56
58
  readSync(p: Uint8Array): number | null;
57
59
  }
58
60
  /**
59
- * An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource asynchronously.
61
+ * An abstract interface which when implemented provides an interface to write
62
+ * bytes from an array buffer to a file/resource asynchronously.
60
63
  */
61
64
  export interface Writer {
62
65
  /** Writes `p.byteLength` bytes from `p` to the underlying data stream. It
@@ -71,7 +74,8 @@ export interface Writer {
71
74
  write(p: Uint8Array): Promise<number>;
72
75
  }
73
76
  /**
74
- * An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource synchronously.
77
+ * An abstract interface which when implemented provides an interface to write
78
+ * bytes from an array buffer to a file/resource synchronously.
75
79
  */
76
80
  export interface WriterSync {
77
81
  /** Writes `p.byteLength` bytes from `p` to the underlying data
@@ -86,10 +90,57 @@ export interface WriterSync {
86
90
  writeSync(p: Uint8Array): number;
87
91
  }
88
92
  /**
89
- * An abstract interface which when implemented provides an interface to close files/resources that were previously opened.
93
+ * An abstract interface which when implemented provides an interface to close
94
+ * files/resources that were previously opened.
90
95
  */
91
96
  export interface Closer {
92
97
  /** Closes the resource, "freeing" the backing file/resource. */
93
98
  close(): void;
94
99
  }
100
+ /**
101
+ * A enum which defines the seek mode for IO related APIs that support
102
+ * seeking.
103
+ */
104
+ export declare enum SeekMode {
105
+ Start = 0,
106
+ Current = 1,
107
+ End = 2
108
+ }
109
+ /**
110
+ * An abstract interface which when implemented provides an interface to seek
111
+ * within an open file/resource asynchronously.
112
+ */
113
+ export interface Seeker {
114
+ /** Seek sets the offset for the next `read()` or `write()` to offset,
115
+ * interpreted according to `whence`: `Start` means relative to the
116
+ * start of the file, `Current` means relative to the current offset,
117
+ * and `End` means relative to the end. Seek resolves to the new offset
118
+ * relative to the start of the file.
119
+ *
120
+ * Seeking to an offset before the start of the file is an error. Seeking to
121
+ * any positive offset is legal, but the behavior of subsequent I/O
122
+ * operations on the underlying object is implementation-dependent.
123
+ *
124
+ * It resolves with the updated offset.
125
+ */
126
+ seek(offset: number | bigint, whence: SeekMode): Promise<number>;
127
+ }
128
+ /**
129
+ * An abstract interface which when implemented provides an interface to seek
130
+ * within an open file/resource synchronously.
131
+ */
132
+ export interface SeekerSync {
133
+ /** Seek sets the offset for the next `readSync()` or `writeSync()` to
134
+ * offset, interpreted according to `whence`: `Start` means relative
135
+ * to the start of the file, `Current` means relative to the current
136
+ * offset, and `End` means relative to the end.
137
+ *
138
+ * Seeking to an offset before the start of the file is an error. Seeking to
139
+ * any positive offset is legal, but the behavior of subsequent I/O
140
+ * operations on the underlying object is implementation-dependent.
141
+ *
142
+ * It returns the updated offset.
143
+ */
144
+ seekSync(offset: number | bigint, whence: SeekMode): number;
145
+ }
95
146
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.8/types.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;OAQG;IACH,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvC;AACD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;OAQG;IACH,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,gEAAgE;IAChE,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,oBAAY,QAAQ;IAElB,KAAK,IAAI;IAET,OAAO,IAAI;IAEX,GAAG,IAAI;CACR;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClE;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC7D"}
@@ -0,0 +1,15 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ /**
4
+ * A enum which defines the seek mode for IO related APIs that support
5
+ * seeking.
6
+ */
7
+ export var SeekMode;
8
+ (function (SeekMode) {
9
+ /* Seek from the start of the file/resource. */
10
+ SeekMode[SeekMode["Start"] = 0] = "Start";
11
+ /* Seek from the current position within the file/resource. */
12
+ SeekMode[SeekMode["Current"] = 1] = "Current";
13
+ /* Seek from the end of the current file/resource. */
14
+ SeekMode[SeekMode["End"] = 2] = "End";
15
+ })(SeekMode || (SeekMode = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"write_all.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.7/write_all.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,iBAK9D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,QAKhE"}
1
+ {"version":3,"file":"write_all.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.8/write_all.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,iBAK9D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,QAKhE"}
@@ -8,7 +8,7 @@ var _FileHandler_instances, _FileHandler_unloadCallback, _FileHandler_resetBuffe
8
8
  import * as dntShim from "../../../../../_dnt.shims.js";
9
9
  import { LogLevels } from "./levels.js";
10
10
  import { BaseHandler } from "./base_handler.js";
11
- import { writeAllSync } from "../../io/0.224.7/write_all.js";
11
+ import { writeAllSync } from "../../io/0.224.8/write_all.js";
12
12
  import { bufSymbol, encoderSymbol, filenameSymbol, fileSymbol, modeSymbol, openOptionsSymbol, pointerSymbol, } from "./_file_handler_symbols.js";
13
13
  /**
14
14
  * This handler will output to a file using an optional mode (default is `a`,
@@ -1 +1 @@
1
- {"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../src/server/createServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAK3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAiBnE,eAAO,MAAM,YAAY,eACX,CAAC,gBAAgB,GAAG,YAAY,CAAC,EAAE,KAC9C,IAwGF,CAAA"}
1
+ {"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../src/server/createServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAK3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAkBnE,eAAO,MAAM,YAAY,eACX,CAAC,gBAAgB,GAAG,YAAY,CAAC,EAAE,KAC9C,IA0GF,CAAA"}
@@ -6,6 +6,7 @@ import { clientSettings as settingsSchema } from '../types/Settings.js';
6
6
  import { transform } from '../transform/transform.js';
7
7
  import { CoreContext } from '../context/CoreContext.js';
8
8
  const postSettingsBody = z.object({
9
+ defaultSelected: z.boolean().optional(),
9
10
  schema: z.string(),
10
11
  clientSettings: settingsSchema.optional()
11
12
  });
@@ -44,13 +45,12 @@ export const createServer = (generators) => {
44
45
  app.post('/settings', async (c) => {
45
46
  return await Sentry.startSpan({ name: 'POST /settings' }, async (span) => {
46
47
  const body = await c.req.json();
47
- const { clientSettings } = postSettingsBody.parse(body);
48
+ const { clientSettings, defaultSelected = false } = postSettingsBody.parse(body);
48
49
  const oasDocument = toOasDocument({
49
50
  schema: body.schema,
50
51
  spanId: span.spanContext().spanId
51
52
  });
52
53
  const out = generators.map(generator => {
53
- console.log('Generator', generator);
54
54
  const generatorSettings = clientSettings?.generators.find(({ id }) => id === generator.id);
55
55
  const generatorType = generator.type;
56
56
  return match(generatorType)
@@ -60,6 +60,7 @@ export const createServer = (generators) => {
60
60
  operations: toOperations({
61
61
  generator: generator,
62
62
  oasDocument,
63
+ defaultSelected,
63
64
  operationsSettings: generatorSettings && 'operations' in generatorSettings
64
65
  ? generatorSettings.operations
65
66
  : undefined
@@ -70,6 +71,7 @@ export const createServer = (generators) => {
70
71
  id: generator.id,
71
72
  models: toModels({
72
73
  oasDocument,
74
+ defaultSelected,
73
75
  modelsSettings: generatorSettings && 'models' in generatorSettings
74
76
  ? generatorSettings.models
75
77
  : undefined
@@ -84,15 +86,15 @@ export const createServer = (generators) => {
84
86
  });
85
87
  return app;
86
88
  };
87
- const toModels = ({ oasDocument, modelsSettings }) => {
89
+ const toModels = ({ defaultSelected, oasDocument, modelsSettings }) => {
88
90
  return Object.fromEntries(Object.keys(oasDocument.components?.schemas ?? {}).map(refName => [
89
91
  refName,
90
92
  modelsSettings?.[refName]
91
93
  ? modelsSettings?.[refName]
92
- : { selected: false }
94
+ : { selected: defaultSelected }
93
95
  ]));
94
96
  };
95
- const toOperations = ({ generator, oasDocument, operationsSettings }) => {
97
+ const toOperations = ({ generator, oasDocument, operationsSettings, defaultSelected }) => {
96
98
  return Object.values(oasDocument.operations)
97
99
  .filter(operation => generator.isSupported(operation))
98
100
  .reduce((acc, operation) => {
@@ -100,7 +102,7 @@ const toOperations = ({ generator, oasDocument, operationsSettings }) => {
100
102
  acc[path] = acc[path] ?? {};
101
103
  acc[path][method] = operationsSettings?.[path]?.[method]
102
104
  ? operationsSettings?.[path]?.[method]
103
- : { selected: false };
105
+ : { selected: defaultSelected };
104
106
  return acc;
105
107
  }, {});
106
108
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skmtc/core",
3
- "version": "0.0.369",
3
+ "version": "0.0.370",
4
4
  "main": "./script/mod.js",
5
5
  "module": "./esm/mod.js",
6
6
  "exports": {
@@ -1,5 +1,6 @@
1
1
  /**
2
- * An abstract interface which when implemented provides an interface to read bytes into an array buffer asynchronously.
2
+ * An abstract interface which when implemented provides an interface to read
3
+ * bytes into an array buffer asynchronously.
3
4
  */
4
5
  export interface Reader {
5
6
  /** Reads up to `p.byteLength` bytes into `p`. It resolves to the number of
@@ -28,7 +29,8 @@ export interface Reader {
28
29
  read(p: Uint8Array): Promise<number | null>;
29
30
  }
30
31
  /**
31
- * An abstract interface which when implemented provides an interface to read bytes into an array buffer synchronously.
32
+ * An abstract interface which when implemented provides an interface to read
33
+ * bytes into an array buffer synchronously.
32
34
  */
33
35
  export interface ReaderSync {
34
36
  /** Reads up to `p.byteLength` bytes into `p`. It resolves to the number
@@ -56,7 +58,8 @@ export interface ReaderSync {
56
58
  readSync(p: Uint8Array): number | null;
57
59
  }
58
60
  /**
59
- * An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource asynchronously.
61
+ * An abstract interface which when implemented provides an interface to write
62
+ * bytes from an array buffer to a file/resource asynchronously.
60
63
  */
61
64
  export interface Writer {
62
65
  /** Writes `p.byteLength` bytes from `p` to the underlying data stream. It
@@ -71,7 +74,8 @@ export interface Writer {
71
74
  write(p: Uint8Array): Promise<number>;
72
75
  }
73
76
  /**
74
- * An abstract interface which when implemented provides an interface to write bytes from an array buffer to a file/resource synchronously.
77
+ * An abstract interface which when implemented provides an interface to write
78
+ * bytes from an array buffer to a file/resource synchronously.
75
79
  */
76
80
  export interface WriterSync {
77
81
  /** Writes `p.byteLength` bytes from `p` to the underlying data
@@ -86,10 +90,57 @@ export interface WriterSync {
86
90
  writeSync(p: Uint8Array): number;
87
91
  }
88
92
  /**
89
- * An abstract interface which when implemented provides an interface to close files/resources that were previously opened.
93
+ * An abstract interface which when implemented provides an interface to close
94
+ * files/resources that were previously opened.
90
95
  */
91
96
  export interface Closer {
92
97
  /** Closes the resource, "freeing" the backing file/resource. */
93
98
  close(): void;
94
99
  }
100
+ /**
101
+ * A enum which defines the seek mode for IO related APIs that support
102
+ * seeking.
103
+ */
104
+ export declare enum SeekMode {
105
+ Start = 0,
106
+ Current = 1,
107
+ End = 2
108
+ }
109
+ /**
110
+ * An abstract interface which when implemented provides an interface to seek
111
+ * within an open file/resource asynchronously.
112
+ */
113
+ export interface Seeker {
114
+ /** Seek sets the offset for the next `read()` or `write()` to offset,
115
+ * interpreted according to `whence`: `Start` means relative to the
116
+ * start of the file, `Current` means relative to the current offset,
117
+ * and `End` means relative to the end. Seek resolves to the new offset
118
+ * relative to the start of the file.
119
+ *
120
+ * Seeking to an offset before the start of the file is an error. Seeking to
121
+ * any positive offset is legal, but the behavior of subsequent I/O
122
+ * operations on the underlying object is implementation-dependent.
123
+ *
124
+ * It resolves with the updated offset.
125
+ */
126
+ seek(offset: number | bigint, whence: SeekMode): Promise<number>;
127
+ }
128
+ /**
129
+ * An abstract interface which when implemented provides an interface to seek
130
+ * within an open file/resource synchronously.
131
+ */
132
+ export interface SeekerSync {
133
+ /** Seek sets the offset for the next `readSync()` or `writeSync()` to
134
+ * offset, interpreted according to `whence`: `Start` means relative
135
+ * to the start of the file, `Current` means relative to the current
136
+ * offset, and `End` means relative to the end.
137
+ *
138
+ * Seeking to an offset before the start of the file is an error. Seeking to
139
+ * any positive offset is legal, but the behavior of subsequent I/O
140
+ * operations on the underlying object is implementation-dependent.
141
+ *
142
+ * It returns the updated offset.
143
+ */
144
+ seekSync(offset: number | bigint, whence: SeekMode): number;
145
+ }
95
146
  //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.8/types.ts"],"names":[],"mappings":"AAGA;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;CACxC;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;OAQG;IACH,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvC;AACD;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;OAQG;IACH,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAClC;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,gEAAgE;IAChE,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;GAGG;AACH,oBAAY,QAAQ;IAElB,KAAK,IAAI;IAET,OAAO,IAAI;IAEX,GAAG,IAAI;CACR;AAED;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;;;;OAWG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClE;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;OAUG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC;CAC7D"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
3
+ // This module is browser compatible.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.SeekMode = void 0;
6
+ /**
7
+ * A enum which defines the seek mode for IO related APIs that support
8
+ * seeking.
9
+ */
10
+ var SeekMode;
11
+ (function (SeekMode) {
12
+ /* Seek from the start of the file/resource. */
13
+ SeekMode[SeekMode["Start"] = 0] = "Start";
14
+ /* Seek from the current position within the file/resource. */
15
+ SeekMode[SeekMode["Current"] = 1] = "Current";
16
+ /* Seek from the end of the current file/resource. */
17
+ SeekMode[SeekMode["End"] = 2] = "End";
18
+ })(SeekMode || (exports.SeekMode = SeekMode = {}));
@@ -1 +1 @@
1
- {"version":3,"file":"write_all.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.7/write_all.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,iBAK9D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,QAKhE"}
1
+ {"version":3,"file":"write_all.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.8/write_all.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAErD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,iBAK9D;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,QAKhE"}
@@ -34,7 +34,7 @@ exports.FileHandler = void 0;
34
34
  const dntShim = __importStar(require("../../../../../_dnt.shims.js"));
35
35
  const levels_js_1 = require("./levels.js");
36
36
  const base_handler_js_1 = require("./base_handler.js");
37
- const write_all_js_1 = require("../../io/0.224.7/write_all.js");
37
+ const write_all_js_1 = require("../../io/0.224.8/write_all.js");
38
38
  const _file_handler_symbols_js_1 = require("./_file_handler_symbols.js");
39
39
  /**
40
40
  * This handler will output to a file using an optional mode (default is `a`,
@@ -1 +1 @@
1
- {"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../src/server/createServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAK3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAiBnE,eAAO,MAAM,YAAY,eACX,CAAC,gBAAgB,GAAG,YAAY,CAAC,EAAE,KAC9C,IAwGF,CAAA"}
1
+ {"version":3,"file":"createServer.d.ts","sourceRoot":"","sources":["../../src/server/createServer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAA;AAK3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAA;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAkBnE,eAAO,MAAM,YAAY,eACX,CAAC,gBAAgB,GAAG,YAAY,CAAC,EAAE,KAC9C,IA0GF,CAAA"}
@@ -32,6 +32,7 @@ const Settings_js_1 = require("../types/Settings.js");
32
32
  const transform_js_1 = require("../transform/transform.js");
33
33
  const CoreContext_js_1 = require("../context/CoreContext.js");
34
34
  const postSettingsBody = zod_1.z.object({
35
+ defaultSelected: zod_1.z.boolean().optional(),
35
36
  schema: zod_1.z.string(),
36
37
  clientSettings: Settings_js_1.clientSettings.optional()
37
38
  });
@@ -70,13 +71,12 @@ const createServer = (generators) => {
70
71
  app.post('/settings', async (c) => {
71
72
  return await Sentry.startSpan({ name: 'POST /settings' }, async (span) => {
72
73
  const body = await c.req.json();
73
- const { clientSettings } = postSettingsBody.parse(body);
74
+ const { clientSettings, defaultSelected = false } = postSettingsBody.parse(body);
74
75
  const oasDocument = toOasDocument({
75
76
  schema: body.schema,
76
77
  spanId: span.spanContext().spanId
77
78
  });
78
79
  const out = generators.map(generator => {
79
- console.log('Generator', generator);
80
80
  const generatorSettings = clientSettings?.generators.find(({ id }) => id === generator.id);
81
81
  const generatorType = generator.type;
82
82
  return (0, ts_pattern_1.match)(generatorType)
@@ -86,6 +86,7 @@ const createServer = (generators) => {
86
86
  operations: toOperations({
87
87
  generator: generator,
88
88
  oasDocument,
89
+ defaultSelected,
89
90
  operationsSettings: generatorSettings && 'operations' in generatorSettings
90
91
  ? generatorSettings.operations
91
92
  : undefined
@@ -96,6 +97,7 @@ const createServer = (generators) => {
96
97
  id: generator.id,
97
98
  models: toModels({
98
99
  oasDocument,
100
+ defaultSelected,
99
101
  modelsSettings: generatorSettings && 'models' in generatorSettings
100
102
  ? generatorSettings.models
101
103
  : undefined
@@ -111,15 +113,15 @@ const createServer = (generators) => {
111
113
  return app;
112
114
  };
113
115
  exports.createServer = createServer;
114
- const toModels = ({ oasDocument, modelsSettings }) => {
116
+ const toModels = ({ defaultSelected, oasDocument, modelsSettings }) => {
115
117
  return Object.fromEntries(Object.keys(oasDocument.components?.schemas ?? {}).map(refName => [
116
118
  refName,
117
119
  modelsSettings?.[refName]
118
120
  ? modelsSettings?.[refName]
119
- : { selected: false }
121
+ : { selected: defaultSelected }
120
122
  ]));
121
123
  };
122
- const toOperations = ({ generator, oasDocument, operationsSettings }) => {
124
+ const toOperations = ({ generator, oasDocument, operationsSettings, defaultSelected }) => {
123
125
  return Object.values(oasDocument.operations)
124
126
  .filter(operation => generator.isSupported(operation))
125
127
  .reduce((acc, operation) => {
@@ -127,7 +129,7 @@ const toOperations = ({ generator, oasDocument, operationsSettings }) => {
127
129
  acc[path] = acc[path] ?? {};
128
130
  acc[path][method] = operationsSettings?.[path]?.[method]
129
131
  ? operationsSettings?.[path]?.[method]
130
- : { selected: false };
132
+ : { selected: defaultSelected };
131
133
  return acc;
132
134
  }, {});
133
135
  };
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.7/types.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;OAQG;IACH,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvC;AACD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;OAQG;IACH,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,gEAAgE;IAChE,KAAK,IAAI,IAAI,CAAC;CACf"}
@@ -1,3 +0,0 @@
1
- // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
- // This module is browser compatible.
3
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../../src/deps/jsr.io/@std/io/0.224.7/types.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,IAAI,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,GAAG,IAAI,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;;;;;;;OAQG;IACH,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACvC;AACD;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;;;;OAQG;IACH,SAAS,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB,gEAAgE;IAChE,KAAK,IAAI,IAAI,CAAC;CACf"}
@@ -1,4 +0,0 @@
1
- "use strict";
2
- // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
3
- // This module is browser compatible.
4
- Object.defineProperty(exports, "__esModule", { value: true });