@powerlines/plugin-prisma 0.1.46 → 0.2.1
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/get-schema-CDmjvXFp.mjs +1 -0
- package/dist/get-schema-Cl2ZL_13.cjs +1 -0
- package/dist/helpers/get-schema.cjs +1 -7
- package/dist/helpers/get-schema.mjs +1 -0
- package/dist/helpers/index.cjs +1 -1
- package/dist/helpers/index.mjs +1 -0
- package/dist/helpers/prisma-postgres.cjs +1 -0
- package/dist/helpers/prisma-postgres.mjs +1 -0
- package/dist/helpers/schema-creator.cjs +1 -20
- package/dist/helpers/schema-creator.mjs +1 -0
- package/dist/index.cjs +4 -6
- package/dist/index.mjs +5 -0
- package/dist/plugin-Gb47Xzf6.mjs +1 -0
- package/dist/prisma-DZZX76mL.mjs +1 -0
- package/dist/prisma-postgres-Bf58erSt.mjs +1 -0
- package/dist/prisma-postgres-a3HnYRL2.cjs +1 -0
- package/dist/schema-creator-CqrBtaPh.mjs +14 -0
- package/dist/schema-creator-D6UwvhxO.cjs +14 -0
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.mjs +1 -0
- package/dist/types/plugin.cjs +1 -1
- package/dist/types/plugin.mjs +1 -0
- package/dist/types/prisma.cjs +1 -1
- package/dist/types/prisma.mjs +1 -0
- package/dist/types-CwXe_Ycf.mjs +1 -0
- package/dist/types-a8gm_IaQ.cjs +0 -0
- package/package.json +53 -34
- package/dist/chunk-FBBMZ4NC.cjs +0 -7
- package/dist/chunk-UCUR73HG.js +0 -7
- package/dist/helpers/get-schema.d.cts +0 -11
- package/dist/helpers/get-schema.d.ts +0 -11
- package/dist/helpers/get-schema.js +0 -7
- package/dist/helpers/index.d.cts +0 -22
- package/dist/helpers/index.d.ts +0 -22
- package/dist/helpers/index.js +0 -1
- package/dist/helpers/schema-creator.d.cts +0 -21
- package/dist/helpers/schema-creator.d.ts +0 -21
- package/dist/helpers/schema-creator.js +0 -20
- package/dist/index-B-z3Jwl2.d.cts +0 -1548
- package/dist/index-lx02iWd5.d.ts +0 -1548
- package/dist/index.d.cts +0 -32
- package/dist/index.d.ts +0 -32
- package/dist/index.js +0 -7
- package/dist/types/index.d.cts +0 -21
- package/dist/types/index.d.ts +0 -21
- package/dist/types/index.js +0 -1
- package/dist/types/plugin.d.cts +0 -21
- package/dist/types/plugin.d.ts +0 -21
- package/dist/types/prisma.d.cts +0 -84
- package/dist/types/prisma.d.ts +0 -84
- /package/dist/{types/plugin.js → plugin-pBKbb5K9.cjs} +0 -0
- /package/dist/{types/prisma.js → prisma-D3KrwikQ.cjs} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{getBinaryTargetForCurrentPlatform as e}from"@prisma/get-platform";import t from"@prisma/prisma-schema-wasm";import*as n from"fp-ts/Either";import{pipe as r}from"fp-ts/lib/function";import{match as i}from"ts-pattern";async function a(t){for(let n of t.binaryTargets){if(n.fromEnvVar&&process.env[n.fromEnvVar]){let e=JSON.parse(process.env[n.fromEnvVar]);Array.isArray(e)?(t.binaryTargets=e.map(e=>({fromEnvVar:null,value:e})),await a(t)):n.value=e}n.value===`native`&&(n.value=await e(),n.native=!0)}t.binaryTargets.length===0&&(t.binaryTargets=[{fromEnvVar:null,value:await e(),native:!0}])}async function o(e){let o=r(n.tryCatch(()=>{process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG&&t.debug_panic();let n=JSON.stringify({prismaSchema:e.datamodel,datasourceOverrides:{},ignoreEnvVarErrors:e.ignoreEnvVarErrors??!1,env:process.env});return t.get_config(n)},e=>({type:`wasm-error`,reason:`(get-config wasm)`,error:e})),n.map(e=>({result:e})),n.chainW(({result:e})=>n.tryCatch(()=>JSON.parse(e),e=>({type:`parse-json`,reason:`Unable to parse JSON`,error:e}))),n.chainW(e=>e.errors.length>0?n.left({type:`validation-error`,reason:`(get-config wasm)`,error:e.errors}):n.right(e.config)));if(n.isRight(o)){let{right:e}=o;for(let t of e.generators)await a(t);return Promise.resolve(e)}throw i(o.left).with({type:`wasm-error`},e=>Error(`Prisma get-config Wasm runtime error: ${e.error.message}`)).with({type:`validation-error`},e=>Error(`Prisma get-config validation error: ${e.error.map(e=>e.message).join(`, `)}`)).otherwise(e=>Error(`Prisma get-config unknown error: ${e.reason} - ${e.error.message}`))}export{o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@prisma/get-platform`),l=require(`@prisma/prisma-schema-wasm`);l=s(l);let u=require(`fp-ts/Either`);u=s(u);let d=require(`fp-ts/lib/function`),f=require(`ts-pattern`);async function p(e){for(let t of e.binaryTargets){if(t.fromEnvVar&&process.env[t.fromEnvVar]){let n=JSON.parse(process.env[t.fromEnvVar]);Array.isArray(n)?(e.binaryTargets=n.map(e=>({fromEnvVar:null,value:e})),await p(e)):t.value=n}t.value===`native`&&(t.value=await(0,c.getBinaryTargetForCurrentPlatform)(),t.native=!0)}e.binaryTargets.length===0&&(e.binaryTargets=[{fromEnvVar:null,value:await(0,c.getBinaryTargetForCurrentPlatform)(),native:!0}])}async function m(e){let t=(0,d.pipe)(u.tryCatch(()=>{process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG&&l.default.debug_panic();let t=JSON.stringify({prismaSchema:e.datamodel,datasourceOverrides:{},ignoreEnvVarErrors:e.ignoreEnvVarErrors??!1,env:process.env});return l.default.get_config(t)},e=>({type:`wasm-error`,reason:`(get-config wasm)`,error:e})),u.map(e=>({result:e})),u.chainW(({result:e})=>u.tryCatch(()=>JSON.parse(e),e=>({type:`parse-json`,reason:`Unable to parse JSON`,error:e}))),u.chainW(e=>e.errors.length>0?u.left({type:`validation-error`,reason:`(get-config wasm)`,error:e.errors}):u.right(e.config)));if(u.isRight(t)){let{right:e}=t;for(let t of e.generators)await p(t);return Promise.resolve(e)}throw(0,f.match)(t.left).with({type:`wasm-error`},e=>Error(`Prisma get-config Wasm runtime error: ${e.error.message}`)).with({type:`validation-error`},e=>Error(`Prisma get-config validation error: ${e.error.map(e=>e.message).join(`, `)}`)).otherwise(e=>Error(`Prisma get-config unknown error: ${e.reason} - ${e.error.message}`))}Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return m}});
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* ⚡ Built by Storm Software
|
|
4
|
-
*
|
|
5
|
-
*****************************************/
|
|
6
|
-
|
|
7
|
-
async function m(a){for(const e of a.binaryTargets){if(e.fromEnvVar&&process.env[e.fromEnvVar]){const r=JSON.parse(process.env[e.fromEnvVar]);Array.isArray(r)?(a.binaryTargets=r.map(o=>({fromEnvVar:null,value:o})),await m(a)):e.value=r;}e.value==="native"&&(e.value=await getPlatform.getBinaryTargetForCurrentPlatform(),e.native=true);}a.binaryTargets.length===0&&(a.binaryTargets=[{fromEnvVar:null,value:await getPlatform.getBinaryTargetForCurrentPlatform(),native:true}]);}chunkFBBMZ4NC_cjs.a(m,"resolveBinaryTargets");async function d(a){const e=_function.pipe(t__namespace.tryCatch(()=>{process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG&&i__default.default.debug_panic();const r=JSON.stringify({prismaSchema:a.datamodel,datasourceOverrides:{},ignoreEnvVarErrors:a.ignoreEnvVarErrors??false,env:process.env});return i__default.default.get_config(r)},r=>({type:"wasm-error",reason:"(get-config wasm)",error:r})),t__namespace.map(r=>({result:r})),t__namespace.chainW(({result:r})=>t__namespace.tryCatch(()=>JSON.parse(r),o=>({type:"parse-json",reason:"Unable to parse JSON",error:o}))),t__namespace.chainW(r=>r.errors.length>0?t__namespace.left({type:"validation-error",reason:"(get-config wasm)",error:r.errors}):t__namespace.right(r.config)));if(t__namespace.isRight(e)){const{right:r}=e;for(const o of r.generators)await m(o);return Promise.resolve(r)}throw tsPattern.match(e.left).with({type:"wasm-error"},r=>new Error(`Prisma get-config Wasm runtime error: ${r.error.message}`)).with({type:"validation-error"},r=>new Error(`Prisma get-config validation error: ${r.error.map(o=>o.message).join(", ")}`)).otherwise(r=>new Error(`Prisma get-config unknown error: ${r.reason} - ${r.error.message}`))}chunkFBBMZ4NC_cjs.a(d,"getSchema");exports.getSchema=d;
|
|
1
|
+
const e=require(`../get-schema-Cl2ZL_13.cjs`);exports.getSchema=e.t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../get-schema-CDmjvXFp.mjs";export{e as getSchema};
|
package/dist/helpers/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
const e=require(`../get-schema-Cl2ZL_13.cjs`),t=require(`../schema-creator-D6UwvhxO.cjs`),n=require(`../prisma-postgres-a3HnYRL2.cjs`);exports.PrismaSchemaCreator=t.t,exports.findDatabaseByName=n.t,exports.getSchema=e.t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../get-schema-CDmjvXFp.mjs";import{t}from"../schema-creator-CqrBtaPh.mjs";import{t as n}from"../prisma-postgres-Bf58erSt.mjs";export{t as PrismaSchemaCreator,n as findDatabaseByName,e as getSchema};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require(`../prisma-postgres-a3HnYRL2.cjs`);exports.findDatabaseByName=e.t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../prisma-postgres-Bf58erSt.mjs";export{e as findDatabaseByName};
|
|
@@ -1,20 +1 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* ⚡ Built by Storm Software
|
|
4
|
-
*
|
|
5
|
-
*****************************************/
|
|
6
|
-
|
|
7
|
-
class v extends schemaCreator.SchemaCreator{static{chunkFBBMZ4NC_cjs.a(this,"PrismaSchemaCreator");}#e;get generators(){return this.#e.prisma.schema.generators}set generators(r){this.#e.prisma.schema.generators=r;}constructor(r){super(),this.#e=r,this.#e.prisma??={},this.#e.prisma.schema??={generators:[],datasources:[],warnings:[]},this.#e.prisma.schema.generators.forEach(e=>{this.pushGenerator(e);});}pushGenerator(r){return this.generators.some(e=>e.name===r.name)?this.generators=[...this.generators.filter(e=>e.name!==r.name),r]:this.generators.push(r),this}build(){let r=super.build();for(const e of this.generators)r=`
|
|
8
|
-
generator ${e.name} {
|
|
9
|
-
provider = "${e.provider.value}"
|
|
10
|
-
output = "${e.output?.value}"${e.previewFeatures&&e.previewFeatures.length>0?`
|
|
11
|
-
previewFeatures = [${e.previewFeatures.map(t=>`"${t}"`).join(", ")}]`:""}${e.config&&Object.keys(e.config).length>0?Object.entries(e.config).map(([t,a])=>Array.isArray(a)?`${t} = [${a.map(i=>`"${i}"`).join(", ")}]`:`${t} = "${a}"`).join(`
|
|
12
|
-
`):""}${e.binaryTargets&&e.binaryTargets.length>0?`
|
|
13
|
-
binaryTargets = [${e.binaryTargets.map(t=>`"${t.value}"`).join(", ")}]`:""}${e.envPaths?.rootEnvPath||e.envPaths?.schemaEnvPath?`
|
|
14
|
-
env = {${e.envPaths?.rootEnvPath?`
|
|
15
|
-
root = "${e.envPaths.rootEnvPath}"`:""}${e.envPaths?.schemaEnvPath?`
|
|
16
|
-
schema = "${e.envPaths.schemaEnvPath}"`:""}
|
|
17
|
-
}`:""}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
${r}`;return r}async write(){await this.#e.fs.write(this.#e.config.prisma.schema,this.build());}}exports.PrismaSchemaCreator=v;
|
|
1
|
+
const e=require(`../schema-creator-D6UwvhxO.cjs`);exports.PrismaSchemaCreator=e.t;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"../schema-creator-CqrBtaPh.mjs";export{e as PrismaSchemaCreator};
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
*
|
|
3
|
-
* ⚡ Built by Storm Software
|
|
4
|
-
*
|
|
5
|
-
*****************************************/
|
|
1
|
+
Object.defineProperty(exports,`__esModule`,{value:!0});const e=require(`./get-schema-Cl2ZL_13.cjs`),t=require(`./schema-creator-D6UwvhxO.cjs`);require(`./plugin-pBKbb5K9.cjs`),require(`./prisma-D3KrwikQ.cjs`),require(`./types-a8gm_IaQ.cjs`);let n=require(`@stryke/cli/execute`),r=require(`@stryke/fs/exists`),i=require(`@stryke/fs/package-fns`),a=require(`@stryke/path/join-paths`),o=require(`@stryke/path/replace`),s=require(`defu`);s=e.n(s);let c=require(`@stryke/path/join`),l=require(`node:fs`);function u(e,t){if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.yml`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.yml`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.yaml`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.yaml`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.json`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.json`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.jsonc`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.jsonc`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.ts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.ts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.cts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.cts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.mts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.mts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.js`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.js`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.cjs`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.cjs`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.mjs`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.mjs`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.ts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.ts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.cts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.cts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.mts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.mts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.js`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.js`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.cjs`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.cjs`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.mjs`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.mjs`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.yml`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.yml`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.yaml`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.yaml`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.json`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.json`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.jsonc`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.jsonc`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.ts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.ts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.cts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.cts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.mts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.mts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.js`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.js`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.cjs`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.cjs`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.mjs`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.mjs`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.ts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.ts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.cts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.cts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.mts`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.mts`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.js`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.js`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.cjs`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.cjs`);if((0,l.existsSync)((0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.mjs`)))return(0,c.joinPaths)(e.workspaceConfig.workspaceRoot,`${t}.config.mjs`)}function d(e,t){return t&&t.replaceAll(`{workspaceRoot}`,e.workspaceConfig.workspaceRoot).replaceAll(`{root}`,e.config.projectRoot).replaceAll(`{projectRoot}`,e.config.projectRoot).replaceAll(`{sourceRoot}`,e.config.sourceRoot).replaceAll(`{powerlinesPath}`,e.powerlinesPath).replaceAll(`{cachePath}`,e.cachePath).replaceAll(`{dataPath}`,e.dataPath).replaceAll(`{logPath}`,e.envPaths.log).replaceAll(`{tempPath}`,e.envPaths.temp).replaceAll(`{configPath}`,e.envPaths.config).replaceAll(`{outputPath}`,e.config.output.outputPath).replaceAll(`{buildPath}`,e.config.output.buildPath).replaceAll(`{artifactsPath}`,(0,o.replacePath)(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,(0,o.replacePath)(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,(0,o.replacePath)(e.entryPath,e.workspaceConfig.workspaceRoot))}const f=({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:r,responseValidator:i,sseDefaultRetryDelay:a,sseMaxRetryAttempts:o,sseMaxRetryDelay:s,sseSleepFn:c,url:l,...u})=>{let d,f=c??(e=>new Promise(t=>setTimeout(t,e)));return{stream:async function*(){let c=a??3e3,p=0,m=u.signal??new AbortController().signal;for(;!m.aborted;){p++;let a=u.headers instanceof Headers?u.headers:new Headers(u.headers);d!==void 0&&a.set(`Last-Event-ID`,d);try{let t={redirect:`follow`,...u,body:u.serializedBody,headers:a,signal:m},o=new Request(l,t);e&&(o=await e(l,t));let s=await(u.fetch??globalThis.fetch)(o);if(!s.ok)throw Error(`SSE failed: ${s.status} ${s.statusText}`);if(!s.body)throw Error(`No body in SSE response`);let f=s.body.pipeThrough(new TextDecoderStream).getReader(),p=``,h=()=>{try{f.cancel()}catch{}};m.addEventListener(`abort`,h);try{for(;;){let{done:e,value:t}=await f.read();if(e)break;p+=t;let a=p.split(`
|
|
6
2
|
|
|
7
|
-
|
|
3
|
+
`);p=a.pop()??``;for(let e of a){let t=e.split(`
|
|
4
|
+
`),a=[],o;for(let e of t)if(e.startsWith(`data:`))a.push(e.replace(/^data:\s*/,``));else if(e.startsWith(`event:`))o=e.replace(/^event:\s*/,``);else if(e.startsWith(`id:`))d=e.replace(/^id:\s*/,``);else if(e.startsWith(`retry:`)){let t=Number.parseInt(e.replace(/^retry:\s*/,``),10);Number.isNaN(t)||(c=t)}let s,l=!1;if(a.length){let e=a.join(`
|
|
5
|
+
`);try{s=JSON.parse(e),l=!0}catch{s=e}}l&&(i&&await i(s),r&&(s=await r(s))),n?.({data:s,event:o,id:d,retry:c}),a.length&&(yield s)}}}finally{m.removeEventListener(`abort`,h),f.releaseLock()}break}catch(e){if(t?.(e),o!==void 0&&p>=o)break;await f(Math.min(c*2**(p-1),s??3e4))}}}()}},p=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},m=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},h=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},g=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(m(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=p(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):_({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},_=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},v=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=h(r),s=Object.entries(i).map(([t,i])=>_({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},y=/\{[^{}]+\}/g,b=({path:e,url:t})=>{let n=t,r=t.match(y);if(r)for(let t of r){let r=!1,i=t.substring(1,t.length-1),a=`simple`;i.endsWith(`*`)&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(`.`)?(i=i.substring(1),a=`label`):i.startsWith(`;`)&&(i=i.substring(1),a=`matrix`);let o=e[i];if(o==null)continue;if(Array.isArray(o)){n=n.replace(t,g({explode:r,name:i,style:a,value:o}));continue}if(typeof o==`object`){n=n.replace(t,v({explode:r,name:i,style:a,value:o,valueOnly:!0}));continue}if(a===`matrix`){n=n.replace(t,`;${_({name:i,value:o})}`);continue}let s=encodeURIComponent(a===`label`?`.${o}`:o);n=n.replace(t,s)}return n},x=({baseUrl:e,path:t,query:n,querySerializer:r,url:i})=>{let a=i.startsWith(`/`)?i:`/${i}`,o=(e??``)+a;t&&(o=b({path:t,url:o}));let s=n?r(n):``;return s.startsWith(`?`)&&(s=s.substring(1)),s&&(o+=`?${s}`),o};function S(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return`serializedBody`in e?e.serializedBody!==void 0&&e.serializedBody!==``?e.serializedBody:null:e.body===``?null:e.body;if(t)return e.body}const C=async(e,t)=>{let n=typeof t==`function`?await t(e):t;if(n)return e.scheme===`bearer`?`Bearer ${n}`:e.scheme===`basic`?`Basic ${btoa(n)}`:n},w={bodySerializer:e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)},T=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=g({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=v({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=_({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},E=e=>{if(!e)return`stream`;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if(t===`multipart/form-data`)return`formData`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},D=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get(`Cookie`)?.includes(`${t}=`)):!1,O=async({security:e,...t})=>{for(let n of e){if(D(t,n.name))continue;let e=await C(n,t.auth);if(!e)continue;let r=n.name??`Authorization`;switch(n.in){case`query`:t.query||={},t.query[r]=e;break;case`cookie`:t.headers.append(`Cookie`,`${r}=${e}`);break;case`header`:default:t.headers.set(r,e);break}}},k=e=>x({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==`function`?e.querySerializer:T(e.querySerializer),url:e.url}),A=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith(`/`)&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=M(e.headers,t.headers),n},j=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},M=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?j(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t};var N=class{fns=[];clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e==`number`?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let n=this.getInterceptorIndex(e);return this.fns[n]?(this.fns[n]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};const P=()=>({error:new N,request:new N,response:new N}),F=T({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),I={"Content-Type":`application/json`},L=(e={})=>({...w,headers:I,parseAs:`auto`,querySerializer:F,...e}),R=(e={})=>{let t=A(L(),e),n=()=>({...t}),r=e=>(t=A(t,e),n()),i=P(),a=async e=>{let n={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:M(t.headers,e.headers),serializedBody:void 0};return n.security&&await O({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body!==void 0&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.body===void 0||n.serializedBody===``)&&n.headers.delete(`Content-Type`),{opts:n,url:k(n)}},o=async e=>{let{opts:t,url:n}=await a(e),r={redirect:`follow`,...t,body:S(t)},o=new Request(n,r);for(let e of i.request.fns)e&&(o=await e(o,t));let s=t.fetch,c;try{c=await s(o)}catch(e){let n=e;for(let r of i.error.fns)r&&(n=await r(e,void 0,o,t));if(n||={},t.throwOnError)throw n;return t.responseStyle===`data`?void 0:{error:n,request:o,response:void 0}}for(let e of i.response.fns)e&&(c=await e(c,o,t));let l={request:o,response:c};if(c.ok){let e=(t.parseAs===`auto`?E(c.headers.get(`Content-Type`)):t.parseAs)??`json`;if(c.status===204||c.headers.get(`Content-Length`)===`0`){let n;switch(e){case`arrayBuffer`:case`blob`:case`text`:n=await c[e]();break;case`formData`:n=new FormData;break;case`stream`:n=c.body;break;case`json`:default:n={};break}return t.responseStyle===`data`?n:{data:n,...l}}let n;switch(e){case`arrayBuffer`:case`blob`:case`formData`:case`json`:case`text`:n=await c[e]();break;case`stream`:return t.responseStyle===`data`?c.body:{data:c.body,...l}}return e===`json`&&(t.responseValidator&&await t.responseValidator(n),t.responseTransformer&&(n=await t.responseTransformer(n))),t.responseStyle===`data`?n:{data:n,...l}}let u=await c.text(),d;try{d=JSON.parse(u)}catch{}let f=d??u,p=f;for(let e of i.error.fns)e&&(p=await e(f,c,o,t));if(p||={},t.throwOnError)throw p;return t.responseStyle===`data`?void 0:{error:p,...l}},s=e=>t=>o({...t,method:e}),c=e=>async t=>{let{opts:n,url:r}=await a(t);return f({...n,body:n.body,headers:n.headers,method:e,onRequest:async(e,t)=>{let r=new Request(e,t);for(let e of i.request.fns)e&&(r=await e(r,n));return r},url:r})};return{buildUrl:k,connect:s(`CONNECT`),delete:s(`DELETE`),get:s(`GET`),getConfig:n,head:s(`HEAD`),interceptors:i,options:s(`OPTIONS`),patch:s(`PATCH`),post:s(`POST`),put:s(`PUT`),request:o,setConfig:r,sse:{connect:c(`CONNECT`),delete:c(`DELETE`),get:c(`GET`),head:c(`HEAD`),options:c(`OPTIONS`),patch:c(`PATCH`),post:c(`POST`),put:c(`PUT`),trace:c(`TRACE`)},trace:s(`TRACE`)}},z=Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`}),B=R(L({throwOnError:!0}));var V=class{client;constructor(e){this.client=e?.client??B}},H=class{defaultKey=`default`;instances=new Map;get(e){let t=this.instances.get(e??this.defaultKey);if(!t)throw Error(`No SDK client found. Create one with "new PrismaClient()" to fix this error.`);return t}set(e,t){this.instances.set(t??this.defaultKey,e)}},U=class e extends V{static __registry=new H;constructor(t){super(t),e.__registry.set(this,t?.key)}deleteDatabaseConnectionString(e){return(e.client??this.client).delete({url:`/v1/connections/{id}`,...e})}deleteDatabase(e){return(e.client??this.client).delete({url:`/v1/databases/{databaseId}`,...e})}getDatabase(e){return(e.client??this.client).get({url:`/v1/databases/{databaseId}`,...e})}listDatabaseConnections(e){return(e.client??this.client).get({url:`/v1/databases/{databaseId}/connections`,...e})}createDatabaseConnectionString(e){return(e.client??this.client).post({url:`/v1/databases/{databaseId}/connections`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}listBackups(e){return(e.client??this.client).get({url:`/v1/databases/{databaseId}/backups`,...e})}getDatabaseUsageMetrics(e){return(e.client??this.client).get({url:`/v1/databases/{databaseId}/usage`,...e})}listProjects(e){return(e?.client??this.client).get({url:`/v1/projects`,...e})}createProjectWithPostgresDatabase(e){return(e?.client??this.client).post({url:`/v1/projects`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}deleteProject(e){return(e.client??this.client).delete({url:`/v1/projects/{id}`,...e})}getProject(e){return(e.client??this.client).get({url:`/v1/projects/{id}`,...e})}transferProject(e){return(e.client??this.client).post({url:`/v1/projects/{id}/transfer`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}listDatabases(e){return(e.client??this.client).get({url:`/v1/projects/{projectId}/databases`,...e})}createDatabase(e){return(e.client??this.client).post({url:`/v1/projects/{projectId}/databases`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}listIntegrations(e){return(e.client??this.client).get({url:`/v1/workspaces/{workspaceId}/integrations`,...e})}revokeIntegrationTokens(e){return(e.client??this.client).delete({url:`/v1/workspaces/{workspaceId}/integrations/{clientId}`,...e})}getPrismaPostgresRegions(e){return(e?.client??this.client).get({url:`/v1/regions/postgres`,...e})}getPrismaAccelerateRegions(e){return(e?.client??this.client).get({url:`/v1/regions/accelerate`,...e})}listWorkspaces(e){return(e?.client??this.client).get({url:`/v1/workspaces`,...e})}};const W=(c={})=>({name:`prisma`,config(){return{prisma:(0,s.default)(c,{schema:(0,a.joinPaths)(this.config.projectRoot,`prisma`,`schema.prisma`),configFile:c.configFile||u(this,`prisma.config`),outputPath:(0,a.joinPaths)(`{builtinPath}`,`prisma`),prismaPostgres:c?.prismaPostgres?{projectId:this.config.name,region:`us-east-1`}:void 0})}},async configResolved(){if(this.dependencies[`@prisma/client`]=`latest`,this.config.prisma.configFile=d(this,this.config.prisma.configFile),!this.config.prisma.schema)throw Error(`Prisma schema path is not defined. Please specify a valid path in the plugin configuration.`);if(this.config.prisma.schema=d(this,this.config.prisma.schema),this.config.prisma.prismaPostgres){let e=process.env.PRISMA_SERVICE_TOKEN;if(!e)if(e=c.serviceToken,e)this.warn("If possible, please use the `PRISMA_SERVICE_TOKEN` environment variable instead of using the `serviceToken` option directly. The `serviceToken` option will work; however, this is a less secure method of configuration.");else throw Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");let t=R(L({baseUrl:`https://api.prisma.io`,throwOnError:!0,headers:{Authorization:`Bearer ${e}`,"User-Agent":`powerlines/1.0`}}));this.prisma.api=new U({client:t}),await this.prisma.api.createDatabase({path:{projectId:this.config.prisma.prismaPostgres.projectId},body:{isDefault:!1,name:this.config.prisma.prismaPostgres.databaseName||`${this.config.prisma.prismaPostgres.region}.${this.config.mode}.${this.config.name}`,region:this.config.prisma.prismaPostgres.region}}).then(e=>e.data.data)}if(!this.config.prisma.outputPath)throw Error(`Prisma generated path is not defined. Please specify a valid path in the plugin configuration.`);this.config.prisma.outputPath=d(this,this.config.prisma.outputPath),this.prisma??={},(0,r.existsSync)(this.config.prisma.schema)?this.prisma.schema=await e.t({datamodel:this.config.prisma.schema}):this.prisma.schema??={generators:[],datasources:[],warnings:[]};let n=this.prisma.schema.generators.find(e=>e.provider.value===`prisma-client-js`);n?n.output??={value:this.config.prisma.outputPath,fromEnvVar:null}:this.prisma.schema.generators.push({name:`prisma-client-js`,provider:{value:`prisma-client-js`,fromEnvVar:null},output:{value:this.config.prisma.outputPath,fromEnvVar:null},config:{},binaryTargets:[],previewFeatures:[],sourceFilePath:this.config.prisma.schema}),this.prisma.builder=new t.t(this)},async prepare(){await this.prisma.builder.write();let e=[`generate`,`--schema`,this.config.prisma.schema];if(this.config.prisma.prismaPath){e.unshift(this.config.prisma.prismaPath);let t=await(0,n.execute)(e.join(` `),this.config.projectRoot);if(t.failed)throw Error(`Prisma process exited with code ${t.exitCode}.`)}else{let t=await(0,i.isPackageListed)(`prisma`,this.config.projectRoot);e.unshift(t?(0,o.replacePath)(this.config.sourceRoot,this.config.projectRoot):this.config.sourceRoot);let r=await(0,n.executePackage)(`prisma`,e,(0,a.joinPaths)(this.workspaceConfig.workspaceRoot,this.config.projectRoot));if(r.failed)throw Error(`Prisma process exited with code ${r.exitCode}.`)}}});var G=W;exports.PrismaClient=U,exports.client=B,exports.default=G,exports.plugin=W;
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{t as e}from"./get-schema-CDmjvXFp.mjs";import{t}from"./schema-creator-CqrBtaPh.mjs";import"./plugin-Gb47Xzf6.mjs";import"./prisma-DZZX76mL.mjs";import"./types-CwXe_Ycf.mjs";import{execute as n,executePackage as r}from"@stryke/cli/execute";import{existsSync as i}from"@stryke/fs/exists";import{isPackageListed as a}from"@stryke/fs/package-fns";import{joinPaths as o}from"@stryke/path/join-paths";import{replacePath as s}from"@stryke/path/replace";import c from"defu";import{joinPaths as l}from"@stryke/path/join";import{existsSync as u}from"node:fs";function d(e,t){if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.yml`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.yml`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.yaml`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.yaml`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.json`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.json`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.jsonc`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.jsonc`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.ts`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.ts`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.cts`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.cts`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.mts`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.mts`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.js`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.js`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.cjs`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.cjs`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.mjs`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.mjs`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.ts`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.ts`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.cts`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.cts`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.mts`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.mts`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.js`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.js`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.cjs`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.cjs`);if(u(l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.mjs`)))return l(e.workspaceConfig.workspaceRoot,e.config.projectRoot,`${t}.config.mjs`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.yml`)))return l(e.workspaceConfig.workspaceRoot,`${t}.yml`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.yaml`)))return l(e.workspaceConfig.workspaceRoot,`${t}.yaml`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.json`)))return l(e.workspaceConfig.workspaceRoot,`${t}.json`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.jsonc`)))return l(e.workspaceConfig.workspaceRoot,`${t}.jsonc`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.ts`)))return l(e.workspaceConfig.workspaceRoot,`${t}.ts`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.cts`)))return l(e.workspaceConfig.workspaceRoot,`${t}.cts`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.mts`)))return l(e.workspaceConfig.workspaceRoot,`${t}.mts`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.js`)))return l(e.workspaceConfig.workspaceRoot,`${t}.js`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.cjs`)))return l(e.workspaceConfig.workspaceRoot,`${t}.cjs`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.mjs`)))return l(e.workspaceConfig.workspaceRoot,`${t}.mjs`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.config.ts`)))return l(e.workspaceConfig.workspaceRoot,`${t}.config.ts`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.config.cts`)))return l(e.workspaceConfig.workspaceRoot,`${t}.config.cts`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.config.mts`)))return l(e.workspaceConfig.workspaceRoot,`${t}.config.mts`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.config.js`)))return l(e.workspaceConfig.workspaceRoot,`${t}.config.js`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.config.cjs`)))return l(e.workspaceConfig.workspaceRoot,`${t}.config.cjs`);if(u(l(e.workspaceConfig.workspaceRoot,`${t}.config.mjs`)))return l(e.workspaceConfig.workspaceRoot,`${t}.config.mjs`)}function f(e,t){return t&&t.replaceAll(`{workspaceRoot}`,e.workspaceConfig.workspaceRoot).replaceAll(`{root}`,e.config.projectRoot).replaceAll(`{projectRoot}`,e.config.projectRoot).replaceAll(`{sourceRoot}`,e.config.sourceRoot).replaceAll(`{powerlinesPath}`,e.powerlinesPath).replaceAll(`{cachePath}`,e.cachePath).replaceAll(`{dataPath}`,e.dataPath).replaceAll(`{logPath}`,e.envPaths.log).replaceAll(`{tempPath}`,e.envPaths.temp).replaceAll(`{configPath}`,e.envPaths.config).replaceAll(`{outputPath}`,e.config.output.outputPath).replaceAll(`{buildPath}`,e.config.output.buildPath).replaceAll(`{artifactsPath}`,s(e.artifactsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{builtinPath}`,s(e.builtinsPath,e.workspaceConfig.workspaceRoot)).replaceAll(`{entryPath}`,s(e.entryPath,e.workspaceConfig.workspaceRoot))}const p=({onRequest:e,onSseError:t,onSseEvent:n,responseTransformer:r,responseValidator:i,sseDefaultRetryDelay:a,sseMaxRetryAttempts:o,sseMaxRetryDelay:s,sseSleepFn:c,url:l,...u})=>{let d,f=c??(e=>new Promise(t=>setTimeout(t,e)));return{stream:async function*(){let c=a??3e3,p=0,m=u.signal??new AbortController().signal;for(;!m.aborted;){p++;let a=u.headers instanceof Headers?u.headers:new Headers(u.headers);d!==void 0&&a.set(`Last-Event-ID`,d);try{let t={redirect:`follow`,...u,body:u.serializedBody,headers:a,signal:m},o=new Request(l,t);e&&(o=await e(l,t));let s=await(u.fetch??globalThis.fetch)(o);if(!s.ok)throw Error(`SSE failed: ${s.status} ${s.statusText}`);if(!s.body)throw Error(`No body in SSE response`);let f=s.body.pipeThrough(new TextDecoderStream).getReader(),p=``,h=()=>{try{f.cancel()}catch{}};m.addEventListener(`abort`,h);try{for(;;){let{done:e,value:t}=await f.read();if(e)break;p+=t;let a=p.split(`
|
|
2
|
+
|
|
3
|
+
`);p=a.pop()??``;for(let e of a){let t=e.split(`
|
|
4
|
+
`),a=[],o;for(let e of t)if(e.startsWith(`data:`))a.push(e.replace(/^data:\s*/,``));else if(e.startsWith(`event:`))o=e.replace(/^event:\s*/,``);else if(e.startsWith(`id:`))d=e.replace(/^id:\s*/,``);else if(e.startsWith(`retry:`)){let t=Number.parseInt(e.replace(/^retry:\s*/,``),10);Number.isNaN(t)||(c=t)}let s,l=!1;if(a.length){let e=a.join(`
|
|
5
|
+
`);try{s=JSON.parse(e),l=!0}catch{s=e}}l&&(i&&await i(s),r&&(s=await r(s))),n?.({data:s,event:o,id:d,retry:c}),a.length&&(yield s)}}}finally{m.removeEventListener(`abort`,h),f.releaseLock()}break}catch(e){if(t?.(e),o!==void 0&&p>=o)break;await f(Math.min(c*2**(p-1),s??3e4))}}}()}},m=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},h=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},g=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},_=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(h(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=m(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):v({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},v=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},y=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=g(r),s=Object.entries(i).map(([t,i])=>v({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},b=/\{[^{}]+\}/g,x=({path:e,url:t})=>{let n=t,r=t.match(b);if(r)for(let t of r){let r=!1,i=t.substring(1,t.length-1),a=`simple`;i.endsWith(`*`)&&(r=!0,i=i.substring(0,i.length-1)),i.startsWith(`.`)?(i=i.substring(1),a=`label`):i.startsWith(`;`)&&(i=i.substring(1),a=`matrix`);let o=e[i];if(o==null)continue;if(Array.isArray(o)){n=n.replace(t,_({explode:r,name:i,style:a,value:o}));continue}if(typeof o==`object`){n=n.replace(t,y({explode:r,name:i,style:a,value:o,valueOnly:!0}));continue}if(a===`matrix`){n=n.replace(t,`;${v({name:i,value:o})}`);continue}let s=encodeURIComponent(a===`label`?`.${o}`:o);n=n.replace(t,s)}return n},S=({baseUrl:e,path:t,query:n,querySerializer:r,url:i})=>{let a=i.startsWith(`/`)?i:`/${i}`,o=(e??``)+a;t&&(o=x({path:t,url:o}));let s=n?r(n):``;return s.startsWith(`?`)&&(s=s.substring(1)),s&&(o+=`?${s}`),o};function C(e){let t=e.body!==void 0;if(t&&e.bodySerializer)return`serializedBody`in e?e.serializedBody!==void 0&&e.serializedBody!==``?e.serializedBody:null:e.body===``?null:e.body;if(t)return e.body}const w=async(e,t)=>{let n=typeof t==`function`?await t(e):t;if(n)return e.scheme===`bearer`?`Bearer ${n}`:e.scheme===`basic`?`Basic ${btoa(n)}`:n},T={bodySerializer:e=>JSON.stringify(e,(e,t)=>typeof t==`bigint`?t.toString():t)},E=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=_({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=y({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=v({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},D=e=>{if(!e)return`stream`;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if(t===`multipart/form-data`)return`formData`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},O=(e,t)=>t?!!(e.headers.has(t)||e.query?.[t]||e.headers.get(`Cookie`)?.includes(`${t}=`)):!1,k=async({security:e,...t})=>{for(let n of e){if(O(t,n.name))continue;let e=await w(n,t.auth);if(!e)continue;let r=n.name??`Authorization`;switch(n.in){case`query`:t.query||={},t.query[r]=e;break;case`cookie`:t.headers.append(`Cookie`,`${r}=${e}`);break;case`header`:default:t.headers.set(r,e);break}}},A=e=>S({baseUrl:e.baseUrl,path:e.path,query:e.query,querySerializer:typeof e.querySerializer==`function`?e.querySerializer:E(e.querySerializer),url:e.url}),j=(e,t)=>{let n={...e,...t};return n.baseUrl?.endsWith(`/`)&&(n.baseUrl=n.baseUrl.substring(0,n.baseUrl.length-1)),n.headers=N(e.headers,t.headers),n},M=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},N=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?M(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t};var P=class{fns=[];clear(){this.fns=[]}eject(e){let t=this.getInterceptorIndex(e);this.fns[t]&&(this.fns[t]=null)}exists(e){let t=this.getInterceptorIndex(e);return!!this.fns[t]}getInterceptorIndex(e){return typeof e==`number`?this.fns[e]?e:-1:this.fns.indexOf(e)}update(e,t){let n=this.getInterceptorIndex(e);return this.fns[n]?(this.fns[n]=t,e):!1}use(e){return this.fns.push(e),this.fns.length-1}};const F=()=>({error:new P,request:new P,response:new P}),I=E({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),L={"Content-Type":`application/json`},R=(e={})=>({...T,headers:L,parseAs:`auto`,querySerializer:I,...e}),z=(e={})=>{let t=j(R(),e),n=()=>({...t}),r=e=>(t=j(t,e),n()),i=F(),a=async e=>{let n={...t,...e,fetch:e.fetch??t.fetch??globalThis.fetch,headers:N(t.headers,e.headers),serializedBody:void 0};return n.security&&await k({...n,security:n.security}),n.requestValidator&&await n.requestValidator(n),n.body!==void 0&&n.bodySerializer&&(n.serializedBody=n.bodySerializer(n.body)),(n.body===void 0||n.serializedBody===``)&&n.headers.delete(`Content-Type`),{opts:n,url:A(n)}},o=async e=>{let{opts:t,url:n}=await a(e),r={redirect:`follow`,...t,body:C(t)},o=new Request(n,r);for(let e of i.request.fns)e&&(o=await e(o,t));let s=t.fetch,c;try{c=await s(o)}catch(e){let n=e;for(let r of i.error.fns)r&&(n=await r(e,void 0,o,t));if(n||={},t.throwOnError)throw n;return t.responseStyle===`data`?void 0:{error:n,request:o,response:void 0}}for(let e of i.response.fns)e&&(c=await e(c,o,t));let l={request:o,response:c};if(c.ok){let e=(t.parseAs===`auto`?D(c.headers.get(`Content-Type`)):t.parseAs)??`json`;if(c.status===204||c.headers.get(`Content-Length`)===`0`){let n;switch(e){case`arrayBuffer`:case`blob`:case`text`:n=await c[e]();break;case`formData`:n=new FormData;break;case`stream`:n=c.body;break;case`json`:default:n={};break}return t.responseStyle===`data`?n:{data:n,...l}}let n;switch(e){case`arrayBuffer`:case`blob`:case`formData`:case`json`:case`text`:n=await c[e]();break;case`stream`:return t.responseStyle===`data`?c.body:{data:c.body,...l}}return e===`json`&&(t.responseValidator&&await t.responseValidator(n),t.responseTransformer&&(n=await t.responseTransformer(n))),t.responseStyle===`data`?n:{data:n,...l}}let u=await c.text(),d;try{d=JSON.parse(u)}catch{}let f=d??u,p=f;for(let e of i.error.fns)e&&(p=await e(f,c,o,t));if(p||={},t.throwOnError)throw p;return t.responseStyle===`data`?void 0:{error:p,...l}},s=e=>t=>o({...t,method:e}),c=e=>async t=>{let{opts:n,url:r}=await a(t);return p({...n,body:n.body,headers:n.headers,method:e,onRequest:async(e,t)=>{let r=new Request(e,t);for(let e of i.request.fns)e&&(r=await e(r,n));return r},url:r})};return{buildUrl:A,connect:s(`CONNECT`),delete:s(`DELETE`),get:s(`GET`),getConfig:n,head:s(`HEAD`),interceptors:i,options:s(`OPTIONS`),patch:s(`PATCH`),post:s(`POST`),put:s(`PUT`),request:o,setConfig:r,sse:{connect:c(`CONNECT`),delete:c(`DELETE`),get:c(`GET`),head:c(`HEAD`),options:c(`OPTIONS`),patch:c(`PATCH`),post:c(`POST`),put:c(`PUT`),trace:c(`TRACE`)},trace:s(`TRACE`)}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const B=z(R({throwOnError:!0}));var V=class{client;constructor(e){this.client=e?.client??B}},H=class{defaultKey=`default`;instances=new Map;get(e){let t=this.instances.get(e??this.defaultKey);if(!t)throw Error(`No SDK client found. Create one with "new PrismaClient()" to fix this error.`);return t}set(e,t){this.instances.set(t??this.defaultKey,e)}},U=class e extends V{static __registry=new H;constructor(t){super(t),e.__registry.set(this,t?.key)}deleteDatabaseConnectionString(e){return(e.client??this.client).delete({url:`/v1/connections/{id}`,...e})}deleteDatabase(e){return(e.client??this.client).delete({url:`/v1/databases/{databaseId}`,...e})}getDatabase(e){return(e.client??this.client).get({url:`/v1/databases/{databaseId}`,...e})}listDatabaseConnections(e){return(e.client??this.client).get({url:`/v1/databases/{databaseId}/connections`,...e})}createDatabaseConnectionString(e){return(e.client??this.client).post({url:`/v1/databases/{databaseId}/connections`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}listBackups(e){return(e.client??this.client).get({url:`/v1/databases/{databaseId}/backups`,...e})}getDatabaseUsageMetrics(e){return(e.client??this.client).get({url:`/v1/databases/{databaseId}/usage`,...e})}listProjects(e){return(e?.client??this.client).get({url:`/v1/projects`,...e})}createProjectWithPostgresDatabase(e){return(e?.client??this.client).post({url:`/v1/projects`,...e,headers:{"Content-Type":`application/json`,...e?.headers}})}deleteProject(e){return(e.client??this.client).delete({url:`/v1/projects/{id}`,...e})}getProject(e){return(e.client??this.client).get({url:`/v1/projects/{id}`,...e})}transferProject(e){return(e.client??this.client).post({url:`/v1/projects/{id}/transfer`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}listDatabases(e){return(e.client??this.client).get({url:`/v1/projects/{projectId}/databases`,...e})}createDatabase(e){return(e.client??this.client).post({url:`/v1/projects/{projectId}/databases`,...e,headers:{"Content-Type":`application/json`,...e.headers}})}listIntegrations(e){return(e.client??this.client).get({url:`/v1/workspaces/{workspaceId}/integrations`,...e})}revokeIntegrationTokens(e){return(e.client??this.client).delete({url:`/v1/workspaces/{workspaceId}/integrations/{clientId}`,...e})}getPrismaPostgresRegions(e){return(e?.client??this.client).get({url:`/v1/regions/postgres`,...e})}getPrismaAccelerateRegions(e){return(e?.client??this.client).get({url:`/v1/regions/accelerate`,...e})}listWorkspaces(e){return(e?.client??this.client).get({url:`/v1/workspaces`,...e})}};const W=(l={})=>({name:`prisma`,config(){return{prisma:c(l,{schema:o(this.config.projectRoot,`prisma`,`schema.prisma`),configFile:l.configFile||d(this,`prisma.config`),outputPath:o(`{builtinPath}`,`prisma`),prismaPostgres:l?.prismaPostgres?{projectId:this.config.name,region:`us-east-1`}:void 0})}},async configResolved(){if(this.dependencies[`@prisma/client`]=`latest`,this.config.prisma.configFile=f(this,this.config.prisma.configFile),!this.config.prisma.schema)throw Error(`Prisma schema path is not defined. Please specify a valid path in the plugin configuration.`);if(this.config.prisma.schema=f(this,this.config.prisma.schema),this.config.prisma.prismaPostgres){let e=process.env.PRISMA_SERVICE_TOKEN;if(!e)if(e=l.serviceToken,e)this.warn("If possible, please use the `PRISMA_SERVICE_TOKEN` environment variable instead of using the `serviceToken` option directly. The `serviceToken` option will work; however, this is a less secure method of configuration.");else throw Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");let t=z(R({baseUrl:`https://api.prisma.io`,throwOnError:!0,headers:{Authorization:`Bearer ${e}`,"User-Agent":`powerlines/1.0`}}));this.prisma.api=new U({client:t}),await this.prisma.api.createDatabase({path:{projectId:this.config.prisma.prismaPostgres.projectId},body:{isDefault:!1,name:this.config.prisma.prismaPostgres.databaseName||`${this.config.prisma.prismaPostgres.region}.${this.config.mode}.${this.config.name}`,region:this.config.prisma.prismaPostgres.region}}).then(e=>e.data.data)}if(!this.config.prisma.outputPath)throw Error(`Prisma generated path is not defined. Please specify a valid path in the plugin configuration.`);this.config.prisma.outputPath=f(this,this.config.prisma.outputPath),this.prisma??={},i(this.config.prisma.schema)?this.prisma.schema=await e({datamodel:this.config.prisma.schema}):this.prisma.schema??={generators:[],datasources:[],warnings:[]};let n=this.prisma.schema.generators.find(e=>e.provider.value===`prisma-client-js`);n?n.output??={value:this.config.prisma.outputPath,fromEnvVar:null}:this.prisma.schema.generators.push({name:`prisma-client-js`,provider:{value:`prisma-client-js`,fromEnvVar:null},output:{value:this.config.prisma.outputPath,fromEnvVar:null},config:{},binaryTargets:[],previewFeatures:[],sourceFilePath:this.config.prisma.schema}),this.prisma.builder=new t(this)},async prepare(){await this.prisma.builder.write();let e=[`generate`,`--schema`,this.config.prisma.schema];if(this.config.prisma.prismaPath){e.unshift(this.config.prisma.prismaPath);let t=await n(e.join(` `),this.config.projectRoot);if(t.failed)throw Error(`Prisma process exited with code ${t.exitCode}.`)}else{let t=await a(`prisma`,this.config.projectRoot);e.unshift(t?s(this.config.sourceRoot,this.config.projectRoot):this.config.sourceRoot);let n=await r(`prisma`,e,o(this.workspaceConfig.workspaceRoot,this.config.projectRoot));if(n.failed)throw Error(`Prisma process exited with code ${n.exitCode}.`)}}});var G=W;export{U as PrismaClient,B as client,G as default,W as plugin};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function e(e,t){if(!e.config.prisma.prismaPostgres?.projectId)throw Error(`Prisma Postgres project ID is not configured. Please set "prisma.prismaPostgres.projectId" in your Powerlines configuration.`);return(await e.prisma.api.listDatabases({path:{projectId:e.config.prisma.prismaPostgres.projectId}})).data.data.find(e=>e.name===t)}export{e as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
async function e(e,t){if(!e.config.prisma.prismaPostgres?.projectId)throw Error(`Prisma Postgres project ID is not configured. Please set "prisma.prismaPostgres.projectId" in your Powerlines configuration.`);return(await e.prisma.api.listDatabases({path:{projectId:e.config.prisma.prismaPostgres.projectId}})).data.data.find(e=>e.name===t)}Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return e}});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{SchemaCreator as e}from"prisma-util/schema-creator";var t=class extends e{#e;get generators(){return this.#e.prisma.schema.generators}set generators(e){this.#e.prisma.schema.generators=e}constructor(e){super(),this.#e=e,this.#e.prisma??={},this.#e.prisma.schema??={generators:[],datasources:[],warnings:[]},this.#e.prisma.schema.generators.forEach(e=>{this.pushGenerator(e)})}pushGenerator(e){return this.generators.some(t=>t.name===e.name)?this.generators=[...this.generators.filter(t=>t.name!==e.name),e]:this.generators.push(e),this}build(){let e=super.build();for(let t of this.generators)e=`
|
|
2
|
+
generator ${t.name} {
|
|
3
|
+
provider = "${t.provider.value}"
|
|
4
|
+
output = "${t.output?.value}"${t.previewFeatures&&t.previewFeatures.length>0?`
|
|
5
|
+
previewFeatures = [${t.previewFeatures.map(e=>`"${e}"`).join(`, `)}]`:``}${t.config&&Object.keys(t.config).length>0?Object.entries(t.config).map(([e,t])=>Array.isArray(t)?`${e} = [${t.map(e=>`"${e}"`).join(`, `)}]`:`${e} = "${t}"`).join(`
|
|
6
|
+
`):``}${t.binaryTargets&&t.binaryTargets.length>0?`
|
|
7
|
+
binaryTargets = [${t.binaryTargets.map(e=>`"${e.value}"`).join(`, `)}]`:``}${t.envPaths?.rootEnvPath||t.envPaths?.schemaEnvPath?`
|
|
8
|
+
env = {${t.envPaths?.rootEnvPath?`
|
|
9
|
+
root = "${t.envPaths.rootEnvPath}"`:``}${t.envPaths?.schemaEnvPath?`
|
|
10
|
+
schema = "${t.envPaths.schemaEnvPath}"`:``}
|
|
11
|
+
}`:``}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
${e}`;return e}async write(){await this.#e.fs.write(this.#e.config.prisma.schema,this.build())}};export{t};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const e=require(`./get-schema-Cl2ZL_13.cjs`);let t=require(`prisma-util/schema-creator`);var n=class extends t.SchemaCreator{#e;get generators(){return this.#e.prisma.schema.generators}set generators(e){this.#e.prisma.schema.generators=e}constructor(e){super(),this.#e=e,this.#e.prisma??={},this.#e.prisma.schema??={generators:[],datasources:[],warnings:[]},this.#e.prisma.schema.generators.forEach(e=>{this.pushGenerator(e)})}pushGenerator(e){return this.generators.some(t=>t.name===e.name)?this.generators=[...this.generators.filter(t=>t.name!==e.name),e]:this.generators.push(e),this}build(){let e=super.build();for(let t of this.generators)e=`
|
|
2
|
+
generator ${t.name} {
|
|
3
|
+
provider = "${t.provider.value}"
|
|
4
|
+
output = "${t.output?.value}"${t.previewFeatures&&t.previewFeatures.length>0?`
|
|
5
|
+
previewFeatures = [${t.previewFeatures.map(e=>`"${e}"`).join(`, `)}]`:``}${t.config&&Object.keys(t.config).length>0?Object.entries(t.config).map(([e,t])=>Array.isArray(t)?`${e} = [${t.map(e=>`"${e}"`).join(`, `)}]`:`${e} = "${t}"`).join(`
|
|
6
|
+
`):``}${t.binaryTargets&&t.binaryTargets.length>0?`
|
|
7
|
+
binaryTargets = [${t.binaryTargets.map(e=>`"${e.value}"`).join(`, `)}]`:``}${t.envPaths?.rootEnvPath||t.envPaths?.schemaEnvPath?`
|
|
8
|
+
env = {${t.envPaths?.rootEnvPath?`
|
|
9
|
+
root = "${t.envPaths.rootEnvPath}"`:``}${t.envPaths?.schemaEnvPath?`
|
|
10
|
+
schema = "${t.envPaths.schemaEnvPath}"`:``}
|
|
11
|
+
}`:``}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
${e}`;return e}async write(){await this.#e.fs.write(this.#e.config.prisma.schema,this.build())}};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return n}});
|
package/dist/types/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`../plugin-pBKbb5K9.cjs`),require(`../prisma-D3KrwikQ.cjs`),require(`../types-a8gm_IaQ.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../plugin-Gb47Xzf6.mjs";import"../prisma-DZZX76mL.mjs";import"../types-CwXe_Ycf.mjs";export{};
|
package/dist/types/plugin.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`../plugin-pBKbb5K9.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../plugin-Gb47Xzf6.mjs";export{};
|
package/dist/types/prisma.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
require(`../prisma-D3KrwikQ.cjs`);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"../prisma-DZZX76mL.mjs";export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-prisma",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A Powerlines plugin to generate project code and a Prisma client from a Prisma schema (PSL).",
|
|
6
6
|
"repository": {
|
|
@@ -39,102 +39,120 @@
|
|
|
39
39
|
"license": "Apache-2.0",
|
|
40
40
|
"private": false,
|
|
41
41
|
"main": "dist/index.cjs",
|
|
42
|
-
"module": "dist/index.
|
|
42
|
+
"module": "dist/index.mjs",
|
|
43
43
|
"exports": {
|
|
44
44
|
"./package.json": "./package.json",
|
|
45
45
|
".": {
|
|
46
|
-
"import": {
|
|
46
|
+
"import": {
|
|
47
|
+
"types": "./dist/index.d.mts",
|
|
48
|
+
"default": "./dist/index.mjs"
|
|
49
|
+
},
|
|
47
50
|
"require": {
|
|
48
51
|
"types": "./dist/index.d.cts",
|
|
49
52
|
"default": "./dist/index.cjs"
|
|
50
53
|
},
|
|
51
|
-
"default": {
|
|
54
|
+
"default": {
|
|
55
|
+
"types": "./dist/index.d.mts",
|
|
56
|
+
"default": "./dist/index.mjs"
|
|
57
|
+
}
|
|
52
58
|
},
|
|
53
59
|
"./index": {
|
|
54
|
-
"import": {
|
|
60
|
+
"import": {
|
|
61
|
+
"types": "./dist/index.d.mts",
|
|
62
|
+
"default": "./dist/index.mjs"
|
|
63
|
+
},
|
|
55
64
|
"require": {
|
|
56
65
|
"types": "./dist/index.d.cts",
|
|
57
66
|
"default": "./dist/index.cjs"
|
|
58
67
|
},
|
|
59
|
-
"default": {
|
|
68
|
+
"default": {
|
|
69
|
+
"types": "./dist/index.d.mts",
|
|
70
|
+
"default": "./dist/index.mjs"
|
|
71
|
+
}
|
|
60
72
|
},
|
|
61
73
|
"./plugin": {
|
|
62
|
-
"import": {
|
|
74
|
+
"import": {
|
|
75
|
+
"types": "./dist/index.d.mts",
|
|
76
|
+
"default": "./dist/index.mjs"
|
|
77
|
+
},
|
|
63
78
|
"require": {
|
|
64
79
|
"types": "./dist/index.d.cts",
|
|
65
80
|
"default": "./dist/index.cjs"
|
|
66
81
|
},
|
|
67
|
-
"default": {
|
|
82
|
+
"default": {
|
|
83
|
+
"types": "./dist/index.d.mts",
|
|
84
|
+
"default": "./dist/index.mjs"
|
|
85
|
+
}
|
|
68
86
|
},
|
|
69
87
|
"./types": {
|
|
70
88
|
"import": {
|
|
71
|
-
"types": "./dist/types/index.d.
|
|
72
|
-
"default": "./dist/types/index.
|
|
89
|
+
"types": "./dist/types/index.d.mts",
|
|
90
|
+
"default": "./dist/types/index.mjs"
|
|
73
91
|
},
|
|
74
92
|
"require": {
|
|
75
93
|
"types": "./dist/types/index.d.cts",
|
|
76
94
|
"default": "./dist/types/index.cjs"
|
|
77
95
|
},
|
|
78
96
|
"default": {
|
|
79
|
-
"types": "./dist/types/index.d.
|
|
80
|
-
"default": "./dist/types/index.
|
|
97
|
+
"types": "./dist/types/index.d.mts",
|
|
98
|
+
"default": "./dist/types/index.mjs"
|
|
81
99
|
}
|
|
82
100
|
},
|
|
83
101
|
"./types/*": {
|
|
84
102
|
"import": {
|
|
85
|
-
"types": "./dist/types/*.d.
|
|
86
|
-
"default": "./dist/types/*.
|
|
103
|
+
"types": "./dist/types/*.d.mts",
|
|
104
|
+
"default": "./dist/types/*.mjs"
|
|
87
105
|
},
|
|
88
106
|
"require": {
|
|
89
107
|
"types": "./dist/types/*.d.cts",
|
|
90
108
|
"default": "./dist/types/*.cjs"
|
|
91
109
|
},
|
|
92
110
|
"default": {
|
|
93
|
-
"types": "./dist/types/*.d.
|
|
94
|
-
"default": "./dist/types/*.
|
|
111
|
+
"types": "./dist/types/*.d.mts",
|
|
112
|
+
"default": "./dist/types/*.mjs"
|
|
95
113
|
}
|
|
96
114
|
},
|
|
97
115
|
"./helpers": {
|
|
98
116
|
"import": {
|
|
99
|
-
"types": "./dist/helpers/index.d.
|
|
100
|
-
"default": "./dist/helpers/index.
|
|
117
|
+
"types": "./dist/helpers/index.d.mts",
|
|
118
|
+
"default": "./dist/helpers/index.mjs"
|
|
101
119
|
},
|
|
102
120
|
"require": {
|
|
103
121
|
"types": "./dist/helpers/index.d.cts",
|
|
104
122
|
"default": "./dist/helpers/index.cjs"
|
|
105
123
|
},
|
|
106
124
|
"default": {
|
|
107
|
-
"types": "./dist/helpers/index.d.
|
|
108
|
-
"default": "./dist/helpers/index.
|
|
125
|
+
"types": "./dist/helpers/index.d.mts",
|
|
126
|
+
"default": "./dist/helpers/index.mjs"
|
|
109
127
|
}
|
|
110
128
|
},
|
|
111
129
|
"./helpers/*": {
|
|
112
130
|
"import": {
|
|
113
|
-
"types": "./dist/helpers/*.d.
|
|
114
|
-
"default": "./dist/helpers/*.
|
|
131
|
+
"types": "./dist/helpers/*.d.mts",
|
|
132
|
+
"default": "./dist/helpers/*.mjs"
|
|
115
133
|
},
|
|
116
134
|
"require": {
|
|
117
135
|
"types": "./dist/helpers/*.d.cts",
|
|
118
136
|
"default": "./dist/helpers/*.cjs"
|
|
119
137
|
},
|
|
120
138
|
"default": {
|
|
121
|
-
"types": "./dist/helpers/*.d.
|
|
122
|
-
"default": "./dist/helpers/*.
|
|
139
|
+
"types": "./dist/helpers/*.d.mts",
|
|
140
|
+
"default": "./dist/helpers/*.mjs"
|
|
123
141
|
}
|
|
124
142
|
}
|
|
125
143
|
},
|
|
126
|
-
"typings": "dist/index.d.
|
|
144
|
+
"typings": "dist/index.d.mts",
|
|
127
145
|
"files": ["dist/**/*"],
|
|
128
146
|
"keywords": ["prisma", "powerlines", "storm-software", "powerlines-plugin"],
|
|
129
147
|
"dependencies": {
|
|
130
|
-
"@stryke/path": "^0.
|
|
131
|
-
"@stryke/fs": "^0.33.
|
|
132
|
-
"@stryke/type-checks": "^0.
|
|
133
|
-
"@stryke/types": "^0.10.
|
|
134
|
-
"@stryke/cli": "^0.12.
|
|
148
|
+
"@stryke/path": "^0.22.0",
|
|
149
|
+
"@stryke/fs": "^0.33.9",
|
|
150
|
+
"@stryke/type-checks": "^0.4.4",
|
|
151
|
+
"@stryke/types": "^0.10.13",
|
|
152
|
+
"@stryke/cli": "^0.12.19",
|
|
135
153
|
"defu": "^6.1.4",
|
|
136
154
|
"jiti": "^2.6.1",
|
|
137
|
-
"powerlines": "^0.
|
|
155
|
+
"powerlines": "^0.29.0",
|
|
138
156
|
"ts-pattern": "^5.9.0",
|
|
139
157
|
"prisma-util": "^2.1.1",
|
|
140
158
|
"@prisma/get-platform": "^6.19.0",
|
|
@@ -142,10 +160,11 @@
|
|
|
142
160
|
"fp-ts": "^2.16.11"
|
|
143
161
|
},
|
|
144
162
|
"devDependencies": {
|
|
145
|
-
"@powerlines/nx": "^0.10.
|
|
146
|
-
"@powerlines/plugin-plugin": "^0.
|
|
163
|
+
"@powerlines/nx": "^0.10.48",
|
|
164
|
+
"@powerlines/plugin-plugin": "^0.12.0",
|
|
165
|
+
"@powerlines/plugin-hey-api": "^0.1.1",
|
|
147
166
|
"@types/node": "^24.10.1"
|
|
148
167
|
},
|
|
149
168
|
"publishConfig": { "access": "public" },
|
|
150
|
-
"gitHead": "
|
|
169
|
+
"gitHead": "f65e5efb5fd5a7f5eab1936aec5a2807b931ae87"
|
|
151
170
|
}
|
package/dist/chunk-FBBMZ4NC.cjs
DELETED
package/dist/chunk-UCUR73HG.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { GetSchemaOptions, PrismaSchema } from '../types/prisma.cjs';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Retrieves the Prisma schema using the provided options.
|
|
5
|
-
*
|
|
6
|
-
* @param options - The options to customize the schema retrieval.
|
|
7
|
-
* @returns The Prisma schema.
|
|
8
|
-
*/
|
|
9
|
-
declare function getSchema(options: GetSchemaOptions): Promise<PrismaSchema>;
|
|
10
|
-
|
|
11
|
-
export { getSchema };
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { GetSchemaOptions, PrismaSchema } from '../types/prisma.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Retrieves the Prisma schema using the provided options.
|
|
5
|
-
*
|
|
6
|
-
* @param options - The options to customize the schema retrieval.
|
|
7
|
-
* @returns The Prisma schema.
|
|
8
|
-
*/
|
|
9
|
-
declare function getSchema(options: GetSchemaOptions): Promise<PrismaSchema>;
|
|
10
|
-
|
|
11
|
-
export { getSchema };
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import {a}from'../chunk-UCUR73HG.js';import {getBinaryTargetForCurrentPlatform}from'@prisma/get-platform';import i from'@prisma/prisma-schema-wasm';import*as t from'fp-ts/Either';import {pipe}from'fp-ts/lib/function';import {match}from'ts-pattern';/*****************************************
|
|
2
|
-
*
|
|
3
|
-
* ⚡ Built by Storm Software
|
|
4
|
-
*
|
|
5
|
-
*****************************************/
|
|
6
|
-
|
|
7
|
-
async function m(a){for(const e of a.binaryTargets){if(e.fromEnvVar&&process.env[e.fromEnvVar]){const r=JSON.parse(process.env[e.fromEnvVar]);Array.isArray(r)?(a.binaryTargets=r.map(o=>({fromEnvVar:null,value:o})),await m(a)):e.value=r;}e.value==="native"&&(e.value=await getBinaryTargetForCurrentPlatform(),e.native=true);}a.binaryTargets.length===0&&(a.binaryTargets=[{fromEnvVar:null,value:await getBinaryTargetForCurrentPlatform(),native:true}]);}a(m,"resolveBinaryTargets");async function G(a){const e=pipe(t.tryCatch(()=>{process.env.FORCE_PANIC_QUERY_ENGINE_GET_CONFIG&&i.debug_panic();const r=JSON.stringify({prismaSchema:a.datamodel,datasourceOverrides:{},ignoreEnvVarErrors:a.ignoreEnvVarErrors??false,env:process.env});return i.get_config(r)},r=>({type:"wasm-error",reason:"(get-config wasm)",error:r})),t.map(r=>({result:r})),t.chainW(({result:r})=>t.tryCatch(()=>JSON.parse(r),o=>({type:"parse-json",reason:"Unable to parse JSON",error:o}))),t.chainW(r=>r.errors.length>0?t.left({type:"validation-error",reason:"(get-config wasm)",error:r.errors}):t.right(r.config)));if(t.isRight(e)){const{right:r}=e;for(const o of r.generators)await m(o);return Promise.resolve(r)}throw match(e.left).with({type:"wasm-error"},r=>new Error(`Prisma get-config Wasm runtime error: ${r.error.message}`)).with({type:"validation-error"},r=>new Error(`Prisma get-config validation error: ${r.error.map(o=>o.message).join(", ")}`)).otherwise(r=>new Error(`Prisma get-config unknown error: ${r.reason} - ${r.error.message}`))}a(G,"getSchema");export{G as getSchema};
|
package/dist/helpers/index.d.cts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export { getSchema } from './get-schema.cjs';
|
|
2
|
-
export { P as PrismaSchemaCreator } from '../index-B-z3Jwl2.cjs';
|
|
3
|
-
import '../types/prisma.cjs';
|
|
4
|
-
import '@storm-software/build-tools/types';
|
|
5
|
-
import '@storm-software/config-tools/types';
|
|
6
|
-
import '@storm-software/config/types';
|
|
7
|
-
import '@stryke/types/base';
|
|
8
|
-
import '@stryke/types/configuration';
|
|
9
|
-
import '@stryke/types/file';
|
|
10
|
-
import 'vite';
|
|
11
|
-
import '@stryke/env/get-env-paths';
|
|
12
|
-
import '@stryke/types/package-json';
|
|
13
|
-
import 'jiti';
|
|
14
|
-
import 'magic-string';
|
|
15
|
-
import 'semver';
|
|
16
|
-
import 'ts-morph';
|
|
17
|
-
import 'unplugin';
|
|
18
|
-
import '@stryke/fs/resolve';
|
|
19
|
-
import '@stryke/types/tsconfig';
|
|
20
|
-
import 'typescript';
|
|
21
|
-
import '@stryke/types/array';
|
|
22
|
-
import 'prisma-util/schema-creator';
|
package/dist/helpers/index.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export { getSchema } from './get-schema.js';
|
|
2
|
-
export { P as PrismaSchemaCreator } from '../index-lx02iWd5.js';
|
|
3
|
-
import '../types/prisma.js';
|
|
4
|
-
import '@storm-software/build-tools/types';
|
|
5
|
-
import '@storm-software/config-tools/types';
|
|
6
|
-
import '@storm-software/config/types';
|
|
7
|
-
import '@stryke/types/base';
|
|
8
|
-
import '@stryke/types/configuration';
|
|
9
|
-
import '@stryke/types/file';
|
|
10
|
-
import 'vite';
|
|
11
|
-
import '@stryke/env/get-env-paths';
|
|
12
|
-
import '@stryke/types/package-json';
|
|
13
|
-
import 'jiti';
|
|
14
|
-
import 'magic-string';
|
|
15
|
-
import 'semver';
|
|
16
|
-
import 'ts-morph';
|
|
17
|
-
import 'unplugin';
|
|
18
|
-
import '@stryke/fs/resolve';
|
|
19
|
-
import '@stryke/types/tsconfig';
|
|
20
|
-
import 'typescript';
|
|
21
|
-
import '@stryke/types/array';
|
|
22
|
-
import 'prisma-util/schema-creator';
|
package/dist/helpers/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export*from'./get-schema';export*from'./schema-creator';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import 'prisma-util/schema-creator';
|
|
2
|
-
export { P as PrismaSchemaCreator } from '../index-B-z3Jwl2.cjs';
|
|
3
|
-
import '../types/prisma.cjs';
|
|
4
|
-
import '@storm-software/build-tools/types';
|
|
5
|
-
import '@storm-software/config-tools/types';
|
|
6
|
-
import '@storm-software/config/types';
|
|
7
|
-
import '@stryke/types/base';
|
|
8
|
-
import '@stryke/types/configuration';
|
|
9
|
-
import '@stryke/types/file';
|
|
10
|
-
import 'vite';
|
|
11
|
-
import '@stryke/env/get-env-paths';
|
|
12
|
-
import '@stryke/types/package-json';
|
|
13
|
-
import 'jiti';
|
|
14
|
-
import 'magic-string';
|
|
15
|
-
import 'semver';
|
|
16
|
-
import 'ts-morph';
|
|
17
|
-
import 'unplugin';
|
|
18
|
-
import '@stryke/fs/resolve';
|
|
19
|
-
import '@stryke/types/tsconfig';
|
|
20
|
-
import 'typescript';
|
|
21
|
-
import '@stryke/types/array';
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import 'prisma-util/schema-creator';
|
|
2
|
-
export { P as PrismaSchemaCreator } from '../index-lx02iWd5.js';
|
|
3
|
-
import '../types/prisma.js';
|
|
4
|
-
import '@storm-software/build-tools/types';
|
|
5
|
-
import '@storm-software/config-tools/types';
|
|
6
|
-
import '@storm-software/config/types';
|
|
7
|
-
import '@stryke/types/base';
|
|
8
|
-
import '@stryke/types/configuration';
|
|
9
|
-
import '@stryke/types/file';
|
|
10
|
-
import 'vite';
|
|
11
|
-
import '@stryke/env/get-env-paths';
|
|
12
|
-
import '@stryke/types/package-json';
|
|
13
|
-
import 'jiti';
|
|
14
|
-
import 'magic-string';
|
|
15
|
-
import 'semver';
|
|
16
|
-
import 'ts-morph';
|
|
17
|
-
import 'unplugin';
|
|
18
|
-
import '@stryke/fs/resolve';
|
|
19
|
-
import '@stryke/types/tsconfig';
|
|
20
|
-
import 'typescript';
|
|
21
|
-
import '@stryke/types/array';
|