@prisma/composer-prisma-cloud 0.11.0-dev.4 → 0.11.0-dev.5

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,10 +1,9 @@
1
- import { D as Bucket, E as isWithin, O as BucketKey, S as ServiceKeyProvider, a as PgWarmProvider, c as PrismaCloudContainer, d as collectPreflightNames, h as prismaCloudContainerOf, n as GeneratedParamProvider, p as deserialize, s as PnMigrationProvider, u as S3CredentialsProvider, v as mintKeyPair, y as Providers } from "./s3-credentials-resource-BUsjCFtj-C-nS9rK-.mjs";
1
+ import { S as ServiceKeyProvider, a as PgWarmProvider, c as PrismaCloudContainer, d as collectPreflightNames, h as prismaCloudContainerOf, n as GeneratedParamProvider, p as deserialize, s as PnMigrationProvider, u as S3CredentialsProvider, v as mintKeyPair, w as isWithin, y as Providers } from "./s3-credentials-resource-BUsjCFtj-BzHGBAmT.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import { blindCast } from "@prisma/composer/casts";
4
4
  import * as Effect from "effect/Effect";
5
5
  import * as Layer from "effect/Layer";
6
6
  import * as Redacted from "effect/Redacted";
7
- import * as Provider from "alchemy/Provider";
8
7
  import * as crypto$1 from "node:crypto";
9
8
  import { randomBytes, randomUUID } from "node:crypto";
10
9
  import * as fs$2 from "node:fs";
@@ -13,8 +12,9 @@ import * as os$2 from "node:os";
13
12
  import os from "node:os";
14
13
  import * as path$1 from "node:path";
15
14
  import path, { basename, join, posix, win32 } from "node:path";
15
+ import * as Provider from "alchemy/Provider";
16
16
  import * as Prisma from "alchemy/Prisma";
17
- import { App, Connection, Database, Deployment, EnvironmentVariable, Project } from "alchemy/Prisma";
17
+ import { App, Bucket, BucketAccessKey, Connection, Database, Deployment, EnvironmentVariable, Project } from "alchemy/Prisma";
18
18
  import * as fs$1$1 from "node:fs/promises";
19
19
  import ro from "node:fs/promises";
20
20
  import { spawn } from "node:child_process";
@@ -5493,23 +5493,47 @@ function appNameOf(container) {
5493
5493
  return container.input.appName;
5494
5494
  }
5495
5495
  /**
5496
+ * Shared helpers for the upstream-attribute records every local provider
5497
+ * emits — one implementation, so the compute and postgres families cannot
5498
+ * drift on the `'local'` project fallback or the timestamp.
5499
+ */
5500
+ /** The fixed `createdAt`/`updatedAt` local providers stamp: local dev has no meaningful creation time. */
5501
+ const DEV_TIMESTAMP = "1970-01-01T00:00:00.000Z";
5502
+ /** Reads a project id from upstream's `project` input: a plain string or a resolved `Prisma.Project` attributes record. */
5503
+ function projectIdOfInput(value) {
5504
+ if (typeof value === "string") return value;
5505
+ if (Predicate.isObject(value) && typeof value["projectId"] === "string") return value["projectId"];
5506
+ return "local";
5507
+ }
5508
+ /**
5496
5509
  * Local bucket-cluster providers (local-dev spec § 4): both `Bucket` and
5497
- * `BucketKey` are clients of the machine-global bucket emulator — already up
5498
- * by the time these run, since the extension's `localTarget.emulators` hook
5499
- * ensures it before converge.
5510
+ * `BucketAccessKey` are clients of the machine-global bucket emulator —
5511
+ * already up by the time these run, since the extension's
5512
+ * `localTarget.emulators` hook ensures it before converge.
5500
5513
  */
5501
- /** `Bucket` registers `<app>--<news.name>` with the bucket emulator, backed by an in-project data root. */
5514
+ /** Upstream lets `name` default to the resource's logical ID; locally a bucket must have a concrete name to register under. */
5515
+ const bucketNameOf = (news, id) => news.name ?? id;
5516
+ /** Reads a bucket id from upstream's `bucket` input: a plain string or a resolved `Prisma.Bucket` attributes record. */
5517
+ function bucketIdOfInput(value) {
5518
+ if (typeof value === "string") return value;
5519
+ if (Predicate.isObject(value) && typeof value["bucketId"] === "string") return value["bucketId"];
5520
+ return "local";
5521
+ }
5522
+ /** `Bucket` → registers `<app>--<name>` with the bucket emulator, backed by an in-project data root. */
5502
5523
  function LocalBucketProvider(input) {
5503
5524
  return Provider.effect(Bucket, Effect.succeed({
5504
5525
  list: () => Effect.succeed([]),
5505
- reconcile: ({ news }) => Effect.tryPromise({
5526
+ reconcile: ({ news, id }) => Effect.tryPromise({
5506
5527
  try: async () => {
5507
5528
  const app = appNameOf(input.container);
5508
- const dir = path$1.join(input.devDir, "buckets", news.name);
5509
- await bucketsClient().putBucket(app, news.name, dir);
5529
+ const name = bucketNameOf(news, id);
5530
+ const dir = path$1.join(input.devDir, "buckets", name);
5531
+ await bucketsClient().putBucket(app, name, dir);
5510
5532
  return {
5511
- id: news.name,
5512
- name: news.name
5533
+ bucketId: name,
5534
+ name,
5535
+ projectId: projectIdOfInput(news.project),
5536
+ createdAt: DEV_TIMESTAMP
5513
5537
  };
5514
5538
  },
5515
5539
  catch: (cause) => cause
@@ -5519,16 +5543,16 @@ function LocalBucketProvider(input) {
5519
5543
  }));
5520
5544
  }
5521
5545
  /**
5522
- * `BucketKey` → mint-once-stable (the same lifecycle as `ServiceKey`/
5546
+ * `BucketAccessKey` → mint-once-stable (the same lifecycle as `ServiceKey`/
5523
5547
  * `S3Credentials`: reuse `output`'s pair when present, mint only on first
5524
5548
  * create) — but ALWAYS re-registers the (prior or fresh) pair with the
5525
5549
  * emulator, so a bucket emulator whose own state was wiped self-heals on the
5526
5550
  * next converge.
5527
5551
  */
5528
- function LocalBucketKeyProvider(input) {
5529
- return Provider.effect(BucketKey, Effect.succeed({
5552
+ function LocalBucketAccessKeyProvider(input) {
5553
+ return Provider.effect(BucketAccessKey, Effect.succeed({
5530
5554
  list: () => Effect.succeed([]),
5531
- reconcile: ({ news, output }) => Effect.tryPromise({
5555
+ reconcile: ({ news, output, id }) => Effect.tryPromise({
5532
5556
  try: async () => {
5533
5557
  const app = appNameOf(input.container);
5534
5558
  const pair = output !== void 0 ? {
@@ -5537,13 +5561,14 @@ function LocalBucketKeyProvider(input) {
5537
5561
  } : mintKeyPair();
5538
5562
  const client = bucketsClient();
5539
5563
  await client.putCredentials(app, pair.accessKeyId, pair.secretAccessKey);
5564
+ const bucketId = bucketIdOfInput(news.bucket);
5540
5565
  return {
5541
- id: news.name,
5542
- bucketId: news.bucketId,
5566
+ bucketAccessKeyId: news.name ?? id,
5567
+ bucketId,
5543
5568
  accessKeyId: pair.accessKeyId,
5544
5569
  secretAccessKey: Redacted.make(pair.secretAccessKey),
5545
5570
  endpoint: client.baseUrl,
5546
- bucketName: `${app}--${news.name}`
5571
+ bucketName: `${app}--${bucketId}`
5547
5572
  };
5548
5573
  },
5549
5574
  catch: (cause) => cause
@@ -5682,19 +5707,6 @@ function secretsStore(devDir) {
5682
5707
  return createStore(path$1.join(devDir, "secrets.json"), isStringRecord, {}, 384);
5683
5708
  }
5684
5709
  /**
5685
- * Shared helpers for the upstream-attribute records every local provider
5686
- * emits — one implementation, so the compute and postgres families cannot
5687
- * drift on the `'local'` project fallback or the timestamp.
5688
- */
5689
- /** The fixed `createdAt`/`updatedAt` local providers stamp: local dev has no meaningful creation time. */
5690
- const DEV_TIMESTAMP = "1970-01-01T00:00:00.000Z";
5691
- /** Reads a project id from upstream's `project` input: a plain string or a resolved `Prisma.Project` attributes record. */
5692
- function projectIdOfInput(value) {
5693
- if (typeof value === "string") return value;
5694
- if (Predicate.isObject(value) && typeof value["projectId"] === "string") return value["projectId"];
5695
- return "local";
5696
- }
5697
- /**
5698
5710
  * Local compute-cluster providers: upstream alchemy's `Prisma.App` and
5699
5711
  * `Prisma.Deployment` become clients of the machine-scoped Compute emulator;
5700
5712
  * `Prisma.EnvironmentVariable` becomes a row in the dev env store;
@@ -6079,8 +6091,8 @@ const localTargetProviders = (input) => Layer.effect(Providers, Provider.collect
6079
6091
  Deployment,
6080
6092
  EnvironmentVariable,
6081
6093
  Bucket,
6082
- BucketKey
6083
- ])).pipe(Layer.provide(Layer.mergeAll(LocalProjectProvider(input), LocalDatabaseProvider(input), LocalConnectionProvider(input), LocalAppProvider(input), LocalDeploymentProvider(input), LocalEnvironmentVariableProvider(input), LocalBucketProvider(input), LocalBucketKeyProvider(input))), Layer.orDie);
6094
+ BucketAccessKey
6095
+ ])).pipe(Layer.provide(Layer.mergeAll(LocalProjectProvider(input), LocalDatabaseProvider(input), LocalConnectionProvider(input), LocalAppProvider(input), LocalDeploymentProvider(input), LocalEnvironmentVariableProvider(input), LocalBucketProvider(input), LocalBucketAccessKeyProvider(input))), Layer.orDie);
6084
6096
  /**
6085
6097
  * `import.meta.resolve(specifier)` + `fileURLToPath` in one call (local-dev
6086
6098
  * spec § 2's publish note). Lives here, not in the target extension's own