@almadar/server 1.0.13 → 1.0.14
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/index.d.ts +2 -0
- package/dist/index.js +497 -1
- package/dist/index.js.map +1 -1
- package/dist/stores/index.d.ts +167 -0
- package/dist/stores/index.js +594 -0
- package/dist/stores/index.js.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { OrbitalSchema, SnapshotDocument, SaveOptions, SaveResult, AppSummary, StatsView, ChangeSetDocument, ValidationResults, CategorizedRemovals, PageContentReduction } from '@almadar/core';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Firestore Serialization Utilities
|
|
5
|
+
*
|
|
6
|
+
* Handles the Firestore 20-level depth limit by serializing deeply nested
|
|
7
|
+
* OrbitalSchema fields (orbitals, traits, services) to JSON strings.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Convert OrbitalSchema to Firestore-safe format.
|
|
12
|
+
*
|
|
13
|
+
* Serializes orbitals, traits, and services to JSON strings to avoid
|
|
14
|
+
* Firestore's 20-level nesting limit.
|
|
15
|
+
*/
|
|
16
|
+
declare function toFirestoreFormat(schema: OrbitalSchema): Record<string, unknown>;
|
|
17
|
+
/**
|
|
18
|
+
* Convert Firestore document back to OrbitalSchema.
|
|
19
|
+
*
|
|
20
|
+
* Deserializes JSON strings back to arrays.
|
|
21
|
+
*/
|
|
22
|
+
declare function fromFirestoreFormat(data: Record<string, unknown>): OrbitalSchema;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* SnapshotStore - Firestore CRUD for schema snapshots
|
|
26
|
+
*
|
|
27
|
+
* Snapshots are full copies of the schema at a point in time,
|
|
28
|
+
* stored in subcollection: users/{uid}/apps/{appId}/snapshots/{snapshotId}
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
declare class SnapshotStore {
|
|
32
|
+
private appsCollection;
|
|
33
|
+
constructor(appsCollection?: string);
|
|
34
|
+
private getCollectionPath;
|
|
35
|
+
private getAppDocPath;
|
|
36
|
+
/** Create a snapshot of the current schema */
|
|
37
|
+
create(uid: string, appId: string, schema: OrbitalSchema, reason: string): Promise<string>;
|
|
38
|
+
/** Get all snapshots for an app (ordered by timestamp desc) */
|
|
39
|
+
getAll(uid: string, appId: string): Promise<SnapshotDocument[]>;
|
|
40
|
+
/** Get a specific snapshot by ID */
|
|
41
|
+
get(uid: string, appId: string, snapshotId: string): Promise<SnapshotDocument | null>;
|
|
42
|
+
/** Delete a snapshot */
|
|
43
|
+
delete(uid: string, appId: string, snapshotId: string): Promise<boolean>;
|
|
44
|
+
/** Get schema snapshot at a specific version */
|
|
45
|
+
getByVersion(uid: string, appId: string, version: number): Promise<OrbitalSchema | null>;
|
|
46
|
+
/** Get the schema from a snapshot (deserialized) */
|
|
47
|
+
getSchemaFromSnapshot(snapshot: SnapshotDocument): OrbitalSchema;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* SchemaStore - Firestore CRUD for OrbitalSchema documents
|
|
52
|
+
*
|
|
53
|
+
* Handles schema get/save/create/delete/list with caching
|
|
54
|
+
* and Firestore serialization.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
declare class SchemaStore {
|
|
58
|
+
private appsCollection;
|
|
59
|
+
private schemaCache;
|
|
60
|
+
private listCache;
|
|
61
|
+
private protectionService;
|
|
62
|
+
private snapshotStore;
|
|
63
|
+
constructor(appsCollection?: string);
|
|
64
|
+
/** Set snapshot store for auto-snapshot on destructive saves */
|
|
65
|
+
setSnapshotStore(store: SnapshotStore): void;
|
|
66
|
+
/** Get a schema by app ID */
|
|
67
|
+
get(uid: string, appId: string): Promise<OrbitalSchema | null>;
|
|
68
|
+
/**
|
|
69
|
+
* Save a schema (create or full replace).
|
|
70
|
+
*
|
|
71
|
+
* Features:
|
|
72
|
+
* - Detects destructive changes (removals)
|
|
73
|
+
* - Requires confirmation for critical removals
|
|
74
|
+
* - Auto-creates snapshots before destructive changes (if SnapshotStore attached)
|
|
75
|
+
*/
|
|
76
|
+
save(uid: string, appId: string, schema: OrbitalSchema, options?: SaveOptions): Promise<SaveResult>;
|
|
77
|
+
/** Create a new app with initial schema */
|
|
78
|
+
create(uid: string, metadata: {
|
|
79
|
+
name: string;
|
|
80
|
+
description?: string;
|
|
81
|
+
}): Promise<{
|
|
82
|
+
appId: string;
|
|
83
|
+
schema: OrbitalSchema;
|
|
84
|
+
}>;
|
|
85
|
+
/** Delete an app */
|
|
86
|
+
delete(uid: string, appId: string): Promise<boolean>;
|
|
87
|
+
/** List all apps for a user */
|
|
88
|
+
list(uid: string): Promise<AppSummary[]>;
|
|
89
|
+
/** Compute stats from OrbitalSchema */
|
|
90
|
+
computeStats(schema: OrbitalSchema): StatsView;
|
|
91
|
+
/** Invalidate caches for a specific app */
|
|
92
|
+
invalidateCache(uid: string, appId: string): void;
|
|
93
|
+
/** Clear all caches */
|
|
94
|
+
clearCaches(): void;
|
|
95
|
+
/** Get the collection path for an app */
|
|
96
|
+
getAppDocPath(uid: string, appId: string): string;
|
|
97
|
+
/** Expose apps collection name for subcollection stores */
|
|
98
|
+
getAppsCollection(): string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* ChangeSetStore - Firestore CRUD for schema changesets
|
|
103
|
+
*
|
|
104
|
+
* Changesets track changes made to the schema over time,
|
|
105
|
+
* stored in subcollection: users/{uid}/apps/{appId}/changesets/{changeSetId}
|
|
106
|
+
*/
|
|
107
|
+
|
|
108
|
+
declare class ChangeSetStore {
|
|
109
|
+
private appsCollection;
|
|
110
|
+
constructor(appsCollection?: string);
|
|
111
|
+
private getCollectionPath;
|
|
112
|
+
private getAppDocPath;
|
|
113
|
+
/** Append a changeset to history */
|
|
114
|
+
append(uid: string, appId: string, changeSet: ChangeSetDocument): Promise<void>;
|
|
115
|
+
/** Get change history for an app (ordered by version desc) */
|
|
116
|
+
getHistory(uid: string, appId: string): Promise<ChangeSetDocument[]>;
|
|
117
|
+
/** Get a specific changeset by ID */
|
|
118
|
+
get(uid: string, appId: string, changeSetId: string): Promise<ChangeSetDocument | null>;
|
|
119
|
+
/** Update a changeset's status */
|
|
120
|
+
updateStatus(uid: string, appId: string, changeSetId: string, status: 'applied' | 'reverted' | 'pending'): Promise<void>;
|
|
121
|
+
/** Delete a changeset */
|
|
122
|
+
delete(uid: string, appId: string, changeSetId: string): Promise<boolean>;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* ValidationStore - Firestore CRUD for validation results
|
|
127
|
+
*
|
|
128
|
+
* Validation results stored at: users/{uid}/apps/{appId}/validation/current
|
|
129
|
+
*/
|
|
130
|
+
|
|
131
|
+
declare class ValidationStore {
|
|
132
|
+
private appsCollection;
|
|
133
|
+
constructor(appsCollection?: string);
|
|
134
|
+
private getDocPath;
|
|
135
|
+
private getAppDocPath;
|
|
136
|
+
/** Save validation results */
|
|
137
|
+
save(uid: string, appId: string, results: ValidationResults): Promise<void>;
|
|
138
|
+
/** Get validation results */
|
|
139
|
+
get(uid: string, appId: string): Promise<ValidationResults | null>;
|
|
140
|
+
/** Clear validation results */
|
|
141
|
+
clear(uid: string, appId: string): Promise<void>;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* SchemaProtectionService - Detects destructive schema changes
|
|
146
|
+
*
|
|
147
|
+
* Uses real diff functions from @almadar/core to detect and categorize
|
|
148
|
+
* removals, page content reductions, and other destructive changes.
|
|
149
|
+
*/
|
|
150
|
+
|
|
151
|
+
declare class SchemaProtectionService {
|
|
152
|
+
/**
|
|
153
|
+
* Compare two schemas and detect destructive changes.
|
|
154
|
+
*
|
|
155
|
+
* Returns categorized removals including page content reductions.
|
|
156
|
+
*/
|
|
157
|
+
compareSchemas(before: OrbitalSchema, after: OrbitalSchema): {
|
|
158
|
+
isDestructive: boolean;
|
|
159
|
+
removals: CategorizedRemovals;
|
|
160
|
+
};
|
|
161
|
+
/** Check if critical removals require confirmation */
|
|
162
|
+
requiresConfirmation(removals: CategorizedRemovals): boolean;
|
|
163
|
+
/** Check for significant page content reductions */
|
|
164
|
+
hasSignificantContentReduction(reductions: PageContentReduction[]): boolean;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export { ChangeSetStore, SchemaProtectionService, SchemaStore, SnapshotStore, ValidationStore, fromFirestoreFormat, toFirestoreFormat };
|