sofa-api 0.18.5 → 0.18.7

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.
package/cjs/index.js CHANGED
@@ -2,10 +2,10 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpenAPI = void 0;
4
4
  exports.useSofa = useSofa;
5
- const router_1 = require("./router");
6
- const sofa_1 = require("./sofa");
7
- var open_api_1 = require("./open-api");
8
- Object.defineProperty(exports, "OpenAPI", { enumerable: true, get: function () { return open_api_1.OpenAPI; } });
5
+ const router_js_1 = require("./router.js");
6
+ const sofa_js_1 = require("./sofa.js");
7
+ var index_js_1 = require("./open-api/index.js");
8
+ Object.defineProperty(exports, "OpenAPI", { enumerable: true, get: function () { return index_js_1.OpenAPI; } });
9
9
  function useSofa(config) {
10
- return (0, router_1.createRouter)((0, sofa_1.createSofa)(config));
10
+ return (0, router_js_1.createRouter)((0, sofa_js_1.createSofa)(config));
11
11
  }
@@ -2,9 +2,9 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpenAPI = OpenAPI;
4
4
  const graphql_1 = require("graphql");
5
- const types_1 = require("./types");
6
- const operations_1 = require("./operations");
7
- const utils_1 = require("./utils");
5
+ const types_js_1 = require("./types.js");
6
+ const operations_js_1 = require("./operations.js");
7
+ const utils_js_1 = require("./utils.js");
8
8
  function OpenAPI({ schema, info, servers, components, security, tags, customScalars = {}, }) {
9
9
  const types = schema.getTypeMap();
10
10
  const swagger = {
@@ -21,7 +21,7 @@ function OpenAPI({ schema, info, servers, components, security, tags, customScal
21
21
  const type = types[typeName];
22
22
  if (((0, graphql_1.isObjectType)(type) || (0, graphql_1.isInputObjectType)(type)) &&
23
23
  !(0, graphql_1.isIntrospectionType)(type)) {
24
- swagger.components.schemas[typeName] = (0, types_1.buildSchemaObjectFromType)(type, {
24
+ swagger.components.schemas[typeName] = (0, types_js_1.buildSchemaObjectFromType)(type, {
25
25
  customScalars,
26
26
  });
27
27
  }
@@ -39,12 +39,12 @@ function OpenAPI({ schema, info, servers, components, security, tags, customScal
39
39
  addRoute(info, config) {
40
40
  const basePath = config?.basePath || '';
41
41
  const path = basePath +
42
- (0, utils_1.normalizePathParamForOpenAPI)(info.path);
42
+ (0, utils_js_1.normalizePathParamForOpenAPI)(info.path);
43
43
  if (!swagger.paths[path]) {
44
44
  swagger.paths[path] = {};
45
45
  }
46
46
  const pathsObj = swagger.paths[path];
47
- pathsObj[info.method.toLowerCase()] = (0, operations_1.buildPathFromOperation)({
47
+ pathsObj[info.method.toLowerCase()] = (0, operations_js_1.buildPathFromOperation)({
48
48
  url: path,
49
49
  operation: info.document,
50
50
  schema,
@@ -7,12 +7,12 @@ exports.resolveResponse = resolveResponse;
7
7
  exports.isInPath = isInPath;
8
8
  exports.resolveVariableDescription = resolveVariableDescription;
9
9
  const graphql_1 = require("graphql");
10
- const ast_1 = require("../ast");
11
- const utils_1 = require("./utils");
12
- const types_1 = require("./types");
10
+ const ast_js_1 = require("../ast.js");
11
+ const utils_js_1 = require("./utils.js");
12
+ const types_js_1 = require("./types.js");
13
13
  const title_case_1 = require("title-case");
14
14
  function buildPathFromOperation({ url, schema, operation, useRequestBody, tags, description, customScalars, }) {
15
- const info = (0, ast_1.getOperationInfo)(operation);
15
+ const info = (0, ast_js_1.getOperationInfo)(operation);
16
16
  const enumTypes = resolveEnumTypes(schema);
17
17
  const summary = resolveDescription(schema, info.operation);
18
18
  const variables = info.operation.variableDefinitions;
@@ -112,10 +112,10 @@ function resolveParamSchema(type, opts) {
112
112
  items: resolveParamSchema(type.type, opts),
113
113
  };
114
114
  }
115
- const primitive = (0, utils_1.mapToPrimitive)(type.name.value);
115
+ const primitive = (0, utils_js_1.mapToPrimitive)(type.name.value);
116
116
  return (primitive ||
117
117
  opts.customScalars[type.name.value] ||
118
- opts.enumTypes[type.name.value] || { $ref: (0, utils_1.mapToRef)(type.name.value) });
118
+ opts.enumTypes[type.name.value] || { $ref: (0, utils_js_1.mapToRef)(type.name.value) });
119
119
  }
120
120
  function resolveResponse({ schema, operation, opts, }) {
121
121
  const operationType = operation.operation;
@@ -124,12 +124,12 @@ function resolveResponse({ schema, operation, opts, }) {
124
124
  if (operationType === 'query') {
125
125
  const queryType = schema.getQueryType();
126
126
  const field = queryType.getFields()[rootField.name.value];
127
- return (0, types_1.resolveFieldType)(field.type, opts);
127
+ return (0, types_js_1.resolveFieldType)(field.type, opts);
128
128
  }
129
129
  if (operationType === 'mutation') {
130
130
  const mutationType = schema.getMutationType();
131
131
  const field = mutationType.getFields()[rootField.name.value];
132
- return (0, types_1.resolveFieldType)(field.type, opts);
132
+ return (0, types_js_1.resolveFieldType)(field.type, opts);
133
133
  }
134
134
  }
135
135
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.buildSchemaObjectFromType = buildSchemaObjectFromType;
4
4
  exports.resolveFieldType = resolveFieldType;
5
5
  const graphql_1 = require("graphql");
6
- const utils_1 = require("./utils");
6
+ const utils_js_1 = require("./utils.js");
7
7
  function buildSchemaObjectFromType(type, opts) {
8
8
  const required = [];
9
9
  const properties = {};
@@ -43,11 +43,11 @@ function resolveFieldType(type, opts) {
43
43
  }
44
44
  if ((0, graphql_1.isObjectType)(type)) {
45
45
  return {
46
- $ref: (0, utils_1.mapToRef)(type.name),
46
+ $ref: (0, utils_js_1.mapToRef)(type.name),
47
47
  };
48
48
  }
49
49
  if ((0, graphql_1.isScalarType)(type)) {
50
- const resolved = (0, utils_1.mapToPrimitive)(type.name) ||
50
+ const resolved = (0, utils_js_1.mapToPrimitive)(type.name) ||
51
51
  opts.customScalars[type.name] ||
52
52
  type.extensions?.jsonSchema || {
53
53
  type: 'object',
package/cjs/router.js CHANGED
@@ -4,7 +4,7 @@ exports.createRouter = createRouter;
4
4
  const graphql_1 = require("graphql");
5
5
  const utils_1 = require("@graphql-tools/utils");
6
6
  const ast_js_1 = require("./ast.js");
7
- const common_1 = require("./common");
7
+ const common_js_1 = require("./common.js");
8
8
  const parse_js_1 = require("./parse.js");
9
9
  const subscriptions_js_1 = require("./subscriptions.js");
10
10
  const logger_js_1 = require("./logger.js");
@@ -387,7 +387,7 @@ function useHandler(config) {
387
387
  };
388
388
  }
389
389
  function getPath(fieldName, hasId = false) {
390
- return `/${(0, common_1.convertName)(fieldName)}${hasId ? '/:id' : ''}`;
390
+ return `/${(0, common_js_1.convertName)(fieldName)}${hasId ? '/:id' : ''}`;
391
391
  }
392
392
  function pickParam({ name, url, params, body, }) {
393
393
  if (name in params) {
package/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { createRouter } from './router';
2
- import { createSofa } from './sofa';
3
- export { OpenAPI } from './open-api';
1
+ import { createRouter } from './router.js';
2
+ import { createSofa } from './sofa.js';
3
+ export { OpenAPI } from './open-api/index.js';
4
4
  export function useSofa(config) {
5
5
  return createRouter(createSofa(config));
6
6
  }
@@ -1,7 +1,7 @@
1
1
  import { isObjectType, isInputObjectType, isIntrospectionType, } from 'graphql';
2
- import { buildSchemaObjectFromType } from './types';
3
- import { buildPathFromOperation } from './operations';
4
- import { normalizePathParamForOpenAPI } from './utils';
2
+ import { buildSchemaObjectFromType } from './types.js';
3
+ import { buildPathFromOperation } from './operations.js';
4
+ import { normalizePathParamForOpenAPI } from './utils.js';
5
5
  export function OpenAPI({ schema, info, servers, components, security, tags, customScalars = {}, }) {
6
6
  const types = schema.getTypeMap();
7
7
  const swagger = {
@@ -1,7 +1,7 @@
1
1
  import { isEnumType, Kind, parse, printType, } from 'graphql';
2
- import { getOperationInfo } from '../ast';
3
- import { mapToPrimitive, mapToRef } from './utils';
4
- import { resolveFieldType } from './types';
2
+ import { getOperationInfo } from '../ast.js';
3
+ import { mapToPrimitive, mapToRef } from './utils.js';
4
+ import { resolveFieldType } from './types.js';
5
5
  import { titleCase } from 'title-case';
6
6
  export function buildPathFromOperation({ url, schema, operation, useRequestBody, tags, description, customScalars, }) {
7
7
  const info = getOperationInfo(operation);
@@ -1,5 +1,5 @@
1
1
  import { isNonNullType, isListType, isObjectType, isScalarType, isEnumType, isUnionType, } from 'graphql';
2
- import { mapToPrimitive, mapToRef } from './utils';
2
+ import { mapToPrimitive, mapToRef } from './utils.js';
3
3
  export function buildSchemaObjectFromType(type, opts) {
4
4
  const required = [];
5
5
  const properties = {};
package/esm/router.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { isObjectType, isNonNullType, Kind, isIntrospectionType, isInputObjectType, isEnumType, } from 'graphql';
2
2
  import { buildOperationNodeForField, createGraphQLError } from '@graphql-tools/utils';
3
3
  import { getOperationInfo } from './ast.js';
4
- import { convertName } from './common';
4
+ import { convertName } from './common.js';
5
5
  import { parseVariable } from './parse.js';
6
6
  import { SubscriptionManager } from './subscriptions.js';
7
7
  import { logger } from './logger.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sofa-api",
3
- "version": "0.18.5",
3
+ "version": "0.18.7",
4
4
  "description": "Create REST APIs with GraphQL",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
@@ -1,5 +1,5 @@
1
- import type { SofaConfig } from './sofa';
2
- export { OpenAPI } from './open-api';
1
+ import type { SofaConfig } from './sofa.cjs';
2
+ export { OpenAPI } from './open-api/index.cjs';
3
3
  export declare function useSofa(config: SofaConfig): import("fets").Router<any, {}, {
4
4
  [TKey: string]: never;
5
5
  }>;
@@ -1,5 +1,5 @@
1
- import type { SofaConfig } from './sofa';
2
- export { OpenAPI } from './open-api';
1
+ import type { SofaConfig } from './sofa.js';
2
+ export { OpenAPI } from './open-api/index.js';
3
3
  export declare function useSofa(config: SofaConfig): import("fets").Router<any, {}, {
4
4
  [TKey: string]: never;
5
5
  }>;
@@ -1,5 +1,5 @@
1
1
  import { GraphQLSchema } from 'graphql';
2
- import { RouteInfo } from '../types';
2
+ import { RouteInfo } from '../types.cjs';
3
3
  import { OpenAPIV3 } from 'openapi-types';
4
4
  export declare function OpenAPI({ schema, info, servers, components, security, tags, customScalars, }: {
5
5
  schema: GraphQLSchema;
@@ -1,5 +1,5 @@
1
1
  import { GraphQLSchema } from 'graphql';
2
- import { RouteInfo } from '../types';
2
+ import { RouteInfo } from '../types.js';
3
3
  import { OpenAPIV3 } from 'openapi-types';
4
4
  export declare function OpenAPI({ schema, info, servers, components, security, tags, customScalars, }: {
5
5
  schema: GraphQLSchema;