better-cf 0.2.1 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -121,7 +121,7 @@ expect(result.acked).toHaveLength(1);
121
121
  | Local dev orchestration | Team-managed scripts | One `better-cf dev` loop |
122
122
  | Queue test harness | Custom mocks/harnesses | `testQueue` helper |
123
123
 
124
- Detailed comparison: `/apps/docs/src/content/docs/comparison/cloudflare-vs-better-cf.mdx`
124
+ Detailed comparison is being migrated to the separate docs repository.
125
125
 
126
126
  ## Limitations
127
127
 
@@ -142,7 +142,5 @@ Use native Cloudflare APIs directly where the SDK intentionally does not abstrac
142
142
 
143
143
  ## Docs
144
144
 
145
- - Site source: `apps/docs`
146
- - Getting started page: `apps/docs/src/content/docs/getting-started.md`
147
- - File structure guide: `apps/docs/src/content/docs/guides/file-structure.md`
148
- - Cookbook page: `apps/docs/src/content/docs/examples/cookbook.md`
145
+ Docs are being migrated to a separate Next.js application repository.
146
+ During migration, legacy docs source may still exist under `apps/docs`, but it is no longer part of package CI/CD.
package/dist/cli/index.js CHANGED
@@ -610,11 +610,15 @@ var RESERVED_KEYS = /* @__PURE__ */ new Set([
610
610
  "visibilityTimeout",
611
611
  "batch",
612
612
  "consumer",
613
+ "args",
614
+ "handler",
615
+ "batchHandler",
613
616
  "message",
614
617
  "process",
615
618
  "processBatch",
616
619
  "onFailure"
617
620
  ]);
621
+ var DEFINE_QUEUE_HELPERS = /* @__PURE__ */ new Set(["defineQueue", "defineQueues"]);
618
622
  async function scanQueues(config) {
619
623
  const diagnostics = [];
620
624
  const candidates = collectSourceFiles(config.rootDir, config.ignore);
@@ -688,7 +692,7 @@ async function scanQueues(config) {
688
692
  diagnostics.push({
689
693
  level: "warning",
690
694
  code: "NO_QUEUES_FOUND",
691
- message: "No defineQueue exports found in this project."
695
+ message: "No defineQueue/defineQueues exports found in this project."
692
696
  });
693
697
  }
694
698
  return {
@@ -732,7 +736,7 @@ function collectSourceFiles(rootDir, ignore) {
732
736
  }
733
737
  if (entry.name.endsWith(".ts") || entry.name.endsWith(".tsx")) {
734
738
  const content = fs8.readFileSync(absolutePath, "utf8");
735
- if (content.includes("defineQueue")) {
739
+ if (content.includes("defineQueue") || content.includes("defineQueues")) {
736
740
  files.push(absolutePath);
737
741
  }
738
742
  }
@@ -749,7 +753,7 @@ function getDefineQueueLocalNames(sourceFile) {
749
753
  continue;
750
754
  }
751
755
  for (const namedImport of importDecl.getNamedImports()) {
752
- if (namedImport.getName() !== "defineQueue") {
756
+ if (!DEFINE_QUEUE_HELPERS.has(namedImport.getName())) {
753
757
  continue;
754
758
  }
755
759
  names.add(namedImport.getAliasNode()?.getText() ?? namedImport.getName());
@@ -782,19 +786,19 @@ function extractQueueConfig(call, absolutePath, diagnostics, rootDir) {
782
786
  const firstArg = call.getArguments()[0];
783
787
  if (!firstArg || firstArg.getKind() !== SyntaxKind.ObjectLiteralExpression) {
784
788
  return {
785
- hasProcess: false,
786
- hasProcessBatch: false,
789
+ hasHandler: false,
790
+ hasBatchHandler: false,
787
791
  isMultiJob: false
788
792
  };
789
793
  }
790
794
  const objectLiteral = firstArg;
791
- const hasProcess = hasProperty(objectLiteral, "process");
792
- const hasProcessBatch = hasProperty(objectLiteral, "processBatch");
793
- if (hasProcess && hasProcessBatch) {
795
+ const hasHandler = hasProperty(objectLiteral, "handler");
796
+ const hasBatchHandler = hasProperty(objectLiteral, "batchHandler");
797
+ if (hasHandler && hasBatchHandler) {
794
798
  diagnostics.push({
795
799
  level: "error",
796
- code: "INVALID_PROCESS_MODE",
797
- message: "Queue config cannot include both process and processBatch.",
800
+ code: "INVALID_HANDLER_MODE",
801
+ message: "Queue config cannot include both handler and batchHandler.",
798
802
  filePath: path3.relative(rootDir, absolutePath),
799
803
  hint: "Pick exactly one processing mode for worker consumers."
800
804
  });
@@ -830,7 +834,7 @@ function extractQueueConfig(call, absolutePath, diagnostics, rootDir) {
830
834
  const batchTimeout = batchObject ? readNumberOrStringProperty(batchObject, "timeout", diagnostics, absolutePath, rootDir) : void 0;
831
835
  const maxConcurrency = batchObject ? readNumberProperty(batchObject, "maxConcurrency", diagnostics, absolutePath, rootDir) : void 0;
832
836
  let isMultiJob = false;
833
- if (!hasProcess && !hasProcessBatch) {
837
+ if (!hasHandler && !hasBatchHandler) {
834
838
  for (const property of objectLiteral.getProperties()) {
835
839
  if (!Node.isPropertyAssignment(property)) {
836
840
  continue;
@@ -844,20 +848,20 @@ function extractQueueConfig(call, absolutePath, diagnostics, rootDir) {
844
848
  continue;
845
849
  }
846
850
  const jobObject = initializer;
847
- if (hasProperty(jobObject, "message") && hasProperty(jobObject, "process")) {
851
+ if (hasProperty(jobObject, "args") && hasProperty(jobObject, "handler")) {
848
852
  isMultiJob = true;
849
853
  break;
850
854
  }
851
855
  }
852
856
  }
853
857
  const relativeFile = path3.relative(rootDir, absolutePath);
854
- if (consumerType === "http_pull" && (hasProcess || hasProcessBatch)) {
858
+ if (consumerType === "http_pull" && (hasHandler || hasBatchHandler)) {
855
859
  diagnostics.push({
856
860
  level: "error",
857
861
  code: "INVALID_PULL_MODE_HANDLER",
858
- message: 'Queue with consumer.type="http_pull" cannot include process/processBatch.',
862
+ message: 'Queue with consumer.type="http_pull" cannot include handler/batchHandler.',
859
863
  filePath: relativeFile,
860
- hint: "Remove process handlers for pull consumers and consume via HTTP pull APIs."
864
+ hint: "Remove handlers for pull consumers and consume via HTTP pull APIs."
861
865
  });
862
866
  }
863
867
  if (consumerType === "http_pull" && isMultiJob) {
@@ -879,8 +883,8 @@ function extractQueueConfig(call, absolutePath, diagnostics, rootDir) {
879
883
  maxConcurrency,
880
884
  visibilityTimeout,
881
885
  consumerType,
882
- hasProcess,
883
- hasProcessBatch,
886
+ hasHandler,
887
+ hasBatchHandler,
884
888
  isMultiJob
885
889
  };
886
890
  }
@@ -1555,7 +1559,7 @@ function defaultConfigTemplate() {
1555
1559
 
1556
1560
  // Auto-inferred env types are generated under .better-cf/*.d.ts
1557
1561
  // You can still switch to createSDK<Env>() when you need explicit overrides.
1558
- export const { defineQueue, defineWorker } = createSDK();
1562
+ export const { defineQueue, defineQueues, defineWorker } = createSDK();
1559
1563
 
1560
1564
  export const betterCfConfig = {
1561
1565
  // workerEntry: 'worker.ts',