Skip to content

Commit

Permalink
Merge pull request #118 from mauriciabad/patch-1
Browse files Browse the repository at this point in the history
fix: use `with` instead of `assert` in the import attributes
  • Loading branch information
radist2s authored Aug 6, 2024
2 parents dbb5c1a + 04caeff commit 3414b96
Show file tree
Hide file tree
Showing 124 changed files with 416 additions and 318 deletions.
6 changes: 6 additions & 0 deletions .changeset/kind-schools-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@openapi-qraft/plugin": patch
"@openapi-qraft/react": patch
---

Update import attributes syntax to use `with` instead of `assert`.
11 changes: 9 additions & 2 deletions .prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@
"trailingComma": "es5",
"importOrderCaseInsensitive": true,
"importOrderSeparation": true,
"importOrder": ["^react(.*)$","^@(.*)$", "<THIRD_PARTY_MODULES>", "^[./]"],
"importOrder": [
"<TYPES>^(node:)",
"<TYPES>",
"<TYPES>^[.]",
"<BUILTIN_MODULES>",
"<THIRD_PARTY_MODULES>",
"^[.]"
],
"importOrderParserPlugins": ["importAssertions", "typescript", "jsx"],
"plugins": ["@trivago/prettier-plugin-sort-imports"]
"plugins": ["@ianvs/prettier-plugin-sort-imports"]
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
},
"devDependencies": {
"@changesets/cli": "^2.27.1",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"prettier": "^3.1.1",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"prettier": "^3.3.3",
"turbo": "^2.0.4",
"typescript": "^5.3.3"
},
Expand Down
1 change: 0 additions & 1 deletion packages/cli/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import openAPIQraftConfig from '@openapi-qraft/eslint-config/eslint.vanilla.config';

import globals from 'globals';

export default [
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/bin.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, expect, it } from 'vitest';

import { extractArgvPluginOptions } from './bin.js';

describe('bin', () => {
Expand Down
6 changes: 2 additions & 4 deletions packages/cli/src/bin.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/usr/bin/env node
import { QraftCommand } from '@openapi-qraft/plugin/lib/QraftCommand';
import type { QraftCommandPlugin } from '@openapi-qraft/plugin/lib/QraftCommandPlugin';

import { Option } from 'commander';
import process from 'node:process';

import { QraftCommand } from '@openapi-qraft/plugin/lib/QraftCommand';
import { Option } from 'commander';
import { builtInPlugins } from './builtInPlugins.js';

export async function main() {
Expand Down
1 change: 0 additions & 1 deletion packages/openapi-typescript-plugin/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import openAPIQraftConfig from '@openapi-qraft/eslint-config/eslint.vanilla.config';

import globals from 'globals';

export default [
Expand Down
11 changes: 3 additions & 8 deletions packages/openapi-typescript-plugin/src/generateSchemaTypes.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { createConfig } from '@redocly/openapi-core';

import type { Readable } from 'node:stream';
import openapiTS, {
astToString,
type OpenAPI3,
type OpenAPITSOptions,
SchemaObject,
} from 'openapi-typescript';
import type { OpenAPI3, OpenAPITSOptions } from 'openapi-typescript';
import { createConfig } from '@redocly/openapi-core';
import openapiTS, { astToString, SchemaObject } from 'openapi-typescript';
import ts from 'typescript';

export async function generateSchemaTypes(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, expect, it } from 'vitest';

import { createOpenapiTypesImportPath } from './createOpenapiTypesImportPath.js';

describe('createOpenapiTypesImportPath', () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/openapi-typescript-plugin/src/plugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import '@openapi-qraft/plugin/lib/vitestFsMock';

import fs from 'node:fs';
import { createRequire } from 'node:module';
import { describe, expect, it, test } from 'vitest';

import { openapiTypesFileNameOptionParser } from './plugin.js';

describe('openapi-typescript types generation', () => {
Expand Down
2 changes: 0 additions & 2 deletions packages/openapi-typescript-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { fileHeader } from '@openapi-qraft/plugin/lib/fileHeader';
import { formatFileHeader } from '@openapi-qraft/plugin/lib/formatFileHeader';
import { QraftCommandPlugin } from '@openapi-qraft/plugin/lib/QraftCommandPlugin';

import { CommanderError } from 'commander';

import { generateSchemaTypes } from './generateSchemaTypes.js';
import {
createOpenapiTypesImportPath,
Expand Down
1 change: 0 additions & 1 deletion packages/plugin/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import openAPIQraftConfig from '@openapi-qraft/eslint-config/eslint.vanilla.config';

import globals from 'globals';

export default [
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin/src/lib/QraftCommand.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, it, expect } from 'vitest';

import { describe, expect, it } from 'vitest';
import { QraftCommand, splitOptionFlags } from './QraftCommand.js';

describe('QraftCommand', () => {
Expand Down
13 changes: 7 additions & 6 deletions packages/plugin/src/lib/QraftCommand.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
import c from 'ansi-colors';
import { Command, type Option } from 'commander';
import type { Option } from 'commander';
import type { Service } from './open-api/getServices.js';
import * as console from 'node:console';
import { sep } from 'node:path';
import process from 'node:process';
import { pathToFileURL, URL } from 'node:url';
import c from 'ansi-colors';
import { Command } from 'commander';
import ora, { Ora } from 'ora';

import { parsePathGlobs } from './createServicePathMatch.js';
import { filterDocumentPaths } from './filterDocumentPaths.js';
import { GeneratorFile } from './GeneratorFile.js';
import { handleSchemaInput } from './handleSchemaInput.js';
import { getServices, type Service } from './open-api/getServices.js';
import { getServices } from './open-api/getServices.js';
import { OpenAPISchemaType } from './open-api/OpenAPISchemaType.js';
import { readSchema } from './open-api/readSchema.js';
import { OutputOptions } from './OutputOptions.js';
import {
parseOperationPredefinedParametersOption,
createPredefinedParametersGlobMap,
parseOperationPredefinedParametersOption,
predefineSchemaParameters,
} from './predefineSchemaParameters.js';
import { writeGeneratorFiles } from './writeGeneratorFiles.js';
Expand Down Expand Up @@ -75,7 +76,7 @@ export class QraftCommand extends Command {
const { version: packageVersion } = await import(
'@openapi-qraft/plugin/package.json',
{
assert: { type: 'json' },
with: { type: 'json' },
}
).then(({ default: packageJSON }) => packageJSON);

Expand Down
3 changes: 1 addition & 2 deletions packages/plugin/src/lib/filterDocumentPaths.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, it, expect } from 'vitest';

import { describe, expect, it } from 'vitest';
import { createServicePathMatch } from './createServicePathMatch.js';

describe('createServicePathMatch', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin/src/lib/filterDocumentPaths.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { type OpenAPI3 } from 'openapi-typescript/src/types.js';

import { createServicePathMatch } from './createServicePathMatch.js';

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/lib/handleSchemaInput.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Ora } from 'ora';
import process from 'node:process';
import { URL } from 'node:url';
import type { Ora } from 'ora';

/**
* Validates Schema's `input` and return `Readable` stream or `URL`
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin/src/lib/open-api/getOperationName.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, it, expect } from 'vitest';

import { describe, expect, it } from 'vitest';
import { getOperationName } from './getOperationName.js';

describe('getOperationName', () => {
Expand Down
1 change: 0 additions & 1 deletion packages/plugin/src/lib/open-api/getServiceName.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, expect, it } from 'vitest';

import { getServiceName } from './getServiceName.js';

describe('getServiceName', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, expect, it } from 'vitest';

import {
getEndpointPartIndex,
getServiceBaseNameByOperationEndpoint,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { describe, expect, it } from 'vitest';

import { getServiceNamesByOperationTags } from './getServiceNamesByOperationTags.js';

describe('getServiceNamesByOperationTags(...)', () => {
Expand Down
4 changes: 1 addition & 3 deletions packages/plugin/src/lib/open-api/getServices.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import openAPI from '@openapi-qraft/test-fixtures/openapi.json' assert { type: 'json' };

import openAPI from '@openapi-qraft/test-fixtures/openapi.json' with { type: 'json' };
import { describe, expect, it } from 'vitest';

import { filterDocumentPaths } from '../filterDocumentPaths.js';
import { getServices } from './getServices.js';

Expand Down
3 changes: 1 addition & 2 deletions packages/plugin/src/lib/open-api/getServices.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import type { OpenAPISchemaType } from './OpenAPISchemaType.js';
import camelCase from 'camelcase';

import { getContentMediaType } from './getContent.js';
import { getOperationName } from './getOperationName.js';
import {
getServiceNamesByOperationEndpoint,
ServiceBaseNameByEndpointOption,
} from './getServiceNamesByOperationEndpoint.js';
import { getServiceNamesByOperationTags } from './getServiceNamesByOperationTags.js';
import type { OpenAPISchemaType } from './OpenAPISchemaType.js';

export type ServiceBaseName = ServiceBaseNameByEndpointOption | 'tags';

Expand Down
3 changes: 1 addition & 2 deletions packages/plugin/src/lib/open-api/readSchema.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createConfig } from '@redocly/openapi-core';

import type { Readable } from 'node:stream';
import type { OpenAPI3 } from 'openapi-typescript';
import { createConfig } from '@redocly/openapi-core';
import { validateAndBundle } from 'openapi-typescript/dist/lib/redoc.js';

export const readSchema = async (
Expand Down
6 changes: 2 additions & 4 deletions packages/plugin/src/lib/predefineSchemaParameters.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import openAPI from '@openapi-qraft/test-fixtures/openapi.json' assert { type: 'json' };

import { describe, it, expect } from 'vitest';

import openAPI from '@openapi-qraft/test-fixtures/openapi.json' with { type: 'json' };
import { describe, expect, it } from 'vitest';
import {
assertIsOperationObject,
assertIsParameterObjects,
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin/src/lib/predefineSchemaParameters.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import type { OpenAPI3 } from 'openapi-typescript/src/types.js';
import { OperationObject, ParameterObject } from 'openapi-typescript';
import {
type OpenAPI3,
PathItemObject,
ReferenceObject,
} from 'openapi-typescript/src/types.js';

import {
createServicePathMatch,
parsePathGlobs,
Expand Down
3 changes: 1 addition & 2 deletions packages/plugin/src/lib/writeGeneratorFiles.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import c from 'ansi-colors';
import fs from 'node:fs';
import c from 'ansi-colors';
import { Ora } from 'ora';

import { GeneratorFile } from './GeneratorFile.js';

export const writeGeneratorFiles = async ({
Expand Down
1 change: 0 additions & 1 deletion packages/react-client/eslint.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import openAPIQraftConfig from '@openapi-qraft/eslint-config/eslint.vanilla.config';

import globals from 'globals';

export default [
Expand Down
2 changes: 1 addition & 1 deletion packages/react-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"globals": "^15.0.0",
"jsdom": "latest",
"msw": "^2.0.12",
"prettier": "^3.1.1",
"prettier": "^3.3.3",
"query-string": "^8.1.0",
"react": "^18.2.0",
"rimraf": "^5.0.5",
Expand Down
3 changes: 1 addition & 2 deletions packages/react-client/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { rollupConfig } from '@openapi-qraft/rollup-config';

import packageJson from './package.json' assert { type: 'json' };
import packageJson from './package.json' with { type: 'json' };

const moduleDist = {
import: packageJson['exports']['.']['import'],
Expand Down
4 changes: 1 addition & 3 deletions packages/react-client/src/QraftContext.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
'use client';

import { createContext } from 'react';

import type { QueryClient } from '@tanstack/react-query';

import type { OperationSchema, RequestFnPayload } from './lib/requestFn.js';
import { createContext } from 'react';

interface QraftContextValueBase {
/**
Expand Down
3 changes: 1 addition & 2 deletions packages/react-client/src/ServiceOperation.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import type { DefaultError } from '@tanstack/query-core';

import type {
ServiceOperationQuery as ServiceOperationQueryBase,
ServiceOperationMutation as ServiceOperationMutationBase,
ServiceOperationQuery as ServiceOperationQueryBase,
} from './service-operation/ServiceOperation.js';
import type {
ServiceOperationInfiniteQueryKey as ServiceOperationInfiniteQueryKeyBase,
Expand Down
14 changes: 4 additions & 10 deletions packages/react-client/src/Unstable_QraftSecureRequestFn.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
'use client';

import { createElement, Fragment, ReactNode, useEffect, useMemo } from 'react';

import {
QueryClient,
type QueryFunctionContext,
type QueryKey,
useQueries,
} from '@tanstack/react-query';

import { jwtDecode } from './lib/jwt-decode/index.js';
import type { QueryFunctionContext, QueryKey } from '@tanstack/react-query';
import type {
OperationSchema,
RequestFnInfo,
RequestFnOptions,
} from './lib/requestFn.js';
import { QueryClient, useQueries } from '@tanstack/react-query';
import { createElement, Fragment, ReactNode, useEffect, useMemo } from 'react';
import { jwtDecode } from './lib/jwt-decode/index.js';

interface QraftSecureRequestFnBaseProps {
requestFn<T>(
Expand Down
2 changes: 1 addition & 1 deletion packages/react-client/src/callbacks/cancelQueries.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { callQueryClientMethodWithQueryFilters } from '../lib/callQueryClientMethodWithQueryFilters.js';
import type { OperationSchema } from '../lib/requestFn.js';
import type { QraftClientOptions } from '../qraftAPIClient.js';
import type { ServiceOperationCancelQueriesCallback } from '../service-operation/ServiceOperationCancelQueries.js';
import { callQueryClientMethodWithQueryFilters } from '../lib/callQueryClientMethodWithQueryFilters.js';

export function cancelQueries<TData>(
qraftOptions: QraftClientOptions | undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-client/src/callbacks/fetchInfiniteQuery.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientFetchMethod.js';
import type { QraftClientOptions } from '../qraftAPIClient.js';
import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientFetchMethod.js';
import { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';

export const fetchInfiniteQuery: <
Expand Down
2 changes: 1 addition & 1 deletion packages/react-client/src/callbacks/fetchQuery.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientFetchMethod.js';
import type { QraftClientOptions } from '../qraftAPIClient.js';
import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientFetchMethod.js';
import { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';

export const fetchQuery: <
Expand Down
3 changes: 1 addition & 2 deletions packages/react-client/src/callbacks/getInfiniteQueryData.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import type { InfiniteData } from '@tanstack/query-core';

import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientMethodWithQueryKey.js';
import type { OperationSchema } from '../lib/requestFn.js';
import type { QraftClientOptions } from '../qraftAPIClient.js';
import type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';
import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientMethodWithQueryKey.js';

export function getInfiniteQueryData<TData>(
_: QraftClientOptions | undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-client/src/callbacks/getInfiniteQueryKey.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { composeInfiniteQueryKey } from '../lib/composeInfiniteQueryKey.js';
import type { OperationSchema } from '../lib/requestFn.js';
import type { QraftClientOptions } from '../qraftAPIClient.js';
import { composeInfiniteQueryKey } from '../lib/composeInfiniteQueryKey.js';
import { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';

export const getInfiniteQueryKey = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientMethodWithQueryKey.js';
import type { OperationSchema } from '../lib/requestFn.js';
import type { QraftClientOptions } from '../qraftAPIClient.js';
import type { ServiceOperationQuery } from '../service-operation/ServiceOperation.js';
import { callQueryClientMethodWithQueryKey } from '../lib/callQueryClientMethodWithQueryKey.js';

export function getInfiniteQueryState<TData>(
_: QraftClientOptions | undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-client/src/callbacks/getMutationKey.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { composeMutationKey } from '../lib/composeMutationKey.js';
import type { OperationSchema } from '../lib/requestFn.js';
import type { QraftClientOptions } from '../qraftAPIClient.js';
import { composeMutationKey } from '../lib/composeMutationKey.js';
import { ServiceOperationMutation } from '../service-operation/ServiceOperation.js';

export const getMutationKey = (
Expand Down
Loading

0 comments on commit 3414b96

Please sign in to comment.