@distilled.cloud/typesense 1.0.0-rc.12 → 1.0.0-rc.14
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/README.md +34 -0
- package/lib/credentials.d.ts +2 -2
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +2 -2
- package/lib/credentials.js.map +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/protocol.d.ts +3 -3
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +3 -2
- package/lib/protocol.js.map +1 -1
- package/lib/retry.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -1
- package/lib/retry.js.map +1 -1
- package/lib/services/typesense.d.ts +65 -9
- package/lib/services/typesense.d.ts.map +1 -1
- package/lib/services/typesense.js +221 -502
- package/lib/services/typesense.js.map +1 -1
- package/package.json +13 -10
- package/src/credentials.ts +7 -9
- package/src/errors.ts +1 -2
- package/src/index.ts +1 -5
- package/src/protocol.ts +21 -25
- package/src/retry.ts +2 -8
- package/src/services/typesense.ts +435 -783
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/typesense",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.14",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"repository": {
|
|
5
6
|
"type": "git",
|
|
6
7
|
"url": "https://github.com/alchemy-run/distilled",
|
|
7
8
|
"directory": "packages/typesense"
|
|
8
9
|
},
|
|
9
|
-
"license": "Apache-2.0",
|
|
10
|
-
"type": "module",
|
|
11
|
-
"sideEffects": false,
|
|
12
10
|
"files": [
|
|
13
11
|
"lib",
|
|
14
12
|
"src"
|
|
15
13
|
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
16
|
"exports": {
|
|
17
17
|
"./Credentials": {
|
|
18
18
|
"types": "./lib/credentials.d.ts",
|
|
@@ -64,20 +64,23 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@distilled.cloud/core": "1.0.0-rc.
|
|
67
|
+
"@distilled.cloud/core": "1.0.0-rc.14"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@types/bun": "1.3.14",
|
|
71
70
|
"@types/node": "26.2.0",
|
|
72
|
-
"
|
|
71
|
+
"yaml": "^2.9.0"
|
|
73
72
|
},
|
|
74
73
|
"peerDependencies": {
|
|
75
|
-
"effect": "
|
|
74
|
+
"effect": "^4.0.0"
|
|
75
|
+
},
|
|
76
|
+
"distilled": {
|
|
77
|
+
"generatedAt": "2026-10-05",
|
|
78
|
+
"specUpdatedAt": "2026-09-11"
|
|
76
79
|
},
|
|
77
80
|
"scripts": {
|
|
78
81
|
"build": "tsc -b",
|
|
79
|
-
"convert": "bun scripts/convert.ts",
|
|
80
|
-
"generate": "bun scripts/generate.ts",
|
|
82
|
+
"convert": "node --conditions=bun scripts/convert.ts",
|
|
83
|
+
"generate": "node --conditions=bun scripts/generate.ts",
|
|
81
84
|
"typecheck": "tsc -p tsconfig.json",
|
|
82
85
|
"typecheck:strict": "tsc -p tsconfig.strict.json",
|
|
83
86
|
"specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-typesense",
|
package/src/credentials.ts
CHANGED
|
@@ -25,10 +25,9 @@ export interface Config {
|
|
|
25
25
|
readonly apiBaseUrl: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export class Credentials extends Context.Service<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
>()("TypesenseCredentials") {}
|
|
28
|
+
export class Credentials extends Context.Service<Credentials, Effect.Effect<Config>>()(
|
|
29
|
+
"TypesenseCredentials",
|
|
30
|
+
) {}
|
|
32
31
|
|
|
33
32
|
const envConfig = EffectConfig.all({
|
|
34
33
|
apiKey: EffectConfig.String("TYPESENSE_API_KEY"),
|
|
@@ -41,8 +40,7 @@ export const CredentialsFromEnv = Layer.succeed(
|
|
|
41
40
|
Effect.mapError(
|
|
42
41
|
() =>
|
|
43
42
|
new ConfigError({
|
|
44
|
-
message:
|
|
45
|
-
"TYPESENSE_API_KEY and TYPESENSE_API_URL environment variables are required",
|
|
43
|
+
message: "TYPESENSE_API_KEY and TYPESENSE_API_URL environment variables are required",
|
|
46
44
|
}),
|
|
47
45
|
),
|
|
48
46
|
Effect.map(({ apiKey, apiBaseUrl }) => ({
|
|
@@ -53,15 +51,15 @@ export const CredentialsFromEnv = Layer.succeed(
|
|
|
53
51
|
),
|
|
54
52
|
);
|
|
55
53
|
|
|
56
|
-
/** Convenience layer from a
|
|
54
|
+
/** Convenience layer from a redacted key + base URL (kept for local tests). */
|
|
57
55
|
export const credentials = (config: {
|
|
58
|
-
readonly apiKey: string
|
|
56
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
59
57
|
readonly apiBaseUrl: string;
|
|
60
58
|
}): Layer.Layer<Credentials> =>
|
|
61
59
|
Layer.succeed(
|
|
62
60
|
Credentials,
|
|
63
61
|
Effect.succeed({
|
|
64
|
-
apiKey:
|
|
62
|
+
apiKey: config.apiKey,
|
|
65
63
|
apiBaseUrl: config.apiBaseUrl,
|
|
66
64
|
}),
|
|
67
65
|
);
|
package/src/errors.ts
CHANGED
|
@@ -23,10 +23,9 @@ export {
|
|
|
23
23
|
DEFAULT_ERRORS,
|
|
24
24
|
API_ERRORS,
|
|
25
25
|
} from "@distilled.cloud/core/errors";
|
|
26
|
+
import * as Category from "@distilled.cloud/core/category";
|
|
26
27
|
import type { DefaultErrors as CoreDefaultErrors } from "@distilled.cloud/core/errors";
|
|
27
|
-
|
|
28
28
|
import * as Schema from "effect/Schema";
|
|
29
|
-
import * as Category from "@distilled.cloud/core/category";
|
|
30
29
|
|
|
31
30
|
// Unknown Typesense error - returned when an error code is not recognized
|
|
32
31
|
export class UnknownTypesenseError extends Schema.TaggedError<UnknownTypesenseError>()(
|
package/src/index.ts
CHANGED
|
@@ -8,10 +8,6 @@
|
|
|
8
8
|
export * from "./credentials.ts";
|
|
9
9
|
export * from "./errors.ts";
|
|
10
10
|
export * as T from "./traits.ts";
|
|
11
|
-
export {
|
|
12
|
-
TypesenseProtocol,
|
|
13
|
-
type TypesenseOpError,
|
|
14
|
-
type TypesenseOpContext,
|
|
15
|
-
} from "./protocol.ts";
|
|
11
|
+
export { TypesenseProtocol, type TypesenseOpError, type TypesenseOpContext } from "./protocol.ts";
|
|
16
12
|
export * as Retry from "./retry.ts";
|
|
17
13
|
export * as Services from "./services/index.ts";
|
package/src/protocol.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type * as API from "@distilled.cloud/core/api";
|
|
2
|
+
import type { ConfigError } from "@distilled.cloud/core/errors";
|
|
3
|
+
import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
|
|
1
4
|
/**
|
|
2
5
|
* TypesenseProtocol — the shared bearer/header-auth REST factory from core,
|
|
3
6
|
* instantiated with Typesense's specifics:
|
|
@@ -12,14 +15,11 @@
|
|
|
12
15
|
* the shared HTTP status map, then UnknownTypesenseError.
|
|
13
16
|
*/
|
|
14
17
|
import * as Effect from "effect/Effect";
|
|
18
|
+
import type * as HttpClient from "effect/http/HttpClient";
|
|
19
|
+
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
15
20
|
import type * as Layer from "effect/Layer";
|
|
16
|
-
import type * as HttpClient from "effect/unstable/http/HttpClient";
|
|
17
|
-
import type * as HttpClientError from "effect/unstable/http/HttpClientError";
|
|
18
|
-
import type * as API from "@distilled.cloud/core/api";
|
|
19
|
-
import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
|
|
20
|
-
import type { ConfigError } from "@distilled.cloud/core/errors";
|
|
21
21
|
import { type Config, Credentials, formatHeaders } from "./credentials.ts";
|
|
22
|
-
import { type DefaultErrors, UnknownTypesenseError } from "./errors.ts";
|
|
22
|
+
import { type DefaultErrors, UnknownTypesenseError, TypesenseParseError } from "./errors.ts";
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Error channel shared by every generated Typesense operation. Generated
|
|
@@ -27,26 +27,22 @@ import { type DefaultErrors, UnknownTypesenseError } from "./errors.ts";
|
|
|
27
27
|
* TypesenseOpError, TypesenseOpContext>` explicitly so the compiler never
|
|
28
28
|
* infers these back out of the schema generics.
|
|
29
29
|
*/
|
|
30
|
-
export type TypesenseOpError =
|
|
31
|
-
| DefaultErrors
|
|
32
|
-
| ConfigError
|
|
33
|
-
| HttpClientError.HttpClientError;
|
|
30
|
+
export type TypesenseOpError = DefaultErrors | ConfigError | HttpClientError.HttpClientError;
|
|
34
31
|
|
|
35
32
|
/** Context (requirements) shared by every generated Typesense operation. */
|
|
36
33
|
export type TypesenseOpContext = Credentials | HttpClient.HttpClient;
|
|
37
34
|
|
|
38
|
-
export const TypesenseProtocol: Layer.Layer<API.Protocol> =
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
35
|
+
export const TypesenseProtocol: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
|
|
36
|
+
// Resolved on the calling fiber, per request — the Credentials service
|
|
37
|
+
// holds an effect, so lazily-resolved keys Just Work.
|
|
38
|
+
credentials: Effect.gen(function* () {
|
|
39
|
+
const resolve = yield* Credentials;
|
|
40
|
+
return yield* resolve;
|
|
41
|
+
}),
|
|
42
|
+
baseUrl: (creds) => creds.apiBaseUrl,
|
|
43
|
+
headers: formatHeaders,
|
|
44
|
+
// Typesense's ApiResponse error body is `{ message }` — covered by the
|
|
45
|
+
// factory's default envelope reader.
|
|
46
|
+
unknownError: ({ message, body }) => new UnknownTypesenseError({ message, body }),
|
|
47
|
+
parseError: ({ body, cause }) => new TypesenseParseError({ body, cause }),
|
|
48
|
+
});
|
package/src/retry.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Policy, throttlingFactory, transientFactory } from "@distilled.cloud/core/retry";
|
|
1
2
|
/**
|
|
2
3
|
* Typesense retry configuration.
|
|
3
4
|
*
|
|
@@ -17,11 +18,6 @@
|
|
|
17
18
|
import * as Context from "effect/Context";
|
|
18
19
|
import * as Effect from "effect/Effect";
|
|
19
20
|
import * as Layer from "effect/Layer";
|
|
20
|
-
import {
|
|
21
|
-
type Policy,
|
|
22
|
-
throttlingFactory,
|
|
23
|
-
transientFactory,
|
|
24
|
-
} from "@distilled.cloud/core/retry";
|
|
25
21
|
|
|
26
22
|
export {
|
|
27
23
|
type Options,
|
|
@@ -44,9 +40,7 @@ export const policy = (optionsOrFactory: Policy) =>
|
|
|
44
40
|
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
45
41
|
|
|
46
42
|
/** Disables all automatic retries. */
|
|
47
|
-
export const none = Effect.provide(
|
|
48
|
-
Layer.succeed(Retry, { while: () => false }),
|
|
49
|
-
);
|
|
43
|
+
export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
|
|
50
44
|
|
|
51
45
|
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
52
46
|
export const throttling = policy(throttlingFactory);
|