sfobjects-basic-client 1.1.7 → 1.1.9
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.d.ts +14 -11
- package/dist/index.js +24 -14
- package/package.json +1 -1
- package/src/index.ts +58 -30
package/dist/index.d.ts
CHANGED
|
@@ -160,18 +160,21 @@ export interface ISfConnection {
|
|
|
160
160
|
create: (n: string, r: any[], o?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
161
161
|
delete: (n: string, ids: string[], o?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
162
162
|
}
|
|
163
|
-
export interface
|
|
163
|
+
export interface SfQueryActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
164
164
|
soql: () => string;
|
|
165
165
|
get: (options?: SfQueryOptions) => Promise<SfQueryResult<SfRootSelectProjection<OI, N, S>>>;
|
|
166
|
-
|
|
166
|
+
first: (options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S> | undefined>;
|
|
167
|
+
}
|
|
168
|
+
export interface SfLimitAction<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
169
|
+
limit: (limit: number) => SfQueryActions<OI, N, S>;
|
|
167
170
|
}
|
|
168
171
|
export interface SfOrderByAction<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
169
|
-
orderBy: <R extends SfRootOrderBy<OI, N>>(orderBy: R) =>
|
|
172
|
+
orderBy: <R extends SfRootOrderBy<OI, N>>(orderBy: R) => (SfQueryActions<OI, N, S> & SfLimitAction<OI, N, S>);
|
|
170
173
|
}
|
|
171
174
|
export interface SfWhereActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
172
|
-
where: <W extends SfRootWhere<OI, N>>(where: W) => (
|
|
175
|
+
where: <W extends SfRootWhere<OI, N>>(where: W) => (SfQueryActions<OI, N, S> & SfOrderByAction<OI, N, S>);
|
|
173
176
|
}
|
|
174
|
-
export interface
|
|
177
|
+
export interface SfQueryAditionalActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
175
178
|
find: (id: string, options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S> | undefined>;
|
|
176
179
|
retrieve: (id: string, options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S>>;
|
|
177
180
|
selection: S[];
|
|
@@ -182,12 +185,12 @@ export interface SfObjActions<OI, N extends KeyOf<OI>> {
|
|
|
182
185
|
where?: string | W;
|
|
183
186
|
orderBy?: SfRootOrderBy<OI, N>;
|
|
184
187
|
limit?: number;
|
|
185
|
-
}) =>
|
|
186
|
-
delete: (ids: string[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
187
|
-
update: (records: SfUpdate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
188
|
-
create: (records: SfCreate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
189
|
-
upsert: <K extends MandatoryCreateProps<OI[N]>>(records: SfUpsert<OI[N], K>[], key: K, options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
190
|
-
select: <S extends SfRootSelect<OI, N>>(select: S[]) => (
|
|
188
|
+
}) => SfQueryActions<OI, N, S>;
|
|
189
|
+
delete: (ids: string | string[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
190
|
+
update: (records: SfUpdate<OI[N]> | SfUpdate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
191
|
+
create: (records: SfCreate<OI[N]> | SfCreate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
192
|
+
upsert: <K extends MandatoryCreateProps<OI[N]>>(records: SfUpsert<OI[N], K> | SfUpsert<OI[N], K>[], key: K, options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
193
|
+
select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfQueryActions<OI, N, S> & SfWhereActions<OI, N, S> & SfQueryAditionalActions<OI, N, S>);
|
|
191
194
|
}
|
|
192
195
|
export declare class SfBasicClientSaveError extends Error {
|
|
193
196
|
errors: SfSaveError[];
|
package/dist/index.js
CHANGED
|
@@ -249,17 +249,30 @@ function processSaveResult(sr, breakOnError) {
|
|
|
249
249
|
}
|
|
250
250
|
return sr;
|
|
251
251
|
}
|
|
252
|
+
function pluralize(a) {
|
|
253
|
+
if (a === undefined) {
|
|
254
|
+
return [];
|
|
255
|
+
}
|
|
256
|
+
if (Array.isArray(a)) {
|
|
257
|
+
return a;
|
|
258
|
+
}
|
|
259
|
+
return [a];
|
|
260
|
+
}
|
|
252
261
|
function getSfObject(_cfg, o) {
|
|
253
262
|
function _query(conn, from, select, where, orderBy, limit) {
|
|
254
263
|
const soql = () => constructSoql(_cfg)(from, from, select, where, orderBy, limit);
|
|
264
|
+
const get = (...args_1) => __awaiter(this, [...args_1], void 0, function* (options = o === null || o === void 0 ? void 0 : o.query) { return yield conn.query(soql(), options); }); // to get rid of promiselike,
|
|
255
265
|
return ({
|
|
256
266
|
soql,
|
|
257
|
-
get
|
|
258
|
-
|
|
267
|
+
get,
|
|
268
|
+
first: (...args_1) => __awaiter(this, [...args_1], void 0, function* (options = o === null || o === void 0 ? void 0 : o.query) {
|
|
269
|
+
const result = (yield get(options)).records;
|
|
270
|
+
return result.length ? result[0] : undefined;
|
|
271
|
+
})
|
|
259
272
|
});
|
|
260
273
|
}
|
|
261
274
|
function _queryOne(conn, from, select, id, options = o === null || o === void 0 ? void 0 : o.query) {
|
|
262
|
-
return _query(conn, from, select, `Id = '${id}'
|
|
275
|
+
return _query(conn, from, select, `Id = '${id}'`, undefined, 1).first(options);
|
|
263
276
|
}
|
|
264
277
|
return (from, _conn) => {
|
|
265
278
|
return ({
|
|
@@ -267,21 +280,18 @@ function getSfObject(_cfg, o) {
|
|
|
267
280
|
const { select, where, orderBy, limit } = q;
|
|
268
281
|
return _query(_conn, from, select, where, orderBy, limit);
|
|
269
282
|
},
|
|
270
|
-
delete: (ids_1, ...args_1) => __awaiter(this, [ids_1, ...args_1], void 0, function* (ids, options = o === null || o === void 0 ? void 0 : o.dml) { return processSaveResult(yield _conn.delete(from, ids, options), o === null || o === void 0 ? void 0 : o.breakOnError); }),
|
|
271
|
-
update: (records_1, ...args_1) => __awaiter(this, [records_1, ...args_1], void 0, function* (records, options = o === null || o === void 0 ? void 0 : o.dml) { return processSaveResult(yield _conn.update(from, records, options), o === null || o === void 0 ? void 0 : o.breakOnError); }),
|
|
272
|
-
create: (records_1, ...args_1) => __awaiter(this, [records_1, ...args_1], void 0, function* (records, options = o === null || o === void 0 ? void 0 : o.dml) { return processSaveResult(yield _conn.create(from, records, options), o === null || o === void 0 ? void 0 : o.breakOnError); }),
|
|
273
|
-
upsert: (records_1, key_1, ...args_1) => __awaiter(this, [records_1, key_1, ...args_1], void 0, function* (records, key, options = o === null || o === void 0 ? void 0 : o.dml) { return processSaveResult(yield _conn.upsert(from, records, key, options), o === null || o === void 0 ? void 0 : o.breakOnError); }),
|
|
274
|
-
select: (select) => (Object.assign(Object.assign({}, _query(_conn, from, select)), { orderBy: (orderBy) => _query(_conn, from, select, undefined, orderBy), where: (where) => (Object.assign(Object.assign({}, _query(_conn, from, select, where)), { orderBy: (orderBy) => _query(_conn, from, select, where, orderBy) })), find: (id_1, ...args_1) => __awaiter(this, [id_1, ...args_1], void 0, function* (id, options = o === null || o === void 0 ? void 0 : o.query) {
|
|
275
|
-
|
|
276
|
-
if (result.records.length) {
|
|
277
|
-
return result.records[0];
|
|
278
|
-
}
|
|
283
|
+
delete: (ids_1, ...args_1) => __awaiter(this, [ids_1, ...args_1], void 0, function* (ids, options = o === null || o === void 0 ? void 0 : o.dml) { return processSaveResult(yield _conn.delete(from, pluralize(ids), options), o === null || o === void 0 ? void 0 : o.breakOnError); }),
|
|
284
|
+
update: (records_1, ...args_1) => __awaiter(this, [records_1, ...args_1], void 0, function* (records, options = o === null || o === void 0 ? void 0 : o.dml) { return processSaveResult(yield _conn.update(from, pluralize(records), options), o === null || o === void 0 ? void 0 : o.breakOnError); }),
|
|
285
|
+
create: (records_1, ...args_1) => __awaiter(this, [records_1, ...args_1], void 0, function* (records, options = o === null || o === void 0 ? void 0 : o.dml) { return processSaveResult(yield _conn.create(from, pluralize(records), options), o === null || o === void 0 ? void 0 : o.breakOnError); }),
|
|
286
|
+
upsert: (records_1, key_1, ...args_1) => __awaiter(this, [records_1, key_1, ...args_1], void 0, function* (records, key, options = o === null || o === void 0 ? void 0 : o.dml) { return processSaveResult(yield _conn.upsert(from, pluralize(records), key, options), o === null || o === void 0 ? void 0 : o.breakOnError); }),
|
|
287
|
+
select: (select) => (Object.assign(Object.assign({}, _query(_conn, from, select)), { orderBy: (orderBy) => (Object.assign(Object.assign({}, _query(_conn, from, select, undefined, orderBy)), { limit: (limit) => _query(_conn, from, select, undefined, orderBy, limit) })), limit: (limit) => _query(_conn, from, select, undefined, undefined, limit), where: (where) => (Object.assign(Object.assign({}, _query(_conn, from, select, where)), { orderBy: (orderBy) => (Object.assign(Object.assign({}, _query(_conn, from, select, where, orderBy)), { limit: (limit) => _query(_conn, from, select, where, orderBy, limit) })), limit: (limit) => _query(_conn, from, select, where, undefined, limit) })), find: (id_1, ...args_1) => __awaiter(this, [id_1, ...args_1], void 0, function* (id, options = o === null || o === void 0 ? void 0 : o.query) {
|
|
288
|
+
return _queryOne(_conn, from, select, id, options);
|
|
279
289
|
}), retrieve: (id_1, ...args_1) => __awaiter(this, [id_1, ...args_1], void 0, function* (id, options = o === null || o === void 0 ? void 0 : o.query) {
|
|
280
290
|
const result = yield _queryOne(_conn, from, select, id, options);
|
|
281
|
-
if (!result
|
|
291
|
+
if (!result) {
|
|
282
292
|
throw new SfBasicClientReadError(`Record with id '${id}' is not found in '${from}'.`);
|
|
283
293
|
}
|
|
284
|
-
return result
|
|
294
|
+
return result;
|
|
285
295
|
}), selection: select }))
|
|
286
296
|
});
|
|
287
297
|
};
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -258,34 +258,38 @@ export interface ISfConnection {
|
|
|
258
258
|
delete: (n: string, ids: string[], o?: SfDmlOptions) => PromiseLike<SfSaveResult[]>
|
|
259
259
|
}
|
|
260
260
|
|
|
261
|
-
export interface
|
|
261
|
+
export interface SfQueryActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
262
262
|
soql: () => string;
|
|
263
263
|
get: (options?: SfQueryOptions) => Promise<SfQueryResult<SfRootSelectProjection<OI, N, S>>>;
|
|
264
|
-
|
|
264
|
+
first: (options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S> | undefined>;
|
|
265
|
+
//limit: (limit: number) => SfSelectActions<OI, N, S>;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
export interface SfLimitAction<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
269
|
+
limit: (limit: number) => SfQueryActions<OI, N, S>;
|
|
265
270
|
}
|
|
266
271
|
|
|
267
272
|
export interface SfOrderByAction<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
268
|
-
orderBy: <R extends SfRootOrderBy<OI, N>>(orderBy: R) =>
|
|
273
|
+
orderBy: <R extends SfRootOrderBy<OI, N>>(orderBy: R) => (SfQueryActions<OI, N, S> & SfLimitAction<OI, N, S>);
|
|
269
274
|
}
|
|
270
275
|
|
|
271
276
|
export interface SfWhereActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
272
|
-
where: <W extends SfRootWhere<OI, N>>(where: W) => (
|
|
277
|
+
where: <W extends SfRootWhere<OI, N>>(where: W) => (SfQueryActions<OI, N, S> & SfOrderByAction<OI, N, S>);
|
|
273
278
|
}
|
|
274
279
|
|
|
275
|
-
export interface
|
|
280
|
+
export interface SfQueryAditionalActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
276
281
|
find: (id: string, options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S> | undefined>;
|
|
277
282
|
retrieve: (id: string, options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S>>;
|
|
278
283
|
selection: S[];
|
|
279
|
-
//S extends SfRootSelect<OI, N>
|
|
280
284
|
}
|
|
281
285
|
|
|
282
286
|
export interface SfObjActions<OI, N extends KeyOf<OI>> {
|
|
283
|
-
query: <S extends SfRootSelect<OI, N>, W extends SfRootWhere<OI, N>>(q: { select: S[], where?: string | W, orderBy?: SfRootOrderBy<OI, N>, limit?: number }) =>
|
|
284
|
-
delete: (ids: string[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
285
|
-
update: (records: SfUpdate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
286
|
-
create: (records: SfCreate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
287
|
-
upsert: <K extends MandatoryCreateProps<OI[N]>>(records: SfUpsert<OI[N], K>[], key: K, options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
288
|
-
select: <S extends SfRootSelect<OI, N>>(select: S[]) => (
|
|
287
|
+
query: <S extends SfRootSelect<OI, N>, W extends SfRootWhere<OI, N>>(q: { select: S[], where?: string | W, orderBy?: SfRootOrderBy<OI, N>, limit?: number }) => SfQueryActions<OI, N, S>;
|
|
288
|
+
delete: (ids: string | string[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
289
|
+
update: (records: SfUpdate<OI[N]> | SfUpdate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
290
|
+
create: (records: SfCreate<OI[N]> | SfCreate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
291
|
+
upsert: <K extends MandatoryCreateProps<OI[N]>>(records: SfUpsert<OI[N], K> | SfUpsert<OI[N], K>[], key: K, options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
292
|
+
select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfQueryActions<OI, N, S> & SfWhereActions<OI, N, S> & SfQueryAditionalActions<OI, N, S>);
|
|
289
293
|
}
|
|
290
294
|
|
|
291
295
|
export class SfBasicClientSaveError extends Error {
|
|
@@ -554,6 +558,19 @@ function processSaveResult(sr: SfSaveResult[], breakOnError?: boolean): SfSaveRe
|
|
|
554
558
|
return sr;
|
|
555
559
|
}
|
|
556
560
|
|
|
561
|
+
function pluralize<T>(a: T | T[]) {
|
|
562
|
+
|
|
563
|
+
if (a === undefined) {
|
|
564
|
+
return [];
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
if (Array.isArray(a)) {
|
|
568
|
+
return a;
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
return [a];
|
|
572
|
+
}
|
|
573
|
+
|
|
557
574
|
export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>, o?: SfClientOptions) {
|
|
558
575
|
|
|
559
576
|
|
|
@@ -564,14 +581,19 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>, o?: SfClientOptions) {
|
|
|
564
581
|
where?: string | W,
|
|
565
582
|
orderBy?: R,
|
|
566
583
|
limit?: number
|
|
567
|
-
):
|
|
584
|
+
): SfQueryActions<OI, N, S> {
|
|
568
585
|
|
|
569
586
|
const soql = () => constructSoql(_cfg)(from, from, select, where, orderBy, limit);
|
|
570
587
|
|
|
588
|
+
const get = async (options: SfQueryOptions | undefined = o?.query) => await conn.query<SfRootSelectProjection<OI, N, S>>(soql(), options); // to get rid of promiselike,
|
|
589
|
+
|
|
571
590
|
return ({
|
|
572
591
|
soql,
|
|
573
|
-
get
|
|
574
|
-
|
|
592
|
+
get,
|
|
593
|
+
first: async (options: SfQueryOptions | undefined = o?.query) => {
|
|
594
|
+
const result = (await get(options)).records;
|
|
595
|
+
return result.length ? result[0] : undefined;
|
|
596
|
+
}
|
|
575
597
|
});
|
|
576
598
|
}
|
|
577
599
|
|
|
@@ -582,7 +604,7 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>, o?: SfClientOptions) {
|
|
|
582
604
|
id: string,
|
|
583
605
|
options: SfQueryOptions | undefined = o?.query
|
|
584
606
|
) {
|
|
585
|
-
return _query(conn, from, select, `Id = '${id}'
|
|
607
|
+
return _query(conn, from, select, `Id = '${id}'`, undefined, 1).first(options);
|
|
586
608
|
}
|
|
587
609
|
|
|
588
610
|
return <N extends KeyOf<OI>>(from: N, _conn: ISfConnection): SfObjActions<OI, N> => {
|
|
@@ -594,46 +616,52 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>, o?: SfClientOptions) {
|
|
|
594
616
|
return _query(_conn, from, select, where, orderBy, limit);
|
|
595
617
|
},
|
|
596
618
|
|
|
597
|
-
delete: async (ids: string[], options: SfDmlOptions | undefined = o?.dml) => processSaveResult(await _conn.delete(from, ids, options), o?.breakOnError),
|
|
619
|
+
delete: async (ids: string | string[], options: SfDmlOptions | undefined = o?.dml) => processSaveResult(await _conn.delete(from, pluralize(ids), options), o?.breakOnError),
|
|
598
620
|
|
|
599
|
-
update: async (records: SfUpdate<OI[N]>[], options: SfDmlOptions | undefined = o?.dml) => processSaveResult(await _conn.update(from, records, options), o?.breakOnError),
|
|
621
|
+
update: async (records: SfUpdate<OI[N]> | SfUpdate<OI[N]>[], options: SfDmlOptions | undefined = o?.dml) => processSaveResult(await _conn.update(from, pluralize(records), options), o?.breakOnError),
|
|
600
622
|
|
|
601
|
-
create: async (records: SfCreate<OI[N]>[], options: SfDmlOptions | undefined = o?.dml) => processSaveResult(await _conn.create(from, records, options), o?.breakOnError),
|
|
623
|
+
create: async (records: SfCreate<OI[N]> | SfCreate<OI[N]>[], options: SfDmlOptions | undefined = o?.dml) => processSaveResult(await _conn.create(from, pluralize(records), options), o?.breakOnError),
|
|
602
624
|
|
|
603
|
-
upsert: async <K extends MandatoryCreateProps<OI[N]>>(records: SfUpsert<OI[N], K>[], key: K, options: SfDmlOptions | undefined = o?.dml) => processSaveResult(await _conn.upsert(from, records, key, options), o?.breakOnError),
|
|
625
|
+
upsert: async <K extends MandatoryCreateProps<OI[N]>>(records: SfUpsert<OI[N], K> | SfUpsert<OI[N], K>[], key: K, options: SfDmlOptions | undefined = o?.dml) => processSaveResult(await _conn.upsert(from, pluralize(records), key, options), o?.breakOnError),
|
|
604
626
|
|
|
605
627
|
select: <S extends SfRootSelect<OI, N>>(select: S[]) => ({
|
|
606
628
|
|
|
607
629
|
..._query(_conn, from, select),
|
|
608
630
|
|
|
609
|
-
orderBy: <R extends SfRootOrderBy<OI, N>>(orderBy: R) =>
|
|
631
|
+
orderBy: <R extends SfRootOrderBy<OI, N>>(orderBy: R) => ({
|
|
632
|
+
..._query(_conn, from, select, undefined, orderBy),
|
|
633
|
+
limit: (limit: number) => _query(_conn, from, select, undefined, orderBy, limit)
|
|
634
|
+
}),
|
|
635
|
+
|
|
636
|
+
limit: (limit: number) => _query(_conn, from, select, undefined, undefined, limit),
|
|
610
637
|
|
|
611
638
|
where: <W extends SfRootWhere<OI, N>>(where: string | W) => ({
|
|
612
639
|
|
|
613
640
|
..._query(_conn, from, select, where),
|
|
614
641
|
|
|
615
|
-
orderBy: <R extends SfRootOrderBy<OI, N>>(orderBy: R) =>
|
|
642
|
+
orderBy: <R extends SfRootOrderBy<OI, N>>(orderBy: R) => ({
|
|
643
|
+
..._query(_conn, from, select, where, orderBy),
|
|
644
|
+
limit: (limit: number) => _query(_conn, from, select, where, orderBy, limit)
|
|
645
|
+
}),
|
|
646
|
+
|
|
647
|
+
limit: (limit: number) => _query(_conn, from, select, where, undefined, limit)
|
|
616
648
|
|
|
617
649
|
}),
|
|
618
650
|
|
|
619
651
|
find: async (id: string, options: SfQueryOptions | undefined = o?.query) => {
|
|
620
652
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
if (result.records.length) {
|
|
624
|
-
return result.records[0];
|
|
625
|
-
}
|
|
653
|
+
return _queryOne(_conn, from, select, id, options);
|
|
626
654
|
},
|
|
627
655
|
|
|
628
656
|
retrieve: async (id: string, options: SfQueryOptions | undefined = o?.query) => {
|
|
629
657
|
|
|
630
658
|
const result = await _queryOne(_conn, from, select, id, options);
|
|
631
659
|
|
|
632
|
-
if (!result
|
|
660
|
+
if (!result) {
|
|
633
661
|
throw new SfBasicClientReadError(`Record with id '${id}' is not found in '${from}'.`);
|
|
634
662
|
}
|
|
635
663
|
|
|
636
|
-
return result
|
|
664
|
+
return result;
|
|
637
665
|
},
|
|
638
666
|
|
|
639
667
|
selection: select
|
|
@@ -645,7 +673,7 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>, o?: SfClientOptions) {
|
|
|
645
673
|
|
|
646
674
|
|
|
647
675
|
export const getSfObjects = <OI>(cfg: SfObjCfgIndex<OI>) => (conn: ISfConnection, options?: SfClientOptions) => {
|
|
648
|
-
|
|
676
|
+
|
|
649
677
|
const __getObject = <N extends KeyOf<OI>>(from: N) => getSfObject<OI>(cfg, options)(from, conn);
|
|
650
678
|
|
|
651
679
|
return {
|