@distilled.cloud/typesense 0.17.0 → 0.18.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.
@@ -1,6 +1,6 @@
1
+ import * as Context from "effect/Context";
1
2
  import * as Layer from "effect/Layer";
2
3
  import * as Redacted from "effect/Redacted";
3
- import * as Context from "effect/Context";
4
4
  import { ConfigError } from "@distilled.cloud/core/errors";
5
5
  /**
6
6
  * Typesense has no fixed default base URL — users run their own server
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAEhC;CAAG;AAEJ,eAAO,MAAM,kBAAkB,8CAoB9B,CAAC"}
1
+ {"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAE1C,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,KAAK,CAAC;AAEvC,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAEhC;CAAG;AAOJ,eAAO,MAAM,kBAAkB,8CAe9B,CAAC"}
@@ -1,7 +1,8 @@
1
+ import * as EffectConfig from "effect/Config";
2
+ import * as Context from "effect/Context";
1
3
  import * as Effect from "effect/Effect";
2
4
  import * as Layer from "effect/Layer";
3
5
  import * as Redacted from "effect/Redacted";
4
- import * as Context from "effect/Context";
5
6
  import { ConfigError } from "@distilled.cloud/core/errors";
6
7
  /**
7
8
  * Typesense has no fixed default base URL — users run their own server
@@ -11,19 +12,14 @@ import { ConfigError } from "@distilled.cloud/core/errors";
11
12
  export const DEFAULT_API_BASE_URL = "";
12
13
  export class Credentials extends Context.Service()("TypesenseCredentials") {
13
14
  }
14
- export const CredentialsFromEnv = Layer.effect(Credentials, Effect.gen(function* () {
15
- const apiKey = process.env.TYPESENSE_API_KEY;
16
- const apiBaseUrl = process.env.TYPESENSE_API_URL ?? DEFAULT_API_BASE_URL;
17
- if (!apiKey) {
18
- return yield* new ConfigError({
19
- message: "TYPESENSE_API_KEY environment variable is required",
20
- });
21
- }
22
- if (!apiBaseUrl) {
23
- return yield* new ConfigError({
24
- message: "TYPESENSE_API_URL environment variable is required",
25
- });
26
- }
27
- return { apiKey: Redacted.make(apiKey), apiBaseUrl };
28
- }));
15
+ const envConfig = EffectConfig.all({
16
+ apiKey: EffectConfig.string("TYPESENSE_API_KEY"),
17
+ apiBaseUrl: EffectConfig.string("TYPESENSE_API_URL"),
18
+ });
19
+ export const CredentialsFromEnv = Layer.effect(Credentials, envConfig.asEffect().pipe(Effect.mapError(() => new ConfigError({
20
+ message: "TYPESENSE_API_KEY and TYPESENSE_API_URL environment variables are required",
21
+ })), Effect.map(({ apiKey, apiBaseUrl }) => ({
22
+ apiKey: Redacted.make(apiKey),
23
+ apiBaseUrl,
24
+ }))));
29
25
  //# sourceMappingURL=credentials.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAOvC,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAAuB,CACrE,sBAAsB,CACvB;CAAG;AAEJ,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CAC5C,WAAW,EACX,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC;IAC7C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,oBAAoB,CAAC;IAEzE,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC;YAC5B,OAAO,EAAE,oDAAoD;SAC9D,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,OAAO,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC;YAC5B,OAAO,EAAE,oDAAoD;SAC9D,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,CAAC;AACvD,CAAC,CAAC,CACH,CAAC"}
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,YAAY,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAOvC,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAAuB,CACrE,sBAAsB,CACvB;CAAG;AAEJ,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,mBAAmB,CAAC;IAChD,UAAU,EAAE,YAAY,CAAC,MAAM,CAAC,mBAAmB,CAAC;CACrD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CAC5C,WAAW,EACX,SAAS,CAAC,QAAQ,EAAE,CAAC,IAAI,CACvB,MAAM,CAAC,QAAQ,CACb,GAAG,EAAE,CACH,IAAI,WAAW,CAAC;IACd,OAAO,EACL,4EAA4E;CAC/E,CAAC,CACL,EACD,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC;IACtC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;IAC7B,UAAU;CACX,CAAC,CAAC,CACJ,CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/typesense",
3
- "version": "0.17.0",
3
+ "version": "0.18.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -70,10 +70,10 @@
70
70
  "publish:npm": "bun run build && bun publish --access public",
71
71
  "generate": "bun run scripts/generate.ts && oxlint --fix src && oxfmt --write src && oxfmt --write src",
72
72
  "specs:fetch": "git submodule update --force --init --recursive --depth=1 specs/typesense-api-spec && git -C specs/typesense-api-spec checkout -- .",
73
- "specs:update": "git -C specs/typesense-api-spec fetch && git -C specs/typesense-api-spec checkout main && git -C specs/typesense-api-spec pull"
73
+ "specs:update": "git -C specs/typesense-api-spec fetch && git -C specs/typesense-api-spec checkout master && git -C specs/typesense-api-spec pull"
74
74
  },
75
75
  "dependencies": {
76
- "@distilled.cloud/core": "0.17.0"
76
+ "@distilled.cloud/core": "0.18.0"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@types/bun": "^1.3.0",
@@ -1,7 +1,8 @@
1
+ import * as EffectConfig from "effect/Config";
2
+ import * as Context from "effect/Context";
1
3
  import * as Effect from "effect/Effect";
2
4
  import * as Layer from "effect/Layer";
3
5
  import * as Redacted from "effect/Redacted";
4
- import * as Context from "effect/Context";
5
6
  import { ConfigError } from "@distilled.cloud/core/errors";
6
7
 
7
8
  /**
@@ -20,24 +21,24 @@ export class Credentials extends Context.Service<Credentials, Config>()(
20
21
  "TypesenseCredentials",
21
22
  ) {}
22
23
 
24
+ const envConfig = EffectConfig.all({
25
+ apiKey: EffectConfig.string("TYPESENSE_API_KEY"),
26
+ apiBaseUrl: EffectConfig.string("TYPESENSE_API_URL"),
27
+ });
28
+
23
29
  export const CredentialsFromEnv = Layer.effect(
24
30
  Credentials,
25
- Effect.gen(function* () {
26
- const apiKey = process.env.TYPESENSE_API_KEY;
27
- const apiBaseUrl = process.env.TYPESENSE_API_URL ?? DEFAULT_API_BASE_URL;
28
-
29
- if (!apiKey) {
30
- return yield* new ConfigError({
31
- message: "TYPESENSE_API_KEY environment variable is required",
32
- });
33
- }
34
-
35
- if (!apiBaseUrl) {
36
- return yield* new ConfigError({
37
- message: "TYPESENSE_API_URL environment variable is required",
38
- });
39
- }
40
-
41
- return { apiKey: Redacted.make(apiKey), apiBaseUrl };
42
- }),
31
+ envConfig.asEffect().pipe(
32
+ Effect.mapError(
33
+ () =>
34
+ new ConfigError({
35
+ message:
36
+ "TYPESENSE_API_KEY and TYPESENSE_API_URL environment variables are required",
37
+ }),
38
+ ),
39
+ Effect.map(({ apiKey, apiBaseUrl }) => ({
40
+ apiKey: Redacted.make(apiKey),
41
+ apiBaseUrl,
42
+ })),
43
+ ),
43
44
  );