@samebase/alchemy-convex 0.36.0 → 0.38.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,8 @@
1
- // Convex.SharedHubClient: one deployment of an app as a client of the identity hub that the stack
1
+ // IdentityHub.Client: one deployment of an app as a client of the identity hub that the stack
2
2
  // names, for an app that deploys in its own GitHub Actions run, on any host, and in development as a
3
- // stage of the same stack.
3
+ // stage of the same stack. Import it as
4
+ // `import * as IdentityHub from "@samebase/alchemy-convex/identity-hub"`; `Convex.providers()`
5
+ // registers its provider.
4
6
  //
5
7
  // A run in GitHub Actions asks the hub for a new client with a GitHub OIDC token, so the stack needs
6
8
  // no key and no Samebase account. The token names the repository. The hub reads
@@ -12,7 +14,7 @@
12
14
  //
13
15
  // The answer to a production registration also holds the app's initial access token (RFC 7591
14
16
  // section 1.2) and the repository id. The state of stage `prod` keeps them. A development checkout
15
- // runs the stack as a stage `dev-<name>`: it reads them with `SharedHubClient.read`, and a client
17
+ // runs the stack as a stage `dev-<name>`: it reads them with `IdentityHub.Client.read`, and a client
16
18
  // with `deploymentType: "development"` asks the hub with the token in place of the GitHub token
17
19
  // (RFC 133).
18
20
  //
@@ -52,8 +54,8 @@ const OFF_VALUES = { issuer: "http://127.0.0.1:1", clientId: "no-hub", clientSec
52
54
  const CONNECTOR_NAME = /^[a-z0-9-]{1,64}$/;
53
55
 
54
56
  /**
55
- * An identity hub of @samebase/identity-broker, such as Samebase's:
56
- * `{ issuer: "https://auth.samebase.com", terms: "https://samebase.com/terms" }`.
57
+ * An identity hub of @samebase/identity-broker, such as Samebase's public hub:
58
+ * `{ issuer: "https://id.samebase.com" }`.
57
59
  */
58
60
  export interface Hub {
59
61
  /**
@@ -61,11 +63,6 @@ export interface Hub {
61
63
  * with a GitHub token whose audience is the issuer, so no other hub can use that token.
62
64
  */
63
65
  readonly issuer: string;
64
- /**
65
- * The terms of the hub's sign-in service, which its answer must name. The log prints them for a
66
- * new client, so no value that the answer chose reaches the log.
67
- */
68
- readonly terms: string;
69
66
  }
70
67
 
71
68
  interface CommonProps {
@@ -100,9 +97,9 @@ interface CommonProps {
100
97
 
101
98
  /**
102
99
  * A production or preview client asks with the GitHub OIDC token of the run. A development client
103
- * asks with the app's initial access token, which `SharedHubClient.read` gives from stage `prod`.
100
+ * asks with the app's initial access token, which `IdentityHub.Client.read` gives from stage `prod`.
104
101
  */
105
- export type SharedHubClientProps =
102
+ export type ClientProps =
106
103
  | (CommonProps & {
107
104
  readonly deploymentType: "production" | "preview";
108
105
  readonly initialAccessToken?: never;
@@ -142,9 +139,9 @@ const Attributes = Schema.Struct({
142
139
 
143
140
  /**
144
141
  * The attributes keep the real values of a suspended client, so that an unblock needs no new client.
145
- * `SharedHubClient.variables` gives the values that the app gets.
142
+ * `IdentityHub.Client.variables` gives the values that the app gets.
146
143
  */
147
- export interface SharedHubClientAttributes extends Schema.Schema.Type<typeof Attributes> {}
144
+ export interface ClientAttributes extends Schema.Schema.Type<typeof Attributes> {}
148
145
 
149
146
  /**
150
147
  * The attributes of a saved row. A row that does not have this version's shape, or any other
@@ -153,13 +150,11 @@ export interface SharedHubClientAttributes extends Schema.Schema.Type<typeof Att
153
150
  */
154
151
  const savedAttributes = (value: unknown, reason: string) =>
155
152
  Schema.decodeUnknownEffect(Attributes)(value).pipe(
156
- Effect.catchCause(() => Effect.die(new SharedHubClientFailed({ reason }))),
153
+ Effect.catchCause(() => Effect.die(new IdentityHubClientFailed({ reason }))),
157
154
  );
158
155
 
159
156
  /** The attributes of no client. */
160
- const offAttributes = (
161
- deploymentType: SharedHubClientAttributes["deploymentType"],
162
- ): SharedHubClientAttributes => ({
157
+ const offAttributes = (deploymentType: ClientAttributes["deploymentType"]): ClientAttributes => ({
163
158
  status: "off",
164
159
  issuer: OFF_VALUES.issuer,
165
160
  clientId: OFF_VALUES.clientId,
@@ -180,12 +175,12 @@ const sameSet = (a: readonly string[], b: readonly string[]) =>
180
175
  a.length === b.length && a.every((name, index) => name === b[index]);
181
176
 
182
177
  /** One request gave no usable answer. The reason holds no secret. */
183
- class SharedHubClientFailed extends Schema.TaggedError<SharedHubClientFailed>()(
184
- "SharedHubClientFailed",
178
+ class IdentityHubClientFailed extends Schema.TaggedError<IdentityHubClientFailed>()(
179
+ "IdentityHubClientFailed",
185
180
  { reason: Schema.String },
186
181
  ) {
187
182
  override get message() {
188
- return `Convex.SharedHubClient: ${this.reason}.`;
183
+ return `IdentityHub.Client: ${this.reason}.`;
189
184
  }
190
185
  }
191
186
 
@@ -201,8 +196,6 @@ const NewClient = Schema.Struct({
201
196
  redirect_uri: Schema.NonEmptyString,
202
197
  /** The set the hub recorded, which must be the set the request sent. */
203
198
  connectors: Schema.Array(Schema.String),
204
- /** The terms of the hub's sign-in service, which must be the `terms` of the stack's `hub`. */
205
- terms: Schema.String,
206
199
  /** Only in the answer to a production registration with the GitHub token. */
207
200
  initial_access_token: Schema.optionalKey(Schema.NonEmptyString),
208
201
  repository: Schema.optionalKey(Schema.String.check(Schema.isPattern(/^\d+$/))),
@@ -290,14 +283,14 @@ const send = (who: string, url: string, token: string, init: { method: string; b
290
283
  const body: unknown = await response.json().catch(() => undefined);
291
284
  return { status: response.status, body };
292
285
  },
293
- catch: () => new SharedHubClientFailed({ reason: `${who} gave no answer` }),
286
+ catch: () => new IdentityHubClientFailed({ reason: `${who} gave no answer` }),
294
287
  });
295
288
 
296
289
  const decode =
297
290
  <S extends Schema.Codec<unknown, unknown>>(schema: S, who: string) =>
298
291
  (value: unknown) =>
299
292
  Schema.decodeUnknownEffect(schema)(value).pipe(
300
- Effect.mapError(() => new SharedHubClientFailed({ reason: `${who} gave a bad answer` })),
293
+ Effect.mapError(() => new IdentityHubClientFailed({ reason: `${who} gave a bad answer` })),
301
294
  );
302
295
 
303
296
  /**
@@ -313,7 +306,7 @@ const readOidcToken = (requestUrl: string, requestToken: string, audience: strin
313
306
  { method: "GET" },
314
307
  );
315
308
  if (status !== 200) {
316
- return yield* new SharedHubClientFailed({
309
+ return yield* new IdentityHubClientFailed({
317
310
  reason: `GitHub gave no OIDC token (HTTP ${status})`,
318
311
  });
319
312
  }
@@ -321,11 +314,7 @@ const readOidcToken = (requestUrl: string, requestToken: string, audience: strin
321
314
  });
322
315
 
323
316
  /** `POST /hub-clients` with `bearer`: the GitHub OIDC token, or the app's initial access token. */
324
- const requestNewClient = (
325
- props: SharedHubClientProps,
326
- connectors: readonly string[],
327
- bearer: string,
328
- ) =>
317
+ const requestNewClient = (props: ClientProps, connectors: readonly string[], bearer: string) =>
329
318
  Effect.gen(function* () {
330
319
  const { hub } = props;
331
320
  const { body, status } = yield* send("The identity hub", `${hub.issuer}/hub-clients`, bearer, {
@@ -342,22 +331,21 @@ const requestNewClient = (
342
331
  status === 401 && props.deploymentType === "development"
343
332
  ? "the identity hub refused the initial access token"
344
333
  : refusalOf(status, body);
345
- return yield* new SharedHubClientFailed({ reason: `${reason} (HTTP ${status})` });
334
+ return yield* new IdentityHubClientFailed({ reason: `${reason} (HTTP ${status})` });
346
335
  }
347
336
  const client = yield* decode(NewClient, "The identity hub")(body);
348
- // The hub registers the address and the connectors that the request sent, under its own issuer
349
- // and the terms that the stack names. The log and the state hold the stack's, so no value that
350
- // the answer chose is printed or kept.
337
+ // The hub registers the address and the connectors that the request sent, under its own issuer.
338
+ // The log and the state hold the stack's values, so no value that the answer chose is printed
339
+ // or kept.
351
340
  if (
352
341
  client.issuer !== hub.issuer ||
353
342
  client.redirect_uri !== props.redirectUri ||
354
- !sameSet(client.connectors, connectors) ||
355
- client.terms !== hub.terms
343
+ !sameSet(client.connectors, connectors)
356
344
  ) {
357
- return yield* new SharedHubClientFailed({ reason: "The identity hub gave a bad answer" });
345
+ return yield* new IdentityHubClientFailed({ reason: "The identity hub gave a bad answer" });
358
346
  }
359
347
  yield* Effect.logInfo(
360
- `Convex.SharedHubClient: ${props.app} on ${props.redirectUri} has a new client of the identity hub. Its use is under ${hub.terms}.`,
348
+ `IdentityHub.Client: ${props.app} on ${props.redirectUri} has a new client of the identity hub ${hub.issuer}.`,
361
349
  );
362
350
  // Only a production registration gives the app's token (RFC 7591); any other answer's is dropped.
363
351
  const production = props.deploymentType === "production";
@@ -377,13 +365,13 @@ const requestNewClient = (
377
365
  });
378
366
 
379
367
  /** A new client, or the off values. */
380
- const newClient = (props: SharedHubClientProps, connectors: readonly string[]) => {
381
- const label = `Convex.SharedHubClient: ${props.app} on ${props.redirectUri} deploys without the hub`;
368
+ const newClient = (props: ClientProps, connectors: readonly string[]) => {
369
+ const label = `IdentityHub.Client: ${props.app} on ${props.redirectUri} deploys without the hub`;
382
370
  const off = offAttributes(props.deploymentType);
383
- const request = (bearer: Effect.Effect<string, SharedHubClientFailed>) =>
371
+ const request = (bearer: Effect.Effect<string, IdentityHubClientFailed>) =>
384
372
  bearer.pipe(
385
373
  Effect.flatMap((token) => requestNewClient(props, connectors, token)),
386
- Effect.catchTag("SharedHubClientFailed", (error) =>
374
+ Effect.catchTag("IdentityHubClientFailed", (error) =>
387
375
  Effect.logWarning(`${label}: ${error.reason}. The next deploy asks again.`).pipe(
388
376
  Effect.as(off),
389
377
  ),
@@ -394,7 +382,7 @@ const newClient = (props: SharedHubClientProps, connectors: readonly string[]) =
394
382
  const token = Redacted.value(props.initialAccessToken);
395
383
  return token === ""
396
384
  ? Effect.logInfo(
397
- "Convex.SharedHubClient: deploy to main once for hub sign-in in development.",
385
+ "IdentityHub.Client: deploy to main once for hub sign-in in development.",
398
386
  ).pipe(Effect.as(off))
399
387
  : request(Effect.succeed(token));
400
388
  }
@@ -419,7 +407,7 @@ const newClient = (props: SharedHubClientProps, connectors: readonly string[]) =
419
407
  * passes a run only when the hub confirms it in that run, so a suspension that an earlier run saw,
420
408
  * and did not save because that run failed, cannot pass a run that the hub does not answer.
421
409
  */
422
- const renew = (saved: SharedHubClientAttributes, required: boolean) =>
410
+ const renew = (saved: ClientAttributes, required: boolean) =>
423
411
  Effect.gen(function* () {
424
412
  const { status } = yield* send(
425
413
  "The identity hub",
@@ -434,31 +422,38 @@ const renew = (saved: SharedHubClientAttributes, required: boolean) =>
434
422
  return undefined;
435
423
  case 403:
436
424
  yield* Effect.logWarning(
437
- `Convex.SharedHubClient: the hub suspended the client of ${saved.redirectUri}. It keeps its values, and nobody can sign in with it.`,
425
+ `IdentityHub.Client: the hub suspended the client of ${saved.redirectUri}. It keeps its values, and nobody can sign in with it.`,
438
426
  );
439
427
  return { ...saved, status: "suspended" as const };
440
428
  default:
441
- return yield* new SharedHubClientFailed({
429
+ return yield* new IdentityHubClientFailed({
442
430
  reason: `The identity hub answered HTTP ${status}`,
443
431
  });
444
432
  }
445
433
  }).pipe(
446
- Effect.catchTag("SharedHubClientFailed", (error) =>
434
+ Effect.catchTag("IdentityHubClientFailed", (error) =>
447
435
  required
448
436
  ? Effect.fail(
449
- new SharedHubClientFailed({
437
+ new IdentityHubClientFailed({
450
438
  reason: `${saved.redirectUri} is required, and the hub did not confirm its client: ${error.reason}`,
451
439
  }),
452
440
  )
453
441
  : Effect.logWarning(
454
- `Convex.SharedHubClient: ${saved.redirectUri} keeps the saved client: ${error.reason}.`,
442
+ `IdentityHub.Client: ${saved.redirectUri} keeps the saved client: ${error.reason}.`,
455
443
  ).pipe(Effect.as(saved)),
456
444
  ),
457
445
  );
458
446
 
447
+ /**
448
+ * The type of this resource before 0.37.0. Alchemy finds this provider for a row of that type, and
449
+ * the next write of the row gives it the new type, with the same client. Remove it, here and in
450
+ * `SavedRow`, once no saved row has the old type.
451
+ */
452
+ const OLD_TYPE = "IdentityHub.SharedClient";
453
+
459
454
  /** A saved row of this resource, whose `attr` `savedAttributes` reads. */
460
455
  const SavedRow = Schema.Struct({
461
- resourceType: Schema.Literal("IdentityHub.SharedClient"),
456
+ resourceType: Schema.Literals(["IdentityHub.Client", OLD_TYPE]),
462
457
  attr: Schema.Unknown,
463
458
  });
464
459
 
@@ -468,7 +463,7 @@ const SavedRow = Schema.Struct({
468
463
  * `initialAccessToken` and the `repository` of the production client. Without that row, the off
469
464
  * attributes, with `deploymentType: "production"`.
470
465
  *
471
- * `SharedHubClient.ref` is not enough: Alchemy fails the plan with `InvalidReferenceError` when the
466
+ * `IdentityHub.Client.ref` is not enough: Alchemy fails the plan with `InvalidReferenceError` when the
472
467
  * row is missing, and a development stage before the first deploy to main has none. This read runs
473
468
  * when the plan resolves it, with the State service of the running stack and its `get`, so it never
474
469
  * creates or upgrades a store. The store revives each secret as `Redacted`, as it does for every
@@ -486,8 +481,8 @@ const read = (id: string, options: { readonly stage: string }) =>
486
481
  const { attr } = yield* Schema.decodeUnknownEffect(SavedRow)(row).pipe(
487
482
  Effect.catchCause(() =>
488
483
  Effect.die(
489
- new SharedHubClientFailed({
490
- reason: `the row ${id} of stage ${options.stage} is not a Convex.SharedHubClient`,
484
+ new IdentityHubClientFailed({
485
+ reason: `the row ${id} of stage ${options.stage} is not an IdentityHub.Client`,
491
486
  }),
492
487
  ),
493
488
  ),
@@ -500,11 +495,12 @@ const read = (id: string, options: { readonly stage: string }) =>
500
495
  );
501
496
 
502
497
  /**
503
- * The three values that the app's deployment gets, such as `HUB_ISSUER`, `HUB_CLIENT_ID`, and
504
- * `HUB_CLIENT_SECRET`, as Outputs: the client's values when `status` is `on`, else the off values,
505
- * so that a suspended client gives guest sign-in and keeps its values in state.
498
+ * The three values that the app's deployment gets, such as `IDENTITY_HUB_ISSUER`,
499
+ * `IDENTITY_HUB_CLIENT_ID`, and `IDENTITY_HUB_CLIENT_SECRET`, as Outputs: the client's values when
500
+ * `status` is `on`, else the off values, so that a suspended client gives guest sign-in and keeps
501
+ * its values in state.
506
502
  */
507
- const variables = (client: SharedHubClient) =>
503
+ const variables = (client: Client) =>
508
504
  Output.map(Output.of(client), (attributes) =>
509
505
  attributes.status === "on"
510
506
  ? {
@@ -519,20 +515,20 @@ const variables = (client: SharedHubClient) =>
519
515
  },
520
516
  );
521
517
 
522
- export type SharedHubClient = Resource<
523
- "IdentityHub.SharedClient",
524
- SharedHubClientProps,
525
- SharedHubClientAttributes,
518
+ export type Client = Resource<
519
+ "IdentityHub.Client",
520
+ ClientProps,
521
+ ClientAttributes,
526
522
  never,
527
523
  Providers
528
524
  >;
529
- export const SharedHubClient = Resource<SharedHubClient>("IdentityHub.SharedClient")({
525
+ export const Client = Resource<Client>("IdentityHub.Client", { aliases: [OLD_TYPE] })({
530
526
  read,
531
527
  variables,
532
528
  });
533
529
 
534
- export const SharedHubClientProvider = () =>
535
- Provider.succeed(SharedHubClient, {
530
+ export const ClientProvider = () =>
531
+ Provider.succeed(Client, {
536
532
  // Always an update, so that each deploy reaches the hub. No attribute is stable, so a push
537
533
  // reads the values that this run ended with. The same values cause no other push.
538
534
  diff: ({ news }) =>
@@ -548,7 +544,7 @@ export const SharedHubClientProvider = () =>
548
544
  news.connectors.length === 0 ||
549
545
  !news.connectors.every((name) => CONNECTOR_NAME.test(name))
550
546
  ) {
551
- return yield* new SharedHubClientFailed({
547
+ return yield* new IdentityHubClientFailed({
552
548
  reason: `${news.app} on ${news.redirectUri} needs connectors: one or more names of [a-z0-9-]{1,64}`,
553
549
  });
554
550
  }
@@ -569,7 +565,7 @@ export const SharedHubClientProvider = () =>
569
565
  : undefined;
570
566
  const client = renewed ?? (yield* newClient(news, connectors));
571
567
  if (news.required === true && client.status !== "on") {
572
- return yield* new SharedHubClientFailed({
568
+ return yield* new IdentityHubClientFailed({
573
569
  reason: `${news.app} on ${news.redirectUri} is required and has no working client (${client.status}). The warning above names the reason`,
574
570
  });
575
571
  }
@@ -590,14 +586,14 @@ export const SharedHubClientProvider = () =>
590
586
  );
591
587
  // 401: the client is gone already.
592
588
  if (status !== 204 && status !== 401) {
593
- return yield* new SharedHubClientFailed({
589
+ return yield* new IdentityHubClientFailed({
594
590
  reason: `The identity hub answered HTTP ${status}`,
595
591
  });
596
592
  }
597
593
  }).pipe(
598
- Effect.catchTag("SharedHubClientFailed", (error) =>
594
+ Effect.catchTag("IdentityHubClientFailed", (error) =>
599
595
  Effect.logWarning(
600
- `Convex.SharedHubClient: the client of ${output.redirectUri} stays on the hub until its removal date: ${error.reason}.`,
596
+ `IdentityHub.Client: the client of ${output.redirectUri} stays on the hub until its removal date: ${error.reason}.`,
601
597
  ),
602
598
  ),
603
599
  ),
package/src/Providers.ts CHANGED
@@ -4,10 +4,10 @@ import * as Provider from "alchemy/Provider";
4
4
  import * as Layer from "effect/Layer";
5
5
  import { type Credentials, fromConfig } from "./Credentials.ts";
6
6
  import { DeploymentProvider, DeploymentResource } from "./Deployment.ts";
7
+ import * as IdentityHub from "./IdentityHub.ts";
7
8
  import { LocalDeployment, LocalDeploymentProvider } from "./LocalDeployment.ts";
8
9
  import { ManagementApiLive } from "./ManagementApi.ts";
9
10
  import { Project, ProjectProvider } from "./Project.ts";
10
- import { SharedHubClient, SharedHubClientProvider } from "./SharedHubClient.ts";
11
11
 
12
12
  export class Providers extends Provider.ProviderCollection<Providers>()("Convex") {}
13
13
 
@@ -19,14 +19,14 @@ export class Providers extends Provider.ProviderCollection<Providers>()("Convex"
19
19
  export const providers = (credentials: Layer.Layer<Credentials> = fromConfig()) =>
20
20
  Layer.effect(
21
21
  Providers,
22
- Provider.collection([Project, DeploymentResource, LocalDeployment, SharedHubClient]),
22
+ Provider.collection([Project, DeploymentResource, LocalDeployment, IdentityHub.Client]),
23
23
  ).pipe(
24
24
  Layer.provide(
25
25
  Layer.mergeAll(
26
26
  ProjectProvider(),
27
27
  DeploymentProvider(),
28
28
  LocalDeploymentProvider(),
29
- SharedHubClientProvider(),
29
+ IdentityHub.ClientProvider(),
30
30
  ),
31
31
  ),
32
32
  Layer.provide(ManagementApiLive()),
package/src/Push.ts CHANGED
@@ -511,8 +511,10 @@ export const checkSource = (rootDir: string, input: Source) =>
511
511
  /**
512
512
  * Sets the `env` variables and pushes the functions of `source` to one
513
513
  * deployment with `key`: a deploy key of the deployment, or a preview deploy
514
- * key of its project with `previewName`. Returns the URL that the CLI
515
- * printed, or undefined without `source`.
514
+ * key of its project with `previewName`. A name of `previousEnvNames` that
515
+ * left `env` is removed after a successful push, or, without `source`, in the
516
+ * same write as the new values. Returns the URL that the CLI printed, or
517
+ * undefined without `source`.
516
518
  */
517
519
  export const push = (
518
520
  spawner: ChildProcessSpawner.ChildProcessSpawner["Service"],
@@ -529,6 +531,10 @@ export const push = (
529
531
  const program = resolved?.program;
530
532
  const env = Object.entries(options.env).sort(([a], [b]) => (a < b ? -1 : 1));
531
533
  const removed = options.previousEnvNames.filter((name) => !Object.hasOwn(options.env, name));
534
+ // The code on the deployment can require a name that left `env`, and Convex refuses a write
535
+ // that removes a variable the running code requires. With a push, such names go only after the
536
+ // push succeeded, so a renamed variable reaches the new code first; a failed push keeps them.
537
+ const removedBeforePush = source === undefined ? removed : [];
532
538
 
533
539
  // 1. Variables before the push, so the push sees them. Each attempt
534
540
  // reads the current values first, so a retry after a write conflict never
@@ -536,7 +542,7 @@ export const push = (
536
542
  // changed values are written, and the earlier ones are kept for a
537
543
  // rollback.
538
544
  const written =
539
- env.length === 0 && removed.length === 0
545
+ env.length === 0 && removedBeforePush.length === 0
540
546
  ? { current: {}, changes: [] }
541
547
  : yield* retryIdempotentWrite(
542
548
  Effect.gen(function* () {
@@ -563,7 +569,7 @@ export const push = (
563
569
  ...env
564
570
  .filter(([name, value]) => current[name] !== valueOf(value))
565
571
  .map(([name, value]) => ({ name, value: valueOf(value) })),
566
- ...removed
572
+ ...removedBeforePush
567
573
  .filter((name) => Object.hasOwn(current, name))
568
574
  .map((name) => ({ name, value: null })),
569
575
  ];
@@ -572,6 +578,20 @@ export const push = (
572
578
  }),
573
579
  );
574
580
 
581
+ /** After a successful push: removes the names that left `env`, as the variables are now. */
582
+ const removeAfterPush =
583
+ removedBeforePush.length === removed.length
584
+ ? Effect.void
585
+ : retryIdempotentWrite(
586
+ Effect.gen(function* () {
587
+ const current = yield* listVariables(options.url, key);
588
+ const changes = removed
589
+ .filter((name) => Object.hasOwn(current, name))
590
+ .map((name) => ({ name, value: null }));
591
+ if (changes.length > 0) yield* writeVariables(options.url, key, changes);
592
+ }),
593
+ );
594
+
575
595
  /**
576
596
  * After a failed push, the variables go back to their earlier values, so
577
597
  * that the deployment matches the hash in state. A failed rollback is
@@ -601,9 +621,16 @@ export const push = (
601
621
 
602
622
  // 2. The push, with the key only in the env file.
603
623
  if (source === undefined || cwd === undefined || program === undefined) return undefined;
604
- return yield* runPush(spawner, key, { ...options, cwd, program, command: source.command }).pipe(
605
- Effect.onError(() => rollback),
606
- );
624
+ const url = yield* runPush(spawner, key, {
625
+ ...options,
626
+ cwd,
627
+ program,
628
+ command: source.command,
629
+ }).pipe(Effect.onError(() => rollback));
630
+ // 3. The names that left `env`, now that the new code runs. A failure here fails the run with
631
+ // the earlier state, which still lists these names, so the next run removes them.
632
+ yield* removeAfterPush;
633
+ return url;
607
634
  });
608
635
 
609
636
  /** Runs the installed CLI or the push command once, and checks the deployment that it names. */
@@ -53,7 +53,9 @@ const Resource = Schema.Union([
53
53
  }),
54
54
  }),
55
55
  Schema.Struct({
56
- resourceType: Schema.Literal("IdentityHub.SharedClient"),
56
+ // A row keeps the type before 0.37.0 until its next write. Remove the old type once no saved
57
+ // row has it.
58
+ resourceType: Schema.Literals(["IdentityHub.Client", "IdentityHub.SharedClient"]),
57
59
  attr: Schema.Struct({
58
60
  status: Schema.Literals(["on", "off", "suspended"]),
59
61
  connectors: Schema.Array(Schema.String),
@@ -190,6 +192,7 @@ const resourceRow = (resource: Resource, address: string | null) => {
190
192
  bucketName,
191
193
  );
192
194
  }
195
+ case "IdentityHub.Client":
193
196
  case "IdentityHub.SharedClient": {
194
197
  const { status, connectors } = resource.attr;
195
198
  return status === "off"
package/src/index.ts CHANGED
@@ -44,12 +44,6 @@ export {
44
44
  runRecord,
45
45
  withRunRecord,
46
46
  } from "./RunRecord.ts";
47
- export {
48
- type Hub,
49
- SharedHubClient,
50
- type SharedHubClientAttributes,
51
- type SharedHubClientProps,
52
- } from "./SharedHubClient.ts";
53
47
  export { state, STORE_PROJECT_NAME } from "./State.ts";
54
48
  export {
55
49
  CodePushFailed,