@stardeck-customer-apps/data-store-sdk 0.1.0-preview.0 → 0.1.0-preview.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.
@@ -53,7 +53,7 @@ var PG_TYPE_MAP = {
53
53
  "time with time zone": "string",
54
54
  "time without time zone": "string",
55
55
  bytea: "Buffer",
56
- "ARRAY": "unknown[]"
56
+ ARRAY: "unknown[]"
57
57
  };
58
58
  function pgTypeToTs(pgType) {
59
59
  return PG_TYPE_MAP[pgType] ?? "unknown";
@@ -30,7 +30,7 @@ var PG_TYPE_MAP = {
30
30
  "time with time zone": "string",
31
31
  "time without time zone": "string",
32
32
  bytea: "Buffer",
33
- "ARRAY": "unknown[]"
33
+ ARRAY: "unknown[]"
34
34
  };
35
35
  function pgTypeToTs(pgType) {
36
36
  return PG_TYPE_MAP[pgType] ?? "unknown";
@@ -90,9 +90,16 @@ var DataStoreClient = class {
90
90
  this.deploymentId = config.deploymentId || this.getEnv("DEPLOYMENT_ID") || "";
91
91
  this.maxRetries = config.maxRetries ?? 3;
92
92
  this.debug = config.debug ?? false;
93
- if (!this.baseUrl || !this.deploymentSecret || !this.organizationId || !this.projectId || !this.deploymentId) {
94
- console.warn(
95
- "[DataStoreClient] Not fully configured. Set CONTROL_PLANE_URL, DEPLOYMENT_SECRET, ORGANIZATION_ID, PROJECT_ID, and DEPLOYMENT_ID environment variables."
93
+ const missing = [
94
+ !this.baseUrl && "CONTROL_PLANE_URL",
95
+ !this.deploymentSecret && "DEPLOYMENT_SECRET",
96
+ !this.organizationId && "ORGANIZATION_ID",
97
+ !this.projectId && "PROJECT_ID",
98
+ !this.deploymentId && "DEPLOYMENT_ID"
99
+ ].filter(Boolean);
100
+ if (missing.length > 0) {
101
+ throw new Error(
102
+ `[DataStoreClient] Missing required configuration: ${missing.join(", ")}. Pass them in the config object or set the corresponding environment variables.`
96
103
  );
97
104
  }
98
105
  }
@@ -156,6 +163,8 @@ var DataStoreClient = class {
156
163
  if (error instanceof AuthenticationError) throw error;
157
164
  if (error instanceof DataStoreError && error.statusCode < 500) throw error;
158
165
  if (attempt < this.maxRetries) {
166
+ const isIdempotent = method === "GET" || method === "HEAD";
167
+ if (!isIdempotent) throw lastError ?? error;
159
168
  const delay = Math.min(1e3 * 2 ** attempt, 1e4);
160
169
  await new Promise((r) => setTimeout(r, delay));
161
170
  }
@@ -163,7 +172,6 @@ var DataStoreClient = class {
163
172
  }
164
173
  throw lastError ?? new DataStoreError("Request failed", "UNKNOWN", 500);
165
174
  }
166
- // ─── Schema Operations ──────────────────────────────────────
167
175
  async getSchema() {
168
176
  return this.request("GET", "/schema");
169
177
  }
@@ -183,7 +191,6 @@ var DataStoreClient = class {
183
191
  async deleteColumn(tableName, columnName) {
184
192
  return this.request("DELETE", "/schema/columns", { tableName, columnName });
185
193
  }
186
- // ─── Query Operations ───────────────────────────────────────
187
194
  async query(tableName, options = {}) {
188
195
  return this.request("POST", "/query", {
189
196
  tableName,
@@ -217,7 +224,6 @@ var DataStoreClient = class {
217
224
  primaryKey
218
225
  });
219
226
  }
220
- // ─── Storage Operations ─────────────────────────────────────
221
227
  async listFiles(options) {
222
228
  const params = {};
223
229
  if (options?.prefix) params.prefix = options.prefix;
@@ -39,9 +39,16 @@ var DataStoreClient = class {
39
39
  this.deploymentId = config.deploymentId || this.getEnv("DEPLOYMENT_ID") || "";
40
40
  this.maxRetries = config.maxRetries ?? 3;
41
41
  this.debug = config.debug ?? false;
42
- if (!this.baseUrl || !this.deploymentSecret || !this.organizationId || !this.projectId || !this.deploymentId) {
43
- console.warn(
44
- "[DataStoreClient] Not fully configured. Set CONTROL_PLANE_URL, DEPLOYMENT_SECRET, ORGANIZATION_ID, PROJECT_ID, and DEPLOYMENT_ID environment variables."
42
+ const missing = [
43
+ !this.baseUrl && "CONTROL_PLANE_URL",
44
+ !this.deploymentSecret && "DEPLOYMENT_SECRET",
45
+ !this.organizationId && "ORGANIZATION_ID",
46
+ !this.projectId && "PROJECT_ID",
47
+ !this.deploymentId && "DEPLOYMENT_ID"
48
+ ].filter(Boolean);
49
+ if (missing.length > 0) {
50
+ throw new Error(
51
+ `[DataStoreClient] Missing required configuration: ${missing.join(", ")}. Pass them in the config object or set the corresponding environment variables.`
45
52
  );
46
53
  }
47
54
  }
@@ -105,6 +112,8 @@ var DataStoreClient = class {
105
112
  if (error instanceof AuthenticationError) throw error;
106
113
  if (error instanceof DataStoreError && error.statusCode < 500) throw error;
107
114
  if (attempt < this.maxRetries) {
115
+ const isIdempotent = method === "GET" || method === "HEAD";
116
+ if (!isIdempotent) throw lastError ?? error;
108
117
  const delay = Math.min(1e3 * 2 ** attempt, 1e4);
109
118
  await new Promise((r) => setTimeout(r, delay));
110
119
  }
@@ -112,7 +121,6 @@ var DataStoreClient = class {
112
121
  }
113
122
  throw lastError ?? new DataStoreError("Request failed", "UNKNOWN", 500);
114
123
  }
115
- // ─── Schema Operations ──────────────────────────────────────
116
124
  async getSchema() {
117
125
  return this.request("GET", "/schema");
118
126
  }
@@ -132,7 +140,6 @@ var DataStoreClient = class {
132
140
  async deleteColumn(tableName, columnName) {
133
141
  return this.request("DELETE", "/schema/columns", { tableName, columnName });
134
142
  }
135
- // ─── Query Operations ───────────────────────────────────────
136
143
  async query(tableName, options = {}) {
137
144
  return this.request("POST", "/query", {
138
145
  tableName,
@@ -166,7 +173,6 @@ var DataStoreClient = class {
166
173
  primaryKey
167
174
  });
168
175
  }
169
- // ─── Storage Operations ─────────────────────────────────────
170
176
  async listFiles(options) {
171
177
  const params = {};
172
178
  if (options?.prefix) params.prefix = options.prefix;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stardeck-customer-apps/data-store-sdk",
3
- "version": "0.1.0-preview.0",
3
+ "version": "0.1.0-preview.1",
4
4
  "description": "SDK for accessing Stardeck data stores from deployed projects",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",