@xata.io/client 0.0.0-alpha.vea397e5 → 0.0.0-alpha.vec0bff6
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.cjs +23 -19
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +23 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -3846,7 +3846,6 @@ declare abstract class Repository<Data extends BaseData, Record extends XataReco
|
|
|
3846
3846
|
}
|
|
3847
3847
|
declare class RestRepository<Data extends BaseData, Record extends XataRecord = Data & XataRecord> extends Query<Record, SelectedPick<Record, ['*']>> implements Repository<Data, Record> {
|
|
3848
3848
|
#private;
|
|
3849
|
-
db: SchemaPluginResult<any>;
|
|
3850
3849
|
constructor(options: {
|
|
3851
3850
|
table: string;
|
|
3852
3851
|
db: SchemaPluginResult<any>;
|
|
@@ -4049,6 +4048,11 @@ interface ClientConstructor<Plugins extends Record<string, XataPlugin>> {
|
|
|
4049
4048
|
search: Awaited<ReturnType<SearchPlugin<SchemaInference<NonNullable<typeof schemaTables>>>['build']>>;
|
|
4050
4049
|
}, keyof Plugins> & {
|
|
4051
4050
|
[Key in StringKeys<NonNullable<Plugins>>]: Awaited<ReturnType<NonNullable<Plugins>[Key]['build']>>;
|
|
4051
|
+
} & {
|
|
4052
|
+
getConfig(): Promise<{
|
|
4053
|
+
databaseURL: string;
|
|
4054
|
+
branch: string;
|
|
4055
|
+
}>;
|
|
4052
4056
|
};
|
|
4053
4057
|
}
|
|
4054
4058
|
declare const BaseClient_base: ClientConstructor<{}>;
|
package/dist/index.mjs
CHANGED
|
@@ -128,7 +128,7 @@ function getFetchImplementation(userFetch) {
|
|
|
128
128
|
return fetchImpl;
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
-
const VERSION = "0.0.0-alpha.
|
|
131
|
+
const VERSION = "0.0.0-alpha.vec0bff6";
|
|
132
132
|
|
|
133
133
|
class ErrorWithCause extends Error {
|
|
134
134
|
constructor(message, options) {
|
|
@@ -1314,7 +1314,7 @@ var __privateMethod$2 = (obj, member, method) => {
|
|
|
1314
1314
|
__accessCheck$4(obj, member, "access private method");
|
|
1315
1315
|
return method;
|
|
1316
1316
|
};
|
|
1317
|
-
var _table, _getFetchProps, _cache, _schemaTables$2, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
|
|
1317
|
+
var _table, _getFetchProps, _db, _cache, _schemaTables$2, _insertRecordWithoutId, insertRecordWithoutId_fn, _insertRecordWithId, insertRecordWithId_fn, _bulkInsertTableRecords, bulkInsertTableRecords_fn, _updateRecordWithID, updateRecordWithID_fn, _upsertRecordWithID, upsertRecordWithID_fn, _deleteRecord, deleteRecord_fn, _setCacheQuery, setCacheQuery_fn, _getCacheQuery, getCacheQuery_fn, _getSchemaTables$1, getSchemaTables_fn$1;
|
|
1318
1318
|
class Repository extends Query {
|
|
1319
1319
|
}
|
|
1320
1320
|
class RestRepository extends Query {
|
|
@@ -1331,11 +1331,12 @@ class RestRepository extends Query {
|
|
|
1331
1331
|
__privateAdd$4(this, _getSchemaTables$1);
|
|
1332
1332
|
__privateAdd$4(this, _table, void 0);
|
|
1333
1333
|
__privateAdd$4(this, _getFetchProps, void 0);
|
|
1334
|
+
__privateAdd$4(this, _db, void 0);
|
|
1334
1335
|
__privateAdd$4(this, _cache, void 0);
|
|
1335
1336
|
__privateAdd$4(this, _schemaTables$2, void 0);
|
|
1336
1337
|
__privateSet$4(this, _table, options.table);
|
|
1337
1338
|
__privateSet$4(this, _getFetchProps, options.pluginOptions.getFetchProps);
|
|
1338
|
-
this
|
|
1339
|
+
__privateSet$4(this, _db, options.db);
|
|
1339
1340
|
__privateSet$4(this, _cache, options.pluginOptions.cache);
|
|
1340
1341
|
__privateSet$4(this, _schemaTables$2, options.schemaTables);
|
|
1341
1342
|
}
|
|
@@ -1387,7 +1388,7 @@ class RestRepository extends Query {
|
|
|
1387
1388
|
...fetchProps
|
|
1388
1389
|
});
|
|
1389
1390
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1390
|
-
return initObject(this
|
|
1391
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1391
1392
|
} catch (e) {
|
|
1392
1393
|
if (isObject(e) && e.status === 404) {
|
|
1393
1394
|
return null;
|
|
@@ -1472,7 +1473,7 @@ class RestRepository extends Query {
|
|
|
1472
1473
|
...fetchProps
|
|
1473
1474
|
});
|
|
1474
1475
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1475
|
-
return records.map((item) => initObject(this
|
|
1476
|
+
return records.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
|
1476
1477
|
}
|
|
1477
1478
|
async query(query) {
|
|
1478
1479
|
const cacheQuery = await __privateMethod$2(this, _getCacheQuery, getCacheQuery_fn).call(this, query);
|
|
@@ -1492,13 +1493,14 @@ class RestRepository extends Query {
|
|
|
1492
1493
|
...fetchProps
|
|
1493
1494
|
});
|
|
1494
1495
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1495
|
-
const records = objects.map((record) => initObject(this
|
|
1496
|
+
const records = objects.map((record) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), record));
|
|
1496
1497
|
await __privateMethod$2(this, _setCacheQuery, setCacheQuery_fn).call(this, query, meta, records);
|
|
1497
1498
|
return new Page(query, meta, records);
|
|
1498
1499
|
}
|
|
1499
1500
|
}
|
|
1500
1501
|
_table = new WeakMap();
|
|
1501
1502
|
_getFetchProps = new WeakMap();
|
|
1503
|
+
_db = new WeakMap();
|
|
1502
1504
|
_cache = new WeakMap();
|
|
1503
1505
|
_schemaTables$2 = new WeakMap();
|
|
1504
1506
|
_insertRecordWithoutId = new WeakSet();
|
|
@@ -1516,7 +1518,7 @@ insertRecordWithoutId_fn = async function(object, columns = ["*"]) {
|
|
|
1516
1518
|
...fetchProps
|
|
1517
1519
|
});
|
|
1518
1520
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1519
|
-
return initObject(this
|
|
1521
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1520
1522
|
};
|
|
1521
1523
|
_insertRecordWithId = new WeakSet();
|
|
1522
1524
|
insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
|
@@ -1534,7 +1536,7 @@ insertRecordWithId_fn = async function(recordId, object, columns = ["*"]) {
|
|
|
1534
1536
|
...fetchProps
|
|
1535
1537
|
});
|
|
1536
1538
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1537
|
-
return initObject(this
|
|
1539
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1538
1540
|
};
|
|
1539
1541
|
_bulkInsertTableRecords = new WeakSet();
|
|
1540
1542
|
bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
@@ -1550,7 +1552,7 @@ bulkInsertTableRecords_fn = async function(objects, columns = ["*"]) {
|
|
|
1550
1552
|
throw new Error("Request included columns but server didn't include them");
|
|
1551
1553
|
}
|
|
1552
1554
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1553
|
-
return response.records?.map((item) => initObject(this
|
|
1555
|
+
return response.records?.map((item) => initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), item));
|
|
1554
1556
|
};
|
|
1555
1557
|
_updateRecordWithID = new WeakSet();
|
|
1556
1558
|
updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
@@ -1563,7 +1565,7 @@ updateRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
|
1563
1565
|
...fetchProps
|
|
1564
1566
|
});
|
|
1565
1567
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1566
|
-
return initObject(this
|
|
1568
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1567
1569
|
};
|
|
1568
1570
|
_upsertRecordWithID = new WeakSet();
|
|
1569
1571
|
upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
@@ -1575,7 +1577,7 @@ upsertRecordWithID_fn = async function(recordId, object, columns = ["*"]) {
|
|
|
1575
1577
|
...fetchProps
|
|
1576
1578
|
});
|
|
1577
1579
|
const schemaTables = await __privateMethod$2(this, _getSchemaTables$1, getSchemaTables_fn$1).call(this);
|
|
1578
|
-
return initObject(this
|
|
1580
|
+
return initObject(__privateGet$4(this, _db), schemaTables, __privateGet$4(this, _table), response);
|
|
1579
1581
|
};
|
|
1580
1582
|
_deleteRecord = new WeakSet();
|
|
1581
1583
|
deleteRecord_fn = async function(recordId) {
|
|
@@ -1973,14 +1975,16 @@ var __privateMethod = (obj, member, method) => {
|
|
|
1973
1975
|
return method;
|
|
1974
1976
|
};
|
|
1975
1977
|
const buildClient = (plugins) => {
|
|
1976
|
-
var _branch, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
|
1978
|
+
var _branch, _options, _parseOptions, parseOptions_fn, _getFetchProps, getFetchProps_fn, _evaluateBranch, evaluateBranch_fn, _a;
|
|
1977
1979
|
return _a = class {
|
|
1978
1980
|
constructor(options = {}, schemaTables) {
|
|
1979
1981
|
__privateAdd(this, _parseOptions);
|
|
1980
1982
|
__privateAdd(this, _getFetchProps);
|
|
1981
1983
|
__privateAdd(this, _evaluateBranch);
|
|
1982
1984
|
__privateAdd(this, _branch, void 0);
|
|
1985
|
+
__privateAdd(this, _options, void 0);
|
|
1983
1986
|
const safeOptions = __privateMethod(this, _parseOptions, parseOptions_fn).call(this, options);
|
|
1987
|
+
__privateSet(this, _options, safeOptions);
|
|
1984
1988
|
const pluginOptions = {
|
|
1985
1989
|
getFetchProps: () => __privateMethod(this, _getFetchProps, getFetchProps_fn).call(this, safeOptions),
|
|
1986
1990
|
cache: safeOptions.cache
|
|
@@ -2002,7 +2006,12 @@ const buildClient = (plugins) => {
|
|
|
2002
2006
|
}
|
|
2003
2007
|
}
|
|
2004
2008
|
}
|
|
2005
|
-
|
|
2009
|
+
async getConfig() {
|
|
2010
|
+
const databaseURL = __privateGet(this, _options).databaseURL;
|
|
2011
|
+
const branch = await __privateGet(this, _options).branch();
|
|
2012
|
+
return { databaseURL, branch };
|
|
2013
|
+
}
|
|
2014
|
+
}, _branch = new WeakMap(), _options = new WeakMap(), _parseOptions = new WeakSet(), parseOptions_fn = function(options) {
|
|
2006
2015
|
const fetch = getFetchImplementation(options?.fetch);
|
|
2007
2016
|
const databaseURL = options?.databaseURL || getDatabaseURL();
|
|
2008
2017
|
const apiKey = options?.apiKey || getAPIKey();
|
|
@@ -2012,12 +2021,7 @@ const buildClient = (plugins) => {
|
|
|
2012
2021
|
throw new Error("Options databaseURL and apiKey are required");
|
|
2013
2022
|
}
|
|
2014
2023
|
return { fetch, databaseURL, apiKey, branch, cache };
|
|
2015
|
-
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({
|
|
2016
|
-
fetch,
|
|
2017
|
-
apiKey,
|
|
2018
|
-
databaseURL,
|
|
2019
|
-
branch
|
|
2020
|
-
}) {
|
|
2024
|
+
}, _getFetchProps = new WeakSet(), getFetchProps_fn = async function({ fetch, apiKey, databaseURL, branch }) {
|
|
2021
2025
|
const branchValue = await __privateMethod(this, _evaluateBranch, evaluateBranch_fn).call(this, branch);
|
|
2022
2026
|
if (!branchValue)
|
|
2023
2027
|
throw new Error("Unable to resolve branch value");
|