Skip to content

Commit fb1c29c

Browse files
committed
Revert "Merge branch 'main' into clientifrst"
This reverts commit 1fda55e.
1 parent 1fda55e commit fb1c29c

11 files changed

Lines changed: 30 additions & 82 deletions

File tree

.github/workflows/dockerize.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
- uses: actions/checkout@v2
2424
- uses: actions/setup-node@v1
2525
with:
26-
node-version: 18
26+
node-version: '16.20'
2727
- name: ci
2828
run: npm ci
2929
- name: build

.github/workflows/npm-publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111

1212
jobs:
1313
main:
14-
uses: deep-foundation/workflows/.github/workflows/npm-publish.yml@npm-publish-4.0.0
14+
uses: deep-foundation/workflows/.github/workflows/npm-publish.yml@npm-publish-1.1.0
1515
secrets:
1616
npm-token: ${{ secrets.NPM_TOKEN }}
1717
with:

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18
1+
18.16.1

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM node:18-alpine3.17 AS node
1+
FROM node:18.16.1-alpine3.17 AS node
22
FROM docker:20.10.8-dind-alpine3.14
33

44
COPY --from=node /usr/lib /usr/lib

imports/client.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,6 @@ export interface DeepClientInstance<L = Link<number>> {
351351

352352
delete<TTable extends 'links'|'numbers'|'strings'|'objects'>(exp: Exp<TTable>, options?: WriteOptions<TTable>):Promise<DeepClientResult<{ id }[]>>;
353353

354-
serial(options: AsyncSerialParams): Promise<DeepClientResult<{ id }[]>>;
355-
356354
reserve<LL = L>(count: number): Promise<number[]>;
357355

358356
await(id: number): Promise<boolean>;
@@ -374,8 +372,6 @@ export interface DeepClientInstance<L = Link<number>> {
374372
logout(): Promise<DeepClientAuthResult>;
375373

376374
can(objectIds: number[], subjectIds: number[], actionIds: number[]): Promise<boolean>;
377-
378-
useDeepSubscription: typeof useDeepSubscription
379375
}
380376

381377
export interface DeepClientAuthResult {
@@ -786,7 +782,9 @@ export class DeepClient<L = Link<number>> implements DeepClientInstance<L> {
786782
return { ...q, data: (q)?.data?.m0?.returning };
787783
};
788784

789-
async serial({
785+
async serial<
786+
LL = L
787+
>({
790788
name, operations, returning, silent
791789
}: AsyncSerialParams): Promise<DeepClientResult<{ id: number }[]>> {
792790
// @ts-ignore
@@ -1058,14 +1056,14 @@ export class DeepClient<L = Link<number>> implements DeepClientInstance<L> {
10581056
try {
10591057
return await DeepClient.resolveDependency(path);
10601058
} catch (e) {
1061-
console.log(`IGNORED ERROR: Call to DeepClient.resolveDependency is failed with`, e);
1059+
console.log(`Call to DeepClient.resolveDependency is failed with`, e);
10621060
}
10631061
}
10641062
if (typeof require !== 'undefined') {
10651063
try {
10661064
return await require(path);
10671065
} catch (e) {
1068-
console.log(`IGNORED ERROR: Call to require is failed with`, e);
1066+
console.log(`Call to require is failed with`, e);
10691067
}
10701068
}
10711069
return await import(path);

imports/packager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export class Packager<L extends Link<any>> {
280280
let newId;
281281
if (item.package) {
282282
newId = await this.client.id(pckg?.dependencies?.[item?.package?.dependencyId]?.name, item.package.containValue, true);
283-
if (!newId) pckg.errors.push(`dependency [${pckg?.dependencies?.[item?.package?.dependencyId]?.name} ${item.package.containValue}], not found`);
283+
if (!newId) pckg.errors.push(`dependency [${pckg?.dependencies?.[item?.package?.dependencyId]?.name, item.package.containValue}], not founded`);
284284
} else if (item.type) {
285285
newId = ids[idsIndex++];
286286
}
@@ -373,7 +373,7 @@ export class Packager<L extends Link<any>> {
373373
const ids = await this.client.reserve(counter);
374374
const { global, difference } = await this.globalizeIds(pckg, ids, sorted);
375375
if (pckg.errors?.length) {
376-
return { errors: pckg.errors };
376+
return { errors };
377377
}
378378
await this.insertItems(pckg, global, counter, dependedLinks, errors, mutated);
379379
if (errors.length) return { errors };

migrations/1655979260869-sync-handlers.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ const prepareFunction = /*javascript*/`
313313
const selectValueTable = `\`SELECT * FROM \${table} WHERE link_id = \${linkId}\``;
314314
const selectLinkByValue = `\`SELECT link_id as id FROM \${table} WHERE value = '\${value}'::\${table==='strings' ? 'text' : table==='objects' ? 'jsonb' : 'bigint'}\``;
315315

316-
const generateSelectWhereCode = /*javascript*/`(_where, shift = 0) => {
316+
const generateSelectWhereCode = /*javascript*/`(_where) => {
317317
const where = [];
318318
let values = [];
319319
let valueTable;
@@ -322,20 +322,20 @@ const generateSelectWhereCode = /*javascript*/`(_where, shift = 0) => {
322322
if (_where[keys[i]]) {
323323
if ( !_where[keys[i]]['_in'] ) {
324324
if (keys[i] !== 'object' && keys[i] !== 'string' && keys[i] !== 'number') {
325-
where.push('"main".'.concat(keys[i], ' = $',values.length+1+shift));
325+
where.push('"main".'.concat(keys[i], ' = $',values.length+2));
326326
values.push(_where[keys[i]]);
327327
} else {
328328
const valueKeys = Object.keys(_where[keys[i]]);
329329
where.push(keys[i].concat('s.link_id = "main".id'));
330330
valueTable = keys[i].concat('s');
331331
for (let j = 0; j < valueKeys.length; j++ ){
332332
if ( !_where[keys[i]][valueKeys[j]]['_in'] ) {
333-
where.push('"'.concat(keys[i].concat('s".'), valueKeys[j], ' = $', values.length+1+shift));
333+
where.push('"'.concat(keys[i].concat('s".'), valueKeys[j], ' = $', values.length+2));
334334
values.push(_where[keys[i]][valueKeys[j]]);
335335
} else {
336336
const inLength = _where[keys[i]][valueKeys[j]]['_in'].length;
337-
let inValues = '$'.concat(values.length+1+shift);
338-
for (let l = values.length+2+shift; l < inLength+values.length+1+shift; l++ ) {
337+
let inValues = '$'.concat(values.length+2);
338+
for (let l = values.length+3; l < inLength+values.length+2; l++ ) {
339339
inValues = inValues.concat(',$',l);
340340
}
341341
if(typeof _where[keys[i]][valueKeys[j]]['_in'][0] === 'number'){
@@ -352,8 +352,8 @@ const generateSelectWhereCode = /*javascript*/`(_where, shift = 0) => {
352352
}
353353
} else {
354354
const inLength = _where[keys[i]]['_in'].length;
355-
let inValues = '$'.concat(values.length+1+shift);
356-
for (let l = values.length+2+shift; l < inLength+where.length+1+shift; l++ ) {
355+
let inValues = '$'.concat(values.length+2);
356+
for (let l = values.length+3; l < inLength+where.length+2; l++ ) {
357357
inValues = inValues.concat(',$',l);
358358
}
359359
if(typeof _where[keys[i]]['_in'][0] === 'number'){
@@ -548,7 +548,8 @@ const findLinkIdByValueCode = /*javascript*/`({ string, object, number, value })
548548
}
549549
}`;
550550

551-
const objectSet = `\`update objects set value = jsonb_set(value, $2, $3, true) where link_id = $1\``;
551+
const wherePush = `\`\${whereFileds[counter]} = $\${counter}\``;
552+
const setPush = `\`\${setFileds[counter]} = $\${counter}\``;
552553

553554
const deepFabric = /*javascript*/`(ownerId, hasura_session) => {
554555
hasura_session['x-hasura-role'] = 'link';
@@ -580,11 +581,6 @@ const deepFabric = /*javascript*/`(ownerId, hasura_session) => {
580581
plv8.elog(ERROR, 'Id not found by '.concat(start, ' -> ', path.join(' -> ')));
581582
}
582583
},
583-
objectSet: function(link_id, path, value) {
584-
plv8.execute('SELECT set_config($1, $2, $3)', [ 'hasura.user', JSON.stringify({...hasura_session, 'x-hasura-user-id': this.linkId}), true]);
585-
hasura_session['x-hasura-user-id'] = this.linkId;
586-
plv8.execute(${objectSet}, [link_id, path, value]);
587-
},
588584
select: function(_where, options) {
589585
if (options?.table && !['links', 'tree', 'can', 'selectors'].includes(options?.table)) plv8.elog(ERROR, 'select not from "links" not permitted');
590586
plv8.execute('SELECT set_config($1, $2, $3)', [ 'hasura.user', JSON.stringify({...hasura_session, 'x-hasura-user-id': this.linkId}), true]);
@@ -596,7 +592,7 @@ const deepFabric = /*javascript*/`(ownerId, hasura_session) => {
596592
const findLinkIdByValue = ${findLinkIdByValueCode};
597593
const fillValueByLinks = ${fillValueByLinksCode};
598594
const isDeepEqual = ${isDeepEqualCode};
599-
let generated = generateSelectWhere(_where, 1);
595+
let generated = generateSelectWhere(_where);
600596
const where = generated.where;
601597
let links = [];
602598
const valueTableString = generated.valueTable ? ', "'.concat(generated.valueTable, '"') : '';
@@ -609,7 +605,7 @@ const deepFabric = /*javascript*/`(ownerId, hasura_session) => {
609605
if (options?.table === 'tree'){
610606
const { id, link_id, parent_id, depth, root_id, position_id, tree_id } = _where;
611607
const generateSelectWhere = ${generateSelectWhereCode};
612-
let generated = generateSelectWhere(_where, 1);
608+
let generated = generateSelectWhere(_where);
613609
const where = generated.where;
614610
let links = [];
615611
if (where) links = plv8.execute(${selectTreeWithPermissions}, [ this.linkId, ...generated.values ]);
@@ -836,16 +832,14 @@ const triggerFunctionFabric = (handleOperationTypeId, valueTrigger) => /*javascr
836832
`;
837833

838834
const deepClientFunction = /*javascript*/`
839-
840835
const checkInsertPermission = ${checkInsertPermissionCode};
841836
const checkUpdatePermission = ${checkUpdatePermissionCode};
842837
const checkDeleteLinkPermission = ${checkDeleteLinkPermissionCode};
843838
const hasura_session = JSON.parse(plv8.execute("select current_setting('hasura.user', 't')")[0].current_setting);
844839
const default_role = hasura_session['x-hasura-role'];
845840
const default_user_id = hasura_session['x-hasura-user-id'];
846-
847841
const deep = (${deepFabric})(Number(clientlinkid), hasura_session);
848-
const result = operation === 'id' || operation === 'update' || operation === 'objectSet' ? deep[operation](...args) : deep[operation](args, options);
842+
const result = operation === 'id' || operation === 'update' ? deep[operation](...args) : deep[operation](args, options);
849843
if (hasura_session['x-hasura-role'] !== default_role || hasura_session['x-hasura-user-id'] !== default_user_id){
850844
if (default_role) hasura_session['x-hasura-role'] = default_role;
851845
if (default_user_id) hasura_session['x-hasura-user-id'] = default_user_id;

migrations/1693460330175-sync-handlers-update.ts

Lines changed: 0 additions & 31 deletions
This file was deleted.

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@deep-foundation/deeplinks",
3-
"version": "0.0.291",
3+
"version": "0.0.288",
44
"license": "Unlicense",
55
"type": "module",
66
"scripts": {
@@ -20,9 +20,8 @@
2020
"benchmark": "export DEEPLINKS_HASURA_PATH=localhost:8080; export DEEPLINKS_HASURA_SSL=0; export DEEPLINKS_HASURA_SECRET=myadminsecretkey; ts-node benchmarks/index.ts",
2121
"migrate": "npm run package:build && npx migrate@latest up --matches '*.js'",
2222
"unmigrate": "npm run package:build && npx migrate@latest down --matches '*.js'",
23-
"migrate-s-h": "npm run package:build && npx migrate@latest up 1693460330175-sync-handlers-update --matches '*.js'",
24-
"unmigrate-s-h": "npm run package:build && npx migrate@latest down 1693460330175-sync-handlers-update --matches '*.js'",
25-
"remigrate-s-h": "npm run unmigrate-s-h && npm run migrate",
23+
"migrate-s-h": "npm run package:build && npx migrate@latest up 1655979260869-sync-handlers --matches '*.js'",
24+
"unmigrate-s-h": "npm run package:build && npx migrate@latest down 1655979260869-sync-handlers --matches '*.js'",
2625
"start-engine-docker": "npm run start-engine-docker-core",
2726
"start-engine-docker-core": "cd ./node_modules/@deep-foundation/hasura && npm run docker",
2827
"stop-engine-docker": "cd ./node_modules/@deep-foundation/hasura/local && docker-compose --project-name deep down",
@@ -89,7 +88,7 @@
8988
"react": "*"
9089
},
9190
"engines": {
92-
"node": "^18"
91+
"node": "^18.16.1"
9392
},
9493
"devDependencies": {
9594
"@testing-library/jest-dom": "^5.16.5",

0 commit comments

Comments
 (0)