appbuild-oceanbase-console 1.10.2

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.
Files changed (105) hide show
  1. package/LICENSE +12 -0
  2. package/README.md +191 -0
  3. package/dist/cjs/package.json +3 -0
  4. package/dist/cjs/sdk.js +27712 -0
  5. package/dist/cjs/sdk.js.map +1 -0
  6. package/dist/esm/package.json +3 -0
  7. package/dist/esm/sdk.js +27675 -0
  8. package/dist/esm/sdk.js.map +1 -0
  9. package/dist/iife/sdk.js +27716 -0
  10. package/package.json +47 -0
  11. package/types/client.d.ts +211 -0
  12. package/types/enums/adapter.d.ts +4 -0
  13. package/types/enums/api-service.d.ts +15 -0
  14. package/types/enums/api.d.ts +5 -0
  15. package/types/enums/attribute-status.d.ts +7 -0
  16. package/types/enums/auth-method.d.ts +9 -0
  17. package/types/enums/authentication-factor.d.ts +6 -0
  18. package/types/enums/authenticator-type.d.ts +3 -0
  19. package/types/enums/billing-plan.d.ts +10 -0
  20. package/types/enums/browser.d.ts +16 -0
  21. package/types/enums/build-runtime.d.ts +66 -0
  22. package/types/enums/column-status.d.ts +7 -0
  23. package/types/enums/compression.d.ts +5 -0
  24. package/types/enums/console-resource-type.d.ts +3 -0
  25. package/types/enums/credit-card.d.ts +19 -0
  26. package/types/enums/database-type.d.ts +4 -0
  27. package/types/enums/deployment-download-type.d.ts +4 -0
  28. package/types/enums/deployment-status.d.ts +7 -0
  29. package/types/enums/email-template-locale.d.ts +133 -0
  30. package/types/enums/email-template-type.d.ts +9 -0
  31. package/types/enums/execution-method.d.ts +9 -0
  32. package/types/enums/execution-status.d.ts +7 -0
  33. package/types/enums/execution-trigger.d.ts +5 -0
  34. package/types/enums/flag.d.ts +197 -0
  35. package/types/enums/framework.d.ts +17 -0
  36. package/types/enums/health-antivirus-status.d.ts +5 -0
  37. package/types/enums/health-check-status.d.ts +4 -0
  38. package/types/enums/image-format.d.ts +9 -0
  39. package/types/enums/image-gravity.d.ts +11 -0
  40. package/types/enums/index-status.d.ts +7 -0
  41. package/types/enums/index-type.d.ts +6 -0
  42. package/types/enums/message-priority.d.ts +4 -0
  43. package/types/enums/message-status.d.ts +7 -0
  44. package/types/enums/messaging-provider-type.d.ts +5 -0
  45. package/types/enums/name.d.ts +14 -0
  46. package/types/enums/o-auth-provider.d.ts +43 -0
  47. package/types/enums/output.d.ts +9 -0
  48. package/types/enums/password-hash.d.ts +13 -0
  49. package/types/enums/platform-type.d.ts +17 -0
  50. package/types/enums/platform.d.ts +4 -0
  51. package/types/enums/project-usage-range.d.ts +4 -0
  52. package/types/enums/proxy-resource-type.d.ts +4 -0
  53. package/types/enums/proxy-rule-deployment-resource-type.d.ts +4 -0
  54. package/types/enums/proxy-rule-status.d.ts +6 -0
  55. package/types/enums/region.d.ts +8 -0
  56. package/types/enums/relation-mutate.d.ts +5 -0
  57. package/types/enums/relationship-type.d.ts +6 -0
  58. package/types/enums/runtime.d.ts +66 -0
  59. package/types/enums/sms-template-locale.d.ts +133 -0
  60. package/types/enums/sms-template-type.d.ts +6 -0
  61. package/types/enums/smtp-encryption.d.ts +5 -0
  62. package/types/enums/smtp-secure.d.ts +4 -0
  63. package/types/enums/status-code.d.ts +6 -0
  64. package/types/enums/status.d.ts +4 -0
  65. package/types/enums/theme.d.ts +4 -0
  66. package/types/enums/timezone.d.ts +421 -0
  67. package/types/enums/type.d.ts +5 -0
  68. package/types/enums/usage-range.d.ts +5 -0
  69. package/types/enums/vcs-deployment-type.d.ts +5 -0
  70. package/types/enums/vcs-detection-type.d.ts +4 -0
  71. package/types/id.d.ts +20 -0
  72. package/types/index.d.ts +102 -0
  73. package/types/migrations.d.ts +240 -0
  74. package/types/models.d.ts +7945 -0
  75. package/types/operator.d.ts +180 -0
  76. package/types/permission.d.ts +43 -0
  77. package/types/query.d.ts +390 -0
  78. package/types/role.d.ts +70 -0
  79. package/types/sdk.d.ts +108 -0
  80. package/types/service.d.ts +11 -0
  81. package/types/services/account.d.ts +1413 -0
  82. package/types/services/assistant.d.ts +24 -0
  83. package/types/services/avatars.d.ts +319 -0
  84. package/types/services/backups.d.ts +276 -0
  85. package/types/services/console.d.ts +210 -0
  86. package/types/services/databases.d.ts +2119 -0
  87. package/types/services/domains.d.ts +1276 -0
  88. package/types/services/functions.d.ts +827 -0
  89. package/types/services/graphql.d.ts +43 -0
  90. package/types/services/health.d.ts +432 -0
  91. package/types/services/locale.d.ts +64 -0
  92. package/types/services/messaging.d.ts +1989 -0
  93. package/types/services/migrations.d.ts +413 -0
  94. package/types/services/organizations.d.ts +842 -0
  95. package/types/services/project.d.ts +130 -0
  96. package/types/services/projects.d.ts +1663 -0
  97. package/types/services/proxy.d.ts +190 -0
  98. package/types/services/realtime.d.ts +118 -0
  99. package/types/services/sites.d.ts +780 -0
  100. package/types/services/storage.d.ts +467 -0
  101. package/types/services/tables-db.d.ts +2034 -0
  102. package/types/services/teams.d.ts +366 -0
  103. package/types/services/tokens.d.ts +119 -0
  104. package/types/services/users.d.ts +1184 -0
  105. package/types/services/vcs.d.ts +249 -0
@@ -0,0 +1,240 @@
1
+ import { TablesDB } from './services/tables-db';
2
+ /**
3
+ * Database Schema Migration Tool
4
+ *
5
+ * This module provides a tool for managing database schema migrations in Appwrite.
6
+ * It compares the current database state with a target schema definition and generates
7
+ * migration operations to synchronize them.
8
+ *
9
+ * Usage example:
10
+ * ```typescript
11
+ * import { sdk } from 'appwrite-console-sdk';
12
+ *
13
+ * // Get project-level SDK
14
+ * const projectSdk = sdk.forProject('region', 'project-id');
15
+ *
16
+ * // Define your schema
17
+ * const schema: SchemaDefinition = {
18
+ * databaseId: 'my-database',
19
+ * collections: [{
20
+ * name: 'memos',
21
+ * _description: '备忘录集合',
22
+ * documentSecurity: true,
23
+ * attributes: [
24
+ * { key: 'id', type: 'string', size: 36, required: true },
25
+ * { key: 'title', type: 'string', size: 255, required: true },
26
+ * { key: 'content', type: 'string', size: 65535, required: true },
27
+ * { key: 'userId', type: 'string', size: 36, required: true },
28
+ * { key: 'createdAt', type: 'datetime', required: true },
29
+ * { key: 'updatedAt', type: 'datetime', required: false },
30
+ * { key: 'isPinned', type: 'boolean', default: false, required: false }
31
+ * ],
32
+ * indexes: [
33
+ * { key: 'user_idx', type: 'index', attributes: ['userId'] },
34
+ * { key: 'created_at_idx', type: 'index', attributes: ['createdAt'] }
35
+ * ]
36
+ * }]
37
+ * };
38
+ *
39
+ * // Generate migration plan
40
+ * const migration = projectSdk.schemaMigration;
41
+ * const plan = await migration.generatePlan(schema);
42
+ *
43
+ * // Preview changes (dry run)
44
+ * await migration.execute(plan, schema, { dryRun: true });
45
+ *
46
+ * // Execute migration
47
+ * await migration.execute(plan, schema);
48
+ * ```
49
+ */
50
+ /**
51
+ * Schema definition types
52
+ */
53
+ export interface SchemaAttribute {
54
+ key: string;
55
+ type: 'string' | 'integer' | 'float' | 'boolean' | 'datetime' | 'email' | 'enum' | 'url' | 'ip' | 'point' | 'line' | 'polygon' | 'relationship';
56
+ size?: number;
57
+ required: boolean;
58
+ default?: any;
59
+ array?: boolean;
60
+ elements?: string[];
61
+ min?: number;
62
+ max?: number;
63
+ encrypt?: boolean;
64
+ relatedCollectionId?: string;
65
+ relationshipType?: 'oneToOne' | 'oneToMany' | 'manyToOne' | 'manyToMany';
66
+ twoWay?: boolean;
67
+ twoWayKey?: string;
68
+ onDelete?: 'cascade' | 'restrict' | 'setNull';
69
+ }
70
+ export interface SchemaIndex {
71
+ key: string;
72
+ type: 'index' | 'unique' | 'fulltext';
73
+ attributes: string[];
74
+ orders?: string[];
75
+ lengths?: number[];
76
+ }
77
+ export interface SchemaCollection {
78
+ _description?: string;
79
+ name: string;
80
+ documentSecurity?: boolean;
81
+ enabled?: boolean;
82
+ permissions?: string[];
83
+ attributes: SchemaAttribute[];
84
+ indexes?: SchemaIndex[];
85
+ }
86
+ export interface SchemaDefinition {
87
+ databaseId: string;
88
+ collections: SchemaCollection[];
89
+ }
90
+ /**
91
+ * Migration operation types
92
+ */
93
+ export declare type MigrationOperationType = 'createCollection' | 'updateCollection' | 'deleteCollection' | 'createAttribute' | 'updateAttribute' | 'deleteAttribute' | 'createIndex' | 'deleteIndex';
94
+ export interface MigrationOperation {
95
+ type: MigrationOperationType;
96
+ databaseId: string;
97
+ collectionId: string;
98
+ collectionName?: string;
99
+ attribute?: SchemaAttribute;
100
+ index?: SchemaIndex;
101
+ attributeKey?: string;
102
+ indexKey?: string;
103
+ reason?: string;
104
+ }
105
+ export interface MigrationPlan {
106
+ operations: MigrationOperation[];
107
+ summary: {
108
+ collectionsToCreate: number;
109
+ collectionsToUpdate: number;
110
+ collectionsToDelete: number;
111
+ attributesToCreate: number;
112
+ attributesToUpdate: number;
113
+ attributesToDelete: number;
114
+ indexesToCreate: number;
115
+ indexesToDelete: number;
116
+ };
117
+ }
118
+ /**
119
+ * Database Schema Migration Tool
120
+ *
121
+ * This tool helps manage database schema migrations by:
122
+ * 1. Comparing current database state with target schema
123
+ * 2. Generating migration operations
124
+ * 3. Executing migration operations
125
+ */
126
+ export declare class SchemaMigration {
127
+ private databases;
128
+ constructor(databases: TablesDB);
129
+ /**
130
+ * Generate migration plan by comparing current database state with target schema
131
+ */
132
+ generatePlan(schema: SchemaDefinition): Promise<MigrationPlan>;
133
+ /**
134
+ * Compare two attributes to see if they differ
135
+ */
136
+ private compareAttributes;
137
+ /**
138
+ * Compare two indexes to see if they differ
139
+ */
140
+ private compareIndexes;
141
+ /**
142
+ * Execute migration plan
143
+ *
144
+ * @param plan - Migration plan generated by generatePlan
145
+ * @param schema - Original schema definition (needed for collection properties)
146
+ * @param options - Execution options including dryRun mode
147
+ *
148
+ * @example
149
+ * ```typescript
150
+ * const schema: SchemaDefinition = {
151
+ * databaseId: 'my-database',
152
+ * collections: [{
153
+ * name: 'memos',
154
+ * documentSecurity: true,
155
+ * attributes: [
156
+ * { key: 'id', type: 'string', size: 36, required: true },
157
+ * { key: 'title', type: 'string', size: 255, required: true }
158
+ * ]
159
+ * }]
160
+ * };
161
+ *
162
+ * const migration = new SchemaMigration(tablesDB);
163
+ * const plan = await migration.generatePlan(schema);
164
+ * await migration.execute(plan, schema, { dryRun: true }); // Preview changes
165
+ * await migration.execute(plan, schema); // Execute changes
166
+ * ```
167
+ */
168
+ execute(plan: MigrationPlan, schema: SchemaDefinition, options?: {
169
+ dryRun?: boolean;
170
+ }): Promise<void>;
171
+ /**
172
+ * Wait for a column to reach a specific state
173
+ *
174
+ * @param databaseId - Database ID
175
+ * @param collectionId - Collection ID
176
+ * @param attributeKey - Column key to wait for
177
+ * @param mode - Wait mode: 'available' (wait for column to be available) or 'deleted' (wait for column to be deleted)
178
+ * @param maxWaitTime - Maximum time to wait in milliseconds
179
+ * @param pollInterval - Polling interval in milliseconds
180
+ */
181
+ private waitForColumnState;
182
+ /**
183
+ * Wait for an attribute to become available
184
+ *
185
+ * @param databaseId - Database ID
186
+ * @param collectionId - Collection ID
187
+ * @param attributeKey - Attribute key to wait for
188
+ * @param maxWaitTime - Maximum time to wait in milliseconds (default: 10000 = 10 seconds)
189
+ * @param pollInterval - Polling interval in milliseconds (default: 50 = 50 milliseconds)
190
+ */
191
+ private waitForAttributeAvailable;
192
+ /**
193
+ * Wait for an attribute to be deleted
194
+ *
195
+ * @param databaseId - Database ID
196
+ * @param collectionId - Collection ID
197
+ * @param attributeKey - Attribute key to wait for
198
+ * @param maxWaitTime - Maximum time to wait in milliseconds (default: 30000 = 30 seconds)
199
+ * @param pollInterval - Polling interval in milliseconds (default: 500 = 500 milliseconds)
200
+ */
201
+ private waitForAttributeDeleted;
202
+ /**
203
+ * Wait for multiple attributes to become available
204
+ *
205
+ * @param databaseId - Database ID
206
+ * @param collectionId - Collection ID
207
+ * @param attributeKeys - Array of attribute keys to wait for
208
+ */
209
+ private waitForAttributesAvailable;
210
+ /**
211
+ * Wait for an index to be deleted
212
+ *
213
+ * @param databaseId - Database ID
214
+ * @param collectionId - Collection ID
215
+ * @param indexKey - Index key to wait for
216
+ * @param maxWaitTime - Maximum time to wait in milliseconds (default: 30000 = 30 seconds)
217
+ * @param pollInterval - Polling interval in milliseconds (default: 500 = 500 milliseconds)
218
+ */
219
+ private waitForIndexDeleted;
220
+ /**
221
+ * Execute a single migration operation
222
+ */
223
+ private executeOperation;
224
+ /**
225
+ * Create a column based on its type
226
+ */
227
+ private createAttribute;
228
+ /**
229
+ * Map index type string to IndexType enum
230
+ */
231
+ private mapIndexType;
232
+ /**
233
+ * Map relationship type string to RelationshipType enum
234
+ */
235
+ private mapRelationshipType;
236
+ /**
237
+ * Map relation mutate string to RelationMutate enum
238
+ */
239
+ private mapRelationMutate;
240
+ }