@centia-io/sdk 0.0.39 → 0.0.40
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/centia-io-sdk.cjs +112 -111
- package/dist/centia-io-sdk.d.cts +31 -7
- package/dist/centia-io-sdk.d.cts.map +1 -1
- package/dist/centia-io-sdk.d.ts +31 -7
- package/dist/centia-io-sdk.d.ts.map +1 -1
- package/dist/centia-io-sdk.js +112 -111
- package/dist/centia-io-sdk.js.map +1 -1
- package/dist/centia-io-sdk.umd.js +112 -111
- package/package.json +1 -1
package/dist/centia-io-sdk.js
CHANGED
|
@@ -1216,36 +1216,35 @@ var TableQueryImpl = class {
|
|
|
1216
1216
|
returning: []
|
|
1217
1217
|
};
|
|
1218
1218
|
return new class {
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
type_hints: Object.keys(type_hints).length ? type_hints : void 0
|
|
1247
|
-
};
|
|
1219
|
+
returning(cols) {
|
|
1220
|
+
state.returning = cols || [];
|
|
1221
|
+
return this;
|
|
1222
|
+
}
|
|
1223
|
+
toSql() {
|
|
1224
|
+
const colsArr = [];
|
|
1225
|
+
const vals = [];
|
|
1226
|
+
const params = {};
|
|
1227
|
+
const type_hints = {};
|
|
1228
|
+
let p = 0;
|
|
1229
|
+
for (const key in state.values) {
|
|
1230
|
+
const value = state.values[key];
|
|
1231
|
+
const col = findColumn(table, key);
|
|
1232
|
+
p += 1;
|
|
1233
|
+
const paramName = `${table.name}_${key}_${p}`;
|
|
1234
|
+
colsArr.push(`"${key}"`);
|
|
1235
|
+
vals.push(`:${paramName}`);
|
|
1236
|
+
params[paramName] = value;
|
|
1237
|
+
addTypeHintForParam(type_hints, paramName, col, value);
|
|
1238
|
+
}
|
|
1239
|
+
const parts = [];
|
|
1240
|
+
parts.push(`insert into "${schema.name}"."${table.name}" (${colsArr.join(", ")}) values (${vals.join(", ")})`);
|
|
1241
|
+
if (state.returning.length) parts.push("returning " + state.returning.join(", "));
|
|
1242
|
+
const req = {
|
|
1243
|
+
q: parts.join(" "),
|
|
1244
|
+
params: Object.keys(params).length > 0 ? params : void 0,
|
|
1245
|
+
type_hints: Object.keys(type_hints).length ? type_hints : void 0
|
|
1248
1246
|
};
|
|
1247
|
+
return state.returning.length ? req : req;
|
|
1249
1248
|
}
|
|
1250
1249
|
}();
|
|
1251
1250
|
}
|
|
@@ -1289,55 +1288,56 @@ var TableQueryImpl = class {
|
|
|
1289
1288
|
}
|
|
1290
1289
|
return this;
|
|
1291
1290
|
};
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1291
|
+
}
|
|
1292
|
+
returning(cols) {
|
|
1293
|
+
state.returning = cols || [];
|
|
1294
|
+
return this;
|
|
1295
|
+
}
|
|
1296
|
+
toSql() {
|
|
1297
|
+
const params = {};
|
|
1298
|
+
const type_hints = {};
|
|
1299
|
+
let p = 0;
|
|
1300
|
+
const setParts = [];
|
|
1301
|
+
for (const key in state.values) {
|
|
1302
|
+
const value = state.values[key];
|
|
1303
|
+
const col = findColumn(table, key);
|
|
1304
|
+
p += 1;
|
|
1305
|
+
const paramName = `${table.name}_${key}_${p}`;
|
|
1306
|
+
setParts.push(`"${key}" = :${paramName}`);
|
|
1307
|
+
params[paramName] = value;
|
|
1308
|
+
addTypeHintForParam(type_hints, paramName, col, value);
|
|
1309
|
+
}
|
|
1310
|
+
const whereClauses = [];
|
|
1311
|
+
for (const key in state.where) {
|
|
1312
|
+
const value = state.where[key];
|
|
1313
|
+
const col = findColumn(table, key);
|
|
1314
|
+
p += 1;
|
|
1315
|
+
const paramName = `${table.name}_${key}_${p}`;
|
|
1316
|
+
if (value === null) {
|
|
1317
|
+
if (!col.is_nullable) throw new Error(`Column ${table.name}.${key} is not nullable; cannot compare to null`);
|
|
1318
|
+
whereClauses.push(`"${key}" is null`);
|
|
1319
|
+
} else if (Array.isArray(value) && !isArrayShapedGeomScalarValue(col, value)) {
|
|
1320
|
+
validateInArrayValues(col, key, value, "in");
|
|
1321
|
+
whereClauses.push(`"${key}" = ANY(:${paramName})`);
|
|
1322
|
+
params[paramName] = value;
|
|
1323
|
+
addTypeHintForParam(type_hints, paramName, col, value);
|
|
1324
|
+
} else {
|
|
1325
|
+
validateScalarForColumn(col, value, `column ${key}`);
|
|
1326
|
+
whereClauses.push(`"${key}" = :${paramName}`);
|
|
1307
1327
|
params[paramName] = value;
|
|
1308
1328
|
addTypeHintForParam(type_hints, paramName, col, value);
|
|
1309
1329
|
}
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
} else if (Array.isArray(value) && !isArrayShapedGeomScalarValue(col, value)) {
|
|
1320
|
-
validateInArrayValues(col, key, value, "in");
|
|
1321
|
-
whereClauses.push(`"${key}" = ANY(:${paramName})`);
|
|
1322
|
-
params[paramName] = value;
|
|
1323
|
-
addTypeHintForParam(type_hints, paramName, col, value);
|
|
1324
|
-
} else {
|
|
1325
|
-
validateScalarForColumn(col, value, `column ${key}`);
|
|
1326
|
-
whereClauses.push(`"${key}" = :${paramName}`);
|
|
1327
|
-
params[paramName] = value;
|
|
1328
|
-
addTypeHintForParam(type_hints, paramName, col, value);
|
|
1329
|
-
}
|
|
1330
|
-
}
|
|
1331
|
-
const parts = [];
|
|
1332
|
-
parts.push(`update "${schema.name}"."${table.name}" set ${setParts.join(", ")}`);
|
|
1333
|
-
if (whereClauses.length) parts.push("where " + whereClauses.join(" and "));
|
|
1334
|
-
if (state.returning.length) parts.push("returning " + state.returning.join(", "));
|
|
1335
|
-
return {
|
|
1336
|
-
q: parts.join(" "),
|
|
1337
|
-
params: Object.keys(params).length > 0 ? params : void 0,
|
|
1338
|
-
type_hints: Object.keys(type_hints).length ? type_hints : void 0
|
|
1339
|
-
};
|
|
1330
|
+
}
|
|
1331
|
+
const parts = [];
|
|
1332
|
+
parts.push(`update "${schema.name}"."${table.name}" set ${setParts.join(", ")}`);
|
|
1333
|
+
if (whereClauses.length) parts.push("where " + whereClauses.join(" and "));
|
|
1334
|
+
if (state.returning.length) parts.push("returning " + state.returning.join(", "));
|
|
1335
|
+
const req = {
|
|
1336
|
+
q: parts.join(" "),
|
|
1337
|
+
params: Object.keys(params).length > 0 ? params : void 0,
|
|
1338
|
+
type_hints: Object.keys(type_hints).length ? type_hints : void 0
|
|
1340
1339
|
};
|
|
1340
|
+
return state.returning.length ? req : req;
|
|
1341
1341
|
}
|
|
1342
1342
|
}();
|
|
1343
1343
|
}
|
|
@@ -1372,45 +1372,46 @@ var TableQueryImpl = class {
|
|
|
1372
1372
|
}
|
|
1373
1373
|
return this;
|
|
1374
1374
|
};
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
}
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1375
|
+
}
|
|
1376
|
+
returning(cols) {
|
|
1377
|
+
state.returning = cols || [];
|
|
1378
|
+
return this;
|
|
1379
|
+
}
|
|
1380
|
+
toSql() {
|
|
1381
|
+
const params = {};
|
|
1382
|
+
const type_hints = {};
|
|
1383
|
+
let p = 0;
|
|
1384
|
+
const whereClauses = [];
|
|
1385
|
+
for (const key in state.where) {
|
|
1386
|
+
const value = state.where[key];
|
|
1387
|
+
const col = findColumn(table, key);
|
|
1388
|
+
p += 1;
|
|
1389
|
+
const paramName = `${table.name}_${key}_${p}`;
|
|
1390
|
+
if (value === null) {
|
|
1391
|
+
if (!col.is_nullable) throw new Error(`Column ${table.name}.${key} is not nullable; cannot compare to null`);
|
|
1392
|
+
whereClauses.push(`"${key}" is null`);
|
|
1393
|
+
} else if (Array.isArray(value)) {
|
|
1394
|
+
validateInArrayValues(col, key, value, "in");
|
|
1395
|
+
whereClauses.push(`"${key}" = ANY(:${paramName})`);
|
|
1396
|
+
params[paramName] = value;
|
|
1397
|
+
addTypeHintForParam(type_hints, paramName, col, value);
|
|
1398
|
+
} else {
|
|
1399
|
+
validateScalarForColumn(col, value, `column ${key}`);
|
|
1400
|
+
whereClauses.push(`"${key}" = :${paramName}`);
|
|
1401
|
+
params[paramName] = value;
|
|
1402
|
+
addTypeHintForParam(type_hints, paramName, col, value);
|
|
1403
1403
|
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1404
|
+
}
|
|
1405
|
+
const parts = [];
|
|
1406
|
+
parts.push(`delete from "${schema.name}"."${table.name}"`);
|
|
1407
|
+
if (whereClauses.length) parts.push("where " + whereClauses.join(" and "));
|
|
1408
|
+
if (state.returning.length) parts.push("returning " + state.returning.join(", "));
|
|
1409
|
+
const req = {
|
|
1410
|
+
q: parts.join(" "),
|
|
1411
|
+
params: Object.keys(params).length > 0 ? params : void 0,
|
|
1412
|
+
type_hints: Object.keys(type_hints).length ? type_hints : void 0
|
|
1413
1413
|
};
|
|
1414
|
+
return state.returning.length ? req : req;
|
|
1414
1415
|
}
|
|
1415
1416
|
}();
|
|
1416
1417
|
}
|