@distilled.cloud/workos 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
  * WorkOS production API base URL.
@@ -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;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D,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,8CAc9B,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;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D,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;AASJ,eAAO,MAAM,kBAAkB,8CAc9B,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
  * WorkOS production API base URL.
@@ -12,14 +13,14 @@ import { ConfigError } from "@distilled.cloud/core/errors";
12
13
  export const DEFAULT_API_BASE_URL = "https://api.workos.com";
13
14
  export class Credentials extends Context.Service()("WorkosCredentials") {
14
15
  }
15
- export const CredentialsFromEnv = Layer.effect(Credentials, Effect.gen(function* () {
16
- const apiKey = process.env.WORKOS_API_KEY;
17
- const apiBaseUrl = process.env.WORKOS_API_URL ?? DEFAULT_API_BASE_URL;
18
- if (!apiKey) {
19
- return yield* new ConfigError({
20
- message: "WORKOS_API_KEY environment variable is required",
21
- });
22
- }
23
- return { apiKey: Redacted.make(apiKey), apiBaseUrl };
24
- }));
16
+ const envConfig = EffectConfig.all({
17
+ apiKey: EffectConfig.string("WORKOS_API_KEY"),
18
+ apiBaseUrl: EffectConfig.string("WORKOS_API_URL").pipe(EffectConfig.withDefault(DEFAULT_API_BASE_URL)),
19
+ });
20
+ export const CredentialsFromEnv = Layer.effect(Credentials, envConfig.asEffect().pipe(Effect.mapError(() => new ConfigError({
21
+ message: "WORKOS_API_KEY environment variable is required",
22
+ })), Effect.map(({ apiKey, apiBaseUrl }) => ({
23
+ apiKey: Redacted.make(apiKey),
24
+ apiBaseUrl,
25
+ }))));
25
26
  //# sourceMappingURL=credentials.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"credentials.js","sourceRoot":"","sources":["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EAAE,MAAM,8BAA8B,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,wBAAwB,CAAC;AAO7D,MAAM,OAAO,WAAY,SAAQ,OAAO,CAAC,OAAO,EAAuB,CACrE,mBAAmB,CACpB;CAAG;AAEJ,MAAM,SAAS,GAAG,YAAY,CAAC,GAAG,CAAC;IACjC,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC;IAC7C,UAAU,EAAE,YAAY,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,IAAI,CACpD,YAAY,CAAC,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,iDAAiD;CAC3D,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/workos",
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",
@@ -73,7 +73,7 @@
73
73
  "specs:update": "git -C specs/openapi-spec fetch && git -C specs/openapi-spec checkout main && git -C specs/openapi-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
  /**
@@ -21,18 +22,25 @@ export class Credentials extends Context.Service<Credentials, Config>()(
21
22
  "WorkosCredentials",
22
23
  ) {}
23
24
 
25
+ const envConfig = EffectConfig.all({
26
+ apiKey: EffectConfig.string("WORKOS_API_KEY"),
27
+ apiBaseUrl: EffectConfig.string("WORKOS_API_URL").pipe(
28
+ EffectConfig.withDefault(DEFAULT_API_BASE_URL),
29
+ ),
30
+ });
31
+
24
32
  export const CredentialsFromEnv = Layer.effect(
25
33
  Credentials,
26
- Effect.gen(function* () {
27
- const apiKey = process.env.WORKOS_API_KEY;
28
- const apiBaseUrl = process.env.WORKOS_API_URL ?? DEFAULT_API_BASE_URL;
29
-
30
- if (!apiKey) {
31
- return yield* new ConfigError({
32
- message: "WORKOS_API_KEY environment variable is required",
33
- });
34
- }
35
-
36
- return { apiKey: Redacted.make(apiKey), apiBaseUrl };
37
- }),
34
+ envConfig.asEffect().pipe(
35
+ Effect.mapError(
36
+ () =>
37
+ new ConfigError({
38
+ message: "WORKOS_API_KEY environment variable is required",
39
+ }),
40
+ ),
41
+ Effect.map(({ apiKey, apiBaseUrl }) => ({
42
+ apiKey: Redacted.make(apiKey),
43
+ apiBaseUrl,
44
+ })),
45
+ ),
38
46
  );