sfobjects-basic-client 1.1.0 → 1.1.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/dist/index.d.ts +5 -2
- package/dist/index.js +6 -1
- package/package.json +1 -1
- package/src/index.ts +19 -5
package/dist/index.d.ts
CHANGED
|
@@ -148,7 +148,7 @@ export interface ISfConnection {
|
|
|
148
148
|
}
|
|
149
149
|
export interface SfSelectActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
150
150
|
soql: () => string;
|
|
151
|
-
get: () => Promise<SfQueryResult<SfRootSelectProjection<OI, N, S>>>;
|
|
151
|
+
get: (options?: SfQueryOptions) => Promise<SfQueryResult<SfRootSelectProjection<OI, N, S>>>;
|
|
152
152
|
limit: (limit: number) => SfSelectActions<OI, N, S>;
|
|
153
153
|
}
|
|
154
154
|
export interface SfOrderByAction<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
@@ -157,6 +157,9 @@ export interface SfOrderByAction<OI, N extends KeyOf<OI>, S extends SfRootSelect
|
|
|
157
157
|
export interface SfWhereActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
158
158
|
where: (where: SfRootWhere<OI, N>) => (SfSelectActions<OI, N, S> & SfOrderByAction<OI, N, S>);
|
|
159
159
|
}
|
|
160
|
+
export interface SfFindActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
161
|
+
find: (id: string, options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S> | undefined>;
|
|
162
|
+
}
|
|
160
163
|
export interface SfObjActions<OI, N extends KeyOf<OI>> {
|
|
161
164
|
query: <S extends SfRootSelect<OI, N>>(q: {
|
|
162
165
|
select: S[];
|
|
@@ -168,7 +171,7 @@ export interface SfObjActions<OI, N extends KeyOf<OI>> {
|
|
|
168
171
|
update: (records: SfUpdate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
169
172
|
create: (records: SfCreate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
170
173
|
upsert: <K extends MandatoryCreateProps<OI[N]>>(records: SfUpsert<OI[N], K>[], key: K, options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
171
|
-
select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfSelectActions<OI, N, S> & SfWhereActions<OI, N, S>);
|
|
174
|
+
select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfSelectActions<OI, N, S> & SfWhereActions<OI, N, S> & SfFindActions<OI, N, S>);
|
|
172
175
|
}
|
|
173
176
|
export declare function isPlainObject(value: unknown): value is Record<string, any>;
|
|
174
177
|
export declare function constructSoql<OI>(_cfg: SfObjCfgIndex<OI>): (objName: string, from: string, select: (string | {})[], where?: string | Record<string, any>, orderBy?: Record<string, any>, limit?: number) => string;
|
package/dist/index.js
CHANGED
|
@@ -241,7 +241,12 @@ function getSfObject(_cfg) {
|
|
|
241
241
|
update: (records, options) => _conn.update(from, records, options),
|
|
242
242
|
create: (records, options) => _conn.create(from, records, options),
|
|
243
243
|
upsert: (records, key, options) => _conn.upsert(from, records, key, options),
|
|
244
|
-
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) }))
|
|
244
|
+
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, options) => __awaiter(this, void 0, void 0, function* () {
|
|
245
|
+
const result = yield _query(_conn, from, select, `Id = '${id}'`).limit(1).get(options);
|
|
246
|
+
if (result.records.length) {
|
|
247
|
+
return result.records[0];
|
|
248
|
+
}
|
|
249
|
+
}) }))
|
|
245
250
|
});
|
|
246
251
|
};
|
|
247
252
|
}
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -244,7 +244,7 @@ export interface ISfConnection {
|
|
|
244
244
|
|
|
245
245
|
export interface SfSelectActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
246
246
|
soql: () => string;
|
|
247
|
-
get: () => Promise<SfQueryResult<SfRootSelectProjection<OI, N, S>>>;
|
|
247
|
+
get: (options?: SfQueryOptions) => Promise<SfQueryResult<SfRootSelectProjection<OI, N, S>>>;
|
|
248
248
|
limit: (limit: number) => SfSelectActions<OI, N, S>;
|
|
249
249
|
}
|
|
250
250
|
|
|
@@ -256,13 +256,17 @@ export interface SfWhereActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<
|
|
|
256
256
|
where: (where: SfRootWhere<OI, N>) => (SfSelectActions<OI, N, S> & SfOrderByAction<OI, N, S>);
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
+
export interface SfFindActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
|
|
260
|
+
find: (id: string, options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S> | undefined>;
|
|
261
|
+
}
|
|
262
|
+
|
|
259
263
|
export interface SfObjActions<OI, N extends KeyOf<OI>> {
|
|
260
264
|
query: <S extends SfRootSelect<OI, N>>(q: { select: S[], where?: SfRootWhere<OI, N>, orderBy?: SfRootOrderBy<OI, N>, limit?: number }) => SfSelectActions<OI, N, S>;
|
|
261
265
|
delete: (ids: string[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
262
266
|
update: (records: SfUpdate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
263
267
|
create: (records: SfCreate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
264
268
|
upsert: <K extends MandatoryCreateProps<OI[N]>>(records: SfUpsert<OI[N], K>[], key: K, options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
|
|
265
|
-
select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfSelectActions<OI, N, S> & SfWhereActions<OI, N, S>);
|
|
269
|
+
select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfSelectActions<OI, N, S> & SfWhereActions<OI, N, S> & SfFindActions<OI, N, S>);
|
|
266
270
|
}
|
|
267
271
|
|
|
268
272
|
// functions
|
|
@@ -509,7 +513,7 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>) {
|
|
|
509
513
|
conn: ISfConnection,
|
|
510
514
|
from: N,
|
|
511
515
|
select: S[],
|
|
512
|
-
where?: SfRootWhere<OI, N>,
|
|
516
|
+
where?: string | SfRootWhere<OI, N>,
|
|
513
517
|
orderBy?: SfRootOrderBy<OI, N>,
|
|
514
518
|
limit?: number
|
|
515
519
|
): SfSelectActions<OI, N, S> {
|
|
@@ -550,8 +554,18 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>) {
|
|
|
550
554
|
|
|
551
555
|
..._query(_conn, from, select, where),
|
|
552
556
|
|
|
553
|
-
orderBy: (orderBy: SfRootOrderBy<OI, N>) => _query(_conn, from, select, where, orderBy)
|
|
554
|
-
|
|
557
|
+
orderBy: (orderBy: SfRootOrderBy<OI, N>) => _query(_conn, from, select, where, orderBy),
|
|
558
|
+
|
|
559
|
+
}),
|
|
560
|
+
|
|
561
|
+
find: async (id: string, options?: SfQueryOptions) => {
|
|
562
|
+
|
|
563
|
+
const result = await _query(_conn, from, select, `Id = '${id}'`).limit(1).get(options);
|
|
564
|
+
|
|
565
|
+
if (result.records.length) {
|
|
566
|
+
return result.records[0];
|
|
567
|
+
}
|
|
568
|
+
}
|
|
555
569
|
|
|
556
570
|
})
|
|
557
571
|
})
|