@effect/platform 0.69.9 → 0.69.11

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.
Files changed (40) hide show
  1. package/HttpApiScalar/package.json +6 -0
  2. package/dist/cjs/HttpApiError.js +1 -1
  3. package/dist/cjs/HttpApiScalar.js +59 -0
  4. package/dist/cjs/HttpApiScalar.js.map +1 -0
  5. package/dist/cjs/HttpApiSwagger.js +1 -1
  6. package/dist/cjs/index.js +3 -1
  7. package/dist/cjs/internal/httpApiScalar.js +2 -0
  8. package/dist/cjs/internal/httpApiScalar.js.map +1 -0
  9. package/dist/cjs/internal/{apiSwagger.js → httpApiSwagger.js} +1 -1
  10. package/dist/cjs/internal/httpApiSwagger.js.map +1 -0
  11. package/dist/dts/HttpApiScalar.d.ts +106 -0
  12. package/dist/dts/HttpApiScalar.d.ts.map +1 -0
  13. package/dist/dts/index.d.ts +4 -0
  14. package/dist/dts/index.d.ts.map +1 -1
  15. package/dist/dts/internal/httpApiScalar.d.ts +2 -0
  16. package/dist/dts/internal/httpApiScalar.d.ts.map +1 -0
  17. package/dist/dts/internal/httpApiSwagger.d.ts +2 -0
  18. package/dist/dts/internal/httpApiSwagger.d.ts.map +1 -0
  19. package/dist/esm/HttpApiError.js +1 -1
  20. package/dist/esm/HttpApiScalar.js +49 -0
  21. package/dist/esm/HttpApiScalar.js.map +1 -0
  22. package/dist/esm/HttpApiSwagger.js +1 -1
  23. package/dist/esm/HttpApiSwagger.js.map +1 -1
  24. package/dist/esm/index.js +4 -0
  25. package/dist/esm/index.js.map +1 -1
  26. package/dist/esm/internal/httpApiScalar.js +2 -0
  27. package/dist/esm/internal/httpApiScalar.js.map +1 -0
  28. package/dist/esm/internal/{apiSwagger.js → httpApiSwagger.js} +1 -1
  29. package/dist/esm/internal/httpApiSwagger.js.map +1 -0
  30. package/package.json +10 -2
  31. package/src/HttpApiError.ts +1 -1
  32. package/src/HttpApiScalar.ts +187 -0
  33. package/src/HttpApiSwagger.ts +1 -1
  34. package/src/index.ts +5 -0
  35. package/src/internal/httpApiScalar.ts +4 -0
  36. package/dist/cjs/internal/apiSwagger.js.map +0 -1
  37. package/dist/dts/internal/apiSwagger.d.ts +0 -2
  38. package/dist/dts/internal/apiSwagger.d.ts.map +0 -1
  39. package/dist/esm/internal/apiSwagger.js.map +0 -1
  40. /package/src/internal/{apiSwagger.ts → httpApiSwagger.ts} +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"httpApiSwagger.js","names":["javascript","css"],"sources":["../../../src/internal/httpApiSwagger.ts"],"sourcesContent":[null],"mappings":"AAAA,qBAEA,gBACA,MAAO,MAAM,CAAAA,UAAU,CAAG,m1lpDAAm1lpD,CAE72lpD,gBACA,MAAO,MAAM,CAAAC,GAAG,CAAG,wopJAAwopJ","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@effect/platform",
3
- "version": "0.69.9",
3
+ "version": "0.69.11",
4
4
  "description": "Unified interfaces for common platform-specific services",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -14,7 +14,7 @@
14
14
  "multipasta": "^0.2.5"
15
15
  },
16
16
  "peerDependencies": {
17
- "effect": "^3.10.4"
17
+ "effect": "^3.10.6"
18
18
  },
19
19
  "publishConfig": {
20
20
  "provenance": true
@@ -109,6 +109,11 @@
109
109
  "import": "./dist/esm/HttpApiMiddleware.js",
110
110
  "default": "./dist/cjs/HttpApiMiddleware.js"
111
111
  },
112
+ "./HttpApiScalar": {
113
+ "types": "./dist/dts/HttpApiScalar.d.ts",
114
+ "import": "./dist/esm/HttpApiScalar.js",
115
+ "default": "./dist/cjs/HttpApiScalar.js"
116
+ },
112
117
  "./HttpApiSchema": {
113
118
  "types": "./dist/dts/HttpApiSchema.d.ts",
114
119
  "import": "./dist/esm/HttpApiSchema.js",
@@ -345,6 +350,9 @@
345
350
  "HttpApiMiddleware": [
346
351
  "./dist/dts/HttpApiMiddleware.d.ts"
347
352
  ],
353
+ "HttpApiScalar": [
354
+ "./dist/dts/HttpApiScalar.d.ts"
355
+ ],
348
356
  "HttpApiSchema": [
349
357
  "./dist/dts/HttpApiSchema.d.ts"
350
358
  ],
@@ -90,7 +90,7 @@ export class HttpApiDecodeError extends Schema.TaggedError<HttpApiDecodeError>()
90
90
  },
91
91
  HttpApiSchema.annotations({
92
92
  status: 400,
93
- description: "HttpApiDecodeError: The request did not match the expected schema"
93
+ description: "The request did not match the expected schema"
94
94
  })
95
95
  ) {
96
96
  /**
@@ -0,0 +1,187 @@
1
+ /**
2
+ * @since 1.0.0
3
+ */
4
+ import * as Effect from "effect/Effect"
5
+ import type { Layer } from "effect/Layer"
6
+ import { Api } from "./HttpApi.js"
7
+ import { Router } from "./HttpApiBuilder.js"
8
+ import * as HttpServerResponse from "./HttpServerResponse.js"
9
+ import * as internal from "./internal/httpApiScalar.js"
10
+ import * as OpenApi from "./OpenApi.js"
11
+
12
+ /**
13
+ * @since 1.0.0
14
+ * @category model
15
+ */
16
+ export type ScalarThemeId =
17
+ | "alternate"
18
+ | "default"
19
+ | "moon"
20
+ | "purple"
21
+ | "solarized"
22
+ | "bluePlanet"
23
+ | "deepSpace"
24
+ | "saturn"
25
+ | "kepler"
26
+ | "mars"
27
+ | "none"
28
+
29
+ /**
30
+ * @since 1.0.0
31
+ * @category model
32
+ *
33
+ * cdn: `https://cdn.jsdelivr.net/npm/@scalar/api-reference@${source.version}/dist/browser/standalone.min.js`
34
+ */
35
+ export type ScalarScriptSource =
36
+ | string
37
+ | { type: "default" }
38
+ | {
39
+ type: "cdn"
40
+ version?: "latest" | (string & {})
41
+ }
42
+
43
+ /**
44
+ * @since 1.0.0
45
+ * @category model
46
+ * @see https://github.com/scalar/scalar/blob/main/documentation/configuration.md
47
+ */
48
+ export type ScalarConfig = {
49
+ /** A string to use one of the color presets */
50
+ theme?: ScalarThemeId
51
+ /** The layout to use for the references */
52
+ layout?: "modern" | "classic"
53
+ /** URL to a request proxy for the API client */
54
+ proxy?: string
55
+ /** Whether the spec input should show */
56
+ isEditable?: boolean
57
+ /** Whether to show the sidebar */
58
+ showSidebar?: boolean
59
+ /**
60
+ * Whether to show models in the sidebar, search, and content.
61
+ *
62
+ * @default false
63
+ */
64
+ hideModels?: boolean
65
+ /**
66
+ * Whether to show the “Download OpenAPI Document” button
67
+ *
68
+ * @default false
69
+ */
70
+ hideDownloadButton?: boolean
71
+ /**
72
+ * Whether to show the “Test Request” button
73
+ *
74
+ * @default: false
75
+ */
76
+ hideTestRequestButton?: boolean
77
+ /**
78
+ * Whether to show the sidebar search bar
79
+ *
80
+ * @default: false
81
+ */
82
+ hideSearch?: boolean
83
+ /** Whether dark mode is on or off initially (light mode) */
84
+ darkMode?: boolean
85
+ /** forceDarkModeState makes it always this state no matter what*/
86
+ forceDarkModeState?: "dark" | "light"
87
+ /** Whether to show the dark mode toggle */
88
+ hideDarkModeToggle?: boolean
89
+ /**
90
+ * Path to a favicon image
91
+ *
92
+ * @default undefined
93
+ * @example '/favicon.svg'
94
+ */
95
+ favicon?: string
96
+ /** Custom CSS to be added to the page */
97
+ customCss?: string
98
+ /**
99
+ * The baseServerURL is used when the spec servers are relative paths and we are using SSR.
100
+ * On the client we can grab the window.location.origin but on the server we need
101
+ * to use this prop.
102
+ *
103
+ * @default undefined
104
+ * @example 'http://localhost:3000'
105
+ */
106
+ baseServerURL?: string
107
+ /**
108
+ * We’re using Inter and JetBrains Mono as the default fonts. If you want to use your own fonts, set this to false.
109
+ *
110
+ * @default true
111
+ */
112
+ withDefaultFonts?: boolean
113
+ /**
114
+ * By default we only open the relevant tag based on the url, however if you want all the tags open by default then set this configuration option :)
115
+ *
116
+ * @default false
117
+ */
118
+ defaultOpenAllTags?: boolean
119
+ }
120
+
121
+ /**
122
+ * @since 1.0.0
123
+ * @category layers
124
+ */
125
+ export const layer = (options?: {
126
+ readonly path?: `/${string}` | undefined
127
+ readonly source?: ScalarScriptSource
128
+ readonly scalar?: ScalarConfig
129
+ }): Layer<never, never, Api> =>
130
+ Router.use((router) =>
131
+ Effect.gen(function*() {
132
+ const { api } = yield* Api
133
+ const spec = OpenApi.fromApi(api)
134
+
135
+ const source = options?.source
136
+ const defaultScript = internal.javascript
137
+ const src: string | null = source
138
+ ? typeof source === "string"
139
+ ? source
140
+ : source.type === "cdn"
141
+ ? `https://cdn.jsdelivr.net/npm/@scalar/api-reference@${
142
+ source.version ?? "latest"
143
+ }/dist/browser/standalone.min.js`
144
+ : null
145
+ : null
146
+
147
+ const scalarConfig = {
148
+ _integration: "http",
149
+ ...options?.scalar
150
+ }
151
+
152
+ const response = HttpServerResponse.html(`<!doctype html>
153
+ <html>
154
+ <head>
155
+ <meta charset="utf-8" />
156
+ <title>${spec.info.title}</title>
157
+ ${
158
+ !spec.info.description
159
+ ? ""
160
+ : `<meta name="description" content="${spec.info.description}"/>`
161
+ }
162
+ ${
163
+ !spec.info.description
164
+ ? ""
165
+ : `<meta name="og:description" content="${spec.info.description}"/>`
166
+ }
167
+ <meta
168
+ name="viewport"
169
+ content="width=device-width, initial-scale=1" />
170
+ </head>
171
+ <body>
172
+ <script id="api-reference" type="application/json">
173
+ ${JSON.stringify(spec)}
174
+ </script>
175
+ <script>
176
+ document.getElementById('api-reference').dataset.configuration = JSON.stringify(${JSON.stringify(scalarConfig)})
177
+ </script>
178
+ ${
179
+ src
180
+ ? `<script src="${src}" crossorigin></script>`
181
+ : `<script>${defaultScript}</script>`
182
+ }
183
+ </body>
184
+ </html>`)
185
+ yield* router.get(options?.path ?? "/docs", Effect.succeed(response))
186
+ })
187
+ )
@@ -6,7 +6,7 @@ import type { Layer } from "effect/Layer"
6
6
  import { Api } from "./HttpApi.js"
7
7
  import { Router } from "./HttpApiBuilder.js"
8
8
  import * as HttpServerResponse from "./HttpServerResponse.js"
9
- import * as internal from "./internal/apiSwagger.js"
9
+ import * as internal from "./internal/httpApiSwagger.js"
10
10
  import * as OpenApi from "./OpenApi.js"
11
11
 
12
12
  /**
package/src/index.ts CHANGED
@@ -78,6 +78,11 @@ export * as HttpApiGroup from "./HttpApiGroup.js"
78
78
  */
79
79
  export * as HttpApiMiddleware from "./HttpApiMiddleware.js"
80
80
 
81
+ /**
82
+ * @since 1.0.0
83
+ */
84
+ export * as HttpApiScalar from "./HttpApiScalar.js"
85
+
81
86
  /**
82
87
  * @since 1.0.0
83
88
  */