@onyx.dev/onyx-database 0.1.4 → 0.1.6
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 +1 -1
- package/dist/gen/cli/generate.cjs +13 -7
- package/dist/gen/cli/generate.cjs.map +1 -1
- package/dist/index.cjs +25 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -202,7 +202,7 @@ declare class QueryResults<T> extends Array<T> {
|
|
|
202
202
|
* const results = new QueryResults(users, token, t => fetchMore(t));
|
|
203
203
|
* ```
|
|
204
204
|
*/
|
|
205
|
-
constructor(records: T
|
|
205
|
+
constructor(records: Iterable<T> | ArrayLike<T> | T | null | undefined, nextPage: string | null, fetcher?: (token: string) => Promise<QueryResults<T>>);
|
|
206
206
|
/**
|
|
207
207
|
* Returns the first record in the result set.
|
|
208
208
|
* @throws Error if the result set is empty.
|
package/dist/index.d.ts
CHANGED
|
@@ -202,7 +202,7 @@ declare class QueryResults<T> extends Array<T> {
|
|
|
202
202
|
* const results = new QueryResults(users, token, t => fetchMore(t));
|
|
203
203
|
* ```
|
|
204
204
|
*/
|
|
205
|
-
constructor(records: T
|
|
205
|
+
constructor(records: Iterable<T> | ArrayLike<T> | T | null | undefined, nextPage: string | null, fetcher?: (token: string) => Promise<QueryResults<T>>);
|
|
206
206
|
/**
|
|
207
207
|
* Returns the first record in the result set.
|
|
208
208
|
* @throws Error if the result set is empty.
|
package/dist/index.js
CHANGED
|
@@ -35,6 +35,12 @@ function dropUndefined(obj) {
|
|
|
35
35
|
}
|
|
36
36
|
return out;
|
|
37
37
|
}
|
|
38
|
+
async function nodeImport(spec) {
|
|
39
|
+
return import(
|
|
40
|
+
/* @vite-ignore */
|
|
41
|
+
spec
|
|
42
|
+
);
|
|
43
|
+
}
|
|
38
44
|
function readEnv(targetId) {
|
|
39
45
|
if (!gProcess?.env) return {};
|
|
40
46
|
const env = gProcess.env;
|
|
@@ -62,8 +68,8 @@ function readEnv(targetId) {
|
|
|
62
68
|
}
|
|
63
69
|
async function readProjectFile(databaseId) {
|
|
64
70
|
if (!isNode) return {};
|
|
65
|
-
const fs = await
|
|
66
|
-
const path = await
|
|
71
|
+
const fs = await nodeImport("node:fs/promises");
|
|
72
|
+
const path = await nodeImport("node:path");
|
|
67
73
|
const cwd = gProcess?.cwd?.() ?? ".";
|
|
68
74
|
const tryRead = async (p) => {
|
|
69
75
|
const txt = await fs.readFile(p, "utf8");
|
|
@@ -90,9 +96,9 @@ async function readProjectFile(databaseId) {
|
|
|
90
96
|
}
|
|
91
97
|
async function readHomeProfile(databaseId) {
|
|
92
98
|
if (!isNode) return {};
|
|
93
|
-
const fs = await
|
|
94
|
-
const os = await
|
|
95
|
-
const path = await
|
|
99
|
+
const fs = await nodeImport("node:fs/promises");
|
|
100
|
+
const os = await nodeImport("node:os");
|
|
101
|
+
const path = await nodeImport("node:path");
|
|
96
102
|
const home = os.homedir();
|
|
97
103
|
const dir = path.join(home, ".onyx");
|
|
98
104
|
const fileExists = async (p) => {
|
|
@@ -146,8 +152,8 @@ async function readHomeProfile(databaseId) {
|
|
|
146
152
|
}
|
|
147
153
|
async function readConfigPath(p) {
|
|
148
154
|
if (!isNode) return {};
|
|
149
|
-
const fs = await
|
|
150
|
-
const path = await
|
|
155
|
+
const fs = await nodeImport("node:fs/promises");
|
|
156
|
+
const path = await nodeImport("node:path");
|
|
151
157
|
const cwd = gProcess?.cwd?.() ?? ".";
|
|
152
158
|
const resolved = path.isAbsolute(p) ? p : path.resolve(cwd, p);
|
|
153
159
|
try {
|
|
@@ -513,7 +519,18 @@ var QueryResults = class extends Array {
|
|
|
513
519
|
* ```
|
|
514
520
|
*/
|
|
515
521
|
constructor(records, nextPage, fetcher) {
|
|
516
|
-
|
|
522
|
+
const items = (() => {
|
|
523
|
+
if (records == null) return [];
|
|
524
|
+
if (Array.isArray(records)) return records;
|
|
525
|
+
if (typeof records[Symbol.iterator] === "function") {
|
|
526
|
+
return Array.from(records);
|
|
527
|
+
}
|
|
528
|
+
if (typeof records.length === "number") {
|
|
529
|
+
return Array.from(records);
|
|
530
|
+
}
|
|
531
|
+
return [records];
|
|
532
|
+
})();
|
|
533
|
+
super(...items);
|
|
517
534
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
518
535
|
this.nextPage = nextPage;
|
|
519
536
|
this.fetcher = fetcher;
|