appwrite-utils
Advanced tools
Comparing version 0.9.3 to 0.9.4
@@ -1,4 +0,5 @@ | ||
export type { AppwriteConfig } from "@/migrations/schema"; | ||
export type { ConverterFunctions } from "@/migrations/converters"; | ||
export type { ValidationRules } from "@/migrations/validationRules"; | ||
export type { AfterImportActions } from "@/migrations/afterImportActions"; | ||
#!/usr/bin/env node | ||
export type { AppwriteConfig } from "@/migrations/schema.js"; | ||
export type { ConverterFunctions } from "@/migrations/converters.js"; | ||
export type { ValidationRules } from "@/migrations/validationRules.js"; | ||
export type { AfterImportActions } from "@/migrations/afterImportActions.js"; |
@@ -1,2 +0,2 @@ | ||
import type { AppwriteConfig } from "./schema"; | ||
import type { AppwriteConfig } from "./schema.js"; | ||
export interface AfterImportActions { | ||
@@ -3,0 +3,0 @@ [key: string]: (config: AppwriteConfig, ...args: any[]) => Promise<any>; |
import { type Databases, type Models } from "node-appwrite"; | ||
import type { Attribute } from "./schema"; | ||
import type { Attribute } from "./schema.js"; | ||
export declare const createOrUpdateAttribute: (db: Databases, dbId: string, collection: Models.Collection, attribute: Attribute) => Promise<void>; | ||
export declare const createUpdateCollectionAttributes: (db: Databases, dbId: string, collection: Models.Collection, attributes: Attribute[]) => Promise<void>; |
import { Databases, type Models } from "node-appwrite"; | ||
import type { AppwriteConfig, CollectionCreate } from "./schema"; | ||
import type { AppwriteConfig, CollectionCreate } from "./schema.js"; | ||
export declare const checkForCollection: (db: Databases, dbId: string, collection: Partial<CollectionCreate>) => Promise<Models.Collection | null>; | ||
@@ -4,0 +4,0 @@ export declare const fetchAndCacheCollectionByName: (db: Databases, dbId: string, collectionName: string) => Promise<Models.Collection | undefined>; |
@@ -1,2 +0,2 @@ | ||
import type { AppwriteConfig, Attribute } from "./schema"; | ||
import type { AppwriteConfig, Attribute } from "./schema.js"; | ||
export declare const categorizeCollectionByRelationshipSide: (attributes: Attribute[]) => "parent" | "mixed" | "child"; | ||
@@ -3,0 +3,0 @@ export declare const getDependencies: (attributes: Attribute[]) => string[]; |
import { type Databases, type Storage } from "node-appwrite"; | ||
import type { AppwriteConfig } from "./schema"; | ||
import { type ValidationRules } from "./validationRules"; | ||
import { type ConverterFunctions } from "./converters"; | ||
import { type AfterImportActions } from "./afterImportActions"; | ||
import type { AppwriteConfig } from "./schema.js"; | ||
import { type ValidationRules } from "./validationRules.js"; | ||
import { type ConverterFunctions } from "./converters.js"; | ||
import { type AfterImportActions } from "./afterImportActions.js"; | ||
type AttributeMappings = AppwriteConfig["collections"][number]["importDefs"][number]["attributeMappings"]; | ||
@@ -7,0 +7,0 @@ export declare class ImportDataActions { |
@@ -1,4 +0,4 @@ | ||
import { type Index } from "./schema"; | ||
import { type Index } from "./schema.js"; | ||
import { Databases, type Models } from "node-appwrite"; | ||
export declare const createOrUpdateIndex: (dbId: string, db: Databases, collectionId: string, index: Index) => Promise<Models.Index>; | ||
export declare const createOrUpdateIndexes: (dbId: string, db: Databases, collectionId: string, indexes: Index[]) => Promise<void>; |
import { type Databases, type Models } from "node-appwrite"; | ||
import type { Attribute } from "./schema"; | ||
import type { Attribute } from "./schema.js"; | ||
export interface QueuedOperation { | ||
@@ -4,0 +4,0 @@ type: "attribute"; |
import { Databases } from "node-appwrite"; | ||
import type { AppwriteConfig } from "./schema"; | ||
import type { AppwriteConfig } from "./schema.js"; | ||
export declare const findCollectionsWithRelationships: (config: AppwriteConfig) => Map<string, ({ | ||
@@ -4,0 +4,0 @@ key: string; |
@@ -1,3 +0,3 @@ | ||
import type { Attribute } from "./schema"; | ||
import type { Attribute } from "./schema.js"; | ||
export declare const createSchemaString: (name: string, attributes: Attribute[]) => string; | ||
export declare const typeToZod: (attribute: Attribute) => string; |
import { Databases, Storage } from "node-appwrite"; | ||
import { type AppwriteConfig } from "./schema"; | ||
import type { SetupOptions } from "@/utilsController"; | ||
import { type AppwriteConfig } from "./schema.js"; | ||
import type { SetupOptions } from "../utilsController.js"; | ||
export declare const setupMigrationDatabase: (config: AppwriteConfig) => Promise<void>; | ||
@@ -5,0 +5,0 @@ export declare const ensureDatabasesExist: (config: AppwriteConfig) => Promise<void>; |
import { Storage, Databases, type Models } from "node-appwrite"; | ||
import { type OperationCreate } from "./backup"; | ||
import type { AppwriteConfig } from "./schema"; | ||
import { type OperationCreate } from "./backup.js"; | ||
import type { AppwriteConfig } from "./schema.js"; | ||
export declare const logOperation: (db: Databases, dbId: string, operationDetails: OperationCreate, operationId?: string) => Promise<Models.Document>; | ||
@@ -5,0 +5,0 @@ export declare const initOrGetBackupStorage: (storage: Storage) => Promise<Models.Bucket>; |
@@ -0,1 +1,2 @@ | ||
#!/usr/bin/env node | ||
export {}; |
@@ -1,2 +0,2 @@ | ||
export * from "./helperFunctions"; | ||
export * from "./setupFiles"; | ||
export * from "./helperFunctions.js"; | ||
export * from "./setupFiles.js"; |
export declare const customDefinitionsFile = "import type { ConverterFunctions, ValidationRules, AfterImportActions } from \"appwrite-utils\";\n\nexport const customConverterFunctions: ConverterFunctions = {\n // Add your custom converter functions here\n}\nexport const customValidationRules: ValidationRules = {\n // Add your custom validation rules here\n}\nexport const customAfterImportActions: AfterImportActions = {\n // Add your custom after import actions here\n}"; | ||
export declare const setupDirsFiles: () => Promise<void>; | ||
export declare const setupDirsFiles: (example?: boolean) => Promise<void>; |
@@ -1,6 +0,6 @@ | ||
import { type AppwriteConfig } from "./migrations/schema"; | ||
import { ImportDataActions } from "./migrations/importDataActions"; | ||
import { type ConverterFunctions } from "./migrations/converters"; | ||
import { type AfterImportActions } from "./migrations/afterImportActions"; | ||
import { type ValidationRules } from "./migrations/validationRules"; | ||
import { type AppwriteConfig } from "./migrations/schema.js"; | ||
import { ImportDataActions } from "./migrations/importDataActions.js"; | ||
import { type ConverterFunctions } from "./migrations/converters.js"; | ||
import { type AfterImportActions } from "./migrations/afterImportActions.js"; | ||
import { type ValidationRules } from "./migrations/validationRules.js"; | ||
export interface SetupOptions { | ||
@@ -7,0 +7,0 @@ runProd: boolean; |
{ | ||
"name": "appwrite-utils", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more.", | ||
"bin": { | ||
"appwrite-utils-setup": "./dist/setup.js", | ||
"appwrite-utils-migrate": "./dist/main.js" | ||
"setup": "./dist/setup.js", | ||
"migrate": "./dist/main.js" | ||
}, | ||
@@ -9,0 +9,0 @@ "repository": { |
@@ -117,5 +117,7 @@ # AppwriteUtils Package | ||
- 0.9.2: Added `bin` section to package.json and "shebang" to top of `main.ts` and `setup.ts` to enable `npx` | ||
- 0.9.4: Turns out you gotta import js files in modules, whoops | ||
- 0.9.3: Added `bin` section to package.json and "shebang" to top of `main.ts` and `setup.ts` to enable `npx` | ||
- 0.9.2: I forget what I did here | ||
- 0.9.1: Ignore this one | ||
- 0.9.1: Added roadmap 😍 | ||
- 0.9.0: Initial refactor into AppwriteUtils package for ease of use |
#!/usr/bin/env node | ||
import { UtilsController } from "./utilsController"; | ||
export type { AppwriteConfig } from "@/migrations/schema"; | ||
export type { ConverterFunctions } from "@/migrations/converters"; | ||
export type { ValidationRules } from "@/migrations/validationRules"; | ||
export type { AfterImportActions } from "@/migrations/afterImportActions"; | ||
import { UtilsController } from "./utilsController.js"; | ||
export type { AppwriteConfig } from "@/migrations/schema.js"; | ||
export type { ConverterFunctions } from "@/migrations/converters.js"; | ||
export type { ValidationRules } from "@/migrations/validationRules.js"; | ||
export type { AfterImportActions } from "@/migrations/afterImportActions.js"; | ||
@@ -8,0 +8,0 @@ const args = process.argv.slice(2); |
import { Databases, Storage, InputFile, Query, ID } from "node-appwrite"; | ||
import type { AppwriteConfig } from "./schema"; | ||
import type { AppwriteConfig } from "./schema.js"; | ||
import path from "path"; | ||
@@ -4,0 +4,0 @@ import fs from "fs"; |
import { Query, type Databases, type Models } from "node-appwrite"; | ||
import type { Attribute } from "./schema"; | ||
import { nameToIdMapping, enqueueOperation } from "./queue"; | ||
import type { Attribute } from "./schema.js"; | ||
import { nameToIdMapping, enqueueOperation } from "./queue.js"; | ||
@@ -5,0 +5,0 @@ export const createOrUpdateAttribute = async ( |
@@ -7,3 +7,3 @@ import { z } from "zod"; | ||
CollectionCreateSchema, | ||
} from "./schema"; | ||
} from "./schema.js"; | ||
@@ -10,0 +10,0 @@ export const BackupSchema = z.object({ |
import { Databases, ID, Permission, Query, type Models } from "node-appwrite"; | ||
import type { AppwriteConfig, CollectionCreate } from "./schema"; | ||
import { nameToIdMapping, processQueue } from "./queue"; | ||
import { createUpdateCollectionAttributes } from "./attributes"; | ||
import { createOrUpdateIndexes } from "./indexes"; | ||
import type { AppwriteConfig, CollectionCreate } from "./schema.js"; | ||
import { nameToIdMapping, processQueue } from "./queue.js"; | ||
import { createUpdateCollectionAttributes } from "./attributes.js"; | ||
import { createOrUpdateIndexes } from "./indexes.js"; | ||
import { | ||
@@ -11,5 +11,5 @@ ensureDirectoryExistence, | ||
writeFileSync, | ||
} from "@/utils"; | ||
} from "../utils/index.js"; | ||
import _ from "lodash"; | ||
import { createSchemaString } from "./schemaStrings"; | ||
import { createSchemaString } from "./schemaStrings.js"; | ||
import path from "path"; | ||
@@ -16,0 +16,0 @@ |
import { DateTime } from "luxon"; | ||
import _ from "lodash"; | ||
import type { AppwriteConfig } from "./schema"; | ||
import type { AppwriteConfig } from "./schema.js"; | ||
@@ -5,0 +5,0 @@ const { cloneDeep, isObject } = _; |
@@ -5,3 +5,3 @@ import type { | ||
RelationshipAttribute, | ||
} from "./schema"; | ||
} from "./schema.js"; | ||
@@ -8,0 +8,0 @@ // Helper function to categorize collections based on relationship sides |
@@ -8,4 +8,4 @@ import { | ||
} from "node-appwrite"; | ||
import type { AppwriteConfig } from "./schema"; | ||
import validationRules, { type ValidationRules } from "./validationRules"; | ||
import type { AppwriteConfig } from "./schema.js"; | ||
import validationRules, { type ValidationRules } from "./validationRules.js"; | ||
import { | ||
@@ -15,7 +15,7 @@ converterFunctions, | ||
type ConverterFunctions, | ||
} from "./converters"; | ||
} from "./converters.js"; | ||
import { | ||
afterImportActions, | ||
type AfterImportActions, | ||
} from "./afterImportActions"; | ||
} from "./afterImportActions.js"; | ||
@@ -22,0 +22,0 @@ type AttributeMappings = |
@@ -1,2 +0,2 @@ | ||
import { indexSchema, type Index } from "./schema"; | ||
import { indexSchema, type Index } from "./schema.js"; | ||
import { Databases, Query, type Models } from "node-appwrite"; | ||
@@ -3,0 +3,0 @@ // import {} |
import { ID, Query, type Databases } from "node-appwrite"; | ||
import { OperationSchema } from "./backup"; | ||
import { OperationSchema } from "./backup.js"; | ||
@@ -4,0 +4,0 @@ export const findOrCreateOperation = async ( |
import { Query, type Databases, type Models } from "node-appwrite"; | ||
import type { Attribute } from "./schema"; | ||
import { createOrUpdateAttribute } from "./attributes"; | ||
import type { Attribute } from "./schema.js"; | ||
import { createOrUpdateAttribute } from "./attributes.js"; | ||
import _ from "lodash"; | ||
import { fetchAndCacheCollectionByName } from "./collections"; | ||
import { fetchAndCacheCollectionByName } from "./collections.js"; | ||
@@ -7,0 +7,0 @@ export interface QueuedOperation { |
import { Databases, Query, type Models } from "node-appwrite"; | ||
import { fetchAllCollections } from "./collections"; | ||
import { fetchAllCollections } from "./collections.js"; | ||
import type { | ||
@@ -7,3 +7,3 @@ AppwriteConfig, | ||
RelationshipAttribute, | ||
} from "./schema"; | ||
} from "./schema.js"; | ||
@@ -10,0 +10,0 @@ export const findCollectionsWithRelationships = (config: AppwriteConfig) => { |
@@ -1,3 +0,3 @@ | ||
import { toCamelCase, toPascalCase } from "@/utils"; | ||
import type { Attribute, RelationshipAttribute } from "./schema"; | ||
import { toCamelCase, toPascalCase } from "../utils/index.js"; | ||
import type { Attribute, RelationshipAttribute } from "./schema.js"; | ||
@@ -4,0 +4,0 @@ export const createSchemaString = ( |
import { Databases, ID, Query, Storage, type Models } from "node-appwrite"; | ||
import { createOrUpdateAttribute } from "./attributes"; | ||
import { createOrUpdateAttribute } from "./attributes.js"; | ||
import { | ||
@@ -7,5 +7,5 @@ createOrUpdateCollections, | ||
wipeDatabase, | ||
} from "./collections"; | ||
import { getMigrationCollectionSchemas } from "./backup"; | ||
import { areCollectionNamesSame, toCamelCase } from "@/utils"; | ||
} from "./collections.js"; | ||
import { getMigrationCollectionSchemas } from "./backup.js"; | ||
import { areCollectionNamesSame, toCamelCase } from "../utils/index.js"; | ||
import { | ||
@@ -15,6 +15,6 @@ backupDatabase, | ||
initOrGetDocumentStorage, | ||
} from "./storage"; | ||
import { type AppwriteConfig } from "./schema"; | ||
import type { SetupOptions } from "@/utilsController"; | ||
import { nameToIdMapping } from "./queue"; | ||
} from "./storage.js"; | ||
import { type AppwriteConfig } from "./schema.js"; | ||
import type { SetupOptions } from "../utilsController.js"; | ||
import { nameToIdMapping } from "./queue.js"; | ||
@@ -21,0 +21,0 @@ export const setupMigrationDatabase = async (config: AppwriteConfig) => { |
@@ -9,5 +9,5 @@ import { | ||
} from "node-appwrite"; | ||
import { type OperationCreate, type BackupCreate } from "./backup"; | ||
import { splitIntoBatches } from "./migrationHelper"; | ||
import type { AppwriteConfig } from "./schema"; | ||
import { type OperationCreate, type BackupCreate } from "./backup.js"; | ||
import { splitIntoBatches } from "./migrationHelper.js"; | ||
import type { AppwriteConfig } from "./schema.js"; | ||
@@ -14,0 +14,0 @@ export const logOperation = async ( |
#!/usr/bin/env node | ||
import { setupDirsFiles } from "./utils/setupFiles"; | ||
import { setupDirsFiles } from "./utils/setupFiles.js"; | ||
@@ -4,0 +4,0 @@ const args = process.argv.slice(2); |
@@ -1,2 +0,2 @@ | ||
export * from "./helperFunctions"; | ||
export * from "./setupFiles"; | ||
export * from "./helperFunctions.js"; | ||
export * from "./setupFiles.js"; |
import { mkdirSync, writeFileSync, existsSync } from "node:fs"; | ||
import path from "node:path"; | ||
import configSchema from "./configSchema.json"; | ||
import configSchema from "./configSchema.json" assert { type: "json" }; | ||
@@ -5,0 +5,0 @@ // Define our YAML files |
@@ -9,3 +9,3 @@ import { | ||
} from "node-appwrite"; | ||
import { startSetup } from "./migrations/setupDatabase"; | ||
import { startSetup } from "./migrations/setupDatabase.js"; | ||
import { | ||
@@ -15,7 +15,7 @@ type AppwriteConfig, | ||
type CollectionCreate, | ||
} from "./migrations/schema"; | ||
} from "./migrations/schema.js"; | ||
import path from "path"; | ||
import fs from "fs"; | ||
import { load } from "js-yaml"; | ||
import { ImportDataActions } from "./migrations/importDataActions"; | ||
import { ImportDataActions } from "./migrations/importDataActions.js"; | ||
import { | ||
@@ -25,14 +25,17 @@ converterFunctions, | ||
type ConverterFunctions, | ||
} from "./migrations/converters"; | ||
import { areCollectionNamesSame, readFileSync } from "./utils/helperFunctions"; | ||
import { checkForCollection } from "./migrations/collections"; | ||
import { resolveAndUpdateRelationships } from "./migrations/relationships"; | ||
import { documentExists } from "./migrations/queue"; | ||
} from "./migrations/converters.js"; | ||
import { | ||
areCollectionNamesSame, | ||
readFileSync, | ||
} from "./utils/helperFunctions.js"; | ||
import { checkForCollection } from "./migrations/collections.js"; | ||
import { resolveAndUpdateRelationships } from "./migrations/relationships.js"; | ||
import { documentExists } from "./migrations/queue.js"; | ||
import { | ||
afterImportActions, | ||
type AfterImportActions, | ||
} from "./migrations/afterImportActions"; | ||
} from "./migrations/afterImportActions.js"; | ||
import validationRules, { | ||
type ValidationRules, | ||
} from "./migrations/validationRules"; | ||
} from "./migrations/validationRules.js"; | ||
@@ -39,0 +42,0 @@ async function loadConfig(configPath: string) { |
{ | ||
"compilerOptions": { | ||
// Enable latest features | ||
"target": "ES2020", | ||
"module": "ES2020", | ||
"lib": ["ES2020"], | ||
"target": "ESNext", | ||
"module": "NodeNext", | ||
"lib": ["ESNext"], | ||
"moduleDetection": "force", | ||
@@ -12,9 +12,9 @@ "jsx": "react-jsx", | ||
"allowSyntheticDefaultImports": true, | ||
"resolveJsonModule": true, | ||
// Bundler mode | ||
"moduleResolution": "bundler", | ||
"allowImportingTsExtensions": true, | ||
"moduleResolution": "NodeNext", | ||
"verbatimModuleSyntax": true, | ||
"noEmit": false, | ||
"emitDeclarationOnly": true, | ||
"emitDeclarationOnly": false, | ||
@@ -21,0 +21,0 @@ // Best practices |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
2951584
81
12626
123
2