@geonosis/document 0.3.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/README.md +23 -15
- package/dist/index.cjs +111 -67
- package/dist/index.d.cts +50 -39
- package/dist/index.d.ts +50 -39
- package/dist/index.js +109 -67
- package/migrations/0001_documents.sql +21 -13
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -273,6 +273,7 @@ var doorFor = (store, name) => {
|
|
|
273
273
|
return door;
|
|
274
274
|
};
|
|
275
275
|
var HEAD_COLUMNS = Object.keys(Document.headFields);
|
|
276
|
+
var SORT_COLUMNS = [...HEAD_COLUMNS, "number", "createdAt", "updatedAt"];
|
|
276
277
|
var rowsFor = (definition, store, schema) => {
|
|
277
278
|
const { name } = definition;
|
|
278
279
|
const door = doorFor(store, name);
|
|
@@ -335,7 +336,7 @@ var rowsFor = (definition, store, schema) => {
|
|
|
335
336
|
limit: optional(numberSchema),
|
|
336
337
|
order: optional(
|
|
337
338
|
schema.object({
|
|
338
|
-
column: schema.enum(
|
|
339
|
+
column: schema.enum(SORT_COLUMNS),
|
|
339
340
|
direction: optional(schema.enum(["asc", "desc"]))
|
|
340
341
|
})
|
|
341
342
|
)
|
|
@@ -509,13 +510,11 @@ var documentSurface = (options) => {
|
|
|
509
510
|
entity: optional(schema.union([stringSchema, arrayOf(stringSchema)])),
|
|
510
511
|
order: arrayOf(
|
|
511
512
|
schema.object({
|
|
512
|
-
column: schema.enum(
|
|
513
|
+
column: schema.enum([...SORT_COLUMNS, "entity"]),
|
|
513
514
|
direction: optional(schema.enum(["asc", "desc"]))
|
|
514
515
|
})
|
|
515
516
|
),
|
|
516
|
-
where: optional(
|
|
517
|
-
schema.object({ createdAt: optional(arrayOf(numberSchema)), status: optional(stringSchema) })
|
|
518
|
-
)
|
|
517
|
+
where: optional(unknownSchema)
|
|
519
518
|
});
|
|
520
519
|
const aggregateInput = schema.object({
|
|
521
520
|
by: optional(unknownSchema),
|
|
@@ -578,12 +577,33 @@ import {
|
|
|
578
577
|
var DEFAULT_DOCUMENT_TABLE = "documents";
|
|
579
578
|
var DEFAULT_ENTITY_COLUMN = "entity";
|
|
580
579
|
var DEFAULT_VERSION_COLUMN = "version";
|
|
581
|
-
var DEFAULT_TOTAL_COLUMN = "total";
|
|
582
580
|
var DEFAULT_TENANT_COLUMN = "tenant_id";
|
|
581
|
+
var DEFAULT_CREATED_AT_COLUMN = "created_at";
|
|
582
|
+
var DEFAULT_UPDATED_AT_COLUMN = "updated_at";
|
|
583
583
|
var DEFAULT_REVISIONS_TABLE = "document_revisions";
|
|
584
584
|
var DEFAULT_REVISION_KIND_COLUMN = "revision_kind";
|
|
585
585
|
var REVISION_KINDS = ["committed", "retired", "reinstated"];
|
|
586
|
+
var HEAD_FIELDS = Object.keys(headFields);
|
|
587
|
+
var snakeOf = (field) => field.replaceAll(/[A-Z]/g, (upper) => `_${upper.toLowerCase()}`);
|
|
586
588
|
var nameOf = (value, fallback) => value === void 0 ? fallback : typeof value === "string" ? value : value.name;
|
|
589
|
+
var physicalColumnsOf = (columns) => {
|
|
590
|
+
const heads = Object.fromEntries(
|
|
591
|
+
HEAD_FIELDS.map((field) => [
|
|
592
|
+
field,
|
|
593
|
+
nameOf(
|
|
594
|
+
columns?.heads?.[field] ?? (field === "total" ? columns?.total : void 0),
|
|
595
|
+
snakeOf(field)
|
|
596
|
+
)
|
|
597
|
+
])
|
|
598
|
+
);
|
|
599
|
+
return {
|
|
600
|
+
...heads,
|
|
601
|
+
createdAt: nameOf(columns?.createdAt, DEFAULT_CREATED_AT_COLUMN),
|
|
602
|
+
entity: columns?.entity ?? DEFAULT_ENTITY_COLUMN,
|
|
603
|
+
tenant: nameOf(columns?.tenant, DEFAULT_TENANT_COLUMN),
|
|
604
|
+
updatedAt: nameOf(columns?.updatedAt, DEFAULT_UPDATED_AT_COLUMN)
|
|
605
|
+
};
|
|
606
|
+
};
|
|
587
607
|
var appendOnlyTables = (options = {}) => {
|
|
588
608
|
if (options.revisions === false) return [];
|
|
589
609
|
return [options.revisions?.table ?? options.table ?? DEFAULT_REVISIONS_TABLE];
|
|
@@ -604,13 +624,21 @@ var documentRoleStatements = (appRole, options = {}) => {
|
|
|
604
624
|
]);
|
|
605
625
|
};
|
|
606
626
|
var DDL_TYPE_OF = { decimal: "numeric" };
|
|
607
|
-
var headIndexedColumns = (
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
|
|
627
|
+
var headIndexedColumns = (physical) => HEAD_FIELDS.map((field) => {
|
|
628
|
+
const type = DDL_TYPE_OF[headFields[field]];
|
|
629
|
+
return {
|
|
630
|
+
column: physical[field],
|
|
631
|
+
nullable: field !== "status",
|
|
632
|
+
...type === void 0 ? {} : { type }
|
|
633
|
+
};
|
|
611
634
|
});
|
|
612
635
|
var revisionKindType = (column) => `text check (${quotedName(column)} in (${REVISION_KINDS.map(literalName).join(", ")}))`;
|
|
613
|
-
var
|
|
636
|
+
var walls = (options) => ({
|
|
637
|
+
...options.freeze === void 0 ? {} : { freeze: options.freeze },
|
|
638
|
+
...options.names === void 0 ? {} : { names: options.names },
|
|
639
|
+
...options.schema === void 0 ? {} : { schema: options.schema }
|
|
640
|
+
});
|
|
641
|
+
var revisionsMigrations = (options, physical) => {
|
|
614
642
|
if (options.revisions === false) return [];
|
|
615
643
|
if (typeof options.appRole !== "string" || options.appRole === "") {
|
|
616
644
|
throw new DbRefusal(
|
|
@@ -621,10 +649,10 @@ var revisionsMigrations = (options, entityColumn, tenantColumn) => {
|
|
|
621
649
|
const table = options.revisions?.table ?? DEFAULT_REVISIONS_TABLE;
|
|
622
650
|
const [tableMigration, policies] = logMigrations({
|
|
623
651
|
appRole: options.appRole,
|
|
624
|
-
columns: { tenant:
|
|
652
|
+
columns: { tenant: physical.tenant },
|
|
625
653
|
extra: [{ column: revisionKindColumn, type: revisionKindType(revisionKindColumn) }],
|
|
626
|
-
key: [
|
|
627
|
-
...options
|
|
654
|
+
key: [physical.entity, "ref", { column: "lineage", type: "integer" }],
|
|
655
|
+
...walls(options),
|
|
628
656
|
settings: options.settings,
|
|
629
657
|
table
|
|
630
658
|
});
|
|
@@ -638,11 +666,10 @@ var revisionsMigrations = (options, entityColumn, tenantColumn) => {
|
|
|
638
666
|
};
|
|
639
667
|
var documentMigrations = (options) => {
|
|
640
668
|
const table = options.table ?? DEFAULT_DOCUMENT_TABLE;
|
|
641
|
-
const
|
|
642
|
-
const totalColumn = nameOf(options.columns?.total, DEFAULT_TOTAL_COLUMN);
|
|
643
|
-
const tenantColumn = nameOf(options.columns?.tenant, DEFAULT_TENANT_COLUMN);
|
|
669
|
+
const physical = physicalColumnsOf(options.columns);
|
|
644
670
|
const {
|
|
645
671
|
entity: _entity,
|
|
672
|
+
heads: _heads,
|
|
646
673
|
revisionKind: _revisionKind,
|
|
647
674
|
total: _total,
|
|
648
675
|
version,
|
|
@@ -651,13 +678,17 @@ var documentMigrations = (options) => {
|
|
|
651
678
|
const [tableMigration, ...rest] = projectionMigrations({
|
|
652
679
|
carried: [{ column: "lineage", type: "integer not null default 1" }],
|
|
653
680
|
columns: { ...restColumns, sequence: version ?? DEFAULT_VERSION_COLUMN },
|
|
654
|
-
constants: { [
|
|
655
|
-
indexed: headIndexedColumns(
|
|
681
|
+
constants: { [physical.entity]: "" },
|
|
682
|
+
indexed: headIndexedColumns(physical),
|
|
656
683
|
key: "number",
|
|
657
684
|
order: [{ column: "number" }],
|
|
658
|
-
...options
|
|
685
|
+
...walls(options),
|
|
659
686
|
settings: options.settings,
|
|
660
|
-
sortable:
|
|
687
|
+
sortable: [
|
|
688
|
+
...HEAD_FIELDS.map((field) => physical[field]),
|
|
689
|
+
physical.createdAt,
|
|
690
|
+
physical.updatedAt
|
|
691
|
+
],
|
|
661
692
|
table
|
|
662
693
|
});
|
|
663
694
|
if (tableMigration === void 0) {
|
|
@@ -665,11 +696,11 @@ var documentMigrations = (options) => {
|
|
|
665
696
|
"projectionMigrations answered with no table migration to append the listing index to"
|
|
666
697
|
);
|
|
667
698
|
}
|
|
668
|
-
const listingIndex = `create index if not exists ${quotedName(`${table}_${
|
|
699
|
+
const listingIndex = `create index if not exists ${quotedName(`${table}_${physical.entity}_${physical.issueDate}_idx`)} on ${quotedName(table)} (${quotedName(physical.entity)}, ${quotedName(physical.issueDate)})`;
|
|
669
700
|
return [
|
|
670
701
|
{ ...tableMigration, statements: [...tableMigration.statements, listingIndex] },
|
|
671
702
|
...rest,
|
|
672
|
-
...revisionsMigrations(options,
|
|
703
|
+
...revisionsMigrations(options, physical)
|
|
673
704
|
];
|
|
674
705
|
};
|
|
675
706
|
|
|
@@ -680,11 +711,7 @@ import {
|
|
|
680
711
|
defineLog,
|
|
681
712
|
projectionOf
|
|
682
713
|
} from "@geonosis/db";
|
|
683
|
-
var DEFAULT_ENTITY_COLUMN2 = "entity";
|
|
684
714
|
var DEFAULT_VERSION_COLUMN2 = "version";
|
|
685
|
-
var DEFAULT_TOTAL_COLUMN2 = "total";
|
|
686
|
-
var DEFAULT_TENANT_COLUMN2 = "tenant_id";
|
|
687
|
-
var DEFAULT_CREATED_AT_COLUMN = "created_at";
|
|
688
715
|
var UNDO_ACTOR = systemActor("document.undo");
|
|
689
716
|
var nameOf2 = (value, fallback) => value === void 0 ? fallback : typeof value === "string" ? value : value.name;
|
|
690
717
|
var readBody = (entity, entityName, ref, stored) => {
|
|
@@ -702,7 +729,6 @@ var readBody = (entity, entityName, ref, stored) => {
|
|
|
702
729
|
}
|
|
703
730
|
return result.value;
|
|
704
731
|
};
|
|
705
|
-
var HEAD_COLUMNS2 = Object.keys(headFields);
|
|
706
732
|
var headFrom = (found) => found === void 0 ? void 0 : {
|
|
707
733
|
body: found.body,
|
|
708
734
|
hash: found.hash,
|
|
@@ -712,28 +738,33 @@ var headFrom = (found) => found === void 0 ? void 0 : {
|
|
|
712
738
|
};
|
|
713
739
|
var documentStore = (options) => {
|
|
714
740
|
const table = options.table ?? DEFAULT_DOCUMENT_TABLE;
|
|
715
|
-
const entityColumn = options.columns?.entity ?? DEFAULT_ENTITY_COLUMN2;
|
|
716
741
|
const revisionKindColumn = options.columns?.revisionKind ?? DEFAULT_REVISION_KIND_COLUMN;
|
|
742
|
+
const physical = physicalColumnsOf(options.columns);
|
|
717
743
|
const {
|
|
718
744
|
entity: _entity,
|
|
745
|
+
heads: _heads,
|
|
719
746
|
revisionKind: _revisionKind,
|
|
720
|
-
total,
|
|
747
|
+
total: _total,
|
|
721
748
|
version,
|
|
722
749
|
...entityColumns
|
|
723
750
|
} = options.columns ?? {};
|
|
724
751
|
const versionColumn = nameOf2(version, DEFAULT_VERSION_COLUMN2);
|
|
725
|
-
const
|
|
726
|
-
const tenantColumn = nameOf2(entityColumns.tenant, DEFAULT_TENANT_COLUMN2);
|
|
727
|
-
const createdAtColumn = nameOf2(entityColumns.createdAt, DEFAULT_CREATED_AT_COLUMN);
|
|
752
|
+
const entityColumn = physical.entity;
|
|
728
753
|
const { archive, registry, schema, seam } = options;
|
|
729
754
|
const tenantKey = seam.tenantKey;
|
|
730
755
|
const placed = schema === void 0 ? {} : { schema };
|
|
731
756
|
const revisionsTable = options.revisions === false ? void 0 : options.revisions?.table ?? DEFAULT_REVISIONS_TABLE;
|
|
732
757
|
const tenanted = (tenantId) => ({ [tenantKey]: tenantId });
|
|
733
|
-
const columnOf = (column) => column === "
|
|
734
|
-
const physicalHeads =
|
|
758
|
+
const columnOf = (column) => column === "number" ? "number" : physical[column];
|
|
759
|
+
const physicalHeads = HEAD_FIELDS.map(columnOf);
|
|
760
|
+
const narrowed = (where) => Object.fromEntries(
|
|
761
|
+
Object.entries(where ?? {}).map(([column, held]) => [
|
|
762
|
+
columnOf(column),
|
|
763
|
+
held
|
|
764
|
+
])
|
|
765
|
+
);
|
|
735
766
|
const revisions = revisionsTable === void 0 ? void 0 : defineLog({
|
|
736
|
-
columns: { tenant:
|
|
767
|
+
columns: { tenant: physical.tenant },
|
|
737
768
|
extra: [{ column: revisionKindColumn, param: "kind" }],
|
|
738
769
|
hash: (row) => hashOf({
|
|
739
770
|
actor: row.actor,
|
|
@@ -767,13 +798,13 @@ var documentStore = (options) => {
|
|
|
767
798
|
};
|
|
768
799
|
const readers = defineEntity({
|
|
769
800
|
columns: { ...entityColumns, version: versionColumn },
|
|
770
|
-
filterable: [...physicalHeads, entityColumn,
|
|
801
|
+
filterable: [...physicalHeads, entityColumn, physical.createdAt, physical.updatedAt],
|
|
771
802
|
item: (row) => row,
|
|
772
803
|
key: { column: "number", param: "ref" },
|
|
773
804
|
order: [{ column: "number" }],
|
|
774
805
|
...placed,
|
|
775
806
|
seam,
|
|
776
|
-
sortable: [...physicalHeads, entityColumn, "number"],
|
|
807
|
+
sortable: [...physicalHeads, entityColumn, "number", physical.createdAt, physical.updatedAt],
|
|
777
808
|
table
|
|
778
809
|
});
|
|
779
810
|
const entityStoreFor = (name) => {
|
|
@@ -806,15 +837,25 @@ var documentStore = (options) => {
|
|
|
806
837
|
carried: ["lineage"],
|
|
807
838
|
columns: { ...entityColumns, hash: "hash", sequence: versionColumn },
|
|
808
839
|
constants: { [entityColumn]: name },
|
|
809
|
-
filterable:
|
|
840
|
+
filterable: physicalHeads,
|
|
810
841
|
item,
|
|
811
842
|
key: { column: "number", param: "ref" },
|
|
812
843
|
order: [{ column: "number" }],
|
|
813
844
|
...placed,
|
|
814
845
|
seam,
|
|
815
|
-
sortable:
|
|
846
|
+
sortable: [...physicalHeads, "number", physical.createdAt, physical.updatedAt],
|
|
816
847
|
table
|
|
817
848
|
});
|
|
849
|
+
const list = (handle, params) => projection.list(handle, {
|
|
850
|
+
...params,
|
|
851
|
+
...params.filter === void 0 ? {} : { filter: narrowed(params.filter) },
|
|
852
|
+
...params.order === void 0 ? {} : {
|
|
853
|
+
order: {
|
|
854
|
+
column: columnOf(params.order.column),
|
|
855
|
+
...params.order.direction === void 0 ? {} : { direction: params.order.direction }
|
|
856
|
+
}
|
|
857
|
+
}
|
|
858
|
+
});
|
|
818
859
|
const locked = async (tx, params) => headFrom(await projection.lockLatest(tx, params));
|
|
819
860
|
const currentLineageOf = async (tx, params) => headFrom(await projection.head(tx, params))?.lineage ?? 1;
|
|
820
861
|
const stream = (params, lineage) => ({
|
|
@@ -1177,7 +1218,7 @@ var documentStore = (options) => {
|
|
|
1177
1218
|
commit,
|
|
1178
1219
|
get: projection.get,
|
|
1179
1220
|
history,
|
|
1180
|
-
list
|
|
1221
|
+
list,
|
|
1181
1222
|
listAll: projection.listAll,
|
|
1182
1223
|
reinstate,
|
|
1183
1224
|
retire,
|
|
@@ -1193,44 +1234,43 @@ var documentStore = (options) => {
|
|
|
1193
1234
|
const restorers = Object.fromEntries(
|
|
1194
1235
|
built.map(([name, one]) => [name, one.restore])
|
|
1195
1236
|
);
|
|
1196
|
-
const heads = seam.scoped(
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1237
|
+
const heads = seam.scoped(
|
|
1238
|
+
async (tx, params) => {
|
|
1239
|
+
const { columns, entity, order, where } = params;
|
|
1240
|
+
const rows = await readers.project(tx, {
|
|
1241
|
+
...tenanted(params[tenantKey]),
|
|
1242
|
+
columns: columns.filter((column) => column !== "number").map(columnOf),
|
|
1243
|
+
order: order.map((one) => ({
|
|
1244
|
+
column: columnOf(one.column),
|
|
1245
|
+
...one.direction === void 0 ? {} : { direction: one.direction }
|
|
1246
|
+
})),
|
|
1247
|
+
where: {
|
|
1248
|
+
...entity === void 0 ? {} : { [entityColumn]: entity },
|
|
1249
|
+
...narrowed(where)
|
|
1250
|
+
}
|
|
1251
|
+
});
|
|
1252
|
+
return rows.map(
|
|
1253
|
+
(row) => Object.fromEntries(
|
|
1254
|
+
columns.map((column) => [column, column === "number" ? row.key : row[columnOf(column)]])
|
|
1255
|
+
)
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
);
|
|
1217
1259
|
const aggregate = seam.scoped(
|
|
1218
1260
|
(tx, params) => {
|
|
1219
1261
|
const { by, entities, entity, measures, where } = params;
|
|
1220
1262
|
return readers.aggregate(tx, {
|
|
1221
1263
|
...tenanted(params[tenantKey]),
|
|
1222
1264
|
...by === void 0 ? {} : {
|
|
1223
|
-
by: by === "
|
|
1265
|
+
by: typeof by === "string" ? columnOf(by) : { bucket: by.bucket, of: columnOf(by.of) }
|
|
1224
1266
|
},
|
|
1225
1267
|
measures: measures.map(
|
|
1226
|
-
(one) => one === "sum:total" ? `sum:${
|
|
1268
|
+
(one) => one === "sum:total" ? `sum:${physical.total}` : one
|
|
1227
1269
|
),
|
|
1228
1270
|
where: {
|
|
1229
1271
|
...entity === void 0 ? {} : { [entityColumn]: entity },
|
|
1230
1272
|
...entities === void 0 ? {} : { [entityColumn]: entities },
|
|
1231
|
-
...where
|
|
1232
|
-
...where !== void 0 && "issueDate" in where ? { issueDate: { from: where.issueDate[0], to: where.issueDate[1] } } : {},
|
|
1233
|
-
...where !== void 0 && "createdAt" in where ? { [createdAtColumn]: { from: where.createdAt[0], to: where.createdAt[1] } } : {}
|
|
1273
|
+
...narrowed(where)
|
|
1234
1274
|
}
|
|
1235
1275
|
});
|
|
1236
1276
|
}
|
|
@@ -1274,6 +1314,7 @@ export {
|
|
|
1274
1314
|
DEFAULT_REVISION_KIND_COLUMN,
|
|
1275
1315
|
ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS,
|
|
1276
1316
|
Document,
|
|
1317
|
+
HEAD_FIELDS,
|
|
1277
1318
|
appendOnlyTables,
|
|
1278
1319
|
canTransition,
|
|
1279
1320
|
canonicalOf,
|
|
@@ -1289,6 +1330,7 @@ export {
|
|
|
1289
1330
|
isSystemActor,
|
|
1290
1331
|
isTerminalStatus,
|
|
1291
1332
|
migrateBody,
|
|
1333
|
+
physicalColumnsOf,
|
|
1292
1334
|
stampBody,
|
|
1293
1335
|
systemActor,
|
|
1294
1336
|
validatorOf
|
|
@@ -7,11 +7,11 @@ create table if not exists "documents" (
|
|
|
7
7
|
"updated_at" bigint not null,
|
|
8
8
|
"retired_at" bigint,
|
|
9
9
|
"version" integer not null default 1,
|
|
10
|
-
"status" text,
|
|
11
|
-
"
|
|
12
|
-
"
|
|
10
|
+
"status" text not null,
|
|
11
|
+
"issue_date" text,
|
|
12
|
+
"due_date" text,
|
|
13
13
|
"counterparty" text,
|
|
14
|
-
"
|
|
14
|
+
"external_ref" text,
|
|
15
15
|
"revision" text,
|
|
16
16
|
"total" numeric,
|
|
17
17
|
constraint "documents_pkey" primary key ("tenant_id", "entity", "number")
|
|
@@ -19,38 +19,46 @@ create table if not exists "documents" (
|
|
|
19
19
|
|
|
20
20
|
-- The migrator applies this file inside a transaction, which is also why CONCURRENTLY is not available here; the index is created in the same migration as its table, over no rows. lock_timeout and statement_timeout are one deployment’s numbers, and a value written into shipped DDL imposes that deployment’s budget on every consumer: set them in the session that migrates.
|
|
21
21
|
-- squawk-ignore require-concurrent-index-creation, require-lock-timeout, require-statement-timeout
|
|
22
|
-
create index if not exists "documents_listing_idx" on "documents" ("tenant_id", "number" asc);
|
|
22
|
+
create index if not exists "documents_listing_idx" on "documents" ("tenant_id", "entity", "number" asc);
|
|
23
23
|
|
|
24
24
|
-- The migrator applies this file inside a transaction, which is also why CONCURRENTLY is not available here; the index is created in the same migration as its table, over no rows. lock_timeout and statement_timeout are one deployment’s numbers, and a value written into shipped DDL imposes that deployment’s budget on every consumer: set them in the session that migrates.
|
|
25
25
|
-- squawk-ignore require-concurrent-index-creation, require-lock-timeout, require-statement-timeout
|
|
26
|
-
create index if not exists "documents_by_status_idx" on "documents" ("tenant_id", "status" asc, "number" asc);
|
|
26
|
+
create index if not exists "documents_by_status_idx" on "documents" ("tenant_id", "entity", "status" asc, "number" asc);
|
|
27
27
|
|
|
28
28
|
-- The migrator applies this file inside a transaction, which is also why CONCURRENTLY is not available here; the index is created in the same migration as its table, over no rows. lock_timeout and statement_timeout are one deployment’s numbers, and a value written into shipped DDL imposes that deployment’s budget on every consumer: set them in the session that migrates.
|
|
29
29
|
-- squawk-ignore require-concurrent-index-creation, require-lock-timeout, require-statement-timeout
|
|
30
|
-
create index if not exists "
|
|
30
|
+
create index if not exists "documents_by_issue_date_idx" on "documents" ("tenant_id", "entity", "issue_date" asc, "number" asc);
|
|
31
31
|
|
|
32
32
|
-- The migrator applies this file inside a transaction, which is also why CONCURRENTLY is not available here; the index is created in the same migration as its table, over no rows. lock_timeout and statement_timeout are one deployment’s numbers, and a value written into shipped DDL imposes that deployment’s budget on every consumer: set them in the session that migrates.
|
|
33
33
|
-- squawk-ignore require-concurrent-index-creation, require-lock-timeout, require-statement-timeout
|
|
34
|
-
create index if not exists "
|
|
34
|
+
create index if not exists "documents_by_due_date_idx" on "documents" ("tenant_id", "entity", "due_date" asc, "number" asc);
|
|
35
35
|
|
|
36
36
|
-- The migrator applies this file inside a transaction, which is also why CONCURRENTLY is not available here; the index is created in the same migration as its table, over no rows. lock_timeout and statement_timeout are one deployment’s numbers, and a value written into shipped DDL imposes that deployment’s budget on every consumer: set them in the session that migrates.
|
|
37
37
|
-- squawk-ignore require-concurrent-index-creation, require-lock-timeout, require-statement-timeout
|
|
38
|
-
create index if not exists "documents_by_counterparty_idx" on "documents" ("tenant_id", "counterparty" asc, "number" asc);
|
|
38
|
+
create index if not exists "documents_by_counterparty_idx" on "documents" ("tenant_id", "entity", "counterparty" asc, "number" asc);
|
|
39
39
|
|
|
40
40
|
-- The migrator applies this file inside a transaction, which is also why CONCURRENTLY is not available here; the index is created in the same migration as its table, over no rows. lock_timeout and statement_timeout are one deployment’s numbers, and a value written into shipped DDL imposes that deployment’s budget on every consumer: set them in the session that migrates.
|
|
41
41
|
-- squawk-ignore require-concurrent-index-creation, require-lock-timeout, require-statement-timeout
|
|
42
|
-
create index if not exists "
|
|
42
|
+
create index if not exists "documents_by_external_ref_idx" on "documents" ("tenant_id", "entity", "external_ref" asc, "number" asc);
|
|
43
43
|
|
|
44
44
|
-- The migrator applies this file inside a transaction, which is also why CONCURRENTLY is not available here; the index is created in the same migration as its table, over no rows. lock_timeout and statement_timeout are one deployment’s numbers, and a value written into shipped DDL imposes that deployment’s budget on every consumer: set them in the session that migrates.
|
|
45
45
|
-- squawk-ignore require-concurrent-index-creation, require-lock-timeout, require-statement-timeout
|
|
46
|
-
create index if not exists "documents_by_revision_idx" on "documents" ("tenant_id", "revision" asc, "number" asc);
|
|
46
|
+
create index if not exists "documents_by_revision_idx" on "documents" ("tenant_id", "entity", "revision" asc, "number" asc);
|
|
47
47
|
|
|
48
48
|
-- The migrator applies this file inside a transaction, which is also why CONCURRENTLY is not available here; the index is created in the same migration as its table, over no rows. lock_timeout and statement_timeout are one deployment’s numbers, and a value written into shipped DDL imposes that deployment’s budget on every consumer: set them in the session that migrates.
|
|
49
49
|
-- squawk-ignore require-concurrent-index-creation, require-lock-timeout, require-statement-timeout
|
|
50
|
-
create index if not exists "documents_by_total_idx" on "documents" ("tenant_id", "total" asc, "number" asc);
|
|
50
|
+
create index if not exists "documents_by_total_idx" on "documents" ("tenant_id", "entity", "total" asc, "number" asc);
|
|
51
|
+
|
|
52
|
+
-- The migrator applies this file inside a transaction, which is also why CONCURRENTLY is not available here; the index is created in the same migration as its table, over no rows. lock_timeout and statement_timeout are one deployment’s numbers, and a value written into shipped DDL imposes that deployment’s budget on every consumer: set them in the session that migrates.
|
|
53
|
+
-- squawk-ignore require-concurrent-index-creation, require-lock-timeout, require-statement-timeout
|
|
54
|
+
create index if not exists "documents_by_created_at_idx" on "documents" ("tenant_id", "entity", "created_at" asc, "number" asc);
|
|
55
|
+
|
|
56
|
+
-- The migrator applies this file inside a transaction, which is also why CONCURRENTLY is not available here; the index is created in the same migration as its table, over no rows. lock_timeout and statement_timeout are one deployment’s numbers, and a value written into shipped DDL imposes that deployment’s budget on every consumer: set them in the session that migrates.
|
|
57
|
+
-- squawk-ignore require-concurrent-index-creation, require-lock-timeout, require-statement-timeout
|
|
58
|
+
create index if not exists "documents_by_updated_at_idx" on "documents" ("tenant_id", "entity", "updated_at" asc, "number" asc);
|
|
51
59
|
|
|
52
60
|
alter table "documents" add column if not exists "hash" text;
|
|
53
61
|
|
|
54
62
|
alter table "documents" add column if not exists "lineage" integer not null default 1;
|
|
55
63
|
|
|
56
|
-
create index if not exists "
|
|
64
|
+
create index if not exists "documents_entity_issue_date_idx" on "documents" ("entity", "issue_date");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geonosis/document",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"types": "./dist/index.d.ts",
|
|
5
5
|
"description": "The abstract Document: an entity-first base every kind of paper-trail record extends, a derived entity registry whose name union keeps every consumer map total, and per-entity body versioning — engine-free, SQL-free, the pure core the store, the workflows and the wire contract build on.",
|
|
6
6
|
"keywords": [
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@standard-schema/spec": "^1.1.0",
|
|
42
|
-
"@geonosis/db": "^0.
|
|
42
|
+
"@geonosis/db": "^0.10.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"embedded-postgres-17": "npm:embedded-postgres@17.10.0-beta.17",
|