sfobjects-basic-client 1.2.0 → 1.2.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 +13 -2
- package/dist/index.js +9 -1
- package/package.json +1 -1
- package/src/index.ts +18 -2
package/dist/index.d.ts
CHANGED
|
@@ -214,11 +214,22 @@ export declare class SfBasicClientReadError extends Error {
|
|
|
214
214
|
export declare function isPlainObject(value: unknown): value is Record<string, any>;
|
|
215
215
|
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;
|
|
216
216
|
export declare function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>, o?: SfClientOptions): <N extends KeyOf<OI>>(from: N, _conn: ISfConnection) => SfObjActions<OI, N>;
|
|
217
|
-
export
|
|
218
|
-
|
|
217
|
+
export type SfObjectsIndex<OI> = {
|
|
218
|
+
[N in KeyOf<OI>]: SfObjActions<OI, N>;
|
|
219
|
+
} & {
|
|
220
|
+
__getObject: <N extends KeyOf<OI>>(from: N) => SfObjActions<OI, N>;
|
|
221
|
+
};
|
|
222
|
+
export type SfObjectFlat<O> = {
|
|
223
|
+
[K in KeyOf<O>]: NonNullable<O[K]> extends SfPrimitiveType ? O[K] : NonNullable<O[K]> extends ChildTable<infer CO> ? SfObjectFlat<CO> : SfObjectFlat<NonNullable<O[K]>>;
|
|
219
224
|
};
|
|
225
|
+
export declare const getSfObjects: <OI>(cfg: SfObjCfgIndex<OI>) => (conn: ISfConnection, options?: SfClientOptions) => SfObjectsIndex<OI>;
|
|
220
226
|
export declare const sfObject: <OI, N extends KeyOf<OI>>(cfg: SfObjCfgIndex<OI>, n: N) => {
|
|
221
227
|
info: SfObjCfgIndex<OI>[N];
|
|
222
228
|
select: <S extends SfRootSelect<OI, N>>(s: S[]) => S[];
|
|
229
|
+
wrapSelection: <S extends SfRootSelect<OI, N>>(value: S[]) => {
|
|
230
|
+
value: S[];
|
|
231
|
+
asProjection: (v: any) => SfRootSelectProjection<OI, N, S>;
|
|
232
|
+
asFlatProjection: (v: any) => SfObjectFlat<SfRootSelectProjection<OI, N, S>>;
|
|
233
|
+
};
|
|
223
234
|
};
|
|
224
235
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -315,5 +315,13 @@ const getSfObjects = (cfg) => (conn, options) => {
|
|
|
315
315
|
return Object.assign(Object.assign({}, Object.keys(cfg).reduce((p, n) => (Object.assign(Object.assign({}, p), { [n]: __getObject(n) })), {})), { __getObject });
|
|
316
316
|
};
|
|
317
317
|
exports.getSfObjects = getSfObjects;
|
|
318
|
-
const sfObject = (cfg, n) => ({
|
|
318
|
+
const sfObject = (cfg, n) => ({
|
|
319
|
+
info: cfg[n],
|
|
320
|
+
select: (s) => s,
|
|
321
|
+
wrapSelection: (value) => ({
|
|
322
|
+
value,
|
|
323
|
+
asProjection: (v) => v,
|
|
324
|
+
asFlatProjection: (v) => v
|
|
325
|
+
})
|
|
326
|
+
});
|
|
319
327
|
exports.sfObject = sfObject;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -705,8 +705,16 @@ export function getSfObject<OI>(_cfg: SfObjCfgIndex<OI>, o?: SfClientOptions) {
|
|
|
705
705
|
|
|
706
706
|
}
|
|
707
707
|
|
|
708
|
+
export type SfObjectsIndex<OI> = { [N in KeyOf<OI>]: SfObjActions<OI, N> } & { __getObject: <N extends KeyOf<OI>>(from: N) => SfObjActions<OI, N> };
|
|
708
709
|
|
|
709
|
-
export
|
|
710
|
+
export type SfObjectFlat<O> = {
|
|
711
|
+
[K in KeyOf<O>]:
|
|
712
|
+
NonNullable<O[K]> extends SfPrimitiveType ? O[K] :
|
|
713
|
+
NonNullable<O[K]> extends ChildTable<infer CO> ? SfObjectFlat<CO> :
|
|
714
|
+
SfObjectFlat<NonNullable<O[K]>>
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
export const getSfObjects = <OI>(cfg: SfObjCfgIndex<OI>) => (conn: ISfConnection, options?: SfClientOptions): SfObjectsIndex<OI> => {
|
|
710
718
|
|
|
711
719
|
const __getObject = <N extends KeyOf<OI>>(from: N) => getSfObject<OI>(cfg, options)(from, conn);
|
|
712
720
|
|
|
@@ -716,4 +724,12 @@ export const getSfObjects = <OI>(cfg: SfObjCfgIndex<OI>) => (conn: ISfConnection
|
|
|
716
724
|
};
|
|
717
725
|
}
|
|
718
726
|
|
|
719
|
-
export const sfObject = <OI, N extends KeyOf<OI>>(cfg: SfObjCfgIndex<OI>, n: N) => ({
|
|
727
|
+
export const sfObject = <OI, N extends KeyOf<OI>>(cfg: SfObjCfgIndex<OI>, n: N) => ({
|
|
728
|
+
info: cfg[n],
|
|
729
|
+
select: <S extends SfRootSelect<OI, N>>(s: S[]) => s,
|
|
730
|
+
wrapSelection: <S extends SfRootSelect<OI, N>>(value: S[]) => ({
|
|
731
|
+
value,
|
|
732
|
+
asProjection: (v: any) => v as SfRootSelectProjection<OI, N, S>,
|
|
733
|
+
asFlatProjection: (v: any) => v as SfObjectFlat<SfRootSelectProjection<OI, N, S>>
|
|
734
|
+
})
|
|
735
|
+
});
|