appbuild-oceanbase-console 1.10.3 → 1.10.4
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 +298 -160
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/esm/sdk.js +298 -160
- package/dist/esm/sdk.js.map +1 -1
- package/dist/iife/sdk.js +298 -160
- package/package.json +1 -1
- package/types/migrations.d.ts +31 -1
- package/dist/cjs/package.json +0 -3
- package/dist/esm/package.json +0 -3
package/dist/cjs/sdk.js
CHANGED
|
@@ -13795,6 +13795,154 @@ exports.AttributeStatus = void 0;
|
|
|
13795
13795
|
AttributeStatus["Failed"] = "failed";
|
|
13796
13796
|
})(exports.AttributeStatus || (exports.AttributeStatus = {}));
|
|
13797
13797
|
|
|
13798
|
+
/**
|
|
13799
|
+
* Helper class to generate permission strings for resources.
|
|
13800
|
+
*/
|
|
13801
|
+
class Permission {
|
|
13802
|
+
}
|
|
13803
|
+
/**
|
|
13804
|
+
* Generate read permission string for the provided role.
|
|
13805
|
+
*
|
|
13806
|
+
* @param {string} role
|
|
13807
|
+
* @returns {string}
|
|
13808
|
+
*/
|
|
13809
|
+
Permission.read = (role) => {
|
|
13810
|
+
return `read("${role}")`;
|
|
13811
|
+
};
|
|
13812
|
+
/**
|
|
13813
|
+
* Generate write permission string for the provided role.
|
|
13814
|
+
*
|
|
13815
|
+
* This is an alias of update, delete, and possibly create.
|
|
13816
|
+
* Don't use write in combination with update, delete, or create.
|
|
13817
|
+
*
|
|
13818
|
+
* @param {string} role
|
|
13819
|
+
* @returns {string}
|
|
13820
|
+
*/
|
|
13821
|
+
Permission.write = (role) => {
|
|
13822
|
+
return `write("${role}")`;
|
|
13823
|
+
};
|
|
13824
|
+
/**
|
|
13825
|
+
* Generate create permission string for the provided role.
|
|
13826
|
+
*
|
|
13827
|
+
* @param {string} role
|
|
13828
|
+
* @returns {string}
|
|
13829
|
+
*/
|
|
13830
|
+
Permission.create = (role) => {
|
|
13831
|
+
return `create("${role}")`;
|
|
13832
|
+
};
|
|
13833
|
+
/**
|
|
13834
|
+
* Generate update permission string for the provided role.
|
|
13835
|
+
*
|
|
13836
|
+
* @param {string} role
|
|
13837
|
+
* @returns {string}
|
|
13838
|
+
*/
|
|
13839
|
+
Permission.update = (role) => {
|
|
13840
|
+
return `update("${role}")`;
|
|
13841
|
+
};
|
|
13842
|
+
/**
|
|
13843
|
+
* Generate delete permission string for the provided role.
|
|
13844
|
+
*
|
|
13845
|
+
* @param {string} role
|
|
13846
|
+
* @returns {string}
|
|
13847
|
+
*/
|
|
13848
|
+
Permission.delete = (role) => {
|
|
13849
|
+
return `delete("${role}")`;
|
|
13850
|
+
};
|
|
13851
|
+
|
|
13852
|
+
/**
|
|
13853
|
+
* Helper class to generate role strings for `Permission`.
|
|
13854
|
+
*/
|
|
13855
|
+
class Role {
|
|
13856
|
+
/**
|
|
13857
|
+
* Grants access to anyone.
|
|
13858
|
+
*
|
|
13859
|
+
* This includes authenticated and unauthenticated users.
|
|
13860
|
+
*
|
|
13861
|
+
* @returns {string}
|
|
13862
|
+
*/
|
|
13863
|
+
static any() {
|
|
13864
|
+
return 'any';
|
|
13865
|
+
}
|
|
13866
|
+
/**
|
|
13867
|
+
* Grants access to a specific user by user ID.
|
|
13868
|
+
*
|
|
13869
|
+
* You can optionally pass verified or unverified for
|
|
13870
|
+
* `status` to target specific types of users.
|
|
13871
|
+
*
|
|
13872
|
+
* @param {string} id
|
|
13873
|
+
* @param {string} status
|
|
13874
|
+
* @returns {string}
|
|
13875
|
+
*/
|
|
13876
|
+
static user(id, status = '') {
|
|
13877
|
+
if (status === '') {
|
|
13878
|
+
return `user:${id}`;
|
|
13879
|
+
}
|
|
13880
|
+
return `user:${id}/${status}`;
|
|
13881
|
+
}
|
|
13882
|
+
/**
|
|
13883
|
+
* Grants access to any authenticated or anonymous user.
|
|
13884
|
+
*
|
|
13885
|
+
* You can optionally pass verified or unverified for
|
|
13886
|
+
* `status` to target specific types of users.
|
|
13887
|
+
*
|
|
13888
|
+
* @param {string} status
|
|
13889
|
+
* @returns {string}
|
|
13890
|
+
*/
|
|
13891
|
+
static users(status = '') {
|
|
13892
|
+
if (status === '') {
|
|
13893
|
+
return 'users';
|
|
13894
|
+
}
|
|
13895
|
+
return `users/${status}`;
|
|
13896
|
+
}
|
|
13897
|
+
/**
|
|
13898
|
+
* Grants access to any guest user without a session.
|
|
13899
|
+
*
|
|
13900
|
+
* Authenticated users don't have access to this role.
|
|
13901
|
+
*
|
|
13902
|
+
* @returns {string}
|
|
13903
|
+
*/
|
|
13904
|
+
static guests() {
|
|
13905
|
+
return 'guests';
|
|
13906
|
+
}
|
|
13907
|
+
/**
|
|
13908
|
+
* Grants access to a team by team ID.
|
|
13909
|
+
*
|
|
13910
|
+
* You can optionally pass a role for `role` to target
|
|
13911
|
+
* team members with the specified role.
|
|
13912
|
+
*
|
|
13913
|
+
* @param {string} id
|
|
13914
|
+
* @param {string} role
|
|
13915
|
+
* @returns {string}
|
|
13916
|
+
*/
|
|
13917
|
+
static team(id, role = '') {
|
|
13918
|
+
if (role === '') {
|
|
13919
|
+
return `team:${id}`;
|
|
13920
|
+
}
|
|
13921
|
+
return `team:${id}/${role}`;
|
|
13922
|
+
}
|
|
13923
|
+
/**
|
|
13924
|
+
* Grants access to a specific member of a team.
|
|
13925
|
+
*
|
|
13926
|
+
* When the member is removed from the team, they will
|
|
13927
|
+
* no longer have access.
|
|
13928
|
+
*
|
|
13929
|
+
* @param {string} id
|
|
13930
|
+
* @returns {string}
|
|
13931
|
+
*/
|
|
13932
|
+
static member(id) {
|
|
13933
|
+
return `member:${id}`;
|
|
13934
|
+
}
|
|
13935
|
+
/**
|
|
13936
|
+
* Grants access to a user with the specified label.
|
|
13937
|
+
*
|
|
13938
|
+
* @param {string} name
|
|
13939
|
+
* @returns {string}
|
|
13940
|
+
*/
|
|
13941
|
+
static label(name) {
|
|
13942
|
+
return `label:${name}`;
|
|
13943
|
+
}
|
|
13944
|
+
}
|
|
13945
|
+
|
|
13798
13946
|
/**
|
|
13799
13947
|
* Database Schema Migration Tool
|
|
13800
13948
|
*
|
|
@@ -13807,13 +13955,45 @@ class SchemaMigration {
|
|
|
13807
13955
|
constructor(databases) {
|
|
13808
13956
|
this.databases = databases;
|
|
13809
13957
|
}
|
|
13958
|
+
/**
|
|
13959
|
+
* Get default permissions for collections (read, create, update, delete all set to 'any')
|
|
13960
|
+
*/
|
|
13961
|
+
getDefaultPermissions() {
|
|
13962
|
+
return [
|
|
13963
|
+
Permission.read(Role.any()),
|
|
13964
|
+
Permission.create(Role.any()),
|
|
13965
|
+
Permission.update(Role.any()),
|
|
13966
|
+
Permission.delete(Role.any())
|
|
13967
|
+
];
|
|
13968
|
+
}
|
|
13810
13969
|
/**
|
|
13811
13970
|
* Check if an attribute key is a built-in field that cannot be modified
|
|
13812
|
-
* Built-in fields:
|
|
13971
|
+
* Built-in fields include:
|
|
13972
|
+
* - Fields starting with '$' prefix (e.g., $id, $createdAt, $updatedAt)
|
|
13973
|
+
* - Legacy field names: id, createdAt, updatedAt
|
|
13813
13974
|
*/
|
|
13814
13975
|
isBuiltInAttribute(key) {
|
|
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
|
|
13815
13981
|
return key === 'id' || key === 'createdAt' || key === 'updatedAt';
|
|
13816
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('$');
|
|
13989
|
+
}
|
|
13990
|
+
/**
|
|
13991
|
+
* Check if an index contains any built-in attributes
|
|
13992
|
+
* Built-in fields cannot have indexes created or deleted
|
|
13993
|
+
*/
|
|
13994
|
+
indexContainsBuiltInAttributes(index) {
|
|
13995
|
+
return index.attributes.some(attr => this.isBuiltInAttribute(attr));
|
|
13996
|
+
}
|
|
13817
13997
|
/**
|
|
13818
13998
|
* Generate migration plan by comparing current database state with target schema
|
|
13819
13999
|
*/
|
|
@@ -13823,6 +14003,7 @@ class SchemaMigration {
|
|
|
13823
14003
|
// Store schema for later use in execution
|
|
13824
14004
|
this._currentSchema = schema;
|
|
13825
14005
|
const operations = [];
|
|
14006
|
+
const skippedBuiltIns = [];
|
|
13826
14007
|
// If databaseId is empty, create a database with id "default"
|
|
13827
14008
|
let databaseId = schema.databaseId;
|
|
13828
14009
|
if (!databaseId || databaseId.trim() === '') {
|
|
@@ -13868,8 +14049,14 @@ class SchemaMigration {
|
|
|
13868
14049
|
// For new tables, create all attributes and indexes
|
|
13869
14050
|
// Process target attributes
|
|
13870
14051
|
for (const targetAttr of targetCollection.attributes) {
|
|
13871
|
-
// Skip built-in attributes (
|
|
14052
|
+
// Skip built-in attributes (starting with '$' or legacy names)
|
|
13872
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
|
+
});
|
|
13873
14060
|
continue;
|
|
13874
14061
|
}
|
|
13875
14062
|
operations.push({
|
|
@@ -13883,6 +14070,26 @@ class SchemaMigration {
|
|
|
13883
14070
|
// Process target indexes
|
|
13884
14071
|
if (targetCollection.indexes) {
|
|
13885
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
|
+
}
|
|
14083
|
+
// Skip indexes that contain built-in attributes
|
|
14084
|
+
if (this.indexContainsBuiltInAttributes(targetIndex)) {
|
|
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
|
+
});
|
|
14091
|
+
continue;
|
|
14092
|
+
}
|
|
13886
14093
|
operations.push({
|
|
13887
14094
|
type: 'createIndex',
|
|
13888
14095
|
databaseId: schema.databaseId,
|
|
@@ -13919,8 +14126,14 @@ class SchemaMigration {
|
|
|
13919
14126
|
});
|
|
13920
14127
|
// Process target attributes
|
|
13921
14128
|
for (const targetAttr of targetCollection.attributes) {
|
|
13922
|
-
// Skip built-in attributes (
|
|
14129
|
+
// Skip built-in attributes (starting with '$' or legacy names)
|
|
13923
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
|
+
});
|
|
13924
14137
|
continue;
|
|
13925
14138
|
}
|
|
13926
14139
|
const currentCol = currentColumnsMap.get(targetAttr.key);
|
|
@@ -13958,8 +14171,9 @@ class SchemaMigration {
|
|
|
13958
14171
|
}
|
|
13959
14172
|
// Check for columns to delete (columns in current but not in target)
|
|
13960
14173
|
for (const [key, currentAttr] of currentColumnsMap.entries()) {
|
|
13961
|
-
// Skip built-in attributes (
|
|
14174
|
+
// Skip built-in attributes (starting with '$' or legacy names)
|
|
13962
14175
|
if (this.isBuiltInAttribute(key)) {
|
|
14176
|
+
// Don't add to skippedBuiltIns here since these are existing columns, not from target schema
|
|
13963
14177
|
continue;
|
|
13964
14178
|
}
|
|
13965
14179
|
const targetAttr = targetCollection.attributes.find(a => a.key === key);
|
|
@@ -13986,6 +14200,26 @@ class SchemaMigration {
|
|
|
13986
14200
|
});
|
|
13987
14201
|
// Process target indexes
|
|
13988
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
|
+
}
|
|
14213
|
+
// Skip indexes that contain built-in attributes
|
|
14214
|
+
if (this.indexContainsBuiltInAttributes(targetIndex)) {
|
|
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
|
+
});
|
|
14221
|
+
continue;
|
|
14222
|
+
}
|
|
13989
14223
|
const currentIndex = currentIndexesMap.get(targetIndex.key);
|
|
13990
14224
|
if (!currentIndex) {
|
|
13991
14225
|
// Index doesn't exist - create it
|
|
@@ -14021,6 +14255,17 @@ class SchemaMigration {
|
|
|
14021
14255
|
}
|
|
14022
14256
|
// Check for indexes to delete
|
|
14023
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
|
+
}
|
|
14263
|
+
// Skip indexes that contain built-in attributes
|
|
14264
|
+
const indexAttributes = currentIndex.columns || [];
|
|
14265
|
+
if (indexAttributes.some((attr) => this.isBuiltInAttribute(attr))) {
|
|
14266
|
+
// Don't add to skippedBuiltIns here since these are existing indexes
|
|
14267
|
+
continue;
|
|
14268
|
+
}
|
|
14024
14269
|
const targetIndex = targetCollection.indexes.find(i => i.key === key);
|
|
14025
14270
|
if (!targetIndex) {
|
|
14026
14271
|
operations.push({
|
|
@@ -14060,7 +14305,8 @@ class SchemaMigration {
|
|
|
14060
14305
|
};
|
|
14061
14306
|
return {
|
|
14062
14307
|
operations,
|
|
14063
|
-
summary
|
|
14308
|
+
summary,
|
|
14309
|
+
skippedBuiltIns
|
|
14064
14310
|
};
|
|
14065
14311
|
});
|
|
14066
14312
|
}
|
|
@@ -14165,6 +14411,25 @@ class SchemaMigration {
|
|
|
14165
14411
|
plan.operations.forEach((op, index) => {
|
|
14166
14412
|
console.log(`${index + 1}. [${op.type}] ${op.reason}`);
|
|
14167
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
|
+
}
|
|
14168
14433
|
return;
|
|
14169
14434
|
}
|
|
14170
14435
|
// Store schema for use in executeOperation
|
|
@@ -14343,7 +14608,7 @@ class SchemaMigration {
|
|
|
14343
14608
|
* Execute a single migration operation
|
|
14344
14609
|
*/
|
|
14345
14610
|
executeOperation(operation) {
|
|
14346
|
-
var _a, _b, _c, _d;
|
|
14611
|
+
var _a, _b, _c, _d, _e, _f;
|
|
14347
14612
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14348
14613
|
switch (operation.type) {
|
|
14349
14614
|
case 'createCollection':
|
|
@@ -14356,7 +14621,7 @@ class SchemaMigration {
|
|
|
14356
14621
|
name: operation.collectionName,
|
|
14357
14622
|
rowSecurity: (_a = targetCollection === null || targetCollection === void 0 ? void 0 : targetCollection.documentSecurity) !== null && _a !== void 0 ? _a : false,
|
|
14358
14623
|
enabled: (_b = targetCollection === null || targetCollection === void 0 ? void 0 : targetCollection.enabled) !== null && _b !== void 0 ? _b : true,
|
|
14359
|
-
permissions: targetCollection === null || targetCollection === void 0 ? void 0 : targetCollection.permissions
|
|
14624
|
+
permissions: (_c = targetCollection === null || targetCollection === void 0 ? void 0 : targetCollection.permissions) !== null && _c !== void 0 ? _c : this.getDefaultPermissions()
|
|
14360
14625
|
});
|
|
14361
14626
|
break;
|
|
14362
14627
|
case 'updateCollection':
|
|
@@ -14367,9 +14632,9 @@ class SchemaMigration {
|
|
|
14367
14632
|
databaseId: operation.databaseId,
|
|
14368
14633
|
tableId: operation.collectionId,
|
|
14369
14634
|
name: operation.collectionName || operation.collectionId,
|
|
14370
|
-
rowSecurity: (
|
|
14371
|
-
enabled: (
|
|
14372
|
-
permissions: updateTargetCollection === null || updateTargetCollection === void 0 ? void 0 : updateTargetCollection.permissions
|
|
14635
|
+
rowSecurity: (_d = updateTargetCollection === null || updateTargetCollection === void 0 ? void 0 : updateTargetCollection.documentSecurity) !== null && _d !== void 0 ? _d : false,
|
|
14636
|
+
enabled: (_e = updateTargetCollection === null || updateTargetCollection === void 0 ? void 0 : updateTargetCollection.enabled) !== null && _e !== void 0 ? _e : true,
|
|
14637
|
+
permissions: (_f = updateTargetCollection === null || updateTargetCollection === void 0 ? void 0 : updateTargetCollection.permissions) !== null && _f !== void 0 ? _f : this.getDefaultPermissions()
|
|
14373
14638
|
});
|
|
14374
14639
|
break;
|
|
14375
14640
|
case 'deleteCollection':
|
|
@@ -14410,6 +14675,16 @@ class SchemaMigration {
|
|
|
14410
14675
|
if (!operation.index) {
|
|
14411
14676
|
throw new Error('Index definition missing for createIndex operation');
|
|
14412
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
|
+
}
|
|
14683
|
+
// Skip indexes that contain built-in attributes
|
|
14684
|
+
if (this.indexContainsBuiltInAttributes(operation.index)) {
|
|
14685
|
+
console.log(`Skipping createIndex for index ${operation.index.key} because it contains built-in attributes`);
|
|
14686
|
+
break;
|
|
14687
|
+
}
|
|
14413
14688
|
// Wait for all attributes used in the index to be available
|
|
14414
14689
|
yield this.waitForAttributesAvailable(operation.databaseId, operation.collectionId, operation.index.attributes);
|
|
14415
14690
|
yield this.databases.createIndex({
|
|
@@ -14426,6 +14701,11 @@ class SchemaMigration {
|
|
|
14426
14701
|
if (!operation.indexKey) {
|
|
14427
14702
|
throw new Error('Index key missing for deleteIndex operation');
|
|
14428
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
|
+
}
|
|
14429
14709
|
// Check if index exists before deleting
|
|
14430
14710
|
try {
|
|
14431
14711
|
const indexesList = yield this.databases.listIndexes({
|
|
@@ -14433,12 +14713,18 @@ class SchemaMigration {
|
|
|
14433
14713
|
tableId: operation.collectionId,
|
|
14434
14714
|
total: true
|
|
14435
14715
|
});
|
|
14436
|
-
const
|
|
14437
|
-
if (!
|
|
14716
|
+
const indexToDelete = indexesList.indexes.find(idx => idx.key === operation.indexKey);
|
|
14717
|
+
if (!indexToDelete) {
|
|
14438
14718
|
// Index doesn't exist, skip deletion
|
|
14439
14719
|
console.log(`Index ${operation.indexKey} does not exist, skipping deletion`);
|
|
14440
14720
|
break;
|
|
14441
14721
|
}
|
|
14722
|
+
// Check if index contains built-in attributes
|
|
14723
|
+
const indexAttributes = indexToDelete.columns || [];
|
|
14724
|
+
if (indexAttributes.some((attr) => this.isBuiltInAttribute(attr))) {
|
|
14725
|
+
console.log(`Skipping deleteIndex for index ${operation.indexKey} because it contains built-in attributes`);
|
|
14726
|
+
break;
|
|
14727
|
+
}
|
|
14442
14728
|
}
|
|
14443
14729
|
catch (error) {
|
|
14444
14730
|
// If we can't list indexes, try to delete anyway (might fail gracefully)
|
|
@@ -25641,154 +25927,6 @@ class Realtime {
|
|
|
25641
25927
|
}
|
|
25642
25928
|
}
|
|
25643
25929
|
|
|
25644
|
-
/**
|
|
25645
|
-
* Helper class to generate permission strings for resources.
|
|
25646
|
-
*/
|
|
25647
|
-
class Permission {
|
|
25648
|
-
}
|
|
25649
|
-
/**
|
|
25650
|
-
* Generate read permission string for the provided role.
|
|
25651
|
-
*
|
|
25652
|
-
* @param {string} role
|
|
25653
|
-
* @returns {string}
|
|
25654
|
-
*/
|
|
25655
|
-
Permission.read = (role) => {
|
|
25656
|
-
return `read("${role}")`;
|
|
25657
|
-
};
|
|
25658
|
-
/**
|
|
25659
|
-
* Generate write permission string for the provided role.
|
|
25660
|
-
*
|
|
25661
|
-
* This is an alias of update, delete, and possibly create.
|
|
25662
|
-
* Don't use write in combination with update, delete, or create.
|
|
25663
|
-
*
|
|
25664
|
-
* @param {string} role
|
|
25665
|
-
* @returns {string}
|
|
25666
|
-
*/
|
|
25667
|
-
Permission.write = (role) => {
|
|
25668
|
-
return `write("${role}")`;
|
|
25669
|
-
};
|
|
25670
|
-
/**
|
|
25671
|
-
* Generate create permission string for the provided role.
|
|
25672
|
-
*
|
|
25673
|
-
* @param {string} role
|
|
25674
|
-
* @returns {string}
|
|
25675
|
-
*/
|
|
25676
|
-
Permission.create = (role) => {
|
|
25677
|
-
return `create("${role}")`;
|
|
25678
|
-
};
|
|
25679
|
-
/**
|
|
25680
|
-
* Generate update permission string for the provided role.
|
|
25681
|
-
*
|
|
25682
|
-
* @param {string} role
|
|
25683
|
-
* @returns {string}
|
|
25684
|
-
*/
|
|
25685
|
-
Permission.update = (role) => {
|
|
25686
|
-
return `update("${role}")`;
|
|
25687
|
-
};
|
|
25688
|
-
/**
|
|
25689
|
-
* Generate delete permission string for the provided role.
|
|
25690
|
-
*
|
|
25691
|
-
* @param {string} role
|
|
25692
|
-
* @returns {string}
|
|
25693
|
-
*/
|
|
25694
|
-
Permission.delete = (role) => {
|
|
25695
|
-
return `delete("${role}")`;
|
|
25696
|
-
};
|
|
25697
|
-
|
|
25698
|
-
/**
|
|
25699
|
-
* Helper class to generate role strings for `Permission`.
|
|
25700
|
-
*/
|
|
25701
|
-
class Role {
|
|
25702
|
-
/**
|
|
25703
|
-
* Grants access to anyone.
|
|
25704
|
-
*
|
|
25705
|
-
* This includes authenticated and unauthenticated users.
|
|
25706
|
-
*
|
|
25707
|
-
* @returns {string}
|
|
25708
|
-
*/
|
|
25709
|
-
static any() {
|
|
25710
|
-
return 'any';
|
|
25711
|
-
}
|
|
25712
|
-
/**
|
|
25713
|
-
* Grants access to a specific user by user ID.
|
|
25714
|
-
*
|
|
25715
|
-
* You can optionally pass verified or unverified for
|
|
25716
|
-
* `status` to target specific types of users.
|
|
25717
|
-
*
|
|
25718
|
-
* @param {string} id
|
|
25719
|
-
* @param {string} status
|
|
25720
|
-
* @returns {string}
|
|
25721
|
-
*/
|
|
25722
|
-
static user(id, status = '') {
|
|
25723
|
-
if (status === '') {
|
|
25724
|
-
return `user:${id}`;
|
|
25725
|
-
}
|
|
25726
|
-
return `user:${id}/${status}`;
|
|
25727
|
-
}
|
|
25728
|
-
/**
|
|
25729
|
-
* Grants access to any authenticated or anonymous user.
|
|
25730
|
-
*
|
|
25731
|
-
* You can optionally pass verified or unverified for
|
|
25732
|
-
* `status` to target specific types of users.
|
|
25733
|
-
*
|
|
25734
|
-
* @param {string} status
|
|
25735
|
-
* @returns {string}
|
|
25736
|
-
*/
|
|
25737
|
-
static users(status = '') {
|
|
25738
|
-
if (status === '') {
|
|
25739
|
-
return 'users';
|
|
25740
|
-
}
|
|
25741
|
-
return `users/${status}`;
|
|
25742
|
-
}
|
|
25743
|
-
/**
|
|
25744
|
-
* Grants access to any guest user without a session.
|
|
25745
|
-
*
|
|
25746
|
-
* Authenticated users don't have access to this role.
|
|
25747
|
-
*
|
|
25748
|
-
* @returns {string}
|
|
25749
|
-
*/
|
|
25750
|
-
static guests() {
|
|
25751
|
-
return 'guests';
|
|
25752
|
-
}
|
|
25753
|
-
/**
|
|
25754
|
-
* Grants access to a team by team ID.
|
|
25755
|
-
*
|
|
25756
|
-
* You can optionally pass a role for `role` to target
|
|
25757
|
-
* team members with the specified role.
|
|
25758
|
-
*
|
|
25759
|
-
* @param {string} id
|
|
25760
|
-
* @param {string} role
|
|
25761
|
-
* @returns {string}
|
|
25762
|
-
*/
|
|
25763
|
-
static team(id, role = '') {
|
|
25764
|
-
if (role === '') {
|
|
25765
|
-
return `team:${id}`;
|
|
25766
|
-
}
|
|
25767
|
-
return `team:${id}/${role}`;
|
|
25768
|
-
}
|
|
25769
|
-
/**
|
|
25770
|
-
* Grants access to a specific member of a team.
|
|
25771
|
-
*
|
|
25772
|
-
* When the member is removed from the team, they will
|
|
25773
|
-
* no longer have access.
|
|
25774
|
-
*
|
|
25775
|
-
* @param {string} id
|
|
25776
|
-
* @returns {string}
|
|
25777
|
-
*/
|
|
25778
|
-
static member(id) {
|
|
25779
|
-
return `member:${id}`;
|
|
25780
|
-
}
|
|
25781
|
-
/**
|
|
25782
|
-
* Grants access to a user with the specified label.
|
|
25783
|
-
*
|
|
25784
|
-
* @param {string} name
|
|
25785
|
-
* @returns {string}
|
|
25786
|
-
*/
|
|
25787
|
-
static label(name) {
|
|
25788
|
-
return `label:${name}`;
|
|
25789
|
-
}
|
|
25790
|
-
}
|
|
25791
|
-
|
|
25792
25930
|
var _a, _ID_hexTimestamp;
|
|
25793
25931
|
/**
|
|
25794
25932
|
* Helper class to generate ID strings for resources.
|