sfobjects-basic-client 1.1.1 → 1.1.3

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
@@ -157,8 +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>> {
160
+ export interface SfSelectAditionalActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
161
161
  find: (id: string, options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S> | undefined>;
162
+ selection: S[];
162
163
  }
163
164
  export interface SfObjActions<OI, N extends KeyOf<OI>> {
164
165
  query: <S extends SfRootSelect<OI, N>>(q: {
@@ -171,10 +172,14 @@ export interface SfObjActions<OI, N extends KeyOf<OI>> {
171
172
  update: (records: SfUpdate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
172
173
  create: (records: SfCreate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
173
174
  upsert: <K extends MandatoryCreateProps<OI[N]>>(records: SfUpsert<OI[N], K>[], key: K, options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
174
- select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfSelectActions<OI, N, S> & SfWhereActions<OI, N, S> & SfFindActions<OI, N, S>);
175
+ select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfSelectActions<OI, N, S> & SfWhereActions<OI, N, S> & SfSelectAditionalActions<OI, N, S>);
175
176
  }
176
177
  export declare function isPlainObject(value: unknown): value is Record<string, any>;
177
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;
178
179
  export declare function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>): <N extends KeyOf<OI>>(from: N, _conn: ISfConnection) => SfObjActions<OI, N>;
179
180
  export declare const getSfObjects: <OI>(cfg: SfObjCfgIndex<OI>) => (conn: ISfConnection) => { [N in KeyOf<OI>]: SfObjActions<OI, N>; };
181
+ export declare const sfObject: <OI, N extends KeyOf<OI>>(cfg: SfObjCfgIndex<OI>, n: N) => {
182
+ info: SfObjCfgIndex<OI>[N];
183
+ select: <S extends SfRootSelect<OI, N>>(s: S[]) => S[];
184
+ };
180
185
  export {};
package/dist/index.js CHANGED
@@ -21,7 +21,7 @@ var __rest = (this && this.__rest) || function (s, e) {
21
21
  return t;
22
22
  };
23
23
  Object.defineProperty(exports, "__esModule", { value: true });
24
- exports.getSfObjects = void 0;
24
+ exports.sfObject = exports.getSfObjects = void 0;
25
25
  exports.isPlainObject = isPlainObject;
26
26
  exports.constructSoql = constructSoql;
27
27
  exports.getSfObject = getSfObject;
@@ -246,7 +246,7 @@ function getSfObject(_cfg) {
246
246
  if (result.records.length) {
247
247
  return result.records[0];
248
248
  }
249
- }) }))
249
+ }), selection: select }))
250
250
  });
251
251
  };
252
252
  }
@@ -255,3 +255,5 @@ const getSfObjects = (cfg) => (conn) => {
255
255
  return Object.keys(cfg).reduce((p, n) => (Object.assign(Object.assign({}, p), { [n]: _func(n, conn) })), {});
256
256
  };
257
257
  exports.getSfObjects = getSfObjects;
258
+ const sfObject = (cfg, n) => ({ info: cfg[n], select: (s) => s });
259
+ exports.sfObject = sfObject;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sfobjects-basic-client",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
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
@@ -256,8 +256,10 @@ 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>> {
259
+ export interface SfSelectAditionalActions<OI, N extends KeyOf<OI>, S extends SfRootSelect<OI, N>> {
260
260
  find: (id: string, options?: SfQueryOptions) => Promise<SfRootSelectProjection<OI, N, S> | undefined>;
261
+ selection: S[];
262
+ //S extends SfRootSelect<OI, N>
261
263
  }
262
264
 
263
265
  export interface SfObjActions<OI, N extends KeyOf<OI>> {
@@ -266,7 +268,7 @@ export interface SfObjActions<OI, N extends KeyOf<OI>> {
266
268
  update: (records: SfUpdate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
267
269
  create: (records: SfCreate<OI[N]>[], options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
268
270
  upsert: <K extends MandatoryCreateProps<OI[N]>>(records: SfUpsert<OI[N], K>[], key: K, options?: SfDmlOptions) => PromiseLike<SfSaveResult[]>;
269
- select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfSelectActions<OI, N, S> & SfWhereActions<OI, N, S> & SfFindActions<OI, N, S>);
271
+ select: <S extends SfRootSelect<OI, N>>(select: S[]) => (SfSelectActions<OI, N, S> & SfWhereActions<OI, N, S> & SfSelectAditionalActions<OI, N, S>);
270
272
  }
271
273
 
272
274
  // functions
@@ -557,15 +559,17 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>) {
557
559
  orderBy: (orderBy: SfRootOrderBy<OI, N>) => _query(_conn, from, select, where, orderBy),
558
560
 
559
561
  }),
560
-
562
+
561
563
  find: async (id: string, options?: SfQueryOptions) => {
562
-
564
+
563
565
  const result = await _query(_conn, from, select, `Id = '${id}'`).limit(1).get(options);
564
-
566
+
565
567
  if (result.records.length) {
566
568
  return result.records[0];
567
569
  }
568
- }
570
+ },
571
+
572
+ selection: select
569
573
 
570
574
  })
571
575
  })
@@ -577,4 +581,6 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>) {
577
581
  export const getSfObjects = <OI>(cfg: SfObjCfgIndex<OI>) => (conn: ISfConnection) => {
578
582
  const _func = getSfObject<OI>(cfg);
579
583
  return (Object.keys(cfg) as KeyOf<OI>[]).reduce((p, n) => ({ ...p, [n]: _func(n, conn) }), {} as { [N in KeyOf<OI>]: SfObjActions<OI, N> });
580
- }
584
+ }
585
+
586
+ export const sfObject = <OI, N extends KeyOf<OI>>(cfg: SfObjCfgIndex<OI>, n: N) => ({ info: cfg[n], select: <S extends SfRootSelect<OI, N>>(s: S[]) => s });