@nymphjs/driver-postgresql 1.0.0-beta.127 → 1.0.0-beta.129

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.
@@ -499,114 +499,58 @@ export default class PostgreSQLDriver extends NymphDriver {
499
499
  );
500
500
  await this.queryRun(
501
501
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
502
- `${this.prefix}data_${etype}_id_guid`,
502
+ `${this.prefix}data_${etype}_id_name_guid`,
503
503
  )};`,
504
504
  { connection },
505
505
  );
506
506
  await this.queryRun(
507
507
  `CREATE INDEX ${PostgreSQLDriver.escape(
508
- `${this.prefix}data_${etype}_id_guid`,
508
+ `${this.prefix}data_${etype}_id_name_guid`,
509
509
  )} ON ${PostgreSQLDriver.escape(
510
510
  `${this.prefix}data_${etype}`,
511
- )} USING btree ("guid");`,
511
+ )} USING btree ("name", "guid");`,
512
512
  { connection },
513
513
  );
514
514
  await this.queryRun(
515
515
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
516
- `${this.prefix}data_${etype}_id_guid_name`,
516
+ `${this.prefix}data_${etype}_id_name_string_guid`,
517
517
  )};`,
518
518
  { connection },
519
519
  );
520
520
  await this.queryRun(
521
521
  `CREATE INDEX ${PostgreSQLDriver.escape(
522
- `${this.prefix}data_${etype}_id_guid_name`,
522
+ `${this.prefix}data_${etype}_id_name_string_guid`,
523
523
  )} ON ${PostgreSQLDriver.escape(
524
524
  `${this.prefix}data_${etype}`,
525
- )} USING btree ("guid", "name");`,
525
+ )} USING btree ("name", LEFT("string", 512), "guid");`,
526
526
  { connection },
527
527
  );
528
528
  await this.queryRun(
529
529
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
530
- `${this.prefix}data_${etype}_id_name`,
530
+ `${this.prefix}data_${etype}_id_name_number_guid`,
531
531
  )};`,
532
532
  { connection },
533
533
  );
534
534
  await this.queryRun(
535
535
  `CREATE INDEX ${PostgreSQLDriver.escape(
536
- `${this.prefix}data_${etype}_id_name`,
536
+ `${this.prefix}data_${etype}_id_name_number_guid`,
537
537
  )} ON ${PostgreSQLDriver.escape(
538
538
  `${this.prefix}data_${etype}`,
539
- )} USING btree ("name");`,
539
+ )} USING btree ("name", "number", "guid");`,
540
540
  { connection },
541
541
  );
542
542
  await this.queryRun(
543
543
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
544
- `${this.prefix}data_${etype}_id_name_string`,
544
+ `${this.prefix}data_${etype}_id_name_truthy_guid`,
545
545
  )};`,
546
546
  { connection },
547
547
  );
548
548
  await this.queryRun(
549
549
  `CREATE INDEX ${PostgreSQLDriver.escape(
550
- `${this.prefix}data_${etype}_id_name_string`,
550
+ `${this.prefix}data_${etype}_id_name_truthy_guid`,
551
551
  )} ON ${PostgreSQLDriver.escape(
552
552
  `${this.prefix}data_${etype}`,
553
- )} USING btree ("name", LEFT("string", 512));`,
554
- { connection },
555
- );
556
- await this.queryRun(
557
- `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
558
- `${this.prefix}data_${etype}_id_name_number`,
559
- )};`,
560
- { connection },
561
- );
562
- await this.queryRun(
563
- `CREATE INDEX ${PostgreSQLDriver.escape(
564
- `${this.prefix}data_${etype}_id_name_number`,
565
- )} ON ${PostgreSQLDriver.escape(
566
- `${this.prefix}data_${etype}`,
567
- )} USING btree ("name", "number");`,
568
- { connection },
569
- );
570
- await this.queryRun(
571
- `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
572
- `${this.prefix}data_${etype}_id_guid_name_number`,
573
- )};`,
574
- { connection },
575
- );
576
- await this.queryRun(
577
- `CREATE INDEX ${PostgreSQLDriver.escape(
578
- `${this.prefix}data_${etype}_id_guid_name_number`,
579
- )} ON ${PostgreSQLDriver.escape(
580
- `${this.prefix}data_${etype}`,
581
- )} USING btree ("guid", "name", "number");`,
582
- { connection },
583
- );
584
- await this.queryRun(
585
- `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
586
- `${this.prefix}data_${etype}_id_name_truthy`,
587
- )};`,
588
- { connection },
589
- );
590
- await this.queryRun(
591
- `CREATE INDEX ${PostgreSQLDriver.escape(
592
- `${this.prefix}data_${etype}_id_name_truthy`,
593
- )} ON ${PostgreSQLDriver.escape(
594
- `${this.prefix}data_${etype}`,
595
- )} USING btree ("name", "truthy");`,
596
- { connection },
597
- );
598
- await this.queryRun(
599
- `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
600
- `${this.prefix}data_${etype}_id_guid_name_truthy`,
601
- )};`,
602
- { connection },
603
- );
604
- await this.queryRun(
605
- `CREATE INDEX ${PostgreSQLDriver.escape(
606
- `${this.prefix}data_${etype}_id_guid_name_truthy`,
607
- )} ON ${PostgreSQLDriver.escape(
608
- `${this.prefix}data_${etype}`,
609
- )} USING btree ("guid", "name", "truthy");`,
553
+ )} USING btree ("name", "truthy", "guid");`,
610
554
  { connection },
611
555
  );
612
556
  await this.queryRun(
@@ -673,100 +617,16 @@ export default class PostgreSQLDriver extends NymphDriver {
673
617
  );
674
618
  await this.queryRun(
675
619
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
676
- `${this.prefix}references_${etype}_id_guid`,
677
- )};`,
678
- { connection },
679
- );
680
- await this.queryRun(
681
- `CREATE INDEX ${PostgreSQLDriver.escape(
682
- `${this.prefix}references_${etype}_id_guid`,
683
- )} ON ${PostgreSQLDriver.escape(
684
- `${this.prefix}references_${etype}`,
685
- )} USING btree ("guid");`,
686
- { connection },
687
- );
688
- await this.queryRun(
689
- `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
690
- `${this.prefix}references_${etype}_id_name`,
691
- )};`,
692
- { connection },
693
- );
694
- await this.queryRun(
695
- `CREATE INDEX ${PostgreSQLDriver.escape(
696
- `${this.prefix}references_${etype}_id_name`,
697
- )} ON ${PostgreSQLDriver.escape(
698
- `${this.prefix}references_${etype}`,
699
- )} USING btree ("name");`,
700
- { connection },
701
- );
702
- await this.queryRun(
703
- `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
704
- `${this.prefix}references_${etype}_id_name_reference`,
705
- )};`,
706
- { connection },
707
- );
708
- await this.queryRun(
709
- `CREATE INDEX ${PostgreSQLDriver.escape(
710
- `${this.prefix}references_${etype}_id_name_reference`,
711
- )} ON ${PostgreSQLDriver.escape(
712
- `${this.prefix}references_${etype}`,
713
- )} USING btree ("name", "reference");`,
714
- { connection },
715
- );
716
- await this.queryRun(
717
- `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
718
- `${this.prefix}references_${etype}_id_reference`,
620
+ `${this.prefix}references_${etype}_id_name_reference_guid`,
719
621
  )};`,
720
622
  { connection },
721
623
  );
722
624
  await this.queryRun(
723
625
  `CREATE INDEX ${PostgreSQLDriver.escape(
724
- `${this.prefix}references_${etype}_id_reference`,
626
+ `${this.prefix}references_${etype}_id_name_reference_guid`,
725
627
  )} ON ${PostgreSQLDriver.escape(
726
628
  `${this.prefix}references_${etype}`,
727
- )} USING btree ("reference");`,
728
- { connection },
729
- );
730
- await this.queryRun(
731
- `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
732
- `${this.prefix}references_${etype}_id_guid_name_reference`,
733
- )};`,
734
- { connection },
735
- );
736
- await this.queryRun(
737
- `CREATE INDEX ${PostgreSQLDriver.escape(
738
- `${this.prefix}references_${etype}_id_guid_name_reference`,
739
- )} ON ${PostgreSQLDriver.escape(
740
- `${this.prefix}references_${etype}`,
741
- )} USING btree ("guid", "name", "reference");`,
742
- { connection },
743
- );
744
- await this.queryRun(
745
- `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
746
- `${this.prefix}references_${etype}_id_reference_name_guid`,
747
- )};`,
748
- { connection },
749
- );
750
- await this.queryRun(
751
- `CREATE INDEX ${PostgreSQLDriver.escape(
752
- `${this.prefix}references_${etype}_id_reference_name_guid`,
753
- )} ON ${PostgreSQLDriver.escape(
754
- `${this.prefix}references_${etype}`,
755
- )} USING btree ("reference", "name", "guid");`,
756
- { connection },
757
- );
758
- await this.queryRun(
759
- `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
760
- `${this.prefix}references_${etype}_id_reference_guid_name`,
761
- )};`,
762
- { connection },
763
- );
764
- await this.queryRun(
765
- `CREATE INDEX ${PostgreSQLDriver.escape(
766
- `${this.prefix}references_${etype}_id_reference_guid_name`,
767
- )} ON ${PostgreSQLDriver.escape(
768
- `${this.prefix}references_${etype}`,
769
- )} USING btree ("reference", "guid", "name");`,
629
+ )} USING btree ("name", "reference", "guid");`,
770
630
  { connection },
771
631
  );
772
632
  await this.queryRun(
@@ -807,16 +667,16 @@ export default class PostgreSQLDriver extends NymphDriver {
807
667
  );
808
668
  await this.queryRun(
809
669
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
810
- `${this.prefix}tokens_${etype}_id_name_token`,
670
+ `${this.prefix}tokens_${etype}_id_name_token_guid`,
811
671
  )};`,
812
672
  { connection },
813
673
  );
814
674
  await this.queryRun(
815
675
  `CREATE INDEX ${PostgreSQLDriver.escape(
816
- `${this.prefix}tokens_${etype}_id_name_token`,
676
+ `${this.prefix}tokens_${etype}_id_name_token_guid`,
817
677
  )} ON ${PostgreSQLDriver.escape(
818
678
  `${this.prefix}tokens_${etype}`,
819
- )} USING btree ("name", "token");`,
679
+ )} USING btree ("name", "token", "guid");`,
820
680
  { connection },
821
681
  );
822
682
  await this.queryRun(
@@ -1292,13 +1152,13 @@ export default class PostgreSQLDriver extends NymphDriver {
1292
1152
  }[] = [];
1293
1153
 
1294
1154
  for (let [scope, suffix] of [
1295
- ['data', '_json'],
1155
+ ['data', '_string_guid'],
1296
1156
  ['references', '_reference_guid'],
1297
- ['tokens', '_token_position_stem'],
1157
+ ['tokens', '_token_guid'],
1298
1158
  ] as (
1299
- | ['data', '_json']
1159
+ | ['data', '_string_guid']
1300
1160
  | ['references', '_reference_guid']
1301
- | ['tokens', '_token_position_stem']
1161
+ | ['tokens', '_token_guid']
1302
1162
  )[]) {
1303
1163
  const indexDefinitions = await this.queryArray(
1304
1164
  `SELECT * FROM "pg_indexes" WHERE "indexname" LIKE @pattern;`,
@@ -1340,42 +1200,42 @@ export default class PostgreSQLDriver extends NymphDriver {
1340
1200
  if (definition.scope === 'data') {
1341
1201
  await this.queryRun(
1342
1202
  `CREATE INDEX ${PostgreSQLDriver.escape(
1343
- `${this.prefix}data_${etype}_id_custom_${definition.name}_json`,
1203
+ `${this.prefix}data_${etype}_id_custom_${definition.name}_string_guid`,
1344
1204
  )} ON ${PostgreSQLDriver.escape(
1345
1205
  `${this.prefix}data_${etype}`,
1346
- )} USING gin ("json") WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1206
+ )} USING btree (LEFT("string", 1024), "guid") WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1347
1207
  { connection },
1348
1208
  );
1349
1209
  await this.queryRun(
1350
1210
  `CREATE INDEX ${PostgreSQLDriver.escape(
1351
- `${this.prefix}data_${etype}_id_custom_${definition.name}_string_gin`,
1211
+ `${this.prefix}data_${etype}_id_custom_${definition.name}_number_guid`,
1352
1212
  )} ON ${PostgreSQLDriver.escape(
1353
1213
  `${this.prefix}data_${etype}`,
1354
- )} USING gin ("string" gin_trgm_ops) WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1214
+ )} USING btree ("number", "guid") WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1355
1215
  { connection },
1356
1216
  );
1357
1217
  await this.queryRun(
1358
1218
  `CREATE INDEX ${PostgreSQLDriver.escape(
1359
- `${this.prefix}data_${etype}_id_custom_${definition.name}_string_btree`,
1219
+ `${this.prefix}data_${etype}_id_custom_${definition.name}_truthy_guid`,
1360
1220
  )} ON ${PostgreSQLDriver.escape(
1361
1221
  `${this.prefix}data_${etype}`,
1362
- )} USING btree (LEFT("string", 1024)) WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1222
+ )} USING btree ("truthy", "guid") WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1363
1223
  { connection },
1364
1224
  );
1365
1225
  await this.queryRun(
1366
1226
  `CREATE INDEX ${PostgreSQLDriver.escape(
1367
- `${this.prefix}data_${etype}_id_custom_${definition.name}_number`,
1227
+ `${this.prefix}data_${etype}_id_custom_${definition.name}_string_gin`,
1368
1228
  )} ON ${PostgreSQLDriver.escape(
1369
1229
  `${this.prefix}data_${etype}`,
1370
- )} USING btree ("number") WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1230
+ )} USING gin ("string" gin_trgm_ops) WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1371
1231
  { connection },
1372
1232
  );
1373
1233
  await this.queryRun(
1374
1234
  `CREATE INDEX ${PostgreSQLDriver.escape(
1375
- `${this.prefix}data_${etype}_id_custom_${definition.name}_truthy`,
1235
+ `${this.prefix}data_${etype}_id_custom_${definition.name}_json`,
1376
1236
  )} ON ${PostgreSQLDriver.escape(
1377
1237
  `${this.prefix}data_${etype}`,
1378
- )} USING btree ("truthy") WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1238
+ )} USING gin ("json") WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1379
1239
  { connection },
1380
1240
  );
1381
1241
  } else if (definition.scope === 'references') {
@@ -1390,10 +1250,10 @@ export default class PostgreSQLDriver extends NymphDriver {
1390
1250
  } else if (definition.scope === 'tokens') {
1391
1251
  await this.queryRun(
1392
1252
  `CREATE INDEX ${PostgreSQLDriver.escape(
1393
- `${this.prefix}tokens_${etype}_id_custom_${definition.name}_token_position_stem`,
1253
+ `${this.prefix}tokens_${etype}_id_custom_${definition.name}_token_guid`,
1394
1254
  )} ON ${PostgreSQLDriver.escape(
1395
1255
  `${this.prefix}tokens_${etype}`,
1396
- )} USING btree ("token", "position", "stem") WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1256
+ )} USING btree ("token", "guid") WHERE "name"=${PostgreSQLDriver.escapeValue(definition.property)};`,
1397
1257
  { connection },
1398
1258
  );
1399
1259
  }
@@ -1411,31 +1271,31 @@ export default class PostgreSQLDriver extends NymphDriver {
1411
1271
  if (scope === 'data') {
1412
1272
  await this.queryRun(
1413
1273
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
1414
- `${this.prefix}data_${etype}_id_custom_${name}_json`,
1274
+ `${this.prefix}data_${etype}_id_custom_${name}_string_guid`,
1415
1275
  )};`,
1416
1276
  { connection },
1417
1277
  );
1418
1278
  await this.queryRun(
1419
1279
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
1420
- `${this.prefix}data_${etype}_id_custom_${name}_string_gin`,
1280
+ `${this.prefix}data_${etype}_id_custom_${name}_number_guid`,
1421
1281
  )};`,
1422
1282
  { connection },
1423
1283
  );
1424
1284
  await this.queryRun(
1425
1285
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
1426
- `${this.prefix}data_${etype}_id_custom_${name}_string_btree`,
1286
+ `${this.prefix}data_${etype}_id_custom_${name}_truthy_guid`,
1427
1287
  )};`,
1428
1288
  { connection },
1429
1289
  );
1430
1290
  await this.queryRun(
1431
1291
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
1432
- `${this.prefix}data_${etype}_id_custom_${name}_number`,
1292
+ `${this.prefix}data_${etype}_id_custom_${name}_string_gin`,
1433
1293
  )};`,
1434
1294
  { connection },
1435
1295
  );
1436
1296
  await this.queryRun(
1437
1297
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
1438
- `${this.prefix}data_${etype}_id_custom_${name}_truthy`,
1298
+ `${this.prefix}data_${etype}_id_custom_${name}_json`,
1439
1299
  )};`,
1440
1300
  { connection },
1441
1301
  );
@@ -1449,7 +1309,7 @@ export default class PostgreSQLDriver extends NymphDriver {
1449
1309
  } else if (scope === 'tokens') {
1450
1310
  await this.queryRun(
1451
1311
  `DROP INDEX IF EXISTS ${PostgreSQLDriver.escape(
1452
- `${this.prefix}tokens_${etype}_id_custom_${name}_token_position_stem`,
1312
+ `${this.prefix}tokens_${etype}_id_custom_${name}_token_guid`,
1453
1313
  )};`,
1454
1314
  { connection },
1455
1315
  );
@@ -1542,90 +1402,112 @@ export default class PostgreSQLDriver extends NymphDriver {
1542
1402
 
1543
1403
  for (const etype of etypes) {
1544
1404
  // Export entities.
1545
- const dataIterator = await this.queryIter(
1546
- `SELECT encode(e."guid", 'hex') AS "guid", e."tags", e."cdate", e."mdate", encode(e."user", 'hex') AS "user", encode(e."group", 'hex') AS "group", e."acUser", e."acGroup", e."acOther", array(SELECT encode(n, 'hex') FROM unnest(e."acRead") AS n) as "acRead", array(SELECT encode(n, 'hex') FROM unnest(e."acWrite") AS n) as "acWrite", array(SELECT encode(n, 'hex') FROM unnest(e."acFull") AS n) as "acFull", d."name", d."value", d."json", d."string", d."number"
1405
+ const entityIterator = this.exportEntityInternal(etype);
1406
+ for await (let content of entityIterator) {
1407
+ yield { type: 'entity', content };
1408
+ }
1409
+ }
1410
+ }
1411
+
1412
+ public async exportEntity(etype: string, guid: string): Promise<string> {
1413
+ const entityIterator = this.exportEntityInternal(etype, guid);
1414
+ let exportContent = '';
1415
+ for await (let content of entityIterator) {
1416
+ exportContent += content;
1417
+ }
1418
+
1419
+ return exportContent;
1420
+ }
1421
+
1422
+ private async *exportEntityInternal(
1423
+ etype: string,
1424
+ guid?: string,
1425
+ ): AsyncGenerator<string, void, false | undefined> {
1426
+ // Export entities.
1427
+ const dataIterator = await this.queryIter(
1428
+ `SELECT encode(e."guid", 'hex') AS "guid", e."tags", e."cdate", e."mdate", encode(e."user", 'hex') AS "user", encode(e."group", 'hex') AS "group", e."acUser", e."acGroup", e."acOther", array(SELECT encode(n, 'hex') FROM unnest(e."acRead") AS n) as "acRead", array(SELECT encode(n, 'hex') FROM unnest(e."acWrite") AS n) as "acWrite", array(SELECT encode(n, 'hex') FROM unnest(e."acFull") AS n) as "acFull", d."name", d."value", d."json", d."string", d."number"
1547
1429
  FROM ${PostgreSQLDriver.escape(`${this.prefix}entities_${etype}`)} e
1548
1430
  LEFT JOIN ${PostgreSQLDriver.escape(
1549
1431
  `${this.prefix}data_${etype}`,
1550
- )} d ON e."guid"=d."guid"
1432
+ )} d ON e."guid"=d."guid"${guid == null ? '' : ` WHERE e."guid"=decode(@guid, 'hex')`}
1551
1433
  ORDER BY e."guid";`,
1552
- );
1553
- let datum = await dataIterator.next();
1554
- while (!datum.done) {
1555
- const guid = datum.value.guid;
1556
- const tags = datum.value.tags.filter((tag: string) => tag).join(',');
1557
- const cdate = datum.value.cdate;
1558
- const mdate = datum.value.mdate;
1559
- const user = datum.value.user;
1560
- const group = datum.value.group;
1561
- const acUser = datum.value.acUser;
1562
- const acGroup = datum.value.acGroup;
1563
- const acOther = datum.value.acOther;
1564
- const acRead = datum.value.acRead?.filter((guid: string) => guid);
1565
- const acWrite = datum.value.acWrite?.filter((guid: string) => guid);
1566
- const acFull = datum.value.acFull?.filter((guid: string) => guid);
1567
- let currentEntityExport: string[] = [];
1568
- currentEntityExport.push(`{${guid}}<${etype}>[${tags}]`);
1569
- currentEntityExport.push(`\tcdate=${JSON.stringify(cdate)}`);
1570
- currentEntityExport.push(`\tmdate=${JSON.stringify(mdate)}`);
1571
- if (this.nymph.tilmeld != null) {
1572
- if (user != null) {
1573
- currentEntityExport.push(
1574
- `\tuser=${JSON.stringify(['nymph_entity_reference', user, 'User'])}`,
1575
- );
1576
- }
1577
- if (group != null) {
1578
- currentEntityExport.push(
1579
- `\tgroup=${JSON.stringify(['nymph_entity_reference', group, 'Group'])}`,
1580
- );
1581
- }
1582
- if (acUser != null) {
1583
- currentEntityExport.push(`\tacUser=${JSON.stringify(acUser)}`);
1584
- }
1585
- if (acGroup != null) {
1586
- currentEntityExport.push(`\tacGroup=${JSON.stringify(acGroup)}`);
1587
- }
1588
- if (acOther != null) {
1589
- currentEntityExport.push(`\tacOther=${JSON.stringify(acOther)}`);
1590
- }
1591
- if (acRead != null) {
1592
- currentEntityExport.push(`\tacRead=${JSON.stringify(acRead)}`);
1593
- }
1594
- if (acWrite != null) {
1595
- currentEntityExport.push(`\tacWrite=${JSON.stringify(acWrite)}`);
1596
- }
1597
- if (acFull != null) {
1598
- currentEntityExport.push(`\tacFull=${JSON.stringify(acFull)}`);
1599
- }
1434
+ guid == null ? undefined : { params: { guid } },
1435
+ );
1436
+ let datum = await dataIterator.next();
1437
+ while (!datum.done) {
1438
+ const guid = datum.value.guid;
1439
+ const tags = datum.value.tags.filter((tag: string) => tag).join(',');
1440
+ const cdate = datum.value.cdate;
1441
+ const mdate = datum.value.mdate;
1442
+ const user = datum.value.user;
1443
+ const group = datum.value.group;
1444
+ const acUser = datum.value.acUser;
1445
+ const acGroup = datum.value.acGroup;
1446
+ const acOther = datum.value.acOther;
1447
+ const acRead = datum.value.acRead?.filter((guid: string) => guid);
1448
+ const acWrite = datum.value.acWrite?.filter((guid: string) => guid);
1449
+ const acFull = datum.value.acFull?.filter((guid: string) => guid);
1450
+ let currentEntityExport: string[] = [];
1451
+ currentEntityExport.push(`{${guid}}<${etype}>[${tags}]`);
1452
+ currentEntityExport.push(`\tcdate=${JSON.stringify(cdate)}`);
1453
+ currentEntityExport.push(`\tmdate=${JSON.stringify(mdate)}`);
1454
+ if (this.nymph.tilmeld != null) {
1455
+ if (user != null) {
1456
+ currentEntityExport.push(
1457
+ `\tuser=${JSON.stringify(['nymph_entity_reference', user, 'User'])}`,
1458
+ );
1459
+ }
1460
+ if (group != null) {
1461
+ currentEntityExport.push(
1462
+ `\tgroup=${JSON.stringify(['nymph_entity_reference', group, 'Group'])}`,
1463
+ );
1464
+ }
1465
+ if (acUser != null) {
1466
+ currentEntityExport.push(`\tacUser=${JSON.stringify(acUser)}`);
1467
+ }
1468
+ if (acGroup != null) {
1469
+ currentEntityExport.push(`\tacGroup=${JSON.stringify(acGroup)}`);
1470
+ }
1471
+ if (acOther != null) {
1472
+ currentEntityExport.push(`\tacOther=${JSON.stringify(acOther)}`);
1473
+ }
1474
+ if (acRead != null) {
1475
+ currentEntityExport.push(`\tacRead=${JSON.stringify(acRead)}`);
1476
+ }
1477
+ if (acWrite != null) {
1478
+ currentEntityExport.push(`\tacWrite=${JSON.stringify(acWrite)}`);
1600
1479
  }
1601
- if (datum.value.name != null) {
1602
- // This do will keep going and adding the data until the
1603
- // next entity is reached. $row will end on the next entity.
1604
- do {
1605
- const value =
1606
- datum.value.value === 'N'
1607
- ? JSON.stringify(Number(datum.value.number))
1608
- : datum.value.value === 'S'
1609
- ? JSON.stringify(
1610
- PostgreSQLDriver.unescapeNulls(datum.value.string),
1480
+ if (acFull != null) {
1481
+ currentEntityExport.push(`\tacFull=${JSON.stringify(acFull)}`);
1482
+ }
1483
+ }
1484
+ if (datum.value.name != null) {
1485
+ // This do will keep going and adding the data until the
1486
+ // next entity is reached. $row will end on the next entity.
1487
+ do {
1488
+ const value =
1489
+ datum.value.value === 'N'
1490
+ ? JSON.stringify(Number(datum.value.number))
1491
+ : datum.value.value === 'S'
1492
+ ? JSON.stringify(
1493
+ PostgreSQLDriver.unescapeNulls(datum.value.string),
1494
+ )
1495
+ : datum.value.value === 'J'
1496
+ ? PostgreSQLDriver.unescapeNullSequences(
1497
+ JSON.stringify(datum.value.json),
1611
1498
  )
1612
- : datum.value.value === 'J'
1613
- ? PostgreSQLDriver.unescapeNullSequences(
1614
- JSON.stringify(datum.value.json),
1615
- )
1616
- : datum.value.value;
1617
- currentEntityExport.push(`\t${datum.value.name}=${value}`);
1618
- datum = await dataIterator.next();
1619
- } while (!datum.done && datum.value.guid === guid);
1620
- } else {
1621
- // Make sure that datum is incremented :)
1499
+ : datum.value.value;
1500
+ currentEntityExport.push(`\t${datum.value.name}=${value}`);
1622
1501
  datum = await dataIterator.next();
1623
- }
1624
- currentEntityExport.push('');
1502
+ } while (!datum.done && datum.value.guid === guid);
1503
+ } else {
1504
+ // Make sure that datum is incremented :)
1505
+ datum = await dataIterator.next();
1506
+ }
1507
+ currentEntityExport.push('');
1625
1508
 
1626
- if (yield { type: 'entity', content: currentEntityExport.join('\n') }) {
1627
- return;
1628
- }
1509
+ if (yield currentEntityExport.join('\n')) {
1510
+ return;
1629
1511
  }
1630
1512
  }
1631
1513
  }
package/tsconfig.json CHANGED
@@ -5,8 +5,8 @@
5
5
  "types": ["node", "jest"],
6
6
  "module": "nodenext",
7
7
  "moduleResolution": "nodenext",
8
- "lib": ["es2023"],
9
- "target": "es2023",
8
+ "lib": ["es2024"],
9
+ "target": "es2024",
10
10
  "noImplicitAny": true,
11
11
  "removeComments": false,
12
12
  "sourceMap": true,