@gaganref/confect-cli 10.3.1-fork.4 → 10.3.1-fork.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Bundler.mjs +22 -1
- package/dist/Bundler.mjs.map +1 -1
- package/dist/CodegenError.mjs +11 -2
- package/dist/CodegenError.mjs.map +1 -1
- package/dist/ConfectDirectory.mjs.map +1 -1
- package/dist/ConvexConfig.mjs.map +1 -1
- package/dist/ConvexDirectory.mjs.map +1 -1
- package/dist/Declaration.mjs +77 -14
- package/dist/Declaration.mjs.map +1 -1
- package/dist/DirectoryOptions.mjs.map +1 -1
- package/dist/EntryPoint.mjs +2 -0
- package/dist/EntryPoint.mjs.map +1 -1
- package/dist/Evaluation.mjs +39 -13
- package/dist/Evaluation.mjs.map +1 -1
- package/dist/EvaluationWorker.mjs +13 -1
- package/dist/EvaluationWorker.mjs.map +1 -1
- package/dist/FunctionModule.mjs +100 -24
- package/dist/FunctionModule.mjs.map +1 -1
- package/dist/FunctionPath.mjs.map +1 -1
- package/dist/FunctionPaths.mjs.map +1 -1
- package/dist/GenerationSnapshot.mjs.map +1 -1
- package/dist/GroupPaths.mjs.map +1 -1
- package/dist/ImplModulePath.mjs.map +1 -1
- package/dist/LeafModule.mjs +17 -17
- package/dist/LeafModule.mjs.map +1 -1
- package/dist/Remove.mjs.map +1 -1
- package/dist/Rollback.mjs.map +1 -1
- package/dist/SpecAssemblyNode.mjs.map +1 -1
- package/dist/SpecModulePath.mjs.map +1 -1
- package/dist/SyncState.mjs +1 -1
- package/dist/SyncState.mjs.map +1 -1
- package/dist/TableModule.mjs.map +1 -1
- package/dist/TableModulePath.mjs.map +1 -1
- package/dist/WatchBuild.mjs.map +1 -1
- package/dist/WatchTopology.mjs.map +1 -1
- package/dist/Watcher.mjs +57 -55
- package/dist/Watcher.mjs.map +1 -1
- package/dist/cliApp.mjs.map +1 -1
- package/dist/confect/codegen.mjs +76 -32
- package/dist/confect/codegen.mjs.map +1 -1
- package/dist/confect/declaration.mjs +20 -7
- package/dist/confect/declaration.mjs.map +1 -1
- package/dist/confect/dev.mjs +9 -4
- package/dist/confect/dev.mjs.map +1 -1
- package/dist/confect.mjs.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/log.mjs.map +1 -1
- package/dist/templates.mjs +29 -15
- package/dist/templates.mjs.map +1 -1
- package/dist/utils.mjs +1 -1
- package/dist/utils.mjs.map +1 -1
- package/package.json +6 -5
package/dist/LeafModule.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LeafModule.mjs","names":["Bundler.importersOfPackage","Bundler.bundle","Bundler.directlyImports","Bundler.withBatch"],"sources":["../src/LeafModule.ts"],"sourcesContent":["import { GroupSpec, MiddlewareAttachment } from \"@confect/core\";\nimport { Registry, type RegistryItems } from \"@confect/server\";\nimport * as GroupImpl from \"@confect/server/GroupImpl\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport type { Context } from \"effect\";\nimport * as Array from \"effect/Array\";\nimport * as Brand from \"effect/Brand\";\nimport * as Effect from \"effect/Effect\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Layer from \"effect/Layer\";\nimport * as Option from \"effect/Option\";\nimport * as Ref from \"effect/Ref\";\nimport * as Schema from \"effect/Schema\";\nimport * as String from \"effect/String\";\nimport { fromBundlerError } from \"./BuildError\";\nimport * as Bundler from \"./Bundler\";\nimport {\n MissingImplFileError,\n MissingSpecFileError,\n ImplMissingDefaultLayerError,\n ImplMissingFunctionsError,\n ImplMissingMiddlewareError,\n ImplMissingSpecImportError,\n ImplNotFinalizedError,\n InvalidMiddlewareAttachmentError,\n SpecImportsServerError,\n SpecMissingDefaultGroupSpecError,\n} from \"./CodegenError\";\nimport { ConfectDirectory } from \"./ConfectDirectory\";\nimport { ImplModulePath } from \"./ImplModulePath\";\nimport { removePathExtension, toPosixPath } from \"./utils\";\n\nexport interface LeafModule {\n readonly relativePath: string;\n readonly pathSegments: readonly [string, ...string[]];\n readonly groupPathDot: string;\n readonly exportName: string;\n readonly specImportPath: string;\n}\n\nexport type LoadedLeafModule = LeafModule & {\n readonly spec: GroupSpec.AnyWithProps;\n} & Brand.Brand<\"@confect/cli/LoadedLeafModule\">;\n\nconst LoadedLeafModule = Brand.nominal<LoadedLeafModule>();\n\nconst VALIDATION_CONCURRENCY = 4;\n\nexport const SPEC_SUFFIX = \".spec.ts\";\nexport const IMPL_SUFFIX = \".impl.ts\";\n\nconst swapModuleSuffix = Effect.fnUntraced(function* (\n relativePath: string,\n fromSuffix: string,\n toSuffix: string,\n) {\n const path = yield* Path.Path;\n const { dir, name, ext } = path.parse(relativePath);\n if (ext !== \".ts\" || !name.endsWith(fromSuffix.slice(0, -\".ts\".length))) {\n return relativePath;\n }\n\n const stem = name.slice(0, -fromSuffix.slice(0, -\".ts\".length).length);\n const nextName = `${stem}${toSuffix.slice(0, -\".ts\".length)}`;\n return dir.length > 0\n ? path.join(dir, `${nextName}${ext}`)\n : `${nextName}${ext}`;\n});\n\nexport const isLeafSpecPath = (relativePath: string) =>\n relativePath.endsWith(SPEC_SUFFIX);\n\nexport const exportNameFromModulePath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const { name, ext } = path.parse(relativePath);\n if (ext !== \".ts\") {\n return name;\n }\n return name.endsWith(\".spec\") ? name.slice(0, -\".spec\".length) : name;\n});\n\nexport const groupPathFromRelativeModulePath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const { dir, name, ext } = path.parse(relativePath);\n const stem =\n ext === \".ts\" && name.endsWith(\".spec\")\n ? name.slice(0, -\".spec\".length)\n : name;\n const dirSegments = Array.filter(\n String.split(dir, path.sep),\n String.isNonEmpty,\n );\n const pathSegments = Array.append(dirSegments, stem) as [string, ...string[]];\n return {\n pathSegments,\n groupPathDot: Array.join(pathSegments, \".\"),\n };\n});\n\nexport const specImportPathFromGenerated = Effect.fnUntraced(function* (\n specRelativePath: string,\n) {\n const path = yield* Path.Path;\n const withoutExt = toPosixPath(\n path,\n yield* removePathExtension(specRelativePath),\n );\n return `../${withoutExt}`;\n});\n\nexport const specPathForImpl = (implRelativePath: string) =>\n swapModuleSuffix(implRelativePath, IMPL_SUFFIX, SPEC_SUFFIX);\n\nexport const implPathForSpec = (specRelativePath: string) =>\n swapModuleSuffix(specRelativePath, SPEC_SUFFIX, IMPL_SUFFIX);\n\nexport const registeredFunctionsRelativePath = Effect.fnUntraced(function* (\n leaf: LeafModule,\n) {\n const path = yield* Path.Path;\n return path.join(\"registeredFunctions\", ...leaf.pathSegments) + \".ts\";\n});\n\nexport const discoverLeafSpecFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const excludedDirs = HashSet.make(\"_generated\", \"tables\", \"middleware\");\n const excludedFiles = HashSet.make(\"nodeSpec.ts\", \"spec.ts\");\n\n const allPaths = yield* fs.readDirectory(confectDirectory, {\n recursive: true,\n });\n\n return Array.filter(allPaths, (relativePath) => {\n if (!isLeafSpecPath(relativePath)) {\n return false;\n }\n\n if (HashSet.has(excludedFiles, relativePath)) {\n return false;\n }\n\n const segments = String.split(relativePath, path.sep);\n return !Array.some(segments, (segment) =>\n HashSet.has(excludedDirs, segment),\n );\n });\n});\n\nexport const discoverLeafImplFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const excludedDirs = HashSet.make(\"_generated\", \"tables\", \"middleware\");\n\n const allPaths = yield* fs.readDirectory(confectDirectory, {\n recursive: true,\n });\n\n return Array.filter(\n Array.filterMap(allPaths, (relativePath) =>\n Schema.decodeResult(ImplModulePath)(relativePath),\n ),\n (relativePath) => {\n const segments = String.split(relativePath, path.sep);\n return !Array.some(segments, (segment) =>\n HashSet.has(excludedDirs, segment),\n );\n },\n );\n});\n\nexport const toLeafModule = Effect.fnUntraced(function* (\n specRelativePath: string,\n) {\n const exportName = yield* exportNameFromModulePath(specRelativePath);\n const { pathSegments, groupPathDot } =\n yield* groupPathFromRelativeModulePath(specRelativePath);\n const specImportPath = yield* specImportPathFromGenerated(specRelativePath);\n\n return {\n relativePath: specRelativePath,\n pathSegments,\n groupPathDot,\n exportName,\n specImportPath,\n } satisfies LeafModule;\n});\n\nconst absoluteModulePath = Effect.fnUntraced(function* (relativePath: string) {\n const confectDirectory = yield* ConfectDirectory.get;\n const path = yield* Path.Path;\n return path.resolve(confectDirectory, relativePath);\n});\n\n/**\n * Every `*.spec.ts` is reachable from `_generated/spec.ts`, which the client\n * imports through `_generated/refs.ts`—so a spec's whole import graph is\n * bundled into the browser whether or not the client calls those functions.\n * Server logic co-located with a declaration therefore ships to users,\n * silently.\n *\n * `@confect/server` is a sound proxy for \"server logic lives here\": an\n * implementation can't be written without `FunctionImpl`/`MiddlewareImpl`, both\n * of which live there. Table `Doc`/`Fields` schemas live in `@confect/core`, so\n * the documented `notes.Doc` pattern in a spec must not reach `@confect/server`\n * even through `tables/` or `_generated/`. The check runs over the spec\n * bundle's transitive inputs rather than the spec module alone, so it also\n * covers middleware declarations under `confect/middleware/` (which codegen\n * otherwise never visits) and any shared helper a spec pulls in—while only ever\n * flagging modules that genuinely reach the client.\n */\nconst validateClientSafety = Effect.fnUntraced(function* (\n leaf: LeafModule,\n bundled: Bundler.Bundled,\n) {\n const path = yield* Path.Path;\n const confectDirectory = path.resolve(yield* ConfectDirectory.get);\n\n const isCheckedUserModule = (absolutePath: string) => {\n const relative = path.relative(confectDirectory, absolutePath);\n return !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n };\n\n const importers = Bundler.importersOfPackage(\n bundled,\n \"@confect/server\",\n isCheckedUserModule,\n );\n\n if (importers.length > 0) {\n return yield* new SpecImportsServerError({\n specPath: leaf.relativePath,\n importerPaths: Array.map(importers, (absolutePath) =>\n toPosixPath(path, path.relative(confectDirectory, absolutePath)),\n ),\n });\n }\n});\n\n/**\n * Validate that the leaf's spec file default-exports a `GroupSpec`, and that\n * nothing it reaches drags server code into the client (see\n * {@link validateClientSafety}). Returns the leaf paired with its validated\n * spec, so subsequent operations reuse that association without re-bundling.\n * The runtime is declared by the spec, not its file location.\n */\nexport const loadSpec = Effect.fn(\"LeafModule.loadSpec\")(function* (\n leaf: LeafModule,\n) {\n const absolutePath = yield* absoluteModulePath(leaf.relativePath);\n const bundled = yield* Bundler.bundle(absolutePath).pipe(\n Effect.mapError((error) => fromBundlerError(leaf.relativePath, error)),\n );\n\n const groupSpec = bundled.module.default;\n\n if (!GroupSpec.isGroupSpec(groupSpec)) {\n return yield* new SpecMissingDefaultGroupSpecError({\n specPath: leaf.relativePath,\n });\n }\n\n yield* validateClientSafety(leaf, bundled);\n\n yield* Effect.fromResult(GroupSpec.validateMiddleware(groupSpec)).pipe(\n Effect.mapError(\n (error) =>\n new InvalidMiddlewareAttachmentError({\n specPath: leaf.relativePath,\n message: MiddlewareAttachment.formatValidationError(error),\n }),\n ),\n );\n\n return LoadedLeafModule({\n ...leaf,\n spec: groupSpec,\n });\n});\n\n/**\n * Walk the built `Context` for a `Finalized` `GroupImpl` service value. The\n * lookup is value-shaped (via `GroupImpl.isFinalizedGroupImpl`) so we don't\n * need to know the group's path up front to construct a typed tag for it.\n */\nconst findFinalizedGroupImpl = <S>(\n context: Context.Context<S>,\n): Option.Option<GroupImpl.AnyFinalized> =>\n Array.findFirst(context.mapUnsafe.values(), GroupImpl.isFinalizedGroupImpl);\n\n/**\n * Build the impl layer with a fresh `Registry` so each validation is isolated\n * from prior validations' `FunctionImpl.make` writes. The CLI no longer reads\n * the registry directly—`GroupImpl.finalize` snapshots the registered function\n * names onto the produced `Finalized` `GroupImpl` service value—but a fresh\n * `Ref` is still required because the default `Context.Reference` is cached\n * globally and would otherwise accumulate items across impls.\n */\nconst buildImplLayer = Effect.fnUntraced(function* (\n implLayer: Layer.Layer<unknown>,\n) {\n const registry = Ref.makeUnsafe<RegistryItems.RegistryItems>({});\n return yield* Layer.build(\n implLayer as Layer.Layer<unknown, never, never>,\n ).pipe(Effect.provideService(Registry.Registry, registry));\n}, Effect.scoped);\n\n/**\n * Validate that the leaf's sibling impl file imports the spec, default-exports\n * a finalized `GroupImpl` layer, and provides a `FunctionImpl` for every\n * function declared by the spec.\n */\nexport const validateImpl = Effect.fn(\"LeafModule.validateImpl\")(function* (\n leaf: LoadedLeafModule,\n) {\n const implRelativePath = yield* implPathForSpec(leaf.relativePath);\n const implAbsolutePath = yield* absoluteModulePath(implRelativePath);\n const specAbsolutePath = yield* absoluteModulePath(leaf.relativePath);\n\n const bundled = yield* Bundler.bundle(implAbsolutePath).pipe(\n Effect.mapError((error) => fromBundlerError(implRelativePath, error)),\n );\n\n if (\n !(yield* Bundler.directlyImports(\n bundled,\n implAbsolutePath,\n specAbsolutePath,\n ))\n ) {\n return yield* new ImplMissingSpecImportError({\n implPath: implRelativePath,\n expectedSpecPath: leaf.relativePath,\n });\n }\n\n if (!Layer.isLayer(bundled.module.default)) {\n return yield* new ImplMissingDefaultLayerError({\n implPath: implRelativePath,\n });\n }\n\n const groupSpec = leaf.spec;\n const expectedFunctionNames = Object.keys(groupSpec.functions);\n\n const context = yield* buildImplLayer(\n bundled.module.default as Layer.Layer<unknown>,\n );\n const finalizedGroupImpl = yield* Option.match(\n findFinalizedGroupImpl(context),\n {\n onNone: () => new ImplNotFinalizedError({ implPath: implRelativePath }),\n onSome: Effect.succeed,\n },\n );\n\n const registeredSet = HashSet.fromIterable(\n finalizedGroupImpl.registeredFunctionNames,\n );\n const missing = expectedFunctionNames.filter(\n (name) => !HashSet.has(registeredSet, name),\n );\n\n if (missing.length > 0) {\n return yield* new ImplMissingFunctionsError({\n implPath: implRelativePath,\n groupPath: leaf.groupPathDot,\n missingFunctionNames: missing,\n });\n }\n\n const expectedMiddlewareKeys = Array.dedupe([\n ...(groupSpec.middlewareSpecs ?? []).map(\n (middlewareSpec) => middlewareSpec.key,\n ),\n ...Object.values(groupSpec.functions).flatMap((function_) =>\n (function_.middlewareSpecs ?? []).map(\n (middlewareSpec) => middlewareSpec.key,\n ),\n ),\n ]);\n const registeredMiddlewareKeys = HashSet.fromIterable(\n finalizedGroupImpl.registeredMiddlewareKeys ?? [],\n );\n const missingMiddleware = Array.filter(\n expectedMiddlewareKeys,\n (key) => !HashSet.has(registeredMiddlewareKeys, key),\n );\n\n if (missingMiddleware.length > 0) {\n return yield* new ImplMissingMiddlewareError({\n implPath: implRelativePath,\n groupPath: leaf.groupPathDot,\n missingMiddlewareKeys: missingMiddleware,\n });\n }\n});\n\nexport const withImplFiles = Effect.fnUntraced(function* <A, E, R>(\n relativePaths: ReadonlyArray<ImplModulePath>,\n use: (leaves: ReadonlyArray<LoadedLeafModule>) => Effect.Effect<A, E, R>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const pairs = yield* Effect.forEach(relativePaths, (implRelativePath) =>\n specPathForImpl(implRelativePath).pipe(\n Effect.map((specRelativePath) => ({\n implRelativePath,\n specRelativePath,\n })),\n ),\n );\n\n return yield* Bundler.withBatch(\n pairs.flatMap(({ implRelativePath, specRelativePath }) => [\n path.resolve(confectDirectory, implRelativePath),\n path.resolve(confectDirectory, specRelativePath),\n ]),\n Effect.gen(function* () {\n const leaves = yield* Effect.forEach(\n pairs,\n Effect.fnUntraced(function* ({ implRelativePath, specRelativePath }) {\n if (\n !(yield* fs.exists(path.join(confectDirectory, specRelativePath)))\n ) {\n return yield* new MissingSpecFileError({\n implPath: implRelativePath,\n expectedSpecPath: specRelativePath,\n });\n }\n if (\n !(yield* fs.exists(path.join(confectDirectory, implRelativePath)))\n ) {\n return yield* new MissingImplFileError({\n specPath: specRelativePath,\n expectedImplPath: implRelativePath,\n });\n }\n const leaf = yield* loadSpec(yield* toLeafModule(specRelativePath));\n return leaf;\n }),\n { concurrency: VALIDATION_CONCURRENCY },\n );\n return yield* use(leaves);\n }),\n );\n});\n\nexport const validateImplFiles = Effect.fn(\"LeafModule.validateImplFiles\")(\n (relativePaths: ReadonlyArray<ImplModulePath>) =>\n withImplFiles(relativePaths, validateAllImpls),\n);\n\nexport const validateAllImpls = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LoadedLeafModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const implementationPaths = yield* Effect.forEach(\n leaves,\n ({ relativePath }) =>\n implPathForSpec(relativePath).pipe(\n Effect.map((implPath) => path.resolve(confectDirectory, implPath)),\n ),\n );\n yield* Bundler.withBatch(\n implementationPaths,\n Effect.forEach(leaves, validateImpl, {\n concurrency: VALIDATION_CONCURRENCY,\n discard: true,\n }),\n );\n});\n\nexport const loadAll = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const specFiles = yield* discoverLeafSpecFiles;\n\n const results = yield* Bundler.withBatch(\n specFiles.map((relativePath) =>\n path.resolve(confectDirectory, relativePath),\n ),\n Effect.forEach(\n specFiles,\n Effect.fnUntraced(function* (specRelativePath: string) {\n const discovered = yield* toLeafModule(specRelativePath);\n const leaf = yield* loadSpec(discovered);\n\n const implRelativePath = yield* implPathForSpec(specRelativePath);\n const implAbsolutePath = path.join(confectDirectory, implRelativePath);\n if (!(yield* fs.exists(implAbsolutePath))) {\n return yield* new MissingImplFileError({\n specPath: specRelativePath,\n expectedImplPath: implRelativePath,\n });\n }\n\n return leaf;\n }),\n { concurrency: VALIDATION_CONCURRENCY },\n ),\n );\n\n yield* validateOrphanImpls(specFiles);\n\n return results;\n});\n\n/**\n * Walk leaf ancestors and fail with a {@link ParentChildNameCollisionError} when\n * a parent leaf declares a function or subgroup whose name matches a sibling\n * subdirectory spec's segment. Without this check the colliding descendant\n * would overwrite the parent's entry in the assembled `GroupSpec.groups` map at\n * runtime, surfacing as a confusing `Refs.make` error rather than a\n * codegen-time diagnostic.\n */\nconst validateOrphanImpls = Effect.fnUntraced(function* (\n specFiles: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const implFiles = yield* discoverLeafImplFiles;\n const specPaths = HashSet.fromIterable(specFiles);\n\n yield* Effect.forEach(\n implFiles,\n Effect.fnUntraced(function* (implRelativePath: string) {\n const specRelativePath = yield* specPathForImpl(implRelativePath);\n if (HashSet.has(specPaths, specRelativePath)) {\n return;\n }\n\n const specAbsolutePath = path.join(confectDirectory, specRelativePath);\n if (!(yield* fs.exists(specAbsolutePath))) {\n return yield* new MissingSpecFileError({\n implPath: implRelativePath,\n expectedSpecPath: specRelativePath,\n });\n }\n }),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6CA,MAAM,mBAAmB,MAAM,QAA0B;AAEzD,MAAM,yBAAyB;AAE/B,MAAa,cAAc;AAC3B,MAAa,cAAc;AAE3B,MAAM,mBAAmB,OAAO,WAAW,WACzC,cACA,YACA,UACA;CACA,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,EAAE,KAAK,MAAM,QAAQ,KAAK,MAAM,YAAY;CAClD,IAAI,QAAQ,SAAS,CAAC,KAAK,SAAS,WAAW,MAAM,GAAG,EAAa,CAAC,GACpE,OAAO;CAIT,MAAM,WAAW,GADJ,KAAK,MAAM,GAAG,CAAC,WAAW,MAAM,GAAG,EAAa,CAAC,CAAC,MACxC,IAAI,SAAS,MAAM,GAAG,EAAa;CAC1D,OAAO,IAAI,SAAS,IAChB,KAAK,KAAK,KAAK,GAAG,WAAW,KAAK,IAClC,GAAG,WAAW;AACpB,CAAC;AAED,MAAa,kBAAkB,iBAC7B,aAAa,SAAS,WAAW;AAEnC,MAAa,2BAA2B,OAAO,WAAW,WACxD,cACA;CAEA,MAAM,EAAE,MAAM,SAAQ,OADF,KAAK,KAAA,CACE,MAAM,YAAY;CAC7C,IAAI,QAAQ,OACV,OAAO;CAET,O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AAS;CAEpC,OAAO;AACT,CAAC;;;;;;;;;AAUD,MAAM,sBAAsB,OAAO,WAAW,WAC5C,WACA;CACA,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,mBAAmB,OAAO,iBAAiB;CACjD,MAAM,YAAY,OAAO;CACzB,MAAM,YAAY,QAAQ,aAAa,SAAS;CAEhD,OAAO,OAAO,QACZ,WACA,OAAO,WAAW,WAAW,kBAA0B;EACrD,MAAM,mBAAmB,OAAO,gBAAgB,gBAAgB;EAChE,IAAI,QAAQ,IAAI,WAAW,gBAAgB,GACzC;EAGF,MAAM,mBAAmB,KAAK,KAAK,kBAAkB,gBAAgB;EACrE,IAAI,EAAE,OAAO,GAAG,OAAO,gBAAgB,IACrC,OAAO,OAAO,IAAI,qBAAqB;GACrC,UAAU;GACV,kBAAkB;EACpB,CAAC;CAEL,CAAC,CACH;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"LeafModule.mjs","names":["Bundler.importersOfPackage","Bundler.bundle","Bundler.directlyImports","Bundler.withBatch"],"sources":["../src/LeafModule.ts"],"sourcesContent":["import { GroupSpec, MiddlewareAttachment } from \"@confect/core\";\nimport { Registry, RegistryItems } from \"@confect/server\";\nimport * as GroupImpl from \"@confect/server/GroupImpl\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport type { Context } from \"effect\";\nimport * as Array from \"effect/Array\";\nimport * as Brand from \"effect/Brand\";\nimport * as Effect from \"effect/Effect\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Layer from \"effect/Layer\";\nimport * as Option from \"effect/Option\";\nimport * as Ref from \"effect/Ref\";\nimport * as Schema from \"effect/Schema\";\nimport * as String from \"effect/String\";\nimport { fromBundlerError } from \"./BuildError.js\";\nimport * as Bundler from \"./Bundler.js\";\nimport {\n MissingImplFileError,\n MissingSpecFileError,\n ImplMissingDefaultLayerError,\n ImplMissingFunctionsError,\n ImplMissingMiddlewareError,\n RequiredMiddlewareError,\n ImplMissingSpecImportError,\n ImplNotFinalizedError,\n InvalidMiddlewareAttachmentError,\n SpecImportsServerError,\n SpecMissingDefaultGroupSpecError,\n} from \"./CodegenError.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport { ImplModulePath } from \"./ImplModulePath.js\";\nimport { removePathExtension, toPosixPath } from \"./utils.js\";\n\nexport interface LeafModule {\n readonly relativePath: string;\n readonly pathSegments: readonly [string, ...string[]];\n readonly groupPathDot: string;\n readonly exportName: string;\n readonly specImportPath: string;\n}\n\nexport type LoadedLeafModule = LeafModule & {\n readonly spec: GroupSpec.AnyWithProps;\n} & Brand.Brand<\"@confect/cli/LoadedLeafModule\">;\n\nconst LoadedLeafModule = Brand.nominal<LoadedLeafModule>();\n\nconst VALIDATION_CONCURRENCY = 4;\n\nexport const SPEC_SUFFIX = \".spec.ts\";\nexport const IMPL_SUFFIX = \".impl.ts\";\n\nconst swapModuleSuffix = Effect.fnUntraced(function* (\n relativePath: string,\n fromSuffix: string,\n toSuffix: string,\n) {\n const path = yield* Path.Path;\n const { dir, name, ext } = path.parse(relativePath);\n if (ext !== \".ts\" || !name.endsWith(fromSuffix.slice(0, -\".ts\".length))) {\n return relativePath;\n }\n\n const stem = name.slice(0, -fromSuffix.slice(0, -\".ts\".length).length);\n const nextName = `${stem}${toSuffix.slice(0, -\".ts\".length)}`;\n return dir.length > 0\n ? path.join(dir, `${nextName}${ext}`)\n : `${nextName}${ext}`;\n});\n\nexport const isLeafSpecPath = (relativePath: string) =>\n relativePath.endsWith(SPEC_SUFFIX);\n\nexport const exportNameFromModulePath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const { name, ext } = path.parse(relativePath);\n if (ext !== \".ts\") {\n return name;\n }\n return name.endsWith(\".spec\") ? name.slice(0, -\".spec\".length) : name;\n});\n\nexport const groupPathFromRelativeModulePath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const { dir, name, ext } = path.parse(relativePath);\n const stem =\n ext === \".ts\" && name.endsWith(\".spec\")\n ? name.slice(0, -\".spec\".length)\n : name;\n const dirSegments = Array.filter(\n String.split(dir, path.sep),\n String.isNonEmpty,\n );\n const pathSegments = Array.append(dirSegments, stem) as [string, ...string[]];\n return {\n pathSegments,\n groupPathDot: Array.join(pathSegments, \".\"),\n };\n});\n\nexport const specImportPathFromGenerated = Effect.fnUntraced(function* (\n specRelativePath: string,\n) {\n const path = yield* Path.Path;\n const withoutExt = toPosixPath(\n path,\n yield* removePathExtension(specRelativePath),\n );\n return `../${withoutExt}.js`;\n});\n\nexport const specPathForImpl = (implRelativePath: string) =>\n swapModuleSuffix(implRelativePath, IMPL_SUFFIX, SPEC_SUFFIX);\n\nexport const implPathForSpec = (specRelativePath: string) =>\n swapModuleSuffix(specRelativePath, SPEC_SUFFIX, IMPL_SUFFIX);\n\nexport const registeredFunctionsRelativePath = Effect.fnUntraced(function* (\n leaf: LeafModule,\n) {\n const path = yield* Path.Path;\n return path.join(\"registeredFunctions\", ...leaf.pathSegments) + \".ts\";\n});\n\nexport const discoverLeafSpecFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const excludedDirs = HashSet.make(\"_generated\", \"tables\", \"middleware\");\n const excludedFiles = HashSet.make(\"nodeSpec.ts\", \"spec.ts\");\n\n const allPaths = yield* fs.readDirectory(confectDirectory, {\n recursive: true,\n });\n\n return Array.filter(allPaths, (relativePath) => {\n if (!isLeafSpecPath(relativePath)) {\n return false;\n }\n\n if (HashSet.has(excludedFiles, relativePath)) {\n return false;\n }\n\n const segments = String.split(relativePath, path.sep);\n return !Array.some(segments, (segment) =>\n HashSet.has(excludedDirs, segment),\n );\n });\n});\n\nexport const discoverLeafImplFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const excludedDirs = HashSet.make(\"_generated\", \"tables\", \"middleware\");\n\n const allPaths = yield* fs.readDirectory(confectDirectory, {\n recursive: true,\n });\n\n return Array.filter(\n Array.filterMap(allPaths, (relativePath) =>\n Schema.decodeResult(ImplModulePath)(relativePath),\n ),\n (relativePath) => {\n const segments = String.split(relativePath, path.sep);\n return !Array.some(segments, (segment) =>\n HashSet.has(excludedDirs, segment),\n );\n },\n );\n});\n\nexport const toLeafModule = Effect.fnUntraced(function* (\n specRelativePath: string,\n) {\n const exportName = yield* exportNameFromModulePath(specRelativePath);\n const { pathSegments, groupPathDot } =\n yield* groupPathFromRelativeModulePath(specRelativePath);\n const specImportPath = yield* specImportPathFromGenerated(specRelativePath);\n\n return {\n relativePath: specRelativePath,\n pathSegments,\n groupPathDot,\n exportName,\n specImportPath,\n } satisfies LeafModule;\n});\n\nconst absoluteModulePath = Effect.fnUntraced(function* (relativePath: string) {\n const confectDirectory = yield* ConfectDirectory.get;\n const path = yield* Path.Path;\n return path.resolve(confectDirectory, relativePath);\n});\n\n/**\n * Every `*.spec.ts` is reachable from `_generated/spec.ts`, which the client\n * imports through `_generated/refs.ts`—so a spec's whole import graph is\n * bundled into the browser whether or not the client calls those functions.\n * Server logic co-located with a declaration therefore ships to users,\n * silently.\n *\n * `@confect/server` is a sound proxy for \"server logic lives here\": an\n * implementation can't be written without `FunctionImpl`/`MiddlewareImpl`, both\n * of which live there. Table `Doc`/`Fields` schemas live in `@confect/core`, so\n * the documented `notes.Doc` pattern in a spec must not reach `@confect/server`\n * even through `tables/` or `_generated/`. The check runs over the spec\n * bundle's transitive inputs rather than the spec module alone, so it also\n * covers middleware declarations under `confect/middleware/` (which codegen\n * otherwise never visits) and any shared helper a spec pulls in—while only ever\n * flagging modules that genuinely reach the client.\n */\nconst validateClientSafety = Effect.fnUntraced(function* (\n leaf: LeafModule,\n bundled: Bundler.Bundled,\n) {\n const path = yield* Path.Path;\n const confectDirectory = path.resolve(yield* ConfectDirectory.get);\n\n const isCheckedUserModule = (absolutePath: string) => {\n const relative = path.relative(confectDirectory, absolutePath);\n return !relative.startsWith(\"..\") && !path.isAbsolute(relative);\n };\n\n const importers = Bundler.importersOfPackage(\n bundled,\n \"@confect/server\",\n isCheckedUserModule,\n );\n\n if (importers.length > 0) {\n return yield* new SpecImportsServerError({\n specPath: leaf.relativePath,\n importerPaths: Array.map(importers, (absolutePath) =>\n toPosixPath(path, path.relative(confectDirectory, absolutePath)),\n ),\n });\n }\n});\n\n/**\n * Validate that the leaf's spec file default-exports a `GroupSpec`, and that\n * nothing it reaches drags server code into the client (see\n * {@link validateClientSafety}). Returns the leaf paired with its validated\n * spec, so subsequent operations reuse that association without re-bundling.\n * The runtime is declared by the spec, not its file location.\n */\nexport const loadSpec = Effect.fn(\"LeafModule.loadSpec\")(function* (\n leaf: LeafModule,\n) {\n const absolutePath = yield* absoluteModulePath(leaf.relativePath);\n const bundled = yield* Bundler.bundle(absolutePath).pipe(\n Effect.mapError((error) => fromBundlerError(leaf.relativePath, error)),\n );\n\n const groupSpec = bundled.module.default;\n\n if (!GroupSpec.isGroupSpec(groupSpec)) {\n return yield* new SpecMissingDefaultGroupSpecError({\n specPath: leaf.relativePath,\n });\n }\n\n yield* validateClientSafety(leaf, bundled);\n\n yield* Effect.fromResult(GroupSpec.validateMiddleware(groupSpec)).pipe(\n Effect.mapError(\n (error) =>\n new InvalidMiddlewareAttachmentError({\n specPath: leaf.relativePath,\n message: MiddlewareAttachment.formatValidationError(error),\n }),\n ),\n );\n\n return LoadedLeafModule({\n ...leaf,\n spec: groupSpec,\n });\n});\n\n/**\n * Walk the built `Context` for a `Finalized` `GroupImpl` service value. The\n * lookup is value-shaped (via `GroupImpl.isFinalizedGroupImpl`) so we don't\n * need to know the group's path up front to construct a typed tag for it.\n */\nconst findFinalizedGroupImpl = <S>(\n context: Context.Context<S>,\n): Option.Option<GroupImpl.AnyFinalized> =>\n Array.findFirst(context.mapUnsafe.values(), GroupImpl.isFinalizedGroupImpl);\n\n/**\n * Build the impl layer with a fresh `Registry` so each validation is isolated\n * from prior validations' `FunctionImpl.make` writes. Retain its items to check\n * required middleware against actual function attachments.\n */\nconst buildImplLayer = Effect.fnUntraced(function* (\n implLayer: Layer.Layer<unknown>,\n) {\n const registry = Ref.makeUnsafe<RegistryItems.RegistryItems>({});\n const context = yield* Layer.build(\n implLayer as Layer.Layer<unknown, never, never>,\n ).pipe(Effect.provideService(Registry.Registry, registry));\n return { context, items: yield* Ref.get(registry) };\n}, Effect.scoped);\n\n/**\n * Validate that the leaf's sibling impl file imports the spec, default-exports\n * a finalized `GroupImpl` layer, and provides a `FunctionImpl` for every\n * function declared by the spec. Return uncovered middleware requirements for\n * the caller to report across groups.\n */\nexport const validateImpl = Effect.fn(\"LeafModule.validateImpl\")(function* (\n leaf: LoadedLeafModule,\n required: ReadonlyArray<{ readonly key: string }> = [],\n) {\n const implRelativePath = yield* implPathForSpec(leaf.relativePath);\n const implAbsolutePath = yield* absoluteModulePath(implRelativePath);\n const specAbsolutePath = yield* absoluteModulePath(leaf.relativePath);\n\n const bundled = yield* Bundler.bundle(implAbsolutePath).pipe(\n Effect.mapError((error) => fromBundlerError(implRelativePath, error)),\n );\n\n if (\n !(yield* Bundler.directlyImports(\n bundled,\n implAbsolutePath,\n specAbsolutePath,\n ))\n ) {\n return yield* new ImplMissingSpecImportError({\n implPath: implRelativePath,\n expectedSpecPath: leaf.relativePath,\n });\n }\n\n if (!Layer.isLayer(bundled.module.default)) {\n return yield* new ImplMissingDefaultLayerError({\n implPath: implRelativePath,\n });\n }\n\n const groupSpec = leaf.spec;\n const expectedFunctionNames = Object.keys(groupSpec.functions);\n\n const { context, items } = yield* buildImplLayer(\n bundled.module.default as Layer.Layer<unknown>,\n );\n const finalizedGroupImpl = yield* Option.match(\n findFinalizedGroupImpl(context),\n {\n onNone: () => new ImplNotFinalizedError({ implPath: implRelativePath }),\n onSome: Effect.succeed,\n },\n );\n\n const registeredSet = HashSet.fromIterable(\n finalizedGroupImpl.registeredFunctionNames,\n );\n const missing = expectedFunctionNames.filter(\n (name) => !HashSet.has(registeredSet, name),\n );\n\n if (missing.length > 0) {\n return yield* new ImplMissingFunctionsError({\n implPath: implRelativePath,\n groupPath: leaf.groupPathDot,\n missingFunctionNames: missing,\n });\n }\n\n const expectedMiddlewareKeys = Array.dedupe([\n ...(groupSpec.middlewareSpecs ?? []).map(\n (middlewareSpec) => middlewareSpec.key,\n ),\n ...Object.values(groupSpec.functions).flatMap((function_) =>\n (function_.middlewareSpecs ?? []).map(\n (middlewareSpec) => middlewareSpec.key,\n ),\n ),\n ]);\n const registeredMiddlewareKeys = HashSet.fromIterable(\n finalizedGroupImpl.registeredMiddlewareKeys ?? [],\n );\n const missingMiddleware = Array.filter(\n expectedMiddlewareKeys,\n (key) => !HashSet.has(registeredMiddlewareKeys, key),\n );\n\n if (missingMiddleware.length > 0) {\n return yield* new ImplMissingMiddlewareError({\n implPath: implRelativePath,\n groupPath: leaf.groupPathDot,\n missingMiddlewareKeys: missingMiddleware,\n });\n }\n\n return RegistryItems.missingRequired(items, required, leaf.groupPathDot);\n});\n\nexport const withImplFiles = Effect.fnUntraced(function* <A, E, R>(\n relativePaths: ReadonlyArray<ImplModulePath>,\n use: (leaves: ReadonlyArray<LoadedLeafModule>) => Effect.Effect<A, E, R>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const pairs = yield* Effect.forEach(relativePaths, (implRelativePath) =>\n specPathForImpl(implRelativePath).pipe(\n Effect.map((specRelativePath) => ({\n implRelativePath,\n specRelativePath,\n })),\n ),\n );\n\n return yield* Bundler.withBatch(\n pairs.flatMap(({ implRelativePath, specRelativePath }) => [\n path.resolve(confectDirectory, implRelativePath),\n path.resolve(confectDirectory, specRelativePath),\n ]),\n Effect.gen(function* () {\n const leaves = yield* Effect.forEach(\n pairs,\n Effect.fnUntraced(function* ({ implRelativePath, specRelativePath }) {\n if (\n !(yield* fs.exists(path.join(confectDirectory, specRelativePath)))\n ) {\n return yield* new MissingSpecFileError({\n implPath: implRelativePath,\n expectedSpecPath: specRelativePath,\n });\n }\n if (\n !(yield* fs.exists(path.join(confectDirectory, implRelativePath)))\n ) {\n return yield* new MissingImplFileError({\n specPath: specRelativePath,\n expectedImplPath: implRelativePath,\n });\n }\n const leaf = yield* loadSpec(yield* toLeafModule(specRelativePath));\n return leaf;\n }),\n { concurrency: VALIDATION_CONCURRENCY },\n );\n return yield* use(leaves);\n }),\n );\n});\n\nexport const validateImplFiles = Effect.fn(\"LeafModule.validateImplFiles\")(\n (relativePaths: ReadonlyArray<ImplModulePath>) =>\n withImplFiles(relativePaths, validateAllImpls),\n);\n\nexport const validateAllImpls = Effect.fnUntraced(function* (\n leaves: ReadonlyArray<LoadedLeafModule>,\n required: ReadonlyArray<{ readonly key: string }> = [],\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const implementationPaths = yield* Effect.forEach(\n leaves,\n ({ relativePath }) =>\n implPathForSpec(relativePath).pipe(\n Effect.map((implPath) => path.resolve(confectDirectory, implPath)),\n ),\n );\n const missing = (yield* Bundler.withBatch(\n implementationPaths,\n Effect.forEach(leaves, (leaf) => validateImpl(leaf, required), {\n concurrency: VALIDATION_CONCURRENCY,\n }),\n ))\n .flat()\n .sort((left, right) => left.functionName.localeCompare(right.functionName));\n if (missing.length > 0) {\n return yield* new RequiredMiddlewareError({ missing });\n }\n});\n\nexport const loadAll = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const specFiles = yield* discoverLeafSpecFiles;\n\n const results = yield* Bundler.withBatch(\n specFiles.map((relativePath) =>\n path.resolve(confectDirectory, relativePath),\n ),\n Effect.forEach(\n specFiles,\n Effect.fnUntraced(function* (specRelativePath: string) {\n const discovered = yield* toLeafModule(specRelativePath);\n const leaf = yield* loadSpec(discovered);\n\n const implRelativePath = yield* implPathForSpec(specRelativePath);\n const implAbsolutePath = path.join(confectDirectory, implRelativePath);\n if (!(yield* fs.exists(implAbsolutePath))) {\n return yield* new MissingImplFileError({\n specPath: specRelativePath,\n expectedImplPath: implRelativePath,\n });\n }\n\n return leaf;\n }),\n { concurrency: VALIDATION_CONCURRENCY },\n ),\n );\n\n yield* validateOrphanImpls(specFiles);\n\n return results;\n});\n\n/**\n * Walk leaf ancestors and fail with a {@link ParentChildNameCollisionError} when\n * a parent leaf declares a function or subgroup whose name matches a sibling\n * subdirectory spec's segment. Without this check the colliding descendant\n * would overwrite the parent's entry in the assembled `GroupSpec.groups` map at\n * runtime, surfacing as a confusing `Refs.make` error rather than a\n * codegen-time diagnostic.\n */\nconst validateOrphanImpls = Effect.fnUntraced(function* (\n specFiles: ReadonlyArray<string>,\n) {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const implFiles = yield* discoverLeafImplFiles;\n const specPaths = HashSet.fromIterable(specFiles);\n\n yield* Effect.forEach(\n implFiles,\n Effect.fnUntraced(function* (implRelativePath: string) {\n const specRelativePath = yield* specPathForImpl(implRelativePath);\n if (HashSet.has(specPaths, specRelativePath)) {\n return;\n }\n\n const specAbsolutePath = path.join(confectDirectory, specRelativePath);\n if (!(yield* fs.exists(specAbsolutePath))) {\n return yield* new MissingSpecFileError({\n implPath: implRelativePath,\n expectedSpecPath: specRelativePath,\n });\n }\n }),\n );\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8CA,MAAM,mBAAmB,MAAM,QAA0B;AAEzD,MAAM,yBAAyB;AAE/B,MAAa,cAAc;AAC3B,MAAa,cAAc;AAE3B,MAAM,mBAAmB,OAAO,WAAW,WACzC,cACA,YACA,UACA;CACA,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,EAAE,KAAK,MAAM,QAAQ,KAAK,MAAM,YAAY;CAClD,IAAI,QAAQ,SAAS,CAAC,KAAK,SAAS,WAAW,MAAM,GAAG,EAAa,CA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AAO,GAAG,OAAO,gBAAgB,IACrC,OAAO,OAAO,IAAI,qBAAqB;GACrC,UAAU;GACV,kBAAkB;EACpB,CAAC;CAEL,CAAC,CACH;AACF,CAAC"}
|
package/dist/Remove.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Remove.mjs","names":[],"sources":["../src/Remove.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Schedule from \"effect/Schedule\";\nimport { RemoveBusyError } from \"./CodegenError\";\n\nconst MAX_ATTEMPTS = 4;\n\nexport const remove = Effect.fn(\"Remove.remove\")(function* (path: string) {\n const fs = yield* FileSystem.FileSystem;\n yield* fs.remove(path, { recursive: true, force: true }).pipe(\n Effect.retry({\n while: (error) => error.reason._tag === \"Busy\",\n times: MAX_ATTEMPTS - 1,\n schedule: Schedule.exponential(\"25 millis\"),\n }),\n Effect.mapError((error) =>\n error.reason._tag === \"Busy\"\n ? new RemoveBusyError({ path, attempts: MAX_ATTEMPTS, cause: error })\n : error,\n ),\n );\n});\n"],"mappings":";;;;;AAKA,MAAM,eAAe;AAErB,MAAa,SAAS,OAAO,GAAG,eAAe,CAAC,CAAC,WAAW,MAAc;CAExE,QAAO,OADW,WAAW,WAAA,CACnB,OAAO,MAAM;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC,CAAC,CAAC,KACvD,OAAO,MAAM;EACX,QAAQ,UAAU,MAAM,OAAO,SAAS;EACxC,OAAO;EACP,UAAU,SAAS,YAAY,WAAW;CAC5C,CAAC,GACD,OAAO,UAAU,UACf,MAAM,OAAO,SAAS,SAClB,IAAI,gBAAgB;EAAE;EAAM,UAAU;EAAc,OAAO;CAAM,CAAC,IAClE,KACN,CACF;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"Remove.mjs","names":[],"sources":["../src/Remove.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Schedule from \"effect/Schedule\";\nimport { RemoveBusyError } from \"./CodegenError.js\";\n\nconst MAX_ATTEMPTS = 4;\n\nexport const remove = Effect.fn(\"Remove.remove\")(function* (path: string) {\n const fs = yield* FileSystem.FileSystem;\n yield* fs.remove(path, { recursive: true, force: true }).pipe(\n Effect.retry({\n while: (error) => error.reason._tag === \"Busy\",\n times: MAX_ATTEMPTS - 1,\n schedule: Schedule.exponential(\"25 millis\"),\n }),\n Effect.mapError((error) =>\n error.reason._tag === \"Busy\"\n ? new RemoveBusyError({ path, attempts: MAX_ATTEMPTS, cause: error })\n : error,\n ),\n );\n});\n"],"mappings":";;;;;AAKA,MAAM,eAAe;AAErB,MAAa,SAAS,OAAO,GAAG,eAAe,CAAC,CAAC,WAAW,MAAc;CAExE,QAAO,OADW,WAAW,WAAA,CACnB,OAAO,MAAM;EAAE,WAAW;EAAM,OAAO;CAAK,CAAC,CAAC,CAAC,KACvD,OAAO,MAAM;EACX,QAAQ,UAAU,MAAM,OAAO,SAAS;EACxC,OAAO;EACP,UAAU,SAAS,YAAY,WAAW;CAC5C,CAAC,GACD,OAAO,UAAU,UACf,MAAM,OAAO,SAAS,SAClB,IAAI,gBAAgB;EAAE;EAAM,UAAU;EAAc,OAAO;CAAM,CAAC,IAClE,KACN,CACF;AACF,CAAC"}
|
package/dist/Rollback.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Rollback.mjs","names":[],"sources":["../src/Rollback.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport * as Schema from \"effect/Schema\";\nimport type * as Scope from \"effect/Scope\";\nimport { ComponentNodeGroupError, logCodegenError } from \"./CodegenError\";\nimport { ConfectDirectory } from \"./ConfectDirectory\";\nimport { CONVEX_CONFIG_FILENAME } from \"./ConvexConfig\";\nimport { ConvexDirectory } from \"./ConvexDirectory\";\nimport { logFileRemoved, logWarn } from \"./log\";\nimport { remove } from \"./Remove\";\n\nconst isNodeGroupRejection = Schema.is(ComponentNodeGroupError);\n\n/**\n * Keep a component's previous generated output when generation rejects a Node\n * group. Specs can import bootstrap output, so generation writes it before\n * their runtimes are known. `duringRestore` pauses whatever watches the output\n * while it is replaced.\n */\nexport const preserveComponentOutput = <A, E, R>(\n generation: Effect.Effect<A, E, R>,\n duringRestore: Effect.Effect<void, never, Scope.Scope> = Effect.void,\n) =>\n Effect.gen(function* () {\n if ((yield* ConvexDirectory.target).kind === \"app\")\n return yield* generation;\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const backupDirectory = yield* fs.makeTempDirectoryScoped();\n const configPath = path.join(\n yield* ConvexDirectory.get,\n CONVEX_CONFIG_FILENAME,\n );\n const snapshots = yield* Effect.forEach(\n [path.join(yield* ConfectDirectory.get, \"_generated\"), configPath],\n Effect.fnUntraced(function* (original, index) {\n const backup = path.join(backupDirectory, String(index));\n const existed = yield* fs.exists(original);\n if (existed) yield* fs.copy(original, backup);\n return { original, backup, existed };\n }),\n );\n const restore = (rejection: ComponentNodeGroupError) =>\n Effect.gen(function* () {\n yield* duringRestore;\n yield* Effect.forEach(snapshots, ({ original, backup, existed }) =>\n Effect.gen(function* () {\n if (\n existed &&\n original === configPath &&\n (yield* fs.exists(original)) &&\n (yield* fs.readFileString(original)) ===\n (yield* fs.readFileString(backup))\n ) {\n return;\n }\n if (yield* fs.exists(original)) {\n yield* remove(original);\n }\n if (existed) yield* fs.copy(backup, original);\n else yield* logFileRemoved(original);\n }),\n );\n yield* logWarn(\n \"Restored generated output after rejecting the Node group.\",\n );\n }).pipe(\n Effect.scoped,\n Effect.tapError(() => logCodegenError(rejection)),\n );\n return yield* generation.pipe(\n Effect.tapError((error) =>\n isNodeGroupRejection(error) ? restore(error) : Effect.void,\n ),\n );\n }).pipe(Effect.scoped);\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,uBAAuB,OAAO,GAAG,uBAAuB;;;;;;;AAQ9D,MAAa,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AAC,KAAK,OAAO,MAAM"}
|
|
1
|
+
{"version":3,"file":"Rollback.mjs","names":[],"sources":["../src/Rollback.ts"],"sourcesContent":["import * as Effect from \"effect/Effect\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport * as Schema from \"effect/Schema\";\nimport type * as Scope from \"effect/Scope\";\nimport { ComponentNodeGroupError, logCodegenError } from \"./CodegenError.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\nimport { CONVEX_CONFIG_FILENAME } from \"./ConvexConfig.js\";\nimport { ConvexDirectory } from \"./ConvexDirectory.js\";\nimport { logFileRemoved, logWarn } from \"./log.js\";\nimport { remove } from \"./Remove.js\";\n\nconst isNodeGroupRejection = Schema.is(ComponentNodeGroupError);\n\n/**\n * Keep a component's previous generated output when generation rejects a Node\n * group. Specs can import bootstrap output, so generation writes it before\n * their runtimes are known. `duringRestore` pauses whatever watches the output\n * while it is replaced.\n */\nexport const preserveComponentOutput = <A, E, R>(\n generation: Effect.Effect<A, E, R>,\n duringRestore: Effect.Effect<void, never, Scope.Scope> = Effect.void,\n) =>\n Effect.gen(function* () {\n if ((yield* ConvexDirectory.target).kind === \"app\")\n return yield* generation;\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const backupDirectory = yield* fs.makeTempDirectoryScoped();\n const configPath = path.join(\n yield* ConvexDirectory.get,\n CONVEX_CONFIG_FILENAME,\n );\n const snapshots = yield* Effect.forEach(\n [path.join(yield* ConfectDirectory.get, \"_generated\"), configPath],\n Effect.fnUntraced(function* (original, index) {\n const backup = path.join(backupDirectory, String(index));\n const existed = yield* fs.exists(original);\n if (existed) yield* fs.copy(original, backup);\n return { original, backup, existed };\n }),\n );\n const restore = (rejection: ComponentNodeGroupError) =>\n Effect.gen(function* () {\n yield* duringRestore;\n yield* Effect.forEach(snapshots, ({ original, backup, existed }) =>\n Effect.gen(function* () {\n if (\n existed &&\n original === configPath &&\n (yield* fs.exists(original)) &&\n (yield* fs.readFileString(original)) ===\n (yield* fs.readFileString(backup))\n ) {\n return;\n }\n if (yield* fs.exists(original)) {\n yield* remove(original);\n }\n if (existed) yield* fs.copy(backup, original);\n else yield* logFileRemoved(original);\n }),\n );\n yield* logWarn(\n \"Restored generated output after rejecting the Node group.\",\n );\n }).pipe(\n Effect.scoped,\n Effect.tapError(() => logCodegenError(rejection)),\n );\n return yield* generation.pipe(\n Effect.tapError((error) =>\n isNodeGroupRejection(error) ? restore(error) : Effect.void,\n ),\n );\n }).pipe(Effect.scoped);\n"],"mappings":";;;;;;;;;;;AAYA,MAAM,uBAAuB,OAAO,GAAG,uBAAuB;;;;;;;AAQ9D,MAAa,2BACX,YACA,gBAAyD,OAAO,SAEhE,OAAO,IAAI,aAAa;CACtB,KAAK,OAAO,gBAAgB,OAAA,CAAQ,SAAS,OAC3C,OAAO,OAAO;CAChB,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,kBAAkB,OAAO,GAAG,wBAAwB;CAC1D,MAAM,aAAa,KAAK,KACtB,OAAO,gBAAgB,KACvB,sBACF;CACA,MAAM,YAAY,OAAO,OAAO,QAC9B,CAAC,KAAK,KAAK,OAAO,iBAAiB,KAAK,YAAY,GAAG,UAAU,GACjE,OAAO,WAAW,WAAW,UAAU,OAAO;EAC5C,MAAM,SAAS,KAAK,KAAK,iBAAiB,OAAO,KAAK,CAAC;EACvD,MAAM,UAAU,OAAO,GAAG,OAAO,QAAQ;EACzC,IAAI,SAAS,OAAO,GAAG,KAAK,UAAU,MAAM;EAC5C,OAAO;GAAE;GAAU;GAAQ;EAAQ;CACrC,CAAC,CACH;CACA,MAAM,WAAW,cACf,OAAO,IAAI,aAAa;EACtB,OAAO;EACP,OAAO,OAAO,QAAQ,YAAY,EAAE,UAAU,QAAQ,cACpD,OAAO,IAAI,aAAa;GACtB,IACE,WACA,aAAa,eACZ,OAAO,GAAG,OAAO,QAAQ,OACzB,OAAO,GAAG,eAAe,QAAQ,QAC/B,OAAO,GAAG,eAAe,MAAM,IAElC;GAEF,IAAI,OAAO,GAAG,OAAO,QAAQ,GAC3B,OAAO,OAAO,QAAQ;GAExB,IAAI,SAAS,OAAO,GAAG,KAAK,QAAQ,QAAQ;QACvC,OAAO,eAAe,QAAQ;EACrC,CAAC,CACH;EACA,OAAO,QACL,2DACF;CACF,CAAC,CAAC,CAAC,KACD,OAAO,QACP,OAAO,eAAe,gBAAgB,SAAS,CAAC,CAClD;CACF,OAAO,OAAO,WAAW,KACvB,OAAO,UAAU,UACf,qBAAqB,KAAK,IAAI,QAAQ,KAAK,IAAI,OAAO,IACxD,CACF;AACF,CAAC,CAAC,CAAC,KAAK,OAAO,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SpecAssemblyNode.mjs","names":[],"sources":["../src/SpecAssemblyNode.ts"],"sourcesContent":["import type { LeafModule } from \"./LeafModule\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter\";\nimport * as Option from \"effect/Option\";\nimport * as Order from \"effect/Order\";\nimport * as Record from \"effect/Record\";\n\nexport interface SpecImportBinding {\n readonly importPath: string;\n readonly exportName: string;\n readonly localName: string;\n}\n\nexport interface SpecAssemblyNode {\n readonly segment: string;\n readonly importBinding: Option.Option<SpecImportBinding>;\n readonly children: ReadonlyArray<SpecAssemblyNode>;\n}\n\nconst importBindingFromLeaf = (leaf: LeafModule): SpecImportBinding => ({\n importPath: leaf.specImportPath,\n exportName: leaf.exportName,\n localName: Array.join(leaf.pathSegments, \"_\"),\n});\n\nconst assemblyNodesAtDepth = (\n leaves: ReadonlyArray<LeafModule>,\n depth: number,\n): ReadonlyArray<SpecAssemblyNode> =>\n pipe(\n Array.groupBy(leaves, (leaf) => leaf.pathSegments[depth]!),\n Record.toEntries,\n Array.sortBy(Order.mapInput(Order.String, ([segment]) => segment)),\n Array.map(([segment, groupLeaves]) => {\n const terminal = Array.findFirst(\n groupLeaves,\n (leaf) => leaf.pathSegments.length === depth + 1,\n );\n const descendants = Array.filter(\n groupLeaves,\n (leaf) => leaf.pathSegments.length > depth + 1,\n );\n return {\n segment,\n importBinding: Option.map(terminal, importBindingFromLeaf),\n children: assemblyNodesAtDepth(descendants, depth + 1),\n };\n }),\n );\n\nexport const assemblyNodesFromLeaves = (\n leaves: ReadonlyArray<LeafModule>,\n): ReadonlyArray<SpecAssemblyNode> => assemblyNodesAtDepth(leaves, 0);\n\nconst importBindingsForNode = (\n node: SpecAssemblyNode,\n): ReadonlyArray<SpecImportBinding> =>\n pipe(node.children, Array.flatMap(importBindingsForNode), (childBindings) =>\n Option.match(node.importBinding, {\n onNone: () => childBindings,\n onSome: (binding) => Array.prepend(childBindings, binding),\n }),\n );\n\nexport const collectImportBindings = (\n nodes: ReadonlyArray<SpecAssemblyNode>,\n): ReadonlyArray<SpecImportBinding> =>\n pipe(\n Array.flatMap(nodes, importBindingsForNode),\n (bindings) =>\n Record.fromIterableBy(bindings, (binding) => binding.importPath),\n Record.toEntries,\n Array.map(([, binding]) => binding),\n Array.sortBy(Order.mapInput(Order.String, (binding) => binding.localName)),\n );\n\nconst writeGroupEntry = Effect.fnUntraced(function* (\n cbw: CodeBlockWriter,\n node: SpecAssemblyNode,\n): Effect.fn.Return<void> {\n yield* cbw.write(\"[\");\n yield* cbw.quote(node.segment);\n yield* cbw.write(\"]: \");\n yield* writeGroupAssembly(cbw, node);\n yield* cbw.write(\",\\n\");\n});\n\nconst writeGroupAssembly: (\n cbw: CodeBlockWriter,\n node: SpecAssemblyNode,\n) => Effect.Effect<void> = Effect.fnUntraced(function* (cbw, node) {\n const group = Option.match(node.importBinding, {\n onNone: () => \"GroupSpec.make()\",\n onSome: (binding) => binding.localName,\n });\n yield* Array.match(node.children, {\n onEmpty: () => cbw.write(group),\n onNonEmpty: (children) =>\n Effect.gen(function* () {\n yield* cbw.write(`GroupSpec.addGroupsAt(${group}, {\\n`);\n yield* cbw.indent(\n Effect.forEach(children, (child) => writeGroupEntry(cbw, child)),\n );\n yield* cbw.write(\"})\");\n }),\n });\n});\n\nconst groupTypeExpr = (node: SpecAssemblyNode): string =>\n Array.match(node.children, {\n onEmpty: () =>\n Option.match(node.importBinding, {\n onNone: () =>\n `GroupSpec.GroupSpec<\"Convex\", \"${node.segment}\", never, never>`,\n onSome: (binding) => `typeof ${binding.localName}`,\n }),\n onNonEmpty: (children) => {\n const childUnion = pipe(\n children,\n Array.map(rootGroupTypeMember),\n Array.join(\" | \"),\n );\n return Option.match(node.importBinding, {\n onNone: () =>\n `GroupSpec.GroupSpec<\"Convex\", \"${node.segment}\", never, ${childUnion}>`,\n onSome: (binding) =>\n `GroupSpec.AddGroups<typeof ${binding.localName}, ${childUnion}>`,\n });\n },\n });\n\nconst rootGroupTypeMember = (node: SpecAssemblyNode): string =>\n `GroupSpec.NamedAt<${groupTypeExpr(node)}, \"${node.segment}\">`;\n\nexport const render = Effect.fnUntraced(function* (\n nodes: ReadonlyArray<SpecAssemblyNode>,\n) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n Array.match(nodes, {\n onEmpty: () => `import { Spec } from \"@confect/core\";`,\n onNonEmpty: () => `import { GroupSpec, Spec } from \"@confect/core\";`,\n }),\n );\n\n yield* Effect.forEach(collectImportBindings(nodes), (binding) =>\n cbw.writeLine(`import ${binding.localName} from \"${binding.importPath}\";`),\n );\n\n yield* cbw.blankLine();\n\n yield* cbw.write(\"const spec: \");\n yield* Array.match(nodes, {\n onEmpty: () => cbw.write(\"Spec.Spec\"),\n onNonEmpty: (nonEmptyNodes) =>\n Effect.gen(function* () {\n yield* cbw.write(\"Spec.Spec<{\\n\");\n yield* cbw.indent(\n Effect.forEach(nonEmptyNodes, (node) =>\n cbw.writeLine(\n `readonly ${node.segment}: ${rootGroupTypeMember(node)};`,\n ),\n ),\n );\n yield* cbw.write(\"}>\");\n }),\n });\n yield* cbw.write(\" = Spec.fromGroups({\\n\");\n yield* cbw.indent(\n Effect.forEach(nodes, (node) => writeGroupEntry(cbw, node)),\n );\n yield* cbw.writeLine(\"}) as typeof spec;\");\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default spec;`);\n\n return yield* cbw.toString();\n});\n"],"mappings":";;;;;;;;AAqBA,MAAM,yBAAyB,UAAyC;CACtE,YAAY,KAAK;CACjB,YAAY,KAAK;CACjB,WAAW,MAAM,KAAK,KAAK,cAAc,GAAG;AAC9C;AAEA,MAAM,wBACJ,QACA,UAEA,KACE,MAAM,QAAQ,SAAS,SAAS,KAAK,aAAa,MAAO,GACzD,OAAO,WACP,MAAM,OAAO,MAAM,SAAS,MAAM,SAAS,CAAC,aAAa,OAAO,CAAC,GACjE,MAAM,KAAK,CAAC,SAAS,iBAAiB;CACpC,MAAM,WAAW,MAAM,UACrB,cACC,SAAS,KAAK,aAAa,WAAW,QAAQ,CACjD;CACA,MAAM,cAAc,MAAM,OACxB,cACC,SAAS,KAAK,aAAa,SAAS,QAAQ,CAC/C;CACA,OAAO;EACL;EACA,eAAe,OAAO,IAAI,UAAU,qBAAqB;EACzD,UAAU,qBAAqB,aAAa,QAAQ,CAAC;CACvD;AACF,CAAC,CACH;AAEF,MAAa,2BACX,WACoC,qBAAqB,QAAQ,CAAC;AAEpE,MAAM,yBACJ,SAEA,KAAK,KAAK,UAAU,MAAM,QAAQ,qBAAqB,IAAI,kBACzD,OAAO,MAAM,KAAK,eAAe;CAC/B,cAAc;CACd,SAAS,YAAY,MAAM,QAAQ,eAAe,OAAO;AAC3D,CAAC,CACH;AAEF,MAAa,yBACX,UAEA,KACE,MAAM,QAAQ,OAAO,qBAAqB,IACzC,aACC,OAAO,eAAe,WAAW,YAAY,QAAQ,UAAU,GACjE,OAAO,WACP,MAAM,KAAK,GAAG,aAAa,OAAO,GAClC,MAAM,OAAO,MAAM,SAAS,MAAM,SAAS,YAAY,QAAQ,SAAS,CAAC,CAC3E;AAEF,MAA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;CAE3D,OAAO,IAAI,UACT,MAAM,MAAM,OAAO;EACjB,eAAe;EACf,kBAAkB;CACpB,CAAC,CACH;CAEA,OAAO,OAAO,QAAQ,sBAAsB,KAAK,IAAI,YACnD,IAAI,UAAU,UAAU,QAAQ,UAAU,SAAS,QAAQ,WAAW,GAAG,CAC3E;CAEA,OAAO,IAAI,UAAU;CAErB,OAAO,IAAI,MAAM,cAAc;CAC/B,OAAO,MAAM,MAAM,OAAO;EACxB,eAAe,IAAI,MAAM,WAAW;EACpC,aAAa,kBACX,OAAO,IAAI,aAAa;GACtB,OAAO,IAAI,MAAM,eAAe;GAChC,OAAO,IAAI,OACT,OAAO,QAAQ,gBAAgB,SAC7B,IAAI,UACF,YAAY,KAAK,QAAQ,IAAI,oBAAoB,IAAI,EAAE,EACzD,CACF,CACF;GACA,OAAO,IAAI,MAAM,IAAI;EACvB,CAAC;CACL,CAAC;CACD,OAAO,IAAI,MAAM,wBAAwB;CACzC,OAAO,IAAI,OACT,OAAO,QAAQ,QAAQ,SAAS,gBAAgB,KAAK,IAAI,CAAC,CAC5D;CACA,OAAO,IAAI,UAAU,oBAAoB;CACzC,OAAO,IAAI,UAAU;CACrB,OAAO,IAAI,UAAU,sBAAsB;CAE3C,OAAO,OAAO,IAAI,SAAS;AAC7B,CAAC"}
|
|
1
|
+
{"version":3,"file":"SpecAssemblyNode.mjs","names":[],"sources":["../src/SpecAssemblyNode.ts"],"sourcesContent":["import type { LeafModule } from \"./LeafModule.js\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport { CodeBlockWriter } from \"./CodeBlockWriter.js\";\nimport * as Option from \"effect/Option\";\nimport * as Order from \"effect/Order\";\nimport * as Record from \"effect/Record\";\n\nexport interface SpecImportBinding {\n readonly importPath: string;\n readonly exportName: string;\n readonly localName: string;\n}\n\nexport interface SpecAssemblyNode {\n readonly segment: string;\n readonly importBinding: Option.Option<SpecImportBinding>;\n readonly children: ReadonlyArray<SpecAssemblyNode>;\n}\n\nconst importBindingFromLeaf = (leaf: LeafModule): SpecImportBinding => ({\n importPath: leaf.specImportPath,\n exportName: leaf.exportName,\n localName: Array.join(leaf.pathSegments, \"_\"),\n});\n\nconst assemblyNodesAtDepth = (\n leaves: ReadonlyArray<LeafModule>,\n depth: number,\n): ReadonlyArray<SpecAssemblyNode> =>\n pipe(\n Array.groupBy(leaves, (leaf) => leaf.pathSegments[depth]!),\n Record.toEntries,\n Array.sortBy(Order.mapInput(Order.String, ([segment]) => segment)),\n Array.map(([segment, groupLeaves]) => {\n const terminal = Array.findFirst(\n groupLeaves,\n (leaf) => leaf.pathSegments.length === depth + 1,\n );\n const descendants = Array.filter(\n groupLeaves,\n (leaf) => leaf.pathSegments.length > depth + 1,\n );\n return {\n segment,\n importBinding: Option.map(terminal, importBindingFromLeaf),\n children: assemblyNodesAtDepth(descendants, depth + 1),\n };\n }),\n );\n\nexport const assemblyNodesFromLeaves = (\n leaves: ReadonlyArray<LeafModule>,\n): ReadonlyArray<SpecAssemblyNode> => assemblyNodesAtDepth(leaves, 0);\n\nconst importBindingsForNode = (\n node: SpecAssemblyNode,\n): ReadonlyArray<SpecImportBinding> =>\n pipe(node.children, Array.flatMap(importBindingsForNode), (childBindings) =>\n Option.match(node.importBinding, {\n onNone: () => childBindings,\n onSome: (binding) => Array.prepend(childBindings, binding),\n }),\n );\n\nexport const collectImportBindings = (\n nodes: ReadonlyArray<SpecAssemblyNode>,\n): ReadonlyArray<SpecImportBinding> =>\n pipe(\n Array.flatMap(nodes, importBindingsForNode),\n (bindings) =>\n Record.fromIterableBy(bindings, (binding) => binding.importPath),\n Record.toEntries,\n Array.map(([, binding]) => binding),\n Array.sortBy(Order.mapInput(Order.String, (binding) => binding.localName)),\n );\n\nconst writeGroupEntry = Effect.fnUntraced(function* (\n cbw: CodeBlockWriter,\n node: SpecAssemblyNode,\n): Effect.fn.Return<void> {\n yield* cbw.write(\"[\");\n yield* cbw.quote(node.segment);\n yield* cbw.write(\"]: \");\n yield* writeGroupAssembly(cbw, node);\n yield* cbw.write(\",\\n\");\n});\n\nconst writeGroupAssembly: (\n cbw: CodeBlockWriter,\n node: SpecAssemblyNode,\n) => Effect.Effect<void> = Effect.fnUntraced(function* (cbw, node) {\n const group = Option.match(node.importBinding, {\n onNone: () => \"GroupSpec.make()\",\n onSome: (binding) => binding.localName,\n });\n yield* Array.match(node.children, {\n onEmpty: () => cbw.write(group),\n onNonEmpty: (children) =>\n Effect.gen(function* () {\n yield* cbw.write(`GroupSpec.addGroupsAt(${group}, {\\n`);\n yield* cbw.indent(\n Effect.forEach(children, (child) => writeGroupEntry(cbw, child)),\n );\n yield* cbw.write(\"})\");\n }),\n });\n});\n\nconst groupTypeExpr = (node: SpecAssemblyNode): string =>\n Array.match(node.children, {\n onEmpty: () =>\n Option.match(node.importBinding, {\n onNone: () =>\n `GroupSpec.GroupSpec<\"Convex\", \"${node.segment}\", never, never>`,\n onSome: (binding) => `typeof ${binding.localName}`,\n }),\n onNonEmpty: (children) => {\n const childUnion = pipe(\n children,\n Array.map(rootGroupTypeMember),\n Array.join(\" | \"),\n );\n return Option.match(node.importBinding, {\n onNone: () =>\n `GroupSpec.GroupSpec<\"Convex\", \"${node.segment}\", never, ${childUnion}>`,\n onSome: (binding) =>\n `GroupSpec.AddGroups<typeof ${binding.localName}, ${childUnion}>`,\n });\n },\n });\n\nconst rootGroupTypeMember = (node: SpecAssemblyNode): string =>\n `GroupSpec.NamedAt<${groupTypeExpr(node)}, \"${node.segment}\">`;\n\nexport const render = Effect.fnUntraced(function* (\n nodes: ReadonlyArray<SpecAssemblyNode>,\n) {\n const cbw = new CodeBlockWriter({ indentNumberOfSpaces: 2 });\n\n yield* cbw.writeLine(\n Array.match(nodes, {\n onEmpty: () => `import { Spec } from \"@confect/core\";`,\n onNonEmpty: () => `import { GroupSpec, Spec } from \"@confect/core\";`,\n }),\n );\n\n yield* Effect.forEach(collectImportBindings(nodes), (binding) =>\n cbw.writeLine(`import ${binding.localName} from \"${binding.importPath}\";`),\n );\n\n yield* cbw.blankLine();\n\n yield* cbw.write(\"const spec: \");\n yield* Array.match(nodes, {\n onEmpty: () => cbw.write(\"Spec.Spec\"),\n onNonEmpty: (nonEmptyNodes) =>\n Effect.gen(function* () {\n yield* cbw.write(\"Spec.Spec<{\\n\");\n yield* cbw.indent(\n Effect.forEach(nonEmptyNodes, (node) =>\n cbw.writeLine(\n `readonly ${node.segment}: ${rootGroupTypeMember(node)};`,\n ),\n ),\n );\n yield* cbw.write(\"}>\");\n }),\n });\n yield* cbw.write(\" = Spec.fromGroups({\\n\");\n yield* cbw.indent(\n Effect.forEach(nodes, (node) => writeGroupEntry(cbw, node)),\n );\n yield* cbw.writeLine(\"}) as typeof spec;\");\n yield* cbw.blankLine();\n yield* cbw.writeLine(`export default spec;`);\n\n return yield* cbw.toString();\n});\n"],"mappings":";;;;;;;;AAqBA,MAAM,yBAAyB,UAAyC;CACtE,YAAY,KAAK;CACjB,YAAY,KAAK;CACjB,WAAW,MAAM,KAAK,KAAK,cAAc,GAAG;AAC9C;AAEA,MAAM,wBACJ,QACA,UAEA,KACE,MAAM,QAAQ,SAAS,SAAS,KAAK,aAAa,MAAO,GACzD,OAAO,WACP,MAAM,OAAO,MAAM,SAAS,MAAM,SAAS,CAAC,aAAa,OAAO,CAAC,GACjE,MAAM,KAAK,CAAC,SAAS,iBAAiB;CACpC,MAAM,WAAW,MAAM,UACrB,cACC,SAAS,KAAK,aAAa,WAAW,QAAQ,CACjD;CACA,MAAM,cAAc,MAAM,OACxB,cACC,SAAS,KAAK,aAAa,SAAS,QAAQ,CAC/C;CACA,OAAO;EACL;EACA,eAAe,OAAO,IAAI,UAAU,qBAAqB;EACzD,UAAU,qBAAqB,aAAa,QAAQ,CAAC;CACvD;AACF,CAAC,CACH;AAEF,MAAa,2BACX,WACoC,qBAAqB,QAAQ,CAAC;AAEpE,MAAM,yBACJ,SAEA,KAAK,KAAK,UAAU,MAAM,QAAQ,qBAAq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Suffix"],"sources":["../src/SpecModulePath.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\nimport { ImplModulePath } from \"./ImplModulePath\";\nimport * as RelativeModulePath from \"./RelativeModulePath\";\n\nexport const SpecModulePath = RelativeModulePath.withSuffix(\".spec.ts\").pipe(\n Schema.brand(\"@confect/cli/SpecModulePath\"),\n);\n\nexport type SpecModulePath = typeof SpecModulePath.Type;\n\nexport const toImpl = (path: SpecModulePath): ImplModulePath =>\n ImplModulePath.make(`${path.slice(0, -\".spec.ts\".length)}.impl.ts`);\n\nexport const fromImpl = (path: ImplModulePath): SpecModulePath =>\n SpecModulePath.make(`${path.slice(0, -\".impl.ts\".length)}.spec.ts`);\n"],"mappings":";;;;AAIA,MAAa,iBAAiBA,WAA8B,UAAU,CAAC,CAAC,KACtE,OAAO,MAAM,6BAA6B,CAC5C;AAIA,MAAa,UAAU,SACrB,eAAe,KAAK,GAAG,KAAK,MAAM,GAAG,EAAkB,EAAE,SAAS"}
|
|
1
|
+
{"version":3,"file":"SpecModulePath.mjs","names":["RelativeModulePath.withSuffix"],"sources":["../src/SpecModulePath.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\nimport { ImplModulePath } from \"./ImplModulePath.js\";\nimport * as RelativeModulePath from \"./RelativeModulePath.js\";\n\nexport const SpecModulePath = RelativeModulePath.withSuffix(\".spec.ts\").pipe(\n Schema.brand(\"@confect/cli/SpecModulePath\"),\n);\n\nexport type SpecModulePath = typeof SpecModulePath.Type;\n\nexport const toImpl = (path: SpecModulePath): ImplModulePath =>\n ImplModulePath.make(`${path.slice(0, -\".spec.ts\".length)}.impl.ts`);\n\nexport const fromImpl = (path: ImplModulePath): SpecModulePath =>\n SpecModulePath.make(`${path.slice(0, -\".impl.ts\".length)}.spec.ts`);\n"],"mappings":";;;;AAIA,MAAa,iBAAiBA,WAA8B,UAAU,CAAC,CAAC,KACtE,OAAO,MAAM,6BAA6B,CAC5C;AAIA,MAAa,UAAU,SACrB,eAAe,KAAK,GAAG,KAAK,MAAM,GAAG,EAAkB,EAAE,SAAS"}
|
package/dist/SyncState.mjs
CHANGED
|
@@ -45,7 +45,7 @@ const add = (pending, entries, forceFull = false) => {
|
|
|
45
45
|
})), Match.tag("Spec", "Table", (declaration) => ({
|
|
46
46
|
...state,
|
|
47
47
|
declarations: HashMap.set(state.declarations, `${declaration._tag}:${declaration.relativePath}`, declaration)
|
|
48
|
-
})), Match.tag("Config", "Env", "App", "Callbacks", () => ({
|
|
48
|
+
})), Match.tag("Config", "Env", "App", "Callbacks", "Runtime", () => ({
|
|
49
49
|
...state,
|
|
50
50
|
needsFull: true
|
|
51
51
|
})), Match.exhaustive));
|
package/dist/SyncState.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SyncState.mjs","names":[],"sources":["../src/SyncState.ts"],"sourcesContent":["import * as Array from \"effect/Array\";\nimport * as Data from \"effect/Data\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as HashMap from \"effect/HashMap\";\nimport * as Match from \"effect/Match\";\nimport type { Declaration, Kind, OptionalFile } from \"./EntryPoint\";\nimport type { ImplModulePath } from \"./ImplModulePath\";\nimport type { GenerationSnapshot } from \"./GenerationSnapshot\";\n\nexport type Work = Data.TaggedEnum<{\n None: {};\n Reconcile: {};\n Full: {};\n Impls: { readonly paths: Array.NonEmptyReadonlyArray<ImplModulePath> };\n Declarations: {\n readonly entries: Array.NonEmptyReadonlyArray<Declaration>;\n readonly paths: ReadonlyArray<ImplModulePath>;\n };\n}>;\nexport const Work = Data.taggedEnum<Work>();\n\nexport interface Pending {\n readonly work: Work;\n readonly optional: HashSet.HashSet<OptionalFile>;\n}\n\nexport const empty: Pending = { work: Work.None(), optional: HashSet.empty() };\nexport const isDirty = (pending: Pending): boolean =>\n !Work.$is(\"None\")(pending.work) || !HashSet.isEmpty(pending.optional);\nexport const full = (pending: Pending): Pending => ({\n ...pending,\n work: Work.Full(),\n});\n\nexport const reconcile = (pending: Pending): Pending => ({\n ...pending,\n work: Work.$is(\"None\")(pending.work) ? Work.Reconcile() : pending.work,\n});\n\nexport const add = (\n pending: Pending,\n entries: ReadonlyArray<Kind>,\n forceFull = false,\n): Pending => {\n const next = Array.reduce(\n entries,\n {\n needsFull: forceFull || Work.$is(\"Full\")(pending.work),\n paths: Work.$match(pending.work, {\n None: () => HashSet.empty<ImplModulePath>(),\n Reconcile: () => HashSet.empty<ImplModulePath>(),\n Full: () => HashSet.empty<ImplModulePath>(),\n Impls: ({ paths }) => HashSet.fromIterable(paths),\n Declarations: ({ paths }) => HashSet.fromIterable(paths),\n }),\n declarations: Work.$match(pending.work, {\n None: () => HashMap.empty<string, Declaration>(),\n Reconcile: () => HashMap.empty<string, Declaration>(),\n Full: () => HashMap.empty<string, Declaration>(),\n Impls: () => HashMap.empty<string, Declaration>(),\n Declarations: ({ entries: declarations }) =>\n HashMap.fromIterable(\n declarations.map(\n (entry) =>\n [`${entry._tag}:${entry.relativePath}`, entry] as const,\n ),\n ),\n }),\n optional: pending.optional,\n },\n (state, entry) =>\n Match.value(entry).pipe(\n Match.tag(\"Impl\", ({ relativePath }) => ({\n ...state,\n paths: HashSet.add(state.paths, relativePath),\n })),\n Match.tag(\"Http\", \"Crons\", \"Auth\", ({ _tag }) => ({\n ...state,\n optional: HashSet.add(state.optional, _tag),\n })),\n Match.tag(\"Spec\", \"Table\", (declaration) => ({\n ...state,\n declarations: HashMap.set(\n state.declarations,\n `${declaration._tag}:${declaration.relativePath}`,\n declaration,\n ),\n })),\n Match.tag(\"Config\", \"Env\", \"App\", \"Callbacks\", () => ({\n ...state,\n needsFull: true,\n })),\n Match.exhaustive,\n ),\n );\n const impls = Array.fromIterable(next.paths);\n const declarations = Array.fromIterable(HashMap.values(next.declarations));\n return {\n work: next.needsFull\n ? Work.Full()\n : Array.isReadonlyArrayNonEmpty(declarations)\n ? Work.Declarations({ entries: declarations, paths: impls })\n : Array.isReadonlyArrayNonEmpty(impls)\n ? Work.Impls({ paths: impls })\n : Work.$is(\"Reconcile\")(pending.work)\n ? Work.Reconcile()\n : Work.None(),\n optional: next.optional,\n };\n};\n\nexport interface Backend {\n readonly declared: boolean;\n readonly component: boolean;\n}\n\n/**\n * Full generation writes a declared backend's `convex/http.ts` and\n * `auth.config.ts` and rejects a component's `auth.ts`, so those edits need it\n * instead of the optional-file writers.\n */\nexport const forBackend = (pending: Pending, backend: Backend): Pending => {\n const generated = HashSet.filter(pending.optional, (file) =>\n Match.value(file).pipe(\n Match.when(\"Http\", () => backend.declared),\n Match.when(\"Auth\", () => backend.declared || backend.component),\n Match.when(\"Crons\", () => false),\n Match.exhaustive,\n ),\n );\n if (HashSet.isEmpty(generated)) return pending;\n return {\n work: Work.Full(),\n optional: backend.declared\n ? HashSet.difference(pending.optional, generated)\n : pending.optional,\n };\n};\n\nexport type Phase = Data.TaggedEnum<{\n Bootstrapping: {};\n NeedsFullSync: {};\n Incremental: {\n readonly failedImpls: HashSet.HashSet<ImplModulePath>;\n readonly snapshot: GenerationSnapshot;\n };\n}>;\nexport const Phase = Data.taggedEnum<Phase>();\n\nexport type Outcome = Data.TaggedEnum<{\n Succeeded: { readonly snapshot: GenerationSnapshot };\n GenerationFailed: {};\n ReconciliationFailed: {};\n ValidationFailed: {\n readonly snapshot: GenerationSnapshot;\n readonly paths: Array.NonEmptyReadonlyArray<ImplModulePath>;\n };\n}>;\nexport const Outcome = Data.taggedEnum<Outcome>();\n\nexport const transition = (outcome: Outcome): Phase =>\n Outcome.$match(outcome, {\n Succeeded: ({ snapshot }) =>\n Phase.Incremental({\n snapshot,\n failedImpls: HashSet.empty(),\n }),\n GenerationFailed: () => Phase.NeedsFullSync(),\n ReconciliationFailed: () => Phase.NeedsFullSync(),\n ValidationFailed: ({ snapshot, paths }) =>\n Phase.Incremental({\n snapshot,\n failedImpls: HashSet.fromIterable(paths),\n }),\n });\n\nexport const shouldRetry = (phase: Phase, outcome: Outcome): boolean =>\n Phase.$is(\"Bootstrapping\")(phase) && Outcome.$is(\"GenerationFailed\")(outcome);\n\nexport const needsDeploymentNotification = (phase: Phase): boolean =>\n Phase.$match(phase, {\n Bootstrapping: () => true,\n NeedsFullSync: () => true,\n Incremental: ({ failedImpls }) => !HashSet.isEmpty(failedImpls),\n });\n\nexport const implsToValidate = (\n phase: Phase,\n pending: Pending,\n): ReadonlyArray<ImplModulePath> =>\n Array.fromIterable(\n HashSet.union(\n Phase.$match(phase, {\n Bootstrapping: () => HashSet.empty<ImplModulePath>(),\n NeedsFullSync: () => HashSet.empty<ImplModulePath>(),\n Incremental: ({ failedImpls }) => failedImpls,\n }),\n Work.$match(pending.work, {\n None: () => HashSet.empty<ImplModulePath>(),\n Reconcile: () => HashSet.empty<ImplModulePath>(),\n Full: () => HashSet.empty<ImplModulePath>(),\n Impls: ({ paths }) => HashSet.fromIterable(paths),\n Declarations: ({ paths }) => HashSet.fromIterable(paths),\n }),\n ),\n );\n\nexport type Operation = Data.TaggedEnum<{\n Generate: {};\n Validate: {\n readonly snapshot: GenerationSnapshot;\n readonly paths: ReadonlyArray<ImplModulePath>;\n };\n Update: {\n readonly snapshot: GenerationSnapshot;\n readonly declarations: Array.NonEmptyReadonlyArray<Declaration>;\n readonly paths: ReadonlyArray<ImplModulePath>;\n };\n}>;\nexport const Operation = Data.taggedEnum<Operation>();\n\nexport const plan = (phase: Phase, pending: Pending): Operation =>\n Phase.$match(phase, {\n Bootstrapping: () => Operation.Generate(),\n NeedsFullSync: () => Operation.Generate(),\n Incremental: (ready) =>\n Match.value(pending.work).pipe(\n Match.tag(\"Full\", () => Operation.Generate()),\n Match.tag(\"None\", \"Reconcile\", \"Impls\", () =>\n Operation.Validate({\n snapshot: ready.snapshot,\n paths: implsToValidate(ready, pending),\n }),\n ),\n Match.tag(\"Declarations\", ({ entries }) =>\n Operation.Update({\n snapshot: ready.snapshot,\n declarations: entries,\n paths: implsToValidate(ready, pending),\n }),\n ),\n Match.exhaustive,\n ),\n });\n"],"mappings":";;;;;;AAmBA,MAAa,OAAO,KAAK,WAAi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AAgB,OAAO,OAAO;CACvC,CAAC,CACH,GACA,MAAM,IAAI,iBAAiB,EAAE,cAC3B,UAAU,OAAO;EACf,UAAU,MAAM;EAChB,cAAc;EACd,OAAO,gBAAgB,OAAO,OAAO;CACvC,CAAC,CACH,GACA,MAAM,UACR;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"SyncState.mjs","names":[],"sources":["../src/SyncState.ts"],"sourcesContent":["import * as Array from \"effect/Array\";\nimport * as Data from \"effect/Data\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as HashMap from \"effect/HashMap\";\nimport * as Match from \"effect/Match\";\nimport type { Declaration, Kind, OptionalFile } from \"./EntryPoint.js\";\nimport type { ImplModulePath } from \"./ImplModulePath.js\";\nimport type { GenerationSnapshot } from \"./GenerationSnapshot.js\";\n\nexport type Work = Data.TaggedEnum<{\n None: {};\n Reconcile: {};\n Full: {};\n Impls: { readonly paths: Array.NonEmptyReadonlyArray<ImplModulePath> };\n Declarations: {\n readonly entries: Array.NonEmptyReadonlyArray<Declaration>;\n readonly paths: ReadonlyArray<ImplModulePath>;\n };\n}>;\nexport const Work = Data.taggedEnum<Work>();\n\nexport interface Pending {\n readonly work: Work;\n readonly optional: HashSet.HashSet<OptionalFile>;\n}\n\nexport const empty: Pending = { work: Work.None(), optional: HashSet.empty() };\nexport const isDirty = (pending: Pending): boolean =>\n !Work.$is(\"None\")(pending.work) || !HashSet.isEmpty(pending.optional);\nexport const full = (pending: Pending): Pending => ({\n ...pending,\n work: Work.Full(),\n});\n\nexport const reconcile = (pending: Pending): Pending => ({\n ...pending,\n work: Work.$is(\"None\")(pending.work) ? Work.Reconcile() : pending.work,\n});\n\nexport const add = (\n pending: Pending,\n entries: ReadonlyArray<Kind>,\n forceFull = false,\n): Pending => {\n const next = Array.reduce(\n entries,\n {\n needsFull: forceFull || Work.$is(\"Full\")(pending.work),\n paths: Work.$match(pending.work, {\n None: () => HashSet.empty<ImplModulePath>(),\n Reconcile: () => HashSet.empty<ImplModulePath>(),\n Full: () => HashSet.empty<ImplModulePath>(),\n Impls: ({ paths }) => HashSet.fromIterable(paths),\n Declarations: ({ paths }) => HashSet.fromIterable(paths),\n }),\n declarations: Work.$match(pending.work, {\n None: () => HashMap.empty<string, Declaration>(),\n Reconcile: () => HashMap.empty<string, Declaration>(),\n Full: () => HashMap.empty<string, Declaration>(),\n Impls: () => HashMap.empty<string, Declaration>(),\n Declarations: ({ entries: declarations }) =>\n HashMap.fromIterable(\n declarations.map(\n (entry) =>\n [`${entry._tag}:${entry.relativePath}`, entry] as const,\n ),\n ),\n }),\n optional: pending.optional,\n },\n (state, entry) =>\n Match.value(entry).pipe(\n Match.tag(\"Impl\", ({ relativePath }) => ({\n ...state,\n paths: HashSet.add(state.paths, relativePath),\n })),\n Match.tag(\"Http\", \"Crons\", \"Auth\", ({ _tag }) => ({\n ...state,\n optional: HashSet.add(state.optional, _tag),\n })),\n Match.tag(\"Spec\", \"Table\", (declaration) => ({\n ...state,\n declarations: HashMap.set(\n state.declarations,\n `${declaration._tag}:${declaration.relativePath}`,\n declaration,\n ),\n })),\n Match.tag(\"Config\", \"Env\", \"App\", \"Callbacks\", \"Runtime\", () => ({\n ...state,\n needsFull: true,\n })),\n Match.exhaustive,\n ),\n );\n const impls = Array.fromIterable(next.paths);\n const declarations = Array.fromIterable(HashMap.values(next.declarations));\n return {\n work: next.needsFull\n ? Work.Full()\n : Array.isReadonlyArrayNonEmpty(declarations)\n ? Work.Declarations({ entries: declarations, paths: impls })\n : Array.isReadonlyArrayNonEmpty(impls)\n ? Work.Impls({ paths: impls })\n : Work.$is(\"Reconcile\")(pending.work)\n ? Work.Reconcile()\n : Work.None(),\n optional: next.optional,\n };\n};\n\nexport interface Backend {\n readonly declared: boolean;\n readonly component: boolean;\n}\n\n/**\n * Full generation writes a declared backend's `convex/http.ts` and\n * `auth.config.ts` and rejects a component's `auth.ts`, so those edits need it\n * instead of the optional-file writers.\n */\nexport const forBackend = (pending: Pending, backend: Backend): Pending => {\n const generated = HashSet.filter(pending.optional, (file) =>\n Match.value(file).pipe(\n Match.when(\"Http\", () => backend.declared),\n Match.when(\"Auth\", () => backend.declared || backend.component),\n Match.when(\"Crons\", () => false),\n Match.exhaustive,\n ),\n );\n if (HashSet.isEmpty(generated)) return pending;\n return {\n work: Work.Full(),\n optional: backend.declared\n ? HashSet.difference(pending.optional, generated)\n : pending.optional,\n };\n};\n\nexport type Phase = Data.TaggedEnum<{\n Bootstrapping: {};\n NeedsFullSync: {};\n Incremental: {\n readonly failedImpls: HashSet.HashSet<ImplModulePath>;\n readonly snapshot: GenerationSnapshot;\n };\n}>;\nexport const Phase = Data.taggedEnum<Phase>();\n\nexport type Outcome = Data.TaggedEnum<{\n Succeeded: { readonly snapshot: GenerationSnapshot };\n GenerationFailed: {};\n ReconciliationFailed: {};\n ValidationFailed: {\n readonly snapshot: GenerationSnapshot;\n readonly paths: Array.NonEmptyReadonlyArray<ImplModulePath>;\n };\n}>;\nexport const Outcome = Data.taggedEnum<Outcome>();\n\nexport const transition = (outcome: Outcome): Phase =>\n Outcome.$match(outcome, {\n Succeeded: ({ snapshot }) =>\n Phase.Incremental({\n snapshot,\n failedImpls: HashSet.empty(),\n }),\n GenerationFailed: () => Phase.NeedsFullSync(),\n ReconciliationFailed: () => Phase.NeedsFullSync(),\n ValidationFailed: ({ snapshot, paths }) =>\n Phase.Incremental({\n snapshot,\n failedImpls: HashSet.fromIterable(paths),\n }),\n });\n\nexport const shouldRetry = (phase: Phase, outcome: Outcome): boolean =>\n Phase.$is(\"Bootstrapping\")(phase) && Outcome.$is(\"GenerationFailed\")(outcome);\n\nexport const needsDeploymentNotification = (phase: Phase): boolean =>\n Phase.$match(phase, {\n Bootstrapping: () => true,\n NeedsFullSync: () => true,\n Incremental: ({ failedImpls }) => !HashSet.isEmpty(failedImpls),\n });\n\nexport const implsToValidate = (\n phase: Phase,\n pending: Pending,\n): ReadonlyArray<ImplModulePath> =>\n Array.fromIterable(\n HashSet.union(\n Phase.$match(phase, {\n Bootstrapping: () => HashSet.empty<ImplModulePath>(),\n NeedsFullSync: () => HashSet.empty<ImplModulePath>(),\n Incremental: ({ failedImpls }) => failedImpls,\n }),\n Work.$match(pending.work, {\n None: () => HashSet.empty<ImplModulePath>(),\n Reconcile: () => HashSet.empty<ImplModulePath>(),\n Full: () => HashSet.empty<ImplModulePath>(),\n Impls: ({ paths }) => HashSet.fromIterable(paths),\n Declarations: ({ paths }) => HashSet.fromIterable(paths),\n }),\n ),\n );\n\nexport type Operation = Data.TaggedEnum<{\n Generate: {};\n Validate: {\n readonly snapshot: GenerationSnapshot;\n readonly paths: ReadonlyArray<ImplModulePath>;\n };\n Update: {\n readonly snapshot: GenerationSnapshot;\n readonly declarations: Array.NonEmptyReadonlyArray<Declaration>;\n readonly paths: ReadonlyArray<ImplModulePath>;\n };\n}>;\nexport const Operation = Data.taggedEnum<Operation>();\n\nexport const plan = (phase: Phase, pending: Pending): Operation =>\n Phase.$match(phase, {\n Bootstrapping: () => Operation.Generate(),\n NeedsFullSync: () => Operation.Generate(),\n Incremental: (ready) =>\n Match.value(pending.work).pipe(\n Match.tag(\"Full\", () => Operation.Generate()),\n Match.tag(\"None\", \"Reconcile\", \"Impls\", () =>\n Operation.Validate({\n snapshot: ready.snapshot,\n paths: implsToValidate(ready, pending),\n }),\n ),\n Match.tag(\"Declarations\", ({ entries }) =>\n Operation.Update({\n snapshot: ready.snapshot,\n declarations: entries,\n paths: implsToValidate(ready, pending),\n }),\n ),\n Match.exhaustive,\n ),\n });\n"],"mappings":";;;;;;AAmBA,MAAa,OAAO,KAAK,WAAiB;AAO1C,MAAa,QAAiB;CAAE,MAAM,KAAK,KAAK;CAAG,UAAU,QAAQ,MAAM;AAAE;AAC7E,MAAa,WAAW,YACtB,CAAC,KAAK,IAAI,MAAM,CAAC,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,QAAQ,QAAQ,QAAQ;AACtE,MAAa,QAAQ,aAA+B;CAClD,GAAG;CACH,MAAM,KAAK,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
|
1
|
-
{"version":3,"file":"TableModule.mjs","names":["Bundler.bundle","Bundler.withBatch"],"sources":["../src/TableModule.ts"],"sourcesContent":["import { Identifier } from \"@confect/core\";\nimport * as Table from \"@confect/core/Table\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Order from \"effect/Order\";\nimport { fromBundlerError } from \"./BuildError\";\nimport * as Bundler from \"./Bundler\";\nimport {\n DuplicateTableNameError,\n InvalidTableDefaultExportError,\n InvalidTableFilenameError,\n} from \"./CodegenError\";\nimport { ConfectDirectory } from \"./ConfectDirectory\";\n\nexport const TABLES_DIRNAME = \"tables\";\n\n/**\n * Discovered metadata for a single user-authored table module under\n * `confect/tables/`.\n *\n * - `relativePath`—path from `confect/` to the file (e.g. `tables/notes.ts`).\n * - `tableName`—the file basename (e.g. `notes`). This is also the import binding\n * used in generated files, and the table name surfaced to Convex.\n */\nexport interface TableModule {\n readonly relativePath: string;\n readonly tableName: string;\n}\n\nconst tableNameFromRelativePath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const { name } = path.parse(relativePath);\n return name;\n});\n\nexport const discoverTableFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const tablesDirectory = path.join(confectDirectory, TABLES_DIRNAME);\n\n if (!(yield* fs.exists(tablesDirectory))) {\n return [] as ReadonlyArray<string>;\n }\n\n const allPaths = yield* fs.readDirectory(tablesDirectory, {\n recursive: true,\n });\n\n return pipe(\n allPaths,\n Array.filter((p) => p.endsWith(\".ts\") && !p.endsWith(\".test.ts\")),\n Array.map((p) => path.join(TABLES_DIRNAME, p)),\n );\n});\n\nconst byTableName = Order.mapInput(\n Order.String,\n (tableModule: TableModule) => tableModule.tableName,\n);\n\n/**\n * Discover every `confect/tables/**\\/*.ts` module by listing the directory.\n * Validates that each filename is a legal table identifier—the table name is\n * derived from the file basename, so the filename must be a valid JavaScript\n * identifier with no leading underscore (Convex reserves `_<name>` for system\n * tables).\n *\n * This step does _not_ bundle the table modules. It runs early in the codegen\n * pipeline so the `_generated/id.ts` constructor can be emitted _before_ any\n * user-authored table is bundled (those modules import from `_generated/id.ts`\n * for cross-table refs).\n *\n * A missing `confect/tables/` directory is allowed and produces an empty list.\n *\n * Fails with {@link InvalidTableFilenameError} if any filename is not a valid\n * table identifier, or {@link DuplicateTableNameError} if two files resolve to\n * the same table name (the directory is scanned recursively but names are\n * derived from the basename alone, so `tables/a/notes.ts` and\n * `tables/b/notes.ts` would collide).\n */\nexport const discover = Effect.gen(function* () {\n const relativePaths = yield* discoverTableFiles;\n\n const tableModules = yield* Effect.forEach(\n relativePaths,\n Effect.fnUntraced(function* (relativePath: string) {\n const tableName = yield* tableNameFromRelativePath(relativePath);\n yield* Effect.try({\n try: () => Identifier.validateConfectTableIdentifier(tableName),\n catch: (e) =>\n new InvalidTableFilenameError({\n tablePath: relativePath,\n reason: e instanceof Error ? e.message : String(e),\n }),\n });\n return { relativePath, tableName } satisfies TableModule;\n }),\n { concurrency: \"unbounded\" },\n );\n\n const sorted = pipe(tableModules, Array.sortBy(byTableName));\n\n const collisions = Object.entries(\n Array.groupBy(sorted, (tableModule) => tableModule.tableName),\n )\n .filter(([, group]) => group.length > 1)\n .map(([tableName, group]) => ({\n tableName,\n tablePaths: Array.map(group, (tableModule) => tableModule.relativePath),\n }));\n\n if (collisions.length > 0) {\n return yield* new DuplicateTableNameError({ collisions });\n }\n\n return sorted;\n});\n\n/**\n * Bundle every discovered table module and verify that its default export is an\n * {@link Table.UnnamedTable} (the result of `Table.make(...)` before a name has\n * been bound). Fails with {@link InvalidTableDefaultExportError} if any\n * module's default export is missing or has the wrong shape.\n *\n * Must run _after_ `_generated/id.ts` has been emitted, because user-authored\n * table modules typically `import { Id } from \"../_generated/id\"` for\n * cross-table references.\n */\nexport const validate = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const validateRelativePath = Effect.fnUntraced(function* (\n relativePath: string,\n ) {\n const absolutePath = path.resolve(confectDirectory, relativePath);\n const { module } = yield* Bundler.bundle(absolutePath).pipe(\n Effect.mapError((error) => fromBundlerError(relativePath, error)),\n );\n\n if (!Table.isUnnamedTable(module.default)) {\n return yield* new InvalidTableDefaultExportError({\n tablePath: relativePath,\n });\n }\n });\n\n const relativePaths = tableModules.map(({ relativePath }) => relativePath);\n yield* Bundler.withBatch(\n relativePaths.map((relativePath) =>\n path.resolve(confectDirectory, relativePath),\n ),\n Effect.forEach(relativePaths, validateRelativePath, { concurrency: 4 }),\n );\n});\n"],"mappings":";;;;;;;;;;;;;AAiBA,MAAa,iBAAiB;AAe9B,MAAM,4BAA4B,OAAO,WAAW,WAClD,cACA;CAEA,MAAM,EAAE,UAAS,OADG,KAAK,KAAA,CACH,MAAM,YAAY;CACxC,OAAO;AACT,CAAC;AAED,MAAa,qBAAqB,OAAO,IAAI,aAAa;CACxD,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,mBAAmB,OAAO,iBAAiB;CACjD,MAAM,kBAAkB,KAAK,KAAK,kBAAkB,cAAc;CAElE,IAAI,EAAE,OAAO,GAAG,OAAO,eAAe,IACpC,OAAO,CAAC;CAGV,MAAM,WAAW,OAAO,GAAG,cAAc,iBAAiB,EACxD,WAAW,KACb,CAAC;CAED,OAAO,KACL,UACA,MAAM,QAAQ,MAAM,EAAE,SAAS,KAAK,KAAK,CAAC,EAAE,SAAS,UAAU,CAAC,GAChE,MAAM,KAAK,MAAM,KAAK,KAAK,gBAAgB,CAAC,CAAC,CAC/C;AACF,CAAC;AAED,MAAM,cAAc,MAAM,SACxB,MAAM,SACL,gBAA6B,YAAY,SAC5C;;;;;;;;;;;;;;;;;;;;;A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;CAED,MAAM,gBAAgB,aAAa,KAAK,EAAE,mBAAmB,YAAY;CACzE,OAAOC,UACL,cAAc,KAAK,iBACjB,KAAK,QAAQ,kBAAkB,YAAY,CAC7C,GACA,OAAO,QAAQ,eAAe,sBAAsB,EAAE,aAAa,EAAE,CAAC,CACxE;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"TableModule.mjs","names":["Bundler.bundle","Bundler.withBatch"],"sources":["../src/TableModule.ts"],"sourcesContent":["import { Identifier } from \"@confect/core\";\nimport * as Table from \"@confect/core/Table\";\nimport * as FileSystem from \"effect/FileSystem\";\nimport * as Path from \"effect/Path\";\nimport { pipe } from \"effect/Function\";\nimport * as Array from \"effect/Array\";\nimport * as Effect from \"effect/Effect\";\nimport * as Order from \"effect/Order\";\nimport { fromBundlerError } from \"./BuildError.js\";\nimport * as Bundler from \"./Bundler.js\";\nimport {\n DuplicateTableNameError,\n InvalidTableDefaultExportError,\n InvalidTableFilenameError,\n} from \"./CodegenError.js\";\nimport { ConfectDirectory } from \"./ConfectDirectory.js\";\n\nexport const TABLES_DIRNAME = \"tables\";\n\n/**\n * Discovered metadata for a single user-authored table module under\n * `confect/tables/`.\n *\n * - `relativePath`—path from `confect/` to the file (e.g. `tables/notes.ts`).\n * - `tableName`—the file basename (e.g. `notes`). This is also the import binding\n * used in generated files, and the table name surfaced to Convex.\n */\nexport interface TableModule {\n readonly relativePath: string;\n readonly tableName: string;\n}\n\nconst tableNameFromRelativePath = Effect.fnUntraced(function* (\n relativePath: string,\n) {\n const path = yield* Path.Path;\n const { name } = path.parse(relativePath);\n return name;\n});\n\nexport const discoverTableFiles = Effect.gen(function* () {\n const fs = yield* FileSystem.FileSystem;\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n const tablesDirectory = path.join(confectDirectory, TABLES_DIRNAME);\n\n if (!(yield* fs.exists(tablesDirectory))) {\n return [] as ReadonlyArray<string>;\n }\n\n const allPaths = yield* fs.readDirectory(tablesDirectory, {\n recursive: true,\n });\n\n return pipe(\n allPaths,\n Array.filter((p) => p.endsWith(\".ts\") && !p.endsWith(\".test.ts\")),\n Array.map((p) => path.join(TABLES_DIRNAME, p)),\n );\n});\n\nconst byTableName = Order.mapInput(\n Order.String,\n (tableModule: TableModule) => tableModule.tableName,\n);\n\n/**\n * Discover every `confect/tables/**\\/*.ts` module by listing the directory.\n * Validates that each filename is a legal table identifier—the table name is\n * derived from the file basename, so the filename must be a valid JavaScript\n * identifier with no leading underscore (Convex reserves `_<name>` for system\n * tables).\n *\n * This step does _not_ bundle the table modules. It runs early in the codegen\n * pipeline so the `_generated/id.ts` constructor can be emitted _before_ any\n * user-authored table is bundled (those modules import from `_generated/id.ts`\n * for cross-table refs).\n *\n * A missing `confect/tables/` directory is allowed and produces an empty list.\n *\n * Fails with {@link InvalidTableFilenameError} if any filename is not a valid\n * table identifier, or {@link DuplicateTableNameError} if two files resolve to\n * the same table name (the directory is scanned recursively but names are\n * derived from the basename alone, so `tables/a/notes.ts` and\n * `tables/b/notes.ts` would collide).\n */\nexport const discover = Effect.gen(function* () {\n const relativePaths = yield* discoverTableFiles;\n\n const tableModules = yield* Effect.forEach(\n relativePaths,\n Effect.fnUntraced(function* (relativePath: string) {\n const tableName = yield* tableNameFromRelativePath(relativePath);\n yield* Effect.try({\n try: () => Identifier.validateConfectTableIdentifier(tableName),\n catch: (e) =>\n new InvalidTableFilenameError({\n tablePath: relativePath,\n reason: e instanceof Error ? e.message : String(e),\n }),\n });\n return { relativePath, tableName } satisfies TableModule;\n }),\n { concurrency: \"unbounded\" },\n );\n\n const sorted = pipe(tableModules, Array.sortBy(byTableName));\n\n const collisions = Object.entries(\n Array.groupBy(sorted, (tableModule) => tableModule.tableName),\n )\n .filter(([, group]) => group.length > 1)\n .map(([tableName, group]) => ({\n tableName,\n tablePaths: Array.map(group, (tableModule) => tableModule.relativePath),\n }));\n\n if (collisions.length > 0) {\n return yield* new DuplicateTableNameError({ collisions });\n }\n\n return sorted;\n});\n\n/**\n * Bundle every discovered table module and verify that its default export is an\n * {@link Table.UnnamedTable} (the result of `Table.make(...)` before a name has\n * been bound). Fails with {@link InvalidTableDefaultExportError} if any\n * module's default export is missing or has the wrong shape.\n *\n * Must run _after_ `_generated/id.ts` has been emitted, because user-authored\n * table modules typically `import { Id } from \"../_generated/id\"` for\n * cross-table references.\n */\nexport const validate = Effect.fnUntraced(function* (\n tableModules: ReadonlyArray<TableModule>,\n) {\n const path = yield* Path.Path;\n const confectDirectory = yield* ConfectDirectory.get;\n\n const validateRelativePath = Effect.fnUntraced(function* (\n relativePath: string,\n ) {\n const absolutePath = path.resolve(confectDirectory, relativePath);\n const { module } = yield* Bundler.bundle(absolutePath).pipe(\n Effect.mapError((error) => fromBundlerError(relativePath, error)),\n );\n\n if (!Table.isUnnamedTable(module.default)) {\n return yield* new InvalidTableDefaultExportError({\n tablePath: relativePath,\n });\n }\n });\n\n const relativePaths = tableModules.map(({ relativePath }) => relativePath);\n yield* Bundler.withBatch(\n relativePaths.map((relativePath) =>\n path.resolve(confectDirectory, relativePath),\n ),\n Effect.forEach(relativePaths, validateRelativePath, { concurrency: 4 }),\n );\n});\n"],"mappings":";;;;;;;;;;;;;AAiBA,MAAa,iBAAiB;AAe9B,MAAM,4BAA4B,OAAO,WAAW,WAClD,cACA;CAEA,MAAM,EAAE,UAAS,OADG,KAAK,KAAA,CACH,MAAM,YAAY;CACxC,OAAO;AACT,CAAC;AAED,MAAa,qBAAqB,OAAO,IAAI,aAAa;CACxD,MAAM,KAAK,OAAO,WAAW;CAC7B,MAAM,OAAO,OAAO,KAAK;CACzB,MAAM,mBAAmB,OAAO,iBAAiB;CACjD,MAAM,kBAAkB,KAAK,KAAK,kBAAkB,cAAc;CAElE,IAAI,EAAE,OAAO,GAAG,OAAO,eAAe,IACpC,OAAO,CAAC;CAGV,MAAM,WAAW,OAAO,GAAG,cAAc,iBAAiB,EACxD,WAAW,KACb,CAAC;CAED,OAAO,KACL,UACA,MAAM,QAAQ,MAAM,EAA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M,EAAE,WAAW,OAAOA,OAAe,YAAY,CAAC,CAAC,KACrD,OAAO,UAAU,UAAU,iBAAiB,cAAc,KAAK,CAAC,CAClE;EAEA,IAAI,CAAC,MAAM,eAAe,OAAO,OAAO,GACtC,OAAO,OAAO,IAAI,+BAA+B,EAC/C,WAAW,aACb,CAAC;CAEL,CAAC;CAED,MAAM,gBAAgB,aAAa,KAAK,EAAE,mBAAmB,YAAY;CACzE,OAAOC,UACL,cAAc,KAAK,iBACjB,KAAK,QAAQ,kBAAkB,YAAY,CAC7C,GACA,OAAO,QAAQ,eAAe,sBAAsB,EAAE,aAAa,EAAE,CAAC,CACxE;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableModulePath.mjs","names":["RelativeModulePath.withSuffix"],"sources":["../src/TableModulePath.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\nimport * as RelativeModulePath from \"./RelativeModulePath\";\n\nexport const TableModulePath = RelativeModulePath.withSuffix(\".ts\")\n .check(Schema.makeFilter((value) => value.split(/[/\\\\]/)[0] === \"tables\"))\n .pipe(Schema.brand(\"@confect/cli/TableModulePath\"));\n\nexport type TableModulePath = typeof TableModulePath.Type;\n"],"mappings":";;;AAGA,MAAa,kBAAkBA,WAA8B,KAAK,CAAC,CAChE,MAAM,OAAO,YAAY,UAAU,MAAM,MAAM,OAAO,CAAC,CAAC,OAAO,QAAQ,CAAC,CAAC,CACzE,KAAK,OAAO,MAAM,8BAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"TableModulePath.mjs","names":["RelativeModulePath.withSuffix"],"sources":["../src/TableModulePath.ts"],"sourcesContent":["import * as Schema from \"effect/Schema\";\nimport * as RelativeModulePath from \"./RelativeModulePath.js\";\n\nexport const TableModulePath = RelativeModulePath.withSuffix(\".ts\")\n .check(Schema.makeFilter((value) => value.split(/[/\\\\]/)[0] === \"tables\"))\n .pipe(Schema.brand(\"@confect/cli/TableModulePath\"));\n\nexport type TableModulePath = typeof TableModulePath.Type;\n"],"mappings":";;;AAGA,MAAa,kBAAkBA,WAA8B,KAAK,CAAC,CAChE,MAAM,OAAO,YAAY,UAAU,MAAM,MAAM,OAAO,CAAC,CAAC,OAAO,QAAQ,CAAC,CAAC,CACzE,KAAK,OAAO,MAAM,8BAA8B,CAAC"}
|
package/dist/WatchBuild.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WatchBuild.mjs","names":["WatchGraph.affected","WatchGraph.make"],"sources":["../src/WatchBuild.ts"],"sourcesContent":["import * as Array from \"effect/Array\";\nimport * as Brand from \"effect/Brand\";\nimport type * as Crypto from \"effect/Crypto\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport type * as FileSystem from \"effect/FileSystem\";\nimport * as Equal from \"effect/Equal\";\nimport * as HashMap from \"effect/HashMap\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Match from \"effect/Match\";\nimport * as Hex from \"effect/encoding/Hex\";\nimport * as Option from \"effect/Option\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport * as Result from \"effect/Result\";\nimport type * as esbuild from \"esbuild\";\nimport * as WatchGraph from \"./WatchGraph\";\n\nexport type Failure = Data.TaggedEnum<{\n BuildFailed: {\n readonly errors: Array.NonEmptyReadonlyArray<esbuild.Message>;\n };\n InputCaptureFailed: { readonly file: string; readonly cause: PlatformError };\n OutputCaptureFailed: { readonly file: string; readonly cause: PlatformError };\n InvalidBuildResult: { readonly missing: \"metafile\" | \"outputFiles\" };\n}>;\nexport const Failure = Data.taggedEnum<Failure>();\nexport type Fingerprints = HashMap.HashMap<string, string>;\n\nexport interface Capture {\n readonly fingerprints: Fingerprints;\n readonly failures: HashMap.HashMap<string, Failure>;\n}\nexport const emptyCapture: Capture = {\n fingerprints: HashMap.empty(),\n failures: HashMap.empty(),\n};\n\nexport interface Snapshot {\n readonly fingerprints: Fingerprints;\n readonly graph: WatchGraph.WatchGraph;\n readonly outputHash: string;\n}\n\nexport type Outcome = Data.TaggedEnum<{\n Succeeded: {\n readonly snapshot: Snapshot;\n readonly warnings: ReadonlyArray<esbuild.Message>;\n };\n Failed: {\n readonly fingerprints: Fingerprints;\n readonly failures: Array.NonEmptyReadonlyArray<Failure>;\n readonly warnings: ReadonlyArray<esbuild.Message>;\n };\n}>;\nexport const Outcome = Data.taggedEnum<Outcome>();\n\nexport type Generation = number & Brand.Brand<\"WatchBuild.Generation\">;\nconst Generation = Brand.nominal<Generation>();\n\nexport type Barrier = number & Brand.Brand<\"WatchBuild.Barrier\">;\nconst Barrier = Brand.nominal<Barrier>();\n\nexport type RequestId = object & Brand.Brand<\"WatchBuild.RequestId\">;\nconst RequestId = Brand.nominal<RequestId>();\n\nexport const makeRequestId = (): RequestId => RequestId({});\n\nexport interface Completion {\n readonly generation: Generation;\n readonly outcome: Outcome;\n}\n\ntype Request = Data.TaggedEnum<{\n Idle: {};\n Pending: {};\n Joined: {};\n Completed: { readonly completion: Completion };\n}>;\nconst Request = Data.taggedEnum<Request>();\n\nexport interface Progress {\n readonly generation: Generation;\n readonly request: Request;\n readonly lastRequest: Option.Option<RequestId>;\n}\n\nexport const initialProgress: Progress = {\n generation: Generation(0),\n request: Request.Idle(),\n lastRequest: Option.none(),\n};\n\nexport const start = (progress: Progress): Progress => ({\n ...progress,\n generation: Generation(progress.generation + 1),\n});\n\nexport const captureBarrier = (progress: Progress): Barrier =>\n Barrier(progress.generation);\n\nexport const request = (progress: Progress, id: RequestId): Progress => ({\n ...progress,\n request:\n Option.isSome(progress.lastRequest) && progress.lastRequest.value === id\n ? Request.Joined()\n : Request.Pending(),\n lastRequest: Option.some(id),\n});\n\nexport const complete = (\n progress: Progress,\n completion: Completion,\n): Progress => ({\n ...progress,\n request: Request.$match(progress.request, {\n Idle: (idle) => idle,\n Pending: () => Request.Completed({ completion }),\n Joined: () => Request.Completed({ completion }),\n Completed: (completed) => completed,\n }),\n});\n\nexport const getCompletion = (progress: Progress): Option.Option<Completion> =>\n Request.$match(progress.request, {\n Idle: () => Option.none(),\n Pending: () => Option.none(),\n Joined: () => Option.none(),\n Completed: ({ completion }) => Option.some(completion),\n });\n\nexport const joinedWithoutCompletion = (progress: Progress): boolean =>\n Request.$is(\"Joined\")(progress.request);\n\nexport const endRequest = (progress: Progress): Progress => ({\n ...progress,\n request: Request.Idle(),\n});\n\nexport const isFresh = (barrier: Barrier, completion: Completion): boolean =>\n completion.generation > barrier;\n\nexport const verifyInputs = Effect.fn(\"WatchBuild.verifyInputs\")(function* (\n snapshot: Snapshot,\n fs: FileSystem.FileSystem,\n crypto: Crypto.Crypto,\n) {\n const matches = yield* Effect.forEach(\n snapshot.fingerprints,\n ([file, expected]) =>\n fs.readFile(file).pipe(\n Effect.flatMap((contents) => crypto.digest(\"SHA-256\", contents)),\n Effect.map((digest) => Hex.encode(digest) === expected),\n Effect.mapError((cause) => Failure.InputCaptureFailed({ file, cause })),\n ),\n { concurrency: 8 },\n );\n return Array.every(matches, (matchesInput) => matchesInput);\n});\n\nexport type State = Data.TaggedEnum<{\n Initial: {};\n Succeeded: {\n readonly snapshot: Snapshot;\n readonly warnings: ReadonlyArray<esbuild.Message>;\n };\n Failed: {\n readonly observation: Extract<Outcome, { readonly _tag: \"Failed\" }>;\n readonly lastSuccessful: Option.Option<Snapshot>;\n readonly discovered: HashSet.HashSet<string>;\n };\n}>;\nexport const State = Data.taggedEnum<State>();\n\nexport const lastSuccessful = (state: State): Option.Option<Snapshot> =>\n State.$match(state, {\n Initial: () => Option.none(),\n Succeeded: ({ snapshot }) => Option.some(snapshot),\n Failed: ({ lastSuccessful: snapshot }) => snapshot,\n });\n\nexport const observe = (previous: State, outcome: Outcome): State =>\n Outcome.$match(outcome, {\n Succeeded: ({ snapshot, warnings }) =>\n State.Succeeded({ snapshot, warnings }),\n Failed: (observation) =>\n State.Failed({\n observation,\n lastSuccessful: lastSuccessful(previous),\n discovered: State.$is(\"Initial\")(previous)\n ? HashSet.empty()\n : HashSet.union(\n State.$is(\"Failed\")(previous)\n ? previous.discovered\n : HashSet.empty(),\n HashSet.difference(\n HashSet.fromIterable(HashMap.keys(observation.fingerprints)),\n HashSet.fromIterable(HashMap.keys(fingerprints(previous))),\n ),\n ),\n }),\n });\n\nexport const fingerprints = (state: State): Fingerprints =>\n State.$match(state, {\n Initial: () => HashMap.empty(),\n Succeeded: ({ snapshot }) => snapshot.fingerprints,\n Failed: ({ observation }) => observation.fingerprints,\n });\n\nexport const outputHash = (state: State): Option.Option<string> =>\n State.$match(state, {\n Initial: () => Option.none(),\n Succeeded: ({ snapshot }) => Option.some(snapshot.outputHash),\n Failed: () => Option.none(),\n });\n\nexport type Change = Data.TaggedEnum<{\n Full: {};\n Affected: { readonly paths: HashSet.HashSet<string> };\n Recovered: { readonly paths: HashSet.HashSet<string> };\n}>;\nexport const Change = Data.taggedEnum<Change>();\n\nexport const diff = (\n previous: State,\n current: State,\n generatedDirectoryPrefix: string,\n): Change => {\n const previousFingerprints = fingerprints(previous);\n const currentFingerprints = fingerprints(current);\n const files = HashSet.union(\n HashSet.fromIterable(HashMap.keys(previousFingerprints)),\n HashSet.fromIterable(HashMap.keys(currentFingerprints)),\n );\n const changed = Array.fromIterable(files).filter(\n (file) =>\n !Equal.equals(\n HashMap.get(previousFingerprints, file),\n HashMap.get(currentFingerprints, file),\n ),\n );\n const sources = changed.filter(\n (file) => !file.startsWith(generatedDirectoryPrefix),\n );\n const recovered =\n State.$is(\"Failed\")(previous) && State.$is(\"Succeeded\")(current);\n const untrackedOutput = recovered\n ? Option.match(lastSuccessful(previous), {\n onNone: () => false,\n onSome: (baseline) =>\n Equal.equals(baseline.fingerprints, currentFingerprints) &&\n !Equal.equals(Option.some(baseline.outputHash), outputHash(current)),\n })\n : changed.length === 0 &&\n !Equal.equals(outputHash(previous), outputHash(current));\n if (\n State.$is(\"Initial\")(previous) ||\n (sources.some((file) => HashMap.has(previousFingerprints, file)) &&\n State.$is(\"Failed\")(current)) ||\n untrackedOutput\n )\n return Change.Full();\n\n const graph = Option.match(lastSuccessful(current), {\n onNone: () => HashMap.empty<string, HashSet.HashSet<string>>(),\n onSome: (snapshot) => snapshot.graph,\n });\n const previousGraph = Option.match(lastSuccessful(previous), {\n onNone: () => HashMap.empty<string, HashSet.HashSet<string>>(),\n onSome: (snapshot) => snapshot.graph,\n });\n const affectedSources =\n recovered && State.$is(\"Failed\")(previous)\n ? Array.fromIterable(\n HashSet.union(\n HashSet.fromIterable(sources),\n HashSet.filter(\n previous.discovered,\n (file) => !file.startsWith(generatedDirectoryPrefix),\n ),\n ),\n )\n : sources;\n const paths = HashSet.union(\n WatchGraph.affected(graph, affectedSources),\n WatchGraph.affected(previousGraph, affectedSources),\n );\n return recovered ? Change.Recovered({ paths }) : Change.Affected({ paths });\n};\n\nexport const parse = Effect.fn(\"WatchBuild.parse\")(function* (\n result: esbuild.BuildResult,\n capture: Capture,\n resolve: (file: string) => string,\n crypto: Crypto.Crypto,\n) {\n const failures = Array.fromIterable(HashMap.values(capture.failures));\n if (Array.isReadonlyArrayNonEmpty(result.errors))\n failures.push(Failure.BuildFailed({ errors: result.errors }));\n if (Array.isReadonlyArrayNonEmpty(failures))\n return Outcome.Failed({\n fingerprints: capture.fingerprints,\n failures,\n warnings: result.warnings,\n });\n if (!result.metafile)\n return Outcome.Failed({\n fingerprints: capture.fingerprints,\n failures: [Failure.InvalidBuildResult({ missing: \"metafile\" })],\n warnings: result.warnings,\n });\n if (!result.outputFiles || !Array.isReadonlyArrayNonEmpty(result.outputFiles))\n return Outcome.Failed({\n fingerprints: capture.fingerprints,\n failures: [Failure.InvalidBuildResult({ missing: \"outputFiles\" })],\n warnings: result.warnings,\n });\n const hashes = yield* Effect.forEach(result.outputFiles, (file) =>\n crypto.digest(\"SHA-256\", file.contents).pipe(\n Effect.map(Hex.encode),\n Effect.mapError((cause) =>\n Failure.OutputCaptureFailed({ file: file.path, cause }),\n ),\n ),\n ).pipe(Effect.result);\n if (Result.isFailure(hashes))\n return Outcome.Failed({\n fingerprints: capture.fingerprints,\n failures: [hashes.failure],\n warnings: result.warnings,\n });\n return Outcome.Succeeded({\n snapshot: {\n fingerprints: capture.fingerprints,\n graph: WatchGraph.make(result.metafile, resolve),\n outputHash: hashes.success.join(\":\"),\n },\n warnings: result.warnings,\n });\n});\n\nexport const failureMessage = (failure: Failure): string =>\n Failure.$match(failure, {\n BuildFailed: ({ errors }) => errors.map((error) => error.text).join(\"\\n\"),\n InputCaptureFailed: ({ file, cause }) =>\n `Could not fingerprint input ${file}: ${cause.message}`,\n OutputCaptureFailed: ({ file, cause }) =>\n `Could not fingerprint output ${file}: ${cause.message}`,\n InvalidBuildResult: ({ missing }) => `esbuild completed without ${missing}`,\n });\n\nexport const messages = (outcome: Outcome): ReadonlyArray<esbuild.Message> =>\n Outcome.$match(outcome, {\n Succeeded: () => [],\n Failed: ({ failures }) =>\n failures.flatMap((failure) =>\n Match.value(failure).pipe(\n Match.tag(\"BuildFailed\", ({ errors }) => errors),\n Match.tag(\n \"InputCaptureFailed\",\n \"OutputCaptureFailed\",\n \"InvalidBuildResult\",\n (captureFailure) => [\n {\n id: \"confect-watch\",\n pluginName: \"confect\",\n text: failureMessage(captureFailure),\n location: null,\n notes: [],\n detail: captureFailure,\n },\n ],\n ),\n Match.exhaustive,\n ),\n ),\n });\n\nexport const diagnostics = (\n state: State,\n): {\n readonly errors: ReadonlyArray<esbuild.Message>;\n readonly warnings: ReadonlyArray<esbuild.Message>;\n} =>\n State.$match(state, {\n Initial: () => ({ errors: [], warnings: [] }),\n Succeeded: ({ warnings }) => ({ errors: [], warnings }),\n Failed: ({ observation }) => ({\n errors: messages(observation),\n warnings: observation.warnings,\n }),\n });\n"],"mappings":";;;;;;;;;;;;;AAyBA,MAAa,UAAU,KAAK,WAAoB;AAOhD,MAAa,eAAwB;CACnC,cAAc,QAAQ,MAAM;CAC5B,UAAU,QAAQ,MAAM;AAC1B;AAmBA,MAAa,UAAU,KAAK,WAAoB;AAGhD,MAAM,aAAa,MAAM,QAAoB;AAG7C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OAAO;CAClB,gBAAgB;EAAE,QAAQ,CAAC;EAAG,UAAU,CAAC;CAAE;CAC3C,YAAY,EAAE,gBAAgB;EAAE,QAAQ,CAAC;EAAG;CAAS;CACrD,SAAS,EAAE,mBAAmB;EAC5B,QAAQ,SAAS,WAAW;EAC5B,UAAU,YAAY;CACxB;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"WatchBuild.mjs","names":["WatchGraph.affected","WatchGraph.make"],"sources":["../src/WatchBuild.ts"],"sourcesContent":["import * as Array from \"effect/Array\";\nimport * as Brand from \"effect/Brand\";\nimport type * as Crypto from \"effect/Crypto\";\nimport * as Data from \"effect/Data\";\nimport * as Effect from \"effect/Effect\";\nimport type * as FileSystem from \"effect/FileSystem\";\nimport * as Equal from \"effect/Equal\";\nimport * as HashMap from \"effect/HashMap\";\nimport * as HashSet from \"effect/HashSet\";\nimport * as Match from \"effect/Match\";\nimport * as Hex from \"effect/encoding/Hex\";\nimport * as Option from \"effect/Option\";\nimport type { PlatformError } from \"effect/PlatformError\";\nimport * as Result from \"effect/Result\";\nimport type * as esbuild from \"esbuild\";\nimport * as WatchGraph from \"./WatchGraph.js\";\n\nexport type Failure = Data.TaggedEnum<{\n BuildFailed: {\n readonly errors: Array.NonEmptyReadonlyArray<esbuild.Message>;\n };\n InputCaptureFailed: { readonly file: string; readonly cause: PlatformError };\n OutputCaptureFailed: { readonly file: string; readonly cause: PlatformError };\n InvalidBuildResult: { readonly missing: \"metafile\" | \"outputFiles\" };\n}>;\nexport const Failure = Data.taggedEnum<Failure>();\nexport type Fingerprints = HashMap.HashMap<string, string>;\n\nexport interface Capture {\n readonly fingerprints: Fingerprints;\n readonly failures: HashMap.HashMap<string, Failure>;\n}\nexport const emptyCapture: Capture = {\n fingerprints: HashMap.empty(),\n failures: HashMap.empty(),\n};\n\nexport interface Snapshot {\n readonly fingerprints: Fingerprints;\n readonly graph: WatchGraph.WatchGraph;\n readonly outputHash: string;\n}\n\nexport type Outcome = Data.TaggedEnum<{\n Succeeded: {\n readonly snapshot: Snapshot;\n readonly warnings: ReadonlyArray<esbuild.Message>;\n };\n Failed: {\n readonly fingerprints: Fingerprints;\n readonly failures: Array.NonEmptyReadonlyArray<Failure>;\n readonly warnings: ReadonlyArray<esbuild.Message>;\n };\n}>;\nexport const Outcome = Data.taggedEnum<Outcome>();\n\nexport type Generation = number & Brand.Brand<\"WatchBuild.Generation\">;\nconst Generation = Brand.nominal<Generation>();\n\nexport type Barrier = number & Brand.Brand<\"WatchBuild.Barrier\">;\nconst Barrier = Brand.nominal<Barrier>();\n\nexport type RequestId = object & Brand.Brand<\"WatchBuild.RequestId\">;\nconst RequestId = Brand.nominal<RequestId>();\n\nexport const makeRequestId = (): RequestId => RequestId({});\n\nexport interface Completion {\n readonly generation: Generation;\n readonly outcome: Outcome;\n}\n\ntype Request = Data.TaggedEnum<{\n Idle: {};\n Pending: {};\n Joined: {};\n Completed: { readonly completion: Completion };\n}>;\nconst Request = Data.taggedEnum<Request>();\n\nexport interface Progress {\n readonly generation: Generation;\n readonly request: Request;\n readonly lastRequest: Option.Option<RequestId>;\n}\n\nexport const initialProgress: Progress = {\n generation: Generation(0),\n request: Request.Idle(),\n lastRequest: Option.none(),\n};\n\nexport const start = (progress: Progress): Progress => ({\n ...progress,\n generation: Generation(progress.generation + 1),\n});\n\nexport const captureBarrier = (progress: Progress): Barrier =>\n Barrier(progress.generation);\n\nexport const request = (progress: Progress, id: RequestId): Progress => ({\n ...progress,\n request:\n Option.isSome(progress.lastRequest) && progress.lastRequest.value === id\n ? Request.Joined()\n : Request.Pending(),\n lastRequest: Option.some(id),\n});\n\nexport const complete = (\n progress: Progress,\n completion: Completion,\n): Progress => ({\n ...progress,\n request: Request.$match(progress.request, {\n Idle: (idle) => idle,\n Pending: () => Request.Completed({ completion }),\n Joined: () => Request.Completed({ completion }),\n Completed: (completed) => completed,\n }),\n});\n\nexport const getCompletion = (progress: Progress): Option.Option<Completion> =>\n Request.$match(progress.request, {\n Idle: () => Option.none(),\n Pending: () => Option.none(),\n Joined: () => Option.none(),\n Completed: ({ completion }) => Option.some(completion),\n });\n\nexport const joinedWithoutCompletion = (progress: Progress): boolean =>\n Request.$is(\"Joined\")(progress.request);\n\nexport const endRequest = (progress: Progress): Progress => ({\n ...progress,\n request: Request.Idle(),\n});\n\nexport const isFresh = (barrier: Barrier, completion: Completion): boolean =>\n completion.generation > barrier;\n\nexport const verifyInputs = Effect.fn(\"WatchBuild.verifyInputs\")(function* (\n snapshot: Snapshot,\n fs: FileSystem.FileSystem,\n crypto: Crypto.Crypto,\n) {\n const matches = yield* Effect.forEach(\n snapshot.fingerprints,\n ([file, expected]) =>\n fs.readFile(file).pipe(\n Effect.flatMap((contents) => crypto.digest(\"SHA-256\", contents)),\n Effect.map((digest) => Hex.encode(digest) === expected),\n Effect.mapError((cause) => Failure.InputCaptureFailed({ file, cause })),\n ),\n { concurrency: 8 },\n );\n return Array.every(matches, (matchesInput) => matchesInput);\n});\n\nexport type State = Data.TaggedEnum<{\n Initial: {};\n Succeeded: {\n readonly snapshot: Snapshot;\n readonly warnings: ReadonlyArray<esbuild.Message>;\n };\n Failed: {\n readonly observation: Extract<Outcome, { readonly _tag: \"Failed\" }>;\n readonly lastSuccessful: Option.Option<Snapshot>;\n readonly discovered: HashSet.HashSet<string>;\n };\n}>;\nexport const State = Data.taggedEnum<State>();\n\nexport const lastSuccessful = (state: State): Option.Option<Snapshot> =>\n State.$match(state, {\n Initial: () => Option.none(),\n Succeeded: ({ snapshot }) => Option.some(snapshot),\n Failed: ({ lastSuccessful: snapshot }) => snapshot,\n });\n\nexport const observe = (previous: State, outcome: Outcome): State =>\n Outcome.$match(outcome, {\n Succeeded: ({ snapshot, warnings }) =>\n State.Succeeded({ snapshot, warnings }),\n Failed: (observation) =>\n State.Failed({\n observation,\n lastSuccessful: lastSuccessful(previous),\n discovered: State.$is(\"Initial\")(previous)\n ? HashSet.empty()\n : HashSet.union(\n State.$is(\"Failed\")(previous)\n ? previous.discovered\n : HashSet.empty(),\n HashSet.difference(\n HashSet.fromIterable(HashMap.keys(observation.fingerprints)),\n HashSet.fromIterable(HashMap.keys(fingerprints(previous))),\n ),\n ),\n }),\n });\n\nexport const fingerprints = (state: State): Fingerprints =>\n State.$match(state, {\n Initial: () => HashMap.empty(),\n Succeeded: ({ snapshot }) => snapshot.fingerprints,\n Failed: ({ observation }) => observation.fingerprints,\n });\n\nexport const outputHash = (state: State): Option.Option<string> =>\n State.$match(state, {\n Initial: () => Option.none(),\n Succeeded: ({ snapshot }) => Option.some(snapshot.outputHash),\n Failed: () => Option.none(),\n });\n\nexport type Change = Data.TaggedEnum<{\n Full: {};\n Affected: { readonly paths: HashSet.HashSet<string> };\n Recovered: { readonly paths: HashSet.HashSet<string> };\n}>;\nexport const Change = Data.taggedEnum<Change>();\n\nexport const diff = (\n previous: State,\n current: State,\n generatedDirectoryPrefix: string,\n): Change => {\n const previousFingerprints = fingerprints(previous);\n const currentFingerprints = fingerprints(current);\n const files = HashSet.union(\n HashSet.fromIterable(HashMap.keys(previousFingerprints)),\n HashSet.fromIterable(HashMap.keys(currentFingerprints)),\n );\n const changed = Array.fromIterable(files).filter(\n (file) =>\n !Equal.equals(\n HashMap.get(previousFingerprints, file),\n HashMap.get(currentFingerprints, file),\n ),\n );\n const sources = changed.filter(\n (file) => !file.startsWith(generatedDirectoryPrefix),\n );\n const recovered =\n State.$is(\"Failed\")(previous) && State.$is(\"Succeeded\")(current);\n const untrackedOutput = recovered\n ? Option.match(lastSuccessful(previous), {\n onNone: () => false,\n onSome: (baseline) =>\n Equal.equals(baseline.fingerprints, currentFingerprints) &&\n !Equal.equals(Option.some(baseline.outputHash), outputHash(current)),\n })\n : changed.length === 0 &&\n !Equal.equals(outputHash(previous), outputHash(current));\n if (\n State.$is(\"Initial\")(previous) ||\n (sources.some((file) => HashMap.has(previousFingerprints, file)) &&\n State.$is(\"Failed\")(current)) ||\n untrackedOutput\n )\n return Change.Full();\n\n const graph = Option.match(lastSuccessful(current), {\n onNone: () => HashMap.empty<string, HashSet.HashSet<string>>(),\n onSome: (snapshot) => snapshot.graph,\n });\n const previousGraph = Option.match(lastSuccessful(previous), {\n onNone: () => HashMap.empty<string, HashSet.HashSet<string>>(),\n onSome: (snapshot) => snapshot.graph,\n });\n const affectedSources =\n recovered && State.$is(\"Failed\")(previous)\n ? Array.fromIterable(\n HashSet.union(\n HashSet.fromIterable(sources),\n HashSet.filter(\n previous.discovered,\n (file) => !file.startsWith(generatedDirectoryPrefix),\n ),\n ),\n )\n : sources;\n const paths = HashSet.union(\n WatchGraph.affected(graph, affectedSources),\n WatchGraph.affected(previousGraph, affectedSources),\n );\n return recovered ? Change.Recovered({ paths }) : Change.Affected({ paths });\n};\n\nexport const parse = Effect.fn(\"WatchBuild.parse\")(function* (\n result: esbuild.BuildResult,\n capture: Capture,\n resolve: (file: string) => string,\n crypto: Crypto.Crypto,\n) {\n const failures = Array.fromIterable(HashMap.values(capture.failures));\n if (Array.isReadonlyArrayNonEmpty(result.errors))\n failures.push(Failure.BuildFailed({ errors: result.errors }));\n if (Array.isReadonlyArrayNonEmpty(failures))\n return Outcome.Failed({\n fingerprints: capture.fingerprints,\n failures,\n warnings: result.warnings,\n });\n if (!result.metafile)\n return Outcome.Failed({\n fingerprints: capture.fingerprints,\n failures: [Failure.InvalidBuildResult({ missing: \"metafile\" })],\n warnings: result.warnings,\n });\n if (!result.outputFiles || !Array.isReadonlyArrayNonEmpty(result.outputFiles))\n return Outcome.Failed({\n fingerprints: capture.fingerprints,\n failures: [Failure.InvalidBuildResult({ missing: \"outputFiles\" })],\n warnings: result.warnings,\n });\n const hashes = yield* Effect.forEach(result.outputFiles, (file) =>\n crypto.digest(\"SHA-256\", file.contents).pipe(\n Effect.map(Hex.encode),\n Effect.mapError((cause) =>\n Failure.OutputCaptureFailed({ file: file.path, cause }),\n ),\n ),\n ).pipe(Effect.result);\n if (Result.isFailure(hashes))\n return Outcome.Failed({\n fingerprints: capture.fingerprints,\n failures: [hashes.failure],\n warnings: result.warnings,\n });\n return Outcome.Succeeded({\n snapshot: {\n fingerprints: capture.fingerprints,\n graph: WatchGraph.make(result.metafile, resolve),\n outputHash: hashes.success.join(\":\"),\n },\n warnings: result.warnings,\n });\n});\n\nexport const failureMessage = (failure: Failure): string =>\n Failure.$match(failure, {\n BuildFailed: ({ errors }) => errors.map((error) => error.text).join(\"\\n\"),\n InputCaptureFailed: ({ file, cause }) =>\n `Could not fingerprint input ${file}: ${cause.message}`,\n OutputCaptureFailed: ({ file, cause }) =>\n `Could not fingerprint output ${file}: ${cause.message}`,\n InvalidBuildResult: ({ missing }) => `esbuild completed without ${missing}`,\n });\n\nexport const messages = (outcome: Outcome): ReadonlyArray<esbuild.Message> =>\n Outcome.$match(outcome, {\n Succeeded: () => [],\n Failed: ({ failures }) =>\n failures.flatMap((failure) =>\n Match.value(failure).pipe(\n Match.tag(\"BuildFailed\", ({ errors }) => errors),\n Match.tag(\n \"InputCaptureFailed\",\n \"OutputCaptureFailed\",\n \"InvalidBuildResult\",\n (captureFailure) => [\n {\n id: \"confect-watch\",\n pluginName: \"confect\",\n text: failureMessage(captureFailure),\n location: null,\n notes: [],\n detail: captureFailure,\n },\n ],\n ),\n Match.exhaustive,\n ),\n ),\n });\n\nexport const diagnostics = (\n state: State,\n): {\n readonly errors: ReadonlyArray<esbuild.Message>;\n readonly warnings: ReadonlyArray<esbuild.Message>;\n} =>\n State.$match(state, {\n Initial: () => ({ errors: [], warnings: [] }),\n Succeeded: ({ warnings }) => ({ errors: [], warnings }),\n Failed: ({ observation }) => ({\n errors: messages(observation),\n warnings: observation.warnings,\n }),\n });\n"],"mappings":";;;;;;;;;;;;;AAyBA,MAAa,UAAU,KAAK,WAAoB;AAOhD,MAAa,eAAwB;CACnC,cAAc,QAAQ,MAAM;CAC5B,UAAU,QAAQ,MAAM;AAC1B;AAmBA,MAAa,UAAU,KAAK,WAAoB;AAGhD,MAAM,aAAa,MAAM,QAAoB;AAG7C,MAAM,UAAU,MAAM,QAAiB;A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AAQ,CAAC;EAAG,UAAU,CAAC;CAAE;CAC3C,YAAY,EAAE,gBAAgB;EAAE,QAAQ,CAAC;EAAG;CAAS;CACrD,SAAS,EAAE,mBAAmB;EAC5B,QAAQ,SAAS,WAAW;EAC5B,UAAU,YAAY;CACxB;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"WatchTopology.mjs","names":["SyncState.full","SyncState.add","SyncState.empty"],"sources":["../src/WatchTopology.ts"],"sourcesContent":["import * as Data from \"effect/Data\";\nimport * as Deferred from \"effect/Deferred\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Ref from \"effect/Ref\";\nimport * as Semaphore from \"effect/Semaphore\";\nimport type { Kind } from \"./EntryPoint\";\nimport * as SyncState from \"./SyncState\";\n\ntype State = Data.TaggedEnum<{\n Reconciling: { readonly revision: number };\n Observing: {\n readonly revision: number;\n readonly initial: Deferred.Deferred<void>;\n };\n}>;\nconst State = Data.taggedEnum<State>();\n\ntype Decision = Data.TaggedEnum<{\n Take: { readonly pending: SyncState.Pending };\n Wait: { readonly ready: Effect.Effect<void> };\n}>;\nconst Decision = Data.taggedEnum<Decision>();\n\nexport const make = Effect.fn(\"WatchTopology.make\")(function* (\n pending: Ref.Ref<SyncState.Pending>,\n) {\n const state = yield* Ref.make<State>(State.Reconciling({ revision: 0 }));\n const changed = yield* Ref.make(yield* Deferred.make<void>());\n const lock = yield* Semaphore.make(1);\n const notify = Effect.gen(function* () {\n const previous = yield* Ref.getAndSet(\n changed,\n yield* Deferred.make<void>(),\n );\n yield* Deferred.succeed(previous, undefined);\n });\n\n const invalidate = Effect.fn(\"WatchTopology.invalidate\")(\n function* (update: (pending: SyncState.Pending) => SyncState.Pending) {\n yield* Ref.update(state, ({ revision }) =>\n State.Reconciling({ revision: revision + 1 }),\n );\n yield* Ref.update(pending, update);\n yield* notify;\n },\n (effect) => lock.withPermit(effect),\n );\n\n return {\n revision: Ref.get(state).pipe(Effect.map((current) => current.revision)),\n invalidate: invalidate(SyncState.full),\n invalidateEntry: (entry: Kind) =>\n invalidate((current) => SyncState.add(current, [entry])),\n reconcile: Effect.fn(\"WatchTopology.reconcile\")(\n function* (revision: number, initial: Deferred.Deferred<void>) {\n const current = yield* Ref.get(state);\n if (current.revision !== revision) return;\n yield* Ref.set(state, State.Observing({ revision, initial }));\n yield* notify;\n },\n (effect) => lock.withPermit(effect),\n ),\n takePending: lock\n .withPermit(\n Effect.gen(function* () {\n const current = yield* Ref.get(state);\n const notification = yield* Ref.get(changed);\n return yield* State.$match(current, {\n Reconciling: () =>\n Effect.succeed(\n Decision.Wait({ ready: Deferred.await(notification) }),\n ),\n Observing: ({ initial }) =>\n Effect.gen(function* () {\n if (yield* Deferred.isDone(initial))\n return Decision.Take({\n pending: yield* Ref.getAndSet(pending, SyncState.empty),\n });\n return Decision.Wait({\n ready: Effect.raceFirst(\n Deferred.await(notification),\n Deferred.await(initial),\n ),\n });\n }),\n });\n }),\n )\n .pipe(\n Effect.flatMap(\n Decision.$match({\n Take: ({ pending: taken }) => Effect.succeedSome(taken),\n Wait: ({ ready }) =>\n ready.pipe(Effect.as(Option.none<SyncState.Pending>())),\n }),\n ),\n Effect.repeat({ until: Option.isSome<SyncState.Pending> }),\n Effect.map((result) => result.value),\n ),\n };\n});\n\nexport type WatchTopology = Effect.Success<ReturnType<typeof make>>;\n"],"mappings":";;;;;;;;AAgBA,MAAM,QAAQ,KAAK,WAAkB;AAMrC,MAAM,WAAW,KAAK,WAAqB;AAE3C,MAAa,OAAO,OAAO,GAAG,oBAAoB,CAAC,CAAC,WAClD,SACA;CACA,MAAM,QAAQ,OAAO,IAAI,KAAY,MAAM,YAAY,EAAE,UAAU,EAAE,CAAC,CAAC;CACvE,MAAM,UAAU,OAAO,IAAI,KAAK,OAAO,SAAS,KAAW,CAAC;CAC5D,MAAM,OAAO,OAAO,UAAU,KAAK,CAAC;CACpC,MAAM,SAAS,OAAO,IAAI,aAAa;EACrC,MA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AAO,OAAO,UACZ,SAAS,MAAM,YAAY,GAC3B,SAAS,MAAM,OAAO,CACxB,EACF,CAAC;IACH,CAAC;GACL,CAAC;EACH,CAAC,CACH,CAAC,CACA,KACC,OAAO,QACL,SAAS,OAAO;GACd,OAAO,EAAE,SAAS,YAAY,OAAO,YAAY,KAAK;GACtD,OAAO,EAAE,YACP,MAAM,KAAK,OAAO,GAAG,OAAO,KAAwB,CAAC,CAAC;EAC1D,CAAC,CACH,GACA,OAAO,OAAO,EAAE,OAAO,OAAO,OAA0B,CAAC,GACzD,OAAO,KAAK,WAAW,OAAO,KAAK,CACrC;CACJ;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"WatchTopology.mjs","names":["SyncState.full","SyncState.add","SyncState.empty"],"sources":["../src/WatchTopology.ts"],"sourcesContent":["import * as Data from \"effect/Data\";\nimport * as Deferred from \"effect/Deferred\";\nimport * as Effect from \"effect/Effect\";\nimport * as Option from \"effect/Option\";\nimport * as Ref from \"effect/Ref\";\nimport * as Semaphore from \"effect/Semaphore\";\nimport type { Kind } from \"./EntryPoint.js\";\nimport * as SyncState from \"./SyncState.js\";\n\ntype State = Data.TaggedEnum<{\n Reconciling: { readonly revision: number };\n Observing: {\n readonly revision: number;\n readonly initial: Deferred.Deferred<void>;\n };\n}>;\nconst State = Data.taggedEnum<State>();\n\ntype Decision = Data.TaggedEnum<{\n Take: { readonly pending: SyncState.Pending };\n Wait: { readonly ready: Effect.Effect<void> };\n}>;\nconst Decision = Data.taggedEnum<Decision>();\n\nexport const make = Effect.fn(\"WatchTopology.make\")(function* (\n pending: Ref.Ref<SyncState.Pending>,\n) {\n const state = yield* Ref.make<State>(State.Reconciling({ revision: 0 }));\n const changed = yield* Ref.make(yield* Deferred.make<void>());\n const lock = yield* Semaphore.make(1);\n const notify = Effect.gen(function* () {\n const previous = yield* Ref.getAndSet(\n changed,\n yield* Deferred.make<void>(),\n );\n yield* Deferred.succeed(previous, undefined);\n });\n\n const invalidate = Effect.fn(\"WatchTopology.invalidate\")(\n function* (update: (pending: SyncState.Pending) => SyncState.Pending) {\n yield* Ref.update(state, ({ revision }) =>\n State.Reconciling({ revision: revision + 1 }),\n );\n yield* Ref.update(pending, update);\n yield* notify;\n },\n (effect) => lock.withPermit(effect),\n );\n\n return {\n revision: Ref.get(state).pipe(Effect.map((current) => current.revision)),\n invalidate: invalidate(SyncState.full),\n invalidateEntry: (entry: Kind) =>\n invalidate((current) => SyncState.add(current, [entry])),\n reconcile: Effect.fn(\"WatchTopology.reconcile\")(\n function* (revision: number, initial: Deferred.Deferred<void>) {\n const current = yield* Ref.get(state);\n if (current.revision !== revision) return;\n yield* Ref.set(state, State.Observing({ revision, initial }));\n yield* notify;\n },\n (effect) => lock.withPermit(effect),\n ),\n takePending: lock\n .withPermit(\n Effect.gen(function* () {\n const current = yield* Ref.get(state);\n const notification = yield* Ref.get(changed);\n return yield* State.$match(current, {\n Reconciling: () =>\n Effect.succeed(\n Decision.Wait({ ready: Deferred.await(notification) }),\n ),\n Observing: ({ initial }) =>\n Effect.gen(function* () {\n if (yield* Deferred.isDone(initial))\n return Decision.Take({\n pending: yield* Ref.getAndSet(pending, SyncState.empty),\n });\n return Decision.Wait({\n ready: Effect.raceFirst(\n Deferred.await(notification),\n Deferred.await(initial),\n ),\n });\n }),\n });\n }),\n )\n .pipe(\n Effect.flatMap(\n Decision.$match({\n Take: ({ pending: taken }) => Effect.succeedSome(taken),\n Wait: ({ ready }) =>\n ready.pipe(Effect.as(Option.none<SyncState.Pending>())),\n }),\n ),\n Effect.repeat({ until: Option.isSome<SyncState.Pending> }),\n Effect.map((result) => result.value),\n ),\n };\n});\n\nexport type WatchTopology = Effect.Success<ReturnType<typeof make>>;\n"],"mappings":";;;;;;;;AAgBA,MAAM,QAAQ,KAAK,WAAkB;AAMrC,MAAM,WAAW,KAAK,WAAqB;AAE3C,MAAa,OAAO,OAAO,GAAG,oBAAoB,CAAC,CAAC,WAClD,SACA;CACA,MAAM,QAAQ,OAAO,IAAI,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