sfobjects-basic-client 1.1.2 → 1.1.4

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
@@ -74,6 +74,13 @@ type MandatoryCreateProps<O> = {
74
74
  -readonly [P in K]: O[P];
75
75
  }, K>) : never) : never;
76
76
  }[KeyOf<O>];
77
+ type UpdateableProps<O> = {
78
+ [K in keyof O]: NonNullable<O[K]> extends SfPrimitiveType ? (IsMutable<{
79
+ [P in K]: O[P];
80
+ }, {
81
+ -readonly [P in K]: O[P];
82
+ }, K>) : never;
83
+ }[KeyOf<O>];
77
84
  export type SfRootSelect<OI, N extends KeyOf<OI>> = SfSelect<GetObjectTypes<OI>, OI[N]>;
78
85
  export type SfRootWhere<OI, N extends KeyOf<OI>> = SfWhere<GetObjectTypes<OI>, OI[N]>;
79
86
  export type SfRootOrderBy<OI, N extends KeyOf<OI>> = SfOrderBy<GetObjectTypes<OI>, OI[N]>;
@@ -88,7 +95,9 @@ export type SfUpsert<O, K extends MandatoryCreateProps<O>> = SfCreate<O> & {
88
95
  };
89
96
  export type SfUpdate<O> = {
90
97
  Id: string;
91
- } & SfCreate<O>;
98
+ } & {
99
+ [K in UpdateableProps<O>]+?: O[K];
100
+ };
92
101
  export type SfObjCfg = {
93
102
  objectPrefix: string;
94
103
  dateTypes: string[];
@@ -178,4 +187,8 @@ export declare function isPlainObject(value: unknown): value is Record<string, a
178
187
  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;
179
188
  export declare function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>): <N extends KeyOf<OI>>(from: N, _conn: ISfConnection) => SfObjActions<OI, N>;
180
189
  export declare const getSfObjects: <OI>(cfg: SfObjCfgIndex<OI>) => (conn: ISfConnection) => { [N in KeyOf<OI>]: SfObjActions<OI, N>; };
190
+ export declare const sfObject: <OI, N extends KeyOf<OI>>(cfg: SfObjCfgIndex<OI>, n: N) => {
191
+ info: SfObjCfgIndex<OI>[N];
192
+ select: <S extends SfRootSelect<OI, N>>(s: S[]) => S[];
193
+ };
181
194
  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;
@@ -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.2",
3
+ "version": "1.1.4",
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
@@ -149,6 +149,16 @@ type MandatoryCreateProps<O> = {
149
149
  }[KeyOf<O>];
150
150
 
151
151
 
152
+ // Update
153
+
154
+ type UpdateableProps<O> = {
155
+ [K in keyof O]: NonNullable<O[K]> extends SfPrimitiveType ? (
156
+ IsMutable<{ [P in K]: O[P] }, { -readonly [P in K]: O[P] }, K>
157
+ ) : never
158
+
159
+ }[KeyOf<O>];
160
+
161
+
152
162
 
153
163
  // Select
154
164
 
@@ -169,11 +179,11 @@ export type SfCreate<O> = { [K in MandatoryCreateProps<O>]: O[K] } & { [K in Opt
169
179
 
170
180
  // Upsert
171
181
 
172
- export type SfUpsert<O, K extends MandatoryCreateProps<O>> = SfCreate<O> & { [P in K]: O[P] };
182
+ export type SfUpsert<O, K extends MandatoryCreateProps<O>/* external keys */> = SfCreate<O> & { [P in K]: O[P] };
173
183
 
174
184
  // Update
175
185
 
176
- export type SfUpdate<O> = { Id: string } & SfCreate<O>;
186
+ export type SfUpdate<O> = { Id: string } & { [K in UpdateableProps<O>]+?: O[K] };
177
187
 
178
188
 
179
189
  // Basic Client
@@ -581,4 +591,6 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>) {
581
591
  export const getSfObjects = <OI>(cfg: SfObjCfgIndex<OI>) => (conn: ISfConnection) => {
582
592
  const _func = getSfObject<OI>(cfg);
583
593
  return (Object.keys(cfg) as KeyOf<OI>[]).reduce((p, n) => ({ ...p, [n]: _func(n, conn) }), {} as { [N in KeyOf<OI>]: SfObjActions<OI, N> });
584
- }
594
+ }
595
+
596
+ 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 });