@tim-smart/openapi-gen 0.4.2 → 0.4.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 (2) hide show
  1. package/main.js +72 -21
  2. package/package.json +1 -1
package/main.js CHANGED
@@ -7344,15 +7344,15 @@ var require_swagger2openapi = __commonJS({
7344
7344
  scheme.scheme = "basic";
7345
7345
  }
7346
7346
  if (scheme.type === "oauth2") {
7347
- let flow = {};
7347
+ let flow2 = {};
7348
7348
  let flowName = scheme.flow;
7349
7349
  if (scheme.flow === "application") flowName = "clientCredentials";
7350
7350
  if (scheme.flow === "accessCode") flowName = "authorizationCode";
7351
- if (typeof scheme.authorizationUrl !== "undefined") flow.authorizationUrl = scheme.authorizationUrl.split("?")[0].trim() || "/";
7352
- if (typeof scheme.tokenUrl === "string") flow.tokenUrl = scheme.tokenUrl.split("?")[0].trim() || "/";
7353
- flow.scopes = scheme.scopes || {};
7351
+ if (typeof scheme.authorizationUrl !== "undefined") flow2.authorizationUrl = scheme.authorizationUrl.split("?")[0].trim() || "/";
7352
+ if (typeof scheme.tokenUrl === "string") flow2.tokenUrl = scheme.tokenUrl.split("?")[0].trim() || "/";
7353
+ flow2.scopes = scheme.scopes || {};
7354
7354
  scheme.flows = {};
7355
- scheme.flows[flowName] = flow;
7355
+ scheme.flows[flowName] = flow2;
7356
7356
  delete scheme.flow;
7357
7357
  delete scheme.authorizationUrl;
7358
7358
  delete scheme.tokenUrl;
@@ -8556,6 +8556,45 @@ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi) {
8556
8556
  }
8557
8557
  }
8558
8558
  }
8559
+ function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
8560
+ switch (arguments.length) {
8561
+ case 1:
8562
+ return ab;
8563
+ case 2:
8564
+ return function() {
8565
+ return bc(ab.apply(this, arguments));
8566
+ };
8567
+ case 3:
8568
+ return function() {
8569
+ return cd(bc(ab.apply(this, arguments)));
8570
+ };
8571
+ case 4:
8572
+ return function() {
8573
+ return de(cd(bc(ab.apply(this, arguments))));
8574
+ };
8575
+ case 5:
8576
+ return function() {
8577
+ return ef(de(cd(bc(ab.apply(this, arguments)))));
8578
+ };
8579
+ case 6:
8580
+ return function() {
8581
+ return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
8582
+ };
8583
+ case 7:
8584
+ return function() {
8585
+ return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
8586
+ };
8587
+ case 8:
8588
+ return function() {
8589
+ return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
8590
+ };
8591
+ case 9:
8592
+ return function() {
8593
+ return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
8594
+ };
8595
+ }
8596
+ return;
8597
+ }
8559
8598
 
8560
8599
  // node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/esm/Equivalence.js
8561
8600
  var make = (isEquivalent) => (self, that) => self === that || isEquivalent(self, that);
@@ -19312,11 +19351,14 @@ var TaggedError = (tag4) => {
19312
19351
  };
19313
19352
 
19314
19353
  // node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/esm/String.js
19354
+ var isString2 = isString;
19315
19355
  var toUpperCase = (self) => self.toUpperCase();
19316
19356
  var capitalize = (self) => {
19317
19357
  if (self.length === 0) return self;
19318
19358
  return toUpperCase(self[0]) + self.slice(1);
19319
19359
  };
19360
+ var trim = (self) => self.trim();
19361
+ var isNonEmpty5 = (self) => self.length > 0;
19320
19362
 
19321
19363
  // node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/esm/internal/schedule.js
19322
19364
  var ScheduleSymbolKey = "effect/Schedule";
@@ -20624,10 +20666,10 @@ var formatUnknown = (u, checkCircular = true) => {
20624
20666
  }
20625
20667
  };
20626
20668
  var formatPropertyKey = (name2) => typeof name2 === "string" ? JSON.stringify(name2) : String(name2);
20627
- var isNonEmpty5 = (x) => Array.isArray(x);
20669
+ var isNonEmpty6 = (x) => Array.isArray(x);
20628
20670
  var isSingle = (x) => !Array.isArray(x);
20629
20671
  var formatPathKey = (key) => `[${formatPropertyKey(key)}]`;
20630
- var formatPath = (path2) => isNonEmpty5(path2) ? path2.map(formatPathKey).join("") : formatPathKey(path2);
20672
+ var formatPath = (path2) => isNonEmpty6(path2) ? path2.map(formatPathKey).join("") : formatPathKey(path2);
20631
20673
 
20632
20674
  // node_modules/.pnpm/effect@3.15.2/node_modules/effect/dist/esm/internal/schema/errors.js
20633
20675
  var getErrorMessage = (reason, details, path2, ast) => {
@@ -22895,7 +22937,7 @@ var formatTree = (issue) => {
22895
22937
  return right2(makeTree(message));
22896
22938
  }
22897
22939
  const parseIssueTitle = getParseIssueTitle(issue);
22898
- return isNonEmpty5(issue.issues) ? map18(forEach8(issue.issues, formatTree), (forest) => makeTree(parseIssueTitle, forest)) : map18(formatTree(issue.issues), (tree) => makeTree(parseIssueTitle, [tree]));
22940
+ return isNonEmpty6(issue.issues) ? map18(forEach8(issue.issues, formatTree), (forest) => makeTree(parseIssueTitle, forest)) : map18(formatTree(issue.issues), (tree) => makeTree(parseIssueTitle, [tree]));
22899
22941
  });
22900
22942
  }
22901
22943
  };
@@ -34761,6 +34803,19 @@ var camelize = (self) => {
34761
34803
  return str;
34762
34804
  };
34763
34805
  var identifier2 = (operationId) => capitalize(camelize(operationId));
34806
+ var nonEmptyString3 = flow(
34807
+ fromNullable,
34808
+ filter(isString2),
34809
+ map2(trim),
34810
+ filter(isNonEmpty5)
34811
+ );
34812
+ var toComment = match2({
34813
+ onNone: () => "",
34814
+ onSome: (description) => `/**
34815
+ * ${description.split("\n").join("\n* ")}
34816
+ */
34817
+ `
34818
+ });
34764
34819
 
34765
34820
  // src/JsonSchemaGen.ts
34766
34821
  var make64 = gen2(function* () {
@@ -34868,7 +34923,7 @@ var make64 = gen2(function* () {
34868
34923
  (source) => transformer.onTopLevel({
34869
34924
  importName,
34870
34925
  schema,
34871
- description: fromNullable(schema.description),
34926
+ description: nonEmptyString3(schema.description),
34872
34927
  name: name2,
34873
34928
  source,
34874
34929
  isClass,
@@ -34916,7 +34971,7 @@ var make64 = gen2(function* () {
34916
34971
  map2(
34917
34972
  (source) => transformer.onProperty({
34918
34973
  importName,
34919
- description: fromNullable(schema2.description),
34974
+ description: nonEmptyString3(schema2.description),
34920
34975
  key,
34921
34976
  source,
34922
34977
  isOptional,
@@ -35005,8 +35060,8 @@ var make64 = gen2(function* () {
35005
35060
  (_) => toSource(importName, _, currentIdentifier + "Enum").pipe(
35006
35061
  map2(
35007
35062
  (source) => ({
35008
- description: fromNullable(_.description),
35009
- title: fromNullable(_.title),
35063
+ description: nonEmptyString3(_.description),
35064
+ title: nonEmptyString3(_.title),
35010
35065
  source
35011
35066
  })
35012
35067
  )
@@ -35259,13 +35314,6 @@ export type ${name2} = (typeof ${name2})[keyof typeof ${name2}];` : `${toComment
35259
35314
  }
35260
35315
  })
35261
35316
  );
35262
- var toComment = match2({
35263
- onNone: () => "",
35264
- onSome: (description) => `/**
35265
- * ${description.split("\n").join("\n* ")}
35266
- */
35267
- `
35268
- });
35269
35317
  function mergeSchemas(self, other) {
35270
35318
  if ("properties" in self && "properties" in other) {
35271
35319
  return {
@@ -35414,6 +35462,9 @@ var make65 = gen2(function* () {
35414
35462
  const op = {
35415
35463
  id: camelize(operation.operationId),
35416
35464
  method,
35465
+ description: nonEmptyString3(operation.description).pipe(
35466
+ orElse(() => nonEmptyString3(operation.summary))
35467
+ ),
35417
35468
  pathIds,
35418
35469
  pathTemplate,
35419
35470
  urlParams: [],
@@ -35585,7 +35636,7 @@ ${clientErrorSource(name2)}`;
35585
35636
  )
35586
35637
  );
35587
35638
  }
35588
- return `readonly "${operation.id}": (${args2.join(", ")}) => Effect.Effect<${success}, ${errors.join(" | ")}>`;
35639
+ return `${toComment(operation.description)}readonly "${operation.id}": (${args2.join(", ")}) => Effect.Effect<${success}, ${errors.join(" | ")}>`;
35589
35640
  };
35590
35641
  const operationsToImpl = (name2, operations) => `export const make = (
35591
35642
  httpClient: HttpClient.HttpClient,
@@ -35716,7 +35767,7 @@ ${clientErrorSource(name2)}`;
35716
35767
  errors.push(`${name2}Error<"${schema}", ${schema}>`);
35717
35768
  }
35718
35769
  }
35719
- return `readonly "${operation.id}": (${args2.join(", ")}) => Effect.Effect<${success}, ${errors.join(" | ")}>`;
35770
+ return `${toComment(operation.description)}readonly "${operation.id}": (${args2.join(", ")}) => Effect.Effect<${success}, ${errors.join(" | ")}>`;
35720
35771
  };
35721
35772
  const operationsToImpl = (name2, operations) => `export const make = (
35722
35773
  httpClient: HttpClient.HttpClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tim-smart/openapi-gen",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "Generate Effect http clients from OpenAPI specs",
5
5
  "bin": "main.js",
6
6
  "repository": {