@hypequery/react 0.7.1 → 0.8.0
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/dist/client.d.ts.map +1 -1
- package/dist/client.js +6 -1
- package/dist/errors.d.ts +8 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +12 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/utils/client-schema-changed.d.ts +3 -0
- package/dist/utils/client-schema-changed.d.ts.map +1 -0
- package/dist/utils/client-schema-changed.js +7 -0
- package/package.json +3 -3
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,GAAG,CAAC;IAAC,MAAM,EAAE,GAAG,CAAA;CAAE,CAAC,CAAC;AAEtE,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;AAE/D,KAAK,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AACpD,MAAM,MAAM,YAAY,GAAG,SAAS,GAAG,CAAC,MAAM,SA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GED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { clientSchemaHeaders } from './utils/client-schema-headers.js';
|
|
2
|
-
import { HttpError } from './errors.js';
|
|
2
|
+
import { ClientSchemaChangedError, HttpError } from './errors.js';
|
|
3
|
+
import { isClientSchemaChanged } from './utils/client-schema-changed.js';
|
|
3
4
|
const normalizeMethodConfig = (source) => {
|
|
4
5
|
if (!source)
|
|
5
6
|
return {};
|
|
@@ -116,6 +117,10 @@ export function createHypequeryClient(config) {
|
|
|
116
117
|
}
|
|
117
118
|
if (!response.ok) {
|
|
118
119
|
const errorBody = await parseResponse(response);
|
|
120
|
+
if (isClientSchemaChanged(response.status, errorBody)) {
|
|
121
|
+
throw new ClientSchemaChangedError(`${method} ${finalUrl}: the endpoint changed since this client was generated. `
|
|
122
|
+
+ 'Regenerate it with `hypequery generate:client --cloud --force` (or from your contract file) and review the changes.', errorBody);
|
|
123
|
+
}
|
|
119
124
|
throw new HttpError(`${method} request to ${finalUrl} failed with status ${response.status}`, response.status, errorBody);
|
|
120
125
|
}
|
|
121
126
|
return response.json();
|
package/dist/errors.d.ts
CHANGED
|
@@ -6,4 +6,12 @@ export declare class HttpError extends Error {
|
|
|
6
6
|
readonly body: unknown;
|
|
7
7
|
constructor(message: string, status: number, body: unknown);
|
|
8
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* The server's schema for this endpoint changed since the client was
|
|
11
|
+
* generated (`409 CLIENT_SCHEMA_CHANGED`). Retrying can't fix it: regenerate
|
|
12
|
+
* the client and review what changed.
|
|
13
|
+
*/
|
|
14
|
+
export declare class ClientSchemaChangedError extends HttpError {
|
|
15
|
+
constructor(message: string, body: unknown);
|
|
16
|
+
}
|
|
9
17
|
//# sourceMappingURL=errors.d.ts.map
|
package/dist/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;aAGhB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,OAAO;gBAF7B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO;CAOhC"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,SAAU,SAAQ,KAAK;aAGhB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,OAAO;gBAF7B,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO;CAOhC;AAED;;;;GAIG;AACH,qBAAa,wBAAyB,SAAQ,SAAS;gBACzC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAK3C"}
|
package/dist/errors.js
CHANGED
|
@@ -11,3 +11,15 @@ export class HttpError extends Error {
|
|
|
11
11
|
Object.setPrototypeOf(this, HttpError.prototype);
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The server's schema for this endpoint changed since the client was
|
|
16
|
+
* generated (`409 CLIENT_SCHEMA_CHANGED`). Retrying can't fix it: regenerate
|
|
17
|
+
* the client and review what changed.
|
|
18
|
+
*/
|
|
19
|
+
export class ClientSchemaChangedError extends HttpError {
|
|
20
|
+
constructor(message, body) {
|
|
21
|
+
super(message, 409, body);
|
|
22
|
+
this.name = 'ClientSchemaChangedError';
|
|
23
|
+
Object.setPrototypeOf(this, ClientSchemaChangedError.prototype);
|
|
24
|
+
}
|
|
25
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { createHooks, queryOptions } from './createHooks.js';
|
|
|
2
2
|
export { createAnalyticsHooks } from './analyticsHooks.js';
|
|
3
3
|
export { createHypequeryClient } from './client.js';
|
|
4
4
|
export { HypequeryProvider, useHypequeryClient } from './provider.js';
|
|
5
|
-
export { HttpError } from './errors.js';
|
|
5
|
+
export { ClientSchemaChangedError, HttpError } from './errors.js';
|
|
6
6
|
export type { QueryInput, QueryOutput, QueryOutputForInput, HttpMethod } from './types.js';
|
|
7
7
|
export type { CreateHooksConfig } from './createHooks.js';
|
|
8
8
|
export type { ApiContract, HeadersInput, HypequeryClient, HypequeryClientConfig, QueryMethodConfig, RouteManifest, RouteManifestEntry, TokenInput, } from './client.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC3F,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,YAAY,EACV,WAAW,EACX,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,iBAAiB,EACjB,aAAa,EACb,kBAAkB,EAClB,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAC5D,YAAY,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,4 @@ export { createHooks, queryOptions } from './createHooks.js';
|
|
|
2
2
|
export { createAnalyticsHooks } from './analyticsHooks.js';
|
|
3
3
|
export { createHypequeryClient } from './client.js';
|
|
4
4
|
export { HypequeryProvider, useHypequeryClient } from './provider.js';
|
|
5
|
-
export { HttpError } from './errors.js';
|
|
5
|
+
export { ClientSchemaChangedError, HttpError } from './errors.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-schema-changed.d.ts","sourceRoot":"","sources":["../../src/utils/client-schema-changed.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,GAAG,OAAO,CAI5E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Whether a response is the stale-client refusal of a generated endpoint. */
|
|
2
|
+
export function isClientSchemaChanged(status, body) {
|
|
3
|
+
if (status !== 409 || typeof body !== 'object' || body === null)
|
|
4
|
+
return false;
|
|
5
|
+
const error = body.error;
|
|
6
|
+
return error?.details?.code === 'CLIENT_SCHEMA_CHANGED';
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypequery/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Type-safe React and TanStack Query hooks for ClickHouse analytics, metrics, and datasets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"react-dom": "^19.3.1",
|
|
49
49
|
"typescript": "^6.0.3",
|
|
50
50
|
"vitest": "^5.0.5",
|
|
51
|
-
"@hypequery/datasets": "0.
|
|
52
|
-
"@hypequery/serve": "0.
|
|
51
|
+
"@hypequery/datasets": "0.28.0",
|
|
52
|
+
"@hypequery/serve": "0.24.2"
|
|
53
53
|
},
|
|
54
54
|
"repository": {
|
|
55
55
|
"type": "git",
|