@cmpsbl/failsafe 3.0.0 → 3.4.0
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/README.md +14 -20
- package/dist/index.d.ts +28 -4
- package/dist/index.js +17 -9
- package/package.json +5 -21
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @cmpsbl/failsafe
|
|
2
2
|
|
|
3
|
-
CMPSBL® FAILSAFE —
|
|
3
|
+
> CMPSBL® FAILSAFE — Zero-dependency disaster recovery & platform migration engine.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@cmpsbl/failsafe)
|
|
4
6
|
|
|
5
7
|
## Install
|
|
6
8
|
|
|
@@ -8,33 +10,25 @@ CMPSBL® FAILSAFE — Disaster Recovery & Platform Migration Engine.
|
|
|
8
10
|
npm install @cmpsbl/failsafe
|
|
9
11
|
```
|
|
10
12
|
|
|
13
|
+
**Zero dependencies.** Builds standalone.
|
|
14
|
+
|
|
15
|
+
## Dependency Tier
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
Tier 1 (no deps — publish/install in any order)
|
|
19
|
+
```
|
|
20
|
+
|
|
11
21
|
## Usage
|
|
12
22
|
|
|
13
23
|
```typescript
|
|
14
|
-
import { createBackup, restore
|
|
24
|
+
import { createBackup, restore } from '@cmpsbl/failsafe';
|
|
15
25
|
|
|
16
|
-
// Backup
|
|
17
26
|
const backup = await createBackup({
|
|
18
|
-
supabaseUrl: 'https://
|
|
27
|
+
supabaseUrl: 'https://your-project.supabase.co',
|
|
19
28
|
supabaseKey: 'your-service-role-key',
|
|
20
29
|
});
|
|
21
|
-
|
|
22
|
-
// Restore
|
|
23
|
-
const result = await restore({
|
|
24
|
-
targetUrl: 'https://yyy.supabase.co',
|
|
25
|
-
targetKey: 'target-service-role-key',
|
|
26
|
-
backupData: myBackupData,
|
|
27
|
-
cleanRestore: true,
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
// Full migration
|
|
31
|
-
const migration = await migrate({
|
|
32
|
-
source: { supabaseUrl: '...', supabaseKey: '...' },
|
|
33
|
-
target: { targetUrl: '...', targetKey: '...' },
|
|
34
|
-
options: { cleanRestore: true, validateIntegrity: true },
|
|
35
|
-
});
|
|
36
30
|
```
|
|
37
31
|
|
|
38
32
|
## License
|
|
39
33
|
|
|
40
|
-
Apache-2.0 ©
|
|
34
|
+
Apache-2.0 — © CMPSBL®
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,36 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @cmpsbl/failsafe — Disaster Recovery & Platform Migration Engine
|
|
3
3
|
* Zero-dependency backup, restore, and migration toolkit.
|
|
4
|
+
* Includes first-contact Memory Stream integration.
|
|
4
5
|
*
|
|
5
6
|
* © CMPSBL® — All rights reserved.
|
|
6
7
|
*/
|
|
8
|
+
export interface MemoryChain {
|
|
9
|
+
id: string;
|
|
10
|
+
pattern: string;
|
|
11
|
+
adoption: string;
|
|
12
|
+
status: 'new' | 'captured' | 'applied' | 'exported';
|
|
13
|
+
discoveredAt: string;
|
|
14
|
+
domain: string;
|
|
15
|
+
confidence: number;
|
|
16
|
+
}
|
|
17
|
+
export interface CeremonyEvent {
|
|
18
|
+
phase: string;
|
|
19
|
+
message: string;
|
|
20
|
+
detail?: string;
|
|
21
|
+
progress?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface FirstContactConfig {
|
|
24
|
+
package: string;
|
|
25
|
+
domain: string;
|
|
26
|
+
endpoint?: string;
|
|
27
|
+
apiKey?: string;
|
|
28
|
+
autoDiscover?: boolean;
|
|
29
|
+
onDiscovery?: (chain: MemoryChain) => void;
|
|
30
|
+
onBoot?: (message: string) => void;
|
|
31
|
+
onCeremony?: (event: CeremonyEvent) => void;
|
|
32
|
+
silent?: boolean;
|
|
33
|
+
}
|
|
7
34
|
export interface BackupConfig {
|
|
8
35
|
/** Supabase project URL */
|
|
9
36
|
supabaseUrl: string;
|
|
@@ -39,13 +66,9 @@ export interface RestoreStep {
|
|
|
39
66
|
error?: string;
|
|
40
67
|
}
|
|
41
68
|
export interface RestoreConfig {
|
|
42
|
-
/** Target Supabase project URL */
|
|
43
69
|
targetUrl: string;
|
|
44
|
-
/** Target Supabase service role key */
|
|
45
70
|
targetKey: string;
|
|
46
|
-
/** Backup data to restore */
|
|
47
71
|
backupData: Record<string, unknown[]>;
|
|
48
|
-
/** Whether to drop existing data before restore */
|
|
49
72
|
cleanRestore?: boolean;
|
|
50
73
|
}
|
|
51
74
|
export interface RestoreResult {
|
|
@@ -73,3 +96,4 @@ export declare function migrate(config: MigrationConfig): Promise<{
|
|
|
73
96
|
backup: BackupResult;
|
|
74
97
|
restore: RestoreResult;
|
|
75
98
|
}>;
|
|
99
|
+
export declare function createFailsafeFirstContact(apiKey?: string): FirstContactConfig;
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* @cmpsbl/failsafe — Disaster Recovery & Platform Migration Engine
|
|
4
4
|
* Zero-dependency backup, restore, and migration toolkit.
|
|
5
|
+
* Includes first-contact Memory Stream integration.
|
|
5
6
|
*
|
|
6
7
|
* © CMPSBL® — All rights reserved.
|
|
7
8
|
*/
|
|
@@ -9,6 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
10
|
exports.createBackup = createBackup;
|
|
10
11
|
exports.restore = restore;
|
|
11
12
|
exports.migrate = migrate;
|
|
13
|
+
exports.createFailsafeFirstContact = createFailsafeFirstContact;
|
|
12
14
|
// ═══════════════════════════════════════════════════════════════
|
|
13
15
|
// §1 — Backup Engine
|
|
14
16
|
// ═══════════════════════════════════════════════════════════════
|
|
@@ -19,7 +21,6 @@ async function createBackup(config) {
|
|
|
19
21
|
let totalRows = 0;
|
|
20
22
|
let totalSize = 0;
|
|
21
23
|
try {
|
|
22
|
-
// Discover tables
|
|
23
24
|
const tables = config.tables?.length
|
|
24
25
|
? config.tables
|
|
25
26
|
: await discoverTables(config.supabaseUrl, config.supabaseKey);
|
|
@@ -28,12 +29,7 @@ async function createBackup(config) {
|
|
|
28
29
|
const data = await fetchTable(config.supabaseUrl, config.supabaseKey, table);
|
|
29
30
|
const json = JSON.stringify(data);
|
|
30
31
|
const checksum = simpleHash(json);
|
|
31
|
-
tableBackups.push({
|
|
32
|
-
table,
|
|
33
|
-
rowCount: data.length,
|
|
34
|
-
sizeBytes: json.length,
|
|
35
|
-
checksum,
|
|
36
|
-
});
|
|
32
|
+
tableBackups.push({ table, rowCount: data.length, sizeBytes: json.length, checksum });
|
|
37
33
|
totalRows += data.length;
|
|
38
34
|
totalSize += json.length;
|
|
39
35
|
}
|
|
@@ -139,7 +135,6 @@ async function migrate(config) {
|
|
|
139
135
|
restore: { success: false, steps: [], tablesRestored: 0, totalRows: 0, durationMs: 0 },
|
|
140
136
|
};
|
|
141
137
|
}
|
|
142
|
-
// Build backup data map (in real implementation, this comes from the actual backup data)
|
|
143
138
|
const restoreResult = await restore({
|
|
144
139
|
...config.target,
|
|
145
140
|
backupData: {},
|
|
@@ -157,7 +152,8 @@ async function discoverTables(url, key) {
|
|
|
157
152
|
if (!res.ok)
|
|
158
153
|
throw new Error(`Failed to discover tables: ${res.status}`);
|
|
159
154
|
const data = await res.json();
|
|
160
|
-
|
|
155
|
+
const defs = (data?.definitions ?? {});
|
|
156
|
+
return Object.keys(defs);
|
|
161
157
|
}
|
|
162
158
|
async function fetchTable(url, key, table) {
|
|
163
159
|
const res = await fetch(`${url}/rest/v1/${table}?select=*`, {
|
|
@@ -197,3 +193,15 @@ function simpleHash(str) {
|
|
|
197
193
|
}
|
|
198
194
|
return Math.abs(hash).toString(16).padStart(8, '0');
|
|
199
195
|
}
|
|
196
|
+
// ═══════════════════════════════════════════════════════════════
|
|
197
|
+
// First Contact — Failsafe Domain
|
|
198
|
+
// ═══════════════════════════════════════════════════════════════
|
|
199
|
+
function createFailsafeFirstContact(apiKey) {
|
|
200
|
+
return {
|
|
201
|
+
package: '@cmpsbl/failsafe',
|
|
202
|
+
domain: 'failsafe',
|
|
203
|
+
apiKey,
|
|
204
|
+
endpoint: 'https://bxodolqqczjuahwdrswy.supabase.co/functions/v1/substrate-api',
|
|
205
|
+
autoDiscover: true,
|
|
206
|
+
};
|
|
207
|
+
}
|
package/package.json
CHANGED
|
@@ -1,33 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cmpsbl/failsafe",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"description": "CMPSBL® FAILSAFE — Zero-dependency disaster recovery & platform migration engine",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
-
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
],
|
|
7
|
+
"files": ["dist"],
|
|
10
8
|
"scripts": {
|
|
11
9
|
"build": "tsc",
|
|
12
10
|
"prepublishOnly": "npm run build"
|
|
13
11
|
},
|
|
14
|
-
"keywords": [
|
|
15
|
-
"cmpsbl",
|
|
16
|
-
"failsafe",
|
|
17
|
-
"disaster-recovery",
|
|
18
|
-
"migration",
|
|
19
|
-
"backup",
|
|
20
|
-
"restore"
|
|
21
|
-
],
|
|
12
|
+
"keywords": ["cmpsbl", "failsafe", "disaster-recovery", "migration", "backup", "restore"],
|
|
22
13
|
"author": "Kenneth E Sweet Jr <promptfluid@gmail.com>",
|
|
23
14
|
"license": "Apache-2.0",
|
|
24
|
-
"repository": {
|
|
25
|
-
|
|
26
|
-
"url": "https://github.com/cmpsbl/failsafe"
|
|
27
|
-
},
|
|
28
|
-
"homepage": "https://cmpsbl.com/engines/failsafe",
|
|
29
|
-
"devDependencies": {
|
|
30
|
-
"@types/lodash": "^4.17.24",
|
|
31
|
-
"@types/lodash-es": "^4.17.12"
|
|
32
|
-
}
|
|
15
|
+
"repository": { "type": "git", "url": "https://github.com/cmpsbl/failsafe" },
|
|
16
|
+
"homepage": "https://cmpsbl.com/engines/failsafe"
|
|
33
17
|
}
|