sfobjects-basic-client 1.1.0 → 1.1.2

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 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,10 @@ 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 SfSelectAditionalActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
161
+ find: (id: string, options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S> | undefined>;
162
+ selection: S[];
163
+ }
160
164
  export interface SfObjActions<OI, N extends KeyOf<OI>> {
161
165
  query: <S extends SfRootSelect<OI, N>>(q: {
162
166
  select: S[];
@@ -168,7 +172,7 @@ export interface SfObjActions<OI, N extends KeyOf<OI>> {
168
172
  update: (records: SfUpdate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
169
173
  create: (records: SfCreate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
170
174
  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>);
175
+ select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfSelectActions<OI, N, S> & SfWhereActions<OI, N, S> & SfSelectAditionalActions<OI, N, S>);
172
176
  }
173
177
  export declare function isPlainObject(value: unknown): value is Record<string, any>;
174
178
  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
+ }), selection: select }))
245
250
  });
246
251
  };
247
252
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfobjects-basic-client",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Basic Salesforce Client to use together with sfobjects-to-typescript lib",
5
5
  "license": "ISC",
6
6
  "author": "Murad Aliyev",
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,19 @@ 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 SfSelectAditionalActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
260
+ find: (id: string, options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S> | undefined>;
261
+ selection: S[];
262
+ //S extends SfRootSelect<OI, N>
263
+ }
264
+
259
265
  export interface SfObjActions<OI, N extends KeyOf<OI>> {
260
266
  query: <S extends SfRootSelect<OI, N>>(q: { select: S[], where?: SfRootWhere<OI, N>, orderBy?: SfRootOrderBy<OI, N>, limit?: number }) => SfSelectActions<OI, N, S>;
261
267
  delete: (ids: string[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
262
268
  update: (records: SfUpdate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
263
269
  create: (records: SfCreate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
264
270
  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>);
271
+ select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfSelectActions<OI, N, S> & SfWhereActions<OI, N, S> & SfSelectAditionalActions<OI, N, S>);
266
272
  }
267
273
 
268
274
  // functions
@@ -509,7 +515,7 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>) {
509
515
  conn: ISfConnection,
510
516
  from: N,
511
517
  select: S[],
512
- where?: SfRootWhere<OI, N>,
518
+ where?: string | SfRootWhere<OI, N>,
513
519
  orderBy?: SfRootOrderBy<OI, N>,
514
520
  limit?: number
515
521
  ): SfSelectActions<OI, N, S> {
@@ -550,8 +556,20 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>) {
550
556
 
551
557
  ..._query(_conn, from, select, where),
552
558
 
553
- orderBy: (orderBy: SfRootOrderBy<OI, N>) => _query(_conn, from, select, where, orderBy)
554
- })
559
+ orderBy: (orderBy: SfRootOrderBy<OI, N>) => _query(_conn, from, select, where, orderBy),
560
+
561
+ }),
562
+
563
+ find: async (id: string, options?: SfQueryOptions) => {
564
+
565
+ const result = await _query(_conn, from, select, `Id = '${id}'`).limit(1).get(options);
566
+
567
+ if (result.records.length) {
568
+ return result.records[0];
569
+ }
570
+ },
571
+
572
+ selection: select
555
573
 
556
574
  })
557
575
  })