From 2aa70ed5f1a0c6b6a4b54652e71551ff46c8e79c Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 14:55:08 +0600 Subject: [PATCH 01/82] Add insert doc --- imports/client.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index be215102..c986dc81 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -729,6 +729,12 @@ export class DeepClient = Link> implements DeepCl } }; + /** + * Inserts a value into the database. By default inserts a link to the links table + * @param objects An object or array of objects to insert to the database + * @param options An object with options for the insert operation + * @returns A promise that resolves to the inserted object or an array of inserted objects with the fields provided by {@link options.returning} which is by default 'id' + */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; checkAndFillShorts(_objects); From 2ebc589acba281eebdbf921aea5cf7d6188038ff Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:19:31 +0600 Subject: [PATCH 02/82] Add update doc --- imports/client.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index c986dc81..0ca9b6db 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -761,6 +761,13 @@ export class DeepClient = Link> implements DeepCl return { ...q, data: (q)?.data?.m0?.returning }; }; + /** + * Updates a value in the database. By default updates a link in the links table + * @param exp An expression to filter the objects to update + * @param value A value to update the objects with + * @param options An object with options for the update operation + * @returns A promise that resolves to the updated object or an array of updated objects with the fields configured by {@link options.returning} which is by default 'id' + */ async update(exp: Exp, value: UpdateValue, options?: WriteOptions):Promise> { if (exp === null) return this.insert( [value], options); if (value === null) return this.delete( exp, options ); From ccca433523fe554acf36f65bb08cc2a2c0a3c471 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:19:42 +0600 Subject: [PATCH 03/82] Update insert doc --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index 0ca9b6db..349d2fb2 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -733,7 +733,7 @@ export class DeepClient = Link> implements DeepCl * Inserts a value into the database. By default inserts a link to the links table * @param objects An object or array of objects to insert to the database * @param options An object with options for the insert operation - * @returns A promise that resolves to the inserted object or an array of inserted objects with the fields provided by {@link options.returning} which is by default 'id' + * @returns A promise that resolves to the inserted object or an array of inserted objects with the fields configured by {@link options.returning} which is by default 'id' */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; From b432efdc33513dd09f13afc3046df66b592e555c Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:20:28 +0600 Subject: [PATCH 04/82] Add delete doc --- imports/client.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 349d2fb2..e82d39d4 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -793,6 +793,12 @@ export class DeepClient = Link> implements DeepCl return { ...q, data: (q)?.data?.m0?.returning }; }; + /** + * Deletes a value in the database. By default deletes a link in the links table + * @param exp An expression to filter the objects to delete + * @param options An object with options for the delete operation + * @returns A promise that resolves to the deleted object or an array of deleted objects with the fields configured by {@link options.returning} which is by default 'id' + */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); const query = serializeQuery(exp, options?.table === this.table || !options?.table ? 'links' : 'value'); From 32f255531b17e3349e3cf0a2863968defd2997d5 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:22:38 +0600 Subject: [PATCH 05/82] Add serial doc --- imports/client.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/imports/client.tsx b/imports/client.tsx index e82d39d4..c4a2eb16 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -822,9 +822,15 @@ export class DeepClient = Link> implements DeepCl return { ...q, data: (q)?.data?.m0?.returning }; }; - async serial({ - name, operations, returning, silent - }: AsyncSerialParams): Promise> { + /** + * Performs write operations to the database in a serial manner + * @param options An object with data for the serial operation + * @returns A promise that resolves to the deleted object or an array of deleted objects with the fields configured by {@link options.returning} which is by default 'id' + */ + async serial(options: AsyncSerialParams): Promise> { + const { + name, operations, returning, silent + } = options; // @ts-ignore let operationsGroupedByTypeAndTable: Record>> = {}; operationsGroupedByTypeAndTable = operations.reduce((acc, operation) => { From d0ad85374a179d805fc583d0474a50d656bba0ee Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:23:49 +0600 Subject: [PATCH 06/82] Add await doc --- imports/client.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index c4a2eb16..3aa72243 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -895,6 +895,12 @@ export class DeepClient = Link> implements DeepCl return reserve({ count, client: this.apolloClient }); }; + /** + * Await for a promise + * @param id Id of a link which is processed by a handler + * @param options An object with options for the await operation + * @returns A promise that resolves to the result of the awaited promise + */ async await(id: number, options: { results: boolean } = { results: false } ): Promise { return awaitPromise({ id, client: this.apolloClient, From 2b19f03227225b800af89d32dce973839c8a70a0 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:25:54 +0600 Subject: [PATCH 07/82] Add id doc --- imports/client.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/imports/client.tsx b/imports/client.tsx index 3aa72243..4eb982c0 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -911,12 +911,17 @@ export class DeepClient = Link> implements DeepCl Results: options.results }); }; - - /** +/** * Find id of link by packageName/id as first argument, and Contain value (name) as path items. * @description Thows error if id is not found. You can set last argument true, for disable throwing error. * @returns number */ + /** + * Find id of a link by link name or id and contain values (names) as path items + * @param start A name or id of a link + * @param path Contain values (names) as path items + * @returns A promise that resolves to the id of the link + */ async id(start: DeepClientStartItem | QueryLink, ...path: DeepClientPathItem[]): Promise { if (typeof(start) === 'object') { return ((await this.select(start)) as any)?.data?.[0]?.id; From e8da48b4a9fcb2fe279a85ec9a72654e3fae30bf Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:48:52 +0600 Subject: [PATCH 08/82] Remove unused doc --- imports/client.tsx | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/imports/client.tsx b/imports/client.tsx index 4eb982c0..355f004c 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -911,11 +911,7 @@ export class DeepClient = Link> implements DeepCl Results: options.results }); }; -/** - * Find id of link by packageName/id as first argument, and Contain value (name) as path items. - * @description Thows error if id is not found. You can set last argument true, for disable throwing error. - * @returns number - */ + /** * Find id of a link by link name or id and contain values (names) as path items * @param start A name or id of a link @@ -991,6 +987,12 @@ export class DeepClient = Link> implements DeepCl return result; } + /** + * + * @param start + * @param path + * @returns + */ idLocal(start: DeepClientStartItem, ...path: DeepClientPathItem[]): number { const paths = [start, ...path] as [DeepClientStartItem, ...Array>]; if (get(_ids, paths.join('.'))) { From e5329a0006d2c7273381378d4fd119927c1b2c0f Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:49:20 +0600 Subject: [PATCH 09/82] Add idLocal doc --- imports/client.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/imports/client.tsx b/imports/client.tsx index 355f004c..9ac1c10b 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -988,10 +988,10 @@ export class DeepClient = Link> implements DeepCl } /** - * - * @param start - * @param path - * @returns + * Find id of a link from minilinks by link name or id and contain values (names) as path items + * @param start A name or id of a link + * @param path Contain values (names) as path items + * @returns A promise that resolves to the id of the link */ idLocal(start: DeepClientStartItem, ...path: DeepClientPathItem[]): number { const paths = [start, ...path] as [DeepClientStartItem, ...Array>]; From 378a1796f2b77691fd94ccf536ded7aaed580e4e Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:50:23 +0600 Subject: [PATCH 10/82] Update whoami doc --- imports/client.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/imports/client.tsx b/imports/client.tsx index 9ac1c10b..97adff71 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1058,8 +1058,7 @@ export class DeepClient = Link> implements DeepCl }; /** - * Return is of current authorized user linkId. - * Refill client.linkId and return. + * Returns id of the current user */ async whoami(): Promise { const result = await this.apolloClient.query({ query: WHOISME }); From ac31d24aac08830a194ab69512c5060e7f271503 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:51:17 +0600 Subject: [PATCH 11/82] Add login doc --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 97adff71..5ecb8c32 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1066,6 +1066,11 @@ export class DeepClient = Link> implements DeepCl return result?.data?.jwt?.linkId; } + /** + * Performs a login operation + * @param options An object with options for the login operation + * @returns A promsie that resolves to the result of the login operation + */ async login(options: DeepClientJWTOptions): Promise { const jwtResult = await this.jwt({ ...options, relogin: true }); this.token = jwtResult.token; From 6a5b36218133303c6a9ab0b2c13c24da6c56b1ae Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:51:34 +0600 Subject: [PATCH 12/82] Add logout doc --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 5ecb8c32..33e9f5be 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1078,6 +1078,11 @@ export class DeepClient = Link> implements DeepCl return jwtResult }; + /** + * Performs a logout operation + * @param options An object with options for the logout operation + * @returns A promsie that resolves to the result of the logout operation + */ async logout(): Promise { if (this?.handleAuth) setTimeout(() => this?.handleAuth(0, ''), 0); return { linkId: 0, token: '' }; From ab1f639047832e066ecbfc1bb00fc507e5bfe67a Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:52:33 +0600 Subject: [PATCH 13/82] Add can doc --- imports/client.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 33e9f5be..876e6b9a 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1088,6 +1088,9 @@ export class DeepClient = Link> implements DeepCl return { linkId: 0, token: '' }; }; + /** + * Checks whether {@link subjectUds} can perform {@link actionIds} on {@link objectIds} + */ async can(objectIds: null | number | number[], subjectIds: null | number | number[], actionIds: null | number | number[], userIds: number | number[] = this.linkId) { const where: any = { }; From 4662ae23f2993cb8a357b900f25e93e5766d067b Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:53:43 +0600 Subject: [PATCH 14/82] Add name doc --- imports/client.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 876e6b9a..3cbd570a 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1101,6 +1101,9 @@ export class DeepClient = Link> implements DeepCl return !!result?.data?.length; } + /** + * Returns a name of a link {@link input} that is located in a value of a contain link pointing to the link {@link input} + */ async name(input: Link | number): Promise { const id = typeof(input) === 'number' ? input : input.id; From b1c8659a0b2f8e8fab35e7d41839a6bed08a5b01 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 15:54:10 +0600 Subject: [PATCH 15/82] Add nameLocal doc --- imports/client.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 3cbd570a..a6d9b888 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1120,6 +1120,9 @@ export class DeepClient = Link> implements DeepCl return containLink?.value?.value; }; + /** + * Returns a name of a link {@link input} that is located in a value of a contain link pointing to the link {@link input} according to links stored in minilinks + */ nameLocal(input: Link | number): string | undefined { const id = typeof(input) === 'number' ? input : input?.id; if (!id) return; From af620fb378d1d61c8db58948ac3727889892337a Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Fri, 9 Feb 2024 16:11:07 +0600 Subject: [PATCH 16/82] Add select doc --- imports/client.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index a6d9b888..f9a546d9 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -622,6 +622,12 @@ export class DeepClient = Link> implements DeepCl serializeQuery = serializeQuery; serializeWhere = serializeWhere; + /** + * Gets a value from the database. By default gets a link from the links table + * @param exp A filter expression to filter the objects to get + * @param options An object with options for the select operation + * @returns A promise that resolves to the selected object or an array of selected objects with the fields configured by {@link options.returning} which is by default 'id' + */ async select(exp: Exp, options?: ReadOptions): Promise> { if (!exp) { return { error: { message: '!exp' }, data: undefined, loading: false, networkStatus: undefined }; From f5012b536d86ec3abf24ffe58167201d32175189 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:07:33 +0600 Subject: [PATCH 17/82] Update subscribe doc --- imports/client.tsx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/imports/client.tsx b/imports/client.tsx index f9a546d9..b68b6dc8 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -676,9 +676,11 @@ export class DeepClient = Link> implements DeepCl }; /** - * deep.subscribe + * Subscribes to data in the database * @example - * deep.subscribe({ up: { link_id: 380 } }).subscribe({ next: (links) => {}, error: (err) => {} }); + * ``` + * deep.subscribe({ up: { link_id: deep.linkId } }).subscribe({ next: (links) => {}, error: (err) => {} }); + * ``` */ subscribe(exp: Exp, options?: ReadOptions): Observable { if (!exp) { From 09fa165b4090a91341d0c875fb5199f96d54c0ee Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:09:05 +0600 Subject: [PATCH 18/82] Add select by id example --- imports/client.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index b68b6dc8..4e51c833 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -627,6 +627,14 @@ export class DeepClient = Link> implements DeepCl * @param exp A filter expression to filter the objects to get * @param options An object with options for the select operation * @returns A promise that resolves to the selected object or an array of selected objects with the fields configured by {@link options.returning} which is by default 'id' + * + * @example + * #### Select by id + * ``` + * await deep.select({ + * id: deep.linkId + * }) + * ``` */ async select(exp: Exp, options?: ReadOptions): Promise> { if (!exp) { From f3b17909c3c8f97f9e7fdad2b1e6ebe669f716b8 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:09:49 +0600 Subject: [PATCH 19/82] Add select by type_id example --- imports/client.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 4e51c833..fc9a8372 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -635,6 +635,15 @@ export class DeepClient = Link> implements DeepCl * id: deep.linkId * }) * ``` + * + * #### Select by type_id + * ``` + * await deep.select({ + * type_id: { + * _id: ["@deep-foundation/core", "User"] + * } + * }) + * ``` */ async select(exp: Exp, options?: ReadOptions): Promise> { if (!exp) { From 1e1909bf5aa6160b9894f170fc486c4bdc159f43 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:10:18 +0600 Subject: [PATCH 20/82] Add select by from_id example --- imports/client.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index fc9a8372..01845f75 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -644,6 +644,13 @@ export class DeepClient = Link> implements DeepCl * } * }) * ``` + * + * #### Select by from_id + * ``` + * await deep.select({ + * from_id: deep.linkId + * }) + * ``` */ async select(exp: Exp, options?: ReadOptions): Promise> { if (!exp) { From a89e1a0c2aef07e2faba344047dc6b1659753db3 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:11:41 +0600 Subject: [PATCH 21/82] Add select by to_id example --- imports/client.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 01845f75..6f72f55f 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -651,6 +651,13 @@ export class DeepClient = Link> implements DeepCl * from_id: deep.linkId * }) * ``` + * + * #### Select by to_id + * ``` + * await deep.select({ + * to_id: deep.linkId + * }) + * ``` */ async select(exp: Exp, options?: ReadOptions): Promise> { if (!exp) { From 2e7e7dff9c4de2755f70f6b21414e09f7d62e7db Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:14:24 +0600 Subject: [PATCH 22/82] Add select by string value example --- imports/client.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 6f72f55f..b2a08009 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -658,6 +658,17 @@ export class DeepClient = Link> implements DeepCl * to_id: deep.linkId * }) * ``` + * + * #### Select by string value + * ``` + * await deep.select({ + * string: { + * value: { + * _eq: "MyString" + * } + * } + * }) + * ``` */ async select(exp: Exp, options?: ReadOptions): Promise> { if (!exp) { From 8cf8f10654db4686d92590c1e374f4b13698c62d Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:14:48 +0600 Subject: [PATCH 23/82] Add select by number example --- imports/client.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index b2a08009..b2c91c13 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -669,6 +669,17 @@ export class DeepClient = Link> implements DeepCl * } * }) * ``` + * + * #### Select by number value + * ``` + * await deep.select({ + * number: { + * value: { + * _eq: 888 + * } + * } + * }) + * ``` */ async select(exp: Exp, options?: ReadOptions): Promise> { if (!exp) { From 198b154f3cc79e7f2c3c44caabfb16285ef46033 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:16:30 +0600 Subject: [PATCH 24/82] Add select by object value example --- imports/client.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index b2c91c13..ff2e6a83 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -680,6 +680,19 @@ export class DeepClient = Link> implements DeepCl * } * }) * ``` + * + * #### Select by object value + * ``` + * await deep.select({ + * object: { + * value: { + * _eq: { + * myFieldKey: "myFieldValue" + * } + * } + * } + * }) + * ``` */ async select(exp: Exp, options?: ReadOptions): Promise> { if (!exp) { From 69dea0ce24fe772c789d51e5c2b1f902765976bc Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:18:09 +0600 Subject: [PATCH 25/82] Add `Insert without from and to` example --- imports/client.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index ff2e6a83..6e5d9ad8 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -808,6 +808,14 @@ export class DeepClient = Link> implements DeepCl * @param objects An object or array of objects to insert to the database * @param options An object with options for the insert operation * @returns A promise that resolves to the inserted object or an array of inserted objects with the fields configured by {@link options.returning} which is by default 'id' + * + * @example + * #### Insert by without from and to + * ``` + * await deep.insert({ + * type_id: await deep.id("@deep-foundation/core", "Type") + * }) + * ``` */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; From 9269e5832071357d635209170496686da7faff0c Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:20:35 +0600 Subject: [PATCH 26/82] Add `Insert with from and to` example --- imports/client.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index 6e5d9ad8..51e6ff9d 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -810,12 +810,22 @@ export class DeepClient = Link> implements DeepCl * @returns A promise that resolves to the inserted object or an array of inserted objects with the fields configured by {@link options.returning} which is by default 'id' * * @example - * #### Insert by without from and to + * #### Insert without from and to * ``` * await deep.insert({ * type_id: await deep.id("@deep-foundation/core", "Type") * }) * ``` + * + * #### Insert with from and to + * ``` + * await deep.insert({ + * type_id: await deep.id("@deep-foundation/core", "Type"), + * from_id: await deep.id("@deep-foundation/core", "Package"), + * to_id: await deep.id("@deep-foundation/core", "User") + * }) + * ``` + * In this case instances of your type will must have from of type Package and to of type User */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; From 01e4443224faa3d8b62efd151b819b19f5c6b8c5 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:20:56 +0600 Subject: [PATCH 27/82] Update `Insert without from and to` example --- imports/client.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/imports/client.tsx b/imports/client.tsx index 51e6ff9d..fb3451e6 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -816,6 +816,7 @@ export class DeepClient = Link> implements DeepCl * type_id: await deep.id("@deep-foundation/core", "Type") * }) * ``` + * In this case instances of your type will not have from and to * * #### Insert with from and to * ``` From 906ac65ee2cde677ad65480b96f48ed7d104c941 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:21:55 +0600 Subject: [PATCH 28/82] Add `Insert with from and to equal to any` example --- imports/client.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index fb3451e6..2cfffaa7 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -827,6 +827,16 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case instances of your type will must have from of type Package and to of type User + * + * #### Insert with from and to equal to any + * ``` + * await deep.insert({ + * type_id: await deep.id("@deep-foundation/core", "Type"), + * from_id: await deep.id("@deep-foundation/core", "Any"), + * to_id: await deep.id("@deep-foundation/core", "Any") + * }) + * ``` + * In this case instances of your type can have any type of from and to */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; From b65d73b711bff59693c093feffeefbbdcc19c868 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:22:21 +0600 Subject: [PATCH 29/82] Rename to `Insert Type from Package to User` --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index 2cfffaa7..95dda9f4 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -818,7 +818,7 @@ export class DeepClient = Link> implements DeepCl * ``` * In this case instances of your type will not have from and to * - * #### Insert with from and to + * #### Insert Type from Package to User * ``` * await deep.insert({ * type_id: await deep.id("@deep-foundation/core", "Type"), From 16998161da23dd8535f5d923f2e54326c28ed69b Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:22:35 +0600 Subject: [PATCH 30/82] Rename to `Insert Type` --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index 95dda9f4..72e743c9 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -810,7 +810,7 @@ export class DeepClient = Link> implements DeepCl * @returns A promise that resolves to the inserted object or an array of inserted objects with the fields configured by {@link options.returning} which is by default 'id' * * @example - * #### Insert without from and to + * #### Insert Type * ``` * await deep.insert({ * type_id: await deep.id("@deep-foundation/core", "Type") From 5f6b2115ffde3d93d850645f2885971f8e1e3beb Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:23:06 +0600 Subject: [PATCH 31/82] Rename to `Insert Type with from Any to Any` --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index 72e743c9..342542f2 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -828,7 +828,7 @@ export class DeepClient = Link> implements DeepCl * ``` * In this case instances of your type will must have from of type Package and to of type User * - * #### Insert with from and to equal to any + * #### Insert Type with from Any to Any * ``` * await deep.insert({ * type_id: await deep.id("@deep-foundation/core", "Type"), From b633711358cb948cd76f997a5887aa09054430a8 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:24:04 +0600 Subject: [PATCH 32/82] Update `Insert Type with from Any to Any` example --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index 342542f2..ce721c08 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -836,7 +836,7 @@ export class DeepClient = Link> implements DeepCl * to_id: await deep.id("@deep-foundation/core", "Any") * }) * ``` - * In this case instances of your type can have any type of from and to + * In this case instances of your type may go from instances of any link to instances of any link without restrictions */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; From fd96e3ec6b355f67155adad5a718868a55ec3dda Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:24:48 +0600 Subject: [PATCH 33/82] Update `Insert Type from Package to User` example --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index ce721c08..85f28380 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -826,7 +826,7 @@ export class DeepClient = Link> implements DeepCl * to_id: await deep.id("@deep-foundation/core", "User") * }) * ``` - * In this case instances of your type will must have from of type Package and to of type User + * In this case instances of your type will must go from instances of Package to instances of User * * #### Insert Type with from Any to Any * ``` From af7a8dbf4fc34cdbbfb496b23ef4df84fdd8eeeb Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:25:41 +0600 Subject: [PATCH 34/82] Add `Insert Type with from Package to Any` example --- imports/client.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 85f28380..1f050532 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -837,6 +837,16 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case instances of your type may go from instances of any link to instances of any link without restrictions + * + * #### Insert Type with from Package to Any + * ``` + * await deep.insert({ + * type_id: await deep.id("@deep-foundation/core", "Type"), + * from_id: await deep.id("@deep-foundation/core", "Package"), + * to_id: await deep.id("@deep-foundation/core", "Any") + * }) + * ``` + * In this case instances of your type may go from instances of Package to instances of any link without restrictions */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; From 9e946f2279104e1532399e11769bbe764a84617f Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:26:23 +0600 Subject: [PATCH 35/82] Add `Insert Type with from Any to Package` example --- imports/client.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 1f050532..393447e6 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -847,6 +847,16 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case instances of your type may go from instances of Package to instances of any link without restrictions + * + * #### Insert Type with from Any to Package + * ``` + * await deep.insert({ + * type_id: await deep.id("@deep-foundation/core", "Type"), + * from_id: await deep.id("@deep-foundation/core", "Any"), + * to_id: await deep.id("@deep-foundation/core", "Package") + * }) + * ``` + * In this case instances of your type may go from instances of any link without restrictions to instances of Package */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; From 96000046e9df03d84e1314e0a67e46489fa1a412 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:29:19 +0600 Subject: [PATCH 36/82] Add `Insert string` example --- imports/client.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 393447e6..9f293c6c 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -857,6 +857,17 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case instances of your type may go from instances of any link without restrictions to instances of Package + * + * #### Insert string + * ``` + * await deep.insert({ + * link_id: 888, + * value: 'MyString' + * }, { + * table: 'strings' + * }) + * ``` + * Note: If a link already has value you should update its value, not insert */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; From 723a7f60b70aaafe1ab94c071d1176b42c676ace Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:29:50 +0600 Subject: [PATCH 37/82] Add `Insert number` example --- imports/client.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 9f293c6c..b84d7c47 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -868,6 +868,17 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * Note: If a link already has value you should update its value, not insert + * + * #### Insert number + * ``` + * await deep.insert({ + * link_id: 888, + * value: 888 + * }, { + * table: 'numbers' + * }) + * ``` + * Note: If a link already has value you should update its value, not insert */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; From bed455f5b1c3e28fcc5b0c2bf5b517f8df38e5f8 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:30:23 +0600 Subject: [PATCH 38/82] Add `Insert object` example --- imports/client.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index b84d7c47..7f4a0fe7 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -879,6 +879,19 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * Note: If a link already has value you should update its value, not insert + * + * #### Insert object + * ``` + * await deep.insert({ + * link_id: 888, + * value: { + * myFieldName: 'myFieldValue' + * } + * }, { + * table: 'objects' + * }) + * ``` + * Note: If a link already has value you should update its value, not insert */ async insert(objects: InsertObjects, options?: WriteOptions):Promise> { const _objects = Object.prototype.toString.call(objects) === '[object Array]' ? objects : [objects]; From e7e0e157af5c84b5380a4b32623088b3a704dd6c Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:33:50 +0600 Subject: [PATCH 39/82] Add `Update from by id` example --- imports/client.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 7f4a0fe7..d8e00651 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -925,6 +925,17 @@ export class DeepClient = Link> implements DeepCl * @param value A value to update the objects with * @param options An object with options for the update operation * @returns A promise that resolves to the updated object or an array of updated objects with the fields configured by {@link options.returning} which is by default 'id' + * + * @example + * #### Update from by id + * ``` + * await deep.update({ + * id: 888 + * }, { + * from_id: 1 + * }) + * ``` + * In this case link from_id will be updated to 1 for link with id 888 */ async update(exp: Exp, value: UpdateValue, options?: WriteOptions):Promise> { if (exp === null) return this.insert( [value], options); From eb5fbd86a58cf79f083099f8589b33239c7ceb1c Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:34:12 +0600 Subject: [PATCH 40/82] Add `Update to by id` example --- imports/client.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index d8e00651..1e2b7aac 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -936,6 +936,16 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case link from_id will be updated to 1 for link with id 888 + * + * #### Update to by id + * ``` + * await deep.update({ + * id: 888 + * }, { + * to_id: 1 + * }) + * ``` + * In this case link to_id will be updated to 1 for link with id 888 */ async update(exp: Exp, value: UpdateValue, options?: WriteOptions):Promise> { if (exp === null) return this.insert( [value], options); From 03df3bdd2fa08bacb7ede28bf0f180e9e26fdf3e Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:36:26 +0600 Subject: [PATCH 41/82] Add `Update string value by link id` example --- imports/client.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 1e2b7aac..9569b4ad 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -946,6 +946,22 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case link to_id will be updated to 1 for link with id 888 + * + * #### Update string value by link id + * ``` + * await deep.update( + * { + * link_id: 888 + * }, + * { + * value: "MyStringValue" + * }, + * { + * table: 'strings' + * } + * ) + * ``` + * In this case string value will be updated to "MyStringValue" for link with id 888 */ async update(exp: Exp, value: UpdateValue, options?: WriteOptions):Promise> { if (exp === null) return this.insert( [value], options); From ca8923ede78c305f5d91b4af14fa53b7553c727f Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:36:35 +0600 Subject: [PATCH 42/82] Update `Update to by id` examle --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index 9569b4ad..7581a78e 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -945,7 +945,7 @@ export class DeepClient = Link> implements DeepCl * to_id: 1 * }) * ``` - * In this case link to_id will be updated to 1 for link with id 888 + * In this case to_id will be updated to 1 for link with id 888 * * #### Update string value by link id * ``` From 4db83403d15eaf49dbac93b893333ede8eea7110 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:36:45 +0600 Subject: [PATCH 43/82] Update `Update from by id` example --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index 7581a78e..6d3135f7 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -935,7 +935,7 @@ export class DeepClient = Link> implements DeepCl * from_id: 1 * }) * ``` - * In this case link from_id will be updated to 1 for link with id 888 + * In this case from_id will be updated to 1 for link with id 888 * * #### Update to by id * ``` From fb664b118d7fe92814a050705f493384d42d64b8 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:37:14 +0600 Subject: [PATCH 44/82] Add `Update number value by link id` example --- imports/client.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 6d3135f7..8a069531 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -962,6 +962,22 @@ export class DeepClient = Link> implements DeepCl * ) * ``` * In this case string value will be updated to "MyStringValue" for link with id 888 + * + * #### Update number value by link id + * ``` + * await deep.update( + * { + * link_id: 888 + * }, + * { + * value: 888 + * }, + * { + * table: 'numbers' + * } + * ) + * ``` + * In this case number value will be updated to 888 for link with id 888 */ async update(exp: Exp, value: UpdateValue, options?: WriteOptions):Promise> { if (exp === null) return this.insert( [value], options); From 33d71b5b82040dd3f887ef450d8449776dd0226b Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:37:58 +0600 Subject: [PATCH 45/82] Add `Update object value by link id` example --- imports/client.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 8a069531..2483bb95 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -978,6 +978,24 @@ export class DeepClient = Link> implements DeepCl * ) * ``` * In this case number value will be updated to 888 for link with id 888 + * + * #### Update object value by link id + * ``` + * await deep.update( + * { + * link_id: 888 + * }, + * { + * value: { + * myFieldName: "myFieldValue" + * } + * }, + * { + * table: 'numbers' + * } + * ) + * ``` + * In this case number value will be updated to { myFieldName: "myFieldValue" } for link with id 888 */ async update(exp: Exp, value: UpdateValue, options?: WriteOptions):Promise> { if (exp === null) return this.insert( [value], options); From 391b5daa1d6d80c6bb830000b2b794c8783c9db6 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:39:48 +0600 Subject: [PATCH 46/82] Add `Delete by id` example --- imports/client.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 2483bb95..4432a49e 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1027,6 +1027,15 @@ export class DeepClient = Link> implements DeepCl * @param exp An expression to filter the objects to delete * @param options An object with options for the delete operation * @returns A promise that resolves to the deleted object or an array of deleted objects with the fields configured by {@link options.returning} which is by default 'id' + * + * @example + * #### Delete by id + * ``` + * await deep.update({ + * id: 888 + * }) + * ``` + * In this case the link with id 888 will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From 970b98ddfc826cfd2d22b2f342c06afb5967ce1a Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:40:23 +0600 Subject: [PATCH 47/82] Add `Delete by from_id` example --- imports/client.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 4432a49e..a4a6f49d 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1036,6 +1036,14 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case the link with id 888 will be deleted + * + * #### Delete by from_id + * ``` + * await deep.delete({ + * from_id: 888 + * }) + * ``` + * In this case all the links with from_id 888 will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From 9dbe23afdf8c8436f7f9d95a34874bd95c405bb0 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:40:33 +0600 Subject: [PATCH 48/82] Update `Delete by id` example --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index a4a6f49d..9e9d373b 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1031,7 +1031,7 @@ export class DeepClient = Link> implements DeepCl * @example * #### Delete by id * ``` - * await deep.update({ + * await deep.delete({ * id: 888 * }) * ``` From 435697789483157ddd6a9545fbb6f18619fc6676 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:40:56 +0600 Subject: [PATCH 49/82] Add example `Delete by to_id` --- imports/client.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 9e9d373b..2e4fdb85 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1044,6 +1044,14 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case all the links with from_id 888 will be deleted + * + * #### Delete by to_id + * ``` + * await deep.delete({ + * to_id: 888 + * }) + * ``` + * In this case all the links with to_id 888 will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From 72157f05f57e811837c1d7c9eb628c6db0bb3d2e Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:41:23 +0600 Subject: [PATCH 50/82] Add `Delete by type_id` example --- imports/client.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 2e4fdb85..d0a92974 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1052,6 +1052,14 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case all the links with to_id 888 will be deleted + * + * #### Delete by type_id + * ``` + * await deep.delete({ + * type_id: 888 + * }) + * ``` + * In this case all the links with type_id 888 will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From 7e0d58fca3f090166fb599a166b5c33691b675b9 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:44:10 +0600 Subject: [PATCH 51/82] Move `Delete by type_id` example after id example --- imports/client.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/imports/client.tsx b/imports/client.tsx index d0a92974..64f4cf8b 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1037,6 +1037,14 @@ export class DeepClient = Link> implements DeepCl * ``` * In this case the link with id 888 will be deleted * + * #### Delete by type_id + * ``` + * await deep.delete({ + * type_id: 888 + * }) + * ``` + * In this case all the links with type_id 888 will be deleted + * * #### Delete by from_id * ``` * await deep.delete({ @@ -1052,14 +1060,6 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case all the links with to_id 888 will be deleted - * - * #### Delete by type_id - * ``` - * await deep.delete({ - * type_id: 888 - * }) - * ``` - * In this case all the links with type_id 888 will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From 0b5596eba43077cd5a967795165856b73d728c87 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:46:04 +0600 Subject: [PATCH 52/82] Add `Delete by string value` example --- imports/client.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 64f4cf8b..d6461116 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1060,6 +1060,18 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case all the links with to_id 888 will be deleted + * + * #### Delete by string value + * ``` + * await deep.delete({ + * string: { + * value: { + * _eq: 'MyString' + * } + * } + * }) + * ``` + * In this case all the links with to_id 888 will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From 70047df1608786da11ae548daf25a59748257c61 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:46:24 +0600 Subject: [PATCH 53/82] Update `Delete by string value` example --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index d6461116..aada4926 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1071,7 +1071,7 @@ export class DeepClient = Link> implements DeepCl * } * }) * ``` - * In this case all the links with to_id 888 will be deleted + * In this case all the links with string value 'MyString' will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From 1359507b32aba01f7ec90e58ea4dc17620603f45 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:47:13 +0600 Subject: [PATCH 54/82] Add `Delete by number value` example --- imports/client.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index aada4926..c1b0fd33 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1072,6 +1072,18 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case all the links with string value 'MyString' will be deleted + * + * #### Delete by number value + * ``` + * await deep.delete({ + * number: { + * value: { + * _eq: 888 + * } + * } + * }) + * ``` + * In this case all the links with number value 888 will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From e7b427f08821f7c6241429d0deb90a17aab2eaa4 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:48:17 +0600 Subject: [PATCH 55/82] Add `Delete by object value` example --- imports/client.tsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index c1b0fd33..a0e8369e 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1084,6 +1084,20 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case all the links with number value 888 will be deleted + * + * #### Delete by object value + * ``` + * await deep.delete({ + * object: { + * value: { + * _eq: { + * myFieldKey: "myFieldValue" + * } + * } + * } + * }) + * ``` + * In this case all the links with object value { myFieldName: "myFieldValue" } will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From e20d56ae4412544bd804638ecc7981add2daa71f Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:49:47 +0600 Subject: [PATCH 56/82] Add `Delete string value by link id` example --- imports/client.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index a0e8369e..27f866d1 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1098,6 +1098,16 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case all the links with object value { myFieldName: "myFieldValue" } will be deleted + * + * #### Delete string value by link id + * ``` + * await deep.delete({ + * link_id: 888 + * }, { + * table: 'strings' + * }) + * ``` + * In this case all string value of a link with id 888 will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From 25159c881cfac4d7eb2348bc537a2934ae3de726 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:50:21 +0600 Subject: [PATCH 57/82] Add `Delete number value by link id` example --- imports/client.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 27f866d1..8c8b1620 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1108,6 +1108,16 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case all string value of a link with id 888 will be deleted + * + * #### Delete number value by link id + * ``` + * await deep.delete({ + * link_id: 888 + * }, { + * table: 'numbers' + * }) + * ``` + * In this case number value of a link with id 888 will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From a53170b40e6d7a9b71837f766bb212c5da9862e2 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:50:32 +0600 Subject: [PATCH 58/82] Update `Delete string value by link id` example --- imports/client.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index 8c8b1620..de705212 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1107,7 +1107,7 @@ export class DeepClient = Link> implements DeepCl * table: 'strings' * }) * ``` - * In this case all string value of a link with id 888 will be deleted + * In this case string value of a link with id 888 will be deleted * * #### Delete number value by link id * ``` From 63b6fd87c2a5701a868ad94ee9b363a090bc0044 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:50:52 +0600 Subject: [PATCH 59/82] Add `Delete object value by link id` example --- imports/client.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index de705212..2513258d 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1118,6 +1118,16 @@ export class DeepClient = Link> implements DeepCl * }) * ``` * In this case number value of a link with id 888 will be deleted + * + * #### Delete object value by link id + * ``` + * await deep.delete({ + * link_id: 888 + * }, { + * table: 'objects' + * }) + * ``` + * In this case object value of a link with id 888 will be deleted */ async delete(exp: Exp, options?: WriteOptions):Promise> { if (!exp) throw new Error('!exp'); From 3e3d7e4b974e078a2cf22eeb9e9c71f92c4eba3f Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Sat, 10 Feb 2024 12:53:56 +0600 Subject: [PATCH 60/82] Add `Await a promise of npm-packager` example --- imports/client.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 2513258d..49c96c67 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1230,6 +1230,16 @@ export class DeepClient = Link> implements DeepCl * @param id Id of a link which is processed by a handler * @param options An object with options for the await operation * @returns A promise that resolves to the result of the awaited promise + * + * @example + * #### Await a promise of npm-packager + * Let us imagine you have published a package and want to programatically wait until it is published or failed to publish + * ``` + * await deep.await( + * await deep.id('my-package-name') + * ) + * ``` + * In this case you will await all the promises for 'my-package-name' link */ async await(id: number, options: { results: boolean } = { results: false } ): Promise { return awaitPromise({ From 86c667e3cd9ef5585f84b07c954957f97b78183e Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 14 Feb 2024 12:16:15 +0600 Subject: [PATCH 61/82] Add `Get Core Package Link Id` example --- imports/client.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 49c96c67..b308e102 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1257,6 +1257,12 @@ export class DeepClient = Link> implements DeepCl * @param start A name or id of a link * @param path Contain values (names) as path items * @returns A promise that resolves to the id of the link + * + * @example + * #### Get Core Package Link Id + * ``` + * const corePackageLinkId = await deep.id("@deep-foundation/core") + * ``` */ async id(start: DeepClientStartItem | QueryLink, ...path: DeepClientPathItem[]): Promise { if (typeof(start) === 'object') { From 2a01d0a5469504f85f2b45b7e00d82a9ed4fa219 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 14 Feb 2024 12:17:03 +0600 Subject: [PATCH 62/82] Add `Get User Type Link Id From Core Package` example --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index b308e102..09fa00b7 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1263,6 +1263,11 @@ export class DeepClient = Link> implements DeepCl * ``` * const corePackageLinkId = await deep.id("@deep-foundation/core") * ``` + * + * #### Get User Type Link Id From Core Package + * ``` + * const userTypeLinkId = await deep.id("@deep-foundation/core", "User") + * ``` */ async id(start: DeepClientStartItem | QueryLink, ...path: DeepClientPathItem[]): Promise { if (typeof(start) === 'object') { From 084bde7ec60bc5db226c68f1c73f0a3e16a8abd3 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 14 Feb 2024 12:19:00 +0600 Subject: [PATCH 63/82] Add `Get the link called "My Nested Link Name" contained in the link called "My Link Name" contained the current user` example --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 09fa00b7..537ce9ca 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1268,6 +1268,11 @@ export class DeepClient = Link> implements DeepCl * ``` * const userTypeLinkId = await deep.id("@deep-foundation/core", "User") * ``` + * + * #### Get the link called "My Nested Link Name" contained in the link called "My Link Name" contained the current user + * ``` + * const myLinkId = await deep.id(deep.linkId, 'My Link Name', 'My Nested Link Name') + * ``` */ async id(start: DeepClientStartItem | QueryLink, ...path: DeepClientPathItem[]): Promise { if (typeof(start) === 'object') { From 9b5bbecfa02ccd24eeccb5d51865c932aa5d686f Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 14 Feb 2024 12:19:28 +0600 Subject: [PATCH 64/82] Add `Get Admin Link Id` example --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 537ce9ca..63ebc230 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1273,6 +1273,11 @@ export class DeepClient = Link> implements DeepCl * ``` * const myLinkId = await deep.id(deep.linkId, 'My Link Name', 'My Nested Link Name') * ``` + * + * #### Get Admin Link Id + * ``` + * const adminLinkId = await deep.id("deep", "admin") + * ``` */ async id(start: DeepClientStartItem | QueryLink, ...path: DeepClientPathItem[]): Promise { if (typeof(start) === 'object') { From e961b35de6ca343c772c4d99cc549eb53cf21134 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 14 Feb 2024 12:20:33 +0600 Subject: [PATCH 65/82] Add `Get Core Package Link Id` example --- imports/client.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 63ebc230..d32ec546 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1353,6 +1353,12 @@ export class DeepClient = Link> implements DeepCl * @param start A name or id of a link * @param path Contain values (names) as path items * @returns A promise that resolves to the id of the link + * + * @example + * #### Get Core Package Link Id + * ``` + * const corePackageLinkId = deep.idLocal("@deep-foundation/core") + * ``` */ idLocal(start: DeepClientStartItem, ...path: DeepClientPathItem[]): number { const paths = [start, ...path] as [DeepClientStartItem, ...Array>]; From e60240536e16d8c6a733be5732b41ef032555ca2 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 14 Feb 2024 12:21:39 +0600 Subject: [PATCH 66/82] Add `Get Core Package Link Id` example --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index d32ec546..8ae193b1 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1359,6 +1359,11 @@ export class DeepClient = Link> implements DeepCl * ``` * const corePackageLinkId = deep.idLocal("@deep-foundation/core") * ``` + * + * #### Get User Type Link Id From Core Package + * ``` + * const userTypeLinkId = deep.idLocal("@deep-foundation/core", "User") + * ``` */ idLocal(start: DeepClientStartItem, ...path: DeepClientPathItem[]): number { const paths = [start, ...path] as [DeepClientStartItem, ...Array>]; From 7a1929eff514f01843129ecef8125b8279489aaf Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 14 Feb 2024 12:22:16 +0600 Subject: [PATCH 67/82] Add `Get the link called "My Nested Link Name" contained in the link called "My Link Name" contained the current user` example --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 8ae193b1..60eb088b 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1364,6 +1364,11 @@ export class DeepClient = Link> implements DeepCl * ``` * const userTypeLinkId = deep.idLocal("@deep-foundation/core", "User") * ``` + * + * #### Get the link called "My Nested Link Name" contained in the link called "My Link Name" contained the current user + * ``` + * const myLinkId = deep.idLocal(deep.linkId, 'My Link Name', 'My Nested Link Name') + * ``` */ idLocal(start: DeepClientStartItem, ...path: DeepClientPathItem[]): number { const paths = [start, ...path] as [DeepClientStartItem, ...Array>]; From 1fc1e099a690ef4c6141beccc7233010abd05fcb Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 14 Feb 2024 12:22:35 +0600 Subject: [PATCH 68/82] Add `Get Admin Link Id` example --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 60eb088b..dc7691bc 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1369,6 +1369,11 @@ export class DeepClient = Link> implements DeepCl * ``` * const myLinkId = deep.idLocal(deep.linkId, 'My Link Name', 'My Nested Link Name') * ``` + * + * #### Get Admin Link Id + * ``` + * const adminLinkId = deep.idLocal("deep", "admin") + * ``` */ idLocal(start: DeepClientStartItem, ...path: DeepClientPathItem[]): number { const paths = [start, ...path] as [DeepClientStartItem, ...Array>]; From 87d8f47bcbb8b95b507feb2036a01be6565ea464 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Wed, 14 Feb 2024 12:24:27 +0600 Subject: [PATCH 69/82] Add example for `whoami` --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index dc7691bc..46d6c072 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1441,6 +1441,11 @@ export class DeepClient = Link> implements DeepCl /** * Returns id of the current user + * + * @example + * ``` + * const myLinkId = await deep.whoami() + * ``` */ async whoami(): Promise { const result = await this.apolloClient.query({ query: WHOISME }); From 1a793921bd126ec884cb39ae061d7ffd2145372d Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 12:34:51 +0600 Subject: [PATCH 70/82] Add login example --- imports/client.tsx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 46d6c072..372943b1 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1457,6 +1457,24 @@ export class DeepClient = Link> implements DeepCl * Performs a login operation * @param options An object with options for the login operation * @returns A promsie that resolves to the result of the login operation + * + * @example + * ``` + * import { DeepClient } from "@deep-foundation/deeplinks/imports/client.js"; + * import { generateApolloClient } from '@deep-foundation/hasura/client.js'; + * + * const apolloClient = generateApolloClient({ + * path: NEXT_PUBLIC_GQL_PATH, + * ssl: true, + * }); + * const unloginedDeep = new DeepClient({ apolloClient }); + * const guestLoginResult = await unloginedDeep.guest(); + * const guestDeep = new DeepClient({ deep: unloginedDeep, ...guestLoginResult }); + * const adminLoginResult = await guestDeep.login({ + * linkId: await guestDeep.id('deep', 'admin'), + * }); + * const deep = new DeepClient({ deep: guestDeep, ...adminLoginResult }); + * ``` */ async login(options: DeepClientJWTOptions): Promise { const jwtResult = await this.jwt({ ...options, relogin: true }); From faf6850ccc19b0396668a66840801843822e7b98 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 12:35:55 +0600 Subject: [PATCH 71/82] Add `guest` doc --- imports/client.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 372943b1..7b1f438d 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1405,6 +1405,25 @@ export class DeepClient = Link> implements DeepCl } }; + /** + * Logs in as a guest + * @param options An object with options for the guest login operation + * @returns A promise that resolves to the result of the guest login operation + * + * @example + * ``` + * import { DeepClient } from "@deep-foundation/deeplinks/imports/client.js"; + * import { generateApolloClient } from '@deep-foundation/hasura/client.js'; + * + * const apolloClient = generateApolloClient({ + * path: NEXT_PUBLIC_GQL_PATH, + * ssl: true, + * }); + * const unloginedDeep = new DeepClient({ apolloClient }); + * const guestLoginResult = await unloginedDeep.guest(); + * const guestDeep = new DeepClient({ deep: unloginedDeep, ...guestLoginResult }); + * ``` + */ async guest(options: DeepClientGuestOptions = {}): Promise { const relogin = typeof(options.relogin) === 'boolean' ? options.relogin : true; const result = await this.apolloClient.query({ query: GUEST }); From 044c8f11ea67c9b51ef05e517c8ca7ac52e3ca73 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 12:37:56 +0600 Subject: [PATCH 72/82] Update `login` doc --- imports/client.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 7b1f438d..3d4ca91b 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1478,6 +1478,22 @@ export class DeepClient = Link> implements DeepCl * @returns A promsie that resolves to the result of the login operation * * @example + * #### Code snippet without imports + * ``` + * const apolloClient = generateApolloClient({ + * path: NEXT_PUBLIC_GQL_PATH, + * ssl: true, + * }); + * const unloginedDeep = new DeepClient({ apolloClient }); + * const guestLoginResult = await unloginedDeep.guest(); + * const guestDeep = new DeepClient({ deep: unloginedDeep, ...guestLoginResult }); + * const adminLoginResult = await guestDeep.login({ + * linkId: await guestDeep.id('deep', 'admin'), + * }); + * const deep = new DeepClient({ deep: guestDeep, ...adminLoginResult }); + * ``` + * + * #### Whole code with imports * ``` * import { DeepClient } from "@deep-foundation/deeplinks/imports/client.js"; * import { generateApolloClient } from '@deep-foundation/hasura/client.js'; From 941f5144e260590b53a8824f4ec163fff2dfc0d8 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 12:38:36 +0600 Subject: [PATCH 73/82] Update `guest` doc --- imports/client.tsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 3d4ca91b..ee03dcd6 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1411,6 +1411,18 @@ export class DeepClient = Link> implements DeepCl * @returns A promise that resolves to the result of the guest login operation * * @example + * #### Code snippet without imports + * ``` + * const apolloClient = generateApolloClient({ + * path: NEXT_PUBLIC_GQL_PATH, + * ssl: true, + * }); + * const unloginedDeep = new DeepClient({ apolloClient }); + * const guestLoginResult = await unloginedDeep.guest(); + * const guestDeep = new DeepClient({ deep: unloginedDeep, ...guestLoginResult }); + * ``` + * + * #### Whole code with imports * ``` * import { DeepClient } from "@deep-foundation/deeplinks/imports/client.js"; * import { generateApolloClient } from '@deep-foundation/hasura/client.js'; From d8516b239c28e1175c16e0b2fc046b25109c73ae Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 12:39:47 +0600 Subject: [PATCH 74/82] Update doc --- imports/client.tsx | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/imports/client.tsx b/imports/client.tsx index ee03dcd6..7b1f438d 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1411,18 +1411,6 @@ export class DeepClient = Link> implements DeepCl * @returns A promise that resolves to the result of the guest login operation * * @example - * #### Code snippet without imports - * ``` - * const apolloClient = generateApolloClient({ - * path: NEXT_PUBLIC_GQL_PATH, - * ssl: true, - * }); - * const unloginedDeep = new DeepClient({ apolloClient }); - * const guestLoginResult = await unloginedDeep.guest(); - * const guestDeep = new DeepClient({ deep: unloginedDeep, ...guestLoginResult }); - * ``` - * - * #### Whole code with imports * ``` * import { DeepClient } from "@deep-foundation/deeplinks/imports/client.js"; * import { generateApolloClient } from '@deep-foundation/hasura/client.js'; @@ -1490,22 +1478,6 @@ export class DeepClient = Link> implements DeepCl * @returns A promsie that resolves to the result of the login operation * * @example - * #### Code snippet without imports - * ``` - * const apolloClient = generateApolloClient({ - * path: NEXT_PUBLIC_GQL_PATH, - * ssl: true, - * }); - * const unloginedDeep = new DeepClient({ apolloClient }); - * const guestLoginResult = await unloginedDeep.guest(); - * const guestDeep = new DeepClient({ deep: unloginedDeep, ...guestLoginResult }); - * const adminLoginResult = await guestDeep.login({ - * linkId: await guestDeep.id('deep', 'admin'), - * }); - * const deep = new DeepClient({ deep: guestDeep, ...adminLoginResult }); - * ``` - * - * #### Whole code with imports * ``` * import { DeepClient } from "@deep-foundation/deeplinks/imports/client.js"; * import { generateApolloClient } from '@deep-foundation/hasura/client.js'; From dcdee14afcf14c00682084f3d8da1a11e9bb3e34 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 12:41:44 +0600 Subject: [PATCH 75/82] Update `can` doc --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 7b1f438d..0c7b8c1f 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1514,6 +1514,11 @@ export class DeepClient = Link> implements DeepCl /** * Checks whether {@link subjectUds} can perform {@link actionIds} on {@link objectIds} + * @param objectIds A link id or an array of link ids to check whether the {@link subjectUds} can perform the {@link actionIds} on + * @param subjectIds A link id or an array of link ids to check whether they can perform the {@link actionIds} on the {@link objectIds} + * @param actionIds A link id or an array of link ids to check whether the {@link subjectUds} can perform on the {@link objectIds} + * @param userIds A link id or an array of link ids from which perspective the check is performed + * @returns A promise that resolves to a boolean value indicating whether the {@link subjectUds} can perform the {@link actionIds} on the {@link objectIds} */ async can(objectIds: null | number | number[], subjectIds: null | number | number[], actionIds: null | number | number[], userIds: number | number[] = this.linkId) { const where: any = { From d01a37ca524b6cef0a2f8ae01e5dc924c5e46047 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 13:18:05 +0600 Subject: [PATCH 76/82] Add `name ` example --- imports/client.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 0c7b8c1f..7b5405ff 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1532,6 +1532,12 @@ export class DeepClient = Link> implements DeepCl /** * Returns a name of a link {@link input} that is located in a value of a contain link pointing to the link {@link input} + * + * @example + * ``` + * const userTypeLinkId = await deep.id("@deep-foundation/core", "User"); + * const userTypeLinkName = await deep.name(userTypeLinkId); + * ``` */ async name(input: Link | number): Promise { const id = typeof(input) === 'number' ? input : input.id; From 237aa6d8e99b4158ffe7ab1e0fcd89741dadf97d Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 13:18:21 +0600 Subject: [PATCH 77/82] Remove imports from examples --- imports/client.tsx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/imports/client.tsx b/imports/client.tsx index 7b5405ff..6a685f6b 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1412,9 +1412,6 @@ export class DeepClient = Link> implements DeepCl * * @example * ``` - * import { DeepClient } from "@deep-foundation/deeplinks/imports/client.js"; - * import { generateApolloClient } from '@deep-foundation/hasura/client.js'; - * * const apolloClient = generateApolloClient({ * path: NEXT_PUBLIC_GQL_PATH, * ssl: true, @@ -1479,9 +1476,6 @@ export class DeepClient = Link> implements DeepCl * * @example * ``` - * import { DeepClient } from "@deep-foundation/deeplinks/imports/client.js"; - * import { generateApolloClient } from '@deep-foundation/hasura/client.js'; - * * const apolloClient = generateApolloClient({ * path: NEXT_PUBLIC_GQL_PATH, * ssl: true, From 90d73900230b1f3d9daa5c266c73d6dc8969f0a7 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 13:20:59 +0600 Subject: [PATCH 78/82] Add `nameLocal` example --- imports/client.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 6a685f6b..ae3250e1 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1551,6 +1551,13 @@ export class DeepClient = Link> implements DeepCl /** * Returns a name of a link {@link input} that is located in a value of a contain link pointing to the link {@link input} according to links stored in minilinks + * + * @example + * ``` + * const userTypeLinkId = await deep.id("@deep-foundation/core", "User"); + * const userTypeLinkName = deep.nameLocal(userTypeLinkId); + * ``` + * Note: "@deep-foundation/core" package, "User" link, Contain link pointing from "@deep-foundation/core" to "User" must be in minilinks */ nameLocal(input: Link | number): string | undefined { const id = typeof(input) === 'number' ? input : input?.id; From db8337f333685ad99fcf30af3b8a5b398ab5c79a Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 13:22:45 +0600 Subject: [PATCH 79/82] Add `import` doc --- imports/client.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index ae3250e1..adf59b75 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1567,6 +1567,11 @@ export class DeepClient = Link> implements DeepCl return (this.minilinks.byType[this.idLocal('@deep-foundation/core', 'Contain')]?.find((c: any) => c?.to_id === id) as any)?.value?.value; } + /** + * Imports from a library + * @param path A path to import from + * @returns A promise that resolves to the imported value + */ async import(path: string) : Promise { if (typeof DeepClient.resolveDependency !== 'undefined') { try { From 64375d2e7d10971cd4bb36bd0784dd0616e33299 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 13:25:32 +0600 Subject: [PATCH 80/82] Add remarks to `import` --- imports/client.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index adf59b75..33868355 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1571,6 +1571,10 @@ export class DeepClient = Link> implements DeepCl * Imports from a library * @param path A path to import from * @returns A promise that resolves to the imported value + * + * @remarks + * Is able to import CommoJS and ESModule libraries. + * This is the recommended way to import from libraries in deep handlers */ async import(path: string) : Promise { if (typeof DeepClient.resolveDependency !== 'undefined') { From 39bd88d4b299d75e5cab906ec8dc7da4fc6b4a39 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 13:26:33 +0600 Subject: [PATCH 81/82] Add `Async handler using import` example --- imports/client.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index 33868355..d2beab8c 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1575,6 +1575,14 @@ export class DeepClient = Link> implements DeepCl * @remarks * Is able to import CommoJS and ESModule libraries. * This is the recommended way to import from libraries in deep handlers + * + * @example + * #### Async handler using import + * ``` + * async ({deep}) => { + * const importResult = await deep.import("my-lib-name"); + * } + * ``` */ async import(path: string) : Promise { if (typeof DeepClient.resolveDependency !== 'undefined') { From 5675dbb8b01217db900d8377c582eec7386d61e3 Mon Sep 17 00:00:00 2001 From: FreePhoenix888 Date: Thu, 15 Feb 2024 13:28:15 +0600 Subject: [PATCH 82/82] Add remarks to `update` --- imports/client.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imports/client.tsx b/imports/client.tsx index d2beab8c..94a84eed 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -809,6 +809,9 @@ export class DeepClient = Link> implements DeepCl * @param options An object with options for the insert operation * @returns A promise that resolves to the inserted object or an array of inserted objects with the fields configured by {@link options.returning} which is by default 'id' * + * @remarks + * If a link already has value you should update its value, not insert + * * @example * #### Insert Type * ```