@dragonmastery/tamer 0.28.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.
- package/README.md +2 -1
- package/dist/{StateManager-DTqtLLVX.mjs → StateManager-JLBtz9V-.mjs} +2 -2
- package/dist/{StateManager-DTqtLLVX.mjs.map → StateManager-JLBtz9V-.mjs.map} +1 -1
- package/dist/{apply-B0b_jjGv.mjs → apply-CWU3HY0P.mjs} +13 -13
- package/dist/{apply-B0b_jjGv.mjs.map → apply-CWU3HY0P.mjs.map} +1 -1
- package/dist/{applyTarget-BetDYdeS.mjs → applyTarget-D15T_q7G.mjs} +3 -3
- package/dist/{applyTarget-BetDYdeS.mjs.map → applyTarget-D15T_q7G.mjs.map} +1 -1
- package/dist/{bootstrap-CBzPilB1.mjs → bootstrap-BicPW44a.mjs} +3 -3
- package/dist/{bootstrap-CBzPilB1.mjs.map → bootstrap-BicPW44a.mjs.map} +1 -1
- package/dist/{cloudflareSnapshot-B4FOaNr0.mjs → cloudflareSnapshot-GBUHeg2m.mjs} +7 -7
- package/dist/{cloudflareSnapshot-B4FOaNr0.mjs.map → cloudflareSnapshot-GBUHeg2m.mjs.map} +1 -1
- package/dist/{deploy-gHEQxhmx.mjs → deploy-DAEjDjOm.mjs} +8 -8
- package/dist/{deploy-gHEQxhmx.mjs.map → deploy-DAEjDjOm.mjs.map} +1 -1
- package/dist/{destroy-B21f3wgq.mjs → destroy-DtgPD_bD.mjs} +11 -11
- package/dist/{destroy-B21f3wgq.mjs.map → destroy-DtgPD_bD.mjs.map} +1 -1
- package/dist/{destroy-tenant-BW2nasnK.mjs → destroy-tenant-B-VLKfc6.mjs} +3 -3
- package/dist/{destroy-tenant-BW2nasnK.mjs.map → destroy-tenant-B-VLKfc6.mjs.map} +1 -1
- package/dist/{dev-Dt26nzMJ.mjs → dev-BYItpt9U.mjs} +8 -8
- package/dist/{dev-Dt26nzMJ.mjs.map → dev-BYItpt9U.mjs.map} +1 -1
- package/dist/{dns-records.sync-Bpzz9H0s.mjs → dns-records.sync-CfI1mqXv.mjs} +2 -2
- package/dist/{dns-records.sync-Bpzz9H0s.mjs.map → dns-records.sync-CfI1mqXv.mjs.map} +1 -1
- package/dist/drift-DRnwTyZD.mjs +10 -0
- package/dist/{drift-D8ZrSgTn.mjs → drift-DncpkI2R.mjs} +8 -8
- package/dist/{drift-D8ZrSgTn.mjs.map → drift-DncpkI2R.mjs.map} +1 -1
- package/dist/{events-BSwGdkGj.mjs → events-B6oCdvSt.mjs} +3 -3
- package/dist/{events-BSwGdkGj.mjs.map → events-B6oCdvSt.mjs.map} +1 -1
- package/dist/{fetchStackImports-B4ZJahOt.mjs → fetchStackImports-ClUYZy_U.mjs} +294 -101
- package/dist/fetchStackImports-ClUYZy_U.mjs.map +1 -0
- package/dist/{generator-CIMbcPzv.mjs → generator-h_VG0Q5f.mjs} +6 -5
- package/dist/generator-h_VG0Q5f.mjs.map +1 -0
- package/dist/{import-BrduwA9Z.mjs → import-D8zaVvwK.mjs} +6 -4
- package/dist/import-D8zaVvwK.mjs.map +1 -0
- package/dist/index.d.mts +154 -4
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{loader-DP7yXqT6.mjs → loader-DnT9iqz9.mjs} +17 -4
- package/dist/loader-DnT9iqz9.mjs.map +1 -0
- package/dist/{logpush-job-xS7270FZ.mjs → logpush-job-DsRkOORJ.mjs} +2 -2
- package/dist/{logpush-job-xS7270FZ.mjs.map → logpush-job-DsRkOORJ.mjs.map} +1 -1
- package/dist/{migrate-CahG6BYV.mjs → migrate-Bwl0w6XN.mjs} +5 -5
- package/dist/{migrate-CahG6BYV.mjs.map → migrate-Bwl0w6XN.mjs.map} +1 -1
- package/dist/{normalize-Bx0bpFop.mjs → normalize-DVSTRZhO.mjs} +18 -1
- package/dist/normalize-DVSTRZhO.mjs.map +1 -0
- package/dist/{plan-DWvsvy1U.mjs → plan-BNIAD--f.mjs} +11 -11
- package/dist/{plan-DWvsvy1U.mjs.map → plan-BNIAD--f.mjs.map} +1 -1
- package/dist/{provision-tenant-WTKo93Y0.mjs → provision-tenant-BcZocyyn.mjs} +4 -4
- package/dist/{provision-tenant-WTKo93Y0.mjs.map → provision-tenant-BcZocyyn.mjs.map} +1 -1
- package/dist/{stackOutputs-W9mnnJuj.mjs → stackOutputs-D33EmyfT.mjs} +3 -3
- package/dist/{stackOutputs-W9mnnJuj.mjs.map → stackOutputs-D33EmyfT.mjs.map} +1 -1
- package/dist/{status-DLwREPjb.mjs → status-BAPpi2Zt.mjs} +7 -7
- package/dist/{status-DLwREPjb.mjs.map → status-BAPpi2Zt.mjs.map} +1 -1
- package/dist/{sync-f2K2blwm.mjs → sync-BdJ43vO7.mjs} +8 -8
- package/dist/{sync-f2K2blwm.mjs.map → sync-BdJ43vO7.mjs.map} +1 -1
- package/dist/tamer.mjs +32 -18
- package/dist/tamer.mjs.map +1 -1
- package/dist/{types-CqxqYnrT.mjs → types-CN1BOr0U.mjs} +5 -5
- package/dist/{types-CqxqYnrT.mjs.map → types-CN1BOr0U.mjs.map} +1 -1
- package/dist/{verifyPlanFile-c16z1AMH.mjs → verifyPlanFile-BQ7GCDC2.mjs} +2 -2
- package/dist/{verifyPlanFile-c16z1AMH.mjs.map → verifyPlanFile-BQ7GCDC2.mjs.map} +1 -1
- package/dist/{wfp-delete-DysvX1u7.mjs → wfp-delete-BG9WBd7F.mjs} +2 -2
- package/dist/{wfp-delete-DysvX1u7.mjs.map → wfp-delete-BG9WBd7F.mjs.map} +1 -1
- package/dist/{wfp-put-jaVd_LjO.mjs → wfp-put-DjErqxFa.mjs} +2 -2
- package/dist/{wfp-put-jaVd_LjO.mjs.map → wfp-put-DjErqxFa.mjs.map} +1 -1
- package/dist/{worker-route-Be2IvOdr.mjs → worker-route-DY1onr-h.mjs} +3 -3
- package/dist/{worker-route-Be2IvOdr.mjs.map → worker-route-DY1onr-h.mjs.map} +1 -1
- package/dist/{workers-aGILs77X.mjs → workers-DNKsZOq4.mjs} +3 -3
- package/dist/{workers-aGILs77X.mjs.map → workers-DNKsZOq4.mjs.map} +1 -1
- package/package.json +1 -1
- package/dist/drift-D5qzCTft.mjs +0 -10
- package/dist/fetchStackImports-B4ZJahOt.mjs.map +0 -1
- package/dist/generator-CIMbcPzv.mjs.map +0 -1
- package/dist/import-BrduwA9Z.mjs.map +0 -1
- package/dist/loader-DP7yXqT6.mjs.map +0 -1
- package/dist/normalize-Bx0bpFop.mjs.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { f as getDispatchNamespaces, n as materializeTamerResolvable, r as materializeVars } from "./normalize-
|
|
2
|
-
import { t as getWorkers } from "./loader-
|
|
3
|
-
import { f as stackNameForConfig, o as effectiveDispatchNamespaceName, s as isEphemeralEnv, t as StateManager } from "./StateManager-
|
|
1
|
+
import { f as getDispatchNamespaces, n as materializeTamerResolvable, r as materializeVars } from "./normalize-DVSTRZhO.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}`;
|
|
@@ -111,6 +115,7 @@ var NamingEngine = class {
|
|
|
111
115
|
* scheme. Pattern: `wf-{logical}-t-{tenantId}-{env}`.
|
|
112
116
|
*/
|
|
113
117
|
workflowName(logicalName, env) {
|
|
118
|
+
if (this.conventions?.workflow) return this.conventions.workflow(logicalName, this.tenant.id, env);
|
|
114
119
|
return `wf-${logicalName}-t-${this.tenant.id}-${env}`.toLowerCase();
|
|
115
120
|
}
|
|
116
121
|
/**
|
|
@@ -152,7 +157,16 @@ var NamingEngine = class {
|
|
|
152
157
|
if (env === "local") return `${this.tenant.slug}-${workerKey}-${this.tenant.id}`;
|
|
153
158
|
return `${this.tenant.slug}-${workerKey}-${env}-${this.tenant.id}`;
|
|
154
159
|
}
|
|
160
|
+
/** Whether stack {@link NamingConventions.d1Shard} is configured. */
|
|
161
|
+
hasD1ShardConvention() {
|
|
162
|
+
return Boolean(this.conventions?.d1Shard);
|
|
163
|
+
}
|
|
155
164
|
d1MatchPattern(logicalName, env) {
|
|
165
|
+
if (this.conventions?.d1Shard) return (name) => {
|
|
166
|
+
const shardDate = this.extractD1ShardDate(name);
|
|
167
|
+
if (!shardDate) return false;
|
|
168
|
+
return this.d1ShardName(logicalName, shardDate, env) === name;
|
|
169
|
+
};
|
|
156
170
|
const suffix = `_t_${this.tenant.id}_${env}`;
|
|
157
171
|
if (logicalName === "default" || logicalName === "") return (name) => /^db_\d{8}_t_/.test(name) && name.endsWith(suffix);
|
|
158
172
|
const prefix = `db_${logicalName}_`;
|
|
@@ -174,11 +188,13 @@ var NamingEngine = class {
|
|
|
174
188
|
return (name) => name === exactNew || legacyDated.test(name);
|
|
175
189
|
}
|
|
176
190
|
extractD1ShardDate(name) {
|
|
177
|
-
const
|
|
178
|
-
if (
|
|
179
|
-
const d =
|
|
191
|
+
const compact = name.match(/_(\d{8})_t_/);
|
|
192
|
+
if (compact) {
|
|
193
|
+
const d = compact[1];
|
|
180
194
|
return `${d.slice(0, 4)}-${d.slice(4, 6)}-${d.slice(6, 8)}`;
|
|
181
195
|
}
|
|
196
|
+
const underscored = name.match(/_(\d{4})_(\d{2})_(\d{2})_t_/);
|
|
197
|
+
if (underscored) return `${underscored[1]}-${underscored[2]}-${underscored[3]}`;
|
|
182
198
|
return null;
|
|
183
199
|
}
|
|
184
200
|
extractR2Date(name) {
|
|
@@ -835,6 +851,71 @@ async function resolveWorkerConfig(config, workerKey, workerConfig, env, baseDir
|
|
|
835
851
|
};
|
|
836
852
|
}
|
|
837
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
|
+
|
|
838
919
|
//#endregion
|
|
839
920
|
//#region src/features/d1/d1.ownership.ts
|
|
840
921
|
function d1IsExternal(config) {
|
|
@@ -855,7 +936,34 @@ function d1CloudflareDatabaseName(config, env, naming) {
|
|
|
855
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.`);
|
|
856
937
|
return n.trim();
|
|
857
938
|
}
|
|
858
|
-
return
|
|
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);
|
|
859
967
|
}
|
|
860
968
|
|
|
861
969
|
//#endregion
|
|
@@ -892,7 +1000,7 @@ async function d1Apply(resources, tenant, env, api, state, naming, addShard) {
|
|
|
892
1000
|
if (addShard && addShard !== config.logicalName) continue;
|
|
893
1001
|
if (addShard && addShard === config.logicalName) {
|
|
894
1002
|
const shardDate$1 = todayNoDashes();
|
|
895
|
-
const derivedName$1 =
|
|
1003
|
+
const derivedName$1 = d1DeriveName(config, env, shardDate$1, naming);
|
|
896
1004
|
if (state.get(derivedName$1)) continue;
|
|
897
1005
|
const { uuid: uuid$1 } = await api.d1Create(derivedName$1);
|
|
898
1006
|
state.set(derivedName$1, {
|
|
@@ -911,7 +1019,7 @@ async function d1Apply(resources, tenant, env, api, state, naming, addShard) {
|
|
|
911
1019
|
const allResources = state.getAll();
|
|
912
1020
|
if (Object.values(allResources).filter((e) => e.type === "d1_database" && "logicalName" in e && e.logicalName === config.logicalName).length > 0) continue;
|
|
913
1021
|
const shardDate = todayNoDashes();
|
|
914
|
-
const derivedName =
|
|
1022
|
+
const derivedName = d1DeriveName(config, env, shardDate, naming);
|
|
915
1023
|
const { uuid } = await api.d1Create(derivedName);
|
|
916
1024
|
state.set(derivedName, {
|
|
917
1025
|
type: "d1_database",
|
|
@@ -927,19 +1035,6 @@ async function d1Apply(resources, tenant, env, api, state, naming, addShard) {
|
|
|
927
1035
|
}
|
|
928
1036
|
}
|
|
929
1037
|
|
|
930
|
-
//#endregion
|
|
931
|
-
//#region src/features/d1/d1.naming.ts
|
|
932
|
-
function d1MatchPattern(config, env, naming) {
|
|
933
|
-
if (config.type === "single") {
|
|
934
|
-
const exactName = naming.d1SingleName(config.logicalName, env);
|
|
935
|
-
return (name) => name === exactName;
|
|
936
|
-
}
|
|
937
|
-
return naming.d1MatchPattern(config.logicalName, env);
|
|
938
|
-
}
|
|
939
|
-
function d1ExtractShardDate(name, naming) {
|
|
940
|
-
return naming.extractD1ShardDate(name);
|
|
941
|
-
}
|
|
942
|
-
|
|
943
1038
|
//#endregion
|
|
944
1039
|
//#region src/features/d1/d1.sync.ts
|
|
945
1040
|
function d1Sync(allD1, resources, tenant, env, state, naming) {
|
|
@@ -1016,7 +1111,7 @@ function d1Drift(allD1, resources, env, state, naming) {
|
|
|
1016
1111
|
});
|
|
1017
1112
|
continue;
|
|
1018
1113
|
}
|
|
1019
|
-
const pattern =
|
|
1114
|
+
const pattern = d1MatchPattern(config, env, naming);
|
|
1020
1115
|
const cfShards = allD1.filter((db) => pattern(db.name));
|
|
1021
1116
|
const cfShardNames = new Set(cfShards.map((s) => s.name));
|
|
1022
1117
|
const stateShards = d1State.filter((e) => e.logicalName === config.logicalName && !!e.shardDate);
|
|
@@ -1167,6 +1262,22 @@ function resourcesFrom(source) {
|
|
|
1167
1262
|
return source;
|
|
1168
1263
|
}
|
|
1169
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
|
+
|
|
1170
1281
|
//#endregion
|
|
1171
1282
|
//#region src/features/d1/d1.module.ts
|
|
1172
1283
|
const d1Module = {
|
|
@@ -1209,11 +1320,13 @@ const d1Module = {
|
|
|
1209
1320
|
console.warn(`Rollback: failed to delete D1 ${entry.derivedName}:`, err);
|
|
1210
1321
|
}
|
|
1211
1322
|
},
|
|
1212
|
-
async importOne({ options, env, api, state, naming, ts }) {
|
|
1323
|
+
async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
|
|
1213
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`);
|
|
1214
1327
|
const hit = (await api.d1ListAll()).find((d) => d.uuid === options.cfId);
|
|
1215
1328
|
if (!hit) throw new Error(`import d1: D1 database with uuid "${options.cfId}" not found in account`);
|
|
1216
|
-
const derivedName = options.shardDate ?
|
|
1329
|
+
const derivedName = options.shardDate ? d1DeriveName(resourceConfig, env, options.shardDate, naming) : d1DeriveName(resourceConfig, env, void 0, naming);
|
|
1217
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?`);
|
|
1218
1331
|
const bindingKey = options.shardDate ? naming.d1ShardBindingKey(options.logical, options.shardDate) : naming.d1SingleBindingKey(options.logical);
|
|
1219
1332
|
const existing = state.get(derivedName);
|
|
@@ -1232,6 +1345,22 @@ const d1Module = {
|
|
|
1232
1345
|
}
|
|
1233
1346
|
};
|
|
1234
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
|
+
|
|
1235
1364
|
//#endregion
|
|
1236
1365
|
//#region src/features/r2/r2.apply.ts
|
|
1237
1366
|
function existingR2ForLogical(state, logicalName) {
|
|
@@ -1249,7 +1378,7 @@ function assertValidR2BucketName(name, logicalName) {
|
|
|
1249
1378
|
}
|
|
1250
1379
|
async function r2Apply(resources, tenant, env, api, state, naming) {
|
|
1251
1380
|
for (const config of resources) {
|
|
1252
|
-
const derivedName =
|
|
1381
|
+
const derivedName = r2DeriveName(config, env, naming);
|
|
1253
1382
|
if (state.get(derivedName)) {
|
|
1254
1383
|
console.log(`R2: skip "${derivedName}" (already in state; logical "${config.logicalName}")`);
|
|
1255
1384
|
continue;
|
|
@@ -1274,17 +1403,11 @@ async function r2Apply(resources, tenant, env, api, state, naming) {
|
|
|
1274
1403
|
}
|
|
1275
1404
|
}
|
|
1276
1405
|
|
|
1277
|
-
//#endregion
|
|
1278
|
-
//#region src/features/r2/r2.naming.ts
|
|
1279
|
-
function r2ExtractDate(name, naming) {
|
|
1280
|
-
return naming.extractR2Date(name);
|
|
1281
|
-
}
|
|
1282
|
-
|
|
1283
1406
|
//#endregion
|
|
1284
1407
|
//#region src/features/r2/r2.sync.ts
|
|
1285
1408
|
function r2Sync(allR2, resources, tenant, env, state, naming) {
|
|
1286
1409
|
for (const config of resources) {
|
|
1287
|
-
const pattern =
|
|
1410
|
+
const pattern = r2MatchPattern(config, env, naming);
|
|
1288
1411
|
const match = allR2.find((b) => pattern(b.name));
|
|
1289
1412
|
if (match) {
|
|
1290
1413
|
const createdDate = r2ExtractDate(match.name, naming) ?? match.creation_date.slice(0, 10);
|
|
@@ -1321,7 +1444,7 @@ function r2Drift(allR2, resources, env, state, naming) {
|
|
|
1321
1444
|
const allState = state.getAll();
|
|
1322
1445
|
const r2State = Object.values(allState).filter((e) => e.type === "r2_bucket");
|
|
1323
1446
|
for (const config of resources) {
|
|
1324
|
-
const pattern =
|
|
1447
|
+
const pattern = r2MatchPattern(config, env, naming);
|
|
1325
1448
|
const cfMatch = allR2.find((b) => pattern(b.name));
|
|
1326
1449
|
const stateEntry = r2State.find((e) => e.logicalName === config.logicalName);
|
|
1327
1450
|
if (stateEntry && !cfNames.has(stateEntry.derivedName)) {
|
|
@@ -1399,7 +1522,7 @@ function r2Status(resources, env, state, naming) {
|
|
|
1399
1522
|
const entry = Object.values(allResources).find((e) => e.type === "r2_bucket" && e.logicalName === config.logicalName);
|
|
1400
1523
|
results.push({
|
|
1401
1524
|
binding: entry?.bindingKey ?? naming.r2BindingKey(config.logicalName),
|
|
1402
|
-
name: entry?.derivedName ??
|
|
1525
|
+
name: entry?.derivedName ?? r2DeriveName(config, env, naming),
|
|
1403
1526
|
status: entry ? "ok" : "missing"
|
|
1404
1527
|
});
|
|
1405
1528
|
}
|
|
@@ -1447,12 +1570,14 @@ const r2Module = {
|
|
|
1447
1570
|
console.warn(`Rollback: failed to delete R2 ${entry.derivedName}:`, err);
|
|
1448
1571
|
}
|
|
1449
1572
|
},
|
|
1450
|
-
async importOne({ options, env, api, state, naming, ts }) {
|
|
1573
|
+
async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
|
|
1451
1574
|
const bucketName = options.cfId;
|
|
1452
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`);
|
|
1453
1578
|
const hit = (await api.r2ListAll()).find((b) => b.name === bucketName);
|
|
1454
1579
|
if (!hit) throw new Error(`import r2: bucket "${bucketName}" not found in account`);
|
|
1455
|
-
if (!
|
|
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}"`);
|
|
1456
1581
|
const derivedName = hit.name;
|
|
1457
1582
|
const createdDate = options.createdDate ?? naming.extractR2Date(hit.name) ?? hit.creation_date.slice(0, 10);
|
|
1458
1583
|
const bindingKey = naming.r2BindingKey(options.logical);
|
|
@@ -1470,11 +1595,17 @@ const r2Module = {
|
|
|
1470
1595
|
}
|
|
1471
1596
|
};
|
|
1472
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
|
+
|
|
1473
1604
|
//#endregion
|
|
1474
1605
|
//#region src/features/kv/kv.apply.ts
|
|
1475
1606
|
async function kvApply(resources, tenant, env, api, state, naming) {
|
|
1476
1607
|
for (const config of resources) {
|
|
1477
|
-
const derivedName =
|
|
1608
|
+
const derivedName = kvDeriveName(config, env, naming);
|
|
1478
1609
|
if (state.get(derivedName)) continue;
|
|
1479
1610
|
const { id } = await api.kvCreate(derivedName);
|
|
1480
1611
|
state.set(derivedName, {
|
|
@@ -1493,7 +1624,7 @@ async function kvApply(resources, tenant, env, api, state, naming) {
|
|
|
1493
1624
|
//#region src/features/kv/kv.sync.ts
|
|
1494
1625
|
function kvSync(allKV, resources, tenant, env, state, naming) {
|
|
1495
1626
|
for (const config of resources) {
|
|
1496
|
-
const derivedName =
|
|
1627
|
+
const derivedName = kvDeriveName(config, env, naming);
|
|
1497
1628
|
const match = allKV.find((ns) => ns.title === derivedName);
|
|
1498
1629
|
if (match) state.set(derivedName, {
|
|
1499
1630
|
type: "kv_namespace",
|
|
@@ -1520,7 +1651,7 @@ function kvDrift(allKV, resources, env, state, naming) {
|
|
|
1520
1651
|
const allState = state.getAll();
|
|
1521
1652
|
const kvState = Object.values(allState).filter((e) => e.type === "kv_namespace");
|
|
1522
1653
|
for (const config of resources) {
|
|
1523
|
-
const derivedName =
|
|
1654
|
+
const derivedName = kvDeriveName(config, env, naming);
|
|
1524
1655
|
const cfId = cfByTitle.get(derivedName);
|
|
1525
1656
|
const stateEntry = kvState.find((e) => e.logicalName === config.logicalName);
|
|
1526
1657
|
if (stateEntry && !cfId) drift.missingFromCloudflare.push({
|
|
@@ -1563,7 +1694,7 @@ async function kvDestroy(_env, state, api, config, baseDir, _force) {
|
|
|
1563
1694
|
function kvGenerate(resources, env, state, naming) {
|
|
1564
1695
|
const bindings = [];
|
|
1565
1696
|
for (const config of resources) {
|
|
1566
|
-
const derivedName =
|
|
1697
|
+
const derivedName = kvDeriveName(config, env, naming);
|
|
1567
1698
|
const entry = state.get(derivedName);
|
|
1568
1699
|
if (!entry || entry.type !== "kv_namespace") throw new Error(`KV "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
|
|
1569
1700
|
bindings.push({
|
|
@@ -1579,7 +1710,7 @@ function kvGenerate(resources, env, state, naming) {
|
|
|
1579
1710
|
function kvStatus(resources, env, state, naming) {
|
|
1580
1711
|
const results = [];
|
|
1581
1712
|
for (const config of resources) {
|
|
1582
|
-
const derivedName =
|
|
1713
|
+
const derivedName = kvDeriveName(config, env, naming);
|
|
1583
1714
|
const entry = state.get(derivedName);
|
|
1584
1715
|
results.push({
|
|
1585
1716
|
binding: naming.kvBindingKey(config.logicalName),
|
|
@@ -1634,11 +1765,13 @@ const kvModule = {
|
|
|
1634
1765
|
console.warn(`Rollback: failed to delete KV ${entry.derivedName}:`, err);
|
|
1635
1766
|
}
|
|
1636
1767
|
},
|
|
1637
|
-
async importOne({ options, env, api, state, naming, ts }) {
|
|
1768
|
+
async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
|
|
1638
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`);
|
|
1639
1772
|
const hit = (await api.kvListAll()).find((k) => k.id === options.cfId);
|
|
1640
1773
|
if (!hit) throw new Error(`import kv: KV namespace id "${options.cfId}" not found in account`);
|
|
1641
|
-
const derivedName =
|
|
1774
|
+
const derivedName = kvDeriveName(resourceConfig, env, naming);
|
|
1642
1775
|
if (hit.title !== derivedName) throw new Error(`import kv: cf title "${hit.title}" does not match derived "${derivedName}"`);
|
|
1643
1776
|
const bindingKey = naming.kvBindingKey(options.logical);
|
|
1644
1777
|
const existing = state.get(derivedName);
|
|
@@ -1655,6 +1788,12 @@ const kvModule = {
|
|
|
1655
1788
|
}
|
|
1656
1789
|
};
|
|
1657
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
|
+
|
|
1658
1797
|
//#endregion
|
|
1659
1798
|
//#region src/features/queues/queues.apply.ts
|
|
1660
1799
|
const STATE_KEY_PREFIX$6 = "queue:";
|
|
@@ -1663,7 +1802,7 @@ function stateKey$6(derivedName) {
|
|
|
1663
1802
|
}
|
|
1664
1803
|
async function queuesApply(resources, _tenant, env, api, state, naming) {
|
|
1665
1804
|
for (const config of resources) {
|
|
1666
|
-
const derivedName =
|
|
1805
|
+
const derivedName = queueDeriveName(config, env, naming);
|
|
1667
1806
|
const key = stateKey$6(derivedName);
|
|
1668
1807
|
if (state.get(key)) continue;
|
|
1669
1808
|
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -1685,7 +1824,7 @@ async function queuesApply(resources, _tenant, env, api, state, naming) {
|
|
|
1685
1824
|
//#region src/features/queues/queues.sync.ts
|
|
1686
1825
|
function queuesSync(allQueues, resources, _tenant, env, state, naming) {
|
|
1687
1826
|
for (const config of resources) {
|
|
1688
|
-
const derivedName =
|
|
1827
|
+
const derivedName = queueDeriveName(config, env, naming);
|
|
1689
1828
|
const match = allQueues.find((q) => q.queue_name === derivedName);
|
|
1690
1829
|
if (!match) continue;
|
|
1691
1830
|
const key = `queue:${derivedName}`;
|
|
@@ -1716,7 +1855,7 @@ function queuesDrift(allQueues, resources, env, state, naming) {
|
|
|
1716
1855
|
const cfByName = new Map(allQueues.map((q) => [q.queue_name, q.queue_id]));
|
|
1717
1856
|
const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "queue");
|
|
1718
1857
|
for (const config of resources) {
|
|
1719
|
-
const derivedName =
|
|
1858
|
+
const derivedName = queueDeriveName(config, env, naming);
|
|
1720
1859
|
const cfId = cfByName.get(derivedName);
|
|
1721
1860
|
const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
|
|
1722
1861
|
if (stateEntry && !cfId) drift.missingFromCloudflare.push({
|
|
@@ -1765,7 +1904,7 @@ function queuesGenerate(resources, env, state, naming) {
|
|
|
1765
1904
|
const producers = [];
|
|
1766
1905
|
for (const config of resources) {
|
|
1767
1906
|
if (config.consumerOnly) continue;
|
|
1768
|
-
const derivedName =
|
|
1907
|
+
const derivedName = queueDeriveName(config, env, naming);
|
|
1769
1908
|
const entry = state.get(`queue:${derivedName}`);
|
|
1770
1909
|
if (!entry || entry.type !== "queue") throw new Error(`Queue "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
|
|
1771
1910
|
producers.push({
|
|
@@ -1782,7 +1921,7 @@ function queuesGenerate(resources, env, state, naming) {
|
|
|
1782
1921
|
function queuesStatus(resources, env, state, naming) {
|
|
1783
1922
|
const out = [];
|
|
1784
1923
|
for (const config of resources) {
|
|
1785
|
-
const derivedName =
|
|
1924
|
+
const derivedName = queueDeriveName(config, env, naming);
|
|
1786
1925
|
const entry = state.get(`queue:${derivedName}`);
|
|
1787
1926
|
out.push({
|
|
1788
1927
|
binding: config.binding?.trim() || naming.queueBindingKey(config.logicalName),
|
|
@@ -1845,11 +1984,13 @@ const queuesModule = {
|
|
|
1845
1984
|
console.warn(`Rollback: failed to delete queue ${entry.derivedName}:`, err);
|
|
1846
1985
|
}
|
|
1847
1986
|
},
|
|
1848
|
-
async importOne({ options, env, api, state, naming, ts }) {
|
|
1987
|
+
async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
|
|
1849
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`);
|
|
1850
1991
|
const hit = (await api.queuesListAll()).find((q) => q.queue_id === options.cfId);
|
|
1851
1992
|
if (!hit) throw new Error(`import queue: queue id "${options.cfId}" not found in account`);
|
|
1852
|
-
const derivedName =
|
|
1993
|
+
const derivedName = queueDeriveName(resourceConfig, env, naming);
|
|
1853
1994
|
if (hit.queue_name !== derivedName) throw new Error(`import queue: cf name "${hit.queue_name}" does not match derived "${derivedName}"`);
|
|
1854
1995
|
const bindingKey = naming.queueBindingKey(options.logical);
|
|
1855
1996
|
const key = `queue:${derivedName}`;
|
|
@@ -1897,13 +2038,19 @@ function resolveHyperdriveOrigin(config) {
|
|
|
1897
2038
|
};
|
|
1898
2039
|
}
|
|
1899
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
|
+
|
|
1900
2047
|
//#endregion
|
|
1901
2048
|
//#region src/features/hyperdrive/hyperdrive.diff.ts
|
|
1902
2049
|
function hyperdriveDiffPlanItems(args) {
|
|
1903
2050
|
const { resources, env, state, naming } = args;
|
|
1904
2051
|
const items = [];
|
|
1905
2052
|
for (const config of resources) {
|
|
1906
|
-
const derivedName =
|
|
2053
|
+
const derivedName = hyperdriveDeriveName(config, env, naming);
|
|
1907
2054
|
const entry = state.get(`hyperdrive:${derivedName}`);
|
|
1908
2055
|
if (!entry || entry.type !== "hyperdrive") continue;
|
|
1909
2056
|
const changes = computeChanges$1(entry, config);
|
|
@@ -1962,7 +2109,7 @@ function stateKey$5(derivedName) {
|
|
|
1962
2109
|
}
|
|
1963
2110
|
async function hyperdriveApply(resources, _tenant, env, api, state, naming) {
|
|
1964
2111
|
for (const config of resources) {
|
|
1965
|
-
const derivedName =
|
|
2112
|
+
const derivedName = hyperdriveDeriveName(config, env, naming);
|
|
1966
2113
|
const key = stateKey$5(derivedName);
|
|
1967
2114
|
const existing = state.get(key);
|
|
1968
2115
|
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -2020,7 +2167,7 @@ async function hyperdriveApply(resources, _tenant, env, api, state, naming) {
|
|
|
2020
2167
|
//#region src/features/hyperdrive/hyperdrive.sync.ts
|
|
2021
2168
|
function hyperdriveSync(allHyperdrive, resources, _tenant, env, state, naming) {
|
|
2022
2169
|
for (const config of resources) {
|
|
2023
|
-
const derivedName =
|
|
2170
|
+
const derivedName = hyperdriveDeriveName(config, env, naming);
|
|
2024
2171
|
const match = allHyperdrive.find((h) => h.name === derivedName);
|
|
2025
2172
|
if (!match) continue;
|
|
2026
2173
|
const key = `hyperdrive:${derivedName}`;
|
|
@@ -2053,7 +2200,7 @@ function hyperdriveDrift(allHyperdrive, resources, env, state, naming) {
|
|
|
2053
2200
|
const cfByName = new Map(allHyperdrive.map((h) => [h.name, h.id]));
|
|
2054
2201
|
const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "hyperdrive");
|
|
2055
2202
|
for (const config of resources) {
|
|
2056
|
-
const derivedName =
|
|
2203
|
+
const derivedName = hyperdriveDeriveName(config, env, naming);
|
|
2057
2204
|
const cfId = cfByName.get(derivedName);
|
|
2058
2205
|
const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
|
|
2059
2206
|
if (stateEntry && !cfId) drift.missingFromCloudflare.push({
|
|
@@ -2096,7 +2243,7 @@ async function hyperdriveDestroy(_env, state, api, config, baseDir, _force) {
|
|
|
2096
2243
|
function hyperdriveGenerate(resources, env, state, naming) {
|
|
2097
2244
|
const out = [];
|
|
2098
2245
|
for (const config of resources) {
|
|
2099
|
-
const derivedName =
|
|
2246
|
+
const derivedName = hyperdriveDeriveName(config, env, naming);
|
|
2100
2247
|
const entry = state.get(`hyperdrive:${derivedName}`);
|
|
2101
2248
|
if (!entry || entry.type !== "hyperdrive") throw new Error(`Hyperdrive "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
|
|
2102
2249
|
out.push({
|
|
@@ -2113,7 +2260,7 @@ function hyperdriveGenerate(resources, env, state, naming) {
|
|
|
2113
2260
|
function hyperdriveStatus(resources, env, state, naming) {
|
|
2114
2261
|
const out = [];
|
|
2115
2262
|
for (const config of resources) {
|
|
2116
|
-
const derivedName =
|
|
2263
|
+
const derivedName = hyperdriveDeriveName(config, env, naming);
|
|
2117
2264
|
const entry = state.get(`hyperdrive:${derivedName}`);
|
|
2118
2265
|
out.push({
|
|
2119
2266
|
binding: config.binding?.trim() || naming.hyperdriveBindingKey(config.logicalName),
|
|
@@ -2179,11 +2326,13 @@ const hyperdriveModule = {
|
|
|
2179
2326
|
console.warn(`Rollback: failed to delete Hyperdrive ${entry.derivedName}:`, err);
|
|
2180
2327
|
}
|
|
2181
2328
|
},
|
|
2182
|
-
async importOne({ options, env, api, state, naming, ts }) {
|
|
2329
|
+
async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
|
|
2183
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`);
|
|
2184
2333
|
const hit = (await api.hyperdriveListAll()).find((h) => h.id === options.cfId);
|
|
2185
2334
|
if (!hit) throw new Error(`import hyperdrive: config id "${options.cfId}" not found in account`);
|
|
2186
|
-
const derivedName =
|
|
2335
|
+
const derivedName = hyperdriveDeriveName(resourceConfig, env, naming);
|
|
2187
2336
|
if (hit.name !== derivedName) throw new Error(`import hyperdrive: cf name "${hit.name}" does not match derived "${derivedName}"`);
|
|
2188
2337
|
const bindingKey = naming.hyperdriveBindingKey(options.logical);
|
|
2189
2338
|
const key = `hyperdrive:${derivedName}`;
|
|
@@ -2205,6 +2354,12 @@ const hyperdriveModule = {
|
|
|
2205
2354
|
}
|
|
2206
2355
|
};
|
|
2207
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
|
+
|
|
2208
2363
|
//#endregion
|
|
2209
2364
|
//#region src/features/vectorize/vectorize.apply.ts
|
|
2210
2365
|
const STATE_KEY_PREFIX$4 = "vectorize:";
|
|
@@ -2213,7 +2368,7 @@ function stateKey$4(derivedName) {
|
|
|
2213
2368
|
}
|
|
2214
2369
|
async function vectorizeApply(resources, _tenant, env, api, state, naming) {
|
|
2215
2370
|
for (const config of resources) {
|
|
2216
|
-
const derivedName =
|
|
2371
|
+
const derivedName = vectorizeDeriveName(config, env, naming);
|
|
2217
2372
|
const key = stateKey$4(derivedName);
|
|
2218
2373
|
const existing = state.get(key);
|
|
2219
2374
|
if (existing) {
|
|
@@ -2249,7 +2404,7 @@ async function vectorizeApply(resources, _tenant, env, api, state, naming) {
|
|
|
2249
2404
|
//#region src/features/vectorize/vectorize.sync.ts
|
|
2250
2405
|
function vectorizeSync(allIndexes, resources, _tenant, env, state, naming) {
|
|
2251
2406
|
for (const config of resources) {
|
|
2252
|
-
const derivedName =
|
|
2407
|
+
const derivedName = vectorizeDeriveName(config, env, naming);
|
|
2253
2408
|
const match = allIndexes.find((i) => i.name === derivedName);
|
|
2254
2409
|
if (!match) continue;
|
|
2255
2410
|
const key = `vectorize:${derivedName}`;
|
|
@@ -2281,7 +2436,7 @@ function vectorizeDrift(allIndexes, resources, env, state, naming) {
|
|
|
2281
2436
|
const cfByName = new Map(allIndexes.map((i) => [i.name, i.id ?? i.name]));
|
|
2282
2437
|
const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "vectorize");
|
|
2283
2438
|
for (const config of resources) {
|
|
2284
|
-
const derivedName =
|
|
2439
|
+
const derivedName = vectorizeDeriveName(config, env, naming);
|
|
2285
2440
|
const cfId = cfByName.get(derivedName);
|
|
2286
2441
|
const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
|
|
2287
2442
|
if (stateEntry && !cfId) drift.missingFromCloudflare.push({
|
|
@@ -2329,7 +2484,7 @@ async function vectorizeDestroy(_env, state, api, config, baseDir, _force) {
|
|
|
2329
2484
|
function vectorizeGenerate(resources, env, state, naming) {
|
|
2330
2485
|
const out = [];
|
|
2331
2486
|
for (const config of resources) {
|
|
2332
|
-
const derivedName =
|
|
2487
|
+
const derivedName = vectorizeDeriveName(config, env, naming);
|
|
2333
2488
|
const entry = state.get(`vectorize:${derivedName}`);
|
|
2334
2489
|
if (!entry || entry.type !== "vectorize") throw new Error(`Vectorize index "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
|
|
2335
2490
|
out.push({
|
|
@@ -2345,7 +2500,7 @@ function vectorizeGenerate(resources, env, state, naming) {
|
|
|
2345
2500
|
function vectorizeStatus(resources, env, state, naming) {
|
|
2346
2501
|
const out = [];
|
|
2347
2502
|
for (const config of resources) {
|
|
2348
|
-
const derivedName =
|
|
2503
|
+
const derivedName = vectorizeDeriveName(config, env, naming);
|
|
2349
2504
|
const entry = state.get(`vectorize:${derivedName}`);
|
|
2350
2505
|
out.push({
|
|
2351
2506
|
binding: config.binding?.trim() || naming.vectorizeBindingKey(config.logicalName),
|
|
@@ -2362,7 +2517,7 @@ function vectorizeDiffPlanItems(args) {
|
|
|
2362
2517
|
const { resources, env, state, naming } = args;
|
|
2363
2518
|
const items = [];
|
|
2364
2519
|
for (const config of resources) {
|
|
2365
|
-
const derivedName =
|
|
2520
|
+
const derivedName = vectorizeDeriveName(config, env, naming);
|
|
2366
2521
|
const key = `vectorize:${derivedName}`;
|
|
2367
2522
|
const entry = state.get(key);
|
|
2368
2523
|
if (!entry || entry.type !== "vectorize") continue;
|
|
@@ -2448,12 +2603,14 @@ const vectorizeModule = {
|
|
|
2448
2603
|
console.warn(`Rollback: failed to delete Vectorize ${entry.derivedName}:`, err);
|
|
2449
2604
|
}
|
|
2450
2605
|
},
|
|
2451
|
-
async importOne({ options, env, api, state, naming, ts }) {
|
|
2606
|
+
async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
|
|
2452
2607
|
const indexName = options.cfId;
|
|
2453
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`);
|
|
2454
2611
|
const hit = (await api.vectorizeListAll()).find((v) => v.name === indexName);
|
|
2455
2612
|
if (!hit) throw new Error(`import vectorize: index "${indexName}" not found in account`);
|
|
2456
|
-
const derivedName =
|
|
2613
|
+
const derivedName = vectorizeDeriveName(resourceConfig, env, naming);
|
|
2457
2614
|
if (hit.name !== derivedName) throw new Error(`import vectorize: cf name "${hit.name}" does not match derived "${derivedName}"`);
|
|
2458
2615
|
if (!hit.config) throw new Error(`import vectorize: cf index "${hit.name}" returned no config (dimensions/metric)`);
|
|
2459
2616
|
const metric = hit.config.metric;
|
|
@@ -2503,13 +2660,19 @@ function resolveAIGatewayConfig(config) {
|
|
|
2503
2660
|
};
|
|
2504
2661
|
}
|
|
2505
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
|
+
|
|
2506
2669
|
//#endregion
|
|
2507
2670
|
//#region src/features/ai-gateway/ai-gateway.diff.ts
|
|
2508
2671
|
function aiGatewayDiffPlanItems(args) {
|
|
2509
2672
|
const { resources, env, state, naming } = args;
|
|
2510
2673
|
const items = [];
|
|
2511
2674
|
for (const config of resources) {
|
|
2512
|
-
const derivedName =
|
|
2675
|
+
const derivedName = aiGatewayDeriveName(config, env, naming);
|
|
2513
2676
|
const entry = state.get(`ai_gateway:${derivedName}`);
|
|
2514
2677
|
if (!entry || entry.type !== "ai_gateway") continue;
|
|
2515
2678
|
const changes = computeChanges(entry, config);
|
|
@@ -2593,7 +2756,7 @@ function stateKey$3(derivedName) {
|
|
|
2593
2756
|
}
|
|
2594
2757
|
async function aiGatewayApply(resources, _tenant, env, api, state, naming) {
|
|
2595
2758
|
for (const config of resources) {
|
|
2596
|
-
const derivedName =
|
|
2759
|
+
const derivedName = aiGatewayDeriveName(config, env, naming);
|
|
2597
2760
|
const key = stateKey$3(derivedName);
|
|
2598
2761
|
const existing = state.get(key);
|
|
2599
2762
|
const resolved = resolveAIGatewayConfig(config);
|
|
@@ -2669,7 +2832,7 @@ async function aiGatewayApply(resources, _tenant, env, api, state, naming) {
|
|
|
2669
2832
|
//#region src/features/ai-gateway/ai-gateway.sync.ts
|
|
2670
2833
|
function aiGatewaySync(allGateways, resources, _tenant, env, state, naming) {
|
|
2671
2834
|
for (const config of resources) {
|
|
2672
|
-
const derivedName =
|
|
2835
|
+
const derivedName = aiGatewayDeriveName(config, env, naming);
|
|
2673
2836
|
const match = allGateways.find((g) => g.id === derivedName);
|
|
2674
2837
|
if (!match) continue;
|
|
2675
2838
|
const key = `ai_gateway:${derivedName}`;
|
|
@@ -2707,7 +2870,7 @@ function aiGatewayDrift(allGateways, resources, env, state, naming) {
|
|
|
2707
2870
|
const cfIds = new Set(allGateways.map((g) => g.id));
|
|
2708
2871
|
const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "ai_gateway");
|
|
2709
2872
|
for (const config of resources) {
|
|
2710
|
-
const derivedName =
|
|
2873
|
+
const derivedName = aiGatewayDeriveName(config, env, naming);
|
|
2711
2874
|
const inCloudflare = cfIds.has(derivedName);
|
|
2712
2875
|
const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
|
|
2713
2876
|
if (stateEntry && !inCloudflare) drift.missingFromCloudflare.push({
|
|
@@ -2750,7 +2913,7 @@ async function aiGatewayDestroy(_env, state, api, config, baseDir, _force) {
|
|
|
2750
2913
|
function aiGatewayStatus(resources, env, state, naming) {
|
|
2751
2914
|
const out = [];
|
|
2752
2915
|
for (const config of resources) {
|
|
2753
|
-
const derivedName =
|
|
2916
|
+
const derivedName = aiGatewayDeriveName(config, env, naming);
|
|
2754
2917
|
const entry = state.get(`ai_gateway:${derivedName}`);
|
|
2755
2918
|
out.push({
|
|
2756
2919
|
binding: naming.aiGatewayBindingKey(config.logicalName),
|
|
@@ -2809,12 +2972,14 @@ const aiGatewayModule = {
|
|
|
2809
2972
|
console.warn(`Rollback: failed to delete AI Gateway ${entry.derivedName}:`, err);
|
|
2810
2973
|
}
|
|
2811
2974
|
},
|
|
2812
|
-
async importOne({ options, env, api, state, naming, ts }) {
|
|
2975
|
+
async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
|
|
2813
2976
|
const gatewayId = options.cfId;
|
|
2814
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`);
|
|
2815
2980
|
const hit = (await api.aiGatewayListAll()).find((g) => g.id === gatewayId);
|
|
2816
2981
|
if (!hit) throw new Error(`import ai_gateway: gateway "${gatewayId}" not found in account`);
|
|
2817
|
-
const derivedName =
|
|
2982
|
+
const derivedName = aiGatewayDeriveName(resourceConfig, env, naming);
|
|
2818
2983
|
if (hit.id !== derivedName) throw new Error(`import ai_gateway: cf id "${hit.id}" does not match derived "${derivedName}"`);
|
|
2819
2984
|
const key = `ai_gateway:${derivedName}`;
|
|
2820
2985
|
const existing = state.get(key);
|
|
@@ -2839,6 +3004,12 @@ const aiGatewayModule = {
|
|
|
2839
3004
|
}
|
|
2840
3005
|
};
|
|
2841
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
|
+
|
|
2842
3013
|
//#endregion
|
|
2843
3014
|
//#region src/features/pipelines/pipelines.apply.ts
|
|
2844
3015
|
const STATE_KEY_PREFIX$2 = "pipeline:";
|
|
@@ -2853,7 +3024,7 @@ function stateKey$2(derivedName) {
|
|
|
2853
3024
|
*/
|
|
2854
3025
|
async function pipelinesApply(resources, _tenant, env, api, state, naming) {
|
|
2855
3026
|
for (const config of resources) {
|
|
2856
|
-
const derivedName =
|
|
3027
|
+
const derivedName = pipelineDeriveName(config, env, naming);
|
|
2857
3028
|
const key = stateKey$2(derivedName);
|
|
2858
3029
|
if (state.get(key)) continue;
|
|
2859
3030
|
const ts = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -2879,7 +3050,7 @@ async function pipelinesApply(resources, _tenant, env, api, state, naming) {
|
|
|
2879
3050
|
//#region src/features/pipelines/pipelines.sync.ts
|
|
2880
3051
|
function pipelinesSync(allPipelines, resources, _tenant, env, state, naming) {
|
|
2881
3052
|
for (const config of resources) {
|
|
2882
|
-
const derivedName =
|
|
3053
|
+
const derivedName = pipelineDeriveName(config, env, naming);
|
|
2883
3054
|
const match = allPipelines.find((p) => p.name === derivedName);
|
|
2884
3055
|
if (!match) continue;
|
|
2885
3056
|
const key = `pipeline:${derivedName}`;
|
|
@@ -2911,7 +3082,7 @@ function pipelinesDrift(allPipelines, resources, env, state, naming) {
|
|
|
2911
3082
|
const cfByName = new Map(allPipelines.map((p) => [p.name, p]));
|
|
2912
3083
|
const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "pipeline");
|
|
2913
3084
|
for (const config of resources) {
|
|
2914
|
-
const derivedName =
|
|
3085
|
+
const derivedName = pipelineDeriveName(config, env, naming);
|
|
2915
3086
|
const inCloudflare = cfByName.has(derivedName);
|
|
2916
3087
|
const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
|
|
2917
3088
|
if (stateEntry && !inCloudflare) drift.missingFromCloudflare.push({
|
|
@@ -2964,7 +3135,7 @@ async function pipelinesDestroy(_env, state, api, config, baseDir, _force) {
|
|
|
2964
3135
|
function pipelinesGenerate(resources, env, state, naming) {
|
|
2965
3136
|
const out = [];
|
|
2966
3137
|
for (const config of resources) {
|
|
2967
|
-
const derivedName =
|
|
3138
|
+
const derivedName = pipelineDeriveName(config, env, naming);
|
|
2968
3139
|
const entry = state.get(`pipeline:${derivedName}`);
|
|
2969
3140
|
if (!entry || entry.type !== "pipeline") throw new Error(`Pipeline "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
|
|
2970
3141
|
out.push({
|
|
@@ -2980,7 +3151,7 @@ function pipelinesGenerate(resources, env, state, naming) {
|
|
|
2980
3151
|
function pipelinesStatus(resources, env, state, naming) {
|
|
2981
3152
|
const out = [];
|
|
2982
3153
|
for (const config of resources) {
|
|
2983
|
-
const derivedName =
|
|
3154
|
+
const derivedName = pipelineDeriveName(config, env, naming);
|
|
2984
3155
|
const entry = state.get(`pipeline:${derivedName}`);
|
|
2985
3156
|
out.push({
|
|
2986
3157
|
binding: config.binding?.trim() || naming.pipelineBindingKey(config.logicalName),
|
|
@@ -2997,7 +3168,7 @@ function pipelinesDiffPlanItems(args) {
|
|
|
2997
3168
|
const { resources, env, state, naming } = args;
|
|
2998
3169
|
const items = [];
|
|
2999
3170
|
for (const config of resources) {
|
|
3000
|
-
const derivedName =
|
|
3171
|
+
const derivedName = pipelineDeriveName(config, env, naming);
|
|
3001
3172
|
const key = `pipeline:${derivedName}`;
|
|
3002
3173
|
const entry = state.get(key);
|
|
3003
3174
|
if (!entry || entry.type !== "pipeline") continue;
|
|
@@ -3089,12 +3260,14 @@ const pipelinesModule = {
|
|
|
3089
3260
|
console.warn(`Rollback: failed to delete Pipeline ${entry.derivedName}:`, err);
|
|
3090
3261
|
}
|
|
3091
3262
|
},
|
|
3092
|
-
async importOne({ options, env, api, state, naming, ts }) {
|
|
3263
|
+
async importOne({ options, env, api, state, naming, config, baseDir, ts }) {
|
|
3093
3264
|
const pipelineId = options.cfId;
|
|
3094
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`);
|
|
3095
3268
|
const hit = (await api.pipelineListAll()).find((p) => p.id === pipelineId);
|
|
3096
3269
|
if (!hit) throw new Error(`import pipeline: pipeline "${pipelineId}" not found in account`);
|
|
3097
|
-
const derivedName =
|
|
3270
|
+
const derivedName = pipelineDeriveName(resourceConfig, env, naming);
|
|
3098
3271
|
if (hit.name !== derivedName) throw new Error(`import pipeline: cf name "${hit.name}" does not match derived "${derivedName}"`);
|
|
3099
3272
|
const key = `pipeline:${derivedName}`;
|
|
3100
3273
|
const existing = state.get(key);
|
|
@@ -3113,13 +3286,23 @@ const pipelinesModule = {
|
|
|
3113
3286
|
}
|
|
3114
3287
|
};
|
|
3115
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
|
+
|
|
3116
3299
|
//#endregion
|
|
3117
3300
|
//#region src/features/workflows/workflows.diff.ts
|
|
3118
3301
|
function workflowsDiffPlanItems(args) {
|
|
3119
3302
|
const { resources, env, state, naming, worker } = args;
|
|
3120
3303
|
const items = [];
|
|
3121
3304
|
for (const config of resources) {
|
|
3122
|
-
const derivedName =
|
|
3305
|
+
const derivedName = workflowDeriveName(config, env, naming);
|
|
3123
3306
|
const key = `workflow:${derivedName}`;
|
|
3124
3307
|
const entry = state.get(key);
|
|
3125
3308
|
if (!entry || entry.type !== "workflow") continue;
|
|
@@ -3206,7 +3389,7 @@ function limitsEqual(a, b) {
|
|
|
3206
3389
|
*/
|
|
3207
3390
|
async function workflowsApply(resources, _tenant, env, api, state, naming, worker) {
|
|
3208
3391
|
for (const config of resources) {
|
|
3209
|
-
const derivedName =
|
|
3392
|
+
const derivedName = workflowDeriveName(config, env, naming);
|
|
3210
3393
|
const scriptName = resolveScriptName(config, worker);
|
|
3211
3394
|
const key = stateKey$1(derivedName);
|
|
3212
3395
|
const existing = state.get(key);
|
|
@@ -3259,8 +3442,9 @@ async function workflowsApply(resources, _tenant, env, api, state, naming, worke
|
|
|
3259
3442
|
*/
|
|
3260
3443
|
function workflowsSync(allWorkflows, resources, _tenant, env, state, naming) {
|
|
3261
3444
|
for (const config of resources) {
|
|
3262
|
-
const derivedName =
|
|
3263
|
-
const
|
|
3445
|
+
const derivedName = workflowDeriveName(config, env, naming);
|
|
3446
|
+
const pattern = workflowMatchPattern(config, env, naming);
|
|
3447
|
+
const match = allWorkflows.find((w) => pattern(w.name));
|
|
3264
3448
|
if (!match) continue;
|
|
3265
3449
|
const key = `workflow:${derivedName}`;
|
|
3266
3450
|
const existing = state.get(key);
|
|
@@ -3293,7 +3477,7 @@ function workflowsDrift(allWorkflows, resources, env, state, naming) {
|
|
|
3293
3477
|
const cfByName = new Map(allWorkflows.map((w) => [w.name, w]));
|
|
3294
3478
|
const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "workflow");
|
|
3295
3479
|
for (const config of resources) {
|
|
3296
|
-
const derivedName =
|
|
3480
|
+
const derivedName = workflowDeriveName(config, env, naming);
|
|
3297
3481
|
const inCloudflare = cfByName.has(derivedName);
|
|
3298
3482
|
const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
|
|
3299
3483
|
if (stateEntry && !inCloudflare) drift.missingFromCloudflare.push({
|
|
@@ -3347,7 +3531,7 @@ async function workflowsDestroy(_env, state, api, config, baseDir, _force) {
|
|
|
3347
3531
|
function workflowsGenerate(resources, env, state, naming, worker) {
|
|
3348
3532
|
const out = [];
|
|
3349
3533
|
for (const config of resources) {
|
|
3350
|
-
const derivedName =
|
|
3534
|
+
const derivedName = workflowDeriveName(config, env, naming);
|
|
3351
3535
|
const entry = state.get(`workflow:${derivedName}`);
|
|
3352
3536
|
if (!entry || entry.type !== "workflow") throw new Error(`Workflow "${config.logicalName}" not in state. Run 'tamer apply --env ${env}' first.`);
|
|
3353
3537
|
const explicitScript = config.scriptName?.trim();
|
|
@@ -3369,7 +3553,7 @@ function workflowsGenerate(resources, env, state, naming, worker) {
|
|
|
3369
3553
|
function workflowsStatus(resources, env, state, naming) {
|
|
3370
3554
|
const out = [];
|
|
3371
3555
|
for (const config of resources) {
|
|
3372
|
-
const derivedName =
|
|
3556
|
+
const derivedName = workflowDeriveName(config, env, naming);
|
|
3373
3557
|
const entry = state.get(`workflow:${derivedName}`);
|
|
3374
3558
|
out.push({
|
|
3375
3559
|
binding: config.binding?.trim() || naming.workflowBindingKey(config.logicalName),
|
|
@@ -3437,10 +3621,11 @@ const workflowsModule = {
|
|
|
3437
3621
|
console.warn(`Rollback: failed to delete Workflow ${entry.derivedName}:`, err);
|
|
3438
3622
|
}
|
|
3439
3623
|
},
|
|
3440
|
-
async importOne({ options, env, api, state, naming, ts }) {
|
|
3441
|
-
const
|
|
3442
|
-
|
|
3443
|
-
const
|
|
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);
|
|
3444
3629
|
if (!hit) throw new Error(`import workflow: no workflow named "${derivedName}" found in account`);
|
|
3445
3630
|
if (options.cfId && hit.id !== options.cfId) throw new Error(`import workflow: cf id "${hit.id}" does not match --cf-id "${options.cfId}"`);
|
|
3446
3631
|
const key = `workflow:${derivedName}`;
|
|
@@ -3461,6 +3646,12 @@ const workflowsModule = {
|
|
|
3461
3646
|
}
|
|
3462
3647
|
};
|
|
3463
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
|
+
|
|
3464
3655
|
//#endregion
|
|
3465
3656
|
//#region src/features/secrets-store/secrets-store.apply.ts
|
|
3466
3657
|
const STATE_KEY_PREFIX = "secrets_store:";
|
|
@@ -3479,7 +3670,7 @@ async function secretsStoreApply(resources, _tenant, env, api, state, naming) {
|
|
|
3479
3670
|
if (resources.length === 0) return;
|
|
3480
3671
|
let allStores = null;
|
|
3481
3672
|
for (const config of resources) {
|
|
3482
|
-
const derivedName =
|
|
3673
|
+
const derivedName = secretsStoreDeriveName(config, env, naming);
|
|
3483
3674
|
const key = stateKey(derivedName);
|
|
3484
3675
|
const existing = state.get(key);
|
|
3485
3676
|
const wantsBindingKey = naming.secretsStoreBindingKey(config.logicalName);
|
|
@@ -3513,7 +3704,7 @@ async function secretsStoreApply(resources, _tenant, env, api, state, naming) {
|
|
|
3513
3704
|
*/
|
|
3514
3705
|
function secretsStoreSync(allStores, resources, _tenant, env, state, naming) {
|
|
3515
3706
|
for (const config of resources) {
|
|
3516
|
-
const derivedName =
|
|
3707
|
+
const derivedName = secretsStoreDeriveName(config, env, naming);
|
|
3517
3708
|
const match = allStores.find((s) => s.name === derivedName);
|
|
3518
3709
|
if (!match) continue;
|
|
3519
3710
|
const key = `secrets_store:${derivedName}`;
|
|
@@ -3544,7 +3735,7 @@ function secretsStoreDrift(allStores, resources, env, state, naming) {
|
|
|
3544
3735
|
const cfByName = new Map(allStores.map((s) => [s.name, s]));
|
|
3545
3736
|
const stateEntries = Object.values(state.getAll()).filter((e) => e.type === "secrets_store");
|
|
3546
3737
|
for (const config of resources) {
|
|
3547
|
-
const derivedName =
|
|
3738
|
+
const derivedName = secretsStoreDeriveName(config, env, naming);
|
|
3548
3739
|
const inCloudflare = cfByName.has(derivedName);
|
|
3549
3740
|
const stateEntry = stateEntries.find((e) => e.logicalName === config.logicalName);
|
|
3550
3741
|
if (stateEntry && !inCloudflare) drift.missingFromCloudflare.push({
|
|
@@ -3589,7 +3780,7 @@ async function secretsStoreDestroy(_env, state, api, config, baseDir, _force) {
|
|
|
3589
3780
|
function secretsStoreStatus(resources, env, state, naming) {
|
|
3590
3781
|
const out = [];
|
|
3591
3782
|
for (const config of resources) {
|
|
3592
|
-
const derivedName =
|
|
3783
|
+
const derivedName = secretsStoreDeriveName(config, env, naming);
|
|
3593
3784
|
const entry = state.get(`secrets_store:${derivedName}`);
|
|
3594
3785
|
out.push({
|
|
3595
3786
|
binding: naming.secretsStoreBindingKey(config.logicalName),
|
|
@@ -3644,9 +3835,11 @@ const secretsStoreModule = {
|
|
|
3644
3835
|
console.warn(`Rollback: failed to delete Secrets Store ${entry.derivedName}:`, err);
|
|
3645
3836
|
}
|
|
3646
3837
|
},
|
|
3647
|
-
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`);
|
|
3648
3841
|
const all = await api.secretsStoreListAll();
|
|
3649
|
-
const derivedName =
|
|
3842
|
+
const derivedName = secretsStoreDeriveName(resourceConfig, env, naming);
|
|
3650
3843
|
const hit = all.find((s) => s.name === derivedName);
|
|
3651
3844
|
if (!hit) throw new Error(`import secret_store: no store named "${derivedName}" found in account`);
|
|
3652
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}"`);
|
|
@@ -3813,5 +4006,5 @@ async function fetchStackImports(api, config, env) {
|
|
|
3813
4006
|
}
|
|
3814
4007
|
|
|
3815
4008
|
//#endregion
|
|
3816
|
-
export {
|
|
3817
|
-
//# sourceMappingURL=fetchStackImports-
|
|
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
|