@encore.dev/sdk 2.0.0-beta.15 → 2.0.0-beta.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.
Files changed (235) hide show
  1. package/README.md +111 -101
  2. package/app_meta.ts +56 -54
  3. package/config/config.ts +60 -57
  4. package/config/secrets.ts +45 -52
  5. package/config/value.ts +23 -26
  6. package/cron/mod.ts +28 -29
  7. package/dist/app_meta.d.ts +52 -50
  8. package/dist/app_meta.d.ts.map +1 -1
  9. package/dist/app_meta.js +2 -2
  10. package/dist/app_meta.js.map +1 -1
  11. package/dist/config/config.d.ts +58 -55
  12. package/dist/config/config.d.ts.map +1 -1
  13. package/dist/config/config.js +8 -9
  14. package/dist/config/config.js.map +1 -1
  15. package/dist/config/secrets.d.ts +45 -52
  16. package/dist/config/secrets.d.ts.map +1 -1
  17. package/dist/config/secrets.js +8 -9
  18. package/dist/config/secrets.js.map +1 -1
  19. package/dist/config/value.d.ts +20 -23
  20. package/dist/config/value.d.ts.map +1 -1
  21. package/dist/config/value.js +20 -23
  22. package/dist/config/value.js.map +1 -1
  23. package/dist/cron/mod.d.ts +26 -27
  24. package/dist/cron/mod.d.ts.map +1 -1
  25. package/dist/cron/mod.js +13 -14
  26. package/dist/cron/mod.js.map +1 -1
  27. package/dist/frontends/mod.d.ts +20 -19
  28. package/dist/frontends/mod.d.ts.map +1 -1
  29. package/dist/frontends/mod.js +20 -19
  30. package/dist/frontends/mod.js.map +1 -1
  31. package/dist/gateway/errors.d.ts +28 -30
  32. package/dist/gateway/errors.d.ts.map +1 -1
  33. package/dist/gateway/errors.js +29 -31
  34. package/dist/gateway/errors.js.map +1 -1
  35. package/dist/gateway/match.d.ts +54 -54
  36. package/dist/gateway/match.d.ts.map +1 -1
  37. package/dist/gateway/match.js +56 -56
  38. package/dist/gateway/match.js.map +1 -1
  39. package/dist/gateway/middleware.d.ts +62 -64
  40. package/dist/gateway/middleware.d.ts.map +1 -1
  41. package/dist/gateway/middleware.js +1 -1
  42. package/dist/gateway/middleware.js.map +1 -1
  43. package/dist/gateway/mod.d.ts +64 -67
  44. package/dist/gateway/mod.d.ts.map +1 -1
  45. package/dist/gateway/mod.js +72 -76
  46. package/dist/gateway/mod.js.map +1 -1
  47. package/dist/gateway/request.d.ts +138 -134
  48. package/dist/gateway/request.d.ts.map +1 -1
  49. package/dist/gateway/request.js +117 -108
  50. package/dist/gateway/request.js.map +1 -1
  51. package/dist/gateway/serve.d.ts +29 -34
  52. package/dist/gateway/serve.d.ts.map +1 -1
  53. package/dist/gateway/serve.js +51 -56
  54. package/dist/gateway/serve.js.map +1 -1
  55. package/dist/gateways/mod.d.ts +23 -21
  56. package/dist/gateways/mod.d.ts.map +1 -1
  57. package/dist/gateways/mod.js +25 -23
  58. package/dist/gateways/mod.js.map +1 -1
  59. package/dist/internal/runtime/napi/napi.cjs +1 -1
  60. package/dist/internal/runtime/napi/napi.d.cts +10 -3
  61. package/dist/internal/runtime/shutdown.d.ts +75 -57
  62. package/dist/internal/runtime/shutdown.d.ts.map +1 -1
  63. package/dist/internal/runtime/shutdown.js +88 -84
  64. package/dist/internal/runtime/shutdown.js.map +1 -1
  65. package/dist/log/logger.d.ts +43 -37
  66. package/dist/log/logger.d.ts.map +1 -1
  67. package/dist/log/logger.js +26 -25
  68. package/dist/log/logger.js.map +1 -1
  69. package/dist/metrics/mod.d.ts +133 -114
  70. package/dist/metrics/mod.d.ts.map +1 -1
  71. package/dist/metrics/mod.js +109 -101
  72. package/dist/metrics/mod.js.map +1 -1
  73. package/dist/otel.d.ts +6 -3
  74. package/dist/otel.d.ts.map +1 -1
  75. package/dist/otel.js +6 -3
  76. package/dist/otel.js.map +1 -1
  77. package/dist/pubsub/subscription.d.ts +88 -116
  78. package/dist/pubsub/subscription.d.ts.map +1 -1
  79. package/dist/pubsub/subscription.js +14 -17
  80. package/dist/pubsub/subscription.js.map +1 -1
  81. package/dist/pubsub/topic.d.ts +86 -113
  82. package/dist/pubsub/topic.d.ts.map +1 -1
  83. package/dist/pubsub/topic.js +68 -82
  84. package/dist/pubsub/topic.js.map +1 -1
  85. package/dist/reqctx/mod.d.ts +83 -86
  86. package/dist/reqctx/mod.d.ts.map +1 -1
  87. package/dist/reqctx/mod.js +39 -41
  88. package/dist/reqctx/mod.js.map +1 -1
  89. package/dist/services/index.d.ts +76 -75
  90. package/dist/services/index.d.ts.map +1 -1
  91. package/dist/services/index.js +73 -71
  92. package/dist/services/index.js.map +1 -1
  93. package/dist/shutdown/mod.d.ts +26 -25
  94. package/dist/shutdown/mod.d.ts.map +1 -1
  95. package/dist/shutdown/mod.js +26 -25
  96. package/dist/shutdown/mod.js.map +1 -1
  97. package/dist/storage/clickhouse/database.d.ts +113 -115
  98. package/dist/storage/clickhouse/database.d.ts.map +1 -1
  99. package/dist/storage/clickhouse/database.js +65 -79
  100. package/dist/storage/clickhouse/database.js.map +1 -1
  101. package/dist/storage/clickhouse/errors.d.ts +25 -26
  102. package/dist/storage/clickhouse/errors.d.ts.map +1 -1
  103. package/dist/storage/clickhouse/errors.js +15 -17
  104. package/dist/storage/clickhouse/errors.js.map +1 -1
  105. package/dist/storage/clickhouse/mod.d.ts +10 -10
  106. package/dist/storage/clickhouse/mod.js +10 -10
  107. package/dist/storage/objects/bucket.d.ts +196 -225
  108. package/dist/storage/objects/bucket.d.ts.map +1 -1
  109. package/dist/storage/objects/bucket.js +71 -84
  110. package/dist/storage/objects/bucket.js.map +1 -1
  111. package/dist/storage/objects/error.d.ts +4 -4
  112. package/dist/storage/objects/error.js +4 -4
  113. package/dist/storage/postgres/database.d.ts +124 -149
  114. package/dist/storage/postgres/database.d.ts.map +1 -1
  115. package/dist/storage/postgres/database.js +98 -135
  116. package/dist/storage/postgres/database.js.map +1 -1
  117. package/dist/storage/postgres/errors.d.ts +42 -48
  118. package/dist/storage/postgres/errors.d.ts.map +1 -1
  119. package/dist/storage/postgres/errors.js +44 -51
  120. package/dist/storage/postgres/errors.js.map +1 -1
  121. package/dist/storage/postgres/interval.d.ts +19 -19
  122. package/dist/storage/postgres/interval.d.ts.map +1 -1
  123. package/dist/storage/postgres/interval.js +21 -21
  124. package/dist/storage/postgres/interval.js.map +1 -1
  125. package/dist/storage/redis/bitfield.d.ts +48 -23
  126. package/dist/storage/redis/bitfield.d.ts.map +1 -1
  127. package/dist/storage/redis/bitfield.js +38 -19
  128. package/dist/storage/redis/bitfield.js.map +1 -1
  129. package/dist/storage/redis/command.d.ts +16 -12
  130. package/dist/storage/redis/command.d.ts.map +1 -1
  131. package/dist/storage/redis/command.js +16 -12
  132. package/dist/storage/redis/command.js.map +1 -1
  133. package/dist/storage/redis/commands.d.ts +99 -100
  134. package/dist/storage/redis/commands.d.ts.map +1 -1
  135. package/dist/storage/redis/commands.js +84 -85
  136. package/dist/storage/redis/commands.js.map +1 -1
  137. package/dist/storage/redis/database.d.ts +138 -122
  138. package/dist/storage/redis/database.d.ts.map +1 -1
  139. package/dist/storage/redis/database.js +120 -101
  140. package/dist/storage/redis/database.js.map +1 -1
  141. package/dist/storage/redis/mod.d.ts +52 -48
  142. package/dist/storage/redis/mod.d.ts.map +1 -1
  143. package/dist/storage/redis/mod.js +52 -48
  144. package/dist/storage/redis/mod.js.map +1 -1
  145. package/dist/storage/redis/options.d.ts +26 -24
  146. package/dist/storage/redis/options.d.ts.map +1 -1
  147. package/dist/storage/redis/options.js.map +1 -1
  148. package/dist/storage/redis/pubsub.d.ts +16 -16
  149. package/dist/storage/redis/pubsub.d.ts.map +1 -1
  150. package/dist/storage/redis/pubsub.js +14 -14
  151. package/dist/storage/redis/pubsub.js.map +1 -1
  152. package/dist/storage/redis/reply.d.ts +80 -72
  153. package/dist/storage/redis/reply.d.ts.map +1 -1
  154. package/dist/storage/redis/reply.js +53 -46
  155. package/dist/storage/redis/reply.js.map +1 -1
  156. package/dist/storage/redis/scan.d.ts +4 -4
  157. package/dist/storage/redis/scan.d.ts.map +1 -1
  158. package/dist/storage/redis/scan.js +6 -6
  159. package/dist/storage/redis/scan.js.map +1 -1
  160. package/dist/storage/redis/script.d.ts +28 -21
  161. package/dist/storage/redis/script.d.ts.map +1 -1
  162. package/dist/storage/redis/script.js +29 -22
  163. package/dist/storage/redis/script.js.map +1 -1
  164. package/dist/storage/redis/target.d.ts +17 -1
  165. package/dist/storage/redis/target.d.ts.map +1 -1
  166. package/dist/storage/redis/target.js +30 -1
  167. package/dist/storage/redis/target.js.map +1 -1
  168. package/dist/storage/redis/wire.d.ts +6 -6
  169. package/dist/storage/redis/wire.d.ts.map +1 -1
  170. package/dist/storage/redis/wire.js +6 -6
  171. package/dist/storage/redis/wire.js.map +1 -1
  172. package/dist/testing/mod.d.ts +83 -88
  173. package/dist/testing/mod.d.ts.map +1 -1
  174. package/dist/testing/mod.js +75 -81
  175. package/dist/testing/mod.js.map +1 -1
  176. package/dist/testing/playwright.d.ts +28 -32
  177. package/dist/testing/playwright.d.ts.map +1 -1
  178. package/dist/testing/playwright.js +22 -27
  179. package/dist/testing/playwright.js.map +1 -1
  180. package/dist/testing/puppeteer.d.ts +11 -12
  181. package/dist/testing/puppeteer.d.ts.map +1 -1
  182. package/dist/testing/puppeteer.js +17 -18
  183. package/dist/testing/puppeteer.js.map +1 -1
  184. package/dist/testing/system.d.ts +72 -90
  185. package/dist/testing/system.d.ts.map +1 -1
  186. package/dist/testing/system.js +90 -107
  187. package/dist/testing/system.js.map +1 -1
  188. package/dist/tsconfig.build.tsbuildinfo +1 -1
  189. package/frontends/mod.test.ts +6 -2
  190. package/frontends/mod.ts +20 -19
  191. package/gateway/errors.ts +30 -32
  192. package/gateway/match.ts +61 -57
  193. package/gateway/middleware.ts +62 -64
  194. package/gateway/mod.ts +73 -76
  195. package/gateway/request.ts +143 -140
  196. package/gateway/serve.ts +58 -63
  197. package/gateways/mod.ts +25 -23
  198. package/internal/runtime/napi/napi.cjs +1 -1
  199. package/internal/runtime/napi/napi.d.cts +10 -3
  200. package/internal/runtime/shutdown.ts +113 -101
  201. package/log/logger.test.ts +8 -0
  202. package/log/logger.ts +48 -45
  203. package/metrics/mod.ts +138 -122
  204. package/otel.ts +6 -3
  205. package/package.json +1 -1
  206. package/pubsub/subscription.ts +93 -123
  207. package/pubsub/topic.ts +96 -130
  208. package/reqctx/mod.ts +83 -86
  209. package/services/index.ts +78 -78
  210. package/shutdown/mod.ts +26 -25
  211. package/storage/clickhouse/database.ts +115 -129
  212. package/storage/clickhouse/errors.ts +27 -29
  213. package/storage/clickhouse/mod.ts +10 -10
  214. package/storage/objects/bucket.ts +209 -239
  215. package/storage/objects/error.ts +4 -4
  216. package/storage/postgres/database.ts +131 -164
  217. package/storage/postgres/errors.ts +45 -52
  218. package/storage/postgres/interval.ts +21 -21
  219. package/storage/redis/bitfield.ts +51 -26
  220. package/storage/redis/command.ts +16 -12
  221. package/storage/redis/commands.ts +99 -100
  222. package/storage/redis/database.ts +145 -123
  223. package/storage/redis/mod.ts +52 -48
  224. package/storage/redis/options.ts +26 -24
  225. package/storage/redis/pubsub.ts +14 -14
  226. package/storage/redis/redis.test.ts +17 -2
  227. package/storage/redis/reply.ts +85 -77
  228. package/storage/redis/scan.ts +6 -6
  229. package/storage/redis/script.ts +29 -22
  230. package/storage/redis/target.ts +34 -1
  231. package/storage/redis/wire.ts +8 -8
  232. package/testing/mod.ts +99 -105
  233. package/testing/playwright.ts +32 -37
  234. package/testing/puppeteer.ts +22 -23
  235. package/testing/system.ts +117 -133
@@ -1,38 +1,39 @@
1
1
  /** Describes the running Encore application. */
2
2
  export interface AppMeta {
3
3
  /**
4
- * The Encore application ID. If the application is not linked to the Encore platform this will be an empty string.
5
- * To link to the Encore platform run `encore cloud link` from your terminal in the root directory of the Encore app.
4
+ * The Encore application ID. If the application is not linked to the Encore
5
+ * platform, this is an empty string. To link the application, run
6
+ * `encore cloud link` in the root directory of your Encore app.
6
7
  */
7
8
  appId: string;
8
9
  /**
9
- * The Encore application slug — the human-readable identifier shown in the Encore
10
- * Cloud dashboard and used by the CLI. If the application is not linked to the
11
- * Encore platform this will be an empty string.
10
+ * The Encore application slug — the human-readable identifier shown in the
11
+ * Encore Cloud dashboard and used by the CLI. If the application is not
12
+ * linked to the Encore platform, this is an empty string.
12
13
  *
13
- * Distinct from `appId`: the id is opaque and stable, the slug is readable and may
14
- * be renamed. Locally the two are the same.
14
+ * Distinct from `appId`: the ID is opaque and stable, whereas the slug is
15
+ * human-readable and may be renamed. Locally, both have the same value.
15
16
  */
16
17
  appSlug: string;
17
18
  /**
18
- * The API gateways of this application this service is given, keyed by
19
- * gateway name: those its code looks up the URL of, and the one it hosts.
19
+ * The API gateways visible to this service, keyed by gateway name.
20
20
  *
21
- * An application can declare several gateways, so there is no single base URL for
22
- * the API — look up the gateway you mean by name. A service's processes, its
23
- * Workers' included, list the gateways its code names (`url("api")` from
24
- * `@encore.dev/sdk/gateways`) and the one it hosts, and no other; one told of
25
- * none, as under `encore test`, reports an empty object.
21
+ * Because an application can declare multiple gateways, there is no single
22
+ * base URL for the API — look up the gateway you want by name. A service's
23
+ * processes (including its workers) receive only the gateways referenced by
24
+ * its code (`url("api")` from `@encore.dev/sdk/gateways`) and any gateway
25
+ * hosted by the service itself. When no gateways are configured (such as
26
+ * under `encore test`), this is an empty object.
26
27
  */
27
28
  gateways: Record<string, GatewayMeta>;
28
29
  /**
29
- * The frontends of this application this service is given — those its code
30
- * looks up the URL of (`url("web")` from `@encore.dev/sdk/frontends`), and
31
- * the one it hosts — keyed by name, with where each is reached. One the
32
- * environment gives no origins is left out.
30
+ * The frontends visible to this service, keyed by frontend name. Includes
31
+ * frontends referenced by this service's code (`url("web")` from
32
+ * `@encore.dev/sdk/frontends`) and any frontend hosted by the service itself.
33
+ * Frontends with no configured origins in this environment are omitted.
33
34
  */
34
35
  frontends: Record<string, FrontendMeta>;
35
- /** Information about the environment the app is running in. */
36
+ /** Information about the environment the application is running in. */
36
37
  environment: EnvironmentMeta;
37
38
  /** Information about the build. */
38
39
  build: BuildMeta;
@@ -41,86 +42,87 @@ export interface AppMeta {
41
42
  }
42
43
  /** Describes an API gateway serving the application. */
43
44
  export interface GatewayMeta {
44
- /** The name of the gateway, as declared by the application. */
45
+ /** The gateway name as declared by the application. */
45
46
  name: string;
46
47
  /**
47
- * The URL the API of this running application is called at through this
48
- * gateway: the first of its origins. Empty when the environment gives the
49
- * gateway no origins.
48
+ * The primary URL at which this gateway is reached (the first entry in
49
+ * `origins`). Empty when no origins are configured for the gateway in this
50
+ * environment.
50
51
  */
51
52
  url: string;
52
53
  /**
53
- * Every origin the gateway is reached at in this environment
54
- * (`scheme://host[:port]`), the first its URL. After the first, an entry may
55
- * be a pattern of one, `https://*.example.com`, or `*`, which makes the
56
- * gateway the one serving requests no other origin matches.
54
+ * All origins at which the gateway is reached in this environment
55
+ * (`scheme://host[:port]`). The first entry is the primary `url`. Subsequent
56
+ * entries may be wildcard patterns (such as `https://*.example.com`) or `*`,
57
+ * which makes this gateway handle requests that no other origin matches.
57
58
  */
58
59
  origins: string[];
59
60
  }
60
- /** Describes a frontend of the application, and where it is reached. */
61
+ /** Describes a frontend of the application and where it is reached. */
61
62
  export interface FrontendMeta {
62
- /** The name of the frontend: for one a service hosts, the service's. */
63
+ /** The frontend name (or the hosting service's name for a service-hosted frontend). */
63
64
  name: string;
64
- /** The URL the frontend is reached at: the first of its origins. */
65
+ /** The primary URL at which the frontend is reached (the first entry in `origins`). */
65
66
  url: string;
66
67
  /**
67
- * Every origin the frontend is reached at in this environment, the first its
68
- * URL; after the first, an entry may be a pattern of one,
69
- * `https://*.example.com`.
68
+ * All origins at which the frontend is reached in this environment. The first
69
+ * entry is the primary `url`; subsequent entries may be wildcard patterns
70
+ * such as `https://*.example.com`.
70
71
  */
71
72
  origins: string[];
72
73
  }
73
74
  /** Describes the environment the Encore application is running in. */
74
75
  export interface EnvironmentMeta {
75
76
  /**
76
- * The name of environment that this application.
77
- * For local development it is "local".
77
+ * The name of the environment this application is running in.
78
+ * For local development, this is `"local"`.
78
79
  */
79
80
  name: string;
80
81
  /**
81
- * The type of environment is this application running in.
82
- * For local development it is "development".
82
+ * The type of environment this application is running in.
83
+ * For local development, this is `"development"`.
83
84
  */
84
85
  type: EnvironmentType;
85
86
  /**
86
- * The cloud this is running in.
87
- * For local development it is "local".
87
+ * The cloud provider this application is running on.
88
+ * For local development, this is `"local"`.
88
89
  */
89
90
  cloud: CloudProvider;
90
91
  }
91
92
  /** Describes what type of environment the application is running in. */
92
93
  export type EnvironmentType = 'production' | 'development' | 'ephemeral' | 'test';
93
- /** Describes what cloud provider the application is running in. */
94
+ /** Describes which cloud provider the application is running on. */
94
95
  export type CloudProvider = 'aws' | 'gcp' | 'azure' | 'encore' | 'local';
95
- /** Information about the build that formed the running application. */
96
+ /** Information about the build that produced the running application. */
96
97
  export interface BuildMeta {
97
98
  /** The VCS revision the deployed application was built from. */
98
99
  revision: string;
99
100
  }
100
101
  /** Information about the deployment of the running application. */
101
102
  export interface DeployMeta {
102
- /** The unique id of the deployment. Generated by the Encore Platform. */
103
+ /** The unique deployment ID generated by the Encore platform. */
103
104
  id: string;
104
- /** The time the Encore Platform deployed this build to the environment. */
105
+ /** The time the Encore platform deployed this build to the environment. */
105
106
  time: Date;
106
- /** The services hosted by this deployment, keyed by the service name. */
107
+ /** The services hosted by this deployment, keyed by service name. */
107
108
  hostedServices: Record<string, HostedService>;
108
109
  /**
109
- * The Worker of its service this process runs: a long-running process of
110
- * the service that serves no requests, declared in the `workers` section of
111
- * its `encore.service.json`. Undefined for the service's main process.
110
+ * The name of the worker this process is running, if any. A worker is a
111
+ * long-running process belonging to a service that does not serve HTTP
112
+ * requests, declared under `workers` in `encore.service.json`. Undefined for
113
+ * the service's main process.
112
114
  */
113
115
  worker?: string;
114
116
  }
115
117
  export interface HostedService {
116
- /** The name of the service */
118
+ /** The name of the service. */
117
119
  name: string;
118
120
  }
119
121
  /**
120
122
  * Returns metadata about the running Encore application.
121
123
  *
122
- * The metadata is cached and is the same object each call,
123
- * and therefore must not be modified by the caller.
124
+ * The metadata is cached and returns the same object on every call, so callers
125
+ * must not mutate it.
124
126
  */
125
127
  export declare function appMeta(): AppMeta;
126
128
  //# sourceMappingURL=app_meta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app_meta.d.ts","sourceRoot":"","sources":["../app_meta.ts"],"names":[],"mappings":"AAEA,gDAAgD;AAChD,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;;;;OAOG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;;;;;;;;OASG;IACH,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IAEtC;;;;;OAKG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IAExC,+DAA+D;IAC/D,WAAW,EAAE,eAAe,CAAC;IAE7B,mCAAmC;IACnC,KAAK,EAAE,SAAS,CAAC;IAEjB,wCAAwC;IACxC,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,wDAAwD;AACxD,MAAM,WAAW,WAAW;IAC1B,+DAA+D;IAC/D,IAAI,EAAE,MAAM,CAAC;IAEb;;;;OAIG;IACH,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;;OAKG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,wEAAwE;IACxE,IAAI,EAAE,MAAM,CAAC;IAEb,oEAAoE;IACpE,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,IAAI,EAAE,eAAe,CAAC;IAEtB;;;OAGG;IACH,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAEvB,YAAY,GAEZ,aAAa,GAEb,WAAW,GAEX,MAAM,CAAC;AA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H,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,uEAAuE;AACvE,MAAM,WAAW,YAAY;IAC3B,uFAAuF;IACvF,IAAI,EAAE,MAAM,CAAC;IAEb,uFAAuF;IACvF,GAAG,EAAE,MAAM,CAAC;IAEZ;;;;OAIG;IACH,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,sEAAsE;AACtE,MAAM,WAAW,eAAe;IAC9B;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;OAGG;IACH,IAAI,EAAE,eAAe,CAAC;IAEtB;;;OAGG;IACH,KAAK,EAAE,aAAa,CAAC;CACtB;AAED,wEAAwE;AACxE,MAAM,MAAM,eAAe,GAEvB,YAAY,GAEZ,aAAa,GAEb,WAAW,GAEX,MAAM,CAAC;AAEX,oEAAoE;AACpE,MAAM,MAAM,aAAa,GACrB,KAAK,GACL,KAAK,GACL,OAAO,GACP,QAAQ,GACR,OAAO,CAAC;AAEZ,yEAAyE;AACzE,MAAM,WAAW,SAAS;IACxB,gEAAgE;IAChE,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,mEAAmE;AACnE,MAAM,WAAW,UAAU;IACzB,iEAAiE;IACjE,EAAE,EAAE,MAAM,CAAC;IAEX,2EAA2E;IAC3E,IAAI,EAAE,IAAI,CAAC;IAEX,qEAAqE;IACrE,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAE9C;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC5B,+BAA+B;IAC/B,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,IAAI,OAAO,CA2BjC"}
package/dist/app_meta.js CHANGED
@@ -2,8 +2,8 @@ import * as runtime from './internal/runtime/mod.js';
2
2
  /**
3
3
  * Returns metadata about the running Encore application.
4
4
  *
5
- * The metadata is cached and is the same object each call,
6
- * and therefore must not be modified by the caller.
5
+ * The metadata is cached and returns the same object on every call, so callers
6
+ * must not mutate it.
7
7
  */
8
8
  export function appMeta() {
9
9
  // Compute the metadata on first use.
@@ -1 +1 @@
1
- {"version":3,"file":"app_meta.js","sourceRoot":"","sources":["../app_meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,wBAAwB,CAAC;AA6JlD;;;;;GAKG;AACH,MAAM,UAAU,OAAO;IACrB,qCAAqC;IACrC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,MAAM,EAAE,GAAG,OAAO,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC;QAChC,MAAM,GAAG;YACP,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,OAAO,EAAE,EAAE,CAAC,OAAO;YACnB,QAAQ,EAAE,EAAE,CAAC,QAAQ;YACrB,SAAS,EAAE,EAAE,CAAC,SAAS;YACvB,WAAW,EAAE;gBACX,IAAI,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI;gBACzB,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC;gBAClC,KAAK,EAAE,aAAa,CAAC,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC;aAC3C;YACD,KAAK,EAAE;gBACL,QAAQ,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ;aAC5B;YACD,MAAM,EAAE;gBACN,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE;gBAChB,IAAI,EAAE,IAAI,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;gBACpC,cAAc,EAAE,EAAE,CAAC,MAAM,CAAC,cAAc;gBACxC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,IAAI,SAAS;aACtC;SACF,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,OAAO,CAAC,MAA+B;IAC9C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,OAAO,CAAC,eAA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QACjB,KAAK,OAAO,CAAC,aAAa,CAAC,MAAM;YAC/B,OAAO,QAAQ,CAAC;QAClB,KAAK,OAAO,CAAC,aAAa,CAAC,KAAK;YAC9B,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,OAAO,CAAC;IACnB,CAAC;AACH,CAAC;AAED,6CAA6C;AAC7C,IAAI,MAAM,GAAmB,IAAI,CAAC"}
@@ -1,18 +1,18 @@
1
1
  import { type Scope } from '../internal/testing/scope.js';
2
2
  export { Duration } from './value.js';
3
3
  /**
4
- * A config: a typed value a service reads, written in files beside the code
5
- * and changed while the app runs. Calling it reads the value now.
4
+ * A typed configuration value defined in config files alongside your code and
5
+ * hot-reloaded while the app runs. Call the handle to read the current value.
6
6
  *
7
- * Declare one with {@link config}, giving the value's type as the type
8
- * argument. Encore reads that type to know what the config's files may hold,
9
- * and checks them against it before the value reaches the code.
7
+ * Declare a config with {@link config}, passing its TypeScript type as the
8
+ * type argument. Encore derives a schema from that type and validates config
9
+ * files against it before delivering values to your code.
10
10
  *
11
11
  * ```ts
12
12
  * import { config, type Min, type Max, type Duration } from "@encore.dev/sdk/config";
13
13
  *
14
14
  * interface Checkout {
15
- * // Most items one order may hold.
15
+ * // Maximum number of items in an order.
16
16
  * maxItems: number & Int & Min<1> & Max<500>;
17
17
  * currencies?: string[];
18
18
  * paymentTimeout: Duration;
@@ -23,112 +23,115 @@ export { Duration } from './value.js';
23
23
  * if (items.length > checkout().maxItems) { ... }
24
24
  * ```
25
25
  *
26
- * # Values
26
+ * # Config files
27
27
  *
28
- * A config's value is written in a file named after it — `checkout.config.toml`,
29
- * or `.json` — beside the declaring service's `encore.service.json`, or beside
30
- * `encore.app.json` for a shared or global config. Files over it change it for some
31
- * environments only: `checkout.production.config.toml` for environments of a
32
- * type, `checkout.@prod-eu.config.toml` for one environment, and
33
- * `checkout.user.config.toml` — gitignored, the user override — for a
34
- * developer's own `encore run`, never in tests.
28
+ * Values live in a file named after the config — `checkout.config.toml` or
29
+ * `.json` — next to the declaring service's `encore.service.json` (or next to
30
+ * `encore.app.json` for a shared or global config). Environment-specific
31
+ * overlay files override the base file:
32
+ * - `checkout.production.config.toml` for all environments of a given type
33
+ * - `checkout.@prod-eu.config.toml` for a single named environment
34
+ * - `checkout.user.config.toml` (gitignored) for local overrides during
35
+ * `encore run` (ignored in tests)
35
36
  *
36
- * Calling the config returns a snapshot: the same object until the value
37
- * changes, which it may while the app runs, without a restart. Read it where
38
- * it is used rather than keeping it, or use {@link Config.onChange}.
37
+ * Calling the config returns a snapshot that remains the same object until the
38
+ * value changes. Because values can update at runtime without a restart, call
39
+ * the config where you use it rather than caching the result, or subscribe
40
+ * with {@link Config.onChange}.
39
41
  */
40
42
  export interface Config<T> {
41
- /** The config's value now. */
43
+ /** Returns the current config value. */
42
44
  (): T;
43
45
  /** The name the config was declared with. */
44
46
  readonly name: string;
45
47
  /**
46
- * Calls `listener` with each new value the config is given from now on,
47
- * while the app runs, until the returned function is called, whether or
48
- * not it is kept. Values that come faster than `listener` is called are
49
- * coalesced: it gets the latest, once. Does not keep the process alive.
48
+ * Registers a `listener` invoked whenever the config value changes while the
49
+ * app is running. Returns an unsubscribe function (the subscription stays
50
+ * active even if you discard the returned function). Rapid updates are
51
+ * coalesced so the listener receives the latest value once. Does not keep
52
+ * the process alive.
50
53
  */
51
54
  onChange(listener: (value: T) => void): () => void;
52
55
  }
53
- /** The options a config is declared with. */
56
+ /** Options for declaring a config with {@link config}. */
54
57
  export interface ConfigOptions {
55
58
  /**
56
- * Who the config belongs to, written as a string literal for Encore to
57
- * read:
59
+ * Controls which services own and can read the config. Must be a string
60
+ * literal so Encore can resolve it statically:
58
61
  *
59
- * - `"service"`, the default: the service that declares it, which holds
60
- * its own value for it. Two services may each declare a config of the
61
- * same name. The declaration must live inside a service.
62
- * - `"shared"`: the whole app, with one value. A service that reads it is
63
- * recorded as using it. It may be declared outside a service.
64
- * - `"global"`: the whole app, with one value available to every service
65
- * without being recorded as used. It may be declared outside a service.
62
+ * - `"service"` (default): scoped to the declaring service, which has its
63
+ * own value. Two services may declare configs with the same name. Must be
64
+ * declared inside a service.
65
+ * - `"shared"`: app-wide with a single value; each service that reads it is
66
+ * recorded as a consumer. May be declared outside a service.
67
+ * - `"global"`: app-wide with a single value available to every service
68
+ * without tracking per-service usage. May be declared outside a service.
66
69
  *
67
- * A config name has one scope across the app, as a secret's has: a name
68
- * declared shared or global can't also be a service's own.
70
+ * Each config name has a single scope across the app, just like secrets: a
71
+ * name declared as `shared` or `global` cannot also be declared as a
72
+ * service-scoped config.
69
73
  */
70
74
  scope?: 'service' | 'shared' | 'global';
71
75
  /**
72
- * Tags that classify the config, for policies to read: written out as
73
- * string literals, as in `{data: "pci"}`. Keys and values are lowercase
74
- * letters, digits, `_` and `-`, at most 63 characters; a key starts with a
75
- * letter, and not with `encore`, which is reserved. At most 32 tags.
76
+ * Static string-literal tags that classify the config for policy checks
77
+ * (e.g. `{data: "pci"}`). Keys and values may contain lowercase letters,
78
+ * digits, `_`, and `-`, up to 63 characters. Keys must start with a letter
79
+ * and cannot start with the reserved prefix `encore`. At most 32 tags.
76
80
  */
77
81
  tags?: Record<string, string>;
78
82
  }
79
83
  /**
80
- * config declares a {@link Config}, by default belonging to the service that
81
- * declares it (see {@link ConfigOptions.scope}). The declaration is a
82
- * module-level `export const`, with the name a string literal.
84
+ * Declares a {@link Config}, scoped by default to the declaring service (see
85
+ * {@link ConfigOptions.scope}). Must be a module-level `export const` with a
86
+ * string-literal name.
83
87
  *
84
88
  * @example
85
89
  * ```ts
86
- * // A config several services read.
90
+ * // A config shared by several services.
87
91
  * export const flags = config<Flags>("flags", {scope: "shared"});
88
92
  * ```
89
93
  */
90
94
  export declare function config<T>(name: string, opts?: ConfigOptions): Config<T>;
91
95
  /**
92
- * Gives `cfg` the value `value` for the test `scope`, once the core has
93
- * checked it against the config's schema: reading the config in the test
94
- * returns it from then on. For `@encore.dev/sdk/testing`.
96
+ * Sets `cfg` to `value` for the given test `scope` after validating it against
97
+ * the config's schema. For `@encore.dev/sdk/testing`.
95
98
  *
96
99
  * @internal
97
100
  */
98
101
  export declare function setTestValue<T>(scope: Scope, cfg: Config<T>, value: T): void;
99
102
  /**
100
- * The value is at least `N`. A constraint on a `number` field of a config's
101
- * type, written as an intersection: `number & Min<1>`. Encore checks the
102
- * config's files against it; at runtime the field is a plain `number`.
103
+ * Requires a `number` config field to be at least `N`, written as an
104
+ * intersection (`number & Min<1>`). Validated by Encore against config files;
105
+ * at runtime the field is a plain `number`.
103
106
  */
104
107
  export type Min<N extends number> = {
105
108
  readonly '~encore.min'?: N;
106
109
  };
107
- /** The value is at most `N`: `number & Max<500>`. See {@link Min}. */
110
+ /** Requires a `number` config field to be at most `N` (`number & Max<500>`). See {@link Min}. */
108
111
  export type Max<N extends number> = {
109
112
  readonly '~encore.max'?: N;
110
113
  };
111
- /** The value is a whole number: `number & Int`. See {@link Min}. */
114
+ /** Requires a `number` config field to be an integer (`number & Int`). See {@link Min}. */
112
115
  export type Int = {
113
116
  readonly '~encore.int'?: true;
114
117
  };
115
- /** The string is at least `N` characters long: `string & MinLen<3>`. */
118
+ /** Requires a `string` config field to be at least `N` characters long (`string & MinLen<3>`). */
116
119
  export type MinLen<N extends number> = {
117
120
  readonly '~encore.min_len'?: N;
118
121
  };
119
- /** The string is at most `N` characters long: `string & MaxLen<64>`. */
122
+ /** Requires a `string` config field to be at most `N` characters long (`string & MaxLen<64>`). */
120
123
  export type MaxLen<N extends number> = {
121
124
  readonly '~encore.max_len'?: N;
122
125
  };
123
- /** The string matches the regular expression `S`: `string & Pattern<"^[A-Z]+$">`. */
126
+ /** Requires a `string` config field to match the regular expression `S` (`string & Pattern<"^[A-Z]+$">`). */
124
127
  export type Pattern<S extends string> = {
125
128
  readonly '~encore.pattern'?: S;
126
129
  };
127
- /** The array has at least `N` items: `string[] & MinItems<1>`. */
130
+ /** Requires an array config field to have at least `N` items (`string[] & MinItems<1>`). */
128
131
  export type MinItems<N extends number> = {
129
132
  readonly '~encore.min_items'?: N;
130
133
  };
131
- /** The array has at most `N` items: `string[] & MaxItems<10>`. */
134
+ /** Requires an array config field to have at most `N` items (`string[] & MaxItems<10>`). */
132
135
  export type MaxItems<N extends number> = {
133
136
  readonly '~encore.max_items'?: N;
134
137
  };
@@ -1 +1 @@
1
- {"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../config/config.ts"],"names":[],"mappings":"AACA,OAAO,EAAwB,KAAK,KAAK,EAAC,MAAM,2BAA2B,CAAC;AAI5E,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,8BAA8B;IAC9B,IAAI,CAAC,CAAC;IAEN,6CAA6C;IAC7C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,QAAQ,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACpD;AAED,6CAA6C;AAC7C,MAAM,WAAW,aAAa;IAC5B;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,EAAE,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAExC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,IAAI,EAAE,MAAM,EAIZ,IAAI,CAAC,EAAE,aAAa,GACnB,MAAM,CAAC,CAAC,CAAC,CAIX;AAKD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAgB5E;AAwED;;;;GAIG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,SAAS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AAC,CAAA;CAAC,CAAC;AAExE,kGAAkG;AAClG,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC;AAExE,6GAA6G;AAC7G,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC;AAEzE,4FAA4F;AAC5F,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC;AAE5E,4FAA4F;AAC5F,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,MAAM,IAAI;IAAC,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC,CAAA;CAAC,CAAC"}
@@ -4,13 +4,13 @@ import { secretOfField } from './secrets.js';
4
4
  import { build } from './value.js';
5
5
  export { Duration } from './value.js';
6
6
  /**
7
- * config declares a {@link Config}, by default belonging to the service that
8
- * declares it (see {@link ConfigOptions.scope}). The declaration is a
9
- * module-level `export const`, with the name a string literal.
7
+ * Declares a {@link Config}, scoped by default to the declaring service (see
8
+ * {@link ConfigOptions.scope}). Must be a module-level `export const` with a
9
+ * string-literal name.
10
10
  *
11
11
  * @example
12
12
  * ```ts
13
- * // A config several services read.
13
+ * // A config shared by several services.
14
14
  * export const flags = config<Flags>("flags", {scope: "shared"});
15
15
  * ```
16
16
  */
@@ -26,20 +26,19 @@ opts) {
26
26
  /** The name of the config each handle reads. */
27
27
  const names = new WeakMap();
28
28
  /**
29
- * Gives `cfg` the value `value` for the test `scope`, once the core has
30
- * checked it against the config's schema: reading the config in the test
31
- * returns it from then on. For `@encore.dev/sdk/testing`.
29
+ * Sets `cfg` to `value` for the given test `scope` after validating it against
30
+ * the config's schema. For `@encore.dev/sdk/testing`.
32
31
  *
33
32
  * @internal
34
33
  */
35
34
  export function setTestValue(scope, cfg, value) {
36
35
  const name = names.get(cfg);
37
36
  if (name === undefined) {
38
- throw new TypeError('setConfig takes a config declared with `config()`');
37
+ throw new TypeError('setConfig requires a config declared with `config()`');
39
38
  }
40
39
  const json = JSON.stringify(value);
41
40
  if (json === undefined) {
42
- throw new TypeError(`config ${name}: the value has no JSON form`);
41
+ throw new TypeError(`config ${name}: value cannot be serialized to JSON`);
43
42
  }
44
43
  const prepared = JSON.parse(scope.native.setConfig(name, json));
45
44
  const impl = runtime.RT.config(name);
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../config/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,yBAAyB,CAAC;AACnD,OAAO,EAAC,WAAW,EAAE,QAAQ,EAAa,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAC;AACxC,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAC;AAE9B,OAAO,EAAC,QAAQ,EAAC,MAAM,SAAS,CAAC;AAmFjC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,MAAM,CACpB,IAAY;AACZ,sEAAsE;AACtE,8DAA8D;AAC9D,6DAA6D;AAC7D,IAAoB;IAEpB,MAAM,MAAM,GAAG,UAAU,CAAI,IAAI,EAAE,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;IAC5D,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IACxB,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,gDAAgD;AAChD,MAAM,KAAK,GAAG,IAAI,OAAO,EAAuB,CAAC;AAEjD;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAAI,KAAY,EAAE,GAAc,EAAE,KAAQ;IACpE,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,IAAI,IAAI,KAAK,SAA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