@lace-cloud/proto 0.21.1 → 0.22.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/dist/index.cjs CHANGED
@@ -2931,7 +2931,7 @@ var ModuleReference = {
2931
2931
  }
2932
2932
  };
2933
2933
  function createBaseTerraformBlock() {
2934
- return { required_version: "", required_providers: {}, backend: void 0 };
2934
+ return { required_version: "", required_providers: {} };
2935
2935
  }
2936
2936
  var TerraformBlock = {
2937
2937
  encode(message, writer = new import_wire2.BinaryWriter()) {
@@ -2941,9 +2941,6 @@ var TerraformBlock = {
2941
2941
  globalThis.Object.entries(message.required_providers).forEach(([key, value]) => {
2942
2942
  TerraformBlock_RequiredProvidersEntry.encode({ key, value }, writer.uint32(18).fork()).join();
2943
2943
  });
2944
- if (message.backend !== void 0) {
2945
- BackendConfig.encode(message.backend, writer.uint32(26).fork()).join();
2946
- }
2947
2944
  return writer;
2948
2945
  },
2949
2946
  decode(input, length) {
@@ -2970,13 +2967,6 @@ var TerraformBlock = {
2970
2967
  }
2971
2968
  continue;
2972
2969
  }
2973
- case 3: {
2974
- if (tag !== 26) {
2975
- break;
2976
- }
2977
- message.backend = BackendConfig.decode(reader, reader.uint32());
2978
- continue;
2979
- }
2980
2970
  }
2981
2971
  if ((tag & 7) === 4 || tag === 0) {
2982
2972
  break;
@@ -3000,8 +2990,7 @@ var TerraformBlock = {
3000
2990
  return acc;
3001
2991
  },
3002
2992
  {}
3003
- ) : {},
3004
- backend: isSet2(object.backend) ? BackendConfig.fromJSON(object.backend) : void 0
2993
+ ) : {}
3005
2994
  };
3006
2995
  },
3007
2996
  toJSON(message) {
@@ -3018,9 +3007,6 @@ var TerraformBlock = {
3018
3007
  });
3019
3008
  }
3020
3009
  }
3021
- if (message.backend !== void 0) {
3022
- obj.backend = BackendConfig.toJSON(message.backend);
3023
- }
3024
3010
  return obj;
3025
3011
  },
3026
3012
  create(base) {
@@ -3038,7 +3024,6 @@ var TerraformBlock = {
3038
3024
  },
3039
3025
  {}
3040
3026
  );
3041
- message.backend = object.backend !== void 0 && object.backend !== null ? BackendConfig.fromPartial(object.backend) : void 0;
3042
3027
  return message;
3043
3028
  }
3044
3029
  };
@@ -3193,167 +3178,6 @@ var ProviderRequirement = {
3193
3178
  return message;
3194
3179
  }
3195
3180
  };
3196
- function createBaseBackendConfig() {
3197
- return { type: "", config: {} };
3198
- }
3199
- var BackendConfig = {
3200
- encode(message, writer = new import_wire2.BinaryWriter()) {
3201
- if (message.type !== "") {
3202
- writer.uint32(10).string(message.type);
3203
- }
3204
- globalThis.Object.entries(message.config).forEach(([key, value]) => {
3205
- if (value !== void 0) {
3206
- BackendConfig_ConfigEntry.encode({ key, value }, writer.uint32(18).fork()).join();
3207
- }
3208
- });
3209
- return writer;
3210
- },
3211
- decode(input, length) {
3212
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
3213
- const end = length === void 0 ? reader.len : reader.pos + length;
3214
- const message = createBaseBackendConfig();
3215
- while (reader.pos < end) {
3216
- const tag = reader.uint32();
3217
- switch (tag >>> 3) {
3218
- case 1: {
3219
- if (tag !== 10) {
3220
- break;
3221
- }
3222
- message.type = reader.string();
3223
- continue;
3224
- }
3225
- case 2: {
3226
- if (tag !== 18) {
3227
- break;
3228
- }
3229
- const entry2 = BackendConfig_ConfigEntry.decode(reader, reader.uint32());
3230
- if (entry2.value !== void 0) {
3231
- message.config[entry2.key] = entry2.value;
3232
- }
3233
- continue;
3234
- }
3235
- }
3236
- if ((tag & 7) === 4 || tag === 0) {
3237
- break;
3238
- }
3239
- reader.skip(tag & 7);
3240
- }
3241
- return message;
3242
- },
3243
- fromJSON(object) {
3244
- return {
3245
- type: isSet2(object.type) ? globalThis.String(object.type) : "",
3246
- config: isObject2(object.config) ? globalThis.Object.entries(object.config).reduce(
3247
- (acc, [key, value]) => {
3248
- acc[key] = value;
3249
- return acc;
3250
- },
3251
- {}
3252
- ) : {}
3253
- };
3254
- },
3255
- toJSON(message) {
3256
- const obj = {};
3257
- if (message.type !== "") {
3258
- obj.type = message.type;
3259
- }
3260
- if (message.config) {
3261
- const entries = globalThis.Object.entries(message.config);
3262
- if (entries.length > 0) {
3263
- obj.config = {};
3264
- entries.forEach(([k, v]) => {
3265
- obj.config[k] = v;
3266
- });
3267
- }
3268
- }
3269
- return obj;
3270
- },
3271
- create(base) {
3272
- return BackendConfig.fromPartial(base ?? {});
3273
- },
3274
- fromPartial(object) {
3275
- const message = createBaseBackendConfig();
3276
- message.type = object.type ?? "";
3277
- message.config = globalThis.Object.entries(object.config ?? {}).reduce(
3278
- (acc, [key, value]) => {
3279
- if (value !== void 0) {
3280
- acc[key] = value;
3281
- }
3282
- return acc;
3283
- },
3284
- {}
3285
- );
3286
- return message;
3287
- }
3288
- };
3289
- function createBaseBackendConfig_ConfigEntry() {
3290
- return { key: "", value: void 0 };
3291
- }
3292
- var BackendConfig_ConfigEntry = {
3293
- encode(message, writer = new import_wire2.BinaryWriter()) {
3294
- if (message.key !== "") {
3295
- writer.uint32(10).string(message.key);
3296
- }
3297
- if (message.value !== void 0) {
3298
- Value.encode(Value.wrap(message.value), writer.uint32(18).fork()).join();
3299
- }
3300
- return writer;
3301
- },
3302
- decode(input, length) {
3303
- const reader = input instanceof import_wire2.BinaryReader ? input : new import_wire2.BinaryReader(input);
3304
- const end = length === void 0 ? reader.len : reader.pos + length;
3305
- const message = createBaseBackendConfig_ConfigEntry();
3306
- while (reader.pos < end) {
3307
- const tag = reader.uint32();
3308
- switch (tag >>> 3) {
3309
- case 1: {
3310
- if (tag !== 10) {
3311
- break;
3312
- }
3313
- message.key = reader.string();
3314
- continue;
3315
- }
3316
- case 2: {
3317
- if (tag !== 18) {
3318
- break;
3319
- }
3320
- message.value = Value.unwrap(Value.decode(reader, reader.uint32()));
3321
- continue;
3322
- }
3323
- }
3324
- if ((tag & 7) === 4 || tag === 0) {
3325
- break;
3326
- }
3327
- reader.skip(tag & 7);
3328
- }
3329
- return message;
3330
- },
3331
- fromJSON(object) {
3332
- return {
3333
- key: isSet2(object.key) ? globalThis.String(object.key) : "",
3334
- value: isSet2(object?.value) ? object.value : void 0
3335
- };
3336
- },
3337
- toJSON(message) {
3338
- const obj = {};
3339
- if (message.key !== "") {
3340
- obj.key = message.key;
3341
- }
3342
- if (message.value !== void 0) {
3343
- obj.value = message.value;
3344
- }
3345
- return obj;
3346
- },
3347
- create(base) {
3348
- return BackendConfig_ConfigEntry.fromPartial(base ?? {});
3349
- },
3350
- fromPartial(object) {
3351
- const message = createBaseBackendConfig_ConfigEntry();
3352
- message.key = object.key ?? "";
3353
- message.value = object.value ?? void 0;
3354
- return message;
3355
- }
3356
- };
3357
3181
  function createBaseProviderConfig() {
3358
3182
  return { name: "", alias: "", config: {}, blocks: [] };
3359
3183
  }
@@ -3708,6 +3532,16 @@ function bindingText(b) {
3708
3532
  if (b.expr) return b.expr.value;
3709
3533
  return "";
3710
3534
  }
3535
+ function exportText(e) {
3536
+ if (!e) return "";
3537
+ if (e.out) return `${childReference(e.out.module)}.${e.out.name}`;
3538
+ return bindingText({ lit: e.lit, var: e.var, out: void 0, expr: e.expr });
3539
+ }
3540
+ function childReference(id) {
3541
+ if (id.startsWith("resource.")) return id.slice("resource.".length);
3542
+ if (id.startsWith("data.")) return id;
3543
+ return `module.${id}`;
3544
+ }
3711
3545
  function bindingMode(b) {
3712
3546
  if (!b) return { mode: "empty" };
3713
3547
  if (b.out) return { mode: "wired", wired_source: bindingText(b) };
@@ -3716,9 +3550,6 @@ function bindingMode(b) {
3716
3550
  if (b.lit !== void 0 && b.lit !== null) return { mode: "literal", value: b.lit };
3717
3551
  return { mode: "empty" };
3718
3552
  }
3719
- function describeBinding(b) {
3720
- return { mode: bindingMode(b).mode, display: bindingText(b) };
3721
- }
3722
3553
  function deriveNodeConfig(bundle, instanceId) {
3723
3554
  const resolved = resolveInstance(bundle, instanceId);
3724
3555
  if (!resolved) return null;
@@ -3749,25 +3580,64 @@ function deriveNodeConfig(bundle, instanceId) {
3749
3580
  ].filter((id) => id !== child.id);
3750
3581
  const dependsOn = child.use?.depends_on ?? child.resource?.depends_on ?? [];
3751
3582
  const providers = child.use?.providers ?? {};
3583
+ const meta = child.use ?? child.resource;
3752
3584
  const availableVariables = (scope.interface?.inputs ?? []).map((v) => ({
3753
3585
  name: v.name,
3754
3586
  type: v.type
3755
3587
  }));
3756
3588
  return {
3757
3589
  instance_id: instanceId,
3590
+ module_key: child.use?.module,
3758
3591
  inputs,
3759
3592
  outputs,
3760
3593
  sibling_ids: siblingIds,
3761
3594
  depends_on: dependsOn,
3762
3595
  providers,
3596
+ count: bindingText(meta?.count),
3597
+ for_each: bindingText(meta?.for_each),
3763
3598
  available_variables: availableVariables
3764
3599
  };
3765
3600
  }
3766
- function deriveSettingsConfig(bundle) {
3767
- const entry = bundle.modules[bundle.entry];
3768
- const terraform = entry?.terraform ? {
3769
- required_version: entry.terraform.required_version,
3770
- required_providers: Object.entries(entry.terraform.required_providers ?? {}).map(
3601
+ function sourceText(source) {
3602
+ if (source.kind === "git") {
3603
+ const subdir = source.subdir ? `//${source.subdir}` : "";
3604
+ const ref = source.ref ? `?ref=${source.ref}` : "";
3605
+ return `git::${source.repo}${subdir}${ref}`;
3606
+ }
3607
+ return source.kind === "local" ? source.subdir : source.ref;
3608
+ }
3609
+ function defaultText(value) {
3610
+ return value === void 0 || value === null ? "null" : hclLiteralText(value);
3611
+ }
3612
+ function blockConfigs(blocks) {
3613
+ return (blocks ?? []).map((b) => ({
3614
+ type: b.type,
3615
+ labels: [...b.labels],
3616
+ attributes: b.attributes.map((a) => ({ name: a.name, value: bindingText(a.value) })),
3617
+ blocks: blockConfigs(b.blocks)
3618
+ }));
3619
+ }
3620
+ function resourceConfig(r) {
3621
+ const kind = r.kind === "data" ? "data" : "resource";
3622
+ return {
3623
+ id: r.id,
3624
+ kind,
3625
+ type: r.type,
3626
+ name: r.id.slice(`${kind}.${r.type}.`.length),
3627
+ arguments: Object.keys(r.inputs ?? {}).sort().map((name) => ({ name, value: bindingText(r.inputs[name]) })),
3628
+ blocks: blockConfigs(r.blocks),
3629
+ count: bindingText(r.count),
3630
+ for_each: bindingText(r.for_each),
3631
+ provider: r.provider_ref,
3632
+ depends_on: [...r.depends_on ?? []]
3633
+ };
3634
+ }
3635
+ function deriveSettingsConfig(bundle, moduleKey) {
3636
+ const mod = bundle.modules[moduleKey];
3637
+ if (!mod) return null;
3638
+ const terraform = mod.terraform ? {
3639
+ required_version: mod.terraform.required_version,
3640
+ required_providers: Object.entries(mod.terraform.required_providers ?? {}).map(
3771
3641
  ([name, req]) => ({
3772
3642
  name,
3773
3643
  source: req.source,
@@ -3776,18 +3646,15 @@ function deriveSettingsConfig(bundle) {
3776
3646
  })
3777
3647
  )
3778
3648
  } : { required_version: "", required_providers: [] };
3779
- const providers = (entry?.providers ?? []).map((p) => {
3649
+ const providers = (mod.providers ?? []).map((p) => {
3780
3650
  const config = {};
3781
3651
  for (const [k, v] of Object.entries(p.config ?? {})) {
3782
- config[k] = describeBinding(v).display;
3652
+ config[k] = bindingText(v);
3783
3653
  }
3784
- return { name: p.name, alias: p.alias, config, blocks: p.blocks };
3785
- });
3786
- const locals = (entry?.locals ?? []).map((l) => {
3787
- const { mode, display } = describeBinding(l.value);
3788
- return { name: l.name, mode, value_display: display };
3654
+ return { name: p.name, alias: p.alias, config, blocks: blockConfigs(p.blocks) };
3789
3655
  });
3790
- const variables = (entry?.interface?.inputs ?? []).map((v) => ({
3656
+ const locals = (mod.locals ?? []).map((l) => ({ name: l.name, value: bindingText(l.value) }));
3657
+ const variables = (mod.interface?.inputs ?? []).map((v) => ({
3791
3658
  name: v.name,
3792
3659
  type: v.type,
3793
3660
  required: v.required,
@@ -3799,20 +3666,42 @@ function deriveSettingsConfig(bundle) {
3799
3666
  })),
3800
3667
  ephemeral: v.ephemeral,
3801
3668
  sensitive: v.sensitive || void 0,
3802
- nullable: v.nullable
3669
+ nullable: v.nullable,
3670
+ default: v.required ? "" : defaultText(v.default_value)
3803
3671
  }));
3804
- const output_defs = (entry?.interface?.outputs ?? []).map((o) => ({
3672
+ const outputs = (mod.interface?.outputs ?? []).map((o) => ({
3805
3673
  name: o.name,
3806
3674
  type: o.type,
3675
+ value: exportText(mod.exports?.outputs?.[o.name]),
3807
3676
  description: o.description || void 0,
3808
3677
  sensitive: o.sensitive || void 0,
3809
3678
  depends_on: o.depends_on
3810
3679
  }));
3811
- const exports2 = Object.entries(entry?.exports?.outputs ?? {}).flatMap(([name, exp]) => {
3812
- if (!exp.out) return [];
3813
- return [{ name, source_instance: exp.out.module, source_output: exp.out.name }];
3814
- });
3815
- return { terraform, providers, locals, variables, exports: exports2, output_defs };
3680
+ const read = indexWires(deriveEdges(mod.modules ?? [])).outputs;
3681
+ const callOutputs = (mod.modules ?? []).flatMap(
3682
+ (use) => resolveSchema(bundle, use, read.get(use.id) ?? []).outputs.map(
3683
+ (o) => `module.${use.id}.${o.name}`
3684
+ )
3685
+ );
3686
+ const resources = (mod.resources ?? []).map(resourceConfig);
3687
+ const leaf = !mod.source && moduleKey !== bundle.entry && (mod.modules ?? []).length === 0;
3688
+ return {
3689
+ module_key: moduleKey,
3690
+ reference: mod.source ? { source: sourceText(mod.source), version: mod.version } : void 0,
3691
+ terraform,
3692
+ providers,
3693
+ locals,
3694
+ variables,
3695
+ outputs,
3696
+ resources,
3697
+ holds_managed_resources: resources.some((r) => r.kind === "resource") || leaf,
3698
+ directives: blockConfigs(mod.top_level_blocks),
3699
+ call_outputs: callOutputs,
3700
+ dependency_options: [
3701
+ ...(mod.modules ?? []).map((u) => childReference(u.id)),
3702
+ ...(mod.resources ?? []).map((r) => childReference(r.id))
3703
+ ]
3704
+ };
3816
3705
  }
3817
3706
 
3818
3707
  // src/projection/join-path.ts
@@ -5183,7 +5072,7 @@ function isSet3(value) {
5183
5072
  var CanvasViewProto = CanvasView;
5184
5073
 
5185
5074
  // src/protocol-version.ts
5186
- var ENGINE_PROTOCOL_VERSION = String(4 /* PROTOCOL_VERSION_CURRENT */);
5075
+ var ENGINE_PROTOCOL_VERSION = String(5 /* PROTOCOL_VERSION_CURRENT */);
5187
5076
  var EngineProtocolMismatchError = class extends Error {
5188
5077
  constructor(engineVersion, engineProtocol, requiredProtocol) {
5189
5078
  super(