@xata.io/client 0.7.1 → 0.8.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xata.io/client",
3
- "version": "0.7.1",
3
+ "version": "0.8.1",
4
4
  "description": "Xata.io SDK for TypeScript and JavaScript",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -23,5 +23,5 @@
23
23
  "url": "https://github.com/xataio/client-ts/issues"
24
24
  },
25
25
  "homepage": "https://github.com/xataio/client-ts/blob/main/client/README.md",
26
- "gitHead": "c817835c55f287286f4d30863e7bcfac0215f8f7"
26
+ "gitHead": "e0277aa65a86bd878e236c28677bab8aeff9a051"
27
27
  }
@@ -1,4 +0,0 @@
1
- import { FetcherExtraProps } from '../api/fetcher';
2
- export declare function getBranch(fetchProps: Omit<FetcherExtraProps, 'workspacesApiUrl'>): Promise<string | undefined>;
3
- export declare function getDatabaseUrl(): string | undefined;
4
- export declare function getAPIKey(): string | undefined;
@@ -1,83 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.getAPIKey = exports.getDatabaseUrl = exports.getBranch = void 0;
13
- const api_1 = require("../api");
14
- const environment_1 = require("../util/environment");
15
- const lang_1 = require("../util/lang");
16
- const envBranchNames = [
17
- 'XATA_BRANCH',
18
- 'VERCEL_GIT_COMMIT_REF',
19
- 'CF_PAGES_BRANCH',
20
- 'BRANCH' // Netlify. Putting it the last one because it is more ambiguous
21
- ];
22
- function getBranch(fetchProps) {
23
- return __awaiter(this, void 0, void 0, function* () {
24
- const env = getBranchByEnvVariable();
25
- if (env)
26
- return env;
27
- const branch = yield (0, environment_1.getGitBranch)();
28
- if (!branch)
29
- return undefined;
30
- // TODO: in the future, call /resolve endpoint
31
- // For now, call API to see if the branch exists. If not, use a default value.
32
- const [protocol, , host, , database] = fetchProps.apiUrl.split('/');
33
- const [workspace] = host.split('.');
34
- const dbBranchName = `${database}:${branch}`;
35
- try {
36
- yield (0, api_1.getBranchDetails)(Object.assign(Object.assign({}, fetchProps), { workspacesApiUrl: `${protocol}//${host}`, pathParams: {
37
- dbBranchName,
38
- workspace
39
- } }));
40
- }
41
- catch (err) {
42
- if ((0, lang_1.isObject)(err) && err.status === 404)
43
- return 'main';
44
- throw err;
45
- }
46
- return branch;
47
- });
48
- }
49
- exports.getBranch = getBranch;
50
- function getBranchByEnvVariable() {
51
- for (const name of envBranchNames) {
52
- const value = (0, environment_1.getEnvVariable)(name);
53
- if (value) {
54
- return value;
55
- }
56
- }
57
- try {
58
- return XATA_BRANCH;
59
- }
60
- catch (err) {
61
- // Ignore ReferenceError. Only CloudFlare workers set env variables as global variables
62
- }
63
- }
64
- function getDatabaseUrl() {
65
- var _a;
66
- try {
67
- return (_a = (0, environment_1.getEnvVariable)('XATA_DATABASE_URL')) !== null && _a !== void 0 ? _a : XATA_DATABASE_URL;
68
- }
69
- catch (err) {
70
- return undefined;
71
- }
72
- }
73
- exports.getDatabaseUrl = getDatabaseUrl;
74
- function getAPIKey() {
75
- var _a;
76
- try {
77
- return (_a = (0, environment_1.getEnvVariable)('XATA_API_KEY')) !== null && _a !== void 0 ? _a : XATA_API_KEY;
78
- }
79
- catch (err) {
80
- return undefined;
81
- }
82
- }
83
- exports.getAPIKey = getAPIKey;