appbuild-oceanbase-console 1.11.0 → 1.11.1

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/cjs/sdk.js CHANGED
@@ -13968,10 +13968,24 @@ class SchemaMigration {
13968
13968
  }
13969
13969
  /**
13970
13970
  * Check if an attribute key is a built-in field that cannot be modified
13971
- * Built-in fields: id, createdAt, updatedAt
13971
+ * Built-in fields include:
13972
+ * - Fields starting with '$' prefix (e.g., $id, $createdAt, $updatedAt)
13973
+ * - Legacy field names: id, createdAt, updatedAt
13972
13974
  */
13973
13975
  isBuiltInAttribute(key) {
13974
- return key === 'id' || key === 'createdAt' || key === 'updatedAt' || key === '$id' || key === '$createdAt' || key === '$updatedAt';
13976
+ // Check if starts with '$' prefix (all system/built-in fields)
13977
+ if (key.startsWith('$')) {
13978
+ return true;
13979
+ }
13980
+ // Legacy field names for backwards compatibility
13981
+ return key === 'id' || key === 'createdAt' || key === 'updatedAt';
13982
+ }
13983
+ /**
13984
+ * Check if an index key is a built-in index that cannot be modified
13985
+ * Built-in indexes start with '$' prefix
13986
+ */
13987
+ isBuiltInIndex(key) {
13988
+ return key.startsWith('$');
13975
13989
  }
13976
13990
  /**
13977
13991
  * Check if an index contains any built-in attributes
@@ -13989,6 +14003,7 @@ class SchemaMigration {
13989
14003
  // Store schema for later use in execution
13990
14004
  this._currentSchema = schema;
13991
14005
  const operations = [];
14006
+ const skippedBuiltIns = [];
13992
14007
  // If databaseId is empty, create a database with id "default"
13993
14008
  let databaseId = schema.databaseId;
13994
14009
  if (!databaseId || databaseId.trim() === '') {
@@ -14034,8 +14049,14 @@ class SchemaMigration {
14034
14049
  // For new tables, create all attributes and indexes
14035
14050
  // Process target attributes
14036
14051
  for (const targetAttr of targetCollection.attributes) {
14037
- // Skip built-in attributes (id, createdAt, updatedAt)
14052
+ // Skip built-in attributes (starting with '$' or legacy names)
14038
14053
  if (this.isBuiltInAttribute(targetAttr.key)) {
14054
+ skippedBuiltIns.push({
14055
+ collectionId: collectionId,
14056
+ key: targetAttr.key,
14057
+ type: 'attribute',
14058
+ reason: `Built-in column '${targetAttr.key}' is automatically managed by the system`
14059
+ });
14039
14060
  continue;
14040
14061
  }
14041
14062
  operations.push({
@@ -14049,9 +14070,24 @@ class SchemaMigration {
14049
14070
  // Process target indexes
14050
14071
  if (targetCollection.indexes) {
14051
14072
  for (const targetIndex of targetCollection.indexes) {
14073
+ // Skip built-in indexes (starting with '$')
14074
+ if (this.isBuiltInIndex(targetIndex.key)) {
14075
+ skippedBuiltIns.push({
14076
+ collectionId: collectionId,
14077
+ key: targetIndex.key,
14078
+ type: 'index',
14079
+ reason: `Built-in index '${targetIndex.key}' is automatically managed by the system`
14080
+ });
14081
+ continue;
14082
+ }
14052
14083
  // Skip indexes that contain built-in attributes
14053
14084
  if (this.indexContainsBuiltInAttributes(targetIndex)) {
14054
- console.log(`Skipping index ${targetIndex.key} because it contains built-in attributes`);
14085
+ skippedBuiltIns.push({
14086
+ collectionId: collectionId,
14087
+ key: targetIndex.key,
14088
+ type: 'index',
14089
+ reason: `Index '${targetIndex.key}' references built-in columns and is automatically managed`
14090
+ });
14055
14091
  continue;
14056
14092
  }
14057
14093
  operations.push({
@@ -14090,8 +14126,14 @@ class SchemaMigration {
14090
14126
  });
14091
14127
  // Process target attributes
14092
14128
  for (const targetAttr of targetCollection.attributes) {
14093
- // Skip built-in attributes (id, createdAt, updatedAt)
14129
+ // Skip built-in attributes (starting with '$' or legacy names)
14094
14130
  if (this.isBuiltInAttribute(targetAttr.key)) {
14131
+ skippedBuiltIns.push({
14132
+ collectionId: collectionId,
14133
+ key: targetAttr.key,
14134
+ type: 'attribute',
14135
+ reason: `Built-in column '${targetAttr.key}' is automatically managed by the system`
14136
+ });
14095
14137
  continue;
14096
14138
  }
14097
14139
  const currentCol = currentColumnsMap.get(targetAttr.key);
@@ -14129,8 +14171,9 @@ class SchemaMigration {
14129
14171
  }
14130
14172
  // Check for columns to delete (columns in current but not in target)
14131
14173
  for (const [key, currentAttr] of currentColumnsMap.entries()) {
14132
- // Skip built-in attributes (id, createdAt, updatedAt)
14174
+ // Skip built-in attributes (starting with '$' or legacy names)
14133
14175
  if (this.isBuiltInAttribute(key)) {
14176
+ // Don't add to skippedBuiltIns here since these are existing columns, not from target schema
14134
14177
  continue;
14135
14178
  }
14136
14179
  const targetAttr = targetCollection.attributes.find(a => a.key === key);
@@ -14157,9 +14200,24 @@ class SchemaMigration {
14157
14200
  });
14158
14201
  // Process target indexes
14159
14202
  for (const targetIndex of targetCollection.indexes) {
14203
+ // Skip built-in indexes (starting with '$')
14204
+ if (this.isBuiltInIndex(targetIndex.key)) {
14205
+ skippedBuiltIns.push({
14206
+ collectionId: collectionId,
14207
+ key: targetIndex.key,
14208
+ type: 'index',
14209
+ reason: `Built-in index '${targetIndex.key}' is automatically managed by the system`
14210
+ });
14211
+ continue;
14212
+ }
14160
14213
  // Skip indexes that contain built-in attributes
14161
14214
  if (this.indexContainsBuiltInAttributes(targetIndex)) {
14162
- console.log(`Skipping index ${targetIndex.key} because it contains built-in attributes`);
14215
+ skippedBuiltIns.push({
14216
+ collectionId: collectionId,
14217
+ key: targetIndex.key,
14218
+ type: 'index',
14219
+ reason: `Index '${targetIndex.key}' references built-in columns and is automatically managed`
14220
+ });
14163
14221
  continue;
14164
14222
  }
14165
14223
  const currentIndex = currentIndexesMap.get(targetIndex.key);
@@ -14197,10 +14255,15 @@ class SchemaMigration {
14197
14255
  }
14198
14256
  // Check for indexes to delete
14199
14257
  for (const [key, currentIndex] of currentIndexesMap.entries()) {
14258
+ // Skip built-in indexes (starting with '$')
14259
+ if (this.isBuiltInIndex(key)) {
14260
+ // Don't add to skippedBuiltIns here since these are existing indexes, not from target schema
14261
+ continue;
14262
+ }
14200
14263
  // Skip indexes that contain built-in attributes
14201
14264
  const indexAttributes = currentIndex.columns || [];
14202
14265
  if (indexAttributes.some((attr) => this.isBuiltInAttribute(attr))) {
14203
- console.log(`Skipping deletion of index ${key} because it contains built-in attributes`);
14266
+ // Don't add to skippedBuiltIns here since these are existing indexes
14204
14267
  continue;
14205
14268
  }
14206
14269
  const targetIndex = targetCollection.indexes.find(i => i.key === key);
@@ -14242,7 +14305,8 @@ class SchemaMigration {
14242
14305
  };
14243
14306
  return {
14244
14307
  operations,
14245
- summary
14308
+ summary,
14309
+ skippedBuiltIns
14246
14310
  };
14247
14311
  });
14248
14312
  }
@@ -14347,6 +14411,25 @@ class SchemaMigration {
14347
14411
  plan.operations.forEach((op, index) => {
14348
14412
  console.log(`${index + 1}. [${op.type}] ${op.reason}`);
14349
14413
  });
14414
+ // Display skipped built-in items
14415
+ if (plan.skippedBuiltIns && plan.skippedBuiltIns.length > 0) {
14416
+ console.log('\n=== SKIPPED BUILT-IN ITEMS ===');
14417
+ console.log('The following items are built-in (starting with "$") and automatically managed by the system:');
14418
+ const skippedAttributes = plan.skippedBuiltIns.filter(item => item.type === 'attribute');
14419
+ const skippedIndexes = plan.skippedBuiltIns.filter(item => item.type === 'index');
14420
+ if (skippedAttributes.length > 0) {
14421
+ console.log('\nBuilt-in Columns:');
14422
+ skippedAttributes.forEach(item => {
14423
+ console.log(` - [${item.collectionId}] ${item.key}: ${item.reason}`);
14424
+ });
14425
+ }
14426
+ if (skippedIndexes.length > 0) {
14427
+ console.log('\nBuilt-in Indexes:');
14428
+ skippedIndexes.forEach(item => {
14429
+ console.log(` - [${item.collectionId}] ${item.key}: ${item.reason}`);
14430
+ });
14431
+ }
14432
+ }
14350
14433
  return;
14351
14434
  }
14352
14435
  // Store schema for use in executeOperation
@@ -14592,6 +14675,11 @@ class SchemaMigration {
14592
14675
  if (!operation.index) {
14593
14676
  throw new Error('Index definition missing for createIndex operation');
14594
14677
  }
14678
+ // Skip built-in indexes (starting with '$')
14679
+ if (this.isBuiltInIndex(operation.index.key)) {
14680
+ console.log(`Skipping createIndex for built-in index: ${operation.index.key}`);
14681
+ break;
14682
+ }
14595
14683
  // Skip indexes that contain built-in attributes
14596
14684
  if (this.indexContainsBuiltInAttributes(operation.index)) {
14597
14685
  console.log(`Skipping createIndex for index ${operation.index.key} because it contains built-in attributes`);
@@ -14613,6 +14701,11 @@ class SchemaMigration {
14613
14701
  if (!operation.indexKey) {
14614
14702
  throw new Error('Index key missing for deleteIndex operation');
14615
14703
  }
14704
+ // Skip built-in indexes (starting with '$')
14705
+ if (this.isBuiltInIndex(operation.indexKey)) {
14706
+ console.log(`Skipping deleteIndex for built-in index: ${operation.indexKey}`);
14707
+ break;
14708
+ }
14616
14709
  // Check if index exists before deleting
14617
14710
  try {
14618
14711
  const indexesList = yield this.databases.listIndexes({
@@ -27655,16 +27748,8 @@ exports.MessageStatus = void 0;
27655
27748
  MessageStatus["Failed"] = "failed";
27656
27749
  })(exports.MessageStatus || (exports.MessageStatus = {}));
27657
27750
 
27658
- // 全局默认 API endpoint 配置
27659
- let defaultApiEndpoint = null;
27660
- function setDefaultApiEndpoint(endpoint) {
27661
- if (!endpoint.startsWith('http://') && !endpoint.startsWith('https://')) {
27662
- throw new Error('Invalid endpoint URL: ' + endpoint);
27663
- }
27664
- defaultApiEndpoint = endpoint;
27665
- }
27666
27751
  function getApiEndpoint(region) {
27667
- return defaultApiEndpoint || 'https://appbuild.oceanbase.com/v1';
27752
+ return 'https://appbuild.oceanbase.com/v1';
27668
27753
  }
27669
27754
  function createConsoleSdk(client) {
27670
27755
  return {
@@ -27813,5 +27898,4 @@ exports.Vcs = Vcs;
27813
27898
  exports.getApiEndpoint = getApiEndpoint;
27814
27899
  exports.realtime = realtime;
27815
27900
  exports.sdk = sdk;
27816
- exports.setDefaultApiEndpoint = setDefaultApiEndpoint;
27817
27901
  //# sourceMappingURL=sdk.js.map