appwrite-utils-cli 1.7.8 → 1.8.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/CHANGELOG.md +14 -199
- package/README.md +87 -30
- package/dist/adapters/AdapterFactory.js +5 -25
- package/dist/adapters/DatabaseAdapter.d.ts +17 -2
- package/dist/adapters/LegacyAdapter.d.ts +2 -1
- package/dist/adapters/LegacyAdapter.js +212 -16
- package/dist/adapters/TablesDBAdapter.d.ts +2 -12
- package/dist/adapters/TablesDBAdapter.js +261 -57
- package/dist/cli/commands/databaseCommands.js +10 -10
- package/dist/cli/commands/functionCommands.js +17 -8
- package/dist/collections/attributes.js +447 -125
- package/dist/collections/methods.js +197 -186
- package/dist/collections/tableOperations.d.ts +86 -0
- package/dist/collections/tableOperations.js +434 -0
- package/dist/collections/transferOperations.d.ts +3 -2
- package/dist/collections/transferOperations.js +93 -12
- package/dist/config/services/ConfigLoaderService.d.ts +7 -0
- package/dist/config/services/ConfigLoaderService.js +47 -1
- package/dist/config/yamlConfig.d.ts +221 -88
- package/dist/examples/yamlTerminologyExample.d.ts +1 -1
- package/dist/examples/yamlTerminologyExample.js +6 -3
- package/dist/functions/deployments.js +5 -23
- package/dist/functions/fnConfigDiscovery.d.ts +3 -0
- package/dist/functions/fnConfigDiscovery.js +108 -0
- package/dist/functions/methods.js +4 -2
- package/dist/functions/pathResolution.d.ts +37 -0
- package/dist/functions/pathResolution.js +185 -0
- package/dist/functions/templates/count-docs-in-collection/README.md +54 -0
- package/dist/functions/templates/count-docs-in-collection/package.json +25 -0
- package/dist/functions/templates/count-docs-in-collection/src/main.ts +159 -0
- package/dist/functions/templates/count-docs-in-collection/src/request.ts +9 -0
- package/dist/functions/templates/count-docs-in-collection/tsconfig.json +28 -0
- package/dist/functions/templates/hono-typescript/README.md +286 -0
- package/dist/functions/templates/hono-typescript/package.json +26 -0
- package/dist/functions/templates/hono-typescript/src/adapters/request.ts +74 -0
- package/dist/functions/templates/hono-typescript/src/adapters/response.ts +106 -0
- package/dist/functions/templates/hono-typescript/src/app.ts +180 -0
- package/dist/functions/templates/hono-typescript/src/context.ts +103 -0
- package/dist/functions/templates/hono-typescript/src/index.ts +54 -0
- package/dist/functions/templates/hono-typescript/src/middleware/appwrite.ts +119 -0
- package/dist/functions/templates/hono-typescript/tsconfig.json +20 -0
- package/dist/functions/templates/typescript-node/README.md +32 -0
- package/dist/functions/templates/typescript-node/package.json +25 -0
- package/dist/functions/templates/typescript-node/src/context.ts +103 -0
- package/dist/functions/templates/typescript-node/src/index.ts +29 -0
- package/dist/functions/templates/typescript-node/tsconfig.json +28 -0
- package/dist/functions/templates/uv/README.md +31 -0
- package/dist/functions/templates/uv/pyproject.toml +30 -0
- package/dist/functions/templates/uv/src/__init__.py +0 -0
- package/dist/functions/templates/uv/src/context.py +125 -0
- package/dist/functions/templates/uv/src/index.py +46 -0
- package/dist/interactiveCLI.js +18 -15
- package/dist/main.js +219 -81
- package/dist/migrations/appwriteToX.d.ts +88 -23
- package/dist/migrations/comprehensiveTransfer.d.ts +2 -0
- package/dist/migrations/comprehensiveTransfer.js +83 -6
- package/dist/migrations/dataLoader.d.ts +227 -69
- package/dist/migrations/dataLoader.js +3 -3
- package/dist/migrations/importController.js +3 -3
- package/dist/migrations/relationships.d.ts +8 -2
- package/dist/migrations/services/ImportOrchestrator.js +3 -3
- package/dist/migrations/transfer.js +159 -37
- package/dist/shared/attributeMapper.d.ts +20 -0
- package/dist/shared/attributeMapper.js +203 -0
- package/dist/shared/selectionDialogs.d.ts +1 -1
- package/dist/shared/selectionDialogs.js +39 -11
- package/dist/storage/schemas.d.ts +354 -92
- package/dist/utils/configDiscovery.js +4 -3
- package/dist/utils/versionDetection.d.ts +0 -4
- package/dist/utils/versionDetection.js +41 -173
- package/dist/utils/yamlConverter.js +89 -16
- package/dist/utils/yamlLoader.d.ts +1 -1
- package/dist/utils/yamlLoader.js +6 -2
- package/dist/utilsController.d.ts +2 -1
- package/dist/utilsController.js +151 -22
- package/package.json +7 -5
- package/scripts/copy-templates.ts +23 -0
- package/src/adapters/AdapterFactory.ts +119 -143
- package/src/adapters/DatabaseAdapter.ts +18 -3
- package/src/adapters/LegacyAdapter.ts +236 -105
- package/src/adapters/TablesDBAdapter.ts +773 -643
- package/src/cli/commands/databaseCommands.ts +19 -19
- package/src/cli/commands/functionCommands.ts +23 -14
- package/src/collections/attributes.ts +2054 -1611
- package/src/collections/methods.ts +208 -293
- package/src/collections/tableOperations.ts +506 -0
- package/src/collections/transferOperations.ts +218 -144
- package/src/config/services/ConfigLoaderService.ts +62 -1
- package/src/examples/yamlTerminologyExample.ts +10 -5
- package/src/functions/deployments.ts +10 -35
- package/src/functions/fnConfigDiscovery.ts +103 -0
- package/src/functions/methods.ts +4 -2
- package/src/functions/pathResolution.ts +227 -0
- package/src/interactiveCLI.ts +25 -20
- package/src/main.ts +557 -202
- package/src/migrations/comprehensiveTransfer.ts +126 -50
- package/src/migrations/dataLoader.ts +3 -3
- package/src/migrations/importController.ts +3 -3
- package/src/migrations/services/ImportOrchestrator.ts +3 -3
- package/src/migrations/transfer.ts +148 -131
- package/src/shared/attributeMapper.ts +229 -0
- package/src/shared/selectionDialogs.ts +65 -32
- package/src/utils/configDiscovery.ts +9 -3
- package/src/utils/versionDetection.ts +74 -228
- package/src/utils/yamlConverter.ts +94 -17
- package/src/utils/yamlLoader.ts +11 -4
- package/src/utilsController.ts +202 -36
- package/dist/utils/schemaStrings.d.ts +0 -14
- package/dist/utils/schemaStrings.js +0 -428
- package/dist/utils/sessionPreservationExample.d.ts +0 -1666
- package/dist/utils/sessionPreservationExample.js +0 -101
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import { resolve as resolvePath, dirname, isAbsolute } from "node:path";
|
|
3
4
|
import yaml from "js-yaml";
|
|
4
5
|
import { register } from "tsx/esm/api";
|
|
5
6
|
import { pathToFileURL } from "node:url";
|
|
@@ -8,6 +9,7 @@ import { normalizeYamlData } from "../../utils/yamlConverter.js";
|
|
|
8
9
|
import { loadYamlConfig } from "../yamlConfig.js";
|
|
9
10
|
import { loadAppwriteProjectConfig, projectConfigToAppwriteConfig, getCollectionsFromProject } from "../../utils/projectConfig.js";
|
|
10
11
|
import { loadYamlCollection, loadYamlTable, } from "../../utils/configDiscovery.js";
|
|
12
|
+
import { expandTildePath } from "../../functions/pathResolution.js";
|
|
11
13
|
/**
|
|
12
14
|
* Service for loading and parsing Appwrite configuration files.
|
|
13
15
|
*
|
|
@@ -25,6 +27,31 @@ import { loadYamlCollection, loadYamlTable, } from "../../utils/configDiscovery.
|
|
|
25
27
|
* - Validates and normalizes configuration data
|
|
26
28
|
*/
|
|
27
29
|
export class ConfigLoaderService {
|
|
30
|
+
/**
|
|
31
|
+
* Normalizes function dirPath to absolute path
|
|
32
|
+
* @param func Function configuration object
|
|
33
|
+
* @param configDir Directory containing the config file
|
|
34
|
+
* @returns Function with normalized dirPath
|
|
35
|
+
*/
|
|
36
|
+
normalizeFunctionPath(func, configDir) {
|
|
37
|
+
if (!func.dirPath) {
|
|
38
|
+
return func;
|
|
39
|
+
}
|
|
40
|
+
// Expand tilde first
|
|
41
|
+
const expandedPath = expandTildePath(func.dirPath);
|
|
42
|
+
// If already absolute, return as-is
|
|
43
|
+
if (isAbsolute(expandedPath)) {
|
|
44
|
+
return {
|
|
45
|
+
...func,
|
|
46
|
+
dirPath: expandedPath
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// Resolve relative to config directory
|
|
50
|
+
return {
|
|
51
|
+
...func,
|
|
52
|
+
dirPath: resolvePath(configDir, expandedPath)
|
|
53
|
+
};
|
|
54
|
+
}
|
|
28
55
|
/**
|
|
29
56
|
* Loads configuration from a discovered path, auto-detecting the type
|
|
30
57
|
* @param configPath Path to the configuration file
|
|
@@ -46,6 +73,11 @@ export class ConfigLoaderService {
|
|
|
46
73
|
if (!partialConfig.appwriteEndpoint || !partialConfig.appwriteProject) {
|
|
47
74
|
throw new Error("JSON project config must contain at minimum 'endpoint' and 'projectId' fields");
|
|
48
75
|
}
|
|
76
|
+
const configDir = path.dirname(configPath);
|
|
77
|
+
// Normalize function paths
|
|
78
|
+
const normalizedFunctions = partialConfig.functions
|
|
79
|
+
? partialConfig.functions.map(func => this.normalizeFunctionPath(func, configDir))
|
|
80
|
+
: [];
|
|
49
81
|
return {
|
|
50
82
|
appwriteEndpoint: partialConfig.appwriteEndpoint,
|
|
51
83
|
appwriteProject: partialConfig.appwriteProject,
|
|
@@ -73,7 +105,7 @@ export class ConfigLoaderService {
|
|
|
73
105
|
},
|
|
74
106
|
databases: partialConfig.databases || [],
|
|
75
107
|
buckets: partialConfig.buckets || [],
|
|
76
|
-
functions:
|
|
108
|
+
functions: normalizedFunctions,
|
|
77
109
|
collections: partialConfig.collections || [],
|
|
78
110
|
sessionCookie: partialConfig.sessionCookie,
|
|
79
111
|
authMethod: partialConfig.authMethod || "auto",
|
|
@@ -114,6 +146,10 @@ export class ConfigLoaderService {
|
|
|
114
146
|
}
|
|
115
147
|
// Load collections and tables from their respective directories
|
|
116
148
|
const configDir = path.dirname(yamlPath);
|
|
149
|
+
// Normalize function paths
|
|
150
|
+
if (config.functions) {
|
|
151
|
+
config.functions = config.functions.map(func => this.normalizeFunctionPath(func, configDir));
|
|
152
|
+
}
|
|
117
153
|
const collectionsDir = path.join(configDir, config.schemaConfig?.collectionsDirectory || "collections");
|
|
118
154
|
const tablesDir = path.join(configDir, config.schemaConfig?.tablesDirectory || "tables");
|
|
119
155
|
// Detect API mode to determine priority order
|
|
@@ -175,6 +211,11 @@ export class ConfigLoaderService {
|
|
|
175
211
|
if (!config) {
|
|
176
212
|
throw new Error(`Failed to load TypeScript config from: ${tsPath}`);
|
|
177
213
|
}
|
|
214
|
+
// Normalize function paths
|
|
215
|
+
const configDir = path.dirname(tsPath);
|
|
216
|
+
if (config.functions) {
|
|
217
|
+
config.functions = config.functions.map(func => this.normalizeFunctionPath(func, configDir));
|
|
218
|
+
}
|
|
178
219
|
MessageFormatter.success(`Loaded TypeScript config from: ${tsPath}`, {
|
|
179
220
|
prefix: "Config",
|
|
180
221
|
});
|
|
@@ -210,6 +251,11 @@ export class ConfigLoaderService {
|
|
|
210
251
|
if (collections.length > 0) {
|
|
211
252
|
appwriteConfig.collections = collections;
|
|
212
253
|
}
|
|
254
|
+
// Normalize function paths
|
|
255
|
+
const configDir = path.dirname(jsonPath);
|
|
256
|
+
if (appwriteConfig.functions) {
|
|
257
|
+
appwriteConfig.functions = appwriteConfig.functions.map(func => this.normalizeFunctionPath(func, configDir));
|
|
258
|
+
}
|
|
213
259
|
MessageFormatter.success(`Loaded project config from: ${jsonPath}`, {
|
|
214
260
|
prefix: "Config",
|
|
215
261
|
});
|
|
@@ -239,100 +239,165 @@ export declare const createSessionPreservingYamlConfig: (configPath: string, ses
|
|
|
239
239
|
name: string;
|
|
240
240
|
attributes: ({
|
|
241
241
|
key: string;
|
|
242
|
-
|
|
243
|
-
size: number;
|
|
244
|
-
error?: string | undefined;
|
|
245
|
-
required?: boolean | undefined;
|
|
246
|
-
array?: boolean | undefined;
|
|
247
|
-
xdefault?: string | null | undefined;
|
|
248
|
-
encrypted?: boolean | undefined;
|
|
249
|
-
format?: string | null | undefined;
|
|
250
|
-
} | {
|
|
251
|
-
key: string;
|
|
242
|
+
required: boolean;
|
|
252
243
|
type: "integer";
|
|
253
|
-
error?: string | undefined;
|
|
254
|
-
required?: boolean | undefined;
|
|
255
244
|
array?: boolean | undefined;
|
|
245
|
+
format?: string | undefined;
|
|
246
|
+
status?: string | undefined;
|
|
247
|
+
attributes?: string[] | undefined;
|
|
248
|
+
orders?: string[] | undefined;
|
|
249
|
+
$createdAt?: string | undefined;
|
|
250
|
+
$updatedAt?: string | undefined;
|
|
251
|
+
error?: string | undefined;
|
|
256
252
|
min?: number | undefined;
|
|
257
253
|
max?: number | undefined;
|
|
258
254
|
xdefault?: number | null | undefined;
|
|
259
255
|
} | {
|
|
260
256
|
key: string;
|
|
261
|
-
|
|
257
|
+
required: boolean;
|
|
258
|
+
type: "relationship";
|
|
259
|
+
relatedCollection: string;
|
|
260
|
+
relationType: "oneToMany" | "manyToOne" | "oneToOne" | "manyToMany";
|
|
261
|
+
twoWay: boolean;
|
|
262
|
+
onDelete: "setNull" | "cascade" | "restrict";
|
|
263
|
+
array?: boolean | undefined;
|
|
264
|
+
format?: string | undefined;
|
|
265
|
+
status?: string | undefined;
|
|
266
|
+
attributes?: string[] | undefined;
|
|
267
|
+
orders?: string[] | undefined;
|
|
268
|
+
$createdAt?: string | undefined;
|
|
269
|
+
$updatedAt?: string | undefined;
|
|
262
270
|
error?: string | undefined;
|
|
263
|
-
|
|
271
|
+
twoWayKey?: string | undefined;
|
|
272
|
+
side?: "parent" | "child" | undefined;
|
|
273
|
+
importMapping?: {
|
|
274
|
+
originalIdField: string;
|
|
275
|
+
targetField?: string | undefined;
|
|
276
|
+
} | undefined;
|
|
277
|
+
} | {
|
|
278
|
+
key: string;
|
|
279
|
+
required: boolean;
|
|
280
|
+
type: "string";
|
|
281
|
+
size: number;
|
|
264
282
|
array?: boolean | undefined;
|
|
283
|
+
format?: string | undefined;
|
|
284
|
+
status?: string | undefined;
|
|
285
|
+
attributes?: string[] | undefined;
|
|
286
|
+
orders?: string[] | undefined;
|
|
287
|
+
$createdAt?: string | undefined;
|
|
288
|
+
$updatedAt?: string | undefined;
|
|
289
|
+
error?: string | undefined;
|
|
290
|
+
xdefault?: string | null | undefined;
|
|
291
|
+
encrypted?: boolean | undefined;
|
|
292
|
+
} | {
|
|
293
|
+
key: string;
|
|
294
|
+
required: boolean;
|
|
295
|
+
type: "double";
|
|
296
|
+
array?: boolean | undefined;
|
|
297
|
+
format?: string | undefined;
|
|
298
|
+
status?: string | undefined;
|
|
299
|
+
attributes?: string[] | undefined;
|
|
300
|
+
orders?: string[] | undefined;
|
|
301
|
+
$createdAt?: string | undefined;
|
|
302
|
+
$updatedAt?: string | undefined;
|
|
303
|
+
error?: string | undefined;
|
|
265
304
|
min?: number | undefined;
|
|
266
305
|
max?: number | undefined;
|
|
267
306
|
xdefault?: number | null | undefined;
|
|
268
307
|
} | {
|
|
269
308
|
key: string;
|
|
309
|
+
required: boolean;
|
|
270
310
|
type: "float";
|
|
271
|
-
error?: string | undefined;
|
|
272
|
-
required?: boolean | undefined;
|
|
273
311
|
array?: boolean | undefined;
|
|
312
|
+
format?: string | undefined;
|
|
313
|
+
status?: string | undefined;
|
|
314
|
+
attributes?: string[] | undefined;
|
|
315
|
+
orders?: string[] | undefined;
|
|
316
|
+
$createdAt?: string | undefined;
|
|
317
|
+
$updatedAt?: string | undefined;
|
|
318
|
+
error?: string | undefined;
|
|
274
319
|
min?: number | undefined;
|
|
275
320
|
max?: number | undefined;
|
|
276
321
|
xdefault?: number | null | undefined;
|
|
277
322
|
} | {
|
|
278
323
|
key: string;
|
|
324
|
+
required: boolean;
|
|
279
325
|
type: "boolean";
|
|
280
|
-
error?: string | undefined;
|
|
281
|
-
required?: boolean | undefined;
|
|
282
326
|
array?: boolean | undefined;
|
|
327
|
+
format?: string | undefined;
|
|
328
|
+
status?: string | undefined;
|
|
329
|
+
attributes?: string[] | undefined;
|
|
330
|
+
orders?: string[] | undefined;
|
|
331
|
+
$createdAt?: string | undefined;
|
|
332
|
+
$updatedAt?: string | undefined;
|
|
333
|
+
error?: string | undefined;
|
|
283
334
|
xdefault?: boolean | null | undefined;
|
|
284
335
|
} | {
|
|
285
336
|
key: string;
|
|
337
|
+
required: boolean;
|
|
286
338
|
type: "datetime";
|
|
287
|
-
error?: string | undefined;
|
|
288
|
-
required?: boolean | undefined;
|
|
289
339
|
array?: boolean | undefined;
|
|
340
|
+
format?: string | undefined;
|
|
341
|
+
status?: string | undefined;
|
|
342
|
+
attributes?: string[] | undefined;
|
|
343
|
+
orders?: string[] | undefined;
|
|
344
|
+
$createdAt?: string | undefined;
|
|
345
|
+
$updatedAt?: string | undefined;
|
|
346
|
+
error?: string | undefined;
|
|
290
347
|
xdefault?: string | null | undefined;
|
|
291
348
|
} | {
|
|
292
349
|
key: string;
|
|
350
|
+
required: boolean;
|
|
293
351
|
type: "email";
|
|
294
|
-
error?: string | undefined;
|
|
295
|
-
required?: boolean | undefined;
|
|
296
352
|
array?: boolean | undefined;
|
|
353
|
+
format?: string | undefined;
|
|
354
|
+
status?: string | undefined;
|
|
355
|
+
attributes?: string[] | undefined;
|
|
356
|
+
orders?: string[] | undefined;
|
|
357
|
+
$createdAt?: string | undefined;
|
|
358
|
+
$updatedAt?: string | undefined;
|
|
359
|
+
error?: string | undefined;
|
|
297
360
|
xdefault?: string | null | undefined;
|
|
298
361
|
} | {
|
|
299
362
|
key: string;
|
|
363
|
+
required: boolean;
|
|
300
364
|
type: "ip";
|
|
301
|
-
error?: string | undefined;
|
|
302
|
-
required?: boolean | undefined;
|
|
303
365
|
array?: boolean | undefined;
|
|
366
|
+
format?: string | undefined;
|
|
367
|
+
status?: string | undefined;
|
|
368
|
+
attributes?: string[] | undefined;
|
|
369
|
+
orders?: string[] | undefined;
|
|
370
|
+
$createdAt?: string | undefined;
|
|
371
|
+
$updatedAt?: string | undefined;
|
|
372
|
+
error?: string | undefined;
|
|
304
373
|
xdefault?: string | null | undefined;
|
|
305
374
|
} | {
|
|
306
375
|
key: string;
|
|
376
|
+
required: boolean;
|
|
307
377
|
type: "url";
|
|
308
|
-
error?: string | undefined;
|
|
309
|
-
required?: boolean | undefined;
|
|
310
378
|
array?: boolean | undefined;
|
|
379
|
+
format?: string | undefined;
|
|
380
|
+
status?: string | undefined;
|
|
381
|
+
attributes?: string[] | undefined;
|
|
382
|
+
orders?: string[] | undefined;
|
|
383
|
+
$createdAt?: string | undefined;
|
|
384
|
+
$updatedAt?: string | undefined;
|
|
385
|
+
error?: string | undefined;
|
|
311
386
|
xdefault?: string | null | undefined;
|
|
312
387
|
} | {
|
|
313
388
|
key: string;
|
|
389
|
+
required: boolean;
|
|
314
390
|
type: "enum";
|
|
315
391
|
elements: string[];
|
|
316
|
-
error?: string | undefined;
|
|
317
|
-
required?: boolean | undefined;
|
|
318
392
|
array?: boolean | undefined;
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
twoWay: boolean;
|
|
326
|
-
onDelete: "setNull" | "cascade" | "restrict";
|
|
393
|
+
format?: string | undefined;
|
|
394
|
+
status?: string | undefined;
|
|
395
|
+
attributes?: string[] | undefined;
|
|
396
|
+
orders?: string[] | undefined;
|
|
397
|
+
$createdAt?: string | undefined;
|
|
398
|
+
$updatedAt?: string | undefined;
|
|
327
399
|
error?: string | undefined;
|
|
328
|
-
|
|
329
|
-
array?: boolean | undefined;
|
|
330
|
-
twoWayKey?: string | undefined;
|
|
331
|
-
side?: "parent" | "child" | undefined;
|
|
332
|
-
importMapping?: {
|
|
333
|
-
originalIdField: string;
|
|
334
|
-
targetField?: string | undefined;
|
|
335
|
-
} | undefined;
|
|
400
|
+
xdefault?: string | null | undefined;
|
|
336
401
|
})[];
|
|
337
402
|
$permissions: {
|
|
338
403
|
permission: string;
|
|
@@ -387,104 +452,170 @@ export declare const createSessionPreservingYamlConfig: (configPath: string, ses
|
|
|
387
452
|
enabled?: boolean | undefined;
|
|
388
453
|
documentSecurity?: boolean | undefined;
|
|
389
454
|
databaseId?: string | undefined;
|
|
455
|
+
databaseIds?: string[] | undefined;
|
|
390
456
|
}[] | undefined;
|
|
391
457
|
tables?: {
|
|
392
458
|
attributes: ({
|
|
393
459
|
key: string;
|
|
394
|
-
|
|
395
|
-
size: number;
|
|
396
|
-
error?: string | undefined;
|
|
397
|
-
required?: boolean | undefined;
|
|
398
|
-
array?: boolean | undefined;
|
|
399
|
-
xdefault?: string | null | undefined;
|
|
400
|
-
encrypted?: boolean | undefined;
|
|
401
|
-
format?: string | null | undefined;
|
|
402
|
-
} | {
|
|
403
|
-
key: string;
|
|
460
|
+
required: boolean;
|
|
404
461
|
type: "integer";
|
|
405
|
-
error?: string | undefined;
|
|
406
|
-
required?: boolean | undefined;
|
|
407
462
|
array?: boolean | undefined;
|
|
463
|
+
format?: string | undefined;
|
|
464
|
+
status?: string | undefined;
|
|
465
|
+
attributes?: string[] | undefined;
|
|
466
|
+
orders?: string[] | undefined;
|
|
467
|
+
$createdAt?: string | undefined;
|
|
468
|
+
$updatedAt?: string | undefined;
|
|
469
|
+
error?: string | undefined;
|
|
408
470
|
min?: number | undefined;
|
|
409
471
|
max?: number | undefined;
|
|
410
472
|
xdefault?: number | null | undefined;
|
|
411
473
|
} | {
|
|
412
474
|
key: string;
|
|
413
|
-
|
|
475
|
+
required: boolean;
|
|
476
|
+
type: "relationship";
|
|
477
|
+
relatedCollection: string;
|
|
478
|
+
relationType: "oneToMany" | "manyToOne" | "oneToOne" | "manyToMany";
|
|
479
|
+
twoWay: boolean;
|
|
480
|
+
onDelete: "setNull" | "cascade" | "restrict";
|
|
481
|
+
array?: boolean | undefined;
|
|
482
|
+
format?: string | undefined;
|
|
483
|
+
status?: string | undefined;
|
|
484
|
+
attributes?: string[] | undefined;
|
|
485
|
+
orders?: string[] | undefined;
|
|
486
|
+
$createdAt?: string | undefined;
|
|
487
|
+
$updatedAt?: string | undefined;
|
|
414
488
|
error?: string | undefined;
|
|
415
|
-
|
|
489
|
+
twoWayKey?: string | undefined;
|
|
490
|
+
side?: "parent" | "child" | undefined;
|
|
491
|
+
importMapping?: {
|
|
492
|
+
originalIdField: string;
|
|
493
|
+
targetField?: string | undefined;
|
|
494
|
+
} | undefined;
|
|
495
|
+
} | {
|
|
496
|
+
key: string;
|
|
497
|
+
required: boolean;
|
|
498
|
+
type: "string";
|
|
499
|
+
size: number;
|
|
416
500
|
array?: boolean | undefined;
|
|
501
|
+
format?: string | undefined;
|
|
502
|
+
status?: string | undefined;
|
|
503
|
+
attributes?: string[] | undefined;
|
|
504
|
+
orders?: string[] | undefined;
|
|
505
|
+
$createdAt?: string | undefined;
|
|
506
|
+
$updatedAt?: string | undefined;
|
|
507
|
+
error?: string | undefined;
|
|
508
|
+
xdefault?: string | null | undefined;
|
|
509
|
+
encrypted?: boolean | undefined;
|
|
510
|
+
} | {
|
|
511
|
+
key: string;
|
|
512
|
+
required: boolean;
|
|
513
|
+
type: "double";
|
|
514
|
+
array?: boolean | undefined;
|
|
515
|
+
format?: string | undefined;
|
|
516
|
+
status?: string | undefined;
|
|
517
|
+
attributes?: string[] | undefined;
|
|
518
|
+
orders?: string[] | undefined;
|
|
519
|
+
$createdAt?: string | undefined;
|
|
520
|
+
$updatedAt?: string | undefined;
|
|
521
|
+
error?: string | undefined;
|
|
417
522
|
min?: number | undefined;
|
|
418
523
|
max?: number | undefined;
|
|
419
524
|
xdefault?: number | null | undefined;
|
|
420
525
|
} | {
|
|
421
526
|
key: string;
|
|
527
|
+
required: boolean;
|
|
422
528
|
type: "float";
|
|
423
|
-
error?: string | undefined;
|
|
424
|
-
required?: boolean | undefined;
|
|
425
529
|
array?: boolean | undefined;
|
|
530
|
+
format?: string | undefined;
|
|
531
|
+
status?: string | undefined;
|
|
532
|
+
attributes?: string[] | undefined;
|
|
533
|
+
orders?: string[] | undefined;
|
|
534
|
+
$createdAt?: string | undefined;
|
|
535
|
+
$updatedAt?: string | undefined;
|
|
536
|
+
error?: string | undefined;
|
|
426
537
|
min?: number | undefined;
|
|
427
538
|
max?: number | undefined;
|
|
428
539
|
xdefault?: number | null | undefined;
|
|
429
540
|
} | {
|
|
430
541
|
key: string;
|
|
542
|
+
required: boolean;
|
|
431
543
|
type: "boolean";
|
|
432
|
-
error?: string | undefined;
|
|
433
|
-
required?: boolean | undefined;
|
|
434
544
|
array?: boolean | undefined;
|
|
545
|
+
format?: string | undefined;
|
|
546
|
+
status?: string | undefined;
|
|
547
|
+
attributes?: string[] | undefined;
|
|
548
|
+
orders?: string[] | undefined;
|
|
549
|
+
$createdAt?: string | undefined;
|
|
550
|
+
$updatedAt?: string | undefined;
|
|
551
|
+
error?: string | undefined;
|
|
435
552
|
xdefault?: boolean | null | undefined;
|
|
436
553
|
} | {
|
|
437
554
|
key: string;
|
|
555
|
+
required: boolean;
|
|
438
556
|
type: "datetime";
|
|
439
|
-
error?: string | undefined;
|
|
440
|
-
required?: boolean | undefined;
|
|
441
557
|
array?: boolean | undefined;
|
|
558
|
+
format?: string | undefined;
|
|
559
|
+
status?: string | undefined;
|
|
560
|
+
attributes?: string[] | undefined;
|
|
561
|
+
orders?: string[] | undefined;
|
|
562
|
+
$createdAt?: string | undefined;
|
|
563
|
+
$updatedAt?: string | undefined;
|
|
564
|
+
error?: string | undefined;
|
|
442
565
|
xdefault?: string | null | undefined;
|
|
443
566
|
} | {
|
|
444
567
|
key: string;
|
|
568
|
+
required: boolean;
|
|
445
569
|
type: "email";
|
|
446
|
-
error?: string | undefined;
|
|
447
|
-
required?: boolean | undefined;
|
|
448
570
|
array?: boolean | undefined;
|
|
571
|
+
format?: string | undefined;
|
|
572
|
+
status?: string | undefined;
|
|
573
|
+
attributes?: string[] | undefined;
|
|
574
|
+
orders?: string[] | undefined;
|
|
575
|
+
$createdAt?: string | undefined;
|
|
576
|
+
$updatedAt?: string | undefined;
|
|
577
|
+
error?: string | undefined;
|
|
449
578
|
xdefault?: string | null | undefined;
|
|
450
579
|
} | {
|
|
451
580
|
key: string;
|
|
581
|
+
required: boolean;
|
|
452
582
|
type: "ip";
|
|
453
|
-
error?: string | undefined;
|
|
454
|
-
required?: boolean | undefined;
|
|
455
583
|
array?: boolean | undefined;
|
|
584
|
+
format?: string | undefined;
|
|
585
|
+
status?: string | undefined;
|
|
586
|
+
attributes?: string[] | undefined;
|
|
587
|
+
orders?: string[] | undefined;
|
|
588
|
+
$createdAt?: string | undefined;
|
|
589
|
+
$updatedAt?: string | undefined;
|
|
590
|
+
error?: string | undefined;
|
|
456
591
|
xdefault?: string | null | undefined;
|
|
457
592
|
} | {
|
|
458
593
|
key: string;
|
|
594
|
+
required: boolean;
|
|
459
595
|
type: "url";
|
|
460
|
-
error?: string | undefined;
|
|
461
|
-
required?: boolean | undefined;
|
|
462
596
|
array?: boolean | undefined;
|
|
597
|
+
format?: string | undefined;
|
|
598
|
+
status?: string | undefined;
|
|
599
|
+
attributes?: string[] | undefined;
|
|
600
|
+
orders?: string[] | undefined;
|
|
601
|
+
$createdAt?: string | undefined;
|
|
602
|
+
$updatedAt?: string | undefined;
|
|
603
|
+
error?: string | undefined;
|
|
463
604
|
xdefault?: string | null | undefined;
|
|
464
605
|
} | {
|
|
465
606
|
key: string;
|
|
607
|
+
required: boolean;
|
|
466
608
|
type: "enum";
|
|
467
609
|
elements: string[];
|
|
468
|
-
error?: string | undefined;
|
|
469
|
-
required?: boolean | undefined;
|
|
470
610
|
array?: boolean | undefined;
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
twoWay: boolean;
|
|
478
|
-
onDelete: "setNull" | "cascade" | "restrict";
|
|
611
|
+
format?: string | undefined;
|
|
612
|
+
status?: string | undefined;
|
|
613
|
+
attributes?: string[] | undefined;
|
|
614
|
+
orders?: string[] | undefined;
|
|
615
|
+
$createdAt?: string | undefined;
|
|
616
|
+
$updatedAt?: string | undefined;
|
|
479
617
|
error?: string | undefined;
|
|
480
|
-
|
|
481
|
-
array?: boolean | undefined;
|
|
482
|
-
twoWayKey?: string | undefined;
|
|
483
|
-
side?: "parent" | "child" | undefined;
|
|
484
|
-
importMapping?: {
|
|
485
|
-
originalIdField: string;
|
|
486
|
-
targetField?: string | undefined;
|
|
487
|
-
} | undefined;
|
|
618
|
+
xdefault?: string | null | undefined;
|
|
488
619
|
})[];
|
|
489
620
|
columns: undefined;
|
|
490
621
|
indexes: {
|
|
@@ -541,7 +672,9 @@ export declare const createSessionPreservingYamlConfig: (configPath: string, ses
|
|
|
541
672
|
enabled?: boolean | undefined;
|
|
542
673
|
documentSecurity?: boolean | undefined;
|
|
543
674
|
databaseId?: string | undefined;
|
|
675
|
+
databaseIds?: string[] | undefined;
|
|
544
676
|
tableId?: string | undefined;
|
|
677
|
+
rowSecurity?: boolean | undefined;
|
|
545
678
|
}[] | undefined;
|
|
546
679
|
functions?: {
|
|
547
680
|
$id: string;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* 3. Validate terminology consistency
|
|
8
8
|
* 4. Migrate between formats
|
|
9
9
|
*/
|
|
10
|
-
import type
|
|
10
|
+
import { type CollectionCreate } from "appwrite-utils";
|
|
11
11
|
/**
|
|
12
12
|
* Example 1: Generate YAML templates for both collection and table formats
|
|
13
13
|
*/
|
|
@@ -11,6 +11,7 @@ import { collectionToYaml, generateYamlTemplate, generateExampleYamls, convertTe
|
|
|
11
11
|
import { createYamlLoader } from "../utils/yamlLoader.js";
|
|
12
12
|
import { YamlImportIntegration } from "../migrations/yaml/YamlImportIntegration.js";
|
|
13
13
|
import { createImportSchemas } from "../migrations/yaml/generateImportSchemas.js";
|
|
14
|
+
import { CollectionCreateSchema } from "appwrite-utils";
|
|
14
15
|
import fs from "fs";
|
|
15
16
|
import path from "path";
|
|
16
17
|
/**
|
|
@@ -208,7 +209,7 @@ export async function runYamlTerminologyExamples(outputDir) {
|
|
|
208
209
|
console.log("🎯 Running YAML Terminology Examples\\n");
|
|
209
210
|
try {
|
|
210
211
|
// Example collection for demonstrations
|
|
211
|
-
const
|
|
212
|
+
const exampleCollectionInput = {
|
|
212
213
|
name: "Product",
|
|
213
214
|
$id: "product",
|
|
214
215
|
enabled: true,
|
|
@@ -223,7 +224,7 @@ export async function runYamlTerminologyExamples(outputDir) {
|
|
|
223
224
|
},
|
|
224
225
|
{
|
|
225
226
|
key: "price",
|
|
226
|
-
type: "
|
|
227
|
+
type: "double",
|
|
227
228
|
required: true,
|
|
228
229
|
min: 0
|
|
229
230
|
},
|
|
@@ -233,7 +234,8 @@ export async function runYamlTerminologyExamples(outputDir) {
|
|
|
233
234
|
relationType: "manyToOne",
|
|
234
235
|
relatedCollection: "Categories",
|
|
235
236
|
twoWay: false,
|
|
236
|
-
onDelete: "setNull"
|
|
237
|
+
onDelete: "setNull",
|
|
238
|
+
required: false
|
|
237
239
|
}
|
|
238
240
|
],
|
|
239
241
|
indexes: [
|
|
@@ -245,6 +247,7 @@ export async function runYamlTerminologyExamples(outputDir) {
|
|
|
245
247
|
],
|
|
246
248
|
importDefs: []
|
|
247
249
|
};
|
|
250
|
+
const exampleCollection = CollectionCreateSchema.parse(exampleCollectionInput);
|
|
248
251
|
// Run examples
|
|
249
252
|
await generateTemplateExamples(outputDir);
|
|
250
253
|
console.log("\\n" + "=".repeat(60) + "\\n");
|
|
@@ -11,23 +11,7 @@ import { execSync } from "child_process";
|
|
|
11
11
|
import { createFunction, getFunction, updateFunction, updateFunctionSpecifications, } from "./methods.js";
|
|
12
12
|
import ignore from "ignore";
|
|
13
13
|
import { MessageFormatter } from "../shared/messageFormatter.js";
|
|
14
|
-
|
|
15
|
-
const normalizedName = functionName.toLowerCase().replace(/\s+/g, "-");
|
|
16
|
-
const dirs = fs.readdirSync(basePath, { withFileTypes: true });
|
|
17
|
-
for (const dir of dirs) {
|
|
18
|
-
if (dir.isDirectory()) {
|
|
19
|
-
const fullPath = join(basePath, dir.name);
|
|
20
|
-
if (dir.name.toLowerCase() === normalizedName) {
|
|
21
|
-
return fullPath;
|
|
22
|
-
}
|
|
23
|
-
const nestedResult = findFunctionDirectory(fullPath, functionName);
|
|
24
|
-
if (nestedResult) {
|
|
25
|
-
return nestedResult;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return undefined;
|
|
30
|
-
};
|
|
14
|
+
import { resolveFunctionDirectory, validateFunctionDirectory } from './pathResolution.js';
|
|
31
15
|
export const deployFunction = async (client, functionId, codePath, activate = true, entrypoint = "index.js", commands = "npm install", ignored = [
|
|
32
16
|
"node_modules",
|
|
33
17
|
".git",
|
|
@@ -123,12 +107,10 @@ export const deployLocalFunction = async (client, functionName, functionConfig,
|
|
|
123
107
|
catch (error) {
|
|
124
108
|
functionExists = false;
|
|
125
109
|
}
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if (!fs.existsSync(resolvedPath)) {
|
|
131
|
-
throw new Error(`Function directory not found at ${resolvedPath}`);
|
|
110
|
+
const configDirPath = process.cwd(); // TODO: This should be passed from caller
|
|
111
|
+
const resolvedPath = resolveFunctionDirectory(functionName, configDirPath, functionConfig.dirPath, functionPath);
|
|
112
|
+
if (!validateFunctionDirectory(resolvedPath)) {
|
|
113
|
+
throw new Error(`Function directory is invalid or missing required files: ${resolvedPath}`);
|
|
132
114
|
}
|
|
133
115
|
if (functionConfig.predeployCommands?.length) {
|
|
134
116
|
MessageFormatter.processing("Executing predeploy commands...", { prefix: "Deployment" });
|