@geonosis/document 0.9.2 → 0.10.0

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.
Files changed (79) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/README.md +78 -13
  3. package/dist/core/actor.d.cts +0 -1
  4. package/dist/core/actor.d.ts +0 -1
  5. package/dist/core/body-version.d.cts +0 -9
  6. package/dist/core/body-version.d.ts +0 -9
  7. package/dist/core/canonical.cjs +2 -3
  8. package/dist/core/canonical.d.cts +0 -4
  9. package/dist/core/canonical.d.ts +0 -4
  10. package/dist/core/canonical.js +2 -3
  11. package/dist/core/document.cjs +28 -25
  12. package/dist/core/document.d.cts +3 -22
  13. package/dist/core/document.d.ts +3 -22
  14. package/dist/core/document.js +28 -25
  15. package/dist/core/entities.d.cts +0 -19
  16. package/dist/core/entities.d.ts +0 -19
  17. package/dist/core/naming.d.cts +0 -5
  18. package/dist/core/naming.d.ts +0 -5
  19. package/dist/core/numbering.d.cts +0 -4
  20. package/dist/core/numbering.d.ts +0 -4
  21. package/dist/core/ports.d.cts +0 -6
  22. package/dist/core/ports.d.ts +0 -6
  23. package/dist/core/schema.cjs +44 -76
  24. package/dist/core/schema.d.cts +1 -13
  25. package/dist/core/schema.d.ts +1 -13
  26. package/dist/core/schema.js +44 -76
  27. package/dist/core/status.d.cts +0 -1
  28. package/dist/core/status.d.ts +0 -1
  29. package/dist/index.cjs +1 -0
  30. package/dist/index.d.cts +1 -1
  31. package/dist/index.d.ts +1 -1
  32. package/dist/index.js +2 -0
  33. package/dist/store/ddl.cjs +35 -38
  34. package/dist/store/ddl.d.cts +6 -6
  35. package/dist/store/ddl.d.ts +6 -6
  36. package/dist/store/ddl.js +37 -39
  37. package/dist/store/hash.d.cts +0 -1
  38. package/dist/store/hash.d.ts +0 -1
  39. package/dist/store/number-for.cjs +52 -0
  40. package/dist/store/number-for.d.cts +11 -0
  41. package/dist/store/number-for.d.ts +11 -0
  42. package/dist/store/number-for.js +12 -0
  43. package/dist/store/store.cjs +188 -162
  44. package/dist/store/store.d.cts +57 -16
  45. package/dist/store/store.d.ts +57 -16
  46. package/dist/store/store.js +190 -163
  47. package/dist/store.cjs +2 -0
  48. package/dist/store.d.cts +3 -2
  49. package/dist/store.d.ts +3 -2
  50. package/dist/store.js +2 -0
  51. package/dist/surface/table.cjs +129 -66
  52. package/dist/surface/table.d.cts +20 -28
  53. package/dist/surface/table.d.ts +20 -28
  54. package/dist/surface/table.js +132 -66
  55. package/dist/workflows/bindings.cjs +48 -0
  56. package/dist/workflows/bindings.d.cts +15 -0
  57. package/dist/workflows/bindings.d.ts +15 -0
  58. package/dist/workflows/bindings.js +10 -0
  59. package/dist/workflows/document-workflows.cjs +29 -40
  60. package/dist/workflows/document-workflows.d.cts +0 -12
  61. package/dist/workflows/document-workflows.d.ts +0 -12
  62. package/dist/workflows/document-workflows.js +29 -40
  63. package/dist/workflows/effects.d.cts +0 -12
  64. package/dist/workflows/effects.d.ts +0 -12
  65. package/dist/workflows/ports.d.cts +0 -17
  66. package/dist/workflows/ports.d.ts +0 -17
  67. package/dist/workflows/refusals.cjs +30 -0
  68. package/dist/workflows/refusals.d.cts +37 -9
  69. package/dist/workflows/refusals.d.ts +37 -9
  70. package/dist/workflows/refusals.js +30 -0
  71. package/dist/workflows/shared.cjs +93 -0
  72. package/dist/workflows/shared.d.cts +28 -0
  73. package/dist/workflows/shared.d.ts +28 -0
  74. package/dist/workflows/shared.js +60 -0
  75. package/dist/workflows.cjs +16 -1
  76. package/dist/workflows.d.cts +3 -1
  77. package/dist/workflows.d.ts +3 -1
  78. package/dist/workflows.js +31 -1
  79. package/package.json +4 -4
@@ -44,11 +44,13 @@ __export(exports_ddl, {
44
44
  DEFAULT_REVISION_KIND_COLUMN: () => DEFAULT_REVISION_KIND_COLUMN,
45
45
  DOCUMENT_MIGRATION_PLACEHOLDERS: () => import_db.ENTITY_PLACEHOLDERS,
46
46
  HEAD_FIELDS: () => HEAD_FIELDS,
47
+ REVISION_KINDS: () => REVISION_KINDS,
47
48
  appendOnlyTables: () => appendOnlyTables,
48
49
  documentMigrations: () => documentMigrations,
49
50
  documentRoleStatements: () => documentRoleStatements,
50
51
  documentTable: () => documentTable,
51
- physicalColumnsOf: () => physicalColumnsOf
52
+ physicalColumnsOf: () => physicalColumnsOf,
53
+ splitColumns: () => splitColumns
52
54
  });
53
55
  module.exports = __toCommonJS(exports_ddl);
54
56
  var import_db = require("@geonosis/db");
@@ -78,34 +80,44 @@ var physicalColumnsOf = (columns) => {
78
80
  updatedAt: nameOf(columns?.updatedAt, DEFAULT_UPDATED_AT_COLUMN)
79
81
  };
80
82
  };
83
+ var splitColumns = (columns) => {
84
+ const {
85
+ entity: _entity,
86
+ heads: _heads,
87
+ revisionKind: _revisionKind,
88
+ total: _total,
89
+ version,
90
+ ...rest
91
+ } = columns ?? {};
92
+ return { rest, version: nameOf(version, DEFAULT_VERSION_COLUMN) };
93
+ };
81
94
  var appendOnlyTables = (options = {}) => {
95
+ if (options.table !== undefined) {
96
+ throw new import_db.DbRefusal("`table` names the documents table everywhere else in this package, and the documents table is the one an application must update: name the log as `revisions: { table }`");
97
+ }
82
98
  if (options.revisions === false)
83
99
  return [];
84
- return [options.revisions?.table ?? options.table ?? DEFAULT_REVISIONS_TABLE];
100
+ return [options.revisions?.table ?? DEFAULT_REVISIONS_TABLE];
85
101
  };
86
- var quotedName = (name) => `"${name}"`;
87
- var literalName = (value) => `'${value.replaceAll("'", "''")}'`;
102
+ var { quoted } = import_db.sqlFragments;
88
103
  var documentRoleStatements = (appRole, options = {}) => {
89
104
  if (typeof appRole !== "string" || appRole === "") {
90
105
  throw new import_db.DbRefusal("documentRoleStatements needs an `appRole` — the name a consumer’s application connects as belongs to whoever runs the database, and one baked in here would be another repo’s");
91
106
  }
92
- const role = quotedName(appRole);
93
- const on = (table) => options.schema === undefined ? quotedName(table) : `${quotedName(options.schema)}.${quotedName(table)}`;
107
+ const role = quoted(appRole);
108
+ const on = (table) => options.schema === undefined ? quoted(table) : `${quoted(options.schema)}.${quoted(table)}`;
94
109
  return appendOnlyTables(options).flatMap((table) => [
95
110
  `revoke update, delete on ${on(table)} from ${role}`,
96
111
  `grant select, insert on ${on(table)} to ${role}`
97
112
  ]);
98
113
  };
99
- var DDL_TYPE_OF = { decimal: "numeric" };
100
- var headIndexedColumns = (physical) => HEAD_FIELDS.map((field) => {
101
- const type = DDL_TYPE_OF[import_document.headFields[field]];
102
- return {
103
- column: physical[field],
104
- nullable: field !== "status",
105
- ...type === undefined ? {} : { type }
106
- };
107
- });
108
- var revisionKindType = (column) => `text check (${quotedName(column)} in (${REVISION_KINDS.map(literalName).join(", ")}))`;
114
+ var isNumeric = (field) => import_document.headFields[field] === "decimal";
115
+ var headIndexedColumns = (physical) => HEAD_FIELDS.map((field) => ({
116
+ column: physical[field],
117
+ nullable: field !== "status",
118
+ ...isNumeric(field) ? { type: "numeric" } : {}
119
+ }));
120
+ var revisionKindType = (column) => `text check (${quoted(column)} in (${REVISION_KINDS.map((kind) => `'${kind}'`).join(", ")}))`;
109
121
  var walls = (options) => ({
110
122
  ...options.freeze === undefined ? {} : { freeze: options.freeze },
111
123
  ...options.names === undefined ? {} : { names: options.names },
@@ -139,17 +151,10 @@ var revisionsMigrations = (options, physical) => {
139
151
  var documentMigrations = (options) => {
140
152
  const table = options.table ?? DEFAULT_DOCUMENT_TABLE;
141
153
  const physical = physicalColumnsOf(options.columns);
142
- const {
143
- entity: _entity,
144
- heads: _heads,
145
- revisionKind: _revisionKind,
146
- total: _total,
147
- version,
148
- ...restColumns
149
- } = options.columns ?? {};
154
+ const { rest: restColumns, version } = splitColumns(options.columns);
150
155
  const [tableMigration, ...rest] = import_db.projectionMigrations({
151
156
  carried: [{ column: "lineage", type: "integer not null default 1" }],
152
- columns: { ...restColumns, sequence: version ?? DEFAULT_VERSION_COLUMN },
157
+ columns: { ...restColumns, sequence: version },
153
158
  constants: { [physical.entity]: "" },
154
159
  indexed: headIndexedColumns(physical),
155
160
  key: "number",
@@ -166,35 +171,27 @@ var documentMigrations = (options) => {
166
171
  if (tableMigration === undefined) {
167
172
  throw new Error("projectionMigrations answered with no table migration to append the listing index to");
168
173
  }
169
- const listingIndex = `create index if not exists ${quotedName(`${table}_${physical.entity}_${physical.issueDate}_idx`)} on ${quotedName(table)} (${quotedName(physical.entity)}, ${quotedName(physical.issueDate)})`;
174
+ const listingIndex = `create index if not exists ${quoted(`${table}_${physical.entity}_${physical.issueDate}_idx`)} on ${quoted(table)} (${quoted(physical.entity)}, ${quoted(physical.issueDate)})`;
170
175
  return [
171
176
  { ...tableMigration, statements: [...tableMigration.statements, listingIndex] },
172
177
  ...rest,
173
178
  ...revisionsMigrations(options, physical)
174
179
  ];
175
180
  };
176
- var TABLE_TYPE_OF = { decimal: "numeric" };
177
181
  var documentTable = (options = {}) => {
178
182
  const physical = physicalColumnsOf(options.columns);
179
- const {
180
- entity: _entity,
181
- heads: _heads,
182
- id,
183
- revisionKind: _revisionKind,
184
- total: _total,
185
- version,
186
- ...restColumns
187
- } = options.columns ?? {};
183
+ const { rest, version } = splitColumns(options.columns);
184
+ const { id, ...restColumns } = rest;
188
185
  const named = Object.fromEntries(Object.entries(restColumns).map(([column, held]) => [column, nameOf(held, column)]));
189
186
  return import_db.entityTable({
190
- columns: { ...named, version: nameOf(version, DEFAULT_VERSION_COLUMN) },
187
+ columns: { ...named, version },
191
188
  constants: [physical.entity],
192
189
  extra: {
193
190
  ...Object.fromEntries(HEAD_FIELDS.map((field) => [
194
191
  physical[field],
195
192
  {
196
193
  nullable: field !== "status",
197
- type: TABLE_TYPE_OF[import_document.headFields[field]] ?? "text"
194
+ type: isNumeric(field) ? "numeric" : "text"
198
195
  }
199
196
  ])),
200
197
  hash: "text",
@@ -5,6 +5,7 @@ export { ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS };
5
5
  export declare const DEFAULT_DOCUMENT_TABLE = "documents";
6
6
  export declare const DEFAULT_REVISIONS_TABLE = "document_revisions";
7
7
  export declare const DEFAULT_REVISION_KIND_COLUMN = "revision_kind";
8
+ export declare const REVISION_KINDS: readonly ['committed', 'retired', 'reinstated'];
8
9
  export type HeadField = keyof DocumentHead;
9
10
  export declare const HEAD_FIELDS: HeadField[];
10
11
  export type DocumentColumns = EntityColumns & {
@@ -20,6 +21,10 @@ export type DocumentPhysicalColumns = Readonly<Record<HeadField, string>> & {
20
21
  updatedAt: string;
21
22
  };
22
23
  export declare const physicalColumnsOf: (columns: DocumentColumns | undefined) => DocumentPhysicalColumns;
24
+ export declare const splitColumns: (columns: DocumentColumns | undefined) => {
25
+ rest: EntityColumns;
26
+ version: string;
27
+ };
23
28
  export type DocumentRevisionsOptions = {
24
29
  table?: string;
25
30
  };
@@ -34,7 +39,7 @@ export type DocumentMigrationsOptions = {
34
39
  table?: string;
35
40
  };
36
41
  export type AppendOnlyTablesOptions = {
37
- table?: string;
42
+ table?: never;
38
43
  revisions?: DocumentRevisionsOptions | false;
39
44
  };
40
45
  export declare const appendOnlyTables: (options?: AppendOnlyTablesOptions) => string[];
@@ -48,9 +53,4 @@ export type DocumentTableOptions = {
48
53
  settings?: SessionSettings;
49
54
  table?: string;
50
55
  };
51
- /**
52
- * The document table as a drizzle table: the same shape `documentMigrations` renders, declared once
53
- * so the store's reads and writes compose over it (D-069). A consumer with a table of their own
54
- * hands that in instead.
55
- */
56
56
  export declare const documentTable: (options?: DocumentTableOptions) => PgTable;
@@ -5,6 +5,7 @@ export { ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS };
5
5
  export declare const DEFAULT_DOCUMENT_TABLE = "documents";
6
6
  export declare const DEFAULT_REVISIONS_TABLE = "document_revisions";
7
7
  export declare const DEFAULT_REVISION_KIND_COLUMN = "revision_kind";
8
+ export declare const REVISION_KINDS: readonly ['committed', 'retired', 'reinstated'];
8
9
  export type HeadField = keyof DocumentHead;
9
10
  export declare const HEAD_FIELDS: HeadField[];
10
11
  export type DocumentColumns = EntityColumns & {
@@ -20,6 +21,10 @@ export type DocumentPhysicalColumns = Readonly<Record<HeadField, string>> & {
20
21
  updatedAt: string;
21
22
  };
22
23
  export declare const physicalColumnsOf: (columns: DocumentColumns | undefined) => DocumentPhysicalColumns;
24
+ export declare const splitColumns: (columns: DocumentColumns | undefined) => {
25
+ rest: EntityColumns;
26
+ version: string;
27
+ };
23
28
  export type DocumentRevisionsOptions = {
24
29
  table?: string;
25
30
  };
@@ -34,7 +39,7 @@ export type DocumentMigrationsOptions = {
34
39
  table?: string;
35
40
  };
36
41
  export type AppendOnlyTablesOptions = {
37
- table?: string;
42
+ table?: never;
38
43
  revisions?: DocumentRevisionsOptions | false;
39
44
  };
40
45
  export declare const appendOnlyTables: (options?: AppendOnlyTablesOptions) => string[];
@@ -48,9 +53,4 @@ export type DocumentTableOptions = {
48
53
  settings?: SessionSettings;
49
54
  table?: string;
50
55
  };
51
- /**
52
- * The document table as a drizzle table: the same shape `documentMigrations` renders, declared once
53
- * so the store's reads and writes compose over it (D-069). A consumer with a table of their own
54
- * hands that in instead.
55
- */
56
56
  export declare const documentTable: (options?: DocumentTableOptions) => PgTable;
package/dist/store/ddl.js CHANGED
@@ -4,7 +4,8 @@ import {
4
4
  ENTITY_PLACEHOLDERS,
5
5
  entityTable,
6
6
  logMigrations,
7
- projectionMigrations
7
+ projectionMigrations,
8
+ sqlFragments
8
9
  } from "@geonosis/db";
9
10
  import { headFields } from "../core/document.js";
10
11
  var DEFAULT_DOCUMENT_TABLE = "documents";
@@ -32,34 +33,44 @@ var physicalColumnsOf = (columns) => {
32
33
  updatedAt: nameOf(columns?.updatedAt, DEFAULT_UPDATED_AT_COLUMN)
33
34
  };
34
35
  };
36
+ var splitColumns = (columns) => {
37
+ const {
38
+ entity: _entity,
39
+ heads: _heads,
40
+ revisionKind: _revisionKind,
41
+ total: _total,
42
+ version,
43
+ ...rest
44
+ } = columns ?? {};
45
+ return { rest, version: nameOf(version, DEFAULT_VERSION_COLUMN) };
46
+ };
35
47
  var appendOnlyTables = (options = {}) => {
48
+ if (options.table !== undefined) {
49
+ throw new DbRefusal("`table` names the documents table everywhere else in this package, and the documents table is the one an application must update: name the log as `revisions: { table }`");
50
+ }
36
51
  if (options.revisions === false)
37
52
  return [];
38
- return [options.revisions?.table ?? options.table ?? DEFAULT_REVISIONS_TABLE];
53
+ return [options.revisions?.table ?? DEFAULT_REVISIONS_TABLE];
39
54
  };
40
- var quotedName = (name) => `"${name}"`;
41
- var literalName = (value) => `'${value.replaceAll("'", "''")}'`;
55
+ var { quoted } = sqlFragments;
42
56
  var documentRoleStatements = (appRole, options = {}) => {
43
57
  if (typeof appRole !== "string" || appRole === "") {
44
58
  throw new DbRefusal("documentRoleStatements needs an `appRole` — the name a consumer’s application connects as belongs to whoever runs the database, and one baked in here would be another repo’s");
45
59
  }
46
- const role = quotedName(appRole);
47
- const on = (table) => options.schema === undefined ? quotedName(table) : `${quotedName(options.schema)}.${quotedName(table)}`;
60
+ const role = quoted(appRole);
61
+ const on = (table) => options.schema === undefined ? quoted(table) : `${quoted(options.schema)}.${quoted(table)}`;
48
62
  return appendOnlyTables(options).flatMap((table) => [
49
63
  `revoke update, delete on ${on(table)} from ${role}`,
50
64
  `grant select, insert on ${on(table)} to ${role}`
51
65
  ]);
52
66
  };
53
- var DDL_TYPE_OF = { decimal: "numeric" };
54
- var headIndexedColumns = (physical) => HEAD_FIELDS.map((field) => {
55
- const type = DDL_TYPE_OF[headFields[field]];
56
- return {
57
- column: physical[field],
58
- nullable: field !== "status",
59
- ...type === undefined ? {} : { type }
60
- };
61
- });
62
- var revisionKindType = (column) => `text check (${quotedName(column)} in (${REVISION_KINDS.map(literalName).join(", ")}))`;
67
+ var isNumeric = (field) => headFields[field] === "decimal";
68
+ var headIndexedColumns = (physical) => HEAD_FIELDS.map((field) => ({
69
+ column: physical[field],
70
+ nullable: field !== "status",
71
+ ...isNumeric(field) ? { type: "numeric" } : {}
72
+ }));
73
+ var revisionKindType = (column) => `text check (${quoted(column)} in (${REVISION_KINDS.map((kind) => `'${kind}'`).join(", ")}))`;
63
74
  var walls = (options) => ({
64
75
  ...options.freeze === undefined ? {} : { freeze: options.freeze },
65
76
  ...options.names === undefined ? {} : { names: options.names },
@@ -93,17 +104,10 @@ var revisionsMigrations = (options, physical) => {
93
104
  var documentMigrations = (options) => {
94
105
  const table = options.table ?? DEFAULT_DOCUMENT_TABLE;
95
106
  const physical = physicalColumnsOf(options.columns);
96
- const {
97
- entity: _entity,
98
- heads: _heads,
99
- revisionKind: _revisionKind,
100
- total: _total,
101
- version,
102
- ...restColumns
103
- } = options.columns ?? {};
107
+ const { rest: restColumns, version } = splitColumns(options.columns);
104
108
  const [tableMigration, ...rest] = projectionMigrations({
105
109
  carried: [{ column: "lineage", type: "integer not null default 1" }],
106
- columns: { ...restColumns, sequence: version ?? DEFAULT_VERSION_COLUMN },
110
+ columns: { ...restColumns, sequence: version },
107
111
  constants: { [physical.entity]: "" },
108
112
  indexed: headIndexedColumns(physical),
109
113
  key: "number",
@@ -120,35 +124,27 @@ var documentMigrations = (options) => {
120
124
  if (tableMigration === undefined) {
121
125
  throw new Error("projectionMigrations answered with no table migration to append the listing index to");
122
126
  }
123
- const listingIndex = `create index if not exists ${quotedName(`${table}_${physical.entity}_${physical.issueDate}_idx`)} on ${quotedName(table)} (${quotedName(physical.entity)}, ${quotedName(physical.issueDate)})`;
127
+ const listingIndex = `create index if not exists ${quoted(`${table}_${physical.entity}_${physical.issueDate}_idx`)} on ${quoted(table)} (${quoted(physical.entity)}, ${quoted(physical.issueDate)})`;
124
128
  return [
125
129
  { ...tableMigration, statements: [...tableMigration.statements, listingIndex] },
126
130
  ...rest,
127
131
  ...revisionsMigrations(options, physical)
128
132
  ];
129
133
  };
130
- var TABLE_TYPE_OF = { decimal: "numeric" };
131
134
  var documentTable = (options = {}) => {
132
135
  const physical = physicalColumnsOf(options.columns);
133
- const {
134
- entity: _entity,
135
- heads: _heads,
136
- id,
137
- revisionKind: _revisionKind,
138
- total: _total,
139
- version,
140
- ...restColumns
141
- } = options.columns ?? {};
136
+ const { rest, version } = splitColumns(options.columns);
137
+ const { id, ...restColumns } = rest;
142
138
  const named = Object.fromEntries(Object.entries(restColumns).map(([column, held]) => [column, nameOf(held, column)]));
143
139
  return entityTable({
144
- columns: { ...named, version: nameOf(version, DEFAULT_VERSION_COLUMN) },
140
+ columns: { ...named, version },
145
141
  constants: [physical.entity],
146
142
  extra: {
147
143
  ...Object.fromEntries(HEAD_FIELDS.map((field) => [
148
144
  physical[field],
149
145
  {
150
146
  nullable: field !== "status",
151
- type: TABLE_TYPE_OF[headFields[field]] ?? "text"
147
+ type: isNumeric(field) ? "numeric" : "text"
152
148
  }
153
149
  ])),
154
150
  hash: "text",
@@ -167,9 +163,11 @@ export {
167
163
  DEFAULT_REVISION_KIND_COLUMN,
168
164
  ENTITY_PLACEHOLDERS as DOCUMENT_MIGRATION_PLACEHOLDERS,
169
165
  HEAD_FIELDS,
166
+ REVISION_KINDS,
170
167
  appendOnlyTables,
171
168
  documentMigrations,
172
169
  documentRoleStatements,
173
170
  documentTable,
174
- physicalColumnsOf
171
+ physicalColumnsOf,
172
+ splitColumns
175
173
  };
@@ -1,2 +1 @@
1
- /** sha256 hex over the canonical JSON of `payload` — no whitespace, keys sorted recursively. */
2
1
  export declare const hashOf: (payload: unknown) => Promise<string>;
@@ -1,2 +1 @@
1
- /** sha256 hex over the canonical JSON of `payload` — no whitespace, keys sorted recursively. */
2
1
  export declare const hashOf: (payload: unknown) => Promise<string>;
@@ -0,0 +1,52 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ function __accessProp(key) {
6
+ return this[key];
7
+ }
8
+ var __toCommonJS = (from) => {
9
+ var entry = (__moduleCache ??= new WeakMap).get(from), desc;
10
+ if (entry)
11
+ return entry;
12
+ entry = __defProp({}, "__esModule", { value: true });
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (var key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(entry, key))
16
+ __defProp(entry, key, {
17
+ get: __accessProp.bind(from, key),
18
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
19
+ });
20
+ }
21
+ __moduleCache.set(from, entry);
22
+ return entry;
23
+ };
24
+ var __moduleCache;
25
+ var __returnValue = (v) => v;
26
+ function __exportSetter(name, newValue) {
27
+ this[name] = __returnValue.bind(null, newValue);
28
+ }
29
+ var __export = (target, all) => {
30
+ for (var name in all)
31
+ __defProp(target, name, {
32
+ get: all[name],
33
+ enumerable: true,
34
+ configurable: true,
35
+ set: __exportSetter.bind(all, name)
36
+ });
37
+ };
38
+
39
+ // src/store/number-for.ts
40
+ var exports_number_for = {};
41
+ __export(exports_number_for, {
42
+ numberFor: () => numberFor
43
+ });
44
+ module.exports = __toCommonJS(exports_number_for);
45
+ var numberFor = (options) => async (ctx, key) => {
46
+ const { handle, tenantId } = options.scope(ctx);
47
+ const issued = await options.counter.next(handle, {
48
+ [options.seam.tenantKey]: tenantId,
49
+ key
50
+ });
51
+ return { number: issued.number };
52
+ };
@@ -0,0 +1,11 @@
1
+ import type { Counter, DrizzleHandle, SessionSeam } from '@geonosis/db';
2
+ export declare const numberFor: <Ctx, Key extends string, Handle extends DrizzleHandle>(options: {
3
+ counter: Counter<Key, Handle>;
4
+ scope: (ctx: Ctx) => {
5
+ handle: Handle;
6
+ tenantId: string;
7
+ };
8
+ seam: SessionSeam<Key, Handle>;
9
+ }) => (ctx: Ctx, key: string) => Promise<{
10
+ number: number;
11
+ }>;
@@ -0,0 +1,11 @@
1
+ import type { Counter, DrizzleHandle, SessionSeam } from '@geonosis/db';
2
+ export declare const numberFor: <Ctx, Key extends string, Handle extends DrizzleHandle>(options: {
3
+ counter: Counter<Key, Handle>;
4
+ scope: (ctx: Ctx) => {
5
+ handle: Handle;
6
+ tenantId: string;
7
+ };
8
+ seam: SessionSeam<Key, Handle>;
9
+ }) => (ctx: Ctx, key: string) => Promise<{
10
+ number: number;
11
+ }>;
@@ -0,0 +1,12 @@
1
+ // src/store/number-for.ts
2
+ var numberFor = (options) => async (ctx, key) => {
3
+ const { handle, tenantId } = options.scope(ctx);
4
+ const issued = await options.counter.next(handle, {
5
+ [options.seam.tenantKey]: tenantId,
6
+ key
7
+ });
8
+ return { number: issued.number };
9
+ };
10
+ export {
11
+ numberFor
12
+ };