@honua/react 0.1.7-beta.0 → 0.1.10-beta.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/control-plane/admin-client.d.ts +89 -0
- package/control-plane/admin-client.d.ts.map +1 -0
- package/control-plane/admin-client.js +200 -0
- package/control-plane/client.d.ts +1 -1
- package/control-plane/client.d.ts.map +1 -1
- package/control-plane/client.js +145 -11
- package/control-plane/commands/catalog.d.ts +133 -0
- package/control-plane/commands/catalog.d.ts.map +1 -0
- package/control-plane/commands/catalog.js +365 -0
- package/control-plane/commands/errors.d.ts +96 -0
- package/control-plane/commands/errors.d.ts.map +1 -0
- package/control-plane/commands/errors.js +130 -0
- package/control-plane/commands/identity.d.ts +71 -0
- package/control-plane/commands/identity.d.ts.map +1 -0
- package/control-plane/commands/identity.js +0 -0
- package/control-plane/commands/index.d.ts +39 -0
- package/control-plane/commands/index.d.ts.map +1 -0
- package/control-plane/commands/index.js +34 -0
- package/control-plane/commands/runtime.d.ts +146 -0
- package/control-plane/commands/runtime.d.ts.map +1 -0
- package/control-plane/commands/runtime.js +330 -0
- package/control-plane/commands/types.d.ts +228 -0
- package/control-plane/commands/types.d.ts.map +1 -0
- package/control-plane/commands/types.js +30 -0
- package/control-plane/commands/validate.d.ts +27 -0
- package/control-plane/commands/validate.d.ts.map +1 -0
- package/control-plane/commands/validate.js +132 -0
- package/control-plane/generated/admin-api.d.ts +30265 -0
- package/control-plane/generated/admin-api.d.ts.map +1 -0
- package/control-plane/generated/admin-api.js +5 -0
- package/control-plane/generated/admin-operations.d.ts +4053 -0
- package/control-plane/generated/admin-operations.d.ts.map +1 -0
- package/control-plane/generated/admin-operations.js +820 -0
- package/control-plane/index.d.ts +11 -0
- package/control-plane/index.d.ts.map +1 -1
- package/control-plane/index.js +8 -0
- package/control-plane/types.d.ts +14 -0
- package/control-plane/types.d.ts.map +1 -1
- package/core/client.d.ts.map +1 -1
- package/core/client.js +29 -31
- package/core/credential-redaction.d.ts +163 -0
- package/core/credential-redaction.d.ts.map +1 -0
- package/core/credential-redaction.js +389 -0
- package/core/error-classifications.d.ts +15 -0
- package/core/error-classifications.d.ts.map +1 -1
- package/core/error-classifications.js +15 -0
- package/core/error-code-registry.d.ts +15 -0
- package/core/error-code-registry.d.ts.map +1 -1
- package/core/error-code-registry.js +15 -0
- package/core/error-envelope.d.ts +31 -0
- package/core/error-envelope.d.ts.map +1 -1
- package/core/error-envelope.js +11 -0
- package/core/errors.d.ts +15 -3
- package/core/errors.d.ts.map +1 -1
- package/core/errors.js +254 -2
- package/core/geometry-input-sr.d.ts +3 -0
- package/core/geometry-input-sr.d.ts.map +1 -0
- package/core/geometry-input-sr.js +28 -0
- package/core/geoservices.d.ts.map +1 -1
- package/core/geoservices.js +33 -6
- package/core/grpc-adapter.d.ts +2 -2
- package/core/grpc-adapter.d.ts.map +1 -1
- package/core/grpc-adapter.js +41 -9
- package/core/job-run-errors.d.ts +10 -0
- package/core/job-run-errors.d.ts.map +1 -0
- package/core/job-run-errors.js +14 -0
- package/core/job-run-lifecycle.d.ts +34 -0
- package/core/job-run-lifecycle.d.ts.map +1 -0
- package/core/job-run-lifecycle.js +193 -0
- package/core/ogc-processes.d.ts +38 -31
- package/core/ogc-processes.d.ts.map +1 -1
- package/core/ogc-processes.js +123 -173
- package/core/pbf-decoder.d.ts.map +1 -1
- package/core/pbf-decoder.js +16 -4
- package/core/process-runner.js +15 -100
- package/core/protocol-transport.d.ts +6 -1
- package/core/protocol-transport.d.ts.map +1 -1
- package/core/request-pipeline.d.ts +6 -3
- package/core/request-pipeline.d.ts.map +1 -1
- package/core/request-pipeline.js +28 -11
- package/core/spatial-filter.d.ts +4 -4
- package/core/spatial-filter.d.ts.map +1 -1
- package/core/spatial-filter.js +7 -7
- package/core/surfaces.d.ts +2 -8
- package/core/surfaces.d.ts.map +1 -1
- package/core/surfaces.js +21 -112
- package/core/types.d.ts +21 -9
- package/core/types.d.ts.map +1 -1
- package/esri-compat/class-breaks-renderer.d.ts +2 -0
- package/esri-compat/class-breaks-renderer.d.ts.map +1 -1
- package/esri-compat/class-breaks-renderer.js +7 -0
- package/esri-compat/controls.d.ts +10 -1
- package/esri-compat/controls.d.ts.map +1 -1
- package/esri-compat/controls.js +86 -2
- package/esri-compat/directions.d.ts +35 -0
- package/esri-compat/directions.d.ts.map +1 -1
- package/esri-compat/directions.js +153 -2
- package/esri-compat/expand.d.ts +1 -0
- package/esri-compat/expand.d.ts.map +1 -1
- package/esri-compat/expand.js +61 -0
- package/esri-compat/feature-layer.d.ts +29 -4
- package/esri-compat/feature-layer.d.ts.map +1 -1
- package/esri-compat/feature-layer.js +335 -13
- package/esri-compat/geometry-engine.d.ts +4 -0
- package/esri-compat/geometry-engine.d.ts.map +1 -1
- package/esri-compat/geometry-engine.js +8 -1
- package/esri-compat/graphic.d.ts +7 -4
- package/esri-compat/graphic.d.ts.map +1 -1
- package/esri-compat/legend.d.ts +2 -1
- package/esri-compat/legend.d.ts.map +1 -1
- package/esri-compat/legend.js +15 -0
- package/esri-compat/map-view-mount.d.ts +48 -0
- package/esri-compat/map-view-mount.d.ts.map +1 -0
- package/esri-compat/map-view-mount.js +344 -0
- package/esri-compat/map-view.d.ts +38 -6
- package/esri-compat/map-view.d.ts.map +1 -1
- package/esri-compat/map-view.js +467 -33
- package/esri-compat/portal.d.ts +2 -0
- package/esri-compat/portal.d.ts.map +1 -1
- package/esri-compat/portal.js +7 -2
- package/esri-compat/renderer-objects.d.ts +7 -2
- package/esri-compat/renderer-objects.d.ts.map +1 -1
- package/esri-compat/renderer-objects.js +16 -5
- package/esri-compat/route-layer.d.ts +8 -0
- package/esri-compat/route-layer.d.ts.map +1 -1
- package/esri-compat/route-layer.js +24 -4
- package/esri-compat/route-task.d.ts +5 -1
- package/esri-compat/route-task.d.ts.map +1 -1
- package/esri-compat/route-task.js +119 -7
- package/esri-compat/scene-view.d.ts.map +1 -1
- package/esri-compat/scene-view.js +1 -0
- package/esri-compat/search.d.ts +2 -1
- package/esri-compat/search.d.ts.map +1 -1
- package/esri-compat/search.js +52 -2
- package/esri-compat/unique-value-renderer.d.ts +2 -0
- package/esri-compat/unique-value-renderer.d.ts.map +1 -1
- package/esri-compat/unique-value-renderer.js +7 -0
- package/esri-compat/web-map.d.ts +10 -0
- package/esri-compat/web-map.d.ts.map +1 -1
- package/esri-compat/web-map.js +102 -0
- package/gen/geospatial/v1/common_pb.d.ts +514 -0
- package/gen/geospatial/v1/common_pb.d.ts.map +1 -0
- package/gen/geospatial/v1/common_pb.js +335 -0
- package/gen/geospatial/v1/execution_types_pb.d.ts +1186 -0
- package/gen/geospatial/v1/execution_types_pb.d.ts.map +1 -0
- package/gen/geospatial/v1/execution_types_pb.js +396 -0
- package/gen/geospatial/v1/feature_service_pb.d.ts +403 -0
- package/gen/geospatial/v1/feature_service_pb.d.ts.map +1 -0
- package/gen/geospatial/v1/feature_service_pb.js +47 -0
- package/gen/geospatial/v1/index.d.ts +5 -0
- package/gen/geospatial/v1/index.d.ts.map +1 -0
- package/gen/geospatial/v1/index.js +9 -0
- package/gen/geospatial/v1/spatial_types_pb.d.ts +285 -0
- package/gen/geospatial/v1/spatial_types_pb.d.ts.map +1 -0
- package/gen/geospatial/v1/spatial_types_pb.js +58 -0
- package/gen/geospatial/v1/workspace_artifact_types_pb.d.ts +379 -0
- package/gen/geospatial/v1/workspace_artifact_types_pb.d.ts.map +1 -0
- package/gen/geospatial/v1/workspace_artifact_types_pb.js +151 -0
- package/generated-app/projection.d.ts.map +1 -1
- package/generated-app/projection.js +10 -1
- package/map/webmap-maplibre.d.ts +2 -1
- package/map/webmap-maplibre.d.ts.map +1 -1
- package/map/webmap-maplibre.js +3 -0
- package/package.json +3 -3
- package/query-planner/geoservices.d.ts.map +1 -1
- package/query-planner/geoservices.js +2 -0
- package/query-planner/grpc.d.ts +4 -4
- package/query-planner/grpc.d.ts.map +1 -1
- package/query-planner/grpc.js +11 -11
- package/query-planner/types.d.ts +6 -4
- package/query-planner/types.d.ts.map +1 -1
- package/realtime/honua-server.d.ts +4 -0
- package/realtime/honua-server.d.ts.map +1 -1
- package/realtime/honua-server.js +10 -0
- package/realtime/resumable.js +9 -0
- package/realtime/types.d.ts +8 -0
- package/realtime/types.d.ts.map +1 -1
- package/runtime/errors.d.ts +1 -1
- package/runtime/errors.d.ts.map +1 -1
- package/runtime/errors.js +2 -0
- package/runtime/generated/map-package-schema-meta.d.ts +11 -0
- package/runtime/generated/map-package-schema-meta.d.ts.map +1 -0
- package/runtime/generated/map-package-schema-meta.js +12 -0
- package/runtime/generated/map-package-schema-validator.d.ts +16 -0
- package/runtime/generated/map-package-schema-validator.d.ts.map +1 -0
- package/runtime/generated/map-package-schema-validator.js +1422 -0
- package/runtime/index.d.ts +5 -1
- package/runtime/index.d.ts.map +1 -1
- package/runtime/index.js +6 -0
- package/runtime/map-package-export.d.ts +151 -0
- package/runtime/map-package-export.d.ts.map +1 -0
- package/runtime/map-package-export.js +636 -0
- package/runtime/map-package-validation.d.ts +21 -1
- package/runtime/map-package-validation.d.ts.map +1 -1
- package/runtime/map-package-validation.js +132 -95
- package/runtime/map-package.d.ts +80 -0
- package/runtime/map-package.d.ts.map +1 -1
- package/studio/capability-manifest.d.ts +10 -0
- package/studio/capability-manifest.d.ts.map +1 -1
- package/studio/capability-manifest.js +38 -0
- package/studio/chart-spec.d.ts +6 -6
- package/studio/chart-spec.d.ts.map +1 -1
- package/studio/chart-spec.js +6 -6
- package/studio/command-adapter.d.ts +35 -0
- package/studio/command-adapter.d.ts.map +1 -0
- package/studio/command-adapter.js +36 -0
- package/studio/generated/studio-api.d.ts +1062 -0
- package/studio/generated/studio-api.d.ts.map +1 -0
- package/studio/generated/studio-api.js +4 -0
- package/studio/index.d.ts +25 -13
- package/studio/index.d.ts.map +1 -1
- package/studio/index.js +21 -10
- package/studio/lifecycle-client.d.ts +262 -22
- package/studio/lifecycle-client.d.ts.map +1 -1
- package/studio/lifecycle-client.js +543 -24
- package/studio/lifecycle-errors.d.ts +8 -2
- package/studio/lifecycle-errors.d.ts.map +1 -1
- package/studio/lifecycle-errors.js +6 -1
- package/studio/lifecycle-types.d.ts +237 -38
- package/studio/lifecycle-types.d.ts.map +1 -1
- package/studio/lifecycle-types.js +5 -12
- package/studio/publication-status.d.ts +55 -0
- package/studio/publication-status.d.ts.map +1 -0
- package/studio/publication-status.js +103 -0
- package/studio/types.d.ts +37 -7
- package/studio/types.d.ts.map +1 -1
- package/studio/types.js +5 -3
- package/studio/validate.d.ts.map +1 -1
- package/studio/validate.js +104 -7
- package/style/renderers.d.ts +6 -1
- package/style/renderers.d.ts.map +1 -1
- package/style/renderers.js +11 -6
- package/style/visual-variables.d.ts +43 -0
- package/style/visual-variables.d.ts.map +1 -0
- package/style/visual-variables.js +183 -0
- package/webmap/convert-layer.d.ts +2 -1
- package/webmap/convert-layer.d.ts.map +1 -1
- package/webmap/convert-layer.js +20 -3
- package/webmap/convert-renderer.d.ts +10 -3
- package/webmap/convert-renderer.d.ts.map +1 -1
- package/webmap/convert-renderer.js +190 -36
- package/webmap/index.d.ts +1 -0
- package/webmap/index.d.ts.map +1 -1
- package/webmap/parse.d.ts +2 -1
- package/webmap/parse.d.ts.map +1 -1
- package/webmap/parse.js +1 -1
- package/gen/honua/v1/feature_service_pb.d.ts +0 -918
- package/gen/honua/v1/feature_service_pb.d.ts.map +0 -1
- package/gen/honua/v1/feature_service_pb.js +0 -375
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { operations } from "./generated/admin-api.js";
|
|
2
|
+
import { type AdminOperationId } from "./generated/admin-operations.js";
|
|
3
|
+
type Operation<Id extends AdminOperationId> = operations[Id];
|
|
4
|
+
type OperationParameters<Id extends AdminOperationId> = Operation<Id> extends {
|
|
5
|
+
parameters: infer Parameters;
|
|
6
|
+
} ? Parameters : never;
|
|
7
|
+
type ParameterValue<Id extends AdminOperationId, Kind extends "header" | "path" | "query"> = OperationParameters<Id> extends {
|
|
8
|
+
[Key in Kind]?: infer Value;
|
|
9
|
+
} ? Exclude<Value, undefined> : never;
|
|
10
|
+
type RequiredRequestBody<Id extends AdminOperationId> = Operation<Id> extends {
|
|
11
|
+
requestBody: infer RequestBody;
|
|
12
|
+
} ? RequestBody : never;
|
|
13
|
+
type OptionalRequestBody<Id extends AdminOperationId> = Operation<Id> extends {
|
|
14
|
+
requestBody?: infer RequestBody;
|
|
15
|
+
} ? Exclude<RequestBody, undefined> : never;
|
|
16
|
+
type RequestBodyContent<RequestBody> = RequestBody extends {
|
|
17
|
+
content: infer Content;
|
|
18
|
+
} ? Content : never;
|
|
19
|
+
type ContentValue<Content> = Content extends Record<PropertyKey, unknown> ? Content[keyof Content] : never;
|
|
20
|
+
export type AdminOperationRequestBody<Id extends AdminOperationId> = ContentValue<RequestBodyContent<RequiredRequestBody<Id> | OptionalRequestBody<Id>>>;
|
|
21
|
+
export type AdminOperationContentType<Id extends AdminOperationId> = Extract<keyof RequestBodyContent<RequiredRequestBody<Id> | OptionalRequestBody<Id>>, string>;
|
|
22
|
+
type OptionalField<Name extends string, Value> = [Value] extends [never] ? {
|
|
23
|
+
readonly [Key in Name]?: never;
|
|
24
|
+
} : {
|
|
25
|
+
readonly [Key in Name]?: Value;
|
|
26
|
+
};
|
|
27
|
+
type RequiredField<Name extends string, Value> = [Value] extends [never] ? {
|
|
28
|
+
readonly [Key in Name]?: never;
|
|
29
|
+
} : {
|
|
30
|
+
readonly [Key in Name]: Value;
|
|
31
|
+
};
|
|
32
|
+
type BodyField<Id extends AdminOperationId> = [RequiredRequestBody<Id>] extends [never] ? [OptionalRequestBody<Id>] extends [never] ? {
|
|
33
|
+
readonly body?: never;
|
|
34
|
+
readonly contentType?: never;
|
|
35
|
+
} : {
|
|
36
|
+
readonly body?: AdminOperationRequestBody<Id>;
|
|
37
|
+
readonly contentType?: AdminOperationContentType<Id>;
|
|
38
|
+
} : {
|
|
39
|
+
readonly body: AdminOperationRequestBody<Id>;
|
|
40
|
+
readonly contentType?: AdminOperationContentType<Id>;
|
|
41
|
+
};
|
|
42
|
+
export type AdminOperationRequest<Id extends AdminOperationId> = RequiredField<"path", ParameterValue<Id, "path">> & OptionalField<"query", ParameterValue<Id, "query">> & OptionalField<"headers", ParameterValue<Id, "header"> & HeadersInit> & BodyField<Id> & {
|
|
43
|
+
readonly signal?: AbortSignal;
|
|
44
|
+
};
|
|
45
|
+
type SuccessStatus<Status> = Status extends number ? `${Status}` extends `2${string}` ? Status : never : Status extends `${2}${string}` ? Status : never;
|
|
46
|
+
type ResponseContent<Response> = Response extends {
|
|
47
|
+
content: infer Content;
|
|
48
|
+
} ? ContentValue<Content> : undefined;
|
|
49
|
+
type SuccessResponsePayload<Responses> = {
|
|
50
|
+
[Status in keyof Responses]: SuccessStatus<Status> extends never ? never : ResponseContent<Responses[Status]>;
|
|
51
|
+
}[keyof Responses];
|
|
52
|
+
export type AdminOperationResponse<Id extends AdminOperationId> = Operation<Id> extends {
|
|
53
|
+
responses: infer Responses;
|
|
54
|
+
} ? SuccessResponsePayload<Responses> : never;
|
|
55
|
+
export interface AdminClientOptions {
|
|
56
|
+
readonly baseUrl: string;
|
|
57
|
+
/** Scoped API key; sent as `X-API-Key`. */
|
|
58
|
+
readonly apiKey?: string;
|
|
59
|
+
/** Root/admin key. Takes precedence over `apiKey`. */
|
|
60
|
+
readonly adminKey?: string;
|
|
61
|
+
readonly basePath?: string;
|
|
62
|
+
readonly fetchFn?: typeof fetch;
|
|
63
|
+
readonly headers?: HeadersInit;
|
|
64
|
+
}
|
|
65
|
+
export interface AdminOperationResult<Id extends AdminOperationId> {
|
|
66
|
+
readonly operationId: Id;
|
|
67
|
+
readonly data: AdminOperationResponse<Id>;
|
|
68
|
+
readonly response: Response;
|
|
69
|
+
}
|
|
70
|
+
export declare class HonuaAdminApiError extends Error {
|
|
71
|
+
readonly operationId: AdminOperationId;
|
|
72
|
+
readonly statusCode: number;
|
|
73
|
+
readonly body: unknown;
|
|
74
|
+
constructor(operationId: AdminOperationId, response: Response, body: unknown);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Complete generated Admin REST client. Curated clients may wrap this surface,
|
|
78
|
+
* but every operation in the pinned OpenAPI contract remains callable here.
|
|
79
|
+
*/
|
|
80
|
+
export declare class HonuaAdminClient {
|
|
81
|
+
#private;
|
|
82
|
+
constructor(options: AdminClientOptions);
|
|
83
|
+
call<Id extends AdminOperationId>(operationId: Id, request: AdminOperationRequest<Id>): Promise<AdminOperationResult<Id>>;
|
|
84
|
+
}
|
|
85
|
+
export declare function createHonuaAdminClient(options: AdminClientOptions): HonuaAdminClient;
|
|
86
|
+
/** Enforce the admin credential transport policy for command-layer requests. */
|
|
87
|
+
export declare function assertAdminBaseUrl(baseUrl: string): void;
|
|
88
|
+
export {};
|
|
89
|
+
//# sourceMappingURL=admin-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-client.d.ts","sourceRoot":"","sources":["../../../src/control-plane/admin-client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAyC,KAAK,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAE/G,KAAK,SAAS,CAAC,EAAE,SAAS,gBAAgB,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;AAC7D,KAAK,mBAAmB,CAAC,EAAE,SAAS,gBAAgB,IAAI,SAAS,CAAC,EAAE,CAAC,SAAS;IAC5E,UAAU,EAAE,MAAM,UAAU,CAAC;CAC9B,GACG,UAAU,GACV,KAAK,CAAC;AACV,KAAK,cAAc,CACjB,EAAE,SAAS,gBAAgB,EAC3B,IAAI,SAAS,QAAQ,GAAG,MAAM,GAAG,OAAO,IACtC,mBAAmB,CAAC,EAAE,CAAC,SAAS;KAAG,GAAG,IAAI,IAAI,CAAC,CAAC,EAAE,MAAM,KAAK;CAAE,GAAG,OAAO,CAAC,KAAK,EAAE,SAAS,CAAC,GAAG,KAAK,CAAC;AACxG,KAAK,mBAAmB,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,QAAQ,CAAC;CAC7B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,SAAgB,WAAW,EAAE,gBAAgB,CAAC;IAC9C,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,IAAI,EAAE,OAAO,CAAC;gBAEX,WAAW,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO;CAQpF;AAmBD;;;GAGG;AACH,qBAAa,gBAAgB;;gBAOR,OAAO,EAAE,kBAAkB;IAmBjC,IAAI,CAAC,EAAE,SAAS,gBAAgB,EAC3C,WAAW,EAAE,EAAE,EACf,OAAO,EAAE,qBAAqB,CAAC,EAAE,CAAC,GACjC,OAAO,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC;CA0BrC;AAOD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,kBAAkB,GAAG,gBAAgB,CAEpF;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAWxD"}
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { trimTrailingSlashes } from "../core/path-utils.js";
|
|
2
|
+
import { ADMIN_API_BASE_PATH, ADMIN_OPERATIONS } from "./generated/admin-operations.js";
|
|
3
|
+
export class HonuaAdminApiError extends Error {
|
|
4
|
+
operationId;
|
|
5
|
+
statusCode;
|
|
6
|
+
body;
|
|
7
|
+
constructor(operationId, response, body) {
|
|
8
|
+
const detail = structuredErrorDetail(body);
|
|
9
|
+
super(`Admin operation ${operationId} failed with HTTP ${response.status}.${detail ? ` ${detail}` : ""}`);
|
|
10
|
+
this.name = "HonuaAdminApiError";
|
|
11
|
+
this.operationId = operationId;
|
|
12
|
+
this.statusCode = response.status;
|
|
13
|
+
this.body = body;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function structuredErrorDetail(body) {
|
|
17
|
+
if (typeof body !== "object" || body === null)
|
|
18
|
+
return undefined;
|
|
19
|
+
const record = body;
|
|
20
|
+
const detail = [record.detail, record.message, record.title].find((value) => typeof value === "string" && value.trim() !== "");
|
|
21
|
+
if (detail)
|
|
22
|
+
return detail;
|
|
23
|
+
if (record.errors !== undefined) {
|
|
24
|
+
try {
|
|
25
|
+
return JSON.stringify(record.errors);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
return "The server returned structured validation errors.";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Complete generated Admin REST client. Curated clients may wrap this surface,
|
|
35
|
+
* but every operation in the pinned OpenAPI contract remains callable here.
|
|
36
|
+
*/
|
|
37
|
+
export class HonuaAdminClient {
|
|
38
|
+
#baseUrl;
|
|
39
|
+
#basePath;
|
|
40
|
+
#fetch;
|
|
41
|
+
#headers;
|
|
42
|
+
#credential;
|
|
43
|
+
constructor(options) {
|
|
44
|
+
const baseUrl = new URL(options.baseUrl);
|
|
45
|
+
if (baseUrl.protocol !== "http:" && baseUrl.protocol !== "https:") {
|
|
46
|
+
throw new Error("Admin client baseUrl must use http or https.");
|
|
47
|
+
}
|
|
48
|
+
if (baseUrl.username || baseUrl.password || baseUrl.search || baseUrl.hash) {
|
|
49
|
+
throw new Error("Admin client baseUrl must not include credentials, query parameters, or a fragment.");
|
|
50
|
+
}
|
|
51
|
+
if (baseUrl.protocol === "http:" && !isLoopbackHost(baseUrl.hostname)) {
|
|
52
|
+
throw new Error("Admin client requires HTTPS except for exact loopback HTTP development endpoints.");
|
|
53
|
+
}
|
|
54
|
+
this.#baseUrl = baseUrl.toString().replace(/\/+$/, "");
|
|
55
|
+
this.#basePath = normalizeBasePath(options.basePath ?? ADMIN_API_BASE_PATH);
|
|
56
|
+
this.#fetch = options.fetchFn ?? fetch;
|
|
57
|
+
this.#headers = new Headers(options.headers);
|
|
58
|
+
this.#credential = options.adminKey ?? options.apiKey;
|
|
59
|
+
if (this.#credential)
|
|
60
|
+
this.#headers.set("X-API-Key", this.#credential);
|
|
61
|
+
}
|
|
62
|
+
async call(operationId, request) {
|
|
63
|
+
const descriptor = ADMIN_OPERATIONS[operationId];
|
|
64
|
+
const path = interpolatePath(descriptor.path, request.path);
|
|
65
|
+
const url = new URL(`${this.#baseUrl}${this.#basePath}${path}`);
|
|
66
|
+
appendQuery(url, request.query);
|
|
67
|
+
const headers = new Headers(this.#headers);
|
|
68
|
+
mergeHeaders(headers, request.headers);
|
|
69
|
+
if (this.#credential)
|
|
70
|
+
headers.set("X-API-Key", this.#credential);
|
|
71
|
+
const body = encodeBody(request.body, request.contentType, headers, descriptor.requestContentTypes);
|
|
72
|
+
const response = await this.#fetch(url, {
|
|
73
|
+
method: descriptor.method,
|
|
74
|
+
headers,
|
|
75
|
+
body,
|
|
76
|
+
signal: request.signal,
|
|
77
|
+
redirect: "manual",
|
|
78
|
+
});
|
|
79
|
+
const data = await readResponse(response);
|
|
80
|
+
if (!response.ok)
|
|
81
|
+
throw new HonuaAdminApiError(operationId, response, data);
|
|
82
|
+
return { operationId, data: data, response };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
function isLoopbackHost(hostname) {
|
|
86
|
+
const normalized = hostname.toLowerCase();
|
|
87
|
+
return normalized === "localhost" || normalized === "127.0.0.1" || normalized === "::1" || normalized === "[::1]";
|
|
88
|
+
}
|
|
89
|
+
export function createHonuaAdminClient(options) {
|
|
90
|
+
return new HonuaAdminClient(options);
|
|
91
|
+
}
|
|
92
|
+
/** Enforce the admin credential transport policy for command-layer requests. */
|
|
93
|
+
export function assertAdminBaseUrl(baseUrl) {
|
|
94
|
+
const parsed = new URL(baseUrl);
|
|
95
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
96
|
+
throw new Error("Admin client baseUrl must use http or https.");
|
|
97
|
+
}
|
|
98
|
+
if (parsed.username || parsed.password || parsed.search || parsed.hash) {
|
|
99
|
+
throw new Error("Admin client baseUrl must not include credentials, query parameters, or a fragment.");
|
|
100
|
+
}
|
|
101
|
+
if (parsed.protocol === "http:" && !isLoopbackHost(parsed.hostname)) {
|
|
102
|
+
throw new Error("Admin client requires HTTPS except for exact loopback HTTP development endpoints.");
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function normalizeBasePath(value) {
|
|
106
|
+
const rooted = value.startsWith("/") ? value : `/${value}`;
|
|
107
|
+
return trimTrailingSlashes(rooted);
|
|
108
|
+
}
|
|
109
|
+
function interpolatePath(template, parameters) {
|
|
110
|
+
const used = new Set();
|
|
111
|
+
const path = template.replace(/\{([^}]+)\}/g, (_match, name) => {
|
|
112
|
+
const value = parameters?.[name];
|
|
113
|
+
if (value === undefined || value === null || value === "") {
|
|
114
|
+
throw new Error(`Missing required admin path parameter: ${name}`);
|
|
115
|
+
}
|
|
116
|
+
used.add(name);
|
|
117
|
+
return encodeURIComponent(String(value));
|
|
118
|
+
});
|
|
119
|
+
for (const name of Object.keys(parameters ?? {})) {
|
|
120
|
+
if (!used.has(name))
|
|
121
|
+
throw new Error(`Unknown admin path parameter for ${template}: ${name}`);
|
|
122
|
+
}
|
|
123
|
+
return path;
|
|
124
|
+
}
|
|
125
|
+
function appendQuery(url, query) {
|
|
126
|
+
for (const [name, value] of Object.entries(query ?? {})) {
|
|
127
|
+
if (value === undefined || value === null)
|
|
128
|
+
continue;
|
|
129
|
+
if (Array.isArray(value)) {
|
|
130
|
+
for (const item of value)
|
|
131
|
+
url.searchParams.append(name, String(item));
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
url.searchParams.set(name, String(value));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
function mergeHeaders(target, source) {
|
|
139
|
+
if (!source)
|
|
140
|
+
return;
|
|
141
|
+
for (const [name, value] of new Headers(source))
|
|
142
|
+
target.set(name, value);
|
|
143
|
+
}
|
|
144
|
+
function encodeBody(value, contentType, headers, declaredContentTypes) {
|
|
145
|
+
if (value === undefined)
|
|
146
|
+
return null;
|
|
147
|
+
const selected = contentType ?? defaultRequestContentType(declaredContentTypes);
|
|
148
|
+
if (selected === "multipart/form-data")
|
|
149
|
+
return toFormData(value);
|
|
150
|
+
headers.set("Content-Type", selected);
|
|
151
|
+
if (selected.includes("json"))
|
|
152
|
+
return JSON.stringify(value);
|
|
153
|
+
if (typeof value === "string" ||
|
|
154
|
+
value instanceof Uint8Array ||
|
|
155
|
+
value instanceof Blob ||
|
|
156
|
+
value instanceof FormData ||
|
|
157
|
+
value instanceof URLSearchParams) {
|
|
158
|
+
return value;
|
|
159
|
+
}
|
|
160
|
+
return String(value);
|
|
161
|
+
}
|
|
162
|
+
function defaultRequestContentType(declaredContentTypes) {
|
|
163
|
+
if (declaredContentTypes.includes("application/json"))
|
|
164
|
+
return "application/json";
|
|
165
|
+
return declaredContentTypes[0] ?? "application/json";
|
|
166
|
+
}
|
|
167
|
+
function toFormData(value) {
|
|
168
|
+
if (value instanceof FormData)
|
|
169
|
+
return value;
|
|
170
|
+
if (typeof value !== "object" || value === null)
|
|
171
|
+
throw new Error("multipart/form-data body must be an object.");
|
|
172
|
+
const form = new FormData();
|
|
173
|
+
for (const [name, field] of Object.entries(value)) {
|
|
174
|
+
if (field === undefined || field === null)
|
|
175
|
+
continue;
|
|
176
|
+
if (Array.isArray(field)) {
|
|
177
|
+
for (const item of field)
|
|
178
|
+
form.append(name, formValue(item));
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
form.append(name, formValue(field));
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return form;
|
|
185
|
+
}
|
|
186
|
+
function formValue(value) {
|
|
187
|
+
if (value instanceof Blob)
|
|
188
|
+
return value;
|
|
189
|
+
return typeof value === "string" ? value : JSON.stringify(value);
|
|
190
|
+
}
|
|
191
|
+
async function readResponse(response) {
|
|
192
|
+
if (response.status === 204)
|
|
193
|
+
return undefined;
|
|
194
|
+
const contentType = response.headers.get("content-type") ?? "";
|
|
195
|
+
if (contentType.includes("json"))
|
|
196
|
+
return response.json();
|
|
197
|
+
if (contentType.startsWith("text/") || contentType.includes("xml"))
|
|
198
|
+
return response.text();
|
|
199
|
+
return response.arrayBuffer();
|
|
200
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HonuaClient } from "../core/client.js";
|
|
2
2
|
import type { QueryMethod } from "../core/types.js";
|
|
3
3
|
import type { HonuaMapPackage } from "../runtime/index.js";
|
|
4
|
-
import type
|
|
4
|
+
import { type StudioCapabilityManifest } from "../studio/capability-manifest.js";
|
|
5
5
|
import { type HonuaApiToken, type HonuaApiTokenCreateRequest, type HonuaCapabilityManifestOptions, type HonuaConnectionSummary, type HonuaControlPlaneCapability, type HonuaControlPlaneJob, type HonuaControlPlaneListOptions, type HonuaControlPlanePage, type HonuaControlPlaneRawRequest, type HonuaControlPlaneRequestOptions, type HonuaControlPlaneResult, type HonuaCreateHostedMapRequest, type HonuaHostedMap, type HonuaHostedMapSummary, type HonuaImportCreateRequest, type HonuaMapPackageSummary, type HonuaPublishMapPackageRequest, type HonuaPublishMapPackageResponse, type HonuaShareRequest, type HonuaShareResponse, type HonuaUpdateHostedMapRequest, type HonuaWorkspaceSummary } from "./types.js";
|
|
6
6
|
export interface HonuaControlPlaneClientOptions {
|
|
7
7
|
readonly client: HonuaClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/control-plane/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/control-plane/client.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,OAAO,KA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ValidatorFromHeaders } from "../core/cache-state.js";
|
|
2
2
|
import { HonuaHttpError } from "../core/errors.js";
|
|
3
3
|
import { trimTrailingSlashes } from "../core/path-utils.js";
|
|
4
|
+
import { assertStudioCapabilityManifest } from "../studio/capability-manifest.js";
|
|
4
5
|
import { HONUA_CAPABILITY_MANIFEST_PATH, HONUA_CONTROL_PLANE_BASE_PATH, } from "./types.js";
|
|
5
6
|
export function createHonuaControlPlane(options) {
|
|
6
7
|
return new HonuaControlPlaneClient(options);
|
|
@@ -33,6 +34,8 @@ export class HonuaControlPlaneClient {
|
|
|
33
34
|
return this.requestJson("raw", request.method ?? "GET", request.path, request.body, {
|
|
34
35
|
signal: request.signal,
|
|
35
36
|
headers: request.headers,
|
|
37
|
+
idempotencyKey: request.idempotencyKey,
|
|
38
|
+
ifMatch: request.ifMatch,
|
|
36
39
|
okStatuses: request.okStatuses,
|
|
37
40
|
});
|
|
38
41
|
}
|
|
@@ -46,12 +49,15 @@ export class HonuaControlPlaneClient {
|
|
|
46
49
|
*/
|
|
47
50
|
async getCapabilityManifest(options = {}) {
|
|
48
51
|
const { environment, workspaceId, ...requestOptions } = options;
|
|
49
|
-
|
|
52
|
+
const result = await this.requestJson("capabilities", "GET", withManifestQuery(HONUA_CAPABILITY_MANIFEST_PATH, environment, workspaceId), undefined, requestOptions);
|
|
53
|
+
if (result.supported)
|
|
54
|
+
assertStudioCapabilityManifest(result.value);
|
|
55
|
+
return result;
|
|
50
56
|
}
|
|
51
57
|
async requestJson(capability, method, path, body, options = {}) {
|
|
52
58
|
try {
|
|
53
59
|
const response = await this.#client.pipelineFetch(method, this.resolvePath(path), {
|
|
54
|
-
headers: jsonHeaders(options
|
|
60
|
+
headers: jsonHeaders(options),
|
|
55
61
|
body: body === undefined ? null : JSON.stringify(body),
|
|
56
62
|
}, options.signal, options.okStatuses ? { okStatuses: options.okStatuses } : {});
|
|
57
63
|
if (response.status === 204)
|
|
@@ -153,18 +159,120 @@ export class HonuaImportsClient {
|
|
|
153
159
|
this.#controlPlane = controlPlane;
|
|
154
160
|
}
|
|
155
161
|
listJobs(options = {}) {
|
|
156
|
-
return this.#controlPlane.requestPage("imports", "/
|
|
162
|
+
return this.#controlPlane.requestPage("imports", "/import/jobs", options).then((result) => result.supported
|
|
163
|
+
? {
|
|
164
|
+
supported: true,
|
|
165
|
+
value: {
|
|
166
|
+
...result.value,
|
|
167
|
+
items: result.value.items.map(normalizeImportJob),
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
: result);
|
|
157
171
|
}
|
|
158
|
-
create(request, options = {}) {
|
|
159
|
-
|
|
172
|
+
async create(request, options = {}) {
|
|
173
|
+
if (!request.sourceUrl?.trim()) {
|
|
174
|
+
throw new TypeError("Stored-connection imports are not supported by /import/upload-url; provide a sourceUrl for a URL import.");
|
|
175
|
+
}
|
|
176
|
+
if (request.connectionId) {
|
|
177
|
+
throw new TypeError("connectionId cannot be sent to /import/upload-url; provide only sourceUrl.");
|
|
178
|
+
}
|
|
179
|
+
const fileName = stringOption(request.options, "fileName") ?? fileNameFromUrl(request.sourceUrl);
|
|
180
|
+
const tableName = stringOption(request.options, "tableName") ?? slug(request.title ?? fileName ?? "imported_data");
|
|
181
|
+
const body = {
|
|
182
|
+
sourceUrl: request.sourceUrl,
|
|
183
|
+
fileName: fileName ?? "import.geojson",
|
|
184
|
+
tableName,
|
|
185
|
+
targetSchema: stringOption(request.options, "targetSchema"),
|
|
186
|
+
sourceSrid: numberOption(request.options, "sourceSrid"),
|
|
187
|
+
targetSrid: numberOption(request.options, "targetSrid") ?? 4326,
|
|
188
|
+
overwriteExisting: booleanOption(request.options, "overwriteExisting") ?? false,
|
|
189
|
+
forceBackground: true,
|
|
190
|
+
trackProgress: true,
|
|
191
|
+
};
|
|
192
|
+
return this.#controlPlane
|
|
193
|
+
.requestJson("imports", "POST", "/import/upload-url", body, options)
|
|
194
|
+
.then((result) => (result.supported ? { supported: true, value: normalizeImportJob(result.value) } : result));
|
|
160
195
|
}
|
|
161
196
|
getJob(jobId, options = {}) {
|
|
162
|
-
return this.#controlPlane
|
|
197
|
+
return this.#controlPlane
|
|
198
|
+
.requestJson("imports", "GET", `/import/jobs/${encodeURIComponent(jobId)}`, undefined, options)
|
|
199
|
+
.then((result) => (result.supported ? { supported: true, value: normalizeImportJob(result.value) } : result));
|
|
163
200
|
}
|
|
164
201
|
job(jobId) {
|
|
165
|
-
return new HonuaControlPlaneJobHandle(this.#controlPlane, "imports", `/
|
|
202
|
+
return new HonuaControlPlaneJobHandle(this.#controlPlane, "imports", `/import/jobs/${encodeURIComponent(jobId)}`);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function normalizeImportJob(value) {
|
|
206
|
+
const id = value.id ?? value.jobId;
|
|
207
|
+
if (!id)
|
|
208
|
+
throw new Error("Import response did not contain a job identifier.");
|
|
209
|
+
return {
|
|
210
|
+
...value,
|
|
211
|
+
id,
|
|
212
|
+
type: "import",
|
|
213
|
+
status: normalizeImportJobStatus(value.status),
|
|
214
|
+
links: {
|
|
215
|
+
...(value.links ?? {}),
|
|
216
|
+
...(value.statusUrl ? { self: value.statusUrl } : {}),
|
|
217
|
+
...(value.cancelUrl ? { cancel: value.cancelUrl } : {}),
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
function normalizeImportJobStatus(status) {
|
|
222
|
+
switch (status?.toLowerCase()) {
|
|
223
|
+
case "processing":
|
|
224
|
+
case "running":
|
|
225
|
+
return "running";
|
|
226
|
+
case "completed":
|
|
227
|
+
case "succeeded":
|
|
228
|
+
case "success":
|
|
229
|
+
return "succeeded";
|
|
230
|
+
case "cancelled":
|
|
231
|
+
case "canceled":
|
|
232
|
+
return "cancelled";
|
|
233
|
+
case "failed":
|
|
234
|
+
return "failed";
|
|
235
|
+
case "queued":
|
|
236
|
+
return "queued";
|
|
237
|
+
default:
|
|
238
|
+
return (status ?? "queued").toLowerCase();
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
function stringOption(options, key) {
|
|
242
|
+
return typeof options?.[key] === "string" ? options[key] : undefined;
|
|
243
|
+
}
|
|
244
|
+
function numberOption(options, key) {
|
|
245
|
+
return typeof options?.[key] === "number" ? options[key] : undefined;
|
|
246
|
+
}
|
|
247
|
+
function booleanOption(options, key) {
|
|
248
|
+
return typeof options?.[key] === "boolean" ? options[key] : undefined;
|
|
249
|
+
}
|
|
250
|
+
function fileNameFromUrl(sourceUrl) {
|
|
251
|
+
if (!sourceUrl)
|
|
252
|
+
return undefined;
|
|
253
|
+
try {
|
|
254
|
+
const name = new URL(sourceUrl).pathname.split("/").pop();
|
|
255
|
+
return name || undefined;
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
return undefined;
|
|
166
259
|
}
|
|
167
260
|
}
|
|
261
|
+
function slug(value) {
|
|
262
|
+
const normalized = Array.from(value.trim(), (character) => {
|
|
263
|
+
const code = character.charCodeAt(0);
|
|
264
|
+
return (code >= 48 && code <= 57) || (code >= 65 && code <= 90) || (code >= 97 && code <= 122) || code === 95
|
|
265
|
+
? character
|
|
266
|
+
: "_";
|
|
267
|
+
}).join("");
|
|
268
|
+
let start = 0;
|
|
269
|
+
while (start < normalized.length && normalized[start] === "_")
|
|
270
|
+
start += 1;
|
|
271
|
+
let end = normalized.length;
|
|
272
|
+
while (end > start && normalized[end - 1] === "_")
|
|
273
|
+
end -= 1;
|
|
274
|
+
return normalized.slice(start, end) || "imported_data";
|
|
275
|
+
}
|
|
168
276
|
export class HonuaApiTokensClient {
|
|
169
277
|
#controlPlane;
|
|
170
278
|
constructor(controlPlane) {
|
|
@@ -225,7 +333,11 @@ export class HonuaControlPlaneJobHandle {
|
|
|
225
333
|
this.#path = path;
|
|
226
334
|
}
|
|
227
335
|
poll(options = {}) {
|
|
228
|
-
return this.#controlPlane
|
|
336
|
+
return this.#controlPlane
|
|
337
|
+
.requestJson(this.#capability, "GET", this.#path, undefined, options)
|
|
338
|
+
.then((result) => this.#capability === "imports" && result.supported
|
|
339
|
+
? { supported: true, value: normalizeImportJob(result.value) }
|
|
340
|
+
: result);
|
|
229
341
|
}
|
|
230
342
|
}
|
|
231
343
|
function supported(value) {
|
|
@@ -277,17 +389,33 @@ function withManifestQuery(path, environment, workspaceId) {
|
|
|
277
389
|
const query = params.toString();
|
|
278
390
|
return query ? `${path}?${query}` : path;
|
|
279
391
|
}
|
|
280
|
-
|
|
392
|
+
/**
|
|
393
|
+
* Base JSON headers plus the concurrency/idempotency options every request
|
|
394
|
+
* option bag can carry.
|
|
395
|
+
*
|
|
396
|
+
* The option-level `idempotencyKey`/`ifMatch` are applied **after** raw
|
|
397
|
+
* `headers`, so a raw `Idempotency-Key`/`If-Match` entry cannot silently
|
|
398
|
+
* replace the value the caller passed as an option — the command layer records
|
|
399
|
+
* that value on its receipt, and a receipt that disagrees with the wire is
|
|
400
|
+
* worse than no receipt. Per-request `ifMatch` on a resource-client method is
|
|
401
|
+
* folded into `headers` by {@link withIfMatch} and still applies whenever the
|
|
402
|
+
* option-level shorthand is absent, which is every existing call site.
|
|
403
|
+
*/
|
|
404
|
+
function jsonHeaders(options) {
|
|
281
405
|
return {
|
|
282
406
|
Accept: "application/json",
|
|
283
407
|
"Content-Type": "application/json",
|
|
284
|
-
...headersToRecord(headers),
|
|
408
|
+
...headersToRecord(options.headers),
|
|
409
|
+
...(options.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : {}),
|
|
410
|
+
...(options.ifMatch ? { "If-Match": options.ifMatch } : {}),
|
|
285
411
|
};
|
|
286
412
|
}
|
|
287
413
|
function listHeaders(options) {
|
|
288
414
|
const headers = {
|
|
289
415
|
Accept: "application/json",
|
|
290
416
|
...headersToRecord(options.headers),
|
|
417
|
+
...(options.idempotencyKey ? { "Idempotency-Key": options.idempotencyKey } : {}),
|
|
418
|
+
...(options.ifMatch ? { "If-Match": options.ifMatch } : {}),
|
|
291
419
|
};
|
|
292
420
|
if (options.validator?.etag)
|
|
293
421
|
headers["If-None-Match"] = options.validator.etag;
|
|
@@ -317,7 +445,13 @@ async function readJson(response) {
|
|
|
317
445
|
}
|
|
318
446
|
function normalizePage(body, response, options = {}) {
|
|
319
447
|
const value = isRecord(body) ? body : {};
|
|
320
|
-
const items = (Array.isArray(value.items)
|
|
448
|
+
const items = (Array.isArray(value.items)
|
|
449
|
+
? value.items
|
|
450
|
+
: Array.isArray(value.data)
|
|
451
|
+
? value.data
|
|
452
|
+
: Array.isArray(value.jobs)
|
|
453
|
+
? value.jobs
|
|
454
|
+
: []);
|
|
321
455
|
const pagination = isRecord(value.pagination) ? value.pagination : value;
|
|
322
456
|
const validator = honuaCacheValidatorFromHeaders(response.headers) ?? options.fallbackValidator;
|
|
323
457
|
const sourceUpdatedAt = response.headers.get("last-modified") ?? undefined;
|