@prisma/composer-prisma-cloud 0.1.0-dev.11 → 0.1.0-dev.13
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.
- package/dist/control.d.mts +1 -1
- package/dist/control.mjs +122 -5
- package/dist/control.mjs.map +1 -1
- package/dist/cron/index.mjs +10 -2
- package/dist/cron/index.mjs.map +1 -1
- package/dist/cron/scheduler-entrypoint.mjs +10 -0
- package/dist/cron/scheduler-entrypoint.mjs.map +1 -1
- package/dist/cron/scheduler-service.mjs +10 -2
- package/dist/cron/scheduler-service.mjs.map +1 -1
- package/dist/index.d.mts +40 -1
- package/dist/index.mjs +41 -1
- package/dist/index.mjs.map +1 -1
- package/dist/storage/index.mjs +10 -2
- package/dist/storage/index.mjs.map +1 -1
- package/dist/storage/storage-entrypoint.mjs +10 -0
- package/dist/storage/storage-entrypoint.mjs.map +1 -1
- package/dist/storage/storage-service.mjs +10 -2
- package/dist/storage/storage-service.mjs.map +1 -1
- package/dist/streams/index.mjs +10 -2
- package/dist/streams/index.mjs.map +1 -1
- package/dist/streams/streams-entrypoint.mjs +10 -0
- package/dist/streams/streams-entrypoint.mjs.map +1 -1
- package/dist/streams/streams-service.mjs +10 -2
- package/dist/streams/streams-service.mjs.map +1 -1
- package/package.json +14 -14
package/dist/control.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as ProviderParamEntry } from "./serializer-Cx5slrV4-xJfH6EWS.mjs";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
|
+
import "effect/Effect";
|
|
3
4
|
import { createManagementApiClient } from "@prisma/management-api-sdk";
|
|
4
5
|
import "effect/Context";
|
|
5
|
-
import "effect/Effect";
|
|
6
6
|
import "effect/Redacted";
|
|
7
7
|
import "effect/Config";
|
|
8
8
|
import "alchemy/Provider";
|
package/dist/control.mjs
CHANGED
|
@@ -6,9 +6,9 @@ import { blindCast } from "@prisma/composer/casts";
|
|
|
6
6
|
import { RPC_PEER_KEY } from "@prisma/composer/service-rpc";
|
|
7
7
|
import pg from "pg";
|
|
8
8
|
import * as Layer from "effect/Layer";
|
|
9
|
+
import * as Effect from "effect/Effect";
|
|
9
10
|
import { createManagementApiClient } from "@prisma/management-api-sdk";
|
|
10
11
|
import * as Context from "effect/Context";
|
|
11
|
-
import * as Effect from "effect/Effect";
|
|
12
12
|
import * as Redacted from "effect/Redacted";
|
|
13
13
|
import * as Config$1 from "effect/Config";
|
|
14
14
|
import * as Data from "effect/Data";
|
|
@@ -28,7 +28,7 @@ import { resolve } from "pathe";
|
|
|
28
28
|
import { readRef } from "@prisma-next/migration-tools/refs";
|
|
29
29
|
import { APP_SPACE_ID, readContractSpaceHeadRef, spaceMigrationDirectory, spaceRefsDirectory } from "@prisma-next/migration-tools/spaces";
|
|
30
30
|
import { createPostgresControlClient } from "@prisma-next/postgres/control";
|
|
31
|
-
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/http-
|
|
31
|
+
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/http-BWHVlSzh.mjs
|
|
32
32
|
/**
|
|
33
33
|
* The Prisma service token used to authenticate Management API calls. Kept
|
|
34
34
|
* as a Redacted value so it never lands in logs or error output.
|
|
@@ -68,6 +68,84 @@ const callOptional = (f) => attempt$1(f).pipe(Effect.flatMap((r) => r.response.s
|
|
|
68
68
|
/** Fire-and-forget a call, tolerating a 404 (already deleted). */
|
|
69
69
|
const callVoid = (f) => attempt$1(f).pipe(Effect.flatMap((r) => r.response.status === 404 || r.error === void 0 ? Effect.void : fail(r)));
|
|
70
70
|
//#endregion
|
|
71
|
+
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/buckets.mjs
|
|
72
|
+
/** A Prisma **Object Store bucket** inside a project. */
|
|
73
|
+
const Bucket = Resource("Prisma.Bucket");
|
|
74
|
+
const BucketProvider = () => Provider.effect(Bucket, Effect.gen(function* () {
|
|
75
|
+
const client = yield* ManagementClient;
|
|
76
|
+
return {
|
|
77
|
+
stables: ["id"],
|
|
78
|
+
list: () => Effect.succeed([]),
|
|
79
|
+
reconcile: Effect.fn(function* ({ news, output }) {
|
|
80
|
+
const observed = output?.id ? yield* callOptional(() => client.GET("/v1/buckets/{bucketId}", { params: { path: { bucketId: output.id } } })) : void 0;
|
|
81
|
+
if (observed) return {
|
|
82
|
+
id: observed.data.id,
|
|
83
|
+
name: observed.data.name
|
|
84
|
+
};
|
|
85
|
+
const created = yield* call(() => client.POST("/v1/buckets", { body: {
|
|
86
|
+
projectId: news.projectId,
|
|
87
|
+
name: news.name,
|
|
88
|
+
...news.branchId !== void 0 ? { branchId: news.branchId } : {}
|
|
89
|
+
} }));
|
|
90
|
+
return {
|
|
91
|
+
id: created.data.id,
|
|
92
|
+
name: created.data.name
|
|
93
|
+
};
|
|
94
|
+
}),
|
|
95
|
+
delete: Effect.fn(function* ({ output }) {
|
|
96
|
+
yield* callVoid(() => client.DELETE("/v1/buckets/{bucketId}", { params: { path: { bucketId: output.id } } }));
|
|
97
|
+
}),
|
|
98
|
+
read: Effect.fn(function* ({ output }) {
|
|
99
|
+
if (!output?.id) return void 0;
|
|
100
|
+
const b = yield* callOptional(() => client.GET("/v1/buckets/{bucketId}", { params: { path: { bucketId: output.id } } }));
|
|
101
|
+
return b ? {
|
|
102
|
+
id: b.data.id,
|
|
103
|
+
name: b.data.name
|
|
104
|
+
} : void 0;
|
|
105
|
+
})
|
|
106
|
+
};
|
|
107
|
+
}));
|
|
108
|
+
/** A **bucket access key** for a Prisma Object Store bucket — yields the S3 credentials. */
|
|
109
|
+
const BucketKey = Resource("Prisma.BucketKey");
|
|
110
|
+
const BucketKeyProvider = () => Provider.effect(BucketKey, Effect.gen(function* () {
|
|
111
|
+
const client = yield* ManagementClient;
|
|
112
|
+
return {
|
|
113
|
+
stables: [
|
|
114
|
+
"id",
|
|
115
|
+
"bucketId",
|
|
116
|
+
"secretAccessKey",
|
|
117
|
+
"accessKeyId",
|
|
118
|
+
"endpoint",
|
|
119
|
+
"bucketName"
|
|
120
|
+
],
|
|
121
|
+
list: () => Effect.succeed([]),
|
|
122
|
+
reconcile: Effect.fn(function* ({ news, output }) {
|
|
123
|
+
if (output?.id) return output;
|
|
124
|
+
const created = yield* call(() => client.POST("/v1/buckets/{bucketId}/keys", {
|
|
125
|
+
params: { path: { bucketId: news.bucketId } },
|
|
126
|
+
body: {
|
|
127
|
+
name: news.name,
|
|
128
|
+
role: news.role
|
|
129
|
+
}
|
|
130
|
+
}));
|
|
131
|
+
return {
|
|
132
|
+
id: created.data.id,
|
|
133
|
+
bucketId: news.bucketId,
|
|
134
|
+
accessKeyId: created.data.accessKeyId,
|
|
135
|
+
secretAccessKey: Redacted.make(created.data.secretAccessKey),
|
|
136
|
+
endpoint: created.data.endpoint,
|
|
137
|
+
bucketName: created.data.bucketName
|
|
138
|
+
};
|
|
139
|
+
}),
|
|
140
|
+
delete: Effect.fn(function* ({ output }) {
|
|
141
|
+
yield* callVoid(() => client.DELETE("/v1/buckets/{bucketId}/keys/{keyId}", { params: { path: {
|
|
142
|
+
bucketId: output.bucketId,
|
|
143
|
+
keyId: output.id
|
|
144
|
+
} } }));
|
|
145
|
+
})
|
|
146
|
+
};
|
|
147
|
+
}));
|
|
148
|
+
//#endregion
|
|
71
149
|
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/compute.mjs
|
|
72
150
|
/**
|
|
73
151
|
* Stopping a deployment before the app that owns it can be
|
|
@@ -558,8 +636,10 @@ const providers = () => Layer.effect(Providers, Provider.collection([
|
|
|
558
636
|
Connection,
|
|
559
637
|
ComputeService,
|
|
560
638
|
Deployment,
|
|
561
|
-
EnvironmentVariable
|
|
562
|
-
|
|
639
|
+
EnvironmentVariable,
|
|
640
|
+
Bucket,
|
|
641
|
+
BucketKey
|
|
642
|
+
])).pipe(Layer.provide(Layer.mergeAll(ProjectProvider(), DatabaseProvider(), ConnectionProvider(), ComputeServiceProvider(), DeploymentProvider(), EnvironmentVariableProvider(), BucketProvider(), BucketKeyProvider())), Layer.provideMerge(layer()), Layer.provideMerge(fromEnv()), Layer.orDie);
|
|
563
643
|
//#endregion
|
|
564
644
|
//#region ../../1-prisma-cloud/0-lowering/lowering/dist/state.mjs
|
|
565
645
|
/** The framework-owned database a stage's deploy state lives in — a child of that stage's Branch (ADR-0034). */
|
|
@@ -1240,6 +1320,42 @@ function projectIdOf(application) {
|
|
|
1240
1320
|
if (!isCloudApplication(application)) throw new Error("prisma-cloud: ctx.application is not this extension's application product — the prismaCloud() application hook must run before any node lowers.");
|
|
1241
1321
|
return application.projectId;
|
|
1242
1322
|
}
|
|
1323
|
+
/**
|
|
1324
|
+
* One Bucket per module-provisioned bucket resource — `id` is the module
|
|
1325
|
+
* provision id, so a resource shared by several consumers is created exactly
|
|
1326
|
+
* once. A BucketKey is minted for the bucket: it is the reveal-once credential
|
|
1327
|
+
* carrier, and its attributes (endpoint, bucketName, accessKeyId,
|
|
1328
|
+
* secretAccessKey) become the four S3Config outputs consumers resolve by name.
|
|
1329
|
+
*/
|
|
1330
|
+
function bucketDescriptor(o) {
|
|
1331
|
+
const lowering = ({ id, application }) => Effect.gen(function* () {
|
|
1332
|
+
validateName(id, "resource name (from provision id)");
|
|
1333
|
+
const bkt = yield* Bucket(`${id}-bucket`, {
|
|
1334
|
+
projectId: projectIdOf(application),
|
|
1335
|
+
name: id,
|
|
1336
|
+
...o.branchId !== void 0 ? { branchId: o.branchId } : {}
|
|
1337
|
+
});
|
|
1338
|
+
const key = yield* BucketKey(`${id}-key`, {
|
|
1339
|
+
bucketId: bkt.id,
|
|
1340
|
+
name: id,
|
|
1341
|
+
role: "read_write"
|
|
1342
|
+
});
|
|
1343
|
+
const secretAccessKey = Output.map(key.secretAccessKey, (v) => Redacted.value(v));
|
|
1344
|
+
return {
|
|
1345
|
+
outputs: {
|
|
1346
|
+
url: key.endpoint,
|
|
1347
|
+
bucket: key.bucketName,
|
|
1348
|
+
accessKeyId: key.accessKeyId,
|
|
1349
|
+
secretAccessKey
|
|
1350
|
+
},
|
|
1351
|
+
entities: [{
|
|
1352
|
+
kind: "bucket",
|
|
1353
|
+
id: bkt.id
|
|
1354
|
+
}]
|
|
1355
|
+
};
|
|
1356
|
+
});
|
|
1357
|
+
return Object.assign(lowering, { kind: "resource" });
|
|
1358
|
+
}
|
|
1243
1359
|
/** The `compute` node kind's descriptor: the four service hooks — provision, serialize, package, deploy. */
|
|
1244
1360
|
/**
|
|
1245
1361
|
* Returns the PRECISE descriptor type, not the erased `NodeDescriptor`: the
|
|
@@ -2139,7 +2255,8 @@ const prismaCloud = (opts = {}) => {
|
|
|
2139
2255
|
"prisma-next": prismaNextDescriptor(o),
|
|
2140
2256
|
compute: computeDescriptor(o),
|
|
2141
2257
|
credentials: s3CredentialsDescriptor(o),
|
|
2142
|
-
"s3-store": s3StoreDescriptor(o)
|
|
2258
|
+
"s3-store": s3StoreDescriptor(o),
|
|
2259
|
+
s3: bucketDescriptor(o)
|
|
2143
2260
|
}
|
|
2144
2261
|
};
|
|
2145
2262
|
};
|