@distilled.cloud/posthog 0.17.0 → 0.18.1

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,5 +1,5 @@
1
- import * as Layer from "effect/Layer";
2
1
  import * as Context from "effect/Context";
2
+ import * as Layer from "effect/Layer";
3
3
  import { ConfigError } from "@distilled.cloud/core/errors";
4
4
  /**
5
5
  * Default PostHog API host (US Cloud).
@@ -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,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D,MAAM,WAAW,MAAM;IACrB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAEhC;CAAG;AAEJ,eAAO,MAAM,kBAAkB,8CAe9B,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,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;;;GAMG;AACH,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D,MAAM,WAAW,MAAM;IACrB,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,oDAAoD;IACpD,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAEhC;CAAG;AASJ,eAAO,MAAM,kBAAkB,8CAU9B,CAAC"}
@@ -1,6 +1,7 @@
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
- import * as Context from "effect/Context";
4
5
  import { ConfigError } from "@distilled.cloud/core/errors";
5
6
  /**
6
7
  * Default PostHog API host (US Cloud).
@@ -12,14 +13,11 @@ import { ConfigError } from "@distilled.cloud/core/errors";
12
13
  export const DEFAULT_API_BASE_URL = "https://us.posthog.com";
13
14
  export class Credentials extends Context.Service()("PosthogCredentials") {
14
15
  }
15
- export const CredentialsFromEnv = Layer.effect(Credentials, Effect.gen(function* () {
16
- const apiKey = process.env.POSTHOG_API_KEY;
17
- if (!apiKey) {
18
- return yield* new ConfigError({
19
- message: "POSTHOG_API_KEY environment variable is required",
20
- });
21
- }
22
- const apiBaseUrl = process.env.POSTHOG_HOST ?? DEFAULT_API_BASE_URL;
23
- return { apiKey, apiBaseUrl };
24
- }));
16
+ const envConfig = EffectConfig.all({
17
+ apiKey: EffectConfig.string("POSTHOG_API_KEY"),
18
+ apiBaseUrl: EffectConfig.string("POSTHOG_HOST").pipe(EffectConfig.withDefault(DEFAULT_API_BASE_URL)),
19
+ });
20
+ export const CredentialsFromEnv = Layer.effect(Credentials, envConfig.asEffect().pipe(Effect.mapError(() => new ConfigError({
21
+ message: "POSTHOG_API_KEY environment variable is required",
22
+ }))));
25
23
  //# 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,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;;;GAMG;AACH,MAA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C,WAAW,CAAC,oBAAoB,CAAC,CAC/C;CACF,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,EAAE,kDAAkD;CAC5D,CAAC,CACL,CACF,CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/posthog",
3
- "version": "0.17.0",
3
+ "version": "0.18.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -73,7 +73,7 @@
73
73
  "specs:update": "git -C specs/distilled-spec-posthog fetch && git -C specs/distilled-spec-posthog checkout main && git -C specs/distilled-spec-posthog pull"
74
74
  },
75
75
  "dependencies": {
76
- "@distilled.cloud/core": "0.17.0"
76
+ "@distilled.cloud/core": "0.18.1"
77
77
  },
78
78
  "devDependencies": {
79
79
  "@effect/platform-node": ">=4.0.0-beta.60 || >=4.0.0",
@@ -1,6 +1,7 @@
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
- import * as Context from "effect/Context";
4
5
  import { ConfigError } from "@distilled.cloud/core/errors";
5
6
 
6
7
  /**
@@ -23,19 +24,21 @@ export class Credentials extends Context.Service<Credentials, Config>()(
23
24
  "PosthogCredentials",
24
25
  ) {}
25
26
 
27
+ const envConfig = EffectConfig.all({
28
+ apiKey: EffectConfig.string("POSTHOG_API_KEY"),
29
+ apiBaseUrl: EffectConfig.string("POSTHOG_HOST").pipe(
30
+ EffectConfig.withDefault(DEFAULT_API_BASE_URL),
31
+ ),
32
+ });
33
+
26
34
  export const CredentialsFromEnv = Layer.effect(
27
35
  Credentials,
28
- Effect.gen(function* () {
29
- const apiKey = process.env.POSTHOG_API_KEY;
30
-
31
- if (!apiKey) {
32
- return yield* new ConfigError({
33
- message: "POSTHOG_API_KEY environment variable is required",
34
- });
35
- }
36
-
37
- const apiBaseUrl = process.env.POSTHOG_HOST ?? DEFAULT_API_BASE_URL;
38
-
39
- return { apiKey, apiBaseUrl };
40
- }),
36
+ envConfig.asEffect().pipe(
37
+ Effect.mapError(
38
+ () =>
39
+ new ConfigError({
40
+ message: "POSTHOG_API_KEY environment variable is required",
41
+ }),
42
+ ),
43
+ ),
41
44
  );