@distilled.cloud/apache-superset 0.0.0 → 1.0.0-rc.9
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/LICENSE +201 -0
- package/lib/credentials.d.ts +37 -0
- package/lib/credentials.d.ts.map +1 -0
- package/lib/credentials.js +43 -0
- package/lib/credentials.js.map +1 -0
- package/lib/errors.d.ts +36 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +26 -0
- package/lib/errors.js.map +1 -0
- package/lib/index.d.ts +24 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +24 -0
- package/lib/index.js.map +1 -0
- package/lib/pagination.d.ts +9 -0
- package/lib/pagination.d.ts.map +1 -0
- package/lib/pagination.js +9 -0
- package/lib/pagination.js.map +1 -0
- package/lib/protocol.d.ts +19 -0
- package/lib/protocol.d.ts.map +1 -0
- package/lib/protocol.js +44 -0
- package/lib/protocol.js.map +1 -0
- package/lib/retry.d.ts +32 -0
- package/lib/retry.d.ts.map +1 -0
- package/lib/retry.js +32 -0
- package/lib/retry.js.map +1 -0
- package/lib/services/index.d.ts +2 -0
- package/lib/services/index.d.ts.map +1 -0
- package/lib/services/index.js +3 -0
- package/lib/services/index.js.map +1 -0
- package/lib/services/superset.d.ts +8346 -0
- package/lib/services/superset.d.ts.map +1 -0
- package/lib/services/superset.js +9371 -0
- package/lib/services/superset.js.map +1 -0
- package/lib/traits.d.ts +11 -0
- package/lib/traits.d.ts.map +1 -0
- package/lib/traits.js +11 -0
- package/lib/traits.js.map +1 -0
- package/package.json +77 -6
- package/src/credentials.ts +65 -0
- package/src/errors.ts +50 -0
- package/src/index.ts +32 -0
- package/src/pagination.ts +8 -0
- package/src/protocol.ts +68 -0
- package/src/retry.ts +56 -0
- package/src/services/index.ts +2 -0
- package/src/services/superset.ts +25208 -0
- package/src/traits.ts +44 -0
package/lib/traits.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apache Superset SDK trait surface — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the generic protocol traits from core (so generated operations
|
|
5
|
+
* import everything from one place). Apache Superset has no envelope of its
|
|
6
|
+
* own; the REST-protocol traits (SensitiveValue / RawResponse) come from
|
|
7
|
+
* `core/protocol-rest`.
|
|
8
|
+
*/
|
|
9
|
+
export { Body, Header, Query, Label, Http, ResponseCode, HttpBody, FormDataFile, KeyDictionary, UnionCases, applyErrorMatchers, getErrorMatchers, type HttpTrait, type ErrorMatcher, bodySymbol, headerSymbol, querySymbol, labelSymbol, httpSymbol, responseCodeSymbol, httpBodySymbol, formDataFileSymbol, keyDictionarySymbol, unionCasesSymbol, errorMatchersSymbol, } from "@distilled.cloud/core/trait";
|
|
10
|
+
export { SensitiveValue, RawResponse, RawResponseRoot, sensitiveValueSymbol, rawResponseSymbol, rawResponseRootSymbol, } from "@distilled.cloud/core/protocol-rest";
|
|
11
|
+
//# sourceMappingURL=traits.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,cAAc,EACd,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,qCAAqC,CAAC"}
|
package/lib/traits.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apache Superset SDK trait surface — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the generic protocol traits from core (so generated operations
|
|
5
|
+
* import everything from one place). Apache Superset has no envelope of its
|
|
6
|
+
* own; the REST-protocol traits (SensitiveValue / RawResponse) come from
|
|
7
|
+
* `core/protocol-rest`.
|
|
8
|
+
*/
|
|
9
|
+
export { Body, Header, Query, Label, Http, ResponseCode, HttpBody, FormDataFile, KeyDictionary, UnionCases, applyErrorMatchers, getErrorMatchers, bodySymbol, headerSymbol, querySymbol, labelSymbol, httpSymbol, responseCodeSymbol, httpBodySymbol, formDataFileSymbol, keyDictionarySymbol, unionCasesSymbol, errorMatchersSymbol, } from "@distilled.cloud/core/trait";
|
|
10
|
+
export { SensitiveValue, RawResponse, RawResponseRoot, sensitiveValueSymbol, rawResponseSymbol, rawResponseRootSymbol, } from "@distilled.cloud/core/protocol-rest";
|
|
11
|
+
//# sourceMappingURL=traits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traits.js","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAGhB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,cAAc,EACd,WAAW,EACX,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,qCAAqC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,85 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/apache-superset",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Placeholder package for an upcoming distilled SDK.",
|
|
5
|
-
"license": "Apache-2.0",
|
|
3
|
+
"version": "1.0.0-rc.9",
|
|
6
4
|
"repository": {
|
|
7
5
|
"type": "git",
|
|
8
6
|
"url": "https://github.com/alchemy-run/distilled",
|
|
9
7
|
"directory": "packages/apache-superset"
|
|
10
8
|
},
|
|
11
|
-
"
|
|
12
|
-
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"files": [
|
|
13
|
+
"lib",
|
|
14
|
+
"src"
|
|
15
|
+
],
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./lib/index.d.ts",
|
|
19
|
+
"bun": "./src/index.ts",
|
|
20
|
+
"worker": "./src/index.ts",
|
|
21
|
+
"default": "./lib/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./Credentials": {
|
|
24
|
+
"types": "./lib/credentials.d.ts",
|
|
25
|
+
"bun": "./src/credentials.ts",
|
|
26
|
+
"worker": "./src/credentials.ts",
|
|
27
|
+
"default": "./lib/credentials.js"
|
|
28
|
+
},
|
|
29
|
+
"./Errors": {
|
|
30
|
+
"types": "./lib/errors.d.ts",
|
|
31
|
+
"bun": "./src/errors.ts",
|
|
32
|
+
"worker": "./src/errors.ts",
|
|
33
|
+
"default": "./lib/errors.js"
|
|
34
|
+
},
|
|
35
|
+
"./Traits": {
|
|
36
|
+
"types": "./lib/traits.d.ts",
|
|
37
|
+
"bun": "./src/traits.ts",
|
|
38
|
+
"worker": "./src/traits.ts",
|
|
39
|
+
"default": "./lib/traits.js"
|
|
40
|
+
},
|
|
41
|
+
"./Pagination": {
|
|
42
|
+
"types": "./lib/pagination.d.ts",
|
|
43
|
+
"bun": "./src/pagination.ts",
|
|
44
|
+
"worker": "./src/pagination.ts",
|
|
45
|
+
"default": "./lib/pagination.js"
|
|
46
|
+
},
|
|
47
|
+
"./Protocol": {
|
|
48
|
+
"types": "./lib/protocol.d.ts",
|
|
49
|
+
"bun": "./src/protocol.ts",
|
|
50
|
+
"worker": "./src/protocol.ts",
|
|
51
|
+
"default": "./lib/protocol.js"
|
|
52
|
+
},
|
|
53
|
+
"./Retry": {
|
|
54
|
+
"types": "./lib/retry.d.ts",
|
|
55
|
+
"bun": "./src/retry.ts",
|
|
56
|
+
"worker": "./src/retry.ts",
|
|
57
|
+
"default": "./lib/retry.js"
|
|
58
|
+
},
|
|
59
|
+
"./*": {
|
|
60
|
+
"types": "./lib/services/*.d.ts",
|
|
61
|
+
"bun": "./src/services/*.ts",
|
|
62
|
+
"worker": "./src/services/*.ts",
|
|
63
|
+
"default": "./lib/services/*.js"
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"dependencies": {
|
|
67
|
+
"@distilled.cloud/core": "1.0.0-rc.9"
|
|
68
|
+
},
|
|
69
|
+
"devDependencies": {
|
|
70
|
+
"@types/bun": "latest",
|
|
71
|
+
"@types/node": "latest",
|
|
72
|
+
"@effect/platform-bun": ">=4.0.0-rc.112 || >=4.0.0"
|
|
73
|
+
},
|
|
74
|
+
"peerDependencies": {
|
|
75
|
+
"effect": ">=4.0.0-rc.112 || >=4.0.0"
|
|
76
|
+
},
|
|
77
|
+
"scripts": {
|
|
78
|
+
"build": "tsc -b",
|
|
79
|
+
"convert": "bun scripts/convert.ts",
|
|
80
|
+
"generate": "bun scripts/convert.ts && bun scripts/generate.ts",
|
|
81
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
82
|
+
"specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-apache-superset",
|
|
83
|
+
"specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-apache-superset"
|
|
13
84
|
}
|
|
14
|
-
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apache Superset credentials — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* The `Credentials` service holds an *effect* that resolves the current
|
|
5
|
+
* credentials on every request (the protocol layer resolves it per request
|
|
6
|
+
* on the calling fiber).
|
|
7
|
+
*
|
|
8
|
+
* Superset authenticates HTTP API requests with a JWT access token
|
|
9
|
+
* (`Authorization: Bearer <token>`), typically obtained from
|
|
10
|
+
* `POST /api/v1/security/login`. Spec paths already include `/api/v1`, so
|
|
11
|
+
* `apiBaseUrl` is the instance origin.
|
|
12
|
+
*/
|
|
13
|
+
import * as Context from "effect/Context";
|
|
14
|
+
import * as Effect from "effect/Effect";
|
|
15
|
+
import * as Layer from "effect/Layer";
|
|
16
|
+
import * as Redacted from "effect/Redacted";
|
|
17
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
18
|
+
|
|
19
|
+
/** Common local Superset listen address (the instance origin, not `/api/v1`). */
|
|
20
|
+
export const DEFAULT_API_BASE_URL = "http://localhost:8088";
|
|
21
|
+
|
|
22
|
+
export interface Config {
|
|
23
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
24
|
+
readonly apiBaseUrl: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class Credentials extends Context.Service<
|
|
28
|
+
Credentials,
|
|
29
|
+
Effect.Effect<Config>
|
|
30
|
+
>()("ApacheSupersetCredentials") {}
|
|
31
|
+
|
|
32
|
+
/** Layer from a JWT access token + optional instance URL. */
|
|
33
|
+
export const fromApiKey = (config: {
|
|
34
|
+
readonly apiKey: string;
|
|
35
|
+
readonly apiBaseUrl?: string;
|
|
36
|
+
}): Layer.Layer<Credentials> =>
|
|
37
|
+
Layer.succeed(
|
|
38
|
+
Credentials,
|
|
39
|
+
Effect.succeed({
|
|
40
|
+
apiKey: Redacted.make(config.apiKey),
|
|
41
|
+
apiBaseUrl: config.apiBaseUrl ?? DEFAULT_API_BASE_URL,
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Reads SUPERSET_ACCESS_TOKEN (required) and SUPERSET_URL (optional instance
|
|
47
|
+
* origin).
|
|
48
|
+
*/
|
|
49
|
+
export const CredentialsFromEnv: Layer.Layer<Credentials> = Layer.succeed(
|
|
50
|
+
Credentials,
|
|
51
|
+
Effect.gen(function* () {
|
|
52
|
+
const apiKey = process.env.SUPERSET_ACCESS_TOKEN;
|
|
53
|
+
|
|
54
|
+
if (!apiKey) {
|
|
55
|
+
return yield* new ConfigError({
|
|
56
|
+
message: "SUPERSET_ACCESS_TOKEN environment variable is required",
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
apiKey: Redacted.make(apiKey),
|
|
62
|
+
apiBaseUrl: process.env.SUPERSET_URL ?? DEFAULT_API_BASE_URL,
|
|
63
|
+
};
|
|
64
|
+
}).pipe(Effect.orDie),
|
|
65
|
+
);
|
package/src/errors.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apache Superset-specific error types.
|
|
3
|
+
*
|
|
4
|
+
* Re-exports the common HTTP errors from core and adds the Apache Superset
|
|
5
|
+
* fallback errors. Note the generated service module additionally defines its
|
|
6
|
+
* own per-status matcher classes (BadRequest/NotFound/…) for the statuses each
|
|
7
|
+
* operation declares — those share `_tag`s with the core classes here, so
|
|
8
|
+
* `catchTag` works against either.
|
|
9
|
+
*/
|
|
10
|
+
export {
|
|
11
|
+
BadGateway,
|
|
12
|
+
BadRequest,
|
|
13
|
+
Conflict,
|
|
14
|
+
ConfigError,
|
|
15
|
+
Forbidden,
|
|
16
|
+
GatewayTimeout,
|
|
17
|
+
InternalServerError,
|
|
18
|
+
Locked,
|
|
19
|
+
NotFound,
|
|
20
|
+
ServiceUnavailable,
|
|
21
|
+
TooManyRequests,
|
|
22
|
+
Unauthorized,
|
|
23
|
+
UnprocessableEntity,
|
|
24
|
+
HTTP_STATUS_MAP,
|
|
25
|
+
DEFAULT_ERRORS,
|
|
26
|
+
API_ERRORS,
|
|
27
|
+
} from "@distilled.cloud/core/errors";
|
|
28
|
+
export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
29
|
+
|
|
30
|
+
import * as Schema from "effect/Schema";
|
|
31
|
+
import * as Category from "@distilled.cloud/core/category";
|
|
32
|
+
|
|
33
|
+
/** Unknown Apache Superset error — returned when nothing else matches. */
|
|
34
|
+
export class UnknownApacheSupersetError extends Schema.TaggedError<UnknownApacheSupersetError>()(
|
|
35
|
+
"UnknownApacheSupersetError",
|
|
36
|
+
{
|
|
37
|
+
code: Schema.optional(Schema.String),
|
|
38
|
+
message: Schema.optional(Schema.String),
|
|
39
|
+
body: Schema.Unknown,
|
|
40
|
+
},
|
|
41
|
+
).pipe(Category.withServerError) {}
|
|
42
|
+
|
|
43
|
+
/** Schema parse error wrapper. */
|
|
44
|
+
export class ApacheSupersetParseError extends Schema.TaggedError<ApacheSupersetParseError>()(
|
|
45
|
+
"ApacheSupersetParseError",
|
|
46
|
+
{
|
|
47
|
+
body: Schema.Unknown,
|
|
48
|
+
cause: Schema.Unknown,
|
|
49
|
+
},
|
|
50
|
+
).pipe(Category.withParseError) {}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @distilled.cloud/apache-superset — Apache Superset REST API SDK for Effect.
|
|
3
|
+
*
|
|
4
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy model
|
|
5
|
+
* in `.generated-specs` (written by `scripts/convert.ts` from the OpenAPI
|
|
6
|
+
* spec). Everything else in this folder is hand-written.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import * as ApacheSuperset from "@distilled.cloud/apache-superset";
|
|
11
|
+
*
|
|
12
|
+
* const dashboards = yield* ApacheSuperset.Services.superset.getApiV1Dashboard({});
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export * from "./credentials.ts";
|
|
16
|
+
export * from "./errors.ts";
|
|
17
|
+
export * as T from "./traits.ts";
|
|
18
|
+
export {
|
|
19
|
+
ApacheSupersetProtocol,
|
|
20
|
+
type ApacheSupersetOpError,
|
|
21
|
+
type ApacheSupersetOpContext,
|
|
22
|
+
} from "./protocol.ts";
|
|
23
|
+
export { paginateCursor } from "./pagination.ts";
|
|
24
|
+
export * as Retry from "./retry.ts";
|
|
25
|
+
export * as Services from "./services/index.ts";
|
|
26
|
+
export * from "./services/superset.ts";
|
|
27
|
+
export {
|
|
28
|
+
BadRequest,
|
|
29
|
+
Forbidden,
|
|
30
|
+
NotFound,
|
|
31
|
+
UnprocessableEntity,
|
|
32
|
+
} from "./services/superset.ts";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apache Superset pagination — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* List operations that stamp `smithy.api#paginated` are traversed by core's
|
|
5
|
+
* {@link paginateCursor}. Other list endpoints leave page/limit as plain
|
|
6
|
+
* inputs.
|
|
7
|
+
*/
|
|
8
|
+
export { paginateCursor } from "@distilled.cloud/core/pagination";
|
package/src/protocol.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ApacheSupersetProtocol — hand-written.
|
|
3
|
+
*
|
|
4
|
+
* Apache Superset speaks plain bearer-authenticated JSON REST (no response
|
|
5
|
+
* envelope), so the whole protocol is one `makeRestProtocol` call from
|
|
6
|
+
* `core/protocol-rest`:
|
|
7
|
+
*
|
|
8
|
+
* request: credentials → `Authorization: Bearer <apiKey>` + instance origin
|
|
9
|
+
* (default http://localhost:8088), resolved from the calling
|
|
10
|
+
* fiber on every request. Spec paths already include `/api/v1`.
|
|
11
|
+
*
|
|
12
|
+
* response: 2xx JSON is the payload (sensitive members delivered as
|
|
13
|
+
* `Redacted`); non-2xx `{ message?, message_text? }` bodies map
|
|
14
|
+
* to the operation's typed error classes by status, then the
|
|
15
|
+
* shared HTTP-status classes, then
|
|
16
|
+
* {@link UnknownApacheSupersetError}.
|
|
17
|
+
*/
|
|
18
|
+
import * as Effect from "effect/Effect";
|
|
19
|
+
import type * as Layer from "effect/Layer";
|
|
20
|
+
import * as Redacted from "effect/Redacted";
|
|
21
|
+
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
22
|
+
import type * as HttpClientError from "effect/unstable/http/HttpClientError";
|
|
23
|
+
import type * as API from "@distilled.cloud/core/api";
|
|
24
|
+
import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
|
|
25
|
+
import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
|
|
26
|
+
import { Credentials, type Config } from "./credentials.ts";
|
|
27
|
+
import { UnknownApacheSupersetError } from "./errors.ts";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Error channel shared by every generated Apache Superset operation.
|
|
31
|
+
* Generated service files annotate operations with
|
|
32
|
+
* `API.OperationMethod<I, O, ApacheSupersetOpError, ApacheSupersetOpContext>`
|
|
33
|
+
* explicitly so the compiler never infers these back out of the schema
|
|
34
|
+
* generics.
|
|
35
|
+
*/
|
|
36
|
+
export type ApacheSupersetOpError =
|
|
37
|
+
| InstanceType<(typeof API_ERRORS)[number]>
|
|
38
|
+
| UnknownApacheSupersetError
|
|
39
|
+
| ConfigError
|
|
40
|
+
| HttpClientError.HttpClientError;
|
|
41
|
+
|
|
42
|
+
/** Context (requirements) shared by every generated Apache Superset operation. */
|
|
43
|
+
export type ApacheSupersetOpContext = Credentials | HttpClient.HttpClient;
|
|
44
|
+
|
|
45
|
+
export const ApacheSupersetProtocol: Layer.Layer<API.Protocol> =
|
|
46
|
+
makeRestProtocol<Config>({
|
|
47
|
+
// The Credentials service holds an effect — resolving it here (per
|
|
48
|
+
// request, on the calling fiber) picks up context-provided credentials.
|
|
49
|
+
credentials: Effect.gen(function* () {
|
|
50
|
+
const resolve = yield* Credentials;
|
|
51
|
+
return yield* resolve;
|
|
52
|
+
}),
|
|
53
|
+
baseUrl: (creds) => creds.apiBaseUrl,
|
|
54
|
+
headers: (creds) => ({
|
|
55
|
+
Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
|
|
56
|
+
}),
|
|
57
|
+
unknownError: ({ code, message, body }) =>
|
|
58
|
+
new UnknownApacheSupersetError({
|
|
59
|
+
code:
|
|
60
|
+
typeof code === "string"
|
|
61
|
+
? code
|
|
62
|
+
: code !== undefined
|
|
63
|
+
? String(code)
|
|
64
|
+
: undefined,
|
|
65
|
+
message,
|
|
66
|
+
body,
|
|
67
|
+
}),
|
|
68
|
+
});
|
package/src/retry.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Apache Superset retry configuration.
|
|
3
|
+
*
|
|
4
|
+
* Defines the per-SDK `Retry` Context.Service tag that generated operations
|
|
5
|
+
* wire into `API.make`. Callers can install a blanket retry policy at the
|
|
6
|
+
* layer level and have every Apache Superset API call below it pick it up:
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```ts
|
|
10
|
+
* import * as ApacheSuperset from "@distilled.cloud/apache-superset";
|
|
11
|
+
*
|
|
12
|
+
* myEffect.pipe(ApacheSuperset.Retry.transient);
|
|
13
|
+
* Effect.provide(myEffect, Layer.succeed(ApacheSuperset.Retry.Retry, customPolicy));
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import * as Context from "effect/Context";
|
|
17
|
+
import * as Effect from "effect/Effect";
|
|
18
|
+
import * as Layer from "effect/Layer";
|
|
19
|
+
import {
|
|
20
|
+
type Policy,
|
|
21
|
+
throttlingFactory,
|
|
22
|
+
transientFactory,
|
|
23
|
+
} from "@distilled.cloud/core/retry";
|
|
24
|
+
|
|
25
|
+
export {
|
|
26
|
+
type Options,
|
|
27
|
+
type Factory,
|
|
28
|
+
type Policy,
|
|
29
|
+
makeDefault,
|
|
30
|
+
jittered,
|
|
31
|
+
capped,
|
|
32
|
+
throttlingOptions,
|
|
33
|
+
transientOptions,
|
|
34
|
+
throttlingFactory,
|
|
35
|
+
transientFactory,
|
|
36
|
+
} from "@distilled.cloud/core/retry";
|
|
37
|
+
|
|
38
|
+
/** Context tag for configuring retry behavior of Apache Superset API calls. */
|
|
39
|
+
export class Retry extends Context.Service<Retry, Policy>()(
|
|
40
|
+
"ApacheSupersetRetry",
|
|
41
|
+
) {}
|
|
42
|
+
|
|
43
|
+
/** Provides a custom retry policy to every Apache Superset API call below it. */
|
|
44
|
+
export const policy = (optionsOrFactory: Policy) =>
|
|
45
|
+
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
46
|
+
|
|
47
|
+
/** Disables all automatic retries. */
|
|
48
|
+
export const none = Effect.provide(
|
|
49
|
+
Layer.succeed(Retry, { while: () => false }),
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
53
|
+
export const throttling = policy(throttlingFactory);
|
|
54
|
+
|
|
55
|
+
/** Apply the transient retry policy (retries all transient errors indefinitely). */
|
|
56
|
+
export const transient = policy(transientFactory);
|