@coffre/cli 0.1.1 → 0.1.3

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.
@@ -0,0 +1,87 @@
1
+ import { G as sql, l as relations } from "./relations-CJCGPRst.js";
2
+ //#region ../db/dist/commits-BuW-NL3n.js
3
+ const pending = /* @__PURE__ */ new WeakMap();
4
+ /** `db`, its transactions tracked for `afterCommit`. */
5
+ function trackCommits(db, outer = null) {
6
+ const run = db.transaction.bind(db);
7
+ const transaction = async (work, ...rest) => {
8
+ const list = [];
9
+ const result = await run((tx) => {
10
+ pending.set(tx, list);
11
+ return work(trackCommits(tx, list));
12
+ }, ...rest);
13
+ if (outer !== null) outer.push(...list);
14
+ else for (const then of list) then();
15
+ return result;
16
+ };
17
+ db.transaction = transaction;
18
+ return db;
19
+ }
20
+ //#endregion
21
+ //#region ../db/dist/relations-DqgxtlKu.js
22
+ /**
23
+ * What both schemas share beyond their columns: the relations and the
24
+ * one generated column.
25
+ *
26
+ * Relations are for Drizzle's relational queries (`db.query.syncs
27
+ * .findMany({ with })`), which read a row and what hangs off it in one
28
+ * statement on every dialect. They add no constraints; the foreign keys in
29
+ * each schema do that. Each schema calls this with its own tables, so a
30
+ * relational query on SQLite joins SQLite tables.
31
+ */
32
+ function relationsOf(t) {
33
+ return {
34
+ environmentsRelations: relations(t.environments, ({ one }) => ({ project: one(t.projects, {
35
+ fields: [t.environments.projectId],
36
+ references: [t.projects.id]
37
+ }) })),
38
+ secretsRelations: relations(t.secrets, ({ one }) => ({
39
+ project: one(t.projects, {
40
+ fields: [t.secrets.projectId],
41
+ references: [t.projects.id]
42
+ }),
43
+ environment: one(t.environments, {
44
+ fields: [t.secrets.environmentId],
45
+ references: [t.environments.id]
46
+ })
47
+ })),
48
+ syncsRelations: relations(t.syncs, ({ one, many }) => ({
49
+ project: one(t.projects, {
50
+ fields: [t.syncs.projectId],
51
+ references: [t.projects.id]
52
+ }),
53
+ environment: one(t.environments, {
54
+ fields: [t.syncs.environmentId],
55
+ references: [t.environments.id]
56
+ }),
57
+ credential: one(t.secrets, {
58
+ fields: [t.syncs.credentialSecretId],
59
+ references: [t.secrets.id]
60
+ }),
61
+ keys: many(t.syncKeys)
62
+ })),
63
+ syncKeysRelations: relations(t.syncKeys, ({ one }) => ({ sync: one(t.syncs, {
64
+ fields: [t.syncKeys.syncId],
65
+ references: [t.syncs.id]
66
+ }) }))
67
+ };
68
+ }
69
+ /**
70
+ * `identities.active_subject`: the subject while the account is bound, null
71
+ * once revoked. A unique index on (provider, issuer_hash, active_subject)
72
+ * binds an account to one person at a time. Plain column names, so the
73
+ * expression reads the same on both databases.
74
+ */
75
+ const ACTIVE_SUBJECT = sql`CASE WHEN revoked_at IS NULL THEN subject END`;
76
+ //#endregion
77
+ //#region ../db/dist/portable.js
78
+ /** Some of a schema's tables, read as their Postgres twins. */
79
+ function asPostgres(tables) {
80
+ return tables;
81
+ }
82
+ /** A SQLite database, read as a Postgres one. */
83
+ function asPostgresDatabase(db) {
84
+ return trackCommits(db);
85
+ }
86
+ //#endregion
87
+ export { trackCommits as a, relationsOf as i, asPostgresDatabase as n, ACTIVE_SUBJECT as r, asPostgres as t };