@prisma/composer-prisma-cloud 0.29.1-dev.1 → 0.29.1-dev.3
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/auth/pack.mjs +1 -1
- package/dist/auth/pack.mjs.map +1 -1
- package/dist/auth/testing.mjs +1 -1
- package/dist/auth/testing.mjs.map +1 -1
- package/dist/compute-main.mjs +2 -1
- package/dist/compute-main.mjs.map +1 -1
- package/dist/control.mjs +2 -2
- package/dist/control.mjs.map +1 -1
- package/dist/{get-port-BYnpbW5H.mjs → get-port-CwLPc-ca.mjs} +7 -2
- package/dist/{get-port-BYnpbW5H.mjs.map → get-port-CwLPc-ca.mjs.map} +1 -1
- package/dist/local-target.mjs +32 -7
- package/dist/local-target.mjs.map +1 -1
- package/dist/postgres-main.mjs +1 -1
- package/dist/{s3-credentials-resource-CySVP49N-Dpqeeey_.mjs → s3-credentials-resource-BZjtuopJ-DIvo5Cdl.mjs} +10 -6
- package/dist/{s3-credentials-resource-CySVP49N-Dpqeeey_.mjs.map → s3-credentials-resource-BZjtuopJ-DIvo5Cdl.mjs.map} +1 -1
- package/package.json +18 -18
|
@@ -105,7 +105,12 @@ function portNumbers(from, to) {
|
|
|
105
105
|
};
|
|
106
106
|
return generator(from, to);
|
|
107
107
|
}
|
|
108
|
+
function clearLockedPorts() {
|
|
109
|
+
lockedPorts.old.clear();
|
|
110
|
+
lockedPorts.young.clear();
|
|
111
|
+
reservedPorts.clear();
|
|
112
|
+
}
|
|
108
113
|
//#endregion
|
|
109
|
-
export {
|
|
114
|
+
export { getPorts as n, portNumbers as r, clearLockedPorts as t };
|
|
110
115
|
|
|
111
|
-
//# sourceMappingURL=get-port-
|
|
116
|
+
//# sourceMappingURL=get-port-CwLPc-ca.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-port-
|
|
1
|
+
{"version":3,"file":"get-port-CwLPc-ca.mjs","names":[],"sources":["../../../../node_modules/get-port/index.js"],"sourcesContent":["import net from 'node:net';\nimport os from 'node:os';\n\nclass Locked extends Error {\n\tconstructor(port) {\n\t\tsuper(`${port} is locked`);\n\t}\n}\n\nconst lockedPorts = {\n\told: new Set(),\n\tyoung: new Set(),\n};\n\n// On this interval, the old locked ports are discarded,\n// the young locked ports are moved to old locked ports,\n// and a new young set for locked ports are created.\nconst releaseOldLockedPortsIntervalMs = 1000 * 15;\n\n// Keep `reserve` deliberately process-wide by port number.\n// It is meant to avoid in-process races, not to model every possible\n// IPv4/IPv6 or host-specific bind combination.\nconst reservedPorts = new Set();\n\nconst minPort = 1024;\nconst maxPort = 65_535;\n\n// Lazily create timeout on first use\nlet timeout;\n\nconst getLocalHosts = () => {\n\tconst interfaces = os.networkInterfaces();\n\n\t// Add undefined value for createServer function to use default host,\n\t// and default IPv4 host in case createServer defaults to IPv6.\n\tconst results = new Set([undefined, '0.0.0.0']);\n\n\tfor (const _interface of Object.values(interfaces)) {\n\t\tfor (const config of _interface) {\n\t\t\tresults.add(config.address);\n\t\t}\n\t}\n\n\treturn results;\n};\n\nconst checkAvailablePort = options =>\n\tnew Promise((resolve, reject) => {\n\t\tconst server = net.createServer();\n\t\tserver.unref();\n\t\tserver.on('error', reject);\n\n\t\tserver.listen(options, () => {\n\t\t\tconst {port} = server.address();\n\t\t\tserver.close(() => {\n\t\t\t\tresolve(port);\n\t\t\t});\n\t\t});\n\t});\n\nconst getAvailablePort = async (options, hosts) => {\n\tif (options.host || options.port === 0) {\n\t\treturn checkAvailablePort(options);\n\t}\n\n\tfor (const host of hosts) {\n\t\ttry {\n\t\t\tawait checkAvailablePort({port: options.port, host}); // eslint-disable-line no-await-in-loop\n\t\t} catch (error) {\n\t\t\tif (!['EADDRNOTAVAIL', 'EINVAL'].includes(error.code)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\treturn options.port;\n};\n\nconst isLockedPort = port => lockedPorts.old.has(port) || lockedPorts.young.has(port) || reservedPorts.has(port);\n\nconst portCheckSequence = function * (ports) {\n\tif (ports) {\n\t\tyield * ports;\n\t}\n\n\tyield 0; // Fall back to 0 if anything else failed\n};\n\nexport default async function getPorts(options) {\n\tlet ports;\n\tlet exclude = new Set();\n\n\tif (options) {\n\t\tif (options.port) {\n\t\t\tports = typeof options.port === 'number' ? [options.port] : options.port;\n\t\t}\n\n\t\tif (options.exclude) {\n\t\t\tconst excludeIterable = options.exclude;\n\n\t\t\tif (typeof excludeIterable[Symbol.iterator] !== 'function') {\n\t\t\t\tthrow new TypeError('The `exclude` option must be an iterable.');\n\t\t\t}\n\n\t\t\tfor (const element of excludeIterable) {\n\t\t\t\tif (typeof element !== 'number') {\n\t\t\t\t\tthrow new TypeError('Each item in the `exclude` option must be a number corresponding to the port you want excluded.');\n\t\t\t\t}\n\n\t\t\t\tif (!Number.isSafeInteger(element)) {\n\t\t\t\t\tthrow new TypeError(`Number ${element} in the exclude option is not a safe integer and can't be used`);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\texclude = new Set(excludeIterable);\n\t\t}\n\t}\n\n\tconst {reserve, ...netOptions} = options ?? {};\n\n\tif (timeout === undefined) {\n\t\ttimeout = setTimeout(() => {\n\t\t\ttimeout = undefined;\n\n\t\t\tlockedPorts.old = lockedPorts.young;\n\t\t\tlockedPorts.young = new Set();\n\t\t}, releaseOldLockedPortsIntervalMs);\n\n\t\t// Does not exist in some environments (Electron, Jest jsdom env, browser, etc).\n\t\tif (timeout.unref) {\n\t\t\ttimeout.unref();\n\t\t}\n\t}\n\n\tconst hosts = getLocalHosts();\n\n\tfor (const port of portCheckSequence(ports)) {\n\t\ttry {\n\t\t\tif (exclude.has(port)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tlet availablePort = await getAvailablePort({...netOptions, port}, hosts); // eslint-disable-line no-await-in-loop\n\t\t\twhile (isLockedPort(availablePort)) {\n\t\t\t\tif (port !== 0) {\n\t\t\t\t\tthrow new Locked(port);\n\t\t\t\t}\n\n\t\t\t\tavailablePort = await getAvailablePort({...netOptions, port}, hosts); // eslint-disable-line no-await-in-loop\n\t\t\t}\n\n\t\t\tif (reserve) {\n\t\t\t\treservedPorts.add(availablePort);\n\t\t\t} else {\n\t\t\t\tlockedPorts.young.add(availablePort);\n\t\t\t}\n\n\t\t\treturn availablePort;\n\t\t} catch (error) {\n\t\t\tif (!['EADDRINUSE', 'EACCES'].includes(error.code) && !(error instanceof Locked)) {\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t}\n\t}\n\n\tthrow new Error('No available ports found');\n}\n\nexport function portNumbers(from, to) {\n\tif (!Number.isInteger(from) || !Number.isInteger(to)) {\n\t\tthrow new TypeError('`from` and `to` must be integer numbers');\n\t}\n\n\tif (from < minPort || from > maxPort) {\n\t\tthrow new RangeError(`'from' must be between ${minPort} and ${maxPort}`);\n\t}\n\n\tif (to < minPort || to > maxPort) {\n\t\tthrow new RangeError(`'to' must be between ${minPort} and ${maxPort}`);\n\t}\n\n\tif (from > to) {\n\t\tthrow new RangeError('`to` must be greater than or equal to `from`');\n\t}\n\n\tconst generator = function * (from, to) {\n\t\tfor (let port = from; port <= to; port++) {\n\t\t\tyield port;\n\t\t}\n\t};\n\n\treturn generator(from, to);\n}\n\nexport function clearLockedPorts() {\n\tlockedPorts.old.clear();\n\tlockedPorts.young.clear();\n\treservedPorts.clear();\n}\n"],"x_google_ignoreList":[0],"mappings":";;;AAGA,IAAM,SAAN,cAAqB,MAAM;CAC1B,YAAY,MAAM;EACjB,MAAM,GAAG,KAAK,WAAW;CAC1B;AACD;AAEA,MAAM,cAAc;CACnB,qBAAK,IAAI,IAAI;CACb,uBAAO,IAAI,IAAI;AAChB;AAKA,MAAM,kCAAkC,MAAO;AAK/C,MAAM,gCAAgB,IAAI,IAAI;AAE9B,MAAM,UAAU;AAChB,MAAM,UAAU;AAGhB,IAAI;AAEJ,MAAM,sBAAsB;CAC3B,MAAM,aAAa,GAAG,kBAAkB;CAIxC,MAAM,0BAAU,IAAI,IAAI,CAAC,KAA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O,SAAS;CAGxE,IAAI,KAAK,WAAW,KAAK,SACxB,MAAM,IAAI,WAAW,wBAAwB,QAAQ,OAAO,SAAS;CAGtE,IAAI,OAAO,IACV,MAAM,IAAI,WAAW,8CAA8C;CAGpE,MAAM,YAAY,WAAY,MAAM,IAAI;EACvC,KAAK,IAAI,OAAO,MAAM,QAAQ,IAAI,QACjC,MAAM;CAER;CAEA,OAAO,UAAU,MAAM,EAAE;AAC1B;AAEA,SAAgB,mBAAmB;CAClC,YAAY,IAAI,MAAM;CACtB,YAAY,MAAM,MAAM;CACxB,cAAc,MAAM;AACrB"}
|
package/dist/local-target.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as blindCast$1 } from "./casts-DpaahrlC-Ykus3kCE.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { E as isWithin, b as mintKeyPair, c as PrismaCloudContainer, d as collectPreflightNames, h as prismaCloudContainerOf, i as OrmMigrationProvider, n as GeneratedParamProvider, p as deserialize, s as PgWarmProvider, u as S3CredentialsProvider, v as serviceAppName, w as ServiceKeyProvider, x as Providers } from "./s3-credentials-resource-BZjtuopJ-DIvo5Cdl.mjs";
|
|
3
3
|
import { createRequire } from "node:module";
|
|
4
4
|
import { blindCast } from "@prisma/composer/casts";
|
|
5
5
|
import * as Effect from "effect/Effect";
|
|
@@ -5957,6 +5957,22 @@ function LocalAppProvider(input) {
|
|
|
5957
5957
|
read: ({ output }) => Effect.succeed(output)
|
|
5958
5958
|
}));
|
|
5959
5959
|
}
|
|
5960
|
+
/**
|
|
5961
|
+
* Reserves each service's emulator port one at a time, in the order given,
|
|
5962
|
+
* before Alchemy applies the `App` resources concurrently. A new service gets
|
|
5963
|
+
* the smallest free port, so on a fresh start the ports follow this order; a
|
|
5964
|
+
* service that already has a port keeps it. `serviceAppNames` are the
|
|
5965
|
+
* `App` resources' `displayName`s.
|
|
5966
|
+
*/
|
|
5967
|
+
async function reserveServicePorts(container, serviceAppNames) {
|
|
5968
|
+
const appName = appNameOf(container);
|
|
5969
|
+
for (const service of serviceAppNames) try {
|
|
5970
|
+
await computeClient().ensureService(appName, slugServiceId(service));
|
|
5971
|
+
} catch (cause) {
|
|
5972
|
+
const reason = cause instanceof Error ? cause.message : String(cause);
|
|
5973
|
+
throw new Error(`reserving a local port for service "${service}" failed: ${reason}`, { cause });
|
|
5974
|
+
}
|
|
5975
|
+
}
|
|
5960
5976
|
/** `Prisma.EnvironmentVariable` → a key/value row in `<devDir>/env.json`. Upstream's value is `Redacted`; env.json holds the plain string the child process is given. */
|
|
5961
5977
|
function LocalEnvironmentVariableProvider(input) {
|
|
5962
5978
|
return Provider.effect(EnvironmentVariable, Effect.succeed({
|
|
@@ -6317,19 +6333,24 @@ function devContainerDescriptor() {
|
|
|
6317
6333
|
deserialize
|
|
6318
6334
|
};
|
|
6319
6335
|
}
|
|
6336
|
+
/** The resolved absolute path to this daemon's published entrypoint. */
|
|
6337
|
+
function daemonEntry(name) {
|
|
6338
|
+
return resolvePackageEntry(`@prisma/composer-prisma-cloud/local-target/${name}-main`);
|
|
6339
|
+
}
|
|
6320
6340
|
function usesBuckets(input) {
|
|
6321
6341
|
return input.graph.nodes.some((n) => n.node.kind === "resource" && n.node.type === "s3");
|
|
6322
6342
|
}
|
|
6323
6343
|
function usesPostgres(input) {
|
|
6324
6344
|
return input.graph.nodes.some((n) => n.node.kind === "resource" && (n.node.type === "raw-postgres" || n.node.type === "postgres"));
|
|
6325
6345
|
}
|
|
6326
|
-
/** The
|
|
6327
|
-
function
|
|
6328
|
-
return
|
|
6346
|
+
/** The `App` name of each of this extension's services, in `graph.nodes` order: dependencies first, ties in declaration order. */
|
|
6347
|
+
function serviceAppNames(input) {
|
|
6348
|
+
return input.graph.nodes.filter((n) => n.node.kind === "service" && n.node.extension === "@prisma/composer-prisma-cloud").map((n) => serviceAppName(n.id));
|
|
6329
6349
|
}
|
|
6330
6350
|
async function runDevEmulators(input) {
|
|
6331
6351
|
const { url: computeUrl } = await ensureDaemon("compute", daemonEntry("compute"));
|
|
6332
6352
|
console.log(`[dev] compute emulator ready at ${computeUrl}`);
|
|
6353
|
+
await reserveServicePorts(input.container, serviceAppNames(input));
|
|
6333
6354
|
if (usesBuckets(input)) {
|
|
6334
6355
|
const { url: bucketsUrl } = await ensureDaemon("buckets", daemonEntry("buckets"));
|
|
6335
6356
|
console.log(`[dev] buckets emulator ready at ${bucketsUrl}`);
|
|
@@ -6387,9 +6408,13 @@ async function runDevTeardown(input) {
|
|
|
6387
6408
|
const app = prismaCloudContainerOf(input.container).input.appName;
|
|
6388
6409
|
const cwd = process.cwd();
|
|
6389
6410
|
await tolerateUnreachable(() => postgresClient().deleteApp(app));
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6411
|
+
try {
|
|
6412
|
+
await ensureDaemon("compute", daemonEntry("compute"));
|
|
6413
|
+
await computeClient().deleteApp(app);
|
|
6414
|
+
} finally {
|
|
6415
|
+
await tolerateUnreachable(() => bucketsClient().deleteApp(app));
|
|
6416
|
+
removeLocalPaths([`${cwd}/${DEV_DIR}`, `${cwd}/.alchemy/state/${app}/dev`]);
|
|
6417
|
+
}
|
|
6393
6418
|
}
|
|
6394
6419
|
/** `localTargetProviders()`'s `ProviderCollection` doesn't structurally unify with Alchemy's inferred providers Layer (a @internal/lowering typings gap); it satisfies it at runtime — mirrors `control/extension.ts`'s own `asProvidersLayer`, duplicated rather than shared so this module imports nothing from `./control`. */
|
|
6395
6420
|
function asProvidersLayer(layer) {
|