@abapify/adk 0.4.5 → 0.4.6

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.mjs CHANGED
@@ -3190,9 +3190,9 @@ var AdkCrudSourceObject = class AdkCrudSourceObject {
3190
3190
  name;
3191
3191
  ctx;
3192
3192
  metadata;
3193
- constructor(ctx, name) {
3193
+ constructor(ctx, nameOrData) {
3194
3194
  this.ctx = ctx;
3195
- this.name = name.toUpperCase();
3195
+ this.name = (typeof nameOrData === "string" ? nameOrData : String(nameOrData.name ?? "")).toUpperCase();
3196
3196
  }
3197
3197
  get objectUri() {
3198
3198
  return `/sap/bc/adt/${this.endpoint}/${encodeURIComponent(this.name.toLowerCase())}`;
@@ -3255,9 +3255,8 @@ var AdkCrudSourceObject = class AdkCrudSourceObject {
3255
3255
  * Get a source object (validates it exists by fetching source).
3256
3256
  * Generic helper used by static `get()` on subclasses.
3257
3257
  */
3258
- static async getSourceObject(name, ctx) {
3259
- const context = AdkCrudSourceObject.resolveContext(ctx);
3260
- const obj = new this(context, name);
3258
+ static async getSourceObject(ctor, name, ctx) {
3259
+ const obj = new ctor(AdkCrudSourceObject.resolveContext(ctx), name);
3261
3260
  await obj.getSource();
3262
3261
  return obj;
3263
3262
  }
@@ -3265,9 +3264,9 @@ var AdkCrudSourceObject = class AdkCrudSourceObject {
3265
3264
  * Check if a source object exists.
3266
3265
  * Generic helper used by static `exists()` on subclasses.
3267
3266
  */
3268
- static async sourceObjectExists(name, ctx) {
3267
+ static async sourceObjectExists(ctor, name, ctx) {
3269
3268
  try {
3270
- await this.getSourceObject(name, ctx);
3269
+ await new ctor(AdkCrudSourceObject.resolveContext(ctx), name).getSource();
3271
3270
  return true;
3272
3271
  } catch {
3273
3272
  return false;
@@ -3277,7 +3276,7 @@ var AdkCrudSourceObject = class AdkCrudSourceObject {
3277
3276
  * Shared skeleton-creation helper. Subclasses pass their contract's `post`
3278
3277
  * function and the root element name + type that their AFF schema expects.
3279
3278
  */
3280
- static async createSourceSkeleton(params, post) {
3279
+ static async createSourceSkeleton(ctor, params, post) {
3281
3280
  const context = AdkCrudSourceObject.resolveContext(params.ctx);
3282
3281
  const nameU = params.name.toUpperCase();
3283
3282
  const pkgU = params.packageName.toUpperCase();
@@ -3294,7 +3293,7 @@ var AdkCrudSourceObject = class AdkCrudSourceObject {
3294
3293
  uri: `/sap/bc/adt/packages/${pkgU.toLowerCase()}`
3295
3294
  }
3296
3295
  } });
3297
- return new this(context, nameU);
3296
+ return new ctor(context, nameU);
3298
3297
  }
3299
3298
  /**
3300
3299
  * Shared delete helper. Subclasses pass their contract's `delete` function.
@@ -3342,10 +3341,10 @@ var AdkDdlSource = class AdkDdlSource extends AdkCrudSourceObject {
3342
3341
  * Get a DDL source (does not fetch metadata, just returns handle)
3343
3342
  */
3344
3343
  static async get(name, ctx) {
3345
- return AdkCrudSourceObject.getSourceObject.call(this, name, ctx);
3344
+ return this.getSourceObject(this, name, ctx);
3346
3345
  }
3347
3346
  static async exists(name, ctx) {
3348
- return AdkCrudSourceObject.sourceObjectExists.call(this, name, ctx);
3347
+ return this.sourceObjectExists(this, name, ctx);
3349
3348
  }
3350
3349
  /**
3351
3350
  * Create a new CDS DDL source on SAP
@@ -3355,7 +3354,7 @@ var AdkDdlSource = class AdkDdlSource extends AdkCrudSourceObject {
3355
3354
  */
3356
3355
  static async create(name, description, packageName, options, ctx) {
3357
3356
  const context = ctx ?? getGlobalContext();
3358
- return AdkCrudSourceObject.createSourceSkeleton.call(this, {
3357
+ return this.createSourceSkeleton(this, {
3359
3358
  name,
3360
3359
  description,
3361
3360
  packageName,
@@ -3398,17 +3397,17 @@ var AdkDclSource = class AdkDclSource extends AdkCrudSourceObject {
3398
3397
  return "dclSource";
3399
3398
  }
3400
3399
  static async get(name, ctx) {
3401
- return AdkCrudSourceObject.getSourceObject.call(this, name, ctx);
3400
+ return this.getSourceObject(this, name, ctx);
3402
3401
  }
3403
3402
  static async exists(name, ctx) {
3404
- return AdkCrudSourceObject.sourceObjectExists.call(this, name, ctx);
3403
+ return this.sourceObjectExists(this, name, ctx);
3405
3404
  }
3406
3405
  /**
3407
3406
  * Create a new CDS DCL source on SAP
3408
3407
  */
3409
3408
  static async create(name, description, packageName, options, ctx) {
3410
3409
  const context = ctx ?? getGlobalContext();
3411
- return AdkCrudSourceObject.createSourceSkeleton.call(this, {
3410
+ return this.createSourceSkeleton(this, {
3412
3411
  name,
3413
3412
  description,
3414
3413
  packageName,
@@ -3433,9 +3432,9 @@ var AdkDdlExtension = class AdkDdlExtension {
3433
3432
  name;
3434
3433
  ctx;
3435
3434
  metadata;
3436
- constructor(ctx, name) {
3435
+ constructor(ctx, nameOrData) {
3437
3436
  this.ctx = ctx;
3438
- this.name = name.toUpperCase();
3437
+ this.name = (typeof nameOrData === "string" ? nameOrData : String(nameOrData.name ?? "")).toUpperCase();
3439
3438
  }
3440
3439
  get objectUri() {
3441
3440
  return `/sap/bc/adt/ddic/ddlx/sources/${encodeURIComponent(this.name.toLowerCase())}`;
@@ -3473,9 +3472,9 @@ var AdkCdsSourceObject = class {
3473
3472
  name;
3474
3473
  ctx;
3475
3474
  metadata;
3476
- constructor(ctx, name) {
3475
+ constructor(ctx, nameOrData) {
3477
3476
  this.ctx = ctx;
3478
- this.name = name.toUpperCase();
3477
+ this.name = (typeof nameOrData === "string" ? nameOrData : String(nameOrData.name ?? "")).toUpperCase();
3479
3478
  }
3480
3479
  get objectUri() {
3481
3480
  return `/sap/bc/adt/${this.endpoint}/${encodeURIComponent(this.name.toLowerCase())}`;
@@ -3508,9 +3507,6 @@ var AdkScalarFunctionDefinition = class AdkScalarFunctionDefinition extends AdkC
3508
3507
  static kind = ScalarFunctionDefinition;
3509
3508
  kind = AdkScalarFunctionDefinition.kind;
3510
3509
  endpoint = "ddic/dsfd/sources";
3511
- constructor(ctx, name) {
3512
- super(ctx, name);
3513
- }
3514
3510
  get contract() {
3515
3511
  return this.ctx.client.adt.ddic.dsfd.sources;
3516
3512
  }
@@ -3525,9 +3521,9 @@ var AdkScalarFunctionImplementation = class AdkScalarFunctionImplementation {
3525
3521
  name;
3526
3522
  ctx;
3527
3523
  definition;
3528
- constructor(ctx, name) {
3524
+ constructor(ctx, nameOrData) {
3529
3525
  this.ctx = ctx;
3530
- this.name = name.toUpperCase();
3526
+ this.name = (typeof nameOrData === "string" ? nameOrData : String(nameOrData.name ?? "")).toUpperCase();
3531
3527
  }
3532
3528
  get objectUri() {
3533
3529
  return `/sap/bc/adt/ddic/dsfi/${encodeURIComponent(this.name.toLowerCase())}`;
@@ -3552,9 +3548,6 @@ var AdkEntityBuffer = class AdkEntityBuffer extends AdkCdsSourceObject {
3552
3548
  static kind = EntityBuffer;
3553
3549
  kind = AdkEntityBuffer.kind;
3554
3550
  endpoint = "ddic/dteb/sources";
3555
- constructor(ctx, name) {
3556
- super(ctx, name);
3557
- }
3558
3551
  get contract() {
3559
3552
  return this.ctx.client.adt.ddic.dteb.sources;
3560
3553
  }
@@ -3575,9 +3568,9 @@ var AdkSourceOnlyCdsObject = class {
3575
3568
  name;
3576
3569
  ctx;
3577
3570
  source;
3578
- constructor(ctx, name) {
3571
+ constructor(ctx, nameOrData) {
3579
3572
  this.ctx = ctx;
3580
- this.name = name.toUpperCase();
3573
+ this.name = (typeof nameOrData === "string" ? nameOrData : String(nameOrData.name ?? "")).toUpperCase();
3581
3574
  }
3582
3575
  get objectUri() {
3583
3576
  return `/sap/bc/adt/${this.endpoint}/${encodeURIComponent(this.name.toLowerCase())}`;
@@ -3604,9 +3597,6 @@ var AdkCdsAspect = class AdkCdsAspect extends AdkSourceOnlyCdsObject {
3604
3597
  static kind = CdsAspect;
3605
3598
  kind = AdkCdsAspect.kind;
3606
3599
  endpoint = "ddic/dras/sources";
3607
- constructor(ctx, name) {
3608
- super(ctx, name);
3609
- }
3610
3600
  };
3611
3601
  registerObjectType("DRAS", CdsAspect, AdkCdsAspect, { endpoint: "ddic/dras/sources" });
3612
3602
 
@@ -3616,9 +3606,6 @@ var AdkCdsType = class AdkCdsType extends AdkSourceOnlyCdsObject {
3616
3606
  static kind = CdsType;
3617
3607
  kind = AdkCdsType.kind;
3618
3608
  endpoint = "ddic/drty/sources";
3619
- constructor(ctx, name) {
3620
- super(ctx, name);
3621
- }
3622
3609
  };
3623
3610
  registerObjectType("DRTY", CdsType, AdkCdsType, { endpoint: "ddic/drty/sources" });
3624
3611
 
@@ -3628,9 +3615,6 @@ var AdkDynamicCache = class AdkDynamicCache extends AdkSourceOnlyCdsObject {
3628
3615
  static kind = DynamicCache;
3629
3616
  kind = AdkDynamicCache.kind;
3630
3617
  endpoint = "ddic/dtdc/sources";
3631
- constructor(ctx, name) {
3632
- super(ctx, name);
3633
- }
3634
3618
  };
3635
3619
  registerObjectType("DTDC", DynamicCache, AdkDynamicCache, { endpoint: "ddic/dtdc/sources" });
3636
3620
 
@@ -3640,9 +3624,6 @@ var AdkTuningIndex = class AdkTuningIndex extends AdkSourceOnlyCdsObject {
3640
3624
  static kind = TuningIndex;
3641
3625
  kind = AdkTuningIndex.kind;
3642
3626
  endpoint = "ddic/dtix/sources";
3643
- constructor(ctx, name) {
3644
- super(ctx, name);
3645
- }
3646
3627
  };
3647
3628
  registerObjectType("DTIX", TuningIndex, AdkTuningIndex, { endpoint: "ddic/dtix/sources" });
3648
3629
 
@@ -3652,9 +3633,6 @@ var AdkStaticCache = class AdkStaticCache extends AdkSourceOnlyCdsObject {
3652
3633
  static kind = StaticCache;
3653
3634
  kind = AdkStaticCache.kind;
3654
3635
  endpoint = "ddic/dtsc/sources";
3655
- constructor(ctx, name) {
3656
- super(ctx, name);
3657
- }
3658
3636
  };
3659
3637
  registerObjectType("DTSC", StaticCache, AdkStaticCache, { endpoint: "ddic/dtsc/sources" });
3660
3638
 
@@ -3665,9 +3643,9 @@ var AdkExternalSchema = class AdkExternalSchema {
3665
3643
  kind = AdkExternalSchema.kind;
3666
3644
  name;
3667
3645
  ctx;
3668
- constructor(ctx, name) {
3646
+ constructor(ctx, nameOrData) {
3669
3647
  this.ctx = ctx;
3670
- this.name = name.toUpperCase();
3648
+ this.name = (typeof nameOrData === "string" ? nameOrData : String(nameOrData.name ?? "")).toUpperCase();
3671
3649
  }
3672
3650
  get objectUri() {
3673
3651
  return `/sap/bc/adt/ddic/desd/${encodeURIComponent(this.name.toLowerCase())}`;
@@ -3719,10 +3697,10 @@ var AdkBehaviorDefinition = class AdkBehaviorDefinition extends AdkCrudSourceObj
3719
3697
  * Get a BDEF (validates it exists by fetching source).
3720
3698
  */
3721
3699
  static async get(name, ctx) {
3722
- return AdkCrudSourceObject.getSourceObject.call(this, name, ctx);
3700
+ return this.getSourceObject(this, name, ctx);
3723
3701
  }
3724
3702
  static async exists(name, ctx) {
3725
- return AdkCrudSourceObject.sourceObjectExists.call(this, name, ctx);
3703
+ return this.sourceObjectExists(this, name, ctx);
3726
3704
  }
3727
3705
  /**
3728
3706
  * Create a new BDEF on SAP.
@@ -3733,7 +3711,7 @@ var AdkBehaviorDefinition = class AdkBehaviorDefinition extends AdkCrudSourceObj
3733
3711
  */
3734
3712
  static async create(name, description, packageName, options, ctx) {
3735
3713
  const context = ctx ?? getGlobalContext();
3736
- return AdkCrudSourceObject.createSourceSkeleton.call(this, {
3714
+ return this.createSourceSkeleton(this, {
3737
3715
  name,
3738
3716
  description,
3739
3717
  packageName,
@@ -3777,9 +3755,9 @@ var AdkBadi = class AdkBadi {
3777
3755
  ctx;
3778
3756
  _description;
3779
3757
  _package;
3780
- constructor(ctx, name) {
3758
+ constructor(ctx, nameOrData) {
3781
3759
  this.ctx = ctx;
3782
- this.name = name.toUpperCase();
3760
+ this.name = (typeof nameOrData === "string" ? nameOrData : String(nameOrData.name ?? "")).toUpperCase();
3783
3761
  }
3784
3762
  /** ADT URI (lowercase path segment — SAP convention). */
3785
3763
  get objectUri() {
@@ -3975,10 +3953,10 @@ var AdkServiceDefinition = class AdkServiceDefinition extends AdkCrudSourceObjec
3975
3953
  * Get a SRVD (validates it exists by fetching source).
3976
3954
  */
3977
3955
  static async get(name, ctx) {
3978
- return AdkCrudSourceObject.getSourceObject.call(this, name, ctx);
3956
+ return this.getSourceObject(this, name, ctx);
3979
3957
  }
3980
3958
  static async exists(name, ctx) {
3981
- return AdkCrudSourceObject.sourceObjectExists.call(this, name, ctx);
3959
+ return this.sourceObjectExists(this, name, ctx);
3982
3960
  }
3983
3961
  /**
3984
3962
  * Create a new SRVD on SAP.
@@ -3989,7 +3967,7 @@ var AdkServiceDefinition = class AdkServiceDefinition extends AdkCrudSourceObjec
3989
3967
  */
3990
3968
  static async create(name, description, packageName, options, ctx) {
3991
3969
  const context = ctx ?? getGlobalContext();
3992
- return AdkCrudSourceObject.createSourceSkeleton.call(this, {
3970
+ return this.createSourceSkeleton(this, {
3993
3971
  name,
3994
3972
  description,
3995
3973
  packageName,
@@ -4031,9 +4009,9 @@ var AdkServiceBinding = class AdkServiceBinding {
4031
4009
  kind = AdkServiceBinding.kind;
4032
4010
  name;
4033
4011
  ctx;
4034
- constructor(ctx, name) {
4012
+ constructor(ctx, nameOrData) {
4035
4013
  this.ctx = ctx;
4036
- this.name = name.toUpperCase();
4014
+ this.name = (typeof nameOrData === "string" ? nameOrData : String(nameOrData.name ?? "")).toUpperCase();
4037
4015
  }
4038
4016
  get objectUri() {
4039
4017
  return `/sap/bc/adt/businessservices/bindings/${encodeURIComponent(this.name.toLowerCase())}`;