@powerlines/plugin-prisma 0.3.0 → 0.4.0

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.
Files changed (57) hide show
  1. package/dist/api/client/client.gen.mjs.map +1 -1
  2. package/dist/api/client/types.gen.d.cts.map +1 -1
  3. package/dist/api/client/utils.gen.mjs.map +1 -1
  4. package/dist/api/client.gen.cjs +0 -8
  5. package/dist/api/client.gen.mjs +0 -8
  6. package/dist/api/client.gen.mjs.map +1 -1
  7. package/dist/api/core/auth.gen.mjs.map +1 -1
  8. package/dist/api/core/bodySerializer.gen.mjs.map +1 -1
  9. package/dist/api/core/params.gen.mjs.map +1 -1
  10. package/dist/api/core/pathSerializer.gen.d.cts.map +1 -1
  11. package/dist/api/core/pathSerializer.gen.mjs.map +1 -1
  12. package/dist/api/core/queryKeySerializer.gen.cjs +0 -3
  13. package/dist/api/core/queryKeySerializer.gen.d.cts.map +1 -1
  14. package/dist/api/core/queryKeySerializer.gen.mjs +0 -3
  15. package/dist/api/core/queryKeySerializer.gen.mjs.map +1 -1
  16. package/dist/api/core/serverSentEvents.gen.mjs.map +1 -1
  17. package/dist/api/core/utils.gen.mjs.map +1 -1
  18. package/dist/api/sdk.gen.cjs +1 -0
  19. package/dist/api/sdk.gen.mjs +1 -0
  20. package/dist/api/sdk.gen.mjs.map +1 -1
  21. package/dist/helpers/get-schema.mjs.map +1 -1
  22. package/dist/helpers/index.cjs +1 -1
  23. package/dist/helpers/index.mjs +1 -1
  24. package/dist/helpers/prisma-postgres.d.cts +1 -51
  25. package/dist/helpers/prisma-postgres.d.mts +1 -51
  26. package/dist/helpers/prisma-postgres.mjs.map +1 -1
  27. package/dist/helpers/schema-creator.mjs.map +1 -1
  28. package/dist/index.cjs +19 -13
  29. package/dist/index.d.cts +3 -6
  30. package/dist/index.d.cts.map +1 -1
  31. package/dist/index.d.mts +3 -6
  32. package/dist/index.d.mts.map +1 -1
  33. package/dist/index.mjs +18 -11
  34. package/dist/index.mjs.map +1 -1
  35. package/dist/node_modules/.pnpm/{@stryke_string-format@0.14.8 → @stryke_string-format@0.16.0}/node_modules/@stryke/string-format/dist/get-words.cjs +1 -1
  36. package/dist/node_modules/.pnpm/{@stryke_string-format@0.14.8 → @stryke_string-format@0.16.0}/node_modules/@stryke/string-format/dist/get-words.mjs +1 -1
  37. package/dist/node_modules/.pnpm/{@stryke_string-format@0.14.8 → @stryke_string-format@0.16.0}/node_modules/@stryke/string-format/dist/get-words.mjs.map +1 -1
  38. package/dist/node_modules/.pnpm/{@stryke_string-format@0.14.8 → @stryke_string-format@0.16.0}/node_modules/@stryke/string-format/dist/kebab-case.cjs +1 -1
  39. package/dist/node_modules/.pnpm/{@stryke_string-format@0.14.8 → @stryke_string-format@0.16.0}/node_modules/@stryke/string-format/dist/kebab-case.mjs +1 -1
  40. package/dist/node_modules/.pnpm/{@stryke_string-format@0.14.8 → @stryke_string-format@0.16.0}/node_modules/@stryke/string-format/dist/kebab-case.mjs.map +1 -1
  41. package/dist/types/plugin.d.cts +8 -6
  42. package/dist/types/plugin.d.cts.map +1 -1
  43. package/dist/types/plugin.d.mts +8 -6
  44. package/dist/types/plugin.d.mts.map +1 -1
  45. package/dist/types/prisma.d.mts.map +1 -1
  46. package/package.json +6 -36
  47. package/dist/components/index.cjs +0 -3
  48. package/dist/components/index.d.cts +0 -2
  49. package/dist/components/index.d.mts +0 -2
  50. package/dist/components/index.mjs +0 -3
  51. package/dist/components/infrastructure-file.cjs +0 -76
  52. package/dist/components/infrastructure-file.d.cts +0 -13
  53. package/dist/components/infrastructure-file.d.cts.map +0 -1
  54. package/dist/components/infrastructure-file.d.mts +0 -13
  55. package/dist/components/infrastructure-file.d.mts.map +0 -1
  56. package/dist/components/infrastructure-file.mjs +0 -75
  57. package/dist/components/infrastructure-file.mjs.map +0 -1
package/dist/index.mjs CHANGED
@@ -1,17 +1,14 @@
1
- import { PrismaSchemaCreator } from "./helpers/schema-creator.mjs";
1
+ import { kebabCase } from "./node_modules/.pnpm/@stryke_string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.mjs";
2
2
  import { getSchema } from "./helpers/get-schema.mjs";
3
- import { PrismaPostgresInfrastructureFile } from "./components/infrastructure-file.mjs";
4
- import { client } from "./api/client.gen.mjs";
5
- import { PrismaClient } from "./api/sdk.gen.mjs";
6
- import { createComponent } from "@alloy-js/core/jsx-runtime";
7
- import defu from "defu";
8
- import { render } from "@powerlines/plugin-alloy/render";
3
+ import { PrismaSchemaCreator } from "./helpers/schema-creator.mjs";
4
+ import * as prismaPostgres from "@pulumi/prisma-postgres";
9
5
  import { execute, executePackage } from "@stryke/cli/execute";
10
6
  import { existsSync } from "@stryke/fs/exists";
11
7
  import { joinPaths } from "@stryke/path/join-paths";
8
+ import defu from "defu";
12
9
  import { getConfigPath, replacePathTokens } from "powerlines/plugin-utils";
13
10
 
14
- //#region src/index.tsx
11
+ //#region src/index.ts
15
12
  /**
16
13
  * A Powerlines plugin to integrate Prisma for code generation.
17
14
  *
@@ -84,9 +81,8 @@ const plugin = (options = {}) => {
84
81
  const result = await execute(args.join(" "), this.config.root);
85
82
  if (result.failed) throw new Error(`Prisma process exited with code ${result.exitCode}.`);
86
83
  }
87
- if (this.config.prisma.prismaPostgres) await render(this, createComponent(PrismaPostgresInfrastructureFile, {}));
88
84
  },
89
- async deploy() {
85
+ async deployPulumi() {
90
86
  if (this.config.prisma.prismaPostgres) {
91
87
  let serviceToken = process.env.PRISMA_SERVICE_TOKEN;
92
88
  if (!serviceToken) {
@@ -94,6 +90,17 @@ const plugin = (options = {}) => {
94
90
  if (serviceToken) 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.");
95
91
  else throw new Error("Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.");
96
92
  }
93
+ await this.pulumi.workspace.installPlugin("registry.terraform.io/prisma/prisma-postgres", "v0.2.0");
94
+ const project = new prismaPostgres.Project("project", { name: `${this.config.prisma.prismaPostgres?.projectId || this.config.name}` });
95
+ const database = new prismaPostgres.Database("database", {
96
+ projectId: project.id,
97
+ name: `${this.config.prisma.prismaPostgres?.databaseName || `${kebabCase(this.config.name)}.${this.config.mode}.${this.config.prisma.prismaPostgres?.region}`}`,
98
+ region: `${this.config.prisma.prismaPostgres?.region}`
99
+ });
100
+ new prismaPostgres.Connection("connection", {
101
+ databaseId: database.id,
102
+ name: `${kebabCase(this.config.name)}-api-key`
103
+ });
97
104
  }
98
105
  }
99
106
  };
@@ -101,5 +108,5 @@ const plugin = (options = {}) => {
101
108
  var src_default = plugin;
102
109
 
103
110
  //#endregion
104
- export { PrismaClient, client, src_default as default, plugin };
111
+ export { src_default as default, plugin };
105
112
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["render","execute","executePackage","existsSync","joinPaths","defu","getConfigPath","replacePathTokens","PrismaPostgresInfrastructureFile","getSchema","PrismaSchemaCreator","plugin","options","name","config","prisma","schema","root","configFile","outputPath","prismaPostgres","projectId","region","undefined","configResolved","dependencies","Error","generators","datasources","warnings","datamodel","generator","find","gen","provider","value","push","fromEnvVar","output","binaryTargets","previewFeatures","sourceFilePath","builder","prepare","write","args","prismaPath","unshift","result","workspaceConfig","workspaceRoot","failed","exitCode","join","_$createComponent","deploy","serviceToken","process","env","PRISMA_SERVICE_TOKEN","warn"],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { execute, executePackage } from \"@stryke/cli/execute\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { getConfigPath, replacePathTokens } from \"powerlines/plugin-utils\";\nimport { PrismaPostgresInfrastructureFile } from \"./components/infrastructure-file\";\nimport { getSchema } from \"./helpers/get-schema\";\nimport { PrismaSchemaCreator } from \"./helpers/schema-creator\";\nimport {\n PrismaPluginContext,\n PrismaPluginOptions,\n PrismaPluginUserConfig\n} from \"./types/plugin\";\n\nexport * from \"./api/client.gen\";\nexport * from \"./api/sdk.gen\";\nexport * from \"./api/types.gen\";\nexport * from \"./types\";\n\ndeclare module \"@powerlines/core\" {\n interface BaseConfig {\n prisma?: PrismaPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to integrate Prisma for code generation.\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends PrismaPluginContext = PrismaPluginContext\n>(\n options: PrismaPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"prisma\",\n config() {\n return {\n prisma: defu(options, {\n schema: joinPaths(this.config.root, \"prisma\", \"schema.prisma\"),\n configFile:\n options.configFile || getConfigPath(this, \"prisma.config\"),\n outputPath: joinPaths(\"{builtinPath}\", \"prisma\"),\n prismaPostgres: options?.prismaPostgres\n ? {\n projectId: this.config.name,\n region: \"us-east-1\"\n }\n : undefined\n })\n } as Partial<PrismaPluginUserConfig>;\n },\n async configResolved() {\n this.dependencies[\"@prisma/ppg\"] = \"latest\";\n\n this.config.prisma.configFile = replacePathTokens(\n this,\n this.config.prisma.configFile\n );\n\n if (!this.config.prisma.schema) {\n throw new Error(\n `Prisma schema path is not defined. Please specify a valid path in the plugin configuration.`\n );\n }\n\n this.config.prisma.schema = replacePathTokens(\n this,\n this.config.prisma.schema\n );\n\n if (!this.config.prisma.outputPath) {\n throw new Error(\n `Prisma generated path is not defined. Please specify a valid path in the plugin configuration.`\n );\n }\n\n this.config.prisma.outputPath = replacePathTokens(\n this,\n this.config.prisma.outputPath\n );\n\n this.prisma ??= {} as TContext[\"prisma\"];\n if (!existsSync(this.config.prisma.schema)) {\n this.prisma.schema ??= {\n generators: [],\n datasources: [],\n warnings: []\n };\n } else {\n this.prisma.schema = await getSchema({\n datamodel: this.config.prisma.schema\n });\n }\n\n const generator = this.prisma.schema.generators.find(\n gen => gen.provider.value === \"prisma-client\"\n );\n if (!generator) {\n this.prisma.schema.generators.push({\n name: \"prisma-client\",\n provider: {\n value: \"prisma-client\",\n fromEnvVar: null\n },\n output: {\n value: this.config.prisma.outputPath,\n fromEnvVar: null\n },\n config: {},\n binaryTargets: [],\n previewFeatures: [],\n sourceFilePath: this.config.prisma.schema\n });\n } else {\n generator.output ??= {\n value: this.config.prisma.outputPath,\n fromEnvVar: null\n };\n }\n\n this.prisma.builder = new PrismaSchemaCreator(this);\n },\n async prepare() {\n // Write the schema file before invoking Prisma - Generate\n await this.prisma.builder.write();\n\n const args = [\"generate\", \"--schema\", this.config.prisma.schema];\n if (!this.config.prisma.prismaPath) {\n args.unshift(this.config.root);\n\n const result = await executePackage(\n \"prisma\",\n args,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n if (result.failed) {\n throw new Error(\n `Prisma process exited with code ${result.exitCode}.`\n );\n }\n } else {\n args.unshift(this.config.prisma.prismaPath);\n\n const result = await execute(args.join(\" \"), this.config.root);\n if (result.failed) {\n throw new Error(\n `Prisma process exited with code ${result.exitCode}.`\n );\n }\n }\n\n if (this.config.prisma.prismaPostgres) {\n await render(this, <PrismaPostgresInfrastructureFile />);\n }\n },\n async deploy() {\n if (this.config.prisma.prismaPostgres) {\n let serviceToken = process.env.PRISMA_SERVICE_TOKEN;\n if (!serviceToken) {\n serviceToken = options.serviceToken;\n if (serviceToken) {\n this.warn(\n \"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.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.\"\n );\n }\n }\n\n // const client = createClient(\n // createConfig<ClientOptions>({\n // baseUrl: \"https://api.prisma.io\",\n // throwOnError: true,\n // headers: {\n // Authorization: `Bearer ${serviceToken}`,\n // \"User-Agent\": \"powerlines/1.0\"\n // }\n // })\n // );\n\n // this.prisma.api = new PrismaClient({\n // client\n // });\n\n // await this.prisma.api\n // .createDatabase({\n // body: {\n // isDefault: false,\n // name:\n // this.config.prisma.prismaPostgres.databaseName ||\n // `${this.config.prisma.prismaPostgres.region}.${this.config.mode}.${this.config.name}`,\n // projectId: this.config.prisma.prismaPostgres.projectId,\n // region: this.config.prisma.prismaPostgres.region\n // }\n // } as Options<CreateDatabaseData>)\n // .then(response => response.data?.data);\n }\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmDA,MAAaW,UAGXC,UAA+B,EAAE,KACZ;AACrB,QAAO;EACLC,MAAM;EACNC,SAAS;AACP,UAAO,EACLC,QAAQV,KAAKO,SAAS;IACpBI,QAAQZ,UAAU,KAAKU,OAAOG,MAAM,UAAU,gBAAgB;IAC9DC,YACEN,QAAQM,cAAcZ,cAAc,MAAM,gBAAgB;IAC5Da,YAAYf,UAAU,iBAAiB,SAAS;IAChDgB,gBAAgBR,SAASQ,iBACrB;KACEC,WAAW,KAAKP,OAAOD;KACvBS,QAAQ;KACT,GACDC;IACL,CAAA,EACF;;EAEH,MAAMC,iBAAiB;AACrB,QAAKC,aAAa,iBAAiB;AAEnC,QAAKX,OAAOC,OAAOG,aAAaX,kBAC9B,MACA,KAAKO,OAAOC,OAAOG,WACpB;AAED,OAAI,CAAC,KAAKJ,OAAOC,OAAOC,OACtB,OAAM,IAAIU,MACR,8FACD;AAGH,QAAKZ,OAAOC,OAAOC,SAAST,kBAC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U,KAAK6C,gBAAgBC,eAAe,KAAKpC,OAAOG,KAC5D,CAAC;AACD,QAAI+B,OAAOG,OACT,OAAM,IAAIzB,MACR,mCAAmCsB,OAAOI,SAAQ,GACnD;UAEE;AACLP,SAAKE,QAAQ,KAAKjC,OAAOC,OAAO+B,WAAW;IAE3C,MAAME,SAAS,MAAM/C,QAAQ4C,KAAKQ,KAAK,IAAI,EAAE,KAAKvC,OAAOG,KAAK;AAC9D,QAAI+B,OAAOG,OACT,OAAM,IAAIzB,MACR,mCAAmCsB,OAAOI,SAAQ,GACnD;;AAIL,OAAI,KAAKtC,OAAOC,OAAOK,eACrB,OAAMpB,OAAO,MAAIsD,gBAAG9C,kCAAgC,EAAA,CAAG,CAAC;;EAG5D,MAAM+C,SAAS;AACb,OAAI,KAAKzC,OAAOC,OAAOK,gBAAgB;IACrC,IAAIoC,eAAeC,QAAQC,IAAIC;AAC/B,QAAI,CAACH,cAAc;AACjBA,oBAAe5C,QAAQ4C;AACvB,SAAIA,aACF,MAAKI,KACH,4NACD;SAED,OAAM,IAAIlC,MACR,4GACD;;;;EAiCV;;AAGH,kBAAef"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport * as prismaPostgres from \"@pulumi/prisma-postgres\";\nimport { execute, executePackage } from \"@stryke/cli/execute\";\nimport { existsSync } from \"@stryke/fs/exists\";\nimport { joinPaths } from \"@stryke/path/join-paths\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { getConfigPath, replacePathTokens } from \"powerlines/plugin-utils\";\nimport { getSchema } from \"./helpers/get-schema\";\nimport { PrismaSchemaCreator } from \"./helpers/schema-creator\";\nimport {\n PrismaPluginContext,\n PrismaPluginOptions,\n PrismaPluginUserConfig\n} from \"./types/plugin\";\n\nexport type * from \"./types\";\n\ndeclare module \"powerlines\" {\n interface Config {\n prisma?: PrismaPluginOptions;\n }\n}\n\n/**\n * A Powerlines plugin to integrate Prisma for code generation.\n *\n * @param options - The plugin options.\n * @returns A Powerlines plugin instance.\n */\nexport const plugin = <\n TContext extends PrismaPluginContext = PrismaPluginContext\n>(\n options: PrismaPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"prisma\",\n config() {\n return {\n prisma: defu(options, {\n schema: joinPaths(this.config.root, \"prisma\", \"schema.prisma\"),\n configFile:\n options.configFile || getConfigPath(this, \"prisma.config\"),\n outputPath: joinPaths(\"{builtinPath}\", \"prisma\"),\n prismaPostgres: options?.prismaPostgres\n ? {\n projectId: this.config.name,\n region: \"us-east-1\"\n }\n : undefined\n })\n } as Partial<PrismaPluginUserConfig>;\n },\n async configResolved() {\n this.dependencies[\"@prisma/ppg\"] = \"latest\";\n\n this.config.prisma.configFile = replacePathTokens(\n this,\n this.config.prisma.configFile\n );\n\n if (!this.config.prisma.schema) {\n throw new Error(\n `Prisma schema path is not defined. Please specify a valid path in the plugin configuration.`\n );\n }\n\n this.config.prisma.schema = replacePathTokens(\n this,\n this.config.prisma.schema\n );\n\n if (!this.config.prisma.outputPath) {\n throw new Error(\n `Prisma generated path is not defined. Please specify a valid path in the plugin configuration.`\n );\n }\n\n this.config.prisma.outputPath = replacePathTokens(\n this,\n this.config.prisma.outputPath\n );\n\n this.prisma ??= {} as TContext[\"prisma\"];\n if (!existsSync(this.config.prisma.schema)) {\n this.prisma.schema ??= {\n generators: [],\n datasources: [],\n warnings: []\n };\n } else {\n this.prisma.schema = await getSchema({\n datamodel: this.config.prisma.schema\n });\n }\n\n const generator = this.prisma.schema.generators.find(\n gen => gen.provider.value === \"prisma-client\"\n );\n if (!generator) {\n this.prisma.schema.generators.push({\n name: \"prisma-client\",\n provider: {\n value: \"prisma-client\",\n fromEnvVar: null\n },\n output: {\n value: this.config.prisma.outputPath,\n fromEnvVar: null\n },\n config: {},\n binaryTargets: [],\n previewFeatures: [],\n sourceFilePath: this.config.prisma.schema\n });\n } else {\n generator.output ??= {\n value: this.config.prisma.outputPath,\n fromEnvVar: null\n };\n }\n\n this.prisma.builder = new PrismaSchemaCreator(this);\n },\n async prepare() {\n // Write the schema file before invoking Prisma - Generate\n await this.prisma.builder.write();\n\n const args = [\"generate\", \"--schema\", this.config.prisma.schema];\n if (!this.config.prisma.prismaPath) {\n args.unshift(this.config.root);\n\n const result = await executePackage(\n \"prisma\",\n args,\n joinPaths(this.workspaceConfig.workspaceRoot, this.config.root)\n );\n if (result.failed) {\n throw new Error(\n `Prisma process exited with code ${result.exitCode}.`\n );\n }\n } else {\n args.unshift(this.config.prisma.prismaPath);\n\n const result = await execute(args.join(\" \"), this.config.root);\n if (result.failed) {\n throw new Error(\n `Prisma process exited with code ${result.exitCode}.`\n );\n }\n }\n },\n async deployPulumi() {\n if (this.config.prisma.prismaPostgres) {\n let serviceToken = process.env.PRISMA_SERVICE_TOKEN;\n if (!serviceToken) {\n serviceToken = options.serviceToken;\n if (serviceToken) {\n this.warn(\n \"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.\"\n );\n } else {\n throw new Error(\n \"Unable to determine the Prisma service token. Please set the `PRISMA_SERVICE_TOKEN` environment variable.\"\n );\n }\n }\n\n await this.pulumi.workspace.installPlugin(\n \"registry.terraform.io/prisma/prisma-postgres\",\n \"v0.2.0\"\n );\n\n const project = new prismaPostgres.Project(\"project\", {\n name: `${\n this.config.prisma.prismaPostgres?.projectId || this.config.name\n }`\n });\n const database = new prismaPostgres.Database(\"database\", {\n projectId: project.id,\n name: `${\n this.config.prisma.prismaPostgres?.databaseName ||\n `${kebabCase(this.config.name)}.${\n this.config.mode\n }.${this.config.prisma.prismaPostgres?.region}`\n }`,\n region: `${this.config.prisma.prismaPostgres?.region}`\n });\n // eslint-disable-next-line no-new\n new prismaPostgres.Connection(\"connection\", {\n databaseId: database.id,\n name: `${kebabCase(this.config.name)}-api-key`\n });\n }\n }\n };\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;AAgDA,MAAa,UAGX,UAA+B,EAAE,KACZ;AACrB,QAAO;EACL,MAAM;EACN,SAAS;AACP,UAAO,EACL,QAAQ,KAAK,SAAS;IACpB,QAAQ,UAAU,KAAK,OAAO,MAAM,UAAU,gBAAgB;IAC9D,YACE,QAAQ,cAAc,cAAc,MAAM,gBAAgB;IAC5D,YAAY,UAAU,iBAAiB,SAAS;IAChD,gBAAgB,SAAS,iBACrB;KACE,WAAW,KAAK,OAAO;KACvB,QAAQ;KACT,GACD;IACL,CAAC,EACH;;EAEH,MAAM,iBAAiB;AACrB,QAAK,aAAa,iBAAiB;AAEnC,QAAK,OAAO,OAAO,aAAa,kBAC9B,MACA,KAAK,OAAO,OAAO,WACpB;AAED,OAAI,CAAC,KAAK,OAAO,OAAO,OACtB,OAAM,IAAI,MACR,8FACD;AAGH,QAAK,OAAO,OAAO,SAAS,kBAC1B,MACA,KAAK,OAAO,OAAO,OACpB;AAED,OAAI,CAAC,KAAK,OAAO,OAAO,WACtB,OAAM,IAAI,MACR,iGACD;AAGH,QAAK,OAAO,OAAO,aAAa,kBAC9B,MACA,KAAK,OAAO,OAAO,WACpB;AAED,QAAK,WAAW,EAAE;AAClB,OAAI,CAAC,WAAW,KAAK,OAAO,OAAO,OAAO,CACxC,MAAK,OAAO,WAAW;IACrB,YAAY,EAAE;IACd,aAAa,EAAE;IACf,UAAU,EAAE;IACb;OAED,MAAK,OAAO,SAAS,MAAM,UAAU,EACnC,W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AAIL,UAAM,KAAK,OAAO,UAAU,cAC1B,gDACA,SACD;IAED,MAAM,UAAU,IAAI,eAAe,QAAQ,WAAW,EACpD,MAAM,GACJ,KAAK,OAAO,OAAO,gBAAgB,aAAa,KAAK,OAAO,QAE/D,CAAC;IACF,MAAM,WAAW,IAAI,eAAe,SAAS,YAAY;KACvD,WAAW,QAAQ;KACnB,MAAM,GACJ,KAAK,OAAO,OAAO,gBAAgB,gBACnC,GAAG,UAAU,KAAK,OAAO,KAAK,CAAC,GAC7B,KAAK,OAAO,KACb,GAAG,KAAK,OAAO,OAAO,gBAAgB;KAEzC,QAAQ,GAAG,KAAK,OAAO,OAAO,gBAAgB;KAC/C,CAAC;AAEF,QAAI,eAAe,WAAW,cAAc;KAC1C,YAAY,SAAS;KACrB,MAAM,GAAG,UAAU,KAAK,OAAO,KAAK,CAAC;KACtC,CAAC;;;EAGP;;AAGH,kBAAe"}
@@ -1,5 +1,5 @@
1
1
 
2
- //#region ../../node_modules/.pnpm/@stryke+string-format@0.14.8/node_modules/@stryke/string-format/dist/get-words.mjs
2
+ //#region ../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/get-words.mjs
3
3
  /**
4
4
  * Regular expression pattern to split strings into words for various case conversions
5
5
  *
@@ -1,4 +1,4 @@
1
- //#region ../../node_modules/.pnpm/@stryke+string-format@0.14.8/node_modules/@stryke/string-format/dist/get-words.mjs
1
+ //#region ../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/get-words.mjs
2
2
  /**
3
3
  * Regular expression pattern to split strings into words for various case conversions
4
4
  *
@@ -1 +1 @@
1
- {"version":3,"file":"get-words.mjs","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@stryke+string-format@0.14.8/node_modules/@stryke/string-format/dist/get-words.mjs"],"sourcesContent":["//#region src/get-words.ts\n/**\n* Regular expression pattern to split strings into words for various case conversions\n*\n* This pattern matches sequences of characters in a string, considering the following case:\n* - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n* - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n* - Single uppercase letters\n* - Sequences of digits\n*\n* The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n* a consistent format like snake case.\n*\n* @example\n* const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n* // matches: ['camel', 'Case', 'HTTP', 'Request']\n*/\nconst CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|\\d+|[A-Z]+(?![a-z])/g;\nconst RELAXED_SPLIT_PATTERN = /[A-Z/.-]?[a-z/.-]+|\\d+|[A-Z/.-]+(?![a-z/.-])/g;\n/**\n* Splits a string into words using a regular expression pattern\n*\n* @example\n* const words = getWords('camelCaseHTTPRequest');\n* // words: ['camel', 'Case', 'HTTP', 'Request']\n*\n* @param str - The string to split into words\n* @param options - Options for splitting the string\n* @returns An array of words\n*/\nfunction getWords(str, options = {}) {\n\tif (str.length > 5e3) throw new Error(\"The regular expression parameter of `get-words` can't handle strings longer than 2000 characters\");\n\treturn [...str.match(options.split ?? (options.relaxed ? RELAXED_SPLIT_PATTERN : CASE_SPLIT_PATTERN)) ?? []];\n}\n\n//#endregion\nexport { CASE_SPLIT_PATTERN, RELAXED_SPLIT_PATTERN, getWords };\n//# sourceMappingURL=get-words.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;;;;;;;;;;;;AAY9B,SAAS,SAAS,KAAK,UAAU,EAAE,EAAE;AACpC,KAAI,IAAI,SAAS,IAAK,OAAM,IAAI,MAAM,mGAAmG;AACzI,QAAO,CAAC,GAAG,IAAI,MAAM,QAAQ,UAAU,QAAQ,UAAU,wBAAwB,oBAAoB,IAAI,EAAE,CAAC"}
1
+ {"version":3,"file":"get-words.mjs","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/get-words.mjs"],"sourcesContent":["//#region src/get-words.ts\n/**\n* Regular expression pattern to split strings into words for various case conversions\n*\n* This pattern matches sequences of characters in a string, considering the following case:\n* - Sequences of two or more uppercase letters followed by an uppercase letter and lowercase letters or digits (for acronyms)\n* - Sequences of one uppercase letter optionally followed by lowercase letters and digits\n* - Single uppercase letters\n* - Sequences of digits\n*\n* The resulting match can be used to convert camelCase, snake_case, kebab-case, and other mixed formats into\n* a consistent format like snake case.\n*\n* @example\n* const matches = 'camelCaseHTTPRequest'.match(CASE_SPLIT_PATTERN);\n* // matches: ['camel', 'Case', 'HTTP', 'Request']\n*/\nconst CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|\\d+|[A-Z]+(?![a-z])/g;\nconst RELAXED_SPLIT_PATTERN = /[A-Z/.-]?[a-z/.-]+|\\d+|[A-Z/.-]+(?![a-z/.-])/g;\n/**\n* Splits a string into words using a regular expression pattern\n*\n* @example\n* const words = getWords('camelCaseHTTPRequest');\n* // words: ['camel', 'Case', 'HTTP', 'Request']\n*\n* @param str - The string to split into words\n* @param options - Options for splitting the string\n* @returns An array of words\n*/\nfunction getWords(str, options = {}) {\n\tif (str.length > 5e3) throw new Error(\"The regular expression parameter of `get-words` can't handle strings longer than 2000 characters\");\n\treturn [...str.match(options.split ?? (options.relaxed ? RELAXED_SPLIT_PATTERN : CASE_SPLIT_PATTERN)) ?? []];\n}\n\n//#endregion\nexport { CASE_SPLIT_PATTERN, RELAXED_SPLIT_PATTERN, getWords };\n//# sourceMappingURL=get-words.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;;;;;;;;;;;;AAY9B,SAAS,SAAS,KAAK,UAAU,EAAE,EAAE;AACpC,KAAI,IAAI,SAAS,IAAK,OAAM,IAAI,MAAM,mGAAmG;AACzI,QAAO,CAAC,GAAG,IAAI,MAAM,QAAQ,UAAU,QAAQ,UAAU,wBAAwB,oBAAoB,IAAI,EAAE,CAAC"}
@@ -1,6 +1,6 @@
1
1
  const require_get_words = require('./get-words.cjs');
2
2
 
3
- //#region ../../node_modules/.pnpm/@stryke+string-format@0.14.8/node_modules/@stryke/string-format/dist/kebab-case.mjs
3
+ //#region ../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.mjs
4
4
  /**
5
5
  * Check if the input string is in kebab case.
6
6
  *
@@ -1,6 +1,6 @@
1
1
  import { getWords } from "./get-words.mjs";
2
2
 
3
- //#region ../../node_modules/.pnpm/@stryke+string-format@0.14.8/node_modules/@stryke/string-format/dist/kebab-case.mjs
3
+ //#region ../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.mjs
4
4
  /**
5
5
  * Check if the input string is in kebab case.
6
6
  *
@@ -1 +1 @@
1
- {"version":3,"file":"kebab-case.mjs","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@stryke+string-format@0.14.8/node_modules/@stryke/string-format/dist/kebab-case.mjs"],"sourcesContent":["import { getWords } from \"./get-words.mjs\";\n\n//#region src/kebab-case.ts\n/**\n* Check if the input string is in kebab case.\n*\n* @remarks\n* Kebab case is defined as all lowercase letters with hyphens separating words - \"this-is-an-example\".\n*\n* @param input - The input string to check.\n* @returns True if the input is in kebab case, false otherwise.\n*/\nfunction isKebabCase(input) {\n\treturn input ? /^[a-z]+(?:-[a-z0-9]+)*$/.test(input) : false;\n}\n/**\n* Convert the input string to kebab case.\n*\n* @remarks\n* Kebab case is defined as all lowercase letters with hyphens separating words - \"this-is-an-example\".\n*\n* @param input - The input string.\n* @returns The kebab-cased string.\n*/\nfunction kebabCase(input) {\n\tif (isKebabCase(input) || input === void 0) return input;\n\tconst parts = input ? getWords(input) : [];\n\tif (parts.length === 0) return \"\";\n\treturn parts.join(\"-\").toLowerCase();\n}\n\n//#endregion\nexport { isKebabCase, kebabCase };\n//# sourceMappingURL=kebab-case.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;AAYA,SAAS,YAAY,OAAO;AAC3B,QAAO,QAAQ,0BAA0B,KAAK,MAAM,GAAG;;;;;;;;;;;AAWxD,SAAS,UAAU,OAAO;AACzB,KAAI,YAAY,MAAM,IAAI,UAAU,KAAK,EAAG,QAAO;CACnD,MAAM,QAAQ,QAAQ,SAAS,MAAM,GAAG,EAAE;AAC1C,KAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAO,MAAM,KAAK,IAAI,CAAC,aAAa"}
1
+ {"version":3,"file":"kebab-case.mjs","names":[],"sources":["../../../../../../../../../../node_modules/.pnpm/@stryke+string-format@0.16.0/node_modules/@stryke/string-format/dist/kebab-case.mjs"],"sourcesContent":["import { getWords } from \"./get-words.mjs\";\n\n//#region src/kebab-case.ts\n/**\n* Check if the input string is in kebab case.\n*\n* @remarks\n* Kebab case is defined as all lowercase letters with hyphens separating words - \"this-is-an-example\".\n*\n* @param input - The input string to check.\n* @returns True if the input is in kebab case, false otherwise.\n*/\nfunction isKebabCase(input) {\n\treturn input ? /^[a-z]+(?:-[a-z0-9]+)*$/.test(input) : false;\n}\n/**\n* Convert the input string to kebab case.\n*\n* @remarks\n* Kebab case is defined as all lowercase letters with hyphens separating words - \"this-is-an-example\".\n*\n* @param input - The input string.\n* @returns The kebab-cased string.\n*/\nfunction kebabCase(input) {\n\tif (isKebabCase(input) || input === void 0) return input;\n\tconst parts = input ? getWords(input) : [];\n\tif (parts.length === 0) return \"\";\n\treturn parts.join(\"-\").toLowerCase();\n}\n\n//#endregion\nexport { isKebabCase, kebabCase };\n//# sourceMappingURL=kebab-case.mjs.map"],"x_google_ignoreList":[0],"mappings":";;;;;;;;;;;;AAYA,SAAS,YAAY,OAAO;AAC3B,QAAO,QAAQ,0BAA0B,KAAK,MAAM,GAAG;;;;;;;;;;;AAWxD,SAAS,UAAU,OAAO;AACzB,KAAI,YAAY,MAAM,IAAI,UAAU,KAAK,EAAG,QAAO;CACnD,MAAM,QAAQ,QAAQ,SAAS,MAAM,GAAG,EAAE;AAC1C,KAAI,MAAM,WAAW,EAAG,QAAO;AAC/B,QAAO,MAAM,KAAK,IAAI,CAAC,aAAa"}
@@ -1,6 +1,6 @@
1
- import { PrismaClient } from "../api/sdk.gen.cjs";
2
1
  import { PrismaSchema } from "./prisma.cjs";
3
2
  import { PrismaSchemaCreator } from "../helpers/schema-creator.cjs";
3
+ import { PulumiPluginContext, PulumiPluginResolvedConfig, PulumiPluginUserConfig } from "@powerlines/plugin-pulumi";
4
4
  import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
5
5
 
6
6
  //#region src/types/plugin.d.ts
@@ -54,7 +54,10 @@ interface PrismaPluginOptions {
54
54
  */
55
55
  params?: string;
56
56
  /**
57
- * The path to the Prisma binary
57
+ * The path to the generated Prisma client. This is used by the plugin to import the client for type generation and other operations.
58
+ *
59
+ * @remarks
60
+ * If not specified, the plugin will attempt to resolve the Prisma client path based on the output path and the schema file name. This field allows you to explicitly specify the path to the generated Prisma client if it cannot be automatically resolved.
58
61
  */
59
62
  prismaPath?: string;
60
63
  /**
@@ -66,19 +69,18 @@ interface PrismaPluginOptions {
66
69
  */
67
70
  prismaPostgres?: PrismaPostgresPrismaPluginOptions | true;
68
71
  }
69
- type PrismaPluginUserConfig = UserConfig & {
72
+ type PrismaPluginUserConfig = UserConfig & PulumiPluginUserConfig & {
70
73
  prisma?: Omit<PrismaPluginOptions, "schema" | "outputPath" | "configFile"> & Required<Pick<PrismaPluginOptions, "schema" | "outputPath" | "configFile">>;
71
74
  };
72
- type PrismaPluginResolvedConfig = ResolvedConfig & {
75
+ type PrismaPluginResolvedConfig = ResolvedConfig & PulumiPluginResolvedConfig & {
73
76
  prisma: Omit<PrismaPluginOptions, "schema" | "outputPath" | "configFile" | "prismaPostgres"> & Required<Pick<PrismaPluginOptions, "schema" | "outputPath" | "configFile">> & {
74
77
  prismaPostgres?: Required<PrismaPostgresPrismaPluginOptions>;
75
78
  };
76
79
  };
77
- type PrismaPluginContext<TResolvedConfig extends PrismaPluginResolvedConfig = PrismaPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
80
+ type PrismaPluginContext<TResolvedConfig extends PrismaPluginResolvedConfig = PrismaPluginResolvedConfig> = PluginContext<TResolvedConfig> & PulumiPluginContext & {
78
81
  prisma: {
79
82
  schema: PrismaSchema;
80
83
  builder: PrismaSchemaCreator;
81
- api: PrismaClient;
82
84
  };
83
85
  };
84
86
  declare type __ΩPrismaPostgresPrismaPluginOptions = any[];
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;UAuBiB,iCAAA;;AAAjB;AAoDA;AAiDA;;EACgB,SAAA,CAAA,EAAA,MAAA;EAAL;;;;;EAIC,MAAA,CAAA,EAAA,WAAA,GAAA,WAA0B,GAAA,WAAA,GAAA,WAAA,GAAA,YAAA,GAAA,WAAA,GAAA,YAAA,GAAA,YAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,cAAA,GAAA,WAAA,GAAA,cAAA,GAAA,cAAA,GAAA,WAAA,GAAA,WAAA,GAAA,WAAA,GAAA,YAAA,GAAA,YAAA,GAAA,YAAA,GAAA,cAAA,GAAA,YAAA,GAAA,cAAA,GAAA,WAAA;EAAG;;;;;EAKrC,YAAA,CAAA,EAAA,MAAA;;AAGmB,UA9DN,mBAAA,CA8DM;EAAQ;AAI/B;;;;EAGI,MAAA,CAAA,EAAA,MAAA;EAEQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAzBO;;KAGP,sBAAA,GAAyB;WAC1B,KAAK,+DACZ,SAAS,KAAK;;KAGN,0BAAA,GAA6B;UAC/B,KACN,kFAGA,SACE,KAAK;qBAEY,SAAS;;;KAIpB,4CACc,6BACtB,8BACA,cAAc;;YAEN;aACC;SACJ"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;UA2BiB,iCAAA;;AAAjB;AAoDA;AAoDA;;EACE,SAAA,CAAA,EAAA,MAAA;EACgB;;;;;EACJ,MAAA,CAAA,EAAA,WAAA,GAAA,WAAA,GAAA,WAAA,GAAA,WAAA,GAAA,YAAA,GAAA,WAAA,GAAA,YAAA,GAAA,YAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,gBAAA,GAAA,cAAA,GAAA,WAAA,GAAA,cAAA,GAAA,cAAA,GAAA,WAAA,GAAA,WAAA,GAAA,WAAA,GAAA,YAAA,GAAA,YAAA,GAAA,YAAA,GAAA,cAAA,GAAA,YAAA,GAAA,cAAA,GAAA,WAAA;EAKF;;;;;EAOC,YAAA,CAAA,EAAA,MAAA;;AADP,UAlEW,mBAAA,CAkEX;EAG4B;;;AAIlC;;EAEI,MAAA,CAAA,EAAA,MAAA;EACc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA3BC;;KAGP,sBAAA,GAAyB,aACnC;WACW,KAAK,+DACZ,SACE,KAAK;;KAID,0BAAA,GAA6B,iBACvC;UACU,KACN,kFAGA,SACE,KAAK;qBAEY,SAAS;;;KAItB,4CACc,6BACtB,8BACA,cAAc,mBAChB;;YAEY;aACC"}
@@ -1,6 +1,6 @@
1
- import { PrismaClient } from "../api/sdk.gen.mjs";
2
1
  import { PrismaSchema } from "./prisma.mjs";
3
2
  import { PrismaSchemaCreator } from "../helpers/schema-creator.mjs";
3
+ import { PulumiPluginContext, PulumiPluginResolvedConfig, PulumiPluginUserConfig } from "@powerlines/plugin-pulumi";
4
4
  import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
5
5
 
6
6
  //#region src/types/plugin.d.ts
@@ -54,7 +54,10 @@ interface PrismaPluginOptions {
54
54
  */
55
55
  params?: string;
56
56
  /**
57
- * The path to the Prisma binary
57
+ * The path to the generated Prisma client. This is used by the plugin to import the client for type generation and other operations.
58
+ *
59
+ * @remarks
60
+ * If not specified, the plugin will attempt to resolve the Prisma client path based on the output path and the schema file name. This field allows you to explicitly specify the path to the generated Prisma client if it cannot be automatically resolved.
58
61
  */
59
62
  prismaPath?: string;
60
63
  /**
@@ -66,19 +69,18 @@ interface PrismaPluginOptions {
66
69
  */
67
70
  prismaPostgres?: PrismaPostgresPrismaPluginOptions | true;
68
71
  }
69
- type PrismaPluginUserConfig = UserConfig & {
72
+ type PrismaPluginUserConfig = UserConfig & PulumiPluginUserConfig & {
70
73
  prisma?: Omit<PrismaPluginOptions, "schema" | "outputPath" | "configFile"> & Required<Pick<PrismaPluginOptions, "schema" | "outputPath" | "configFile">>;
71
74
  };
72
- type PrismaPluginResolvedConfig = ResolvedConfig & {
75
+ type PrismaPluginResolvedConfig = ResolvedConfig & PulumiPluginResolvedConfig & {
73
76
  prisma: Omit<PrismaPluginOptions, "schema" | "outputPath" | "configFile" | "prismaPostgres"> & Required<Pick<PrismaPluginOptions, "schema" | "outputPath" | "configFile">> & {
74
77
  prismaPostgres?: Required<PrismaPostgresPrismaPluginOptions>;
75
78
  };
76
79
  };
77
- type PrismaPluginContext<TResolvedConfig extends PrismaPluginResolvedConfig = PrismaPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
80
+ type PrismaPluginContext<TResolvedConfig extends PrismaPluginResolvedConfig = PrismaPluginResolvedConfig> = PluginContext<TResolvedConfig> & PulumiPluginContext & {
78
81
  prisma: {
79
82
  schema: PrismaSchema;
80
83
  builder: PrismaSchemaCreator;
81
- api: PrismaClient;
82
84
  };
83
85
  };
84
86
  declare type __ΩPrismaPostgresPrismaPluginOptions = any[];
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;UAuBiB,iCAAA;;AAAjB;AAoDA;AAiDA;;EACgB,SAAA,CAAA,EAAA,MAAA;E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;cACD;;;UAIJ,wBAAA;;;;UAKO,gBAAA;aACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-prisma",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
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"],
@@ -265,34 +265,6 @@
265
265
  "default": "./dist/api/types.gen.mjs"
266
266
  }
267
267
  },
268
- "./components": {
269
- "require": {
270
- "types": "./dist/components/index.d.cts",
271
- "default": "./dist/components/index.cjs"
272
- },
273
- "import": {
274
- "types": "./dist/components/index.d.mts",
275
- "default": "./dist/components/index.mjs"
276
- },
277
- "default": {
278
- "types": "./dist/components/index.d.mts",
279
- "default": "./dist/components/index.mjs"
280
- }
281
- },
282
- "./components/infrastructure-file": {
283
- "require": {
284
- "types": "./dist/components/infrastructure-file.d.cts",
285
- "default": "./dist/components/infrastructure-file.cjs"
286
- },
287
- "import": {
288
- "types": "./dist/components/infrastructure-file.d.mts",
289
- "default": "./dist/components/infrastructure-file.mjs"
290
- },
291
- "default": {
292
- "types": "./dist/components/infrastructure-file.d.mts",
293
- "default": "./dist/components/infrastructure-file.mjs"
294
- }
295
- },
296
268
  "./helpers": {
297
269
  "require": {
298
270
  "types": "./dist/helpers/index.d.cts",
@@ -398,9 +370,7 @@
398
370
  "typings": "dist/index.d.mts",
399
371
  "files": ["dist/**/*"],
400
372
  "dependencies": {
401
- "@alloy-js/core": "0.23.0-dev.8",
402
- "@alloy-js/typescript": "0.23.0-dev.4",
403
- "@powerlines/plugin-pulumi": "^0.3.0",
373
+ "@powerlines/plugin-pulumi": "^0.4.0",
404
374
  "@prisma/get-platform": "^6.19.2",
405
375
  "@prisma/prisma-schema-wasm": "6.19.0-26.2ba551f319ab1df4bc874a89965d8b3641056773",
406
376
  "@stryke/cli": "^0.13.25",
@@ -411,15 +381,15 @@
411
381
  "defu": "^6.1.4",
412
382
  "fp-ts": "^2.16.11",
413
383
  "jiti": "^2.6.1",
414
- "powerlines": "^0.40.3",
384
+ "powerlines": "^0.40.5",
415
385
  "prisma-util": "^2.1.1",
416
386
  "ts-pattern": "^5.9.0"
417
387
  },
418
388
  "devDependencies": {
419
- "@powerlines/plugin-alloy": "^0.25.0",
420
- "@powerlines/plugin-plugin": "^0.12.267",
389
+ "@pulumi/pulumi": "^3.225.1",
390
+ "@powerlines/plugin-plugin": "^0.12.269",
421
391
  "@types/node": "^25.3.5"
422
392
  },
423
393
  "publishConfig": { "access": "public" },
424
- "gitHead": "50b8a5ce8e5dbafd182ff7c8659469af86eef47c"
394
+ "gitHead": "842d89a4d59dd40606518bc727bfc31e3219b941"
425
395
  }
@@ -1,3 +0,0 @@
1
- const require_components_infrastructure_file = require('./infrastructure-file.cjs');
2
-
3
- exports.PrismaPostgresInfrastructureFile = require_components_infrastructure_file.PrismaPostgresInfrastructureFile;
@@ -1,2 +0,0 @@
1
- import { PrismaPostgresInfrastructureFile, PrismaPostgresInfrastructureFileProps, __ΩPrismaPostgresInfrastructureFileProps } from "./infrastructure-file.cjs";
2
- export { PrismaPostgresInfrastructureFile, PrismaPostgresInfrastructureFileProps, __ΩPrismaPostgresInfrastructureFileProps };
@@ -1,2 +0,0 @@
1
- import { PrismaPostgresInfrastructureFile, PrismaPostgresInfrastructureFileProps, __ΩPrismaPostgresInfrastructureFileProps } from "./infrastructure-file.mjs";
2
- export { PrismaPostgresInfrastructureFile, PrismaPostgresInfrastructureFileProps, __ΩPrismaPostgresInfrastructureFileProps };
@@ -1,3 +0,0 @@
1
- import { PrismaPostgresInfrastructureFile } from "./infrastructure-file.mjs";
2
-
3
- export { PrismaPostgresInfrastructureFile };
@@ -1,76 +0,0 @@
1
- const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
2
- const require_kebab_case = require('../node_modules/.pnpm/@stryke_string-format@0.14.8/node_modules/@stryke/string-format/dist/kebab-case.cjs');
3
- let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
- let __alloy_js_core = require("@alloy-js/core");
5
- let __alloy_js_typescript = require("@alloy-js/typescript");
6
- let __powerlines_plugin_alloy_core_components_spacing = require("@powerlines/plugin-alloy/core/components/spacing");
7
- let __powerlines_plugin_alloy_core_contexts_context = require("@powerlines/plugin-alloy/core/contexts/context");
8
- let __powerlines_plugin_alloy_typescript_components_infrastructure_file = require("@powerlines/plugin-alloy/typescript/components/infrastructure-file");
9
- let defu = require("defu");
10
- defu = require_rolldown_runtime.__toESM(defu);
11
-
12
- //#region src/components/infrastructure-file.tsx
13
- /**
14
- * Generates the Prisma Postgres infrastructure configuration module for the Powerlines project.
15
- */
16
- function PrismaPostgresInfrastructureFile(props) {
17
- const [{ children, imports }, rest] = (0, __alloy_js_core.splitProps)(props, ["children", "imports"]);
18
- const context = (0, __powerlines_plugin_alloy_core_contexts_context.usePowerlines)();
19
- return (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_typescript_components_infrastructure_file.InfrastructureFile, (0, __alloy_js_core_jsx_runtime.mergeProps)({ id: "prisma-postgres" }, rest, {
20
- get imports() {
21
- return (0, defu.default)({
22
- "@pulumi/pulumi": "pulumi",
23
- "@pulumi/prisma-postgres": "prismaPostgres"
24
- }, imports ?? {});
25
- },
26
- get children() {
27
- return [
28
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
29
- "export": true,
30
- "const": true,
31
- name: "project",
32
- get initializer() {
33
- return __alloy_js_core.code`new prismaPostgres.Project("project", {
34
- name: "${context.config.prisma.prismaPostgres?.projectId}",
35
- }); `;
36
- }
37
- }),
38
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
39
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
40
- "export": true,
41
- "const": true,
42
- name: "database",
43
- get initializer() {
44
- return __alloy_js_core.code`prismaPostgres.Database("database", {
45
- projectId: project.id,
46
- name: "${context.config.prisma.prismaPostgres?.databaseName || `${require_kebab_case.kebabCase(context.config.name)}.${context.config.mode}.${context.config.prisma.prismaPostgres?.region}`}",
47
- region: "${context.config.prisma.prismaPostgres?.region}",
48
- }); `;
49
- }
50
- }),
51
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
52
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_typescript.VarDeclaration, {
53
- "export": true,
54
- "const": true,
55
- name: "connection",
56
- get initializer() {
57
- return __alloy_js_core.code`new prismaPostgres.Connection("connection", {
58
- databaseId: database.id,
59
- name: "${require_kebab_case.kebabCase(context.config.name)}-api-key",
60
- }); `;
61
- }
62
- }),
63
- (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_core_components_spacing.Spacing, {}),
64
- (0, __alloy_js_core_jsx_runtime.createComponent)(__alloy_js_core.Show, {
65
- get when() {
66
- return Boolean(children);
67
- },
68
- children
69
- })
70
- ];
71
- }
72
- }));
73
- }
74
-
75
- //#endregion
76
- exports.PrismaPostgresInfrastructureFile = PrismaPostgresInfrastructureFile;
@@ -1,13 +0,0 @@
1
- import * as _alloy_js_core0 from "@alloy-js/core";
2
- import { InfrastructureFileProps } from "@powerlines/plugin-alloy/typescript/components/infrastructure-file";
3
-
4
- //#region src/components/infrastructure-file.d.ts
5
- type PrismaPostgresInfrastructureFileProps = Omit<InfrastructureFileProps, "id">;
6
- /**
7
- * Generates the Prisma Postgres infrastructure configuration module for the Powerlines project.
8
- */
9
- declare function PrismaPostgresInfrastructureFile(props: PrismaPostgresInfrastructureFileProps): _alloy_js_core0.Children;
10
- declare type __ΩPrismaPostgresInfrastructureFileProps = any[];
11
- //#endregion
12
- export { PrismaPostgresInfrastructureFile, PrismaPostgresInfrastructureFileProps, __ΩPrismaPostgresInfrastructureFileProps };
13
- //# sourceMappingURL=infrastructure-file.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"infrastructure-file.d.cts","names":[],"sources":["../../src/components/infrastructure-file.tsx"],"sourcesContent":[],"mappings":";;;;KA8BY,qCAAA,GAAwC,KAClD;;;AADF;AAQgB,iBAAA,gCAAA,CACP,KAAA,EAAA,qCAAqC,CAAA,EAAA,eAAA,CAAA,QAAA"}
@@ -1,13 +0,0 @@
1
- import * as _alloy_js_core0 from "@alloy-js/core";
2
- import { InfrastructureFileProps } from "@powerlines/plugin-alloy/typescript/components/infrastructure-file";
3
-
4
- //#region src/components/infrastructure-file.d.ts
5
- type PrismaPostgresInfrastructureFileProps = Omit<InfrastructureFileProps, "id">;
6
- /**
7
- * Generates the Prisma Postgres infrastructure configuration module for the Powerlines project.
8
- */
9
- declare function PrismaPostgresInfrastructureFile(props: PrismaPostgresInfrastructureFileProps): _alloy_js_core0.Children;
10
- declare type __ΩPrismaPostgresInfrastructureFileProps = any[];
11
- //#endregion
12
- export { PrismaPostgresInfrastructureFile, PrismaPostgresInfrastructureFileProps, __ΩPrismaPostgresInfrastructureFileProps };
13
- //# sourceMappingURL=infrastructure-file.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"infrastructure-file.d.mts","names":[],"sources":["../../src/components/infrastructure-file.tsx"],"sourcesContent":[],"mappings":";;;;KA8BY,qCAAA,GAAwC,KAClD;;;AADF;AAQgB,iBAAA,gCAAA,CACP,KAAA,EAAA,qCAAqC,CAAA,EAAA,eAAA,CAAA,QAAA"}
@@ -1,75 +0,0 @@
1
- import { kebabCase } from "../node_modules/.pnpm/@stryke_string-format@0.14.8/node_modules/@stryke/string-format/dist/kebab-case.mjs";
2
- import { createComponent, mergeProps } from "@alloy-js/core/jsx-runtime";
3
- import { Show, code, splitProps } from "@alloy-js/core";
4
- import { VarDeclaration } from "@alloy-js/typescript";
5
- import { Spacing } from "@powerlines/plugin-alloy/core/components/spacing";
6
- import { usePowerlines } from "@powerlines/plugin-alloy/core/contexts/context";
7
- import { InfrastructureFile } from "@powerlines/plugin-alloy/typescript/components/infrastructure-file";
8
- import defu from "defu";
9
-
10
- //#region src/components/infrastructure-file.tsx
11
- /**
12
- * Generates the Prisma Postgres infrastructure configuration module for the Powerlines project.
13
- */
14
- function PrismaPostgresInfrastructureFile(props) {
15
- const [{ children, imports }, rest] = splitProps(props, ["children", "imports"]);
16
- const context = usePowerlines();
17
- return createComponent(InfrastructureFile, mergeProps({ id: "prisma-postgres" }, rest, {
18
- get imports() {
19
- return defu({
20
- "@pulumi/pulumi": "pulumi",
21
- "@pulumi/prisma-postgres": "prismaPostgres"
22
- }, imports ?? {});
23
- },
24
- get children() {
25
- return [
26
- createComponent(VarDeclaration, {
27
- "export": true,
28
- "const": true,
29
- name: "project",
30
- get initializer() {
31
- return code`new prismaPostgres.Project("project", {
32
- name: "${context.config.prisma.prismaPostgres?.projectId}",
33
- }); `;
34
- }
35
- }),
36
- createComponent(Spacing, {}),
37
- createComponent(VarDeclaration, {
38
- "export": true,
39
- "const": true,
40
- name: "database",
41
- get initializer() {
42
- return code`prismaPostgres.Database("database", {
43
- projectId: project.id,
44
- name: "${context.config.prisma.prismaPostgres?.databaseName || `${kebabCase(context.config.name)}.${context.config.mode}.${context.config.prisma.prismaPostgres?.region}`}",
45
- region: "${context.config.prisma.prismaPostgres?.region}",
46
- }); `;
47
- }
48
- }),
49
- createComponent(Spacing, {}),
50
- createComponent(VarDeclaration, {
51
- "export": true,
52
- "const": true,
53
- name: "connection",
54
- get initializer() {
55
- return code`new prismaPostgres.Connection("connection", {
56
- databaseId: database.id,
57
- name: "${kebabCase(context.config.name)}-api-key",
58
- }); `;
59
- }
60
- }),
61
- createComponent(Spacing, {}),
62
- createComponent(Show, {
63
- get when() {
64
- return Boolean(children);
65
- },
66
- children
67
- })
68
- ];
69
- }
70
- }));
71
- }
72
-
73
- //#endregion
74
- export { PrismaPostgresInfrastructureFile };
75
- //# sourceMappingURL=infrastructure-file.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"infrastructure-file.mjs","names":["code","Show","splitProps","VarDeclaration","Spacing","usePowerlines","InfrastructureFile","kebabCase","defu","PrismaPostgresInfrastructureFile","props","children","imports","rest","context","_$createComponent","_$mergeProps","id","name","initializer","config","prisma","prismaPostgres","projectId","databaseName","mode","region","when","Boolean"],"sources":["../../src/components/infrastructure-file.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { code, Show, splitProps } from \"@alloy-js/core\";\nimport { VarDeclaration } from \"@alloy-js/typescript\";\nimport { Spacing } from \"@powerlines/plugin-alloy/core/components/spacing\";\nimport { usePowerlines } from \"@powerlines/plugin-alloy/core/contexts/context\";\nimport {\n InfrastructureFile,\n InfrastructureFileProps\n} from \"@powerlines/plugin-alloy/typescript/components/infrastructure-file\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport defu from \"defu\";\nimport { PrismaPluginContext } from \"../types\";\n\nexport type PrismaPostgresInfrastructureFileProps = Omit<\n InfrastructureFileProps,\n \"id\"\n>;\n\n/**\n * Generates the Prisma Postgres infrastructure configuration module for the Powerlines project.\n */\nexport function PrismaPostgresInfrastructureFile(\n props: PrismaPostgresInfrastructureFileProps\n) {\n const [{ children, imports }, rest] = splitProps(props, [\n \"children\",\n \"imports\"\n ]);\n\n const context = usePowerlines<PrismaPluginContext>();\n\n return (\n <InfrastructureFile\n id=\"prisma-postgres\"\n {...rest}\n imports={defu(\n {\n \"@pulumi/pulumi\": \"pulumi\",\n \"@pulumi/prisma-postgres\": \"prismaPostgres\"\n },\n imports ?? {}\n )}>\n <VarDeclaration\n export\n const\n name=\"project\"\n initializer={code`new prismaPostgres.Project(\"project\", {\n name: \"${context.config.prisma.prismaPostgres?.projectId}\",\n }); `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"database\"\n initializer={code`prismaPostgres.Database(\"database\", {\n projectId: project.id,\n name: \"${\n context.config.prisma.prismaPostgres?.databaseName ||\n `${kebabCase(context.config.name)}.${\n context.config.mode\n }.${context.config.prisma.prismaPostgres?.region}`\n }\",\n region: \"${context.config.prisma.prismaPostgres?.region}\",\n }); `}\n />\n <Spacing />\n <VarDeclaration\n export\n const\n name=\"connection\"\n initializer={code`new prismaPostgres.Connection(\"connection\", {\n databaseId: database.id,\n name: \"${kebabCase(context.config.name)}-api-key\",\n }); `}\n />\n <Spacing />\n <Show when={Boolean(children)}>{children}</Show>\n </InfrastructureFile>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAsCA,SAAgBS,iCACdC,OACA;CACA,MAAM,CAAC,EAAEC,UAAUC,WAAWC,QAAQX,WAAWQ,OAAO,CACtD,YACA,UACD,CAAC;CAEF,MAAMI,UAAUT,eAAoC;AAEpD,QAAAU,gBACGT,oBAAkBU,WAAA,EACjBC,IAAE,mBAAA,EACEJ,MAAI;EAAA,IACRD,UAAO;AAAA,UAAEJ,KACP;IACE,kBAAkB;IAClB,2BAA2B;IAC5B,EACDI,WAAW,EACb,CAAC;;EAAA,IAAAD,WAAA;AAAA,UAAA;IAAAI,gBACAZ,gBAAc;KAAA,UAAA;KAAA,SAAA;KAGbe,MAAI;KAAA,IACJC,cAAW;AAAA,aAAEnB,IAAI;mBACNc,QAAQM,OAAOC,OAAOC,gBAAgBC,UAAS;;;KACrD,CAAA;IAAAR,gBAENX,SAAO,EAAA,CAAA;IAAAW,gBACPZ,gBAAc;KAAA,UAAA;KAAA,SAAA;KAGbe,MAAI;KAAA,IACJC,cAAW;AAAA,aAAEnB,IAAI;;mBAGbc,QAAQM,OAAOC,OAAO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