@distilled.cloud/typesense 1.0.0-rc.15 → 1.0.0-rc.16
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/lib/credentials.d.ts +2 -2
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +25 -22
- package/lib/credentials.js.map +1 -1
- package/lib/errors.d.ts +12 -12
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +12 -12
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.js +7 -7
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +17 -20
- 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 +26 -25
- package/lib/retry.js.map +1 -1
- package/lib/services/typesense.d.ts +7 -342
- package/lib/services/typesense.d.ts.map +1 -1
- package/lib/services/typesense.js +258 -2624
- package/lib/traits.d.ts +1 -1
- package/lib/traits.js +8 -8
- package/package.json +15 -11
- package/src/credentials.ts +15 -14
- package/src/errors.ts +9 -13
- package/src/index.ts +1 -1
- package/src/protocol.ts +6 -9
- package/src/retry.ts +6 -4
- package/src/services/typesense.ts +2556 -3163
- package/src/traits.ts +1 -1
- package/lib/services/typesense.js.map +0 -1
package/lib/traits.d.ts
CHANGED
package/lib/traits.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
9
|
export { SensitiveValue, RawResponse, RawResponseRoot, sensitiveValueSymbol, rawResponseSymbol, rawResponseRootSymbol, } from "@distilled.cloud/core/protocol-rest";
|
|
10
10
|
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";
|
|
11
11
|
//# sourceMappingURL=traits.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/typesense",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.16",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -42,13 +42,17 @@
|
|
|
42
42
|
"types": "./lib/index.d.ts",
|
|
43
43
|
"bun": "./src/index.ts",
|
|
44
44
|
"worker": "./src/index.ts",
|
|
45
|
-
"
|
|
45
|
+
"module": "./lib/index.full.js",
|
|
46
|
+
"module-sync": "./lib/index.js",
|
|
47
|
+
"default": "./lib/index.full.js"
|
|
46
48
|
},
|
|
47
49
|
"./*": {
|
|
48
50
|
"types": "./lib/services/*.d.ts",
|
|
49
51
|
"bun": "./src/services/*.ts",
|
|
50
52
|
"worker": "./src/services/*.ts",
|
|
51
|
-
"
|
|
53
|
+
"module": "./lib/services.full/*.js",
|
|
54
|
+
"module-sync": "./lib/services/*.js",
|
|
55
|
+
"default": "./lib/services.full/*.js"
|
|
52
56
|
},
|
|
53
57
|
"./Protocol": {
|
|
54
58
|
"types": "./lib/protocol.d.ts",
|
|
@@ -64,25 +68,25 @@
|
|
|
64
68
|
}
|
|
65
69
|
},
|
|
66
70
|
"dependencies": {
|
|
67
|
-
"@distilled.cloud/core": "1.0.0-rc.
|
|
71
|
+
"@distilled.cloud/core": "1.0.0-rc.16"
|
|
68
72
|
},
|
|
69
73
|
"devDependencies": {
|
|
70
|
-
"@types/node": "26.
|
|
71
|
-
"yaml": "^2.9.
|
|
74
|
+
"@types/node": "26.6.5",
|
|
75
|
+
"yaml": "^2.9.1"
|
|
72
76
|
},
|
|
73
77
|
"peerDependencies": {
|
|
74
|
-
"effect": "^4.0.
|
|
78
|
+
"effect": "^4.0.5"
|
|
75
79
|
},
|
|
76
80
|
"distilled": {
|
|
77
|
-
"generatedAt": "2026-10-
|
|
81
|
+
"generatedAt": "2026-10-09",
|
|
78
82
|
"specUpdatedAt": "2026-09-11"
|
|
79
83
|
},
|
|
80
84
|
"scripts": {
|
|
81
|
-
"build": "
|
|
85
|
+
"build": "tsrs -b",
|
|
82
86
|
"convert": "node --conditions=bun scripts/convert.ts",
|
|
83
87
|
"generate": "node --conditions=bun scripts/generate.ts",
|
|
84
|
-
"typecheck": "
|
|
85
|
-
"typecheck:strict": "
|
|
88
|
+
"typecheck": "tsrs -p tsconfig.json",
|
|
89
|
+
"typecheck:strict": "tsrs -p tsconfig.strict.json",
|
|
86
90
|
"specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-typesense",
|
|
87
91
|
"specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-typesense"
|
|
88
92
|
}
|
package/src/credentials.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
+
import * as EffectConfig from "@distilled.cloud/core/config";
|
|
1
2
|
/**
|
|
2
|
-
* Typesense credentials
|
|
3
|
+
* Typesense credentials -- hand-written.
|
|
3
4
|
*
|
|
4
5
|
* API-compatible port of the distilled repo's typesense credentials module:
|
|
5
6
|
* a static API key sent as the `X-TYPESENSE-API-KEY` header plus a
|
|
6
7
|
* caller-supplied base URL. The `Credentials` service holds an *effect* so
|
|
7
|
-
* layers may resolve the key lazily (env, vaults,
|
|
8
|
+
* layers may resolve the key lazily (env, vaults, ...).
|
|
8
9
|
*/
|
|
9
10
|
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
10
|
-
import * as EffectConfig from "effect/Config";
|
|
11
11
|
import * as Context from "effect/Context";
|
|
12
12
|
import * as Effect from "effect/Effect";
|
|
13
13
|
import * as Layer from "effect/Layer";
|
|
14
14
|
import * as Redacted from "effect/Redacted";
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* Typesense has no fixed default base URL
|
|
17
|
+
* Typesense has no fixed default base URL -- users run their own server
|
|
18
18
|
* (e.g. http://localhost:8108) or use Typesense Cloud (per-cluster URLs
|
|
19
19
|
* like https://xxx.a1.typesense.net). Users must supply TYPESENSE_API_URL.
|
|
20
20
|
*/
|
|
@@ -25,25 +25,26 @@ export interface Config {
|
|
|
25
25
|
readonly apiBaseUrl: string;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
export class Credentials
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
export class Credentials
|
|
29
|
+
extends /*@__PURE__*/ Context.Service<Credentials, Effect.Effect<Config>>()(
|
|
30
|
+
"TypesenseCredentials",
|
|
31
|
+
) {}
|
|
31
32
|
|
|
32
|
-
const envConfig = EffectConfig.all({
|
|
33
|
-
apiKey: EffectConfig.String("TYPESENSE_API_KEY"),
|
|
34
|
-
apiBaseUrl: EffectConfig.String("TYPESENSE_API_URL"),
|
|
33
|
+
const envConfig = /*@__PURE__*/ EffectConfig.all({
|
|
34
|
+
apiKey: /*@__PURE__*/ EffectConfig.String("TYPESENSE_API_KEY"),
|
|
35
|
+
apiBaseUrl: /*@__PURE__*/ EffectConfig.String("TYPESENSE_API_URL"),
|
|
35
36
|
});
|
|
36
37
|
|
|
37
|
-
export const CredentialsFromEnv = Layer.succeed(
|
|
38
|
+
export const CredentialsFromEnv = /*@__PURE__*/ Layer.succeed(
|
|
38
39
|
Credentials,
|
|
39
|
-
envConfig.pipe(
|
|
40
|
-
Effect.mapError(
|
|
40
|
+
/*@__PURE__*/ envConfig.pipe(
|
|
41
|
+
/*@__PURE__*/ Effect.mapError(
|
|
41
42
|
() =>
|
|
42
43
|
new ConfigError({
|
|
43
44
|
message: "TYPESENSE_API_KEY and TYPESENSE_API_URL environment variables are required",
|
|
44
45
|
}),
|
|
45
46
|
),
|
|
46
|
-
Effect.map(({ apiKey, apiBaseUrl }) => ({
|
|
47
|
+
/*@__PURE__*/ Effect.map(({ apiKey, apiBaseUrl }) => ({
|
|
47
48
|
apiKey: Redacted.make(apiKey),
|
|
48
49
|
apiBaseUrl,
|
|
49
50
|
})),
|
package/src/errors.ts
CHANGED
|
@@ -25,26 +25,22 @@ export {
|
|
|
25
25
|
} from "@distilled.cloud/core/errors";
|
|
26
26
|
import * as Category from "@distilled.cloud/core/category";
|
|
27
27
|
import type { DefaultErrors as CoreDefaultErrors } from "@distilled.cloud/core/errors";
|
|
28
|
-
import * as Schema from "
|
|
28
|
+
import * as Schema from "@distilled.cloud/core/schema-lite-typed";
|
|
29
29
|
|
|
30
30
|
// Unknown Typesense error - returned when an error code is not recognized
|
|
31
|
-
export class UnknownTypesenseError
|
|
32
|
-
"UnknownTypesenseError",
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
message: Schema.optional(Schema.String),
|
|
31
|
+
export class UnknownTypesenseError
|
|
32
|
+
extends /*@__PURE__*/ Schema.TaggedError<UnknownTypesenseError>()("UnknownTypesenseError", {
|
|
33
|
+
code: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
34
|
+
message: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
36
35
|
body: Schema.Unknown,
|
|
37
|
-
}
|
|
38
|
-
).pipe(Category.withServerError) {}
|
|
36
|
+
}).pipe(Category.withServerError) {}
|
|
39
37
|
|
|
40
38
|
// Schema parse error wrapper
|
|
41
|
-
export class TypesenseParseError
|
|
42
|
-
"TypesenseParseError",
|
|
43
|
-
{
|
|
39
|
+
export class TypesenseParseError
|
|
40
|
+
extends /*@__PURE__*/ Schema.TaggedError<TypesenseParseError>()("TypesenseParseError", {
|
|
44
41
|
body: Schema.Unknown,
|
|
45
42
|
cause: Schema.Unknown,
|
|
46
|
-
}
|
|
47
|
-
).pipe(Category.withParseError) {}
|
|
43
|
+
}).pipe(Category.withParseError) {}
|
|
48
44
|
|
|
49
45
|
/**
|
|
50
46
|
* Errors that any Typesense operation may surface in addition to
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @distilled.cloud/typesense
|
|
2
|
+
* @distilled.cloud/typesense -- Typesense SDK for Effect.
|
|
3
3
|
*
|
|
4
4
|
* `./services` is generated by `scripts/generate.ts` from the Smithy model
|
|
5
5
|
* in `.generated-specs` (converted from the Typesense OpenAPI spec by
|
package/src/protocol.ts
CHANGED
|
@@ -2,11 +2,11 @@ import type * as API from "@distilled.cloud/core/api";
|
|
|
2
2
|
import type { ConfigError } from "@distilled.cloud/core/errors";
|
|
3
3
|
import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
|
|
4
4
|
/**
|
|
5
|
-
* TypesenseProtocol
|
|
5
|
+
* TypesenseProtocol -- the shared bearer/header-auth REST factory from core,
|
|
6
6
|
* instantiated with Typesense's specifics:
|
|
7
7
|
*
|
|
8
8
|
* request: base URL from the caller's credentials (Typesense has no fixed
|
|
9
|
-
* default
|
|
9
|
+
* default -- self-hosted servers and per-cluster Cloud URLs), auth
|
|
10
10
|
* via the `X-TYPESENSE-API-KEY` header
|
|
11
11
|
*
|
|
12
12
|
* response: plain JSON, no envelope. Non-2xx bodies decode against
|
|
@@ -32,16 +32,13 @@ export type TypesenseOpError = DefaultErrors | ConfigError | HttpClientError.Htt
|
|
|
32
32
|
/** Context (requirements) shared by every generated Typesense operation. */
|
|
33
33
|
export type TypesenseOpContext = Credentials | HttpClient.HttpClient;
|
|
34
34
|
|
|
35
|
-
export const TypesenseProtocol: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
|
|
36
|
-
// Resolved on the calling fiber, per request
|
|
35
|
+
export const TypesenseProtocol: Layer.Layer<API.Protocol> = /*@__PURE__*/ makeRestProtocol<Config>({
|
|
36
|
+
// Resolved on the calling fiber, per request -- the Credentials service
|
|
37
37
|
// holds an effect, so lazily-resolved keys Just Work.
|
|
38
|
-
credentials: Effect.
|
|
39
|
-
const resolve = yield* Credentials;
|
|
40
|
-
return yield* resolve;
|
|
41
|
-
}),
|
|
38
|
+
credentials: /*@__PURE__*/ Effect.flatMap(Credentials, (resolve) => resolve),
|
|
42
39
|
baseUrl: (creds) => creds.apiBaseUrl,
|
|
43
40
|
headers: formatHeaders,
|
|
44
|
-
// Typesense's ApiResponse error body is `{ message }`
|
|
41
|
+
// Typesense's ApiResponse error body is `{ message }` -- covered by the
|
|
45
42
|
// factory's default envelope reader.
|
|
46
43
|
unknownError: ({ message, body }) => new UnknownTypesenseError({ message, body }),
|
|
47
44
|
parseError: ({ body, cause }) => new TypesenseParseError({ body, cause }),
|
package/src/retry.ts
CHANGED
|
@@ -33,17 +33,19 @@ export {
|
|
|
33
33
|
} from "@distilled.cloud/core/retry";
|
|
34
34
|
|
|
35
35
|
/** Context tag for configuring retry behavior of Typesense API calls. */
|
|
36
|
-
export class Retry extends Context.Service<Retry, Policy>()("TypesenseRetry") {}
|
|
36
|
+
export class Retry extends /*@__PURE__*/ Context.Service<Retry, Policy>()("TypesenseRetry") {}
|
|
37
37
|
|
|
38
38
|
/** Provides a custom retry policy to every Typesense API call below it. */
|
|
39
39
|
export const policy = (optionsOrFactory: Policy) =>
|
|
40
40
|
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
41
41
|
|
|
42
42
|
/** Disables all automatic retries. */
|
|
43
|
-
export const none = Effect.provide(
|
|
43
|
+
export const none = /*@__PURE__*/ Effect.provide(
|
|
44
|
+
/*@__PURE__*/ Layer.succeed(Retry, { while: () => false }),
|
|
45
|
+
);
|
|
44
46
|
|
|
45
47
|
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
46
|
-
export const throttling = policy(throttlingFactory);
|
|
48
|
+
export const throttling = /*@__PURE__*/ policy(throttlingFactory);
|
|
47
49
|
|
|
48
50
|
/** Apply the transient retry policy (retries all transient errors indefinitely). */
|
|
49
|
-
export const transient = policy(transientFactory);
|
|
51
|
+
export const transient = /*@__PURE__*/ policy(transientFactory);
|