@next-feature/client 0.1.0-MIGRATION.22.0.3 → 0.1.1

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,4 +1,4 @@
1
- export default {
1
+ module.exports = {
2
2
  displayName: 'client',
3
3
  preset: '../../jest.preset.js',
4
4
  transform: {
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "@next-feature/client",
3
- "version": "0.1.0-MIGRATION.22.0.3",
3
+ "version": "0.1.1",
4
4
  "main": "./index.js",
5
5
  "types": "./index.d.ts",
6
6
  "exports": {
7
7
  ".": {
8
8
  "import": "./index.mjs",
9
9
  "require": "./index.js"
10
+ },
11
+ "./server": {
12
+ "types": "./dist/server.d.ts",
13
+ "import": "./dist/server.js",
14
+ "default": "./dist/server.js"
10
15
  }
11
16
  }
12
17
  }
package/project.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "executor": "@nx/jest:jest",
26
26
  "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
27
27
  "options": {
28
- "jestConfig": "clients/client/jest.config.ts"
28
+ "jestConfig": "clients/client/jest.config.cts"
29
29
  }
30
30
  }
31
31
  }
package/src/lib/client.ts CHANGED
@@ -60,7 +60,7 @@ export class ApiClient {
60
60
  }
61
61
  },
62
62
  onAuthenticated: async (config) => {
63
- console.log('Authenticated', config.baseURL);
63
+ console.log('Authenticated', config.data);
64
64
  },
65
65
  onRefreshToken: async () => {
66
66
  return '';
package/src/lib/error.ts CHANGED
@@ -21,7 +21,7 @@ export class ApiError extends Error {
21
21
  constructor(
22
22
  public status: HttpStatusCode,
23
23
  public problemDetail: ProblemDetail | null,
24
- public originalError: Error,
24
+ public originalError?: Error,
25
25
  message?: string
26
26
  ) {
27
27
  super(
@@ -59,7 +59,7 @@ export class ApiError extends Error {
59
59
  return new ApiErrorBuilder<T>();
60
60
  }
61
61
 
62
- static of(error: Error) {
62
+ static of(error: Error): ApiError {
63
63
  if (error instanceof ApiError) {
64
64
  return error;
65
65
  }
@@ -83,7 +83,7 @@ export class ApiError extends Error {
83
83
  .originalError(zodError)
84
84
  .status(HttpStatusCode.BadRequest)
85
85
  .message('Validation error')
86
- .problemDetail('errors', errors)
86
+ .detail('errors', errors)
87
87
  .build();
88
88
  }
89
89
  }
@@ -91,7 +91,7 @@ export class ApiError extends Error {
91
91
  export class ApiErrorBuilder<
92
92
  AdditionalProblemDetails = Record<string, unknown>
93
93
  > {
94
- private readonly _problemDetail: ProblemDetail;
94
+ private _problemDetail: ProblemDetail;
95
95
  private _status: HttpStatusCode;
96
96
  private _originalError: Error;
97
97
  private _message: string;
@@ -108,7 +108,7 @@ export class ApiErrorBuilder<
108
108
  /**
109
109
  * Set standard ProblemDetail fields
110
110
  */
111
- problemDetail<K extends keyof (ProblemDetail & AdditionalProblemDetails)>(
111
+ detail<K extends keyof (ProblemDetail & AdditionalProblemDetails)>(
112
112
  key: K,
113
113
  value: K extends keyof ProblemDetail
114
114
  ? ProblemDetail[K]
@@ -120,6 +120,18 @@ export class ApiErrorBuilder<
120
120
  return this;
121
121
  }
122
122
 
123
+ /**
124
+ * Set standard ProblemDetail fields
125
+ */
126
+ problemDetail(
127
+ problemDetail: ProblemDetail
128
+ ): ApiErrorBuilder<AdditionalProblemDetails> {
129
+ if (problemDetail) {
130
+ this._problemDetail = problemDetail;
131
+ }
132
+ return this;
133
+ }
134
+
123
135
  originalError(error: Error): ApiErrorBuilder<AdditionalProblemDetails> {
124
136
  this._originalError = error;
125
137
  this._problemDetail.title = error.name;
package/tsconfig.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "allowJs": false,
5
5
  "esModuleInterop": false,
6
6
  "allowSyntheticDefaultImports": true,
7
- "types": ["vite/client"]
7
+ "types": ["vite/client", "node"]
8
8
  },
9
9
  "files": [],
10
10
  "include": [],
package/tsconfig.lib.json CHANGED
@@ -21,6 +21,7 @@
21
21
  "**/*.spec.jsx",
22
22
  "**/*.test.jsx",
23
23
  "jest.config.ts",
24
+ "jest.config.cts",
24
25
  "src/**/*.spec.ts",
25
26
  "src/**/*.test.ts"
26
27
  ],
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "include": [
11
11
  "jest.config.ts",
12
+ "jest.config.cts",
12
13
  "src/**/*.test.ts",
13
14
  "src/**/*.spec.ts",
14
15
  "src/**/*.test.tsx",
package/vite.config.ts CHANGED
@@ -16,6 +16,7 @@ export default defineConfig(() => ({
16
16
  dts({
17
17
  entryRoot: 'src',
18
18
  tsconfigPath: path.join(__dirname, 'tsconfig.lib.json'),
19
+ pathsToAliases: false,
19
20
  }),
20
21
  ],
21
22
  // Uncomment this if you are using workers.
@@ -33,9 +34,11 @@ export default defineConfig(() => ({
33
34
  },
34
35
  lib: {
35
36
  // Could also be a dictionary or array of multiple entry points.
36
- entry: 'src/index.ts',
37
+ entry: {
38
+ index: 'src/index.ts',
39
+ },
37
40
  name: 'client',
38
- fileName: 'index',
41
+ fileName: (format, entryName) => `${entryName}.js`,
39
42
  // Change this to the formats you want to support.
40
43
  // Don't forget to update your package.json as well.
41
44
  formats: ['es' as const],