@dragonmastery/tamer 0.29.0 → 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{StateManager-DTqtLLVX.mjs → StateManager-JLBtz9V-.mjs} +2 -2
  2. package/dist/{StateManager-DTqtLLVX.mjs.map → StateManager-JLBtz9V-.mjs.map} +1 -1
  3. package/dist/{apply-BOABC3UB.mjs → apply-CWU3HY0P.mjs} +11 -11
  4. package/dist/{apply-BOABC3UB.mjs.map → apply-CWU3HY0P.mjs.map} +1 -1
  5. package/dist/{applyTarget-GWDEOXeY.mjs → applyTarget-D15T_q7G.mjs} +2 -2
  6. package/dist/{applyTarget-GWDEOXeY.mjs.map → applyTarget-D15T_q7G.mjs.map} +1 -1
  7. package/dist/{bootstrap-BxwxC_2Z.mjs → bootstrap-BicPW44a.mjs} +3 -3
  8. package/dist/{bootstrap-BxwxC_2Z.mjs.map → bootstrap-BicPW44a.mjs.map} +1 -1
  9. package/dist/{cloudflareSnapshot-DzPuCRTh.mjs → cloudflareSnapshot-GBUHeg2m.mjs} +5 -5
  10. package/dist/{cloudflareSnapshot-DzPuCRTh.mjs.map → cloudflareSnapshot-GBUHeg2m.mjs.map} +1 -1
  11. package/dist/{deploy-C0edCpn9.mjs → deploy-DAEjDjOm.mjs} +7 -7
  12. package/dist/{deploy-C0edCpn9.mjs.map → deploy-DAEjDjOm.mjs.map} +1 -1
  13. package/dist/{destroy-DzgA4lCA.mjs → destroy-DtgPD_bD.mjs} +9 -9
  14. package/dist/{destroy-DzgA4lCA.mjs.map → destroy-DtgPD_bD.mjs.map} +1 -1
  15. package/dist/{destroy-tenant-U0t7BeJ0.mjs → destroy-tenant-B-VLKfc6.mjs} +3 -3
  16. package/dist/{destroy-tenant-U0t7BeJ0.mjs.map → destroy-tenant-B-VLKfc6.mjs.map} +1 -1
  17. package/dist/{dev-CZbKfdFw.mjs → dev-BYItpt9U.mjs} +7 -7
  18. package/dist/{dev-CZbKfdFw.mjs.map → dev-BYItpt9U.mjs.map} +1 -1
  19. package/dist/{dns-records.sync-Bpzz9H0s.mjs → dns-records.sync-CfI1mqXv.mjs} +2 -2
  20. package/dist/{dns-records.sync-Bpzz9H0s.mjs.map → dns-records.sync-CfI1mqXv.mjs.map} +1 -1
  21. package/dist/drift-DRnwTyZD.mjs +10 -0
  22. package/dist/{drift-B5bpkI0i.mjs → drift-DncpkI2R.mjs} +6 -6
  23. package/dist/{drift-B5bpkI0i.mjs.map → drift-DncpkI2R.mjs.map} +1 -1
  24. package/dist/{events-BIznt8Sj.mjs → events-B6oCdvSt.mjs} +3 -3
  25. package/dist/{events-BIznt8Sj.mjs.map → events-B6oCdvSt.mjs.map} +1 -1
  26. package/dist/{fetchStackImports-C-1THPYL.mjs → fetchStackImports-ClUYZy_U.mjs} +281 -97
  27. package/dist/fetchStackImports-ClUYZy_U.mjs.map +1 -0
  28. package/dist/{generator-Ba-vqyBG.mjs → generator-h_VG0Q5f.mjs} +6 -5
  29. package/dist/generator-h_VG0Q5f.mjs.map +1 -0
  30. package/dist/{import-B0dlwKoQ.mjs → import-D8zaVvwK.mjs} +6 -4
  31. package/dist/import-D8zaVvwK.mjs.map +1 -0
  32. package/dist/index.d.mts +51 -13
  33. package/dist/index.d.mts.map +1 -1
  34. package/dist/{loader-DAvCKLTT.mjs → loader-DnT9iqz9.mjs} +16 -3
  35. package/dist/loader-DnT9iqz9.mjs.map +1 -0
  36. package/dist/{migrate-BpW6JkIg.mjs → migrate-Bwl0w6XN.mjs} +5 -5
  37. package/dist/{migrate-BpW6JkIg.mjs.map → migrate-Bwl0w6XN.mjs.map} +1 -1
  38. package/dist/normalize-DVSTRZhO.mjs.map +1 -1
  39. package/dist/{plan-Do5rE-c5.mjs → plan-BNIAD--f.mjs} +9 -9
  40. package/dist/{plan-Do5rE-c5.mjs.map → plan-BNIAD--f.mjs.map} +1 -1
  41. package/dist/{provision-tenant-Wfck-2Oa.mjs → provision-tenant-BcZocyyn.mjs} +3 -3
  42. package/dist/{provision-tenant-Wfck-2Oa.mjs.map → provision-tenant-BcZocyyn.mjs.map} +1 -1
  43. package/dist/{stackOutputs-CQQHtdPA.mjs → stackOutputs-D33EmyfT.mjs} +2 -2
  44. package/dist/{stackOutputs-CQQHtdPA.mjs.map → stackOutputs-D33EmyfT.mjs.map} +1 -1
  45. package/dist/{status-D5GLpWyn.mjs → status-BAPpi2Zt.mjs} +5 -5
  46. package/dist/{status-D5GLpWyn.mjs.map → status-BAPpi2Zt.mjs.map} +1 -1
  47. package/dist/{sync-B_pyPi7Z.mjs → sync-BdJ43vO7.mjs} +6 -6
  48. package/dist/{sync-B_pyPi7Z.mjs.map → sync-BdJ43vO7.mjs.map} +1 -1
  49. package/dist/tamer.mjs +32 -18
  50. package/dist/tamer.mjs.map +1 -1
  51. package/dist/{types-JrdlG7Dy.mjs → types-CN1BOr0U.mjs} +5 -5
  52. package/dist/{types-JrdlG7Dy.mjs.map → types-CN1BOr0U.mjs.map} +1 -1
  53. package/dist/{verifyPlanFile-ah_4tvTu.mjs → verifyPlanFile-BQ7GCDC2.mjs} +2 -2
  54. package/dist/{verifyPlanFile-ah_4tvTu.mjs.map → verifyPlanFile-BQ7GCDC2.mjs.map} +1 -1
  55. package/dist/{wfp-delete-BhuUrBUA.mjs → wfp-delete-BG9WBd7F.mjs} +2 -2
  56. package/dist/{wfp-delete-BhuUrBUA.mjs.map → wfp-delete-BG9WBd7F.mjs.map} +1 -1
  57. package/dist/{wfp-put-DL0mJNNz.mjs → wfp-put-DjErqxFa.mjs} +2 -2
  58. package/dist/{wfp-put-DL0mJNNz.mjs.map → wfp-put-DjErqxFa.mjs.map} +1 -1
  59. package/dist/{worker-route-CMbtozNa.mjs → worker-route-DY1onr-h.mjs} +3 -3
  60. package/dist/{worker-route-CMbtozNa.mjs.map → worker-route-DY1onr-h.mjs.map} +1 -1
  61. package/dist/{workers-C-oeZhdD.mjs → workers-DNKsZOq4.mjs} +3 -3
  62. package/dist/{workers-C-oeZhdD.mjs.map → workers-DNKsZOq4.mjs.map} +1 -1
  63. package/package.json +1 -1
  64. package/dist/drift-BNa92AK5.mjs +0 -10
  65. package/dist/fetchStackImports-C-1THPYL.mjs.map +0 -1
  66. package/dist/generator-Ba-vqyBG.mjs.map +0 -1
  67. package/dist/import-B0dlwKoQ.mjs.map +0 -1
  68. package/dist/loader-DAvCKLTT.mjs.map +0 -1
@@ -1,6 +1,6 @@
1
1
  import { f as getDispatchNamespaces, n as materializeTamerResolvable, r as materializeVars } from "./normalize-DVSTRZhO.mjs";
2
- import { t as getWorkers } from "./loader-DAvCKLTT.mjs";
3
- import { f as stackNameForConfig, o as effectiveDispatchNamespaceName, s as isEphemeralEnv, t as StateManager } from "./StateManager-DTqtLLVX.mjs";
2
+ import { t as getWorkers } from "./loader-DnT9iqz9.mjs";
3
+ import { f as stackNameForConfig, o as effectiveDispatchNamespaceName, s as isEphemeralEnv, t as StateManager } from "./StateManager-JLBtz9V-.mjs";
4
4
  import { n as r2S3CredentialsFromEnv, t as emptyR2BucketViaS3 } from "./r2S3EmptyBucket-DD81ZWQ7.mjs";
5
5
  import { n as logApplyChange } from "./planFormat-CJw8Kq2s.mjs";
6
6
  import { resolve } from "path";
@@ -14,6 +14,10 @@ var NamingEngine = class {
14
14
  this.tenant = tenant;
15
15
  this.conventions = conventions;
16
16
  }
17
+ /** Tenant id for per-resource {@link CloudflareNameFn} overrides. */
18
+ get tenantId() {
19
+ return this.tenant.id;
20
+ }
17
21
  d1SingleName(logicalName, env) {
18
22
  if (this.conventions?.d1Single) return this.conventions.d1Single(logicalName, this.tenant.id, env);
19
23
  return `db_${logicalName}_t_${this.tenant.id}_${env}`;
@@ -153,6 +157,10 @@ var NamingEngine = class {
153
157
  if (env === "local") return `${this.tenant.slug}-${workerKey}-${this.tenant.id}`;
154
158
  return `${this.tenant.slug}-${workerKey}-${env}-${this.tenant.id}`;
155
159
  }
160
+ /** Whether stack {@link NamingConventions.d1Shard} is configured. */
161
+ hasD1ShardConvention() {
162
+ return Boolean(this.conventions?.d1Shard);
163
+ }
156
164
  d1MatchPattern(logicalName, env) {
157
165
  if (this.conventions?.d1Shard) return (name) => {
158
166
  const shardDate = this.extractD1ShardDate(name);
@@ -843,6 +851,71 @@ async function resolveWorkerConfig(config, workerKey, workerConfig, env, baseDir
843
851
  };
844
852
  }
845
853
 
854
+ //#endregion
855
+ //#region src/core/naming/resolveCloudflareName.ts
856
+ function resolveOverride(fn, tenantId, env, ctx) {
857
+ if (!fn) return void 0;
858
+ return fn(tenantId, env, ctx);
859
+ }
860
+ /** Managed D1 Cloudflare database name (not external `databaseName`). */
861
+ function resolveD1CloudflareName(config, env, naming, shardDate) {
862
+ const tenantId = naming.tenantId;
863
+ if (config.type === "single") {
864
+ const override$1 = resolveOverride(config.cloudflareName, tenantId, env);
865
+ if (override$1 !== void 0) return override$1;
866
+ return naming.d1SingleName(config.logicalName, env);
867
+ }
868
+ if (!shardDate) throw new Error(`Sharded D1 "${config.logicalName}" requires shardDate`);
869
+ const override = resolveOverride(config.cloudflareName, tenantId, env, { shardDate });
870
+ if (override !== void 0) return override;
871
+ return naming.d1ShardName(config.logicalName, shardDate, env);
872
+ }
873
+ function resolveR2CloudflareName(config, env, naming) {
874
+ const override = resolveOverride(config.cloudflareName, naming.tenantId, env);
875
+ if (override !== void 0) return override;
876
+ return naming.r2BucketName(config.logicalName, env);
877
+ }
878
+ function resolveWorkflowCloudflareName(config, env, naming) {
879
+ const override = resolveOverride(config.cloudflareName, naming.tenantId, env);
880
+ if (override !== void 0) return override;
881
+ return naming.workflowName(config.logicalName, env);
882
+ }
883
+ function resolveKVCloudflareName(config, env, naming) {
884
+ const override = resolveOverride(config.cloudflareName, naming.tenantId, env);
885
+ if (override !== void 0) return override;
886
+ return naming.kvNamespaceName(config.logicalName, env);
887
+ }
888
+ function resolveQueueCloudflareName(config, env, naming) {
889
+ const override = resolveOverride(config.cloudflareName, naming.tenantId, env);
890
+ if (override !== void 0) return override;
891
+ return naming.queueName(config.logicalName, env);
892
+ }
893
+ function resolveHyperdriveCloudflareName(config, env, naming) {
894
+ const override = resolveOverride(config.cloudflareName, naming.tenantId, env);
895
+ if (override !== void 0) return override;
896
+ return naming.hyperdriveName(config.logicalName, env);
897
+ }
898
+ function resolveVectorizeCloudflareName(config, env, naming) {
899
+ const override = resolveOverride(config.cloudflareName, naming.tenantId, env);
900
+ if (override !== void 0) return override;
901
+ return naming.vectorizeName(config.logicalName, env);
902
+ }
903
+ function resolveAIGatewayCloudflareName(config, env, naming) {
904
+ const override = resolveOverride(config.cloudflareName, naming.tenantId, env);
905
+ if (override !== void 0) return override;
906
+ return naming.aiGatewayId(config.logicalName, env);
907
+ }
908
+ function resolvePipelineCloudflareName(config, env, naming) {
909
+ const override = resolveOverride(config.cloudflareName, naming.tenantId, env);
910
+ if (override !== void 0) return override;
911
+ return naming.pipelineName(config.logicalName, env);
912
+ }
913
+ function resolveSecretsStoreCloudflareName(config, env, naming) {
914
+ const override = resolveOverride(config.cloudflareName, naming.tenantId, env);
915
+ if (override !== void 0) return override;
916
+ return naming.secretsStoreName(config.logicalName, env);
917
+ }
918
+
846
919
  //#endregion
847
920
  //#region src/features/d1/d1.ownership.ts
848
921
  function d1IsExternal(config) {
@@ -863,7 +936,34 @@ function d1CloudflareDatabaseName(config, env, naming) {
863
936
  if (typeof n !== "string" || !n.trim()) throw new Error(`D1 "${config.logicalName}" has ownership "external" but databaseName is empty — ensure imports are pre-fetched and config is merged with resolveWorkerConfig / mergeWorkerConfigWithResolvedRefs.`);
864
937
  return n.trim();
865
938
  }
866
- return naming.d1SingleName(config.logicalName, env);
939
+ return resolveD1CloudflareName(config, env, naming);
940
+ }
941
+
942
+ //#endregion
943
+ //#region src/features/d1/d1.naming.ts
944
+ function d1DeriveName(config, env, shardDate, naming) {
945
+ if (config.type === "single") return resolveD1CloudflareName(config, env, naming);
946
+ if (!shardDate) throw new Error(`Sharded D1 "${config.logicalName}" requires shardDate`);
947
+ return resolveD1CloudflareName(config, env, naming, shardDate);
948
+ }
949
+ function d1MatchPattern(config, env, naming) {
950
+ if (config.type === "single") {
951
+ const exactName = resolveD1CloudflareName(config, env, naming);
952
+ return (name) => name === exactName;
953
+ }
954
+ if (config.cloudflareName || naming.hasD1ShardConvention()) return (name) => {
955
+ const shardDate = d1ExtractShardDate(name, naming);
956
+ if (!shardDate) return false;
957
+ try {
958
+ return resolveD1CloudflareName(config, env, naming, shardDate) === name;
959
+ } catch {
960
+ return false;
961
+ }
962
+ };
963
+ return naming.d1MatchPattern(config.logicalName, env);
964
+ }
965
+ function d1ExtractShardDate(name, naming) {
966
+ return naming.extractD1ShardDate(name);
867
967
  }
868
968
 
869
969
  //#endregion
@@ -900,7 +1000,7 @@ async function d1Apply(resources, tenant, env, api, state, naming, addShard) {
900
1000
  if (addShard && addShard !== config.logicalName) continue;
901
1001
  if (addShard && addShard === config.logicalName) {
902
1002
  const shardDate$1 = todayNoDashes();
903
- const derivedName$1 = naming.d1ShardName(config.logicalName, shardDate$1, env);
1003
+ const derivedName$1 = d1DeriveName(config, env, shardDate$1, naming);
904
1004
  if (state.get(derivedName$1)) continue;
905
1005
  const { uuid: uuid$1 } = await api.d1Create(derivedName$1);
906
1006
  state.set(derivedName$1, {
@@ -919,7 +1019,7 @@ async function d1Apply(resources, tenant, env, api, state, naming, addShard) {
919
1019
  const allResources = state.getAll();
920
1020
  if (Object.values(allResources).filter((e) => e.type === "d1_database" && "logicalName" in e && e.logicalName === config.logicalName).length > 0) continue;
921
1021
  const shardDate = todayNoDashes();
922
- const derivedName = naming.d1ShardName(config.logicalName, shardDate, env);
1022
+ const derivedName = d1DeriveName(config, env, shardDate, naming);
923
1023
  const { uuid } = await api.d1Create(derivedName);
924
1024
  state.set(derivedName, {
925
1025
  type: "d1_database",
@@ -935,19 +1035,6 @@ async function d1Apply(resources, tenant, env, api, state, naming, addShard) {
935
1035
  }
936
1036
  }
937
1037
 
938
- //#endregion
939
- //#region src/features/d1/d1.naming.ts
940
- function d1MatchPattern(config, env, naming) {
941
- if (config.type === "single") {
942
- const exactName = naming.d1SingleName(config.logicalName, env);
943
- return (name) => name === exactName;
944
- }
945
- return naming.d1MatchPattern(config.logicalName, env);
946
- }
947
- function d1ExtractShardDate(name, naming) {
948
- return naming.extractD1ShardDate(name);
949
- }
950
-
951
1038
  //#endregion
952
1039
  //#region src/features/d1/d1.sync.ts
953
1040
  function d1Sync(allD1, resources, tenant, env, state, naming) {
@@ -1024,7 +1111,7 @@ function d1Drift(allD1, resources, env, state, naming) {
1024
1111
  });
1025
1112
  continue;
1026
1113
  }
1027
- const pattern = naming.d1MatchPattern(config.logicalName, env);
1114
+ const pattern = d1MatchPattern(config, env, naming);
1028
1115
  const cfShards = allD1.filter((db) => pattern(db.name));
1029
1116
  const cfShardNames = new Set(cfShards.map((s) => s.name));
1030
1117
  const stateShards = d1State.filter((e) => e.logicalName === config.logicalName && !!e.shardDate);
@@ -1175,6 +1262,22 @@ function resourcesFrom(source) {
1175
1262
  return source;
1176
1263
  }
1177
1264
 
1265
+ //#endregion
1266
+ //#region src/core/registry/findResourceForImport.ts
1267
+ /**
1268
+ * Find the first declared resource config matching `logical` across all workers.
1269
+ * Used by `tamer import` to validate CF names against {@link cloudflareName} overrides.
1270
+ */
1271
+ async function findWorkerResourceByLogicalName(config, configKey, logical, baseDir) {
1272
+ const workers = await getWorkers(config, baseDir);
1273
+ for (const [, wc] of workers) {
1274
+ const list = wc.resources?.[configKey];
1275
+ if (!list) continue;
1276
+ const hit = list.find((r) => r.logicalName === logical);
1277
+ if (hit) return hit;
1278
+ }
1279
+ }
1280
+
1178
1281
  //#endregion
1179
1282
  //#region src/features/d1/d1.module.ts
1180
1283
  const d1Module = {
@@ -1217,11 +1320,13 @@ const d1Module = {
1217
1320
  console.warn(`Rollback: failed to delete D1 ${entry.derivedName}:`, err);
1218
1321
  }
1219
1322
  },
1220
- async importOne({ options, env, api, state, naming, ts }) {
1323
+ async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
1221
1324
  if (!options.cfId) throw new Error("import d1: --cf-id <uuid> is required");
1325
+ const resourceConfig = await findWorkerResourceByLogicalName(config, "d1", options.logical, baseDir);
1326
+ if (!resourceConfig) throw new Error(`import d1: no resources.d1 entry with logicalName "${options.logical}" in the Tamer project config`);
1222
1327
  const hit = (await api.d1ListAll()).find((d) => d.uuid === options.cfId);
1223
1328
  if (!hit) throw new Error(`import d1: D1 database with uuid "${options.cfId}" not found in account`);
1224
- const derivedName = options.shardDate ? naming.d1ShardName(options.logical, options.shardDate, env) : naming.d1SingleName(options.logical, env);
1329
+ const derivedName = options.shardDate ? d1DeriveName(resourceConfig, env, options.shardDate, naming) : d1DeriveName(resourceConfig, env, void 0, naming);
1225
1330
  if (hit.name !== derivedName) throw new Error(`import d1: cf name "${hit.name}" does not match derived "${derivedName}" — wrong --logical, missing --shard-date, or naming convention drift?`);
1226
1331
  const bindingKey = options.shardDate ? naming.d1ShardBindingKey(options.logical, options.shardDate) : naming.d1SingleBindingKey(options.logical);
1227
1332
  const existing = state.get(derivedName);
@@ -1240,6 +1345,22 @@ const d1Module = {
1240
1345
  }
1241
1346
  };
1242
1347
 
1348
+ //#endregion
1349
+ //#region src/features/r2/r2.naming.ts
1350
+ function r2DeriveName(config, env, naming) {
1351
+ return resolveR2CloudflareName(config, env, naming);
1352
+ }
1353
+ function r2MatchPattern(config, env, naming) {
1354
+ if (config.cloudflareName) {
1355
+ const expected = resolveR2CloudflareName(config, env, naming);
1356
+ return (name) => name === expected;
1357
+ }
1358
+ return naming.r2MatchPattern(config.logicalName, env);
1359
+ }
1360
+ function r2ExtractDate(name, naming) {
1361
+ return naming.extractR2Date(name);
1362
+ }
1363
+
1243
1364
  //#endregion
1244
1365
  //#region src/features/r2/r2.apply.ts
1245
1366
  function existingR2ForLogical(state, logicalName) {
@@ -1257,7 +1378,7 @@ function assertValidR2BucketName(name, logicalName) {
1257
1378
  }
1258
1379
  async function r2Apply(resources, tenant, env, api, state, naming) {
1259
1380
  for (const config of resources) {
1260
- const derivedName = naming.r2BucketName(config.logicalName, env);
1381
+ const derivedName = r2DeriveName(config, env, naming);
1261
1382
  if (state.get(derivedName)) {
1262
1383
  console.log(`R2: skip "${derivedName}" (already in state; logical "${config.logicalName}")`);
1263
1384
  continue;
@@ -1282,17 +1403,11 @@ async function r2Apply(resources, tenant, env, api, state, naming) {
1282
1403
  }
1283
1404
  }
1284
1405
 
1285
- //#endregion
1286
- //#region src/features/r2/r2.naming.ts
1287
- function r2ExtractDate(name, naming) {
1288
- return naming.extractR2Date(name);
1289
- }
1290
-
1291
1406
  //#endregion
1292
1407
  //#region src/features/r2/r2.sync.ts
1293
1408
  function r2Sync(allR2, resources, tenant, env, state, naming) {
1294
1409
  for (const config of resources) {
1295
- const pattern = naming.r2MatchPattern(config.logicalName, env);
1410
+ const pattern = r2MatchPattern(config, env, naming);
1296
1411
  const match = allR2.find((b) => pattern(b.name));
1297
1412
  if (match) {
1298
1413
  const createdDate = r2ExtractDate(match.name, naming) ?? match.creation_date.slice(0, 10);
@@ -1329,7 +1444,7 @@ function r2Drift(allR2, resources, env, state, naming) {
1329
1444
  const allState = state.getAll();
1330
1445
  const r2State = Object.values(allState).filter((e) => e.type === "r2_bucket");
1331
1446
  for (const config of resources) {
1332
- const pattern = naming.r2MatchPattern(config.logicalName, env);
1447
+ const pattern = r2MatchPattern(config, env, naming);
1333
1448
  const cfMatch = allR2.find((b) => pattern(b.name));
1334
1449
  const stateEntry = r2State.find((e) => e.logicalName === config.logicalName);
1335
1450
  if (stateEntry && !cfNames.has(stateEntry.derivedName)) {
@@ -1407,7 +1522,7 @@ function r2Status(resources, env, state, naming) {
1407
1522
  const entry = Object.values(allResources).find((e) => e.type === "r2_bucket" && e.logicalName === config.logicalName);
1408
1523
  results.push({
1409
1524
  binding: entry?.bindingKey ?? naming.r2BindingKey(config.logicalName),
1410
- name: entry?.derivedName ?? naming.r2BucketName(config.logicalName, env),
1525
+ name: entry?.derivedName ?? r2DeriveName(config, env, naming),
1411
1526
  status: entry ? "ok" : "missing"
1412
1527
  });
1413
1528
  }
@@ -1455,12 +1570,14 @@ const r2Module = {
1455
1570
  console.warn(`Rollback: failed to delete R2 ${entry.derivedName}:`, err);
1456
1571
  }
1457
1572
  },
1458
- async importOne({ options, env, api, state, naming, ts }) {
1573
+ async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
1459
1574
  const bucketName = options.cfId;
1460
1575
  if (!bucketName) throw new Error("import r2: --cf-id <bucket-name> is required");
1576
+ const resourceConfig = await findWorkerResourceByLogicalName(config, "r2", options.logical, baseDir);
1577
+ if (!resourceConfig) throw new Error(`import r2: no resources.r2 entry with logicalName "${options.logical}" in the Tamer project config`);
1461
1578
  const hit = (await api.r2ListAll()).find((b) => b.name === bucketName);
1462
1579
  if (!hit) throw new Error(`import r2: bucket "${bucketName}" not found in account`);
1463
- if (!naming.r2MatchPattern(options.logical, env)(hit.name)) throw new Error(`import r2: bucket name "${hit.name}" does not match expected pattern for logical "${options.logical}" and env "${env}"`);
1580
+ if (!r2MatchPattern(resourceConfig, env, naming)(hit.name)) throw new Error(`import r2: bucket name "${hit.name}" does not match expected pattern for logical "${options.logical}" and env "${env}"`);
1464
1581
  const derivedName = hit.name;
1465
1582
  const createdDate = options.createdDate ?? naming.extractR2Date(hit.name) ?? hit.creation_date.slice(0, 10);
1466
1583
  const bindingKey = naming.r2BindingKey(options.logical);
@@ -1478,11 +1595,17 @@ const r2Module = {
1478
1595
  }
1479
1596
  };
1480
1597
 
1598
+ //#endregion
1599
+ //#region src/features/kv/kv.naming.ts
1600
+ function kvDeriveName(config, env, naming) {
1601
+ return resolveKVCloudflareName(config, env, naming);
1602
+ }
1603
+
1481
1604
  //#endregion
1482
1605
  //#region src/features/kv/kv.apply.ts
1483
1606
  async function kvApply(resources, tenant, env, api, state, naming) {
1484
1607
  for (const config of resources) {
1485
- const derivedName = naming.kvNamespaceName(config.logicalName, env);
1608
+ const derivedName = kvDeriveName(config, env, naming);
1486
1609
  if (state.get(derivedName)) continue;
1487
1610
  const { id } = await api.kvCreate(derivedName);
1488
1611
  state.set(derivedName, {
@@ -1501,7 +1624,7 @@ async function kvApply(resources, tenant, env, api, state, naming) {
1501
1624
  //#region src/features/kv/kv.sync.ts
1502
1625
  function kvSync(allKV, resources, tenant, env, state, naming) {
1503
1626
  for (const config of resources) {
1504
- const derivedName = naming.kvNamespaceName(config.logicalName, env);
1627
+ const derivedName = kvDeriveName(config, env, naming);
1505
1628
  const match = allKV.find((ns) => ns.title === derivedName);
1506
1629
  if (match) state.set(derivedName, {
1507
1630
  type: "kv_namespace",
@@ -1528,7 +1651,7 @@ function kvDrift(allKV, resources, env, state, naming) {
1528
1651
  const allState = state.getAll();
1529
1652
  const kvState = Object.values(allState).filter((e) => e.type === "kv_namespace");
1530
1653
  for (const config of resources) {
1531
- const derivedName = naming.kvNamespaceName(config.logicalName, env);
1654
+ const derivedName = kvDeriveName(config, env, naming);
1532
1655
  const cfId = cfByTitle.get(derivedName);
1533
1656
  const stateEntry = kvState.find((e) => e.logicalName === config.logicalName);
1534
1657
  if (stateEntry && !cfId) drift.missingFromCloudflare.push({
@@ -1571,7 +1694,7 @@ async function kvDestroy(_env, state, api, config, baseDir, _force) {
1571
1694
  function kvGenerate(resources, env, state, naming) {
1572
1695
  const bindings = [];
1573
1696
  for (const config of resources) {
1574
- const derivedName = naming.kvNamespaceName(config.logicalName, env);
1697
+ const derivedName = kvDeriveName(config, env, naming);
1575
1698
  const entry = state.get(derivedName);
1576
1699
  if (!entry || entry.type !== "kv_namespace") throw new Error(`KV "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
1577
1700
  bindings.push({
@@ -1587,7 +1710,7 @@ function kvGenerate(resources, env, state, naming) {
1587
1710
  function kvStatus(resources, env, state, naming) {
1588
1711
  const results = [];
1589
1712
  for (const config of resources) {
1590
- const derivedName = naming.kvNamespaceName(config.logicalName, env);
1713
+ const derivedName = kvDeriveName(config, env, naming);
1591
1714
  const entry = state.get(derivedName);
1592
1715
  results.push({
1593
1716
  binding: naming.kvBindingKey(config.logicalName),
@@ -1642,11 +1765,13 @@ const kvModule = {
1642
1765
  console.warn(`Rollback: failed to delete KV ${entry.derivedName}:`, err);
1643
1766
  }
1644
1767
  },
1645
- async importOne({ options, env, api, state, naming, ts }) {
1768
+ async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
1646
1769
  if (!options.cfId) throw new Error("import kv: --cf-id <namespace-id> is required");
1770
+ const resourceConfig = await findWorkerResourceByLogicalName(config, "kv", options.logical, baseDir);
1771
+ if (!resourceConfig) throw new Error(`import kv: no resources.kv entry with logicalName "${options.logical}" in the Tamer project config`);
1647
1772
  const hit = (await api.kvListAll()).find((k) => k.id === options.cfId);
1648
1773
  if (!hit) throw new Error(`import kv: KV namespace id "${options.cfId}" not found in account`);
1649
- const derivedName = naming.kvNamespaceName(options.logical, env);
1774
+ const derivedName = kvDeriveName(resourceConfig, env, naming);
1650
1775
  if (hit.title !== derivedName) throw new Error(`import kv: cf title "${hit.title}" does not match derived "${derivedName}"`);
1651
1776
  const bindingKey = naming.kvBindingKey(options.logical);
1652
1777
  const existing = state.get(derivedName);
@@ -1663,6 +1788,12 @@ const kvModule = {
1663
1788
  }
1664
1789
  };
1665
1790
 
1791
+ //#endregion
1792
+ //#region src/features/queues/queues.naming.ts
1793
+ function queueDeriveName(config, env, naming) {
1794
+ return resolveQueueCloudflareName(config, env, naming);
1795
+ }
1796
+
1666
1797
  //#endregion
1667
1798
  //#region src/features/queues/queues.apply.ts
1668
1799
  const STATE_KEY_PREFIX$6 = "queue:";
@@ -1671,7 +1802,7 @@ function stateKey$6(derivedName) {
1671
1802
  }
1672
1803
  async function queuesApply(resources, _tenant, env, api, state, naming) {
1673
1804
  for (const config of resources) {
1674
- const derivedName = naming.queueName(config.logicalName, env);
1805
+ const derivedName = queueDeriveName(config, env, naming);
1675
1806
  const key = stateKey$6(derivedName);
1676
1807
  if (state.get(key)) continue;
1677
1808
  const ts = (/* @__PURE__ */ new Date()).toISOString();
@@ -1693,7 +1824,7 @@ async function queuesApply(resources, _tenant, env, api, state, naming) {
1693
1824
  //#region src/features/queues/queues.sync.ts
1694
1825
  function queuesSync(allQueues, resources, _tenant, env, state, naming) {
1695
1826
  for (const config of resources) {
1696
- const derivedName = naming.queueName(config.logicalName, env);
1827
+ const derivedName = queueDeriveName(config, env, naming);
1697
1828
  const match = allQueues.find((q) => q.queue_name === derivedName);
1698
1829
  if (!match) continue;
1699
1830
  const key = `queue:${derivedName}`;
@@ -1724,7 +1855,7 @@ function queuesDrift(allQueues, resources, env, state, naming) {
1724
1855
  const cfByName = new Map(allQueues.map((q) => [q.queue_name, q.queue_id]));
1725
1856
  const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "queue");
1726
1857
  for (const config of resources) {
1727
- const derivedName = naming.queueName(config.logicalName, env);
1858
+ const derivedName = queueDeriveName(config, env, naming);
1728
1859
  const cfId = cfByName.get(derivedName);
1729
1860
  const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
1730
1861
  if (stateEntry && !cfId) drift.missingFromCloudflare.push({
@@ -1773,7 +1904,7 @@ function queuesGenerate(resources, env, state, naming) {
1773
1904
  const producers = [];
1774
1905
  for (const config of resources) {
1775
1906
  if (config.consumerOnly) continue;
1776
- const derivedName = naming.queueName(config.logicalName, env);
1907
+ const derivedName = queueDeriveName(config, env, naming);
1777
1908
  const entry = state.get(`queue:${derivedName}`);
1778
1909
  if (!entry || entry.type !== "queue") throw new Error(`Queue "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
1779
1910
  producers.push({
@@ -1790,7 +1921,7 @@ function queuesGenerate(resources, env, state, naming) {
1790
1921
  function queuesStatus(resources, env, state, naming) {
1791
1922
  const out = [];
1792
1923
  for (const config of resources) {
1793
- const derivedName = naming.queueName(config.logicalName, env);
1924
+ const derivedName = queueDeriveName(config, env, naming);
1794
1925
  const entry = state.get(`queue:${derivedName}`);
1795
1926
  out.push({
1796
1927
  binding: config.binding?.trim() || naming.queueBindingKey(config.logicalName),
@@ -1853,11 +1984,13 @@ const queuesModule = {
1853
1984
  console.warn(`Rollback: failed to delete queue ${entry.derivedName}:`, err);
1854
1985
  }
1855
1986
  },
1856
- async importOne({ options, env, api, state, naming, ts }) {
1987
+ async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
1857
1988
  if (!options.cfId) throw new Error("import queue: --cf-id <queue-id> is required");
1989
+ const resourceConfig = await findWorkerResourceByLogicalName(config, "queues", options.logical, baseDir);
1990
+ if (!resourceConfig) throw new Error(`import queue: no resources.queues entry with logicalName "${options.logical}" in the Tamer project config`);
1858
1991
  const hit = (await api.queuesListAll()).find((q) => q.queue_id === options.cfId);
1859
1992
  if (!hit) throw new Error(`import queue: queue id "${options.cfId}" not found in account`);
1860
- const derivedName = naming.queueName(options.logical, env);
1993
+ const derivedName = queueDeriveName(resourceConfig, env, naming);
1861
1994
  if (hit.queue_name !== derivedName) throw new Error(`import queue: cf name "${hit.queue_name}" does not match derived "${derivedName}"`);
1862
1995
  const bindingKey = naming.queueBindingKey(options.logical);
1863
1996
  const key = `queue:${derivedName}`;
@@ -1905,13 +2038,19 @@ function resolveHyperdriveOrigin(config) {
1905
2038
  };
1906
2039
  }
1907
2040
 
2041
+ //#endregion
2042
+ //#region src/features/hyperdrive/hyperdrive.naming.ts
2043
+ function hyperdriveDeriveName(config, env, naming) {
2044
+ return resolveHyperdriveCloudflareName(config, env, naming);
2045
+ }
2046
+
1908
2047
  //#endregion
1909
2048
  //#region src/features/hyperdrive/hyperdrive.diff.ts
1910
2049
  function hyperdriveDiffPlanItems(args) {
1911
2050
  const { resources, env, state, naming } = args;
1912
2051
  const items = [];
1913
2052
  for (const config of resources) {
1914
- const derivedName = naming.hyperdriveName(config.logicalName, env);
2053
+ const derivedName = hyperdriveDeriveName(config, env, naming);
1915
2054
  const entry = state.get(`hyperdrive:${derivedName}`);
1916
2055
  if (!entry || entry.type !== "hyperdrive") continue;
1917
2056
  const changes = computeChanges$1(entry, config);
@@ -1970,7 +2109,7 @@ function stateKey$5(derivedName) {
1970
2109
  }
1971
2110
  async function hyperdriveApply(resources, _tenant, env, api, state, naming) {
1972
2111
  for (const config of resources) {
1973
- const derivedName = naming.hyperdriveName(config.logicalName, env);
2112
+ const derivedName = hyperdriveDeriveName(config, env, naming);
1974
2113
  const key = stateKey$5(derivedName);
1975
2114
  const existing = state.get(key);
1976
2115
  const ts = (/* @__PURE__ */ new Date()).toISOString();
@@ -2028,7 +2167,7 @@ async function hyperdriveApply(resources, _tenant, env, api, state, naming) {
2028
2167
  //#region src/features/hyperdrive/hyperdrive.sync.ts
2029
2168
  function hyperdriveSync(allHyperdrive, resources, _tenant, env, state, naming) {
2030
2169
  for (const config of resources) {
2031
- const derivedName = naming.hyperdriveName(config.logicalName, env);
2170
+ const derivedName = hyperdriveDeriveName(config, env, naming);
2032
2171
  const match = allHyperdrive.find((h) => h.name === derivedName);
2033
2172
  if (!match) continue;
2034
2173
  const key = `hyperdrive:${derivedName}`;
@@ -2061,7 +2200,7 @@ function hyperdriveDrift(allHyperdrive, resources, env, state, naming) {
2061
2200
  const cfByName = new Map(allHyperdrive.map((h) => [h.name, h.id]));
2062
2201
  const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "hyperdrive");
2063
2202
  for (const config of resources) {
2064
- const derivedName = naming.hyperdriveName(config.logicalName, env);
2203
+ const derivedName = hyperdriveDeriveName(config, env, naming);
2065
2204
  const cfId = cfByName.get(derivedName);
2066
2205
  const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
2067
2206
  if (stateEntry && !cfId) drift.missingFromCloudflare.push({
@@ -2104,7 +2243,7 @@ async function hyperdriveDestroy(_env, state, api, config, baseDir, _force) {
2104
2243
  function hyperdriveGenerate(resources, env, state, naming) {
2105
2244
  const out = [];
2106
2245
  for (const config of resources) {
2107
- const derivedName = naming.hyperdriveName(config.logicalName, env);
2246
+ const derivedName = hyperdriveDeriveName(config, env, naming);
2108
2247
  const entry = state.get(`hyperdrive:${derivedName}`);
2109
2248
  if (!entry || entry.type !== "hyperdrive") throw new Error(`Hyperdrive "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
2110
2249
  out.push({
@@ -2121,7 +2260,7 @@ function hyperdriveGenerate(resources, env, state, naming) {
2121
2260
  function hyperdriveStatus(resources, env, state, naming) {
2122
2261
  const out = [];
2123
2262
  for (const config of resources) {
2124
- const derivedName = naming.hyperdriveName(config.logicalName, env);
2263
+ const derivedName = hyperdriveDeriveName(config, env, naming);
2125
2264
  const entry = state.get(`hyperdrive:${derivedName}`);
2126
2265
  out.push({
2127
2266
  binding: config.binding?.trim() || naming.hyperdriveBindingKey(config.logicalName),
@@ -2187,11 +2326,13 @@ const hyperdriveModule = {
2187
2326
  console.warn(`Rollback: failed to delete Hyperdrive ${entry.derivedName}:`, err);
2188
2327
  }
2189
2328
  },
2190
- async importOne({ options, env, api, state, naming, ts }) {
2329
+ async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
2191
2330
  if (!options.cfId) throw new Error("import hyperdrive: --cf-id <config-id> is required");
2331
+ const resourceConfig = await findWorkerResourceByLogicalName(config, "hyperdrive", options.logical, baseDir);
2332
+ if (!resourceConfig) throw new Error(`import hyperdrive: no resources.hyperdrive entry with logicalName "${options.logical}" in the Tamer project config`);
2192
2333
  const hit = (await api.hyperdriveListAll()).find((h) => h.id === options.cfId);
2193
2334
  if (!hit) throw new Error(`import hyperdrive: config id "${options.cfId}" not found in account`);
2194
- const derivedName = naming.hyperdriveName(options.logical, env);
2335
+ const derivedName = hyperdriveDeriveName(resourceConfig, env, naming);
2195
2336
  if (hit.name !== derivedName) throw new Error(`import hyperdrive: cf name "${hit.name}" does not match derived "${derivedName}"`);
2196
2337
  const bindingKey = naming.hyperdriveBindingKey(options.logical);
2197
2338
  const key = `hyperdrive:${derivedName}`;
@@ -2213,6 +2354,12 @@ const hyperdriveModule = {
2213
2354
  }
2214
2355
  };
2215
2356
 
2357
+ //#endregion
2358
+ //#region src/features/vectorize/vectorize.naming.ts
2359
+ function vectorizeDeriveName(config, env, naming) {
2360
+ return resolveVectorizeCloudflareName(config, env, naming);
2361
+ }
2362
+
2216
2363
  //#endregion
2217
2364
  //#region src/features/vectorize/vectorize.apply.ts
2218
2365
  const STATE_KEY_PREFIX$4 = "vectorize:";
@@ -2221,7 +2368,7 @@ function stateKey$4(derivedName) {
2221
2368
  }
2222
2369
  async function vectorizeApply(resources, _tenant, env, api, state, naming) {
2223
2370
  for (const config of resources) {
2224
- const derivedName = naming.vectorizeName(config.logicalName, env);
2371
+ const derivedName = vectorizeDeriveName(config, env, naming);
2225
2372
  const key = stateKey$4(derivedName);
2226
2373
  const existing = state.get(key);
2227
2374
  if (existing) {
@@ -2257,7 +2404,7 @@ async function vectorizeApply(resources, _tenant, env, api, state, naming) {
2257
2404
  //#region src/features/vectorize/vectorize.sync.ts
2258
2405
  function vectorizeSync(allIndexes, resources, _tenant, env, state, naming) {
2259
2406
  for (const config of resources) {
2260
- const derivedName = naming.vectorizeName(config.logicalName, env);
2407
+ const derivedName = vectorizeDeriveName(config, env, naming);
2261
2408
  const match = allIndexes.find((i) => i.name === derivedName);
2262
2409
  if (!match) continue;
2263
2410
  const key = `vectorize:${derivedName}`;
@@ -2289,7 +2436,7 @@ function vectorizeDrift(allIndexes, resources, env, state, naming) {
2289
2436
  const cfByName = new Map(allIndexes.map((i) => [i.name, i.id ?? i.name]));
2290
2437
  const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "vectorize");
2291
2438
  for (const config of resources) {
2292
- const derivedName = naming.vectorizeName(config.logicalName, env);
2439
+ const derivedName = vectorizeDeriveName(config, env, naming);
2293
2440
  const cfId = cfByName.get(derivedName);
2294
2441
  const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
2295
2442
  if (stateEntry && !cfId) drift.missingFromCloudflare.push({
@@ -2337,7 +2484,7 @@ async function vectorizeDestroy(_env, state, api, config, baseDir, _force) {
2337
2484
  function vectorizeGenerate(resources, env, state, naming) {
2338
2485
  const out = [];
2339
2486
  for (const config of resources) {
2340
- const derivedName = naming.vectorizeName(config.logicalName, env);
2487
+ const derivedName = vectorizeDeriveName(config, env, naming);
2341
2488
  const entry = state.get(`vectorize:${derivedName}`);
2342
2489
  if (!entry || entry.type !== "vectorize") throw new Error(`Vectorize index "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
2343
2490
  out.push({
@@ -2353,7 +2500,7 @@ function vectorizeGenerate(resources, env, state, naming) {
2353
2500
  function vectorizeStatus(resources, env, state, naming) {
2354
2501
  const out = [];
2355
2502
  for (const config of resources) {
2356
- const derivedName = naming.vectorizeName(config.logicalName, env);
2503
+ const derivedName = vectorizeDeriveName(config, env, naming);
2357
2504
  const entry = state.get(`vectorize:${derivedName}`);
2358
2505
  out.push({
2359
2506
  binding: config.binding?.trim() || naming.vectorizeBindingKey(config.logicalName),
@@ -2370,7 +2517,7 @@ function vectorizeDiffPlanItems(args) {
2370
2517
  const { resources, env, state, naming } = args;
2371
2518
  const items = [];
2372
2519
  for (const config of resources) {
2373
- const derivedName = naming.vectorizeName(config.logicalName, env);
2520
+ const derivedName = vectorizeDeriveName(config, env, naming);
2374
2521
  const key = `vectorize:${derivedName}`;
2375
2522
  const entry = state.get(key);
2376
2523
  if (!entry || entry.type !== "vectorize") continue;
@@ -2456,12 +2603,14 @@ const vectorizeModule = {
2456
2603
  console.warn(`Rollback: failed to delete Vectorize ${entry.derivedName}:`, err);
2457
2604
  }
2458
2605
  },
2459
- async importOne({ options, env, api, state, naming, ts }) {
2606
+ async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
2460
2607
  const indexName = options.cfId;
2461
2608
  if (!indexName) throw new Error("import vectorize: --cf-id <index-name> is required");
2609
+ const resourceConfig = await findWorkerResourceByLogicalName(config, "vectorize", options.logical, baseDir);
2610
+ if (!resourceConfig) throw new Error(`import vectorize: no resources.vectorize entry with logicalName "${options.logical}" in the Tamer project config`);
2462
2611
  const hit = (await api.vectorizeListAll()).find((v) => v.name === indexName);
2463
2612
  if (!hit) throw new Error(`import vectorize: index "${indexName}" not found in account`);
2464
- const derivedName = naming.vectorizeName(options.logical, env);
2613
+ const derivedName = vectorizeDeriveName(resourceConfig, env, naming);
2465
2614
  if (hit.name !== derivedName) throw new Error(`import vectorize: cf name "${hit.name}" does not match derived "${derivedName}"`);
2466
2615
  if (!hit.config) throw new Error(`import vectorize: cf index "${hit.name}" returned no config (dimensions/metric)`);
2467
2616
  const metric = hit.config.metric;
@@ -2511,13 +2660,19 @@ function resolveAIGatewayConfig(config) {
2511
2660
  };
2512
2661
  }
2513
2662
 
2663
+ //#endregion
2664
+ //#region src/features/ai-gateway/ai-gateway.naming.ts
2665
+ function aiGatewayDeriveName(config, env, naming) {
2666
+ return resolveAIGatewayCloudflareName(config, env, naming);
2667
+ }
2668
+
2514
2669
  //#endregion
2515
2670
  //#region src/features/ai-gateway/ai-gateway.diff.ts
2516
2671
  function aiGatewayDiffPlanItems(args) {
2517
2672
  const { resources, env, state, naming } = args;
2518
2673
  const items = [];
2519
2674
  for (const config of resources) {
2520
- const derivedName = naming.aiGatewayId(config.logicalName, env);
2675
+ const derivedName = aiGatewayDeriveName(config, env, naming);
2521
2676
  const entry = state.get(`ai_gateway:${derivedName}`);
2522
2677
  if (!entry || entry.type !== "ai_gateway") continue;
2523
2678
  const changes = computeChanges(entry, config);
@@ -2601,7 +2756,7 @@ function stateKey$3(derivedName) {
2601
2756
  }
2602
2757
  async function aiGatewayApply(resources, _tenant, env, api, state, naming) {
2603
2758
  for (const config of resources) {
2604
- const derivedName = naming.aiGatewayId(config.logicalName, env);
2759
+ const derivedName = aiGatewayDeriveName(config, env, naming);
2605
2760
  const key = stateKey$3(derivedName);
2606
2761
  const existing = state.get(key);
2607
2762
  const resolved = resolveAIGatewayConfig(config);
@@ -2677,7 +2832,7 @@ async function aiGatewayApply(resources, _tenant, env, api, state, naming) {
2677
2832
  //#region src/features/ai-gateway/ai-gateway.sync.ts
2678
2833
  function aiGatewaySync(allGateways, resources, _tenant, env, state, naming) {
2679
2834
  for (const config of resources) {
2680
- const derivedName = naming.aiGatewayId(config.logicalName, env);
2835
+ const derivedName = aiGatewayDeriveName(config, env, naming);
2681
2836
  const match = allGateways.find((g) => g.id === derivedName);
2682
2837
  if (!match) continue;
2683
2838
  const key = `ai_gateway:${derivedName}`;
@@ -2715,7 +2870,7 @@ function aiGatewayDrift(allGateways, resources, env, state, naming) {
2715
2870
  const cfIds = new Set(allGateways.map((g) => g.id));
2716
2871
  const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "ai_gateway");
2717
2872
  for (const config of resources) {
2718
- const derivedName = naming.aiGatewayId(config.logicalName, env);
2873
+ const derivedName = aiGatewayDeriveName(config, env, naming);
2719
2874
  const inCloudflare = cfIds.has(derivedName);
2720
2875
  const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
2721
2876
  if (stateEntry && !inCloudflare) drift.missingFromCloudflare.push({
@@ -2758,7 +2913,7 @@ async function aiGatewayDestroy(_env, state, api, config, baseDir, _force) {
2758
2913
  function aiGatewayStatus(resources, env, state, naming) {
2759
2914
  const out = [];
2760
2915
  for (const config of resources) {
2761
- const derivedName = naming.aiGatewayId(config.logicalName, env);
2916
+ const derivedName = aiGatewayDeriveName(config, env, naming);
2762
2917
  const entry = state.get(`ai_gateway:${derivedName}`);
2763
2918
  out.push({
2764
2919
  binding: naming.aiGatewayBindingKey(config.logicalName),
@@ -2817,12 +2972,14 @@ const aiGatewayModule = {
2817
2972
  console.warn(`Rollback: failed to delete AI Gateway ${entry.derivedName}:`, err);
2818
2973
  }
2819
2974
  },
2820
- async importOne({ options, env, api, state, naming, ts }) {
2975
+ async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
2821
2976
  const gatewayId = options.cfId;
2822
2977
  if (!gatewayId) throw new Error("import ai_gateway: --cf-id <gateway-id> is required");
2978
+ const resourceConfig = await findWorkerResourceByLogicalName(config, "aiGateway", options.logical, baseDir);
2979
+ if (!resourceConfig) throw new Error(`import ai_gateway: no resources.aiGateway entry with logicalName "${options.logical}" in the Tamer project config`);
2823
2980
  const hit = (await api.aiGatewayListAll()).find((g) => g.id === gatewayId);
2824
2981
  if (!hit) throw new Error(`import ai_gateway: gateway "${gatewayId}" not found in account`);
2825
- const derivedName = naming.aiGatewayId(options.logical, env);
2982
+ const derivedName = aiGatewayDeriveName(resourceConfig, env, naming);
2826
2983
  if (hit.id !== derivedName) throw new Error(`import ai_gateway: cf id "${hit.id}" does not match derived "${derivedName}"`);
2827
2984
  const key = `ai_gateway:${derivedName}`;
2828
2985
  const existing = state.get(key);
@@ -2847,6 +3004,12 @@ const aiGatewayModule = {
2847
3004
  }
2848
3005
  };
2849
3006
 
3007
+ //#endregion
3008
+ //#region src/features/pipelines/pipelines.naming.ts
3009
+ function pipelineDeriveName(config, env, naming) {
3010
+ return resolvePipelineCloudflareName(config, env, naming);
3011
+ }
3012
+
2850
3013
  //#endregion
2851
3014
  //#region src/features/pipelines/pipelines.apply.ts
2852
3015
  const STATE_KEY_PREFIX$2 = "pipeline:";
@@ -2861,7 +3024,7 @@ function stateKey$2(derivedName) {
2861
3024
  */
2862
3025
  async function pipelinesApply(resources, _tenant, env, api, state, naming) {
2863
3026
  for (const config of resources) {
2864
- const derivedName = naming.pipelineName(config.logicalName, env);
3027
+ const derivedName = pipelineDeriveName(config, env, naming);
2865
3028
  const key = stateKey$2(derivedName);
2866
3029
  if (state.get(key)) continue;
2867
3030
  const ts = (/* @__PURE__ */ new Date()).toISOString();
@@ -2887,7 +3050,7 @@ async function pipelinesApply(resources, _tenant, env, api, state, naming) {
2887
3050
  //#region src/features/pipelines/pipelines.sync.ts
2888
3051
  function pipelinesSync(allPipelines, resources, _tenant, env, state, naming) {
2889
3052
  for (const config of resources) {
2890
- const derivedName = naming.pipelineName(config.logicalName, env);
3053
+ const derivedName = pipelineDeriveName(config, env, naming);
2891
3054
  const match = allPipelines.find((p) => p.name === derivedName);
2892
3055
  if (!match) continue;
2893
3056
  const key = `pipeline:${derivedName}`;
@@ -2919,7 +3082,7 @@ function pipelinesDrift(allPipelines, resources, env, state, naming) {
2919
3082
  const cfByName = new Map(allPipelines.map((p) => [p.name, p]));
2920
3083
  const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "pipeline");
2921
3084
  for (const config of resources) {
2922
- const derivedName = naming.pipelineName(config.logicalName, env);
3085
+ const derivedName = pipelineDeriveName(config, env, naming);
2923
3086
  const inCloudflare = cfByName.has(derivedName);
2924
3087
  const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
2925
3088
  if (stateEntry && !inCloudflare) drift.missingFromCloudflare.push({
@@ -2972,7 +3135,7 @@ async function pipelinesDestroy(_env, state, api, config, baseDir, _force) {
2972
3135
  function pipelinesGenerate(resources, env, state, naming) {
2973
3136
  const out = [];
2974
3137
  for (const config of resources) {
2975
- const derivedName = naming.pipelineName(config.logicalName, env);
3138
+ const derivedName = pipelineDeriveName(config, env, naming);
2976
3139
  const entry = state.get(`pipeline:${derivedName}`);
2977
3140
  if (!entry || entry.type !== "pipeline") throw new Error(`Pipeline "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
2978
3141
  out.push({
@@ -2988,7 +3151,7 @@ function pipelinesGenerate(resources, env, state, naming) {
2988
3151
  function pipelinesStatus(resources, env, state, naming) {
2989
3152
  const out = [];
2990
3153
  for (const config of resources) {
2991
- const derivedName = naming.pipelineName(config.logicalName, env);
3154
+ const derivedName = pipelineDeriveName(config, env, naming);
2992
3155
  const entry = state.get(`pipeline:${derivedName}`);
2993
3156
  out.push({
2994
3157
  binding: config.binding?.trim() || naming.pipelineBindingKey(config.logicalName),
@@ -3005,7 +3168,7 @@ function pipelinesDiffPlanItems(args) {
3005
3168
  const { resources, env, state, naming } = args;
3006
3169
  const items = [];
3007
3170
  for (const config of resources) {
3008
- const derivedName = naming.pipelineName(config.logicalName, env);
3171
+ const derivedName = pipelineDeriveName(config, env, naming);
3009
3172
  const key = `pipeline:${derivedName}`;
3010
3173
  const entry = state.get(key);
3011
3174
  if (!entry || entry.type !== "pipeline") continue;
@@ -3097,12 +3260,14 @@ const pipelinesModule = {
3097
3260
  console.warn(`Rollback: failed to delete Pipeline ${entry.derivedName}:`, err);
3098
3261
  }
3099
3262
  },
3100
- async importOne({ options, env, api, state, naming, ts }) {
3263
+ async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
3101
3264
  const pipelineId = options.cfId;
3102
3265
  if (!pipelineId) throw new Error("import pipeline: --cf-id <pipeline-id> is required");
3266
+ const resourceConfig = await findWorkerResourceByLogicalName(config, "pipelines", options.logical, baseDir);
3267
+ if (!resourceConfig) throw new Error(`import pipeline: no resources.pipelines entry with logicalName "${options.logical}" in the Tamer project config`);
3103
3268
  const hit = (await api.pipelineListAll()).find((p) => p.id === pipelineId);
3104
3269
  if (!hit) throw new Error(`import pipeline: pipeline "${pipelineId}" not found in account`);
3105
- const derivedName = naming.pipelineName(options.logical, env);
3270
+ const derivedName = pipelineDeriveName(resourceConfig, env, naming);
3106
3271
  if (hit.name !== derivedName) throw new Error(`import pipeline: cf name "${hit.name}" does not match derived "${derivedName}"`);
3107
3272
  const key = `pipeline:${derivedName}`;
3108
3273
  const existing = state.get(key);
@@ -3121,13 +3286,23 @@ const pipelinesModule = {
3121
3286
  }
3122
3287
  };
3123
3288
 
3289
+ //#endregion
3290
+ //#region src/features/workflows/workflows.naming.ts
3291
+ function workflowDeriveName(config, env, naming) {
3292
+ return resolveWorkflowCloudflareName(config, env, naming);
3293
+ }
3294
+ function workflowMatchPattern(config, env, naming) {
3295
+ const expected = resolveWorkflowCloudflareName(config, env, naming);
3296
+ return (name) => name === expected;
3297
+ }
3298
+
3124
3299
  //#endregion
3125
3300
  //#region src/features/workflows/workflows.diff.ts
3126
3301
  function workflowsDiffPlanItems(args) {
3127
3302
  const { resources, env, state, naming, worker } = args;
3128
3303
  const items = [];
3129
3304
  for (const config of resources) {
3130
- const derivedName = naming.workflowName(config.logicalName, env);
3305
+ const derivedName = workflowDeriveName(config, env, naming);
3131
3306
  const key = `workflow:${derivedName}`;
3132
3307
  const entry = state.get(key);
3133
3308
  if (!entry || entry.type !== "workflow") continue;
@@ -3214,7 +3389,7 @@ function limitsEqual(a, b) {
3214
3389
  */
3215
3390
  async function workflowsApply(resources, _tenant, env, api, state, naming, worker) {
3216
3391
  for (const config of resources) {
3217
- const derivedName = naming.workflowName(config.logicalName, env);
3392
+ const derivedName = workflowDeriveName(config, env, naming);
3218
3393
  const scriptName = resolveScriptName(config, worker);
3219
3394
  const key = stateKey$1(derivedName);
3220
3395
  const existing = state.get(key);
@@ -3267,8 +3442,8 @@ async function workflowsApply(resources, _tenant, env, api, state, naming, worke
3267
3442
  */
3268
3443
  function workflowsSync(allWorkflows, resources, _tenant, env, state, naming) {
3269
3444
  for (const config of resources) {
3270
- const derivedName = naming.workflowName(config.logicalName, env);
3271
- const pattern = naming.workflowMatchPattern(config.logicalName, env);
3445
+ const derivedName = workflowDeriveName(config, env, naming);
3446
+ const pattern = workflowMatchPattern(config, env, naming);
3272
3447
  const match = allWorkflows.find((w) => pattern(w.name));
3273
3448
  if (!match) continue;
3274
3449
  const key = `workflow:${derivedName}`;
@@ -3302,7 +3477,7 @@ function workflowsDrift(allWorkflows, resources, env, state, naming) {
3302
3477
  const cfByName = new Map(allWorkflows.map((w) => [w.name, w]));
3303
3478
  const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "workflow");
3304
3479
  for (const config of resources) {
3305
- const derivedName = naming.workflowName(config.logicalName, env);
3480
+ const derivedName = workflowDeriveName(config, env, naming);
3306
3481
  const inCloudflare = cfByName.has(derivedName);
3307
3482
  const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
3308
3483
  if (stateEntry && !inCloudflare) drift.missingFromCloudflare.push({
@@ -3356,7 +3531,7 @@ async function workflowsDestroy(_env, state, api, config, baseDir, _force) {
3356
3531
  function workflowsGenerate(resources, env, state, naming, worker) {
3357
3532
  const out = [];
3358
3533
  for (const config of resources) {
3359
- const derivedName = naming.workflowName(config.logicalName, env);
3534
+ const derivedName = workflowDeriveName(config, env, naming);
3360
3535
  const entry = state.get(`workflow:${derivedName}`);
3361
3536
  if (!entry || entry.type !== "workflow") throw new Error(`Workflow "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
3362
3537
  const explicitScript = config.scriptName?.trim();
@@ -3378,7 +3553,7 @@ function workflowsGenerate(resources, env, state, naming, worker) {
3378
3553
  function workflowsStatus(resources, env, state, naming) {
3379
3554
  const out = [];
3380
3555
  for (const config of resources) {
3381
- const derivedName = naming.workflowName(config.logicalName, env);
3556
+ const derivedName = workflowDeriveName(config, env, naming);
3382
3557
  const entry = state.get(`workflow:${derivedName}`);
3383
3558
  out.push({
3384
3559
  binding: config.binding?.trim() || naming.workflowBindingKey(config.logicalName),
@@ -3446,10 +3621,11 @@ const workflowsModule = {
3446
3621
  console.warn(`Rollback: failed to delete Workflow ${entry.derivedName}:`, err);
3447
3622
  }
3448
3623
  },
3449
- async importOne({ options, env, api, state, naming, ts }) {
3450
- const all = await api.workflowListAll();
3451
- const derivedName = naming.workflowName(options.logical, env);
3452
- const hit = all.find((w) => w.name === derivedName);
3624
+ async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
3625
+ const resourceConfig = await findWorkerResourceByLogicalName(config, "workflows", options.logical, baseDir);
3626
+ if (!resourceConfig) throw new Error(`import workflow: no resources.workflows entry with logicalName "${options.logical}" in the Tamer project config`);
3627
+ const derivedName = workflowDeriveName(resourceConfig, env, naming);
3628
+ const hit = (await api.workflowListAll()).find((w) => w.name === derivedName);
3453
3629
  if (!hit) throw new Error(`import workflow: no workflow named "${derivedName}" found in account`);
3454
3630
  if (options.cfId && hit.id !== options.cfId) throw new Error(`import workflow: cf id "${hit.id}" does not match --cf-id "${options.cfId}"`);
3455
3631
  const key = `workflow:${derivedName}`;
@@ -3470,6 +3646,12 @@ const workflowsModule = {
3470
3646
  }
3471
3647
  };
3472
3648
 
3649
+ //#endregion
3650
+ //#region src/features/secrets-store/secrets-store.naming.ts
3651
+ function secretsStoreDeriveName(config, env, naming) {
3652
+ return resolveSecretsStoreCloudflareName(config, env, naming);
3653
+ }
3654
+
3473
3655
  //#endregion
3474
3656
  //#region src/features/secrets-store/secrets-store.apply.ts
3475
3657
  const STATE_KEY_PREFIX = "secrets_store:";
@@ -3488,7 +3670,7 @@ async function secretsStoreApply(resources, _tenant, env, api, state, naming) {
3488
3670
  if (resources.length === 0) return;
3489
3671
  let allStores = null;
3490
3672
  for (const config of resources) {
3491
- const derivedName = naming.secretsStoreName(config.logicalName, env);
3673
+ const derivedName = secretsStoreDeriveName(config, env, naming);
3492
3674
  const key = stateKey(derivedName);
3493
3675
  const existing = state.get(key);
3494
3676
  const wantsBindingKey = naming.secretsStoreBindingKey(config.logicalName);
@@ -3522,7 +3704,7 @@ async function secretsStoreApply(resources, _tenant, env, api, state, naming) {
3522
3704
  */
3523
3705
  function secretsStoreSync(allStores, resources, _tenant, env, state, naming) {
3524
3706
  for (const config of resources) {
3525
- const derivedName = naming.secretsStoreName(config.logicalName, env);
3707
+ const derivedName = secretsStoreDeriveName(config, env, naming);
3526
3708
  const match = allStores.find((s) => s.name === derivedName);
3527
3709
  if (!match) continue;
3528
3710
  const key = `secrets_store:${derivedName}`;
@@ -3553,7 +3735,7 @@ function secretsStoreDrift(allStores, resources, env, state, naming) {
3553
3735
  const cfByName = new Map(allStores.map((s) => [s.name, s]));
3554
3736
  const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "secrets_store");
3555
3737
  for (const config of resources) {
3556
- const derivedName = naming.secretsStoreName(config.logicalName, env);
3738
+ const derivedName = secretsStoreDeriveName(config, env, naming);
3557
3739
  const inCloudflare = cfByName.has(derivedName);
3558
3740
  const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
3559
3741
  if (stateEntry && !inCloudflare) drift.missingFromCloudflare.push({
@@ -3598,7 +3780,7 @@ async function secretsStoreDestroy(_env, state, api, config, baseDir, _force) {
3598
3780
  function secretsStoreStatus(resources, env, state, naming) {
3599
3781
  const out = [];
3600
3782
  for (const config of resources) {
3601
- const derivedName = naming.secretsStoreName(config.logicalName, env);
3783
+ const derivedName = secretsStoreDeriveName(config, env, naming);
3602
3784
  const entry = state.get(`secrets_store:${derivedName}`);
3603
3785
  out.push({
3604
3786
  binding: naming.secretsStoreBindingKey(config.logicalName),
@@ -3653,9 +3835,11 @@ const secretsStoreModule = {
3653
3835
  console.warn(`Rollback: failed to delete Secrets Store ${entry.derivedName}:`, err);
3654
3836
  }
3655
3837
  },
3656
- async importOne({ options, env, api, state, naming, ts }) {
3838
+ async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
3839
+ const resourceConfig = await findWorkerResourceByLogicalName(config, "secretsStores", options.logical, baseDir);
3840
+ if (!resourceConfig) throw new Error(`import secret_store: no resources.secretsStores entry with logicalName "${options.logical}" in the Tamer project config`);
3657
3841
  const all = await api.secretsStoreListAll();
3658
- const derivedName = naming.secretsStoreName(options.logical, env);
3842
+ const derivedName = secretsStoreDeriveName(resourceConfig, env, naming);
3659
3843
  const hit = all.find((s) => s.name === derivedName);
3660
3844
  if (!hit) throw new Error(`import secret_store: no store named "${derivedName}" found in account`);
3661
3845
  if (options.cfId && hit.id !== options.cfId) throw new Error(`import secret_store: cf id "${hit.id}" does not match --cf-id "${options.cfId}"`);
@@ -3822,5 +4006,5 @@ async function fetchStackImports(api, config, env) {
3822
4006
  }
3823
4007
 
3824
4008
  //#endregion
3825
- export { namingFromConfig as _, resourceModules as a, d1SkipsProvisionAndMigrate as c, mergedWorkerConfigForEnv as d, resolveDeployedWorkerName as f, wranglerConfigCliArgs as g, resolveReferencesInString as h, getResourceModule as i, buildIntraStackScriptNameMap as l, rewriteIntraStackServiceTargets as m, importedStackNames as n, logicalNamesForResourceKind as o, resolveWorkerConfig as p, scanConfigForImports as r, d1CloudflareDatabaseName as s, fetchStackImports as t, mergeWorkerConfigForResourcePick as u };
3826
- //# sourceMappingURL=fetchStackImports-C-1THPYL.mjs.map
4009
+ export { wranglerConfigCliArgs as _, resourceModules as a, d1CloudflareDatabaseName as c, mergeWorkerConfigForResourcePick as d, mergedWorkerConfigForEnv as f, resolveReferencesInString as g, rewriteIntraStackServiceTargets as h, getResourceModule as i, d1SkipsProvisionAndMigrate as l, resolveWorkerConfig as m, importedStackNames as n, secretsStoreDeriveName as o, resolveDeployedWorkerName as p, scanConfigForImports as r, logicalNamesForResourceKind as s, fetchStackImports as t, buildIntraStackScriptNameMap as u, namingFromConfig as v };
4010
+ //# sourceMappingURL=fetchStackImports-ClUYZy_U.mjs.map