@gaganref/confect-cli 10.3.1-fork.31 → 10.3.1-fork.33

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.
@@ -40,12 +40,17 @@ var AuthForAnotherBackend = class extends Data.TaggedError("AuthForAnotherBacken
40
40
  return `confect/auth.ts declares auth for the "${this.backend}" backend, but confect/app.ts declares "${this.expectedBackend}".`;
41
41
  }
42
42
  };
43
+ var InvalidProviderEnv = class extends Data.TaggedError("InvalidProviderEnv") {
44
+ get message() {
45
+ return `Auth provider field "${this.field}" requires a non-secret, required string entry of the "${this.backend}" env; got "${this.key}".`;
46
+ }
47
+ };
43
48
  const ENV_KEY = /^[A-Za-z][A-Za-z0-9_]*$/;
44
49
  const MOUNT_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
45
50
  /**
46
51
  * The declaration file a parse error is about.
47
52
  */
48
- const fileOf = (error) => error._tag === "NotADeclaration" ? error.file : error._tag === "AuthForAnotherBackend" ? "confect/auth.ts" : "confect/app.ts";
53
+ const fileOf = (error) => error._tag === "NotADeclaration" ? error.file : error._tag === "AuthForAnotherBackend" || error._tag === "InvalidProviderEnv" ? "confect/auth.ts" : "confect/app.ts";
49
54
  /**
50
55
  * Parse the default exports of `confect/app.ts` and, when present,
51
56
  * `confect/auth.ts`. `componentImport` recovers how the generated config
@@ -119,16 +124,44 @@ const parseProviders = (auth, backend) => {
119
124
  backend: authBackend,
120
125
  expectedBackend: backend
121
126
  }));
122
- return Result.succeed(Auth.providers(auth).map((provider) => Object.entries(provider).map(([field, value]) => {
123
- const sitePath = Auth.siteUrlPath(value);
124
- return [field, sitePath === void 0 ? {
125
- kind: "value",
126
- value: Predicate.isString(value) ? value : JSON.stringify(value)
127
- } : {
128
- kind: "siteUrl",
129
- path: sitePath
130
- }];
131
- })));
127
+ return Result.gen(function* () {
128
+ const providers = [];
129
+ for (const provider of Auth.providers(auth)) {
130
+ const fields = [];
131
+ for (const [field, value] of Object.entries(provider)) {
132
+ const sitePath = Auth.siteUrlPath(value);
133
+ const cloudPath = Auth.cloudUrlPath(value);
134
+ let lowered;
135
+ if (Env.isEntry(value)) {
136
+ const { backend: owner, key } = Env.origin(value);
137
+ const descriptor = value["~@confect/core/Env/Entry"].descriptor;
138
+ if (owner !== backend || descriptor.optional || descriptor.kind === "secret" || !ENV_KEY.test(key)) return yield* Result.fail(new InvalidProviderEnv({
139
+ field,
140
+ key,
141
+ backend
142
+ }));
143
+ lowered = {
144
+ kind: "env",
145
+ key
146
+ };
147
+ } else if (sitePath !== void 0) lowered = {
148
+ kind: "siteUrl",
149
+ path: sitePath
150
+ };
151
+ else if (cloudPath !== void 0) lowered = {
152
+ kind: "cloudUrl",
153
+ path: cloudPath
154
+ };
155
+ else lowered = {
156
+ kind: "value",
157
+ value: Predicate.isString(value) ? value : JSON.stringify(value)
158
+ };
159
+ fields.push([field, lowered]);
160
+ }
161
+ providers.push(fields);
162
+ }
163
+ return providers;
164
+ });
132
165
  };
133
166
  const quote = (value) => JSON.stringify(value);
134
167
  const header = (source) => `// Generated by \`confect codegen\` from ${source}. Do not edit.`;
@@ -207,7 +240,13 @@ const convexConfig = (declaration) => {
207
240
  lines.push("", `export default ${self};`, "");
208
241
  return lines.join("\n");
209
242
  };
210
- const providerValue = (value) => value.kind === "value" ? quote(value.value) : `\`\${process.env.CONVEX_SITE_URL}${value.path.replaceAll(/[`$\\]/g, "\\$&")}\``;
243
+ const providerValue = (value) => {
244
+ switch (value.kind) {
245
+ case "value": return quote(value.value);
246
+ case "env": return `process.env[${quote(value.key)}]!`;
247
+ default: return `\`\${process.env.${value.kind === "siteUrl" ? "CONVEX_SITE_URL" : "CONVEX_CLOUD_URL"}}${value.path.replaceAll(/[`$\\]/g, "\\$&")}\``;
248
+ }
249
+ };
211
250
  /**
212
251
  * `convex/auth.config.ts`: Convex's provider list, with site URLs resolved
213
252
  * there.
@@ -220,13 +259,37 @@ const authConfig = (providers) => [
220
259
  providers.length === 0 ? " providers: []," : " providers: [",
221
260
  ...providers.length === 0 ? [] : [...providers.flatMap((provider) => [
222
261
  " {",
223
- ...provider.map(([field, value]) => ` ${field}: ${providerValue(value)},`),
262
+ ...provider.filter(([field]) => field !== "family" && field !== "name").map(([field, value]) => ` ${field}: ${providerValue(value)},`),
224
263
  " },"
225
264
  ]), " ],"],
226
265
  "} satisfies AuthConfig;",
227
266
  ""
228
267
  ].join("\n");
229
268
  /**
269
+ * Runtime issuer data with no dependency on declarations or component
270
+ * definitions.
271
+ */
272
+ const authProviders = (providers) => [
273
+ header("confect/auth.ts"),
274
+ "",
275
+ "export const providers = [",
276
+ ...providers.flatMap((provider) => [
277
+ " {",
278
+ ...provider.flatMap(([field, value]) => {
279
+ const key = field === "domain" ? "issuer" : field === "applicationID" ? "audience" : field;
280
+ return [
281
+ "issuer",
282
+ "audience",
283
+ "family",
284
+ "name"
285
+ ].includes(key) ? [` ${key}: ${providerValue(value)},`] : [];
286
+ }),
287
+ " },"
288
+ ]),
289
+ "] as const;",
290
+ ""
291
+ ].join("\n");
292
+ /**
230
293
  * `confect/_generated/manifest.ts`: plain data, no imports, for infra.
231
294
  */
232
295
  const manifest = (declaration, digest) => {
@@ -253,6 +316,6 @@ const digest = (input) => {
253
316
  return `sha256:${hash.digest("hex")}`;
254
317
  };
255
318
  //#endregion
256
- export { AuthForAnotherBackend, ForeignEnvBinding, InvalidBinding, InvalidEnvKey, InvalidMountName, NotADeclaration, UnknownComponentImport, authConfig, convexConfig, digest, fileOf, header, isGenerated, manifest, parse };
319
+ export { AuthForAnotherBackend, ForeignEnvBinding, InvalidBinding, InvalidEnvKey, InvalidMountName, InvalidProviderEnv, NotADeclaration, UnknownComponentImport, authConfig, authProviders, convexConfig, digest, fileOf, header, isGenerated, manifest, parse };
257
320
 
258
321
  //# sourceMappingURL=Declaration.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Declaration.mjs","names":[],"sources":["../src/Declaration.ts"],"sourcesContent":["import { App, Auth, Env } from \"@confect/core\";\nimport * as Data from \"effect/Data\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\n// oxlint-disable-next-line effecttsgo/node-builtin-import -- a synchronous hash of in-memory strings in a pure function; Effect's Crypto is a service.\nimport { createHash } from \"node:crypto\";\n\n/**\n * A backend's declaration (`confect/env.ts`, `app.ts`, `auth.ts`) reduced to\n * the plain data codegen renders. The evaluated modules are parsed into this\n * once, at {@link parse}; every renderer below is a pure function of it.\n */\nexport interface Declaration {\n readonly target: \"app\" | \"component\";\n readonly name: string;\n readonly env: ReadonlyArray<readonly [string, Env.Descriptor]>;\n readonly mounts: ReadonlyArray<Mount>;\n readonly providers: Option.Option<ReadonlyArray<Provider>>;\n}\n\nexport interface Mount {\n readonly name: string;\n readonly importPath: string;\n readonly componentName: string;\n readonly httpPrefix: string | undefined;\n readonly env: ReadonlyArray<readonly [string, Binding]>;\n}\n\nexport type Binding =\n | { readonly kind: \"value\"; readonly value: string }\n | { readonly kind: \"env\"; readonly key: string };\n\nexport type ProviderValue =\n | { readonly kind: \"value\"; readonly value: string }\n | { readonly kind: \"siteUrl\"; readonly path: string };\n\nexport type Provider = ReadonlyArray<readonly [string, ProviderValue]>;\n\nexport class NotADeclaration extends Data.TaggedError(\"NotADeclaration\")<{\n readonly file: string;\n readonly expected: string;\n}> {\n override get message(): string {\n return `${this.file} must default-export ${this.expected}.`;\n }\n}\n\nexport class InvalidEnvKey extends Data.TaggedError(\"InvalidEnvKey\")<{\n readonly key: string;\n}> {\n override get message(): string {\n return `\"${this.key}\" is not a valid Convex environment variable name; use letters, digits and underscores, starting with a letter.`;\n }\n}\n\nexport class InvalidMountName extends Data.TaggedError(\"InvalidMountName\")<{\n readonly mount: string;\n}> {\n override get message(): string {\n return `\"${this.mount}\" is not a valid mount name; use letters, digits and underscores, starting with a letter or underscore.`;\n }\n}\n\nexport class ForeignEnvBinding extends Data.TaggedError(\"ForeignEnvBinding\")<{\n readonly mount: string;\n readonly slot: string;\n readonly backend: string;\n readonly key: string;\n readonly expectedBackend: string;\n}> {\n override get message(): string {\n return `The mount \"${this.mount}\" binds ${this.slot} to ${this.key} of the \"${this.backend}\" env, but this backend's env is \"${this.expectedBackend}\".`;\n }\n}\n\nexport class InvalidBinding extends Data.TaggedError(\"InvalidBinding\")<{\n readonly mount: string;\n readonly slot: string;\n}> {\n override get message(): string {\n return `The mount \"${this.mount}\" binds ${this.slot} to something other than a string or an entry of this backend's env.`;\n }\n}\n\nexport class UnknownComponentImport extends Data.TaggedError(\n \"UnknownComponentImport\",\n)<{ readonly mount: string }> {\n override get message(): string {\n return `The mount \"${this.mount}\" must pass the default export of a component's convex.config module, imported directly in the declaration.`;\n }\n}\n\nexport class AuthForAnotherBackend extends Data.TaggedError(\n \"AuthForAnotherBackend\",\n)<{ readonly backend: string; readonly expectedBackend: string }> {\n override get message(): string {\n return `confect/auth.ts declares auth for the \"${this.backend}\" backend, but confect/app.ts declares \"${this.expectedBackend}\".`;\n }\n}\n\nexport type DeclarationError =\n | NotADeclaration\n | InvalidEnvKey\n | InvalidMountName\n | ForeignEnvBinding\n | InvalidBinding\n | UnknownComponentImport\n | AuthForAnotherBackend;\n\nconst ENV_KEY = /^[A-Za-z][A-Za-z0-9_]*$/;\nconst MOUNT_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/**\n * The declaration file a parse error is about.\n */\nexport const fileOf = (error: DeclarationError): string =>\n error._tag === \"NotADeclaration\"\n ? error.file\n : error._tag === \"AuthForAnotherBackend\"\n ? \"confect/auth.ts\"\n : \"confect/app.ts\";\n\n/**\n * A mounted component's import as the generated `convex.config.ts` writes it.\n */\nexport interface ComponentImport {\n readonly importPath: string;\n readonly componentName: string;\n}\n\n/**\n * Parse the default exports of `confect/app.ts` and, when present,\n * `confect/auth.ts`. `componentImport` recovers how the generated config\n * imports a mounted definition; codegen's bundler records it.\n */\nexport const parse = (input: {\n readonly target: \"app\" | \"component\";\n readonly app: unknown;\n readonly auth: Option.Option<unknown>;\n readonly componentImport: (\n definition: unknown,\n ) => Option.Option<ComponentImport>;\n}): Result.Result<Declaration, DeclarationError> =>\n Result.gen(function* () {\n if (!App.isApp(input.app)) {\n return yield* Result.fail(\n new NotADeclaration({\n file: \"confect/app.ts\",\n expected: \"App.make(...)\",\n }),\n );\n }\n const env = App.env(input.app);\n const name = Env.name(env);\n const descriptors = Env.descriptors(env);\n for (const [key] of descriptors) {\n if (!ENV_KEY.test(key))\n return yield* Result.fail(new InvalidEnvKey({ key }));\n }\n\n const mounts: Array<Mount> = [];\n for (const mount of App.mounts(input.app)) {\n if (!MOUNT_NAME.test(mount.name)) {\n return yield* Result.fail(new InvalidMountName({ mount: mount.name }));\n }\n const component = input.componentImport(mount.definition);\n if (Option.isNone(component)) {\n return yield* Result.fail(\n new UnknownComponentImport({ mount: mount.name }),\n );\n }\n const bindings: Array<readonly [string, Binding]> = [];\n for (const [slot, bound] of Object.entries(mount.env)) {\n if (bound === undefined) continue;\n if (typeof bound === \"string\") {\n bindings.push([slot, { kind: \"value\", value: bound }]);\n continue;\n }\n if (!Env.isEntry(bound)) {\n return yield* Result.fail(\n new InvalidBinding({ mount: mount.name, slot }),\n );\n }\n const origin = Env.origin(bound);\n if (origin.backend !== name) {\n return yield* Result.fail(\n new ForeignEnvBinding({\n mount: mount.name,\n slot,\n backend: origin.backend,\n key: origin.key,\n expectedBackend: name,\n }),\n );\n }\n bindings.push([slot, { kind: \"env\", key: origin.key }]);\n }\n mounts.push({\n name: mount.name,\n importPath: component.value.importPath,\n componentName: component.value.componentName,\n httpPrefix: mount.httpPrefix,\n env: bindings,\n });\n }\n\n const providers: Option.Option<ReadonlyArray<Provider>> = Option.isNone(\n input.auth,\n )\n ? Option.none()\n : Option.some(yield* parseProviders(input.auth.value, name));\n\n return {\n target: input.target,\n name,\n env: descriptors,\n mounts,\n providers,\n };\n });\n\nconst parseProviders = (\n auth: unknown,\n backend: string,\n): Result.Result<ReadonlyArray<Provider>, DeclarationError> => {\n if (!Auth.isAuth(auth)) {\n return Result.fail(\n new NotADeclaration({\n file: \"confect/auth.ts\",\n expected: \"Auth.make(app, ...)\",\n }),\n );\n }\n const authBackend = Env.name(App.env(auth.app));\n if (authBackend !== backend) {\n return Result.fail(\n new AuthForAnotherBackend({\n backend: authBackend,\n expectedBackend: backend,\n }),\n );\n }\n return Result.succeed(\n Auth.providers(auth).map((provider) =>\n Object.entries(provider).map(([field, value]) => {\n const sitePath = Auth.siteUrlPath(value);\n return [\n field,\n sitePath === undefined\n ? {\n kind: \"value\",\n value: Predicate.isString(value)\n ? value\n : JSON.stringify(value),\n }\n : { kind: \"siteUrl\", path: sitePath },\n ] as const;\n }),\n ),\n );\n};\n\nconst quote = (value: string): string => JSON.stringify(value);\n\nexport const header = (source: string): string =>\n `// Generated by \\`confect codegen\\` from ${source}. Do not edit.`;\n\nconst GENERATED_PREFIX = \"// Generated by `confect codegen` from \";\n\n/**\n * Whether codegen may overwrite or remove an existing file: it carries the\n * generated header, or it is exactly one of the files an earlier codegen wrote\n * there (`legacy`).\n */\nexport const isGenerated = (\n contents: string,\n legacy: ReadonlyArray<string>,\n): boolean =>\n contents.startsWith(GENERATED_PREFIX) || legacy.includes(contents);\n\nconst validator = (descriptor: Env.Descriptor): string => {\n const base =\n descriptor.kind === \"literals\"\n ? descriptor.values.length === 1\n ? `v.literal(${quote(descriptor.values[0])})`\n : `v.union(${descriptor.values.map((value) => `v.literal(${quote(value)})`).join(\", \")})`\n : \"v.string()\";\n return descriptor.optional ? `v.optional(${base})` : base;\n};\n\nconst RESERVED = new Set(\n \"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 static super switch this throw true try typeof var void while with yield\".split(\n \" \",\n ),\n);\n\n/**\n * A safe import name for a component, from its Convex name.\n */\nconst identifier = (name: string): string => {\n const cleaned = name.replaceAll(/[^A-Za-z0-9_$]/g, \"_\");\n const valid = /^[A-Za-z_$]/.test(cleaned) ? cleaned : `_${cleaned}`;\n return RESERVED.has(valid) ? `${valid}Component` : valid;\n};\n\n/**\n * `convex/convex.config.ts`: Convex's own app or component definition.\n */\nexport const convexConfig = (declaration: Declaration): string => {\n const self = declaration.target === \"app\" ? \"app\" : \"component\";\n const aliases = new Map<string, string>();\n const taken = new Set([self, \"v\", \"defineApp\", \"defineComponent\"]);\n for (const mount of declaration.mounts) {\n if (aliases.has(mount.importPath)) continue;\n const base = identifier(mount.componentName);\n let alias = base;\n for (let n = 2; taken.has(alias); n++) alias = `${base}${n}`;\n taken.add(alias);\n aliases.set(mount.importPath, alias);\n }\n\n const lines = [header(\"confect/app.ts\")];\n lines.push(\n declaration.target === \"app\"\n ? 'import { defineApp } from \"convex/server\";'\n : 'import { defineComponent } from \"convex/server\";',\n );\n if (declaration.env.length > 0)\n lines.push('import { v } from \"convex/values\";');\n for (const [importPath, alias] of aliases) {\n lines.push(`import ${alias} from ${quote(importPath)};`);\n }\n lines.push(\"\");\n\n const envBlock =\n declaration.env.length === 0\n ? []\n : [\n \" env: {\",\n ...declaration.env.map(\n ([key, descriptor]) => ` ${key}: ${validator(descriptor)},`,\n ),\n \" },\",\n ];\n if (declaration.target === \"app\") {\n lines.push(\n envBlock.length === 0\n ? \"const app = defineApp();\"\n : [\"const app = defineApp({\", ...envBlock, \"});\"].join(\"\\n\"),\n );\n } else {\n lines.push(\n envBlock.length === 0\n ? `const component = defineComponent(${quote(declaration.name)});`\n : [\n `const component = defineComponent(${quote(declaration.name)}, {`,\n ...envBlock,\n \"});\",\n ].join(\"\\n\"),\n );\n }\n\n for (const mount of declaration.mounts) {\n lines.push(\"\");\n lines.push(`${self}.use(${aliases.get(mount.importPath)}, {`);\n lines.push(` name: ${quote(mount.name)},`);\n if (mount.httpPrefix !== undefined) {\n lines.push(` httpPrefix: ${quote(mount.httpPrefix)},`);\n }\n if (mount.env.length > 0) {\n lines.push(\" env: {\");\n for (const [slot, binding] of mount.env) {\n lines.push(\n ` ${slot}: ${binding.kind === \"value\" ? quote(binding.value) : `${self}.env.${binding.key}`},`,\n );\n }\n lines.push(\" },\");\n }\n lines.push(\"});\");\n }\n\n lines.push(\"\", `export default ${self};`, \"\");\n return lines.join(\"\\n\");\n};\n\nconst providerValue = (value: ProviderValue): string =>\n value.kind === \"value\"\n ? quote(value.value)\n : `\\`\\${process.env.CONVEX_SITE_URL}${value.path.replaceAll(/[`$\\\\]/g, \"\\\\$&\")}\\``;\n\n/**\n * `convex/auth.config.ts`: Convex's provider list, with site URLs resolved\n * there.\n */\nexport const authConfig = (providers: ReadonlyArray<Provider>): string =>\n [\n header(\"confect/auth.ts\"),\n 'import type { AuthConfig } from \"convex/server\";',\n \"\",\n \"export default {\",\n providers.length === 0 ? \" providers: [],\" : \" providers: [\",\n ...(providers.length === 0\n ? []\n : [\n ...providers.flatMap((provider) => [\n \" {\",\n ...provider.map(\n ([field, value]) => ` ${field}: ${providerValue(value)},`,\n ),\n \" },\",\n ]),\n \" ],\",\n ]),\n \"} satisfies AuthConfig;\",\n \"\",\n ].join(\"\\n\");\n\n/**\n * `confect/_generated/manifest.ts`: plain data, no imports, for infra.\n */\nexport const manifest = (declaration: Declaration, digest: string): string => {\n const data = {\n name: declaration.name,\n env: Object.fromEntries(declaration.env),\n http: {\n mounts: Object.fromEntries(\n declaration.mounts.flatMap(({ name, httpPrefix }) =>\n httpPrefix === undefined ? [] : [[name, httpPrefix]],\n ),\n ),\n },\n digest,\n };\n return `${header(\"confect/env.ts and confect/app.ts\")}\\n\\nexport default ${JSON.stringify(data, null, 2)} as const;\\n`;\n};\n\n/**\n * A digest of the declaration's inputs: every first-party file its modules\n * import (by project-relative path and contents) and the versions of the\n * packages that shape the generated output.\n */\nexport const digest = (input: {\n readonly files: ReadonlyArray<readonly [string, string]>;\n readonly versions: ReadonlyArray<readonly [string, string]>;\n}): string => {\n const hash = createHash(\"sha256\");\n const byFirst = (\n a: readonly [string, string],\n b: readonly [string, string],\n ) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);\n hash.update(\n JSON.stringify({\n files: [...input.files].sort(byFirst),\n versions: [...input.versions].sort(byFirst),\n }),\n );\n return `sha256:${hash.digest(\"hex\")}`;\n};\n"],"mappings":";;;;;;;AAuCA,IAAa,kBAAb,cAAqC,KAAK,YAAY,iBAAiB,CAAC,CAGrE;CACD,IAAa,UAAkB;EAC7B,OAAO,GAAG,KAAK,KAAK,uBAAuB,KAAK,SAAS;CAC3D;AACF;AAEA,IAAa,gBAAb,cAAmC,KAAK,YAAY,eAAe,CAAC,CAEjE;CACD,IAAa,UAAkB;EAC7B,OAAO,IAAI,KAAK,IAAI;CACtB;AACF;AAEA,IAAa,mBAAb,cAAsC,KAAK,YAAY,kBAAkB,CAAC,CAEvE;CACD,IAAa,UAAkB;EAC7B,OAAO,IAAI,KAAK,MAAM;CACxB;AACF;AAEA,IAAa,oBAAb,cAAuC,KAAK,YAAY,mBAAmB,CAAC,CAMzE;CACD,IAAa,UAAkB;EAC7B,OAAO,cAAc,KAAK,MAAM,UAAU,KAAK,KAAK,MAAM,KAAK,IAAI,WAAW,KAAK,QAAQ,oCAAoC,KAAK,gBAAgB;CACtJ;AACF;AAEA,IAAa,iBAAb,cAAoC,KAAK,YAAY,gBAAgB,CAAC,CAGnE;CACD,IAAa,UAAkB;EAC7B,OAAO,cAAc,KAAK,MAAM,UAAU,KAAK,KAAK;CACtD;AACF;AAEA,IAAa,yBAAb,cAA4C,KAAK,YAC/C,wBACF,CAAC,CAA6B;CAC5B,IAAa,UAAkB;EAC7B,OAAO,cAAc,KAAK,MAAM;CAClC;AACF;AAEA,IAAa,wBAAb,cAA2C,KAAK,YAC9C,uBACF,CAAC,CAAiE;CAChE,IAAa,UAAkB;EAC7B,OAAO,0CAA0C,KAAK,QAAQ,0CAA0C,KAAK,gBAAgB;CAC/H;AACF;AAWA,MAAM,UAAU;AAChB,MAAM,aAAa;;;;AAKnB,MAAa,UAAU,UACrB,MAAM,SAAS,oBACX,MAAM,OACN,MAAM,SAAS,0BACb,oBACA;;;;;;AAe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,MAAM,iBAAiB,UACrB,MAAM,SAAS,UACX,MAAM,MAAM,KAAK,IACjB,oCAAoC,MAAM,KAAK,WAAW,WAAW,MAAM,EAAE;;;;;AAMnF,MAAa,cAAc,cACzB;CACE,OAAO,iBAAiB;CACxB;CACA;CACA;CACA,UAAU,WAAW,IAAI,qBAAqB;CAC9C,GAAI,UAAU,WAAW,IACrB,CAAC,IACD,CACE,GAAG,UAAU,SAAS,aAAa;EACjC;EACA,GAAG,SAAS,KACT,CAAC,OAAO,WAAW,SAAS,MAAM,IAAI,cAAc,KAAK,EAAE,EAC9D;EACA;CACF,CAAC,GACD,MACF;CACJ;CACA;AACF,CAAC,CAAC,KAAK,IAAI;;;;AAKb,MAAa,YAAY,aAA0B,WAA2B;CAC5E,MAAM,OAAO;EACX,MAAM,YAAY;EAClB,KAAK,OAAO,YAAY,YAAY,GAAG;EACvC,MAAM,EACJ,QAAQ,OAAO,YACb,YAAY,OAAO,SAAS,EAAE,MAAM,iBAClC,eAAe,KAAA,IAAY,CAAC,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,CACrD,CACF,EACF;EACA;CACF;CACA,OAAO,GAAG,OAAO,mCAAmC,EAAE,qBAAqB,KAAK,UAAU,MAAM,MAAM,CAAC,EAAE;AAC3G;;;;;;AAOA,MAAa,UAAU,UAGT;CACZ,MAAM,OAAO,WAAW,QAAQ;CAChC,MAAM,WACJ,GACA,MACI,EAAE,KAAK,EAAE,KAAK,KAAK,EAAE,KAAK,EAAE,KAAK,IAAI;CAC3C,KAAK,OACH,KAAK,UAAU;EACb,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC,CAAC,KAAK,OAAO;EACpC,UAAU,CAAC,GAAG,MAAM,QAAQ,CAAC,CAAC,KAAK,OAAO;CAC5C,CAAC,CACH;CACA,OAAO,UAAU,KAAK,OAAO,KAAK;AACpC"}
1
+ {"version":3,"file":"Declaration.mjs","names":[],"sources":["../src/Declaration.ts"],"sourcesContent":["import { App, Auth, Env } from \"@confect/core\";\nimport * as Data from \"effect/Data\";\nimport * as Option from \"effect/Option\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\n// oxlint-disable-next-line effecttsgo/node-builtin-import -- a synchronous hash of in-memory strings in a pure function; Effect's Crypto is a service.\nimport { createHash } from \"node:crypto\";\n\n/**\n * A backend's declaration (`confect/env.ts`, `app.ts`, `auth.ts`) reduced to\n * the plain data codegen renders. The evaluated modules are parsed into this\n * once, at {@link parse}; every renderer below is a pure function of it.\n */\nexport interface Declaration {\n readonly target: \"app\" | \"component\";\n readonly name: string;\n readonly env: ReadonlyArray<readonly [string, Env.Descriptor]>;\n readonly mounts: ReadonlyArray<Mount>;\n readonly providers: Option.Option<ReadonlyArray<Provider>>;\n}\n\nexport interface Mount {\n readonly name: string;\n readonly importPath: string;\n readonly componentName: string;\n readonly httpPrefix: string | undefined;\n readonly env: ReadonlyArray<readonly [string, Binding]>;\n}\n\nexport type Binding =\n | { readonly kind: \"value\"; readonly value: string }\n | { readonly kind: \"env\"; readonly key: string };\n\nexport type ProviderValue =\n | { readonly kind: \"value\"; readonly value: string }\n | { readonly kind: \"siteUrl\" | \"cloudUrl\"; readonly path: string }\n | { readonly kind: \"env\"; readonly key: string };\n\nexport type Provider = ReadonlyArray<readonly [string, ProviderValue]>;\n\nexport class NotADeclaration extends Data.TaggedError(\"NotADeclaration\")<{\n readonly file: string;\n readonly expected: string;\n}> {\n override get message(): string {\n return `${this.file} must default-export ${this.expected}.`;\n }\n}\n\nexport class InvalidEnvKey extends Data.TaggedError(\"InvalidEnvKey\")<{\n readonly key: string;\n}> {\n override get message(): string {\n return `\"${this.key}\" is not a valid Convex environment variable name; use letters, digits and underscores, starting with a letter.`;\n }\n}\n\nexport class InvalidMountName extends Data.TaggedError(\"InvalidMountName\")<{\n readonly mount: string;\n}> {\n override get message(): string {\n return `\"${this.mount}\" is not a valid mount name; use letters, digits and underscores, starting with a letter or underscore.`;\n }\n}\n\nexport class ForeignEnvBinding extends Data.TaggedError(\"ForeignEnvBinding\")<{\n readonly mount: string;\n readonly slot: string;\n readonly backend: string;\n readonly key: string;\n readonly expectedBackend: string;\n}> {\n override get message(): string {\n return `The mount \"${this.mount}\" binds ${this.slot} to ${this.key} of the \"${this.backend}\" env, but this backend's env is \"${this.expectedBackend}\".`;\n }\n}\n\nexport class InvalidBinding extends Data.TaggedError(\"InvalidBinding\")<{\n readonly mount: string;\n readonly slot: string;\n}> {\n override get message(): string {\n return `The mount \"${this.mount}\" binds ${this.slot} to something other than a string or an entry of this backend's env.`;\n }\n}\n\nexport class UnknownComponentImport extends Data.TaggedError(\n \"UnknownComponentImport\",\n)<{ readonly mount: string }> {\n override get message(): string {\n return `The mount \"${this.mount}\" must pass the default export of a component's convex.config module, imported directly in the declaration.`;\n }\n}\n\nexport class AuthForAnotherBackend extends Data.TaggedError(\n \"AuthForAnotherBackend\",\n)<{ readonly backend: string; readonly expectedBackend: string }> {\n override get message(): string {\n return `confect/auth.ts declares auth for the \"${this.backend}\" backend, but confect/app.ts declares \"${this.expectedBackend}\".`;\n }\n}\n\nexport class InvalidProviderEnv extends Data.TaggedError(\"InvalidProviderEnv\")<{\n readonly field: string;\n readonly key: string;\n readonly backend: string;\n}> {\n override get message(): string {\n return `Auth provider field \"${this.field}\" requires a non-secret, required string entry of the \"${this.backend}\" env; got \"${this.key}\".`;\n }\n}\n\nexport type DeclarationError =\n | NotADeclaration\n | InvalidEnvKey\n | InvalidMountName\n | ForeignEnvBinding\n | InvalidBinding\n | UnknownComponentImport\n | AuthForAnotherBackend\n | InvalidProviderEnv;\n\nconst ENV_KEY = /^[A-Za-z][A-Za-z0-9_]*$/;\nconst MOUNT_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;\n\n/**\n * The declaration file a parse error is about.\n */\nexport const fileOf = (error: DeclarationError): string =>\n error._tag === \"NotADeclaration\"\n ? error.file\n : error._tag === \"AuthForAnotherBackend\" ||\n error._tag === \"InvalidProviderEnv\"\n ? \"confect/auth.ts\"\n : \"confect/app.ts\";\n\n/**\n * A mounted component's import as the generated `convex.config.ts` writes it.\n */\nexport interface ComponentImport {\n readonly importPath: string;\n readonly componentName: string;\n}\n\n/**\n * Parse the default exports of `confect/app.ts` and, when present,\n * `confect/auth.ts`. `componentImport` recovers how the generated config\n * imports a mounted definition; codegen's bundler records it.\n */\nexport const parse = (input: {\n readonly target: \"app\" | \"component\";\n readonly app: unknown;\n readonly auth: Option.Option<unknown>;\n readonly componentImport: (\n definition: unknown,\n ) => Option.Option<ComponentImport>;\n}): Result.Result<Declaration, DeclarationError> =>\n Result.gen(function* () {\n if (!App.isApp(input.app)) {\n return yield* Result.fail(\n new NotADeclaration({\n file: \"confect/app.ts\",\n expected: \"App.make(...)\",\n }),\n );\n }\n const env = App.env(input.app);\n const name = Env.name(env);\n const descriptors = Env.descriptors(env);\n for (const [key] of descriptors) {\n if (!ENV_KEY.test(key))\n return yield* Result.fail(new InvalidEnvKey({ key }));\n }\n\n const mounts: Array<Mount> = [];\n for (const mount of App.mounts(input.app)) {\n if (!MOUNT_NAME.test(mount.name)) {\n return yield* Result.fail(new InvalidMountName({ mount: mount.name }));\n }\n const component = input.componentImport(mount.definition);\n if (Option.isNone(component)) {\n return yield* Result.fail(\n new UnknownComponentImport({ mount: mount.name }),\n );\n }\n const bindings: Array<readonly [string, Binding]> = [];\n for (const [slot, bound] of Object.entries(mount.env)) {\n if (bound === undefined) continue;\n if (typeof bound === \"string\") {\n bindings.push([slot, { kind: \"value\", value: bound }]);\n continue;\n }\n if (!Env.isEntry(bound)) {\n return yield* Result.fail(\n new InvalidBinding({ mount: mount.name, slot }),\n );\n }\n const origin = Env.origin(bound);\n if (origin.backend !== name) {\n return yield* Result.fail(\n new ForeignEnvBinding({\n mount: mount.name,\n slot,\n backend: origin.backend,\n key: origin.key,\n expectedBackend: name,\n }),\n );\n }\n bindings.push([slot, { kind: \"env\", key: origin.key }]);\n }\n mounts.push({\n name: mount.name,\n importPath: component.value.importPath,\n componentName: component.value.componentName,\n httpPrefix: mount.httpPrefix,\n env: bindings,\n });\n }\n\n const providers: Option.Option<ReadonlyArray<Provider>> = Option.isNone(\n input.auth,\n )\n ? Option.none()\n : Option.some(yield* parseProviders(input.auth.value, name));\n\n return {\n target: input.target,\n name,\n env: descriptors,\n mounts,\n providers,\n };\n });\n\nconst parseProviders = (\n auth: unknown,\n backend: string,\n): Result.Result<ReadonlyArray<Provider>, DeclarationError> => {\n if (!Auth.isAuth(auth)) {\n return Result.fail(\n new NotADeclaration({\n file: \"confect/auth.ts\",\n expected: \"Auth.make(app, ...)\",\n }),\n );\n }\n const authBackend = Env.name(App.env(auth.app));\n if (authBackend !== backend) {\n return Result.fail(\n new AuthForAnotherBackend({\n backend: authBackend,\n expectedBackend: backend,\n }),\n );\n }\n return Result.gen(function* () {\n const providers: Provider[] = [];\n for (const provider of Auth.providers(auth)) {\n const fields: Array<readonly [string, ProviderValue]> = [];\n for (const [field, value] of Object.entries(provider)) {\n const sitePath = Auth.siteUrlPath(value);\n const cloudPath = Auth.cloudUrlPath(value);\n let lowered: ProviderValue;\n if (Env.isEntry(value)) {\n const { backend: owner, key } = Env.origin(value);\n const descriptor = value[\"~@confect/core/Env/Entry\"].descriptor;\n if (\n owner !== backend ||\n descriptor.optional ||\n descriptor.kind === \"secret\" ||\n !ENV_KEY.test(key)\n ) {\n return yield* Result.fail(\n new InvalidProviderEnv({ field, key, backend }),\n );\n }\n lowered = { kind: \"env\", key };\n } else if (sitePath !== undefined) {\n lowered = { kind: \"siteUrl\", path: sitePath };\n } else if (cloudPath !== undefined) {\n lowered = { kind: \"cloudUrl\", path: cloudPath };\n } else {\n lowered = {\n kind: \"value\",\n value: Predicate.isString(value) ? value : JSON.stringify(value),\n };\n }\n fields.push([field, lowered]);\n }\n providers.push(fields);\n }\n return providers;\n });\n};\n\nconst quote = (value: string): string => JSON.stringify(value);\n\nexport const header = (source: string): string =>\n `// Generated by \\`confect codegen\\` from ${source}. Do not edit.`;\n\nconst GENERATED_PREFIX = \"// Generated by `confect codegen` from \";\n\n/**\n * Whether codegen may overwrite or remove an existing file: it carries the\n * generated header, or it is exactly one of the files an earlier codegen wrote\n * there (`legacy`).\n */\nexport const isGenerated = (\n contents: string,\n legacy: ReadonlyArray<string>,\n): boolean =>\n contents.startsWith(GENERATED_PREFIX) || legacy.includes(contents);\n\nconst validator = (descriptor: Env.Descriptor): string => {\n const base =\n descriptor.kind === \"literals\"\n ? descriptor.values.length === 1\n ? `v.literal(${quote(descriptor.values[0])})`\n : `v.union(${descriptor.values.map((value) => `v.literal(${quote(value)})`).join(\", \")})`\n : \"v.string()\";\n return descriptor.optional ? `v.optional(${base})` : base;\n};\n\nconst RESERVED = new Set(\n \"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 static super switch this throw true try typeof var void while with yield\".split(\n \" \",\n ),\n);\n\n/**\n * A safe import name for a component, from its Convex name.\n */\nconst identifier = (name: string): string => {\n const cleaned = name.replaceAll(/[^A-Za-z0-9_$]/g, \"_\");\n const valid = /^[A-Za-z_$]/.test(cleaned) ? cleaned : `_${cleaned}`;\n return RESERVED.has(valid) ? `${valid}Component` : valid;\n};\n\n/**\n * `convex/convex.config.ts`: Convex's own app or component definition.\n */\nexport const convexConfig = (declaration: Declaration): string => {\n const self = declaration.target === \"app\" ? \"app\" : \"component\";\n const aliases = new Map<string, string>();\n const taken = new Set([self, \"v\", \"defineApp\", \"defineComponent\"]);\n for (const mount of declaration.mounts) {\n if (aliases.has(mount.importPath)) continue;\n const base = identifier(mount.componentName);\n let alias = base;\n for (let n = 2; taken.has(alias); n++) alias = `${base}${n}`;\n taken.add(alias);\n aliases.set(mount.importPath, alias);\n }\n\n const lines = [header(\"confect/app.ts\")];\n lines.push(\n declaration.target === \"app\"\n ? 'import { defineApp } from \"convex/server\";'\n : 'import { defineComponent } from \"convex/server\";',\n );\n if (declaration.env.length > 0)\n lines.push('import { v } from \"convex/values\";');\n for (const [importPath, alias] of aliases) {\n lines.push(`import ${alias} from ${quote(importPath)};`);\n }\n lines.push(\"\");\n\n const envBlock =\n declaration.env.length === 0\n ? []\n : [\n \" env: {\",\n ...declaration.env.map(\n ([key, descriptor]) => ` ${key}: ${validator(descriptor)},`,\n ),\n \" },\",\n ];\n if (declaration.target === \"app\") {\n lines.push(\n envBlock.length === 0\n ? \"const app = defineApp();\"\n : [\"const app = defineApp({\", ...envBlock, \"});\"].join(\"\\n\"),\n );\n } else {\n lines.push(\n envBlock.length === 0\n ? `const component = defineComponent(${quote(declaration.name)});`\n : [\n `const component = defineComponent(${quote(declaration.name)}, {`,\n ...envBlock,\n \"});\",\n ].join(\"\\n\"),\n );\n }\n\n for (const mount of declaration.mounts) {\n lines.push(\"\");\n lines.push(`${self}.use(${aliases.get(mount.importPath)}, {`);\n lines.push(` name: ${quote(mount.name)},`);\n if (mount.httpPrefix !== undefined) {\n lines.push(` httpPrefix: ${quote(mount.httpPrefix)},`);\n }\n if (mount.env.length > 0) {\n lines.push(\" env: {\");\n for (const [slot, binding] of mount.env) {\n lines.push(\n ` ${slot}: ${binding.kind === \"value\" ? quote(binding.value) : `${self}.env.${binding.key}`},`,\n );\n }\n lines.push(\" },\");\n }\n lines.push(\"});\");\n }\n\n lines.push(\"\", `export default ${self};`, \"\");\n return lines.join(\"\\n\");\n};\n\nconst providerValue = (value: ProviderValue): string => {\n switch (value.kind) {\n case \"value\":\n return quote(value.value);\n case \"env\":\n return `process.env[${quote(value.key)}]!`;\n default:\n return `\\`\\${process.env.${value.kind === \"siteUrl\" ? \"CONVEX_SITE_URL\" : \"CONVEX_CLOUD_URL\"}}${value.path.replaceAll(/[`$\\\\]/g, \"\\\\$&\")}\\``;\n }\n};\n\n/**\n * `convex/auth.config.ts`: Convex's provider list, with site URLs resolved\n * there.\n */\nexport const authConfig = (providers: ReadonlyArray<Provider>): string =>\n [\n header(\"confect/auth.ts\"),\n 'import type { AuthConfig } from \"convex/server\";',\n \"\",\n \"export default {\",\n providers.length === 0 ? \" providers: [],\" : \" providers: [\",\n ...(providers.length === 0\n ? []\n : [\n ...providers.flatMap((provider) => [\n \" {\",\n ...provider\n .filter(([field]) => field !== \"family\" && field !== \"name\")\n .map(\n ([field, value]) => ` ${field}: ${providerValue(value)},`,\n ),\n \" },\",\n ]),\n \" ],\",\n ]),\n \"} satisfies AuthConfig;\",\n \"\",\n ].join(\"\\n\");\n\n/**\n * Runtime issuer data with no dependency on declarations or component\n * definitions.\n */\nexport const authProviders = (providers: ReadonlyArray<Provider>): string =>\n [\n header(\"confect/auth.ts\"),\n \"\",\n \"export const providers = [\",\n ...providers.flatMap((provider) => [\n \" {\",\n ...provider.flatMap(([field, value]) => {\n const key =\n field === \"domain\"\n ? \"issuer\"\n : field === \"applicationID\"\n ? \"audience\"\n : field;\n return [\"issuer\", \"audience\", \"family\", \"name\"].includes(key)\n ? [` ${key}: ${providerValue(value)},`]\n : [];\n }),\n \" },\",\n ]),\n \"] as const;\",\n \"\",\n ].join(\"\\n\");\n\n/**\n * `confect/_generated/manifest.ts`: plain data, no imports, for infra.\n */\nexport const manifest = (declaration: Declaration, digest: string): string => {\n const data = {\n name: declaration.name,\n env: Object.fromEntries(declaration.env),\n http: {\n mounts: Object.fromEntries(\n declaration.mounts.flatMap(({ name, httpPrefix }) =>\n httpPrefix === undefined ? [] : [[name, httpPrefix]],\n ),\n ),\n },\n digest,\n };\n return `${header(\"confect/env.ts and confect/app.ts\")}\\n\\nexport default ${JSON.stringify(data, null, 2)} as const;\\n`;\n};\n\n/**\n * A digest of the declaration's inputs: every first-party file its modules\n * import (by project-relative path and contents) and the versions of the\n * packages that shape the generated output.\n */\nexport const digest = (input: {\n readonly files: ReadonlyArray<readonly [string, string]>;\n readonly versions: ReadonlyArray<readonly [string, string]>;\n}): string => {\n const hash = createHash(\"sha256\");\n const byFirst = (\n a: readonly [string, string],\n b: readonly [string, string],\n ) => (a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0);\n hash.update(\n JSON.stringify({\n files: [...input.files].sort(byFirst),\n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KAAK;AACpC"}
@@ -8,7 +8,7 @@ import { ConfectDirectory } from "../ConfectDirectory.mjs";
8
8
  import { authConfig, declaredHttp, http } from "../templates.mjs";
9
9
  import { removePathIfExists, toModuleImportPath, toPosixPath, writeFileString, writeFileStringAndLog } from "../utils.mjs";
10
10
  import { CONVEX_CONFIG_FILENAME, componentConfigPlugin, componentImportOf } from "../ConvexConfig.mjs";
11
- import { authConfig as authConfig$1, convexConfig, digest, fileOf, isGenerated, manifest, parse } from "../Declaration.mjs";
11
+ import { authConfig as authConfig$1, authProviders, convexConfig, digest, fileOf, isGenerated, manifest, parse } from "../Declaration.mjs";
12
12
  import * as Effect from "effect/Effect";
13
13
  import { App, Http } from "@confect/core";
14
14
  import * as FileSystem from "effect/FileSystem";
@@ -22,7 +22,7 @@ import * as Predicate from "effect/Predicate";
22
22
  * Bumped when the generated files change shape, so a manifest written by an
23
23
  * older generator never matches a current one.
24
24
  */
25
- const GENERATOR_FORMAT = "1";
25
+ const GENERATOR_FORMAT = "2";
26
26
  const confectPath = Effect.fnUntraced(function* (file) {
27
27
  return (yield* Path.Path).join(yield* ConfectDirectory.get, file);
28
28
  });
@@ -117,6 +117,12 @@ const removeGenerated = Effect.fnUntraced(function* (filePath, legacy) {
117
117
  const removeManifest = Effect.gen(function* () {
118
118
  yield* removeGenerated(yield* manifestPath, []);
119
119
  });
120
+ const authProvidersPath = Effect.gen(function* () {
121
+ return (yield* Path.Path).join(yield* ConfectDirectory.get, "_generated", "auth.providers.ts");
122
+ });
123
+ const removeAuthProviders = Effect.gen(function* () {
124
+ yield* removeGenerated(yield* authProvidersPath, []);
125
+ });
120
126
  const writeDeclaration = Effect.gen(function* () {
121
127
  const fs = yield* FileSystem.FileSystem;
122
128
  const path = yield* Path.Path;
@@ -157,12 +163,16 @@ const writeDeclaration = Effect.gen(function* () {
157
163
  yield* writeFileStringAndLog(convexConfigPath, convexConfig(declaration));
158
164
  yield* Option.match(declaration.providers, {
159
165
  onNone: () => Effect.gen(function* () {
166
+ yield* removeAuthProviders;
160
167
  if (yield* fs.exists(authConfigPath)) {
161
168
  yield* removePathIfExists(authConfigPath);
162
169
  yield* logFileRemoved(authConfigPath);
163
170
  }
164
171
  }),
165
- onSome: (providers) => writeFileStringAndLog(authConfigPath, authConfig$1(providers))
172
+ onSome: (providers) => Effect.gen(function* () {
173
+ yield* writeFileStringAndLog(authConfigPath, authConfig$1(providers));
174
+ yield* writeFileStringAndLog(yield* authProvidersPath, authProviders(providers));
175
+ })
166
176
  });
167
177
  return App.isApp(appValue) ? Option.some(appValue) : Option.none();
168
178
  });
@@ -175,9 +185,10 @@ const writeDeclaration = Effect.gen(function* () {
175
185
  const syncDeclaration = Effect.gen(function* () {
176
186
  if (!(yield* isDeclared)) {
177
187
  yield* removeManifest;
188
+ yield* removeAuthProviders;
178
189
  return Option.none();
179
190
  }
180
- return yield* writeDeclaration.pipe(Effect.tapError(() => removeManifest));
191
+ return yield* writeDeclaration.pipe(Effect.tapError(() => removeManifest.pipe(Effect.andThen(removeAuthProviders))));
181
192
  });
182
193
  /**
183
194
  * Check every HTTP route the backend serves and write `convex/http.ts` from
@@ -1 +1 @@
1
- {"version":3,"file":"declaration.mjs","names":["Bundler.bundle","ConvexConfig.componentConfigPlugin","Declaration.isGenerated","Bundler.resolveModule","ConvexConfig.componentImportOf","Declaration.parse","Declaration.fileOf","ConvexConfig.CONVEX_CONFIG_FILENAME","templates.authConfig","digest","Declaration.digest","Declaration.manifest","Declaration.convexConfig","Declaration.authConfig","templates.http","http","templates.declaredHttp"],"sources":["../../src/confect/declaration.ts"],"sourcesContent":["import { App, Http } from \"@confect/core\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport { fromBundlerError } from \"../BuildError.js\";\nimport * as Bundler from \"../Bundler.js\";\nimport {\n HandWrittenConvexFileError,\n DeclarationKindMismatchError,\n InvalidDeclarationError,\n} from \"../CodegenError.js\";\nimport { ConfectDirectory } from \"../ConfectDirectory.js\";\nimport * as ConvexConfig from \"../ConvexConfig.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as Declaration from \"../Declaration.js\";\nimport { logFileRemoved } from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport * as templates from \"../templates.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n writeFileString,\n writeFileStringAndLog,\n} from \"../utils.js\";\n\n/**\n * Bumped when the generated files change shape, so a manifest written by an\n * older generator never matches a current one.\n */\nconst GENERATOR_FORMAT = \"1\";\n\nconst confectPath = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, file);\n});\n\n/**\n * A backend opts in to the declaration by writing `confect/app.ts`.\n */\nexport const isDeclared = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n return yield* fs.exists(yield* confectPath(\"app.ts\"));\n});\n\nconst displayPath = Effect.fnUntraced(function* (absolutePath: string) {\n const path = yield* Path.Path;\n return toPosixPath(path, path.relative(yield* ProjectRoot.get, absolutePath));\n});\n\nconst bundleDeclaration = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n const absolutePath = yield* confectPath(file);\n return yield* Bundler.bundle(absolutePath, {\n plugins: [ConvexConfig.componentConfigPlugin(path)],\n }).pipe(\n Effect.mapError((error) => fromBundlerError(`confect/${file}`, error)),\n );\n});\n\nconst invalid = (file: string) => (error: { readonly message: string }) =>\n new InvalidDeclarationError({\n declarationPath: `confect/${file}`,\n reason: error.message,\n });\n\n/**\n * Fail instead of overwriting a Convex file someone wrote by hand. A file with\n * the generated header, or one of the exact files an earlier codegen wrote\n * there, is ours to replace.\n */\nconst assertOwned = Effect.fnUntraced(function* (\n convexPath: string,\n declarationFile: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(convexPath))) return;\n if (Declaration.isGenerated(yield* fs.readFileString(convexPath), legacy)) {\n return;\n }\n return yield* new HandWrittenConvexFileError({\n convexPath: yield* displayPath(convexPath),\n declarationPath: `confect/${declarationFile}`,\n });\n});\n\nconst decodeVersion = Schema.decodeUnknownOption(\n Schema.fromJsonString(Schema.Struct({ version: Schema.String })),\n);\n\nconst packageVersion = Effect.fnUntraced(function* (\n name: string,\n from: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n return yield* Option.match(\n Bundler.resolveModule(`${name}/package.json`, path.join(from, \"_\")),\n {\n onNone: () => Effect.succeed(\"unresolved\"),\n onSome: (packageJson) =>\n fs.readFileString(packageJson).pipe(\n Effect.map((contents) =>\n Option.match(decodeVersion(contents), {\n onNone: () => \"unknown\",\n onSome: ({ version }) => version,\n }),\n ),\n ),\n },\n );\n});\n\n/**\n * Every first-party file the declaration modules import, by project-relative\n * path and contents. Files under `node_modules` and outside the project count\n * through package versions instead, so rebuilding a dependency does not change\n * the digest.\n */\nconst declarationInputs = Effect.fnUntraced(function* (\n bundles: ReadonlyArray<Bundler.Bundled>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const projectRoot = yield* ProjectRoot.get;\n const files = new Set<string>();\n for (const { metafile } of bundles) {\n for (const input of Object.keys(metafile.inputs)) {\n const relative = path.relative(projectRoot, input);\n if (\n path.isAbsolute(input) &&\n !relative.startsWith(\"..\") &&\n !relative.split(path.sep).includes(\"node_modules\")\n ) {\n files.add(input);\n }\n }\n }\n // Plugin namespaces (component config wrappers) appear as inputs too;\n // only real files count.\n const real = yield* Effect.filter([...files], (file) => fs.exists(file));\n return yield* Effect.forEach(real, (file) =>\n fs\n .readFileString(file)\n .pipe(\n Effect.map(\n (contents) =>\n [\n toPosixPath(path, path.relative(projectRoot, file)),\n contents,\n ] as const,\n ),\n ),\n );\n});\n\nconst componentImport = Effect.fnUntraced(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n return (definition: unknown): Option.Option<Declaration.ComponentImport> =>\n Option.map(ConvexConfig.componentImportOf(definition), (recorded) => {\n const bare =\n !recorded.specifier.startsWith(\".\") &&\n !path.isAbsolute(recorded.specifier);\n const relative = toPosixPath(\n path,\n path.relative(convexDirectory, recorded.path),\n ).replace(/\\.([cm]?)[jt]s$/, \".$1js\");\n return {\n importPath: bare\n ? recorded.specifier\n : relative.startsWith(\".\")\n ? relative\n : `./${relative}`,\n componentName:\n Predicate.hasProperty(definition, \"defaultName\") &&\n Predicate.isString(definition.defaultName)\n ? definition.defaultName\n : \"component\",\n };\n });\n});\n\nconst manifestPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, \"_generated\", \"manifest.ts\");\n});\n\n/**\n * Remove a file codegen wrote whose source is gone; leave anything else.\n */\nconst removeGenerated = Effect.fnUntraced(function* (\n filePath: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) return;\n if (!Declaration.isGenerated(yield* fs.readFileString(filePath), legacy)) {\n return;\n }\n yield* removePathIfExists(filePath);\n yield* logFileRemoved(filePath);\n});\n\nconst removeManifest = Effect.gen(function* () {\n yield* removeGenerated(yield* manifestPath, []);\n});\n\nconst writeDeclaration = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const target = (yield* ConvexDirectory.target).kind;\n\n const app = yield* bundleDeclaration(\"app.ts\");\n const appValue: unknown = app.module.default;\n if (App.isApp(appValue) && appValue.kind !== target) {\n return yield* new DeclarationKindMismatchError({\n declarationPath: \"confect/app.ts\",\n declaredKind: appValue.kind,\n targetKind: target,\n });\n }\n const authPath = yield* confectPath(\"auth.ts\");\n const auth = (yield* fs.exists(authPath))\n ? Option.some(yield* bundleDeclaration(\"auth.ts\"))\n : Option.none();\n\n const declaration = yield* Declaration.parse({\n target,\n app: app.module.default,\n auth: Option.map(auth, ({ module }) => module.default),\n componentImport: yield* componentImport(),\n }).pipe(\n Result.mapError(\n (error) =>\n new InvalidDeclarationError({\n declarationPath: Declaration.fileOf(error),\n reason: error.message,\n }),\n ),\n Effect.fromResult,\n );\n\n const convexConfigPath = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n const authConfigPath = path.join(convexDirectory, \"auth.config.ts\");\n const authImportPath = yield* toModuleImportPath(\n path.relative(convexDirectory, authPath),\n );\n const legacyAuthConfigs = yield* Effect.forEach(\n [authImportPath, authImportPath.replace(/\\.js$/, \"\")],\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n );\n yield* assertOwned(convexConfigPath, \"app.ts\", []);\n yield* assertOwned(authConfigPath, \"auth.ts\", legacyAuthConfigs);\n\n if (target === \"app\") {\n const digest = Declaration.digest({\n files: yield* declarationInputs([app, ...Option.toArray(auth)]),\n versions: [\n [\"convex\", yield* packageVersion(\"convex\", projectRoot)],\n [\"@confect/cli generator format\", GENERATOR_FORMAT],\n ],\n });\n yield* writeFileStringAndLog(\n yield* manifestPath,\n Declaration.manifest(declaration, digest),\n );\n }\n yield* writeFileStringAndLog(\n convexConfigPath,\n Declaration.convexConfig(declaration),\n );\n yield* Option.match(declaration.providers, {\n onNone: () =>\n Effect.gen(function* () {\n if (yield* fs.exists(authConfigPath)) {\n yield* removePathIfExists(authConfigPath);\n yield* logFileRemoved(authConfigPath);\n }\n }),\n onSome: (providers) =>\n writeFileStringAndLog(authConfigPath, Declaration.authConfig(providers)),\n });\n return App.isApp(appValue) ? Option.some(appValue) : Option.none<App.Any>();\n});\n\n/**\n * Write the declaration's Convex files and manifest from `confect/app.ts`,\n * `confect/env.ts` and `confect/auth.ts`, before anything else is validated. On\n * any failure the previous manifest is removed, so a stale manifest never\n * outlives a declaration that no longer produces it.\n */\nexport const syncDeclaration = Effect.gen(function* () {\n if (!(yield* isDeclared)) {\n yield* removeManifest;\n return Option.none<App.Any>();\n }\n return yield* writeDeclaration.pipe(Effect.tapError(() => removeManifest));\n});\n\n/**\n * Check every HTTP route the backend serves and write `convex/http.ts` from\n * `confect/http.ts`. Runs after generation, because `http.ts` imports its\n * handlers, which import generated services.\n */\nexport const syncDeclaredHttp = (app: App.Any) =>\n checkAndWriteHttp(app).pipe(Effect.tapError(() => removeManifest));\n\nconst checkAndWriteHttp = Effect.fnUntraced(function* (app: App.Any) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const confectDirectory = yield* ConfectDirectory.get;\n const httpPath = yield* confectPath(\"http.ts\");\n\n const convexHttpPath = path.join(convexDirectory, \"http.ts\");\n if (!(yield* fs.exists(httpPath))) {\n yield* Http.routes(app).pipe(\n Result.mapError(invalid(\"app.ts\")),\n Effect.fromResult,\n );\n yield* removeGenerated(convexHttpPath, [\n yield* templates.http({\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n }),\n ]);\n return Option.none();\n }\n\n const http = (yield* bundleDeclaration(\"http.ts\")).module.default;\n if (!Http.isHttp(http)) {\n return yield* new InvalidDeclarationError({\n declarationPath: \"confect/http.ts\",\n reason: \"it must default-export Http.make(...).\",\n });\n }\n yield* Http.routes(app, http).pipe(\n Result.mapError(invalid(\"http.ts\")),\n Effect.fromResult,\n );\n\n const contents = yield* templates.declaredHttp({\n schemaImportPath: yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"_generated\", \"schema.ts\"),\n ),\n ),\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n });\n const change = yield* writeFileString(convexHttpPath, contents);\n return Option.some({ change, convexFilePath: convexHttpPath });\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAkCA,MAAM,mBAAmB;AAEzB,MAAM,cAAc,OAAO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ACnB,OAAO,OAAO,IAAI,wBAAwB;EACxC,iBAAiB;EACjB,QAAQ;CACV,CAAC;CAEH,OAAO,KAAK,OAAO,KAAKA,MAAI,CAAC,CAAC,KAC5B,OAAO,SAAS,QAAQ,SAAS,CAAC,GAClC,OAAO,UACT;CAEA,MAAM,WAAW,OAAOC,aAAuB;EAC7C,kBAAkB,OAAO,mBACvB,KAAK,SACH,iBACA,KAAK,KAAK,kBAAkB,cAAc,WAAW,CACvD,CACF;EACA,gBAAgB,OAAO,mBACrB,KAAK,SAAS,iBAAiB,QAAQ,CACzC;CACF,CAAC;CACD,MAAM,SAAS,OAAO,gBAAgB,gBAAgB,QAAQ;CAC9D,OAAO,OAAO,KAAK;EAAE;EAAQ,gBAAgB;CAAe,CAAC;AAC/D,CAAC"}
1
+ {"version":3,"file":"declaration.mjs","names":["Bundler.bundle","ConvexConfig.componentConfigPlugin","Declaration.isGenerated","Bundler.resolveModule","ConvexConfig.componentImportOf","Declaration.parse","Declaration.fileOf","ConvexConfig.CONVEX_CONFIG_FILENAME","templates.authConfig","digest","Declaration.digest","Declaration.manifest","Declaration.convexConfig","Declaration.authConfig","Declaration.authProviders","templates.http","http","templates.declaredHttp"],"sources":["../../src/confect/declaration.ts"],"sourcesContent":["import { App, Http } from \"@confect/core\";\nimport * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Option from \"effect/Option\";\nimport * as Path from \"effect/Path\";\nimport * as Predicate from \"effect/Predicate\";\nimport * as Result from \"effect/Result\";\nimport * as Schema from \"effect/Schema\";\nimport { fromBundlerError } from \"../BuildError.js\";\nimport * as Bundler from \"../Bundler.js\";\nimport {\n HandWrittenConvexFileError,\n DeclarationKindMismatchError,\n InvalidDeclarationError,\n} from \"../CodegenError.js\";\nimport { ConfectDirectory } from \"../ConfectDirectory.js\";\nimport * as ConvexConfig from \"../ConvexConfig.js\";\nimport { ConvexDirectory } from \"../ConvexDirectory.js\";\nimport * as Declaration from \"../Declaration.js\";\nimport { logFileRemoved } from \"../log.js\";\nimport { ProjectRoot } from \"../ProjectRoot.js\";\nimport * as templates from \"../templates.js\";\nimport {\n removePathIfExists,\n toModuleImportPath,\n toPosixPath,\n writeFileString,\n writeFileStringAndLog,\n} from \"../utils.js\";\n\n/**\n * Bumped when the generated files change shape, so a manifest written by an\n * older generator never matches a current one.\n */\nconst GENERATOR_FORMAT = \"2\";\n\nconst confectPath = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, file);\n});\n\n/**\n * A backend opts in to the declaration by writing `confect/app.ts`.\n */\nexport const isDeclared = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n return yield* fs.exists(yield* confectPath(\"app.ts\"));\n});\n\nconst displayPath = Effect.fnUntraced(function* (absolutePath: string) {\n const path = yield* Path.Path;\n return toPosixPath(path, path.relative(yield* ProjectRoot.get, absolutePath));\n});\n\nconst bundleDeclaration = Effect.fnUntraced(function* (file: string) {\n const path = yield* Path.Path;\n const absolutePath = yield* confectPath(file);\n return yield* Bundler.bundle(absolutePath, {\n plugins: [ConvexConfig.componentConfigPlugin(path)],\n }).pipe(\n Effect.mapError((error) => fromBundlerError(`confect/${file}`, error)),\n );\n});\n\nconst invalid = (file: string) => (error: { readonly message: string }) =>\n new InvalidDeclarationError({\n declarationPath: `confect/${file}`,\n reason: error.message,\n });\n\n/**\n * Fail instead of overwriting a Convex file someone wrote by hand. A file with\n * the generated header, or one of the exact files an earlier codegen wrote\n * there, is ours to replace.\n */\nconst assertOwned = Effect.fnUntraced(function* (\n convexPath: string,\n declarationFile: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(convexPath))) return;\n if (Declaration.isGenerated(yield* fs.readFileString(convexPath), legacy)) {\n return;\n }\n return yield* new HandWrittenConvexFileError({\n convexPath: yield* displayPath(convexPath),\n declarationPath: `confect/${declarationFile}`,\n });\n});\n\nconst decodeVersion = Schema.decodeUnknownOption(\n Schema.fromJsonString(Schema.Struct({ version: Schema.String })),\n);\n\nconst packageVersion = Effect.fnUntraced(function* (\n name: string,\n from: string,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n return yield* Option.match(\n Bundler.resolveModule(`${name}/package.json`, path.join(from, \"_\")),\n {\n onNone: () => Effect.succeed(\"unresolved\"),\n onSome: (packageJson) =>\n fs.readFileString(packageJson).pipe(\n Effect.map((contents) =>\n Option.match(decodeVersion(contents), {\n onNone: () => \"unknown\",\n onSome: ({ version }) => version,\n }),\n ),\n ),\n },\n );\n});\n\n/**\n * Every first-party file the declaration modules import, by project-relative\n * path and contents. Files under `node_modules` and outside the project count\n * through package versions instead, so rebuilding a dependency does not change\n * the digest.\n */\nconst declarationInputs = Effect.fnUntraced(function* (\n bundles: ReadonlyArray<Bundler.Bundled>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const projectRoot = yield* ProjectRoot.get;\n const files = new Set<string>();\n for (const { metafile } of bundles) {\n for (const input of Object.keys(metafile.inputs)) {\n const relative = path.relative(projectRoot, input);\n if (\n path.isAbsolute(input) &&\n !relative.startsWith(\"..\") &&\n !relative.split(path.sep).includes(\"node_modules\")\n ) {\n files.add(input);\n }\n }\n }\n // Plugin namespaces (component config wrappers) appear as inputs too;\n // only real files count.\n const real = yield* Effect.filter([...files], (file) => fs.exists(file));\n return yield* Effect.forEach(real, (file) =>\n fs\n .readFileString(file)\n .pipe(\n Effect.map(\n (contents) =>\n [\n toPosixPath(path, path.relative(projectRoot, file)),\n contents,\n ] as const,\n ),\n ),\n );\n});\n\nconst componentImport = Effect.fnUntraced(function* () {\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n return (definition: unknown): Option.Option<Declaration.ComponentImport> =>\n Option.map(ConvexConfig.componentImportOf(definition), (recorded) => {\n const bare =\n !recorded.specifier.startsWith(\".\") &&\n !path.isAbsolute(recorded.specifier);\n const relative = toPosixPath(\n path,\n path.relative(convexDirectory, recorded.path),\n ).replace(/\\.([cm]?)[jt]s$/, \".$1js\");\n return {\n importPath: bare\n ? recorded.specifier\n : relative.startsWith(\".\")\n ? relative\n : `./${relative}`,\n componentName:\n Predicate.hasProperty(definition, \"defaultName\") &&\n Predicate.isString(definition.defaultName)\n ? definition.defaultName\n : \"component\",\n };\n });\n});\n\nconst manifestPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(yield* ConfectDirectory.get, \"_generated\", \"manifest.ts\");\n});\n\n/**\n * Remove a file codegen wrote whose source is gone; leave anything else.\n */\nconst removeGenerated = Effect.fnUntraced(function* (\n filePath: string,\n legacy: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n if (!(yield* fs.exists(filePath))) return;\n if (!Declaration.isGenerated(yield* fs.readFileString(filePath), legacy)) {\n return;\n }\n yield* removePathIfExists(filePath);\n yield* logFileRemoved(filePath);\n});\n\nconst removeManifest = Effect.gen(function* () {\n yield* removeGenerated(yield* manifestPath, []);\n});\n\nconst authProvidersPath = Effect.gen(function* () {\n const path = yield* Path.Path;\n return path.join(\n yield* ConfectDirectory.get,\n \"_generated\",\n \"auth.providers.ts\",\n );\n});\n\nconst removeAuthProviders = Effect.gen(function* () {\n yield* removeGenerated(yield* authProvidersPath, []);\n});\n\nconst writeDeclaration = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const projectRoot = yield* ProjectRoot.get;\n const target = (yield* ConvexDirectory.target).kind;\n\n const app = yield* bundleDeclaration(\"app.ts\");\n const appValue: unknown = app.module.default;\n if (App.isApp(appValue) && appValue.kind !== target) {\n return yield* new DeclarationKindMismatchError({\n declarationPath: \"confect/app.ts\",\n declaredKind: appValue.kind,\n targetKind: target,\n });\n }\n const authPath = yield* confectPath(\"auth.ts\");\n const auth = (yield* fs.exists(authPath))\n ? Option.some(yield* bundleDeclaration(\"auth.ts\"))\n : Option.none();\n\n const declaration = yield* Declaration.parse({\n target,\n app: app.module.default,\n auth: Option.map(auth, ({ module }) => module.default),\n componentImport: yield* componentImport(),\n }).pipe(\n Result.mapError(\n (error) =>\n new InvalidDeclarationError({\n declarationPath: Declaration.fileOf(error),\n reason: error.message,\n }),\n ),\n Effect.fromResult,\n );\n\n const convexConfigPath = path.join(\n convexDirectory,\n ConvexConfig.CONVEX_CONFIG_FILENAME,\n );\n const authConfigPath = path.join(convexDirectory, \"auth.config.ts\");\n const authImportPath = yield* toModuleImportPath(\n path.relative(convexDirectory, authPath),\n );\n const legacyAuthConfigs = yield* Effect.forEach(\n [authImportPath, authImportPath.replace(/\\.js$/, \"\")],\n (importPath) => templates.authConfig({ authImportPath: importPath }),\n );\n yield* assertOwned(convexConfigPath, \"app.ts\", []);\n yield* assertOwned(authConfigPath, \"auth.ts\", legacyAuthConfigs);\n\n if (target === \"app\") {\n const digest = Declaration.digest({\n files: yield* declarationInputs([app, ...Option.toArray(auth)]),\n versions: [\n [\"convex\", yield* packageVersion(\"convex\", projectRoot)],\n [\"@confect/cli generator format\", GENERATOR_FORMAT],\n ],\n });\n yield* writeFileStringAndLog(\n yield* manifestPath,\n Declaration.manifest(declaration, digest),\n );\n }\n yield* writeFileStringAndLog(\n convexConfigPath,\n Declaration.convexConfig(declaration),\n );\n yield* Option.match(declaration.providers, {\n onNone: () =>\n Effect.gen(function* () {\n yield* removeAuthProviders;\n if (yield* fs.exists(authConfigPath)) {\n yield* removePathIfExists(authConfigPath);\n yield* logFileRemoved(authConfigPath);\n }\n }),\n onSome: (providers) =>\n Effect.gen(function* () {\n yield* writeFileStringAndLog(\n authConfigPath,\n Declaration.authConfig(providers),\n );\n yield* writeFileStringAndLog(\n yield* authProvidersPath,\n Declaration.authProviders(providers),\n );\n }),\n });\n return App.isApp(appValue) ? Option.some(appValue) : Option.none<App.Any>();\n});\n\n/**\n * Write the declaration's Convex files and manifest from `confect/app.ts`,\n * `confect/env.ts` and `confect/auth.ts`, before anything else is validated. On\n * any failure the previous manifest is removed, so a stale manifest never\n * outlives a declaration that no longer produces it.\n */\nexport const syncDeclaration = Effect.gen(function* () {\n if (!(yield* isDeclared)) {\n yield* removeManifest;\n yield* removeAuthProviders;\n return Option.none<App.Any>();\n }\n return yield* writeDeclaration.pipe(\n Effect.tapError(() =>\n removeManifest.pipe(Effect.andThen(removeAuthProviders)),\n ),\n );\n});\n\n/**\n * Check every HTTP route the backend serves and write `convex/http.ts` from\n * `confect/http.ts`. Runs after generation, because `http.ts` imports its\n * handlers, which import generated services.\n */\nexport const syncDeclaredHttp = (app: App.Any) =>\n checkAndWriteHttp(app).pipe(Effect.tapError(() => removeManifest));\n\nconst checkAndWriteHttp = Effect.fnUntraced(function* (app: App.Any) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const convexDirectory = yield* ConvexDirectory.get;\n const confectDirectory = yield* ConfectDirectory.get;\n const httpPath = yield* confectPath(\"http.ts\");\n\n const convexHttpPath = path.join(convexDirectory, \"http.ts\");\n if (!(yield* fs.exists(httpPath))) {\n yield* Http.routes(app).pipe(\n Result.mapError(invalid(\"app.ts\")),\n Effect.fromResult,\n );\n yield* removeGenerated(convexHttpPath, [\n yield* templates.http({\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n }),\n ]);\n return Option.none();\n }\n\n const http = (yield* bundleDeclaration(\"http.ts\")).module.default;\n if (!Http.isHttp(http)) {\n return yield* new InvalidDeclarationError({\n declarationPath: \"confect/http.ts\",\n reason: \"it must default-export Http.make(...).\",\n });\n }\n yield* Http.routes(app, http).pipe(\n Result.mapError(invalid(\"http.ts\")),\n Effect.fromResult,\n );\n\n const contents = yield* templates.declaredHttp({\n schemaImportPath: yield* toModuleImportPath(\n path.relative(\n convexDirectory,\n path.join(confectDirectory, \"_generated\", \"schema.ts\"),\n ),\n ),\n httpImportPath: yield* toModuleImportPath(\n path.relative(convexDirectory, httpPath),\n ),\n });\n const change = yield* writeFileString(convexHtt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,MAAM,WAAW,OAAO,YAAY,SAAS;CAE7C,MAAM,iBAAiB,KAAK,KAAK,iBAAiB,SAAS;CAC3D,IAAI,EAAE,OAAO,GAAG,OAAO,QAAQ,IAAI;EACjC,OAAO,KAAK,OAAO,GAAG,CAAC,CAAC,KACtB,OAAO,SAAS,QAAQ,QAAQ,CAAC,GACjC,OAAO,UACT;EACA,OAAO,gBAAgB,gBAAgB,CACrC,OAAOC,KAAe,EACpB,gBAAgB,OAAO,mBACrB,KAAK,SAAS,iBAAiB,QAAQ,CACzC,EACF,CAAC,CACH,CAAC;EACD,OAAO,OAAO,KAAK;CACrB;CAEA,MAAMC,UAAQ,OAAO,kBAAkB,SAAS,EAAA,CAAG,OAAO;CAC1D,IAAI,CAAC,KAAK,OAAOA,MAAI,GACnB,OAAO,OAAO,IAAI,wBAAwB;EACxC,iBAAiB;EACjB,QAAQ;CACV,CAAC;CAEH,OAAO,KAAK,OAAO,KAAKA,MAAI,CAAC,CAAC,KAC5B,OAAO,SAAS,QAAQ,SAAS,CAAC,GAClC,OAAO,UACT;CAEA,MAAM,WAAW,OAAOC,aAAuB;EAC7C,kBAAkB,OAAO,mBACvB,KAAK,SACH,iBACA,KAAK,KAAK,kBAAkB,cAAc,WAAW,CACvD,CACF;EACA,gBAAgB,OAAO,mBACrB,KAAK,SAAS,iBAAiB,QAAQ,CACzC;CACF,CAAC;CACD,MAAM,SAAS,OAAO,gBAAgB,gBAAgB,QAAQ;CAC9D,OAAO,OAAO,KAAK;EAAE;EAAQ,gBAAgB;CAAe,CAAC;AAC/D,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaganref/confect-cli",
3
- "version": "10.3.1-fork.31",
3
+ "version": "10.3.1-fork.33",
4
4
  "dependencies": {
5
5
  "@effect/platform-node": "^4.0.4",
6
6
  "bundle-require": "^5.1.0",
@@ -9,8 +9,8 @@
9
9
  "exsolve": "^1.1.3"
10
10
  },
11
11
  "peerDependencies": {
12
- "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.31",
13
- "@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.31",
12
+ "@confect/core": "npm:@gaganref/confect-core@10.3.1-fork.33",
13
+ "@confect/server": "npm:@gaganref/confect-server@10.3.1-fork.33",
14
14
  "effect": "^4.0.4"
15
15
  },
16
16
  "description": "Developer tooling for codegen and sync",