@powerlines/plugin-prisma 0.4.136 → 0.4.137

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- require(`./get-schema-BUxb6ANl.cjs`);let e=require(`@stryke/path/find`),t=require(`@prisma/client-generator-ts`),n=require(`@prisma/engines-version`),r=require(`@stryke/convert/buffer-to-string`),i=require(`@stryke/path/replace`),a=require(`@stryke/type-checks/is-buffer`),o=require(`@stryke/type-checks/is-string`);var s=`0.4.135`,c=class{#e;name=`powerlines-client`;constructor(e){this.context=e,this.#e={name:this.name,output:null,config:{},provider:{fromEnvVar:`POWERLINES_CLIENT_PROVIDER`,value:this.name},binaryTargets:[],previewFeatures:this.context.prisma.previewFeatures,sourceFilePath:this.context.prisma.schema.schemaRootDir}}async getManifest(e){return Promise.resolve({defaultOutput:`./generated`,prettyName:`Powerlines Client`,version:s,requiresEngines:[],requiresEngineVersion:n.enginesVersion})}async generate(){let{prismaClientDmmf:e,fileMap:r}=(0,t.buildClient)({datamodel:this.context.prisma.schema.schemas.map(e=>e.content).join(`
1
+ require(`./get-schema-BUxb6ANl.cjs`);let e=require(`@stryke/path/find`),t=require(`@prisma/client-generator-ts`),n=require(`@prisma/engines-version`),r=require(`@stryke/convert/buffer-to-string`),i=require(`@stryke/path/replace`),a=require(`@stryke/type-checks/is-buffer`),o=require(`@stryke/type-checks/is-string`);var s=`0.4.137`,c=class{#e;name=`powerlines-client`;constructor(e){this.context=e,this.#e={name:this.name,output:null,config:{},provider:{fromEnvVar:`POWERLINES_CLIENT_PROVIDER`,value:this.name},binaryTargets:[],previewFeatures:this.context.prisma.previewFeatures,sourceFilePath:this.context.prisma.schema.schemaRootDir}}async getManifest(e){return Promise.resolve({defaultOutput:`./generated`,prettyName:`Powerlines Client`,version:s,requiresEngines:[],requiresEngineVersion:n.enginesVersion})}async generate(){let{prismaClientDmmf:e,fileMap:r}=(0,t.buildClient)({datamodel:this.context.prisma.schema.schemas.map(e=>e.content).join(`
2
2
  `),schemaPath:this.context.prisma.schema.schemaPath,binaryPaths:{},datasources:this.context.prisma.schema.datasources,outputDir:this.context.config.prisma.outputPath,runtimeBase:`@prisma/client/runtime`,dmmf:this.context.prisma.dmmf,generator:this.#e,engineVersion:n.enginesVersion,clientVersion:s,activeProvider:this.context.prisma.schema.primaryDatasource?.activeProvider,typedSql:this.context.prisma.typedSql,target:this.context.config.prisma.runtime,generatedFileExtension:`ts`,importFileExtension:`ts`,moduleFormat:`esm`,tsNoCheckPreamble:!0,compilerBuild:`fast`}),i=[],a={models:`PrismaClient.Prisma.async.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.enum.export.extends.false.finally.for.function.if.implements.import.in.instanceof.interface.let.new.null.package.private.protected.public.return.super.switch.this.throw.true.try.using.typeof.var.void.while.with.yield`.split(`.`),fields:[`AND`,`OR`,`NOT`],dynamic:[]};if(e.datamodel.enums)for(let t of e.datamodel.enums)(a.models.includes(t.name)||a.fields.includes(t.name))&&i.push(Error(`"enum ${t.name}"`));if(e.datamodel.models)for(let t of e.datamodel.models)(a.models.includes(t.name)||a.fields.includes(t.name))&&i.push(Error(`"model ${t.name}"`));if(i.length>0){let e=`Error: The schema at "${this.context.prisma.schema.schemaPath}" contains reserved keywords.\n Rename the following items:`;for(let t of i)e+=`\n - ${t.message}`;throw Error(`${e}\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`)}await this.writeFileMap(r)}stop(){}async writeFileMap(t){return Promise.all(Object.entries(t).map(async([t,n])=>{(0,o.isString)(n)?this.context.emitBuiltinSync(n,`prisma/${(0,i.replaceExtension)(t)}`,{extension:(0,e.findFileExtension)(t)||`ts`}):(0,a.isBuffer)(n)?this.context.emitBuiltinSync((0,r.bufferToString)(n),`prisma/${(0,i.replaceExtension)(t)}`,{extension:(0,e.findFileExtension)(t)||`ts`}):await this.writeFileMap(n)}))}};Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return c}});
@@ -1,2 +1,2 @@
1
- import{findFileExtension as e}from"@stryke/path/find";import{buildClient as t}from"@prisma/client-generator-ts";import{enginesVersion as n}from"@prisma/engines-version";import{bufferToString as r}from"@stryke/convert/buffer-to-string";import{replaceExtension as i}from"@stryke/path/replace";import{isBuffer as a}from"@stryke/type-checks/is-buffer";import{isString as o}from"@stryke/type-checks/is-string";var s=`0.4.135`,c=class{#e;name=`powerlines-client`;constructor(e){this.context=e,this.#e={name:this.name,output:null,config:{},provider:{fromEnvVar:`POWERLINES_CLIENT_PROVIDER`,value:this.name},binaryTargets:[],previewFeatures:this.context.prisma.previewFeatures,sourceFilePath:this.context.prisma.schema.schemaRootDir}}async getManifest(e){return Promise.resolve({defaultOutput:`./generated`,prettyName:`Powerlines Client`,version:s,requiresEngines:[],requiresEngineVersion:n})}async generate(){let{prismaClientDmmf:e,fileMap:r}=t({datamodel:this.context.prisma.schema.schemas.map(e=>e.content).join(`
1
+ import{findFileExtension as e}from"@stryke/path/find";import{buildClient as t}from"@prisma/client-generator-ts";import{enginesVersion as n}from"@prisma/engines-version";import{bufferToString as r}from"@stryke/convert/buffer-to-string";import{replaceExtension as i}from"@stryke/path/replace";import{isBuffer as a}from"@stryke/type-checks/is-buffer";import{isString as o}from"@stryke/type-checks/is-string";var s=`0.4.137`,c=class{#e;name=`powerlines-client`;constructor(e){this.context=e,this.#e={name:this.name,output:null,config:{},provider:{fromEnvVar:`POWERLINES_CLIENT_PROVIDER`,value:this.name},binaryTargets:[],previewFeatures:this.context.prisma.previewFeatures,sourceFilePath:this.context.prisma.schema.schemaRootDir}}async getManifest(e){return Promise.resolve({defaultOutput:`./generated`,prettyName:`Powerlines Client`,version:s,requiresEngines:[],requiresEngineVersion:n})}async generate(){let{prismaClientDmmf:e,fileMap:r}=t({datamodel:this.context.prisma.schema.schemas.map(e=>e.content).join(`
2
2
  `),schemaPath:this.context.prisma.schema.schemaPath,binaryPaths:{},datasources:this.context.prisma.schema.datasources,outputDir:this.context.config.prisma.outputPath,runtimeBase:`@prisma/client/runtime`,dmmf:this.context.prisma.dmmf,generator:this.#e,engineVersion:n,clientVersion:s,activeProvider:this.context.prisma.schema.primaryDatasource?.activeProvider,typedSql:this.context.prisma.typedSql,target:this.context.config.prisma.runtime,generatedFileExtension:`ts`,importFileExtension:`ts`,moduleFormat:`esm`,tsNoCheckPreamble:!0,compilerBuild:`fast`}),i=[],a={models:`PrismaClient.Prisma.async.await.break.case.catch.class.const.continue.debugger.default.delete.do.else.enum.export.extends.false.finally.for.function.if.implements.import.in.instanceof.interface.let.new.null.package.private.protected.public.return.super.switch.this.throw.true.try.using.typeof.var.void.while.with.yield`.split(`.`),fields:[`AND`,`OR`,`NOT`],dynamic:[]};if(e.datamodel.enums)for(let t of e.datamodel.enums)(a.models.includes(t.name)||a.fields.includes(t.name))&&i.push(Error(`"enum ${t.name}"`));if(e.datamodel.models)for(let t of e.datamodel.models)(a.models.includes(t.name)||a.fields.includes(t.name))&&i.push(Error(`"model ${t.name}"`));if(i.length>0){let e=`Error: The schema at "${this.context.prisma.schema.schemaPath}" contains reserved keywords.\n Rename the following items:`;for(let t of i)e+=`\n - ${t.message}`;throw Error(`${e}\nTo learn more about how to rename models, check out https://pris.ly/d/naming-models`)}await this.writeFileMap(r)}stop(){}async writeFileMap(t){return Promise.all(Object.entries(t).map(async([t,n])=>{o(n)?this.context.emitBuiltinSync(n,`prisma/${i(t)}`,{extension:e(t)||`ts`}):a(n)?this.context.emitBuiltinSync(r(n),`prisma/${i(t)}`,{extension:e(t)||`ts`}):await this.writeFileMap(n)}))}};export{c as t};
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../client-generator-5BW_43rC.cjs`);exports.PowerlinesClientGenerator=e.t;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../client-generator-BCGePF_n.cjs`);exports.PowerlinesClientGenerator=e.t;
@@ -1 +1 @@
1
- import{t as e}from"../client-generator-smxGkxQb.mjs";export{e as PowerlinesClientGenerator};
1
+ import{t as e}from"../client-generator-DSbnNWnk.mjs";export{e as PowerlinesClientGenerator};
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../get-schema-BUxb6ANl.cjs`),t=require(`../client-generator-5BW_43rC.cjs`),n=require(`./schema-creator.cjs`),r=require(`./typed-sql.cjs`);exports.PowerlinesClientGenerator=t.t,exports.PrismaSchemaCreator=n.PrismaSchemaCreator,exports.getSchema=e.t,exports.introspectSql=r.introspectSql;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../get-schema-BUxb6ANl.cjs`),t=require(`../client-generator-BCGePF_n.cjs`),n=require(`./schema-creator.cjs`),r=require(`./typed-sql.cjs`);exports.PowerlinesClientGenerator=t.t,exports.PrismaSchemaCreator=n.PrismaSchemaCreator,exports.getSchema=e.t,exports.introspectSql=r.introspectSql;
@@ -1 +1 @@
1
- import{t as e}from"../client-generator-smxGkxQb.mjs";import{getSchema as t}from"./get-schema.mjs";import{PrismaSchemaCreator as n}from"./schema-creator.mjs";import{introspectSql as r}from"./typed-sql.mjs";export{e as PowerlinesClientGenerator,n as PrismaSchemaCreator,t as getSchema,r as introspectSql};
1
+ import{t as e}from"../client-generator-DSbnNWnk.mjs";import{getSchema as t}from"./get-schema.mjs";import{PrismaSchemaCreator as n}from"./schema-creator.mjs";import{introspectSql as r}from"./typed-sql.mjs";export{e as PowerlinesClientGenerator,n as PrismaSchemaCreator,t as getSchema,r as introspectSql};
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./get-schema-BUxb6ANl.cjs`),t=require(`./client-generator-5BW_43rC.cjs`),n=require(`./helpers/schema-creator.cjs`),r=require(`./helpers/typed-sql.cjs`);let i=require(`@powerlines/plugin-pulumi`);i=e.n(i,1);let a=require(`@prisma/client-generator-registry`),o=require(`@prisma/engines`),s=require(`@prisma/internals`),c=require(`@pulumi/prisma-postgres`);c=e.n(c,1);let l=require(`@stryke/convert/to-array`),u=require(`@stryke/path/append`),d=require(`@stryke/path/common`),f=require(`@stryke/path/find`),p=require(`@stryke/path/join-paths`),m=require(`@stryke/string-format/constant-case`),h=require(`@stryke/string-format/kebab-case`),g=require(`defu`);g=e.n(g,1);let _=require(`powerlines/plugin-utils`);const v=(v={})=>[...(0,i.default)(v.pulumi),{name:`prisma`,config(){return{prisma:(0,g.default)(v,{schema:(0,p.joinPaths)(this.config.root,`prisma`,`*.prisma`),configFile:v.configFile||(0,_.getConfigPath)(this,`prisma.config`),runtime:v.runtime||`nodejs`,outputPath:(0,p.joinPaths)(`{builtinPath}`,`prisma`),prismaPostgres:v.prismaPostgres?{projectId:this.config.name,region:`us-east-1`}:void 0})}},async configResolved(){if(this.dependencies[`@prisma/ppg`]=`latest`,this.config.prisma.configFile=(0,_.replacePathTokens)(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=(0,l.toArray)(this.config.prisma.schema).map(e=>(0,_.replacePathTokens)(this,e)),!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=(0,_.replacePathTokens)(this,this.config.prisma.outputPath),this.prisma??={},this.prisma.config=(0,s.validatePrismaConfigWithDatasource)({config:this.config.prisma,cmd:`generate --sql`});let t=(0,u.appendPath)((0,u.appendPath)((0,d.findBasePath)(this.config.prisma.schema),this.config.root),this.config.cwd);this.prisma.schema??={schemaRootDir:t,loadedFromPathForLogMessages:(0,f.relativePath)(this.config.root,t),schemaPath:t,schemas:[],schemaFiles:[],generators:[],datasources:[],warnings:[],primaryDatasource:void 0},this.prisma.schema.schemas=await Promise.all((await this.fs.glob(this.config.prisma.schema.map(e=>e.includes(`*`)||this.fs.isFileSync(e)?e:(0,p.joinPaths)(e,`**/*.prisma`)))).map(async t=>e.t(t))),this.prisma.schema=this.prisma.schema.schemas.reduce((e,t)=>(e.datasources.push(...t.datasources),e.generators.push(...t.generators),e.warnings.push(...t.warnings),e.schemaFiles.push([t.path,t.content]),e),this.prisma.schema),this.prisma.schema.primaryDatasource=this.prisma.schema.datasources.at(0),this.prisma.schema.schemaPath=this.prisma.schema.schemas.at(0).path,this.prisma.builder=new n.PrismaSchemaCreator(this)},async prepare(){await this.prisma.builder.write(),this.prisma.previewFeatures=(0,s.extractPreviewFeatures)(this.prisma.schema.generators),this.prisma.dmmf=await(0,s.getDMMF)({datamodel:this.prisma.schema.schemaFiles,previewFeatures:this.prisma.previewFeatures});let e=await r.introspectSql(this),n=await(0,s.getGenerators)({schemaContext:this.prisma.schema,printDownloadProgress:!0,version:o.enginesVersion,typedSql:e,allowNoModels:!0,registry:a.defaultRegistry.toInternal()});!n||!n.some(e=>[`prisma-client`,`prisma-client-js`,`prisma-client-ts`].includes(e.name||e.getProvider()))?(n??=[],n.push(new t.t(this))):n=n.map(e=>[`prisma-client`,`prisma-client-js`,`prisma-client-ts`].includes(e.name||e.getProvider())?new t.t(this):e);for(let e of n)try{await e.generate(),e.stop()}catch(t){e.stop(),this.error(`Error while generating with ${e.name||e.getProvider()}: ${t instanceof Error?t.message:String(t)}`)}},pulumi:{async deploy(){if(this.config.prisma.prismaPostgres){let e=process.env.PRISMA_SERVICE_TOKEN;if(!e)if(e=v.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.");await this.pulumi.workspace.installPlugin(`registry.terraform.io/prisma/prisma-postgres`,`v0.2.0`);let t=new c.Project(`project`,{name:`${this.config.prisma.prismaPostgres?.projectId||this.config.name}`}),n=new c.Database(`database`,{projectId:t.id,name:`${this.config.prisma.prismaPostgres?.databaseName||`${(0,h.kebabCase)(this.config.name)}.${this.config.mode}.${this.config.prisma.prismaPostgres?.region}`}`,region:`${this.config.prisma.prismaPostgres?.region}`});return{project:t,database:n,connection:new c.Connection(`connection`,{databaseId:n.id,name:`${(0,m.constantCase)(this.config.name)}_API_KEY`})}}return null}}}];exports.default=v,exports.plugin=v;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./get-schema-BUxb6ANl.cjs`),t=require(`./client-generator-BCGePF_n.cjs`),n=require(`./helpers/schema-creator.cjs`),r=require(`./helpers/typed-sql.cjs`);let i=require(`@powerlines/plugin-pulumi`);i=e.n(i,1);let a=require(`@prisma/client-generator-registry`),o=require(`@prisma/engines`),s=require(`@prisma/internals`),c=require(`@pulumi/prisma-postgres`);c=e.n(c,1);let l=require(`@stryke/convert/to-array`),u=require(`@stryke/path/append`),d=require(`@stryke/path/common`),f=require(`@stryke/path/find`),p=require(`@stryke/path/join-paths`),m=require(`@stryke/string-format/constant-case`),h=require(`@stryke/string-format/kebab-case`),g=require(`defu`);g=e.n(g,1);let _=require(`powerlines/plugin-utils`);const v=(v={})=>[...(0,i.default)(v.pulumi),{name:`prisma`,config(){return{prisma:(0,g.default)(v,{schema:(0,p.joinPaths)(this.config.root,`prisma`,`*.prisma`),configFile:v.configFile||(0,_.getConfigPath)(this,`prisma.config`),runtime:v.runtime||`nodejs`,outputPath:(0,p.joinPaths)(`{builtinPath}`,`prisma`),prismaPostgres:v.prismaPostgres?{projectId:this.config.name,region:`us-east-1`}:void 0})}},async configResolved(){if(this.dependencies[`@prisma/ppg`]=`latest`,this.config.prisma.configFile=(0,_.replacePathTokens)(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=(0,l.toArray)(this.config.prisma.schema).map(e=>(0,_.replacePathTokens)(this,e)),!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=(0,_.replacePathTokens)(this,this.config.prisma.outputPath),this.prisma??={},this.prisma.config=(0,s.validatePrismaConfigWithDatasource)({config:this.config.prisma,cmd:`generate --sql`});let t=(0,u.appendPath)((0,u.appendPath)((0,d.findBasePath)(this.config.prisma.schema),this.config.root),this.config.cwd);this.prisma.schema??={schemaRootDir:t,loadedFromPathForLogMessages:(0,f.relativePath)(this.config.root,t),schemaPath:t,schemas:[],schemaFiles:[],generators:[],datasources:[],warnings:[],primaryDatasource:void 0},this.prisma.schema.schemas=await Promise.all((await this.fs.glob(this.config.prisma.schema.map(e=>e.includes(`*`)||this.fs.isFileSync(e)?e:(0,p.joinPaths)(e,`**/*.prisma`)))).map(async t=>e.t(t))),this.prisma.schema=this.prisma.schema.schemas.reduce((e,t)=>(e.datasources.push(...t.datasources),e.generators.push(...t.generators),e.warnings.push(...t.warnings),e.schemaFiles.push([t.path,t.content]),e),this.prisma.schema),this.prisma.schema.primaryDatasource=this.prisma.schema.datasources.at(0),this.prisma.schema.schemaPath=this.prisma.schema.schemas.at(0).path,this.prisma.builder=new n.PrismaSchemaCreator(this)},async prepare(){await this.prisma.builder.write(),this.prisma.previewFeatures=(0,s.extractPreviewFeatures)(this.prisma.schema.generators),this.prisma.dmmf=await(0,s.getDMMF)({datamodel:this.prisma.schema.schemaFiles,previewFeatures:this.prisma.previewFeatures});let e=await r.introspectSql(this),n=await(0,s.getGenerators)({schemaContext:this.prisma.schema,printDownloadProgress:!0,version:o.enginesVersion,typedSql:e,allowNoModels:!0,registry:a.defaultRegistry.toInternal()});!n||!n.some(e=>[`prisma-client`,`prisma-client-js`,`prisma-client-ts`].includes(e.name||e.getProvider()))?(n??=[],n.push(new t.t(this))):n=n.map(e=>[`prisma-client`,`prisma-client-js`,`prisma-client-ts`].includes(e.name||e.getProvider())?new t.t(this):e);for(let e of n)try{await e.generate(),e.stop()}catch(t){e.stop(),this.error(`Error while generating with ${e.name||e.getProvider()}: ${t instanceof Error?t.message:String(t)}`)}},pulumi:{async deploy(){if(this.config.prisma.prismaPostgres){let e=process.env.PRISMA_SERVICE_TOKEN;if(!e)if(e=v.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.");await this.pulumi.workspace.installPlugin(`registry.terraform.io/prisma/prisma-postgres`,`v0.2.0`);let t=new c.Project(`project`,{name:`${this.config.prisma.prismaPostgres?.projectId||this.config.name}`}),n=new c.Database(`database`,{projectId:t.id,name:`${this.config.prisma.prismaPostgres?.databaseName||`${(0,h.kebabCase)(this.config.name)}.${this.config.mode}.${this.config.prisma.prismaPostgres?.region}`}`,region:`${this.config.prisma.prismaPostgres?.region}`});return{project:t,database:n,connection:new c.Connection(`connection`,{databaseId:n.id,name:`${(0,m.constantCase)(this.config.name)}_API_KEY`})}}return null}}}];exports.default=v,exports.plugin=v;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{t as e}from"./client-generator-smxGkxQb.mjs";import{getSchema as t}from"./helpers/get-schema.mjs";import{PrismaSchemaCreator as n}from"./helpers/schema-creator.mjs";import{introspectSql as r}from"./helpers/typed-sql.mjs";import i from"@powerlines/plugin-pulumi";import{defaultRegistry as a}from"@prisma/client-generator-registry";import{enginesVersion as o}from"@prisma/engines";import{extractPreviewFeatures as s,getDMMF as c,getGenerators as l,validatePrismaConfigWithDatasource as u}from"@prisma/internals";import*as d from"@pulumi/prisma-postgres";import{toArray as f}from"@stryke/convert/to-array";import{appendPath as p}from"@stryke/path/append";import{findBasePath as m}from"@stryke/path/common";import{relativePath as h}from"@stryke/path/find";import{joinPaths as g}from"@stryke/path/join-paths";import{constantCase as _}from"@stryke/string-format/constant-case";import{kebabCase as v}from"@stryke/string-format/kebab-case";import y from"defu";import{getConfigPath as b,replacePathTokens as x}from"powerlines/plugin-utils";const S=(S={})=>[...i(S.pulumi),{name:`prisma`,config(){return{prisma:y(S,{schema:g(this.config.root,`prisma`,`*.prisma`),configFile:S.configFile||b(this,`prisma.config`),runtime:S.runtime||`nodejs`,outputPath:g(`{builtinPath}`,`prisma`),prismaPostgres:S.prismaPostgres?{projectId:this.config.name,region:`us-east-1`}:void 0})}},async configResolved(){if(this.dependencies[`@prisma/ppg`]=`latest`,this.config.prisma.configFile=x(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.config.prisma.schema).map(e=>x(this,e)),!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=x(this,this.config.prisma.outputPath),this.prisma??={},this.prisma.config=u({config:this.config.prisma,cmd:`generate --sql`});let e=p(p(m(this.config.prisma.schema),this.config.root),this.config.cwd);this.prisma.schema??={schemaRootDir:e,loadedFromPathForLogMessages:h(this.config.root,e),schemaPath:e,schemas:[],schemaFiles:[],generators:[],datasources:[],warnings:[],primaryDatasource:void 0},this.prisma.schema.schemas=await Promise.all((await this.fs.glob(this.config.prisma.schema.map(e=>e.includes(`*`)||this.fs.isFileSync(e)?e:g(e,`**/*.prisma`)))).map(async e=>t(e))),this.prisma.schema=this.prisma.schema.schemas.reduce((e,t)=>(e.datasources.push(...t.datasources),e.generators.push(...t.generators),e.warnings.push(...t.warnings),e.schemaFiles.push([t.path,t.content]),e),this.prisma.schema),this.prisma.schema.primaryDatasource=this.prisma.schema.datasources.at(0),this.prisma.schema.schemaPath=this.prisma.schema.schemas.at(0).path,this.prisma.builder=new n(this)},async prepare(){await this.prisma.builder.write(),this.prisma.previewFeatures=s(this.prisma.schema.generators),this.prisma.dmmf=await c({datamodel:this.prisma.schema.schemaFiles,previewFeatures:this.prisma.previewFeatures});let t=await r(this),n=await l({schemaContext:this.prisma.schema,printDownloadProgress:!0,version:o,typedSql:t,allowNoModels:!0,registry:a.toInternal()});!n||!n.some(e=>[`prisma-client`,`prisma-client-js`,`prisma-client-ts`].includes(e.name||e.getProvider()))?(n??=[],n.push(new e(this))):n=n.map(t=>[`prisma-client`,`prisma-client-js`,`prisma-client-ts`].includes(t.name||t.getProvider())?new e(this):t);for(let e of n)try{await e.generate(),e.stop()}catch(t){e.stop(),this.error(`Error while generating with ${e.name||e.getProvider()}: ${t instanceof Error?t.message:String(t)}`)}},pulumi:{async deploy(){if(this.config.prisma.prismaPostgres){let e=process.env.PRISMA_SERVICE_TOKEN;if(!e)if(e=S.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.");await this.pulumi.workspace.installPlugin(`registry.terraform.io/prisma/prisma-postgres`,`v0.2.0`);let t=new d.Project(`project`,{name:`${this.config.prisma.prismaPostgres?.projectId||this.config.name}`}),n=new d.Database(`database`,{projectId:t.id,name:`${this.config.prisma.prismaPostgres?.databaseName||`${v(this.config.name)}.${this.config.mode}.${this.config.prisma.prismaPostgres?.region}`}`,region:`${this.config.prisma.prismaPostgres?.region}`});return{project:t,database:n,connection:new d.Connection(`connection`,{databaseId:n.id,name:`${_(this.config.name)}_API_KEY`})}}return null}}}];export{S as default,S as plugin};
1
+ import{t as e}from"./client-generator-DSbnNWnk.mjs";import{getSchema as t}from"./helpers/get-schema.mjs";import{PrismaSchemaCreator as n}from"./helpers/schema-creator.mjs";import{introspectSql as r}from"./helpers/typed-sql.mjs";import i from"@powerlines/plugin-pulumi";import{defaultRegistry as a}from"@prisma/client-generator-registry";import{enginesVersion as o}from"@prisma/engines";import{extractPreviewFeatures as s,getDMMF as c,getGenerators as l,validatePrismaConfigWithDatasource as u}from"@prisma/internals";import*as d from"@pulumi/prisma-postgres";import{toArray as f}from"@stryke/convert/to-array";import{appendPath as p}from"@stryke/path/append";import{findBasePath as m}from"@stryke/path/common";import{relativePath as h}from"@stryke/path/find";import{joinPaths as g}from"@stryke/path/join-paths";import{constantCase as _}from"@stryke/string-format/constant-case";import{kebabCase as v}from"@stryke/string-format/kebab-case";import y from"defu";import{getConfigPath as b,replacePathTokens as x}from"powerlines/plugin-utils";const S=(S={})=>[...i(S.pulumi),{name:`prisma`,config(){return{prisma:y(S,{schema:g(this.config.root,`prisma`,`*.prisma`),configFile:S.configFile||b(this,`prisma.config`),runtime:S.runtime||`nodejs`,outputPath:g(`{builtinPath}`,`prisma`),prismaPostgres:S.prismaPostgres?{projectId:this.config.name,region:`us-east-1`}:void 0})}},async configResolved(){if(this.dependencies[`@prisma/ppg`]=`latest`,this.config.prisma.configFile=x(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.config.prisma.schema).map(e=>x(this,e)),!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=x(this,this.config.prisma.outputPath),this.prisma??={},this.prisma.config=u({config:this.config.prisma,cmd:`generate --sql`});let e=p(p(m(this.config.prisma.schema),this.config.root),this.config.cwd);this.prisma.schema??={schemaRootDir:e,loadedFromPathForLogMessages:h(this.config.root,e),schemaPath:e,schemas:[],schemaFiles:[],generators:[],datasources:[],warnings:[],primaryDatasource:void 0},this.prisma.schema.schemas=await Promise.all((await this.fs.glob(this.config.prisma.schema.map(e=>e.includes(`*`)||this.fs.isFileSync(e)?e:g(e,`**/*.prisma`)))).map(async e=>t(e))),this.prisma.schema=this.prisma.schema.schemas.reduce((e,t)=>(e.datasources.push(...t.datasources),e.generators.push(...t.generators),e.warnings.push(...t.warnings),e.schemaFiles.push([t.path,t.content]),e),this.prisma.schema),this.prisma.schema.primaryDatasource=this.prisma.schema.datasources.at(0),this.prisma.schema.schemaPath=this.prisma.schema.schemas.at(0).path,this.prisma.builder=new n(this)},async prepare(){await this.prisma.builder.write(),this.prisma.previewFeatures=s(this.prisma.schema.generators),this.prisma.dmmf=await c({datamodel:this.prisma.schema.schemaFiles,previewFeatures:this.prisma.previewFeatures});let t=await r(this),n=await l({schemaContext:this.prisma.schema,printDownloadProgress:!0,version:o,typedSql:t,allowNoModels:!0,registry:a.toInternal()});!n||!n.some(e=>[`prisma-client`,`prisma-client-js`,`prisma-client-ts`].includes(e.name||e.getProvider()))?(n??=[],n.push(new e(this))):n=n.map(t=>[`prisma-client`,`prisma-client-js`,`prisma-client-ts`].includes(t.name||t.getProvider())?new e(this):t);for(let e of n)try{await e.generate(),e.stop()}catch(t){e.stop(),this.error(`Error while generating with ${e.name||e.getProvider()}: ${t instanceof Error?t.message:String(t)}`)}},pulumi:{async deploy(){if(this.config.prisma.prismaPostgres){let e=process.env.PRISMA_SERVICE_TOKEN;if(!e)if(e=S.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.");await this.pulumi.workspace.installPlugin(`registry.terraform.io/prisma/prisma-postgres`,`v0.2.0`);let t=new d.Project(`project`,{name:`${this.config.prisma.prismaPostgres?.projectId||this.config.name}`}),n=new d.Database(`database`,{projectId:t.id,name:`${this.config.prisma.prismaPostgres?.databaseName||`${v(this.config.name)}.${this.config.mode}.${this.config.prisma.prismaPostgres?.region}`}`,region:`${this.config.prisma.prismaPostgres?.region}`});return{project:t,database:n,connection:new d.Connection(`connection`,{databaseId:n.id,name:`${_(this.config.name)}_API_KEY`})}}return null}}}];export{S as default,S as plugin};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-prisma",
3
- "version": "0.4.136",
3
+ "version": "0.4.137",
4
4
  "private": false,
5
5
  "description": "A Powerlines plugin to generate project code and a Prisma client from a Prisma schema (PSL).",
6
6
  "keywords": ["prisma", "powerlines", "storm-software", "powerlines-plugin"],
@@ -174,7 +174,7 @@
174
174
  "typings": "dist/index.d.mts",
175
175
  "files": ["dist/**/*"],
176
176
  "dependencies": {
177
- "@powerlines/plugin-pulumi": "^0.6.95",
177
+ "@powerlines/plugin-pulumi": "^0.6.96",
178
178
  "@prisma/client-generator-registry": "7.6.0",
179
179
  "@prisma/config": "7.6.0",
180
180
  "@prisma/dmmf": "7.6.0",
@@ -192,16 +192,16 @@
192
192
  "defu": "^6.1.7",
193
193
  "fp-ts": "^2.16.11",
194
194
  "jiti": "^2.6.1",
195
- "powerlines": "^0.46.1",
195
+ "powerlines": "^0.46.2",
196
196
  "prisma-util": "^2.1.1",
197
197
  "ts-pattern": "^5.9.0"
198
198
  },
199
199
  "devDependencies": {
200
- "@powerlines/plugin-plugin": "^0.12.405",
200
+ "@powerlines/plugin-plugin": "^0.12.406",
201
201
  "@prisma/client-generator-ts": "7.6.0",
202
202
  "@pulumi/pulumi": "^3.233.0",
203
203
  "@types/node": "^25.6.0"
204
204
  },
205
205
  "publishConfig": { "access": "public" },
206
- "gitHead": "de70be13e6fd973ea0b1c56b8915223dcfb4a708"
206
+ "gitHead": "e2eca169a851d2b144bfc7c677e7047cedf4b6a0"
207
207
  }