@fireproof/core 0.21.0-dev-preview-6 → 0.21.0-dev-preview-7
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/blockstore/attachable-store.d.ts.map +1 -1
- package/blockstore/attachable-store.js +4 -5
- package/blockstore/attachable-store.js.map +1 -1
- package/blockstore/index.d.ts +2 -1
- package/blockstore/index.d.ts.map +1 -1
- package/blockstore/index.js +2 -1
- package/blockstore/index.js.map +1 -1
- package/blockstore/loader.d.ts +2 -1
- package/blockstore/loader.d.ts.map +1 -1
- package/blockstore/loader.js +41 -11
- package/blockstore/loader.js.map +1 -1
- package/blockstore/store.js +1 -1
- package/blockstore/store.js.map +1 -1
- package/blockstore/types.d.ts +0 -2
- package/blockstore/types.d.ts.map +1 -1
- package/blockstore/types.js.map +1 -1
- package/cli/main.js +112 -80
- package/database.d.ts +0 -1
- package/database.d.ts.map +1 -1
- package/database.js +0 -1
- package/database.js.map +1 -1
- package/deno.json +2 -2
- package/ledger.d.ts +3 -2
- package/ledger.d.ts.map +1 -1
- package/ledger.js +16 -19
- package/ledger.js.map +1 -1
- package/package.json +3 -4
- package/protocols/cloud/http-connection.d.ts +2 -1
- package/protocols/cloud/http-connection.d.ts.map +1 -1
- package/protocols/cloud/http-connection.js +1 -0
- package/protocols/cloud/http-connection.js.map +1 -1
- package/protocols/cloud/msg-types-data.d.ts +4 -4
- package/protocols/cloud/msg-types-data.d.ts.map +1 -1
- package/protocols/cloud/msg-types-data.js.map +1 -1
- package/protocols/cloud/msg-types-meta.d.ts +13 -13
- package/protocols/cloud/msg-types-meta.d.ts.map +1 -1
- package/protocols/cloud/msg-types-meta.js.map +1 -1
- package/protocols/cloud/msg-types-wal.d.ts +4 -4
- package/protocols/cloud/msg-types-wal.d.ts.map +1 -1
- package/protocols/cloud/msg-types-wal.js.map +1 -1
- package/protocols/cloud/msg-types.d.ts +33 -19
- package/protocols/cloud/msg-types.d.ts.map +1 -1
- package/protocols/cloud/msg-types.js +4 -1
- package/protocols/cloud/msg-types.js.map +1 -1
- package/protocols/cloud/msger.d.ts +54 -39
- package/protocols/cloud/msger.d.ts.map +1 -1
- package/protocols/cloud/msger.js +228 -107
- package/protocols/cloud/msger.js.map +1 -1
- package/protocols/cloud/ws-connection.d.ts +14 -3
- package/protocols/cloud/ws-connection.d.ts.map +1 -1
- package/protocols/cloud/ws-connection.js +73 -34
- package/protocols/cloud/ws-connection.js.map +1 -1
- package/protocols/dashboard/index.d.ts +4 -0
- package/protocols/dashboard/index.d.ts.map +1 -0
- package/protocols/dashboard/index.js +4 -0
- package/protocols/dashboard/index.js.map +1 -0
- package/protocols/dashboard/msg-api.d.ts +11 -0
- package/protocols/dashboard/msg-api.d.ts.map +1 -0
- package/protocols/dashboard/msg-api.js +55 -0
- package/protocols/dashboard/msg-api.js.map +1 -0
- package/protocols/dashboard/msg-is.d.ts +45 -0
- package/protocols/dashboard/msg-is.d.ts.map +1 -0
- package/protocols/dashboard/msg-is.js +63 -0
- package/protocols/dashboard/msg-is.js.map +1 -0
- package/protocols/dashboard/msg-types.d.ts +397 -0
- package/protocols/dashboard/msg-types.d.ts.map +1 -0
- package/protocols/dashboard/msg-types.js +4 -0
- package/protocols/dashboard/msg-types.js.map +1 -0
- package/protocols/index.d.ts +1 -0
- package/protocols/index.d.ts.map +1 -1
- package/protocols/index.js +1 -0
- package/protocols/index.js.map +1 -1
- package/react/types.d.ts +28 -8
- package/react/types.d.ts.map +1 -1
- package/react/use-attach.d.ts +9 -4
- package/react/use-attach.d.ts.map +1 -1
- package/react/use-attach.js +137 -43
- package/react/use-attach.js.map +1 -1
- package/react/use-fireproof.js +2 -2
- package/react/use-fireproof.js.map +1 -1
- package/runtime/gateways/cloud/gateway.d.ts +8 -8
- package/runtime/gateways/cloud/gateway.d.ts.map +1 -1
- package/runtime/gateways/cloud/gateway.js +17 -15
- package/runtime/gateways/cloud/gateway.js.map +1 -1
- package/runtime/gateways/cloud/to-cloud.d.ts +22 -9
- package/runtime/gateways/cloud/to-cloud.d.ts.map +1 -1
- package/runtime/gateways/cloud/to-cloud.js +75 -59
- package/runtime/gateways/cloud/to-cloud.js.map +1 -1
- package/runtime/gateways/file/key-bag-file.d.ts +1 -0
- package/runtime/gateways/file/key-bag-file.d.ts.map +1 -1
- package/runtime/gateways/file/key-bag-file.js +12 -0
- package/runtime/gateways/file/key-bag-file.js.map +1 -1
- package/runtime/gateways/indexeddb/gateway-impl.d.ts.map +1 -1
- package/runtime/gateways/indexeddb/gateway-impl.js.map +1 -1
- package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts +1 -0
- package/runtime/gateways/indexeddb/key-bag-indexeddb.d.ts.map +1 -1
- package/runtime/gateways/indexeddb/key-bag-indexeddb.js +6 -0
- package/runtime/gateways/indexeddb/key-bag-indexeddb.js.map +1 -1
- package/runtime/key-bag-memory.d.ts +1 -0
- package/runtime/key-bag-memory.d.ts.map +1 -1
- package/runtime/key-bag-memory.js +7 -0
- package/runtime/key-bag-memory.js.map +1 -1
- package/runtime/key-bag.d.ts +3 -0
- package/runtime/key-bag.d.ts.map +1 -1
- package/runtime/key-bag.js +6 -0
- package/runtime/key-bag.js.map +1 -1
- package/runtime/keyed-crypto.d.ts.map +1 -1
- package/runtime/keyed-crypto.js +5 -5
- package/runtime/keyed-crypto.js.map +1 -1
- package/tests/blockstore/keyed-crypto.test.ts +0 -150
- package/tests/blockstore/loader.test.ts +3 -2
- package/tests/blockstore/standalone.test.ts +1 -1
- package/tests/blockstore/transaction.test.ts +3 -3
- package/tests/fireproof/attachable.test.ts +1 -1
- package/tests/helpers.ts +7 -9
- package/tests/protocols/cloud/msger.test.ts +548 -0
- package/tests/react/use-all-docs.test.tsx +1 -2
- package/tests/react/use-fireproof-stability.test.tsx +1 -1
- package/types.d.ts +1 -2
- package/types.d.ts.map +1 -1
- package/use-fireproof/iframe-strategy.d.ts +5 -4
- package/use-fireproof/iframe-strategy.d.ts.map +1 -1
- package/use-fireproof/iframe-strategy.js +7 -11
- package/use-fireproof/iframe-strategy.js.map +1 -1
- package/use-fireproof/index.d.ts +6 -2
- package/use-fireproof/index.d.ts.map +1 -1
- package/use-fireproof/index.js +23 -3
- package/use-fireproof/index.js.map +1 -1
- package/use-fireproof/redirect-strategy.d.ts +11 -4
- package/use-fireproof/redirect-strategy.d.ts.map +1 -1
- package/use-fireproof/redirect-strategy.js +142 -20
- package/use-fireproof/redirect-strategy.js.map +1 -1
- package/utils.d.ts +5 -6
- package/utils.d.ts.map +1 -1
- package/utils.js +19 -67
- package/utils.js.map +1 -1
- package/tests/utils.test.ts +0 -192
package/tests/utils.test.ts
DELETED
@@ -1,192 +0,0 @@
|
|
1
|
-
import { describe, it, expect } from "vitest";
|
2
|
-
import { ensureURIDefaults } from "../src/utils.js";
|
3
|
-
import { BuildURI, Logger } from "@adviser/cement";
|
4
|
-
import { PARAM, StoreType, SuperThis } from "@fireproof/core"; // Assuming types are here
|
5
|
-
// import { mockSuperThis } from './helpers'; // We'll need a mock for SuperThis
|
6
|
-
|
7
|
-
// A minimal mock for SuperThis, to be expanded as needed
|
8
|
-
const mockSuperThisMinimal = (): Partial<SuperThis> => {
|
9
|
-
// Helper to create a LogBuilder mock part
|
10
|
-
// The LogBuilder interface is complex, so we mock only what's used by ensureURIDefaults
|
11
|
-
const createLogBuilder = (level: string) => ({
|
12
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
13
|
-
Msg: (_message: string) => ({
|
14
|
-
// Using _message for potentially unused parameter
|
15
|
-
AsError: () => new Error(`Mock Error from ${level}`),
|
16
|
-
// Log: () => { /* no-op */ }
|
17
|
-
}),
|
18
|
-
With: function () {
|
19
|
-
return this;
|
20
|
-
}, // Fluent interface
|
21
|
-
Stv: function () {
|
22
|
-
return this;
|
23
|
-
}, // Fluent interface
|
24
|
-
});
|
25
|
-
|
26
|
-
const loggerInstance = {
|
27
|
-
Error: () => createLogBuilder("Error"),
|
28
|
-
Info: () => createLogBuilder("Info"),
|
29
|
-
Warn: () => createLogBuilder("Warn"),
|
30
|
-
Debug: () => createLogBuilder("Debug"),
|
31
|
-
// Add stubs for other Logger methods/properties if ensureURIDefaults uses them
|
32
|
-
// For now, these are the ones that might be expected by the Logger type itself
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
34
|
-
Msg: (_message: string) => createLogBuilder("DefaultMsgLevel"), // Top-level Msg
|
35
|
-
Flush: async () => {
|
36
|
-
/* no-op */
|
37
|
-
},
|
38
|
-
levelHandler: {
|
39
|
-
/* minimal stub or actual mock if needed */
|
40
|
-
},
|
41
|
-
TxtEnDe: { encode: (s: string) => new Uint8Array(s.length), decode: (b: Uint8Array) => b.toString() },
|
42
|
-
Child: function () {
|
43
|
-
return this as unknown as Logger;
|
44
|
-
},
|
45
|
-
With: function () {
|
46
|
-
return this as unknown as Logger;
|
47
|
-
},
|
48
|
-
Stv: function () {
|
49
|
-
return this as unknown as Logger;
|
50
|
-
},
|
51
|
-
// ... and potentially other properties from the Logger interface if TS still complains
|
52
|
-
};
|
53
|
-
|
54
|
-
return {
|
55
|
-
logger: loggerInstance as unknown as Logger, // Using unknown as Logger for partial mock
|
56
|
-
// Add other SuperThis properties if ensureURIDefaults accesses them
|
57
|
-
};
|
58
|
-
};
|
59
|
-
|
60
|
-
describe("ensureURIDefaults", () => {
|
61
|
-
const baseUri = BuildURI.from("fireproof://mydatabase").URI();
|
62
|
-
const defaultName = "testDb";
|
63
|
-
|
64
|
-
it("should set STORE_KEY to insecure and apply store type when opts.public is true", () => {
|
65
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
66
|
-
const names = { name: defaultName };
|
67
|
-
const opts = { public: true };
|
68
|
-
const store: StoreType = "car";
|
69
|
-
|
70
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, baseUri, store);
|
71
|
-
|
72
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe("insecure");
|
73
|
-
expect(resultUri.getParam(PARAM.STORE)).toBe("car");
|
74
|
-
expect(resultUri.getParam(PARAM.NAME)).toBe(defaultName);
|
75
|
-
});
|
76
|
-
|
77
|
-
it("should use opts.storeKey when public is false and storeKey is provided", () => {
|
78
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
79
|
-
const names = { name: defaultName };
|
80
|
-
const opts = { public: false, storeKey: "customKey123" };
|
81
|
-
const store: StoreType = "car";
|
82
|
-
|
83
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, baseUri, store);
|
84
|
-
|
85
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe("customKey123");
|
86
|
-
expect(resultUri.getParam(PARAM.STORE)).toBe("car");
|
87
|
-
expect(resultUri.getParam(PARAM.NAME)).toBe(defaultName);
|
88
|
-
});
|
89
|
-
|
90
|
-
it("should use STORE_KEY from names.localURI when public is false and opts.storeKey is not set", () => {
|
91
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
92
|
-
const localStoreKey = "keyFromLocalURI";
|
93
|
-
const localUriWithKey = BuildURI.from("file:///another?storekey=" + localStoreKey).URI();
|
94
|
-
const names = { name: defaultName, localURI: localUriWithKey };
|
95
|
-
const opts = { public: false }; // storeKey is undefined
|
96
|
-
const store: StoreType = "wal";
|
97
|
-
|
98
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, baseUri, store);
|
99
|
-
|
100
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe(localStoreKey);
|
101
|
-
expect(resultUri.getParam(PARAM.STORE)).toBe("wal");
|
102
|
-
expect(resultUri.getParam(PARAM.NAME)).toBe(defaultName);
|
103
|
-
});
|
104
|
-
|
105
|
-
it("should generate a new STORE_KEY when public is false and no key is provided", () => {
|
106
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
107
|
-
const names = { name: defaultName, localURI: BuildURI.from("file:///clean").URI() }; // No store_key in localURI
|
108
|
-
const opts = { public: false }; // No storeKey in opts
|
109
|
-
const store: StoreType = "wal";
|
110
|
-
const initialUri = baseUri.clone();
|
111
|
-
|
112
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, initialUri, store);
|
113
|
-
|
114
|
-
const storeKey = resultUri.getParam(PARAM.STORE_KEY);
|
115
|
-
expect(storeKey).toBeDefined();
|
116
|
-
expect(storeKey).not.toBeNull();
|
117
|
-
expect(storeKey).not.toBe("insecure");
|
118
|
-
expect(typeof storeKey).toBe("string");
|
119
|
-
// Add a direct check to satisfy TypeScript's null/undefined check for storeKey
|
120
|
-
if (storeKey) {
|
121
|
-
expect(storeKey.length).toBeGreaterThan(0); // Ensure it's not an empty string
|
122
|
-
} else {
|
123
|
-
// This case should not be reached if the above expects pass, but it satisfies TS
|
124
|
-
expect(storeKey).toBe("actually a string"); // This will fail if storeKey is not a string, or null/undefined
|
125
|
-
}
|
126
|
-
expect(resultUri.getParam(PARAM.STORE)).toBe(store);
|
127
|
-
});
|
128
|
-
|
129
|
-
it('should preserve suffix if opts.public is true (and store is not "car")', () => {
|
130
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
131
|
-
const names = { name: defaultName };
|
132
|
-
const opts = { public: true };
|
133
|
-
const store: StoreType = "wal";
|
134
|
-
const suffixValue = "somesuffix";
|
135
|
-
const initialUriWithSuffix = BuildURI.from(baseUri).setParam(PARAM.SUFFIX, suffixValue).URI();
|
136
|
-
|
137
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, initialUriWithSuffix, store);
|
138
|
-
|
139
|
-
expect(resultUri.hasParam(PARAM.SUFFIX)).toBe(true);
|
140
|
-
expect(resultUri.getParam(PARAM.SUFFIX)).toBe(suffixValue);
|
141
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe("insecure");
|
142
|
-
});
|
143
|
-
|
144
|
-
it("should preserve suffix if opts.public is false", () => {
|
145
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
146
|
-
const names = { name: defaultName };
|
147
|
-
const opts = { public: false, storeKey: "somekey" }; // Provide a storeKey for private
|
148
|
-
const store: StoreType = "wal";
|
149
|
-
const suffixValue = "keepsuffix";
|
150
|
-
const initialUriWithSuffix = BuildURI.from(baseUri).setParam(PARAM.SUFFIX, suffixValue).URI();
|
151
|
-
|
152
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, initialUriWithSuffix, store);
|
153
|
-
|
154
|
-
expect(resultUri.hasParam(PARAM.SUFFIX)).toBe(true);
|
155
|
-
expect(resultUri.getParam(PARAM.SUFFIX)).toBe(suffixValue);
|
156
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe("somekey");
|
157
|
-
});
|
158
|
-
|
159
|
-
it("should generate STORE_KEY with -idx and set PARAM.INDEX when ctx.idx is true and public is false", () => {
|
160
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
161
|
-
const names = { name: defaultName }; // No localURI with storeKey
|
162
|
-
const opts = { public: false }; // No explicit storeKey
|
163
|
-
const store: StoreType = "wal";
|
164
|
-
const ctx = { idx: true };
|
165
|
-
|
166
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, baseUri, store, ctx);
|
167
|
-
|
168
|
-
expect(resultUri.hasParam(PARAM.INDEX)).toBe(true);
|
169
|
-
expect(resultUri.getParam(PARAM.INDEX)).toBe("idx");
|
170
|
-
// Assuming storeType2DataMetaWal('wal') results in 'wal' for the key name
|
171
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe(`@${defaultName}-wal-idx@`);
|
172
|
-
});
|
173
|
-
|
174
|
-
it("should use opts.uri as base and correctly apply other params (e.g., public affects STORE_KEY)", () => {
|
175
|
-
const sthis = mockSuperThisMinimal() as SuperThis;
|
176
|
-
const customUriString = "fireproof://custombase/path";
|
177
|
-
const optsUri = BuildURI.from(customUriString).URI();
|
178
|
-
const names = { name: defaultName };
|
179
|
-
// Set public to true to check interaction: STORE_KEY should be 'insecure'
|
180
|
-
const opts = { uri: optsUri, public: true };
|
181
|
-
const store: StoreType = "file"; // Changed 'data' to 'file' (a valid StoreType)
|
182
|
-
// This baseUri should be overridden by opts.uri
|
183
|
-
const originalUri = BuildURI.from("fireproof://original/ignored").URI();
|
184
|
-
|
185
|
-
const resultUri = ensureURIDefaults(sthis, names, opts, originalUri, store);
|
186
|
-
|
187
|
-
expect(resultUri.pathname.startsWith(optsUri.pathname)).toBe(true);
|
188
|
-
expect(resultUri.getParam(PARAM.STORE_KEY)).toBe("insecure");
|
189
|
-
expect(resultUri.getParam(PARAM.STORE)).toBe(store);
|
190
|
-
expect(resultUri.getParam(PARAM.NAME)).toBe(defaultName);
|
191
|
-
});
|
192
|
-
});
|