@hot-updater/server 1.2.0-rc.6 → 1.2.0-rc.61
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/dist/adapters/drizzle.cjs +8 -4
- package/dist/adapters/drizzle.d.cts +3 -2
- package/dist/adapters/drizzle.d.mts +3 -2
- package/dist/adapters/drizzle.mjs +8 -4
- package/dist/adapters/drizzleExecutor.cjs +4 -2
- package/dist/adapters/drizzleExecutor.mjs +4 -2
- package/dist/adapters/kysely.cjs +3 -2
- package/dist/adapters/kysely.mjs +3 -2
- package/dist/adapters/mongodb.cjs +1 -1
- package/dist/adapters/mongodb.mjs +1 -1
- package/dist/adapters/mongodbAdapter.cjs +15 -3
- package/dist/adapters/mongodbAdapter.mjs +15 -3
- package/dist/adapters/prisma.cjs +9 -13
- package/dist/adapters/prisma.mjs +10 -14
- package/dist/adapters/prismaExecutor.cjs +25 -20
- package/dist/adapters/prismaExecutor.mjs +25 -20
- package/dist/core/api.cjs +2 -0
- package/dist/core/api.d.cts +48 -1
- package/dist/core/api.d.mts +48 -1
- package/dist/core/api.mjs +2 -0
- package/dist/core/iosDevices.cjs +306 -0
- package/dist/core/iosDevices.mjs +303 -0
- package/dist/core/labels.cjs +325 -0
- package/dist/core/labels.mjs +318 -0
- package/dist/core/nativeBuildDestinations.cjs +13 -0
- package/dist/core/nativeBuildDestinations.mjs +13 -0
- package/dist/core/nativeBuilds.cjs +291 -22
- package/dist/core/nativeBuilds.mjs +291 -23
- package/dist/core/operations.cjs +45 -24
- package/dist/core/operations.mjs +48 -27
- package/dist/core/reads.cjs +69 -5
- package/dist/core/reads.mjs +70 -6
- package/dist/core/releases.cjs +138 -38
- package/dist/core/releases.mjs +138 -41
- package/dist/core/writes.cjs +14 -2
- package/dist/core/writes.mjs +14 -2
- package/dist/createHotUpdaterCore.d.cts +2 -4
- package/dist/createHotUpdaterCore.d.mts +2 -4
- package/dist/db/engineDrizzleSchema.cjs +21 -5
- package/dist/db/engineDrizzleSchema.mjs +21 -6
- package/dist/db/enginePrismaSchema.cjs +6 -14
- package/dist/db/enginePrismaSchema.mjs +7 -15
- package/dist/db/releaseCatalog.cjs +13 -4
- package/dist/db/releaseCatalog.mjs +12 -5
- package/dist/handler.cjs +2 -1
- package/dist/handler.mjs +2 -1
- package/dist/handlerAdminRoutes.cjs +288 -16
- package/dist/handlerAdminRoutes.mjs +289 -17
- package/dist/handlerReleaseCatalogRoutes.cjs +43 -27
- package/dist/handlerReleaseCatalogRoutes.mjs +43 -27
- package/dist/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/package.json +7 -14
|
@@ -7,8 +7,9 @@ let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
|
7
7
|
/**
|
|
8
8
|
* Hot Updater's database on a Drizzle instance: the storage engine through the
|
|
9
9
|
* shared SQL core, fenced by the schema settings. `db generate` writes the
|
|
10
|
-
* Drizzle schema drizzle-kit applies; `db migrate` then
|
|
11
|
-
*
|
|
10
|
+
* Drizzle schema drizzle-kit applies; `db migrate` then checks the tables,
|
|
11
|
+
* sets the PostgreSQL collations drizzle-kit cannot read back, and writes the
|
|
12
|
+
* settings rows the fence checks.
|
|
12
13
|
*/
|
|
13
14
|
const drizzleAdapter = (config) => {
|
|
14
15
|
const provider = require_sqlProviders.checkSqlProvider("drizzleAdapter", config.provider);
|
|
@@ -26,11 +27,14 @@ const drizzleAdapter = (config) => {
|
|
|
26
27
|
path: "hot-updater-schema.ts"
|
|
27
28
|
};
|
|
28
29
|
}),
|
|
29
|
-
createMigrator: ({ settings } = _hot_updater_plugin_core.coreTarget) => (0, _hot_updater_plugin_core.createSettingsMigrator)({
|
|
30
|
+
createMigrator: ({ schema, settings, ordered } = _hot_updater_plugin_core.coreTarget) => (0, _hot_updater_plugin_core.createSettingsMigrator)({
|
|
30
31
|
adapterName: "drizzle",
|
|
31
32
|
executor,
|
|
33
|
+
schema,
|
|
32
34
|
settings,
|
|
33
|
-
|
|
35
|
+
ordered,
|
|
36
|
+
applyTables: provider === "mysql" ? "`npx drizzle-kit generate` and `npx drizzle-kit migrate`" : "`npx drizzle-kit push`",
|
|
37
|
+
collate: () => provider === "postgresql"
|
|
34
38
|
})
|
|
35
39
|
};
|
|
36
40
|
};
|
|
@@ -10,8 +10,9 @@ interface DrizzleConfig {
|
|
|
10
10
|
/**
|
|
11
11
|
* Hot Updater's database on a Drizzle instance: the storage engine through the
|
|
12
12
|
* shared SQL core, fenced by the schema settings. `db generate` writes the
|
|
13
|
-
* Drizzle schema drizzle-kit applies; `db migrate` then
|
|
14
|
-
*
|
|
13
|
+
* Drizzle schema drizzle-kit applies; `db migrate` then checks the tables,
|
|
14
|
+
* sets the PostgreSQL collations drizzle-kit cannot read back, and writes the
|
|
15
|
+
* settings rows the fence checks.
|
|
15
16
|
*/
|
|
16
17
|
declare const drizzleAdapter: (config: DrizzleConfig) => ToolingDatabase;
|
|
17
18
|
//#endregion
|
|
@@ -10,8 +10,9 @@ interface DrizzleConfig {
|
|
|
10
10
|
/**
|
|
11
11
|
* Hot Updater's database on a Drizzle instance: the storage engine through the
|
|
12
12
|
* shared SQL core, fenced by the schema settings. `db generate` writes the
|
|
13
|
-
* Drizzle schema drizzle-kit applies; `db migrate` then
|
|
14
|
-
*
|
|
13
|
+
* Drizzle schema drizzle-kit applies; `db migrate` then checks the tables,
|
|
14
|
+
* sets the PostgreSQL collations drizzle-kit cannot read back, and writes the
|
|
15
|
+
* settings rows the fence checks.
|
|
15
16
|
*/
|
|
16
17
|
declare const drizzleAdapter: (config: DrizzleConfig) => ToolingDatabase;
|
|
17
18
|
//#endregion
|
|
@@ -6,8 +6,9 @@ import { coreSettings, coreTarget, createEngineDatabase, createSettingsMigrator,
|
|
|
6
6
|
/**
|
|
7
7
|
* Hot Updater's database on a Drizzle instance: the storage engine through the
|
|
8
8
|
* shared SQL core, fenced by the schema settings. `db generate` writes the
|
|
9
|
-
* Drizzle schema drizzle-kit applies; `db migrate` then
|
|
10
|
-
*
|
|
9
|
+
* Drizzle schema drizzle-kit applies; `db migrate` then checks the tables,
|
|
10
|
+
* sets the PostgreSQL collations drizzle-kit cannot read back, and writes the
|
|
11
|
+
* settings rows the fence checks.
|
|
11
12
|
*/
|
|
12
13
|
const drizzleAdapter = (config) => {
|
|
13
14
|
const provider = checkSqlProvider("drizzleAdapter", config.provider);
|
|
@@ -25,11 +26,14 @@ const drizzleAdapter = (config) => {
|
|
|
25
26
|
path: "hot-updater-schema.ts"
|
|
26
27
|
};
|
|
27
28
|
}),
|
|
28
|
-
createMigrator: ({ settings } = coreTarget) => createSettingsMigrator({
|
|
29
|
+
createMigrator: ({ schema, settings, ordered } = coreTarget) => createSettingsMigrator({
|
|
29
30
|
adapterName: "drizzle",
|
|
30
31
|
executor,
|
|
32
|
+
schema,
|
|
31
33
|
settings,
|
|
32
|
-
|
|
34
|
+
ordered,
|
|
35
|
+
applyTables: provider === "mysql" ? "`npx drizzle-kit generate` and `npx drizzle-kit migrate`" : "`npx drizzle-kit push`",
|
|
36
|
+
collate: () => provider === "postgresql"
|
|
33
37
|
})
|
|
34
38
|
};
|
|
35
39
|
};
|
|
@@ -47,14 +47,16 @@ const changesOf = (result) => {
|
|
|
47
47
|
* The SQL core's executor over a Drizzle database, or a function that
|
|
48
48
|
* returns one. Async drivers run Drizzle's transactions; sync SQLite drivers
|
|
49
49
|
* run one statement at a time, beginning transactions with BEGIN IMMEDIATE.
|
|
50
|
-
* First use checks that the driver can run a transaction at all.
|
|
50
|
+
* First use checks that the driver can run a transaction at all. Under
|
|
51
|
+
* `withReplicas`, it runs on `$primary`.
|
|
51
52
|
*/
|
|
52
53
|
const drizzleExecutor = (source, dialect) => {
|
|
53
54
|
const isSync = (runner) => dialect === "sqlite" && runner.resultKind === "sync";
|
|
54
55
|
let ready;
|
|
55
56
|
const resolve = () => {
|
|
56
57
|
ready ??= (async () => {
|
|
57
|
-
const
|
|
58
|
+
const database = await (typeof source === "function" ? source() : source);
|
|
59
|
+
const runner = database.$primary ?? database;
|
|
58
60
|
if (isSync(runner)) return runner;
|
|
59
61
|
let started = false;
|
|
60
62
|
try {
|
|
@@ -47,14 +47,16 @@ const changesOf = (result) => {
|
|
|
47
47
|
* The SQL core's executor over a Drizzle database, or a function that
|
|
48
48
|
* returns one. Async drivers run Drizzle's transactions; sync SQLite drivers
|
|
49
49
|
* run one statement at a time, beginning transactions with BEGIN IMMEDIATE.
|
|
50
|
-
* First use checks that the driver can run a transaction at all.
|
|
50
|
+
* First use checks that the driver can run a transaction at all. Under
|
|
51
|
+
* `withReplicas`, it runs on `$primary`.
|
|
51
52
|
*/
|
|
52
53
|
const drizzleExecutor = (source, dialect) => {
|
|
53
54
|
const isSync = (runner) => dialect === "sqlite" && runner.resultKind === "sync";
|
|
54
55
|
let ready;
|
|
55
56
|
const resolve = () => {
|
|
56
57
|
ready ??= (async () => {
|
|
57
|
-
const
|
|
58
|
+
const database = await (typeof source === "function" ? source() : source);
|
|
59
|
+
const runner = database.$primary ?? database;
|
|
58
60
|
if (isSync(runner)) return runner;
|
|
59
61
|
let started = false;
|
|
60
62
|
try {
|
package/dist/adapters/kysely.cjs
CHANGED
|
@@ -17,11 +17,12 @@ const kyselyAdapter = (config) => {
|
|
|
17
17
|
adapter: (0, _hot_updater_plugin_core.createSqlAdapter)({ executor })
|
|
18
18
|
}),
|
|
19
19
|
provider,
|
|
20
|
-
createMigrator: ({ schema, settings } = _hot_updater_plugin_core.coreTarget) => (0, _hot_updater_plugin_core.createEngineSqlMigrator)({
|
|
20
|
+
createMigrator: ({ schema, settings, ordered } = _hot_updater_plugin_core.coreTarget) => (0, _hot_updater_plugin_core.createEngineSqlMigrator)({
|
|
21
21
|
adapterName: "kysely",
|
|
22
22
|
executor,
|
|
23
23
|
schema,
|
|
24
|
-
settings
|
|
24
|
+
settings,
|
|
25
|
+
ordered
|
|
25
26
|
})
|
|
26
27
|
};
|
|
27
28
|
};
|
package/dist/adapters/kysely.mjs
CHANGED
|
@@ -16,11 +16,12 @@ const kyselyAdapter = (config) => {
|
|
|
16
16
|
adapter: createSqlAdapter({ executor })
|
|
17
17
|
}),
|
|
18
18
|
provider,
|
|
19
|
-
createMigrator: ({ schema, settings } = coreTarget) => createEngineSqlMigrator({
|
|
19
|
+
createMigrator: ({ schema, settings, ordered } = coreTarget) => createEngineSqlMigrator({
|
|
20
20
|
adapterName: "kysely",
|
|
21
21
|
executor,
|
|
22
22
|
schema,
|
|
23
|
-
settings
|
|
23
|
+
settings,
|
|
24
|
+
ordered
|
|
24
25
|
})
|
|
25
26
|
};
|
|
26
27
|
};
|
|
@@ -4,7 +4,7 @@ let _hot_updater_plugin_core = require("@hot-updater/plugin-core");
|
|
|
4
4
|
//#region src/adapters/mongodb.ts
|
|
5
5
|
/** Settings rows by their `key` field: the engine's rows and a v0 database's alike. */
|
|
6
6
|
const readSettings = (client) => async () => {
|
|
7
|
-
const rows = await client.db().collection(_hot_updater_plugin_core.SETTINGS_TABLE.name).find({ key: { $type: "string" } }).toArray();
|
|
7
|
+
const rows = await client.db().collection(_hot_updater_plugin_core.SETTINGS_TABLE.name).find({ key: { $type: "string" } }, { readPreference: "primary" }).toArray();
|
|
8
8
|
return new Map(rows.map((row) => [String(row.key), row.value]));
|
|
9
9
|
};
|
|
10
10
|
/**
|
|
@@ -3,7 +3,7 @@ import { SETTINGS_TABLE, createEngineDatabase } from "@hot-updater/plugin-core";
|
|
|
3
3
|
//#region src/adapters/mongodb.ts
|
|
4
4
|
/** Settings rows by their `key` field: the engine's rows and a v0 database's alike. */
|
|
5
5
|
const readSettings = (client) => async () => {
|
|
6
|
-
const rows = await client.db().collection(SETTINGS_TABLE.name).find({ key: { $type: "string" } }).toArray();
|
|
6
|
+
const rows = await client.db().collection(SETTINGS_TABLE.name).find({ key: { $type: "string" } }, { readPreference: "primary" }).toArray();
|
|
7
7
|
return new Map(rows.map((row) => [String(row.key), row.value]));
|
|
8
8
|
};
|
|
9
9
|
/**
|
|
@@ -51,6 +51,11 @@ const indexDescription = (table, index) => {
|
|
|
51
51
|
};
|
|
52
52
|
const mongoError = (error) => error instanceof mongodb.MongoError ? error : void 0;
|
|
53
53
|
/**
|
|
54
|
+
* Every read goes to the primary, whatever the client's read preference: a
|
|
55
|
+
* secondary can lag, and `get` and `query` promise every committed write.
|
|
56
|
+
*/
|
|
57
|
+
const PRIMARY = { readPreference: "primary" };
|
|
58
|
+
/**
|
|
54
59
|
* The storage engine's adapter over MongoDB: one collection per table, the
|
|
55
60
|
* key as `_id`, and indexes as declared, with multi-valued fields as multikey
|
|
56
61
|
* indexes. A write runs in one transaction. Guards are conditional updates,
|
|
@@ -115,7 +120,7 @@ const createMongoAdapter = (options) => {
|
|
|
115
120
|
async get(table, keys) {
|
|
116
121
|
if (keys.length === 0) return [];
|
|
117
122
|
const ids = keys.map((key) => idOf(table, key));
|
|
118
|
-
const documents = await collection(table).find(byId({ $in: ids })).toArray();
|
|
123
|
+
const documents = await collection(table).find(byId({ $in: ids }), PRIMARY).toArray();
|
|
119
124
|
const found = new Map(documents.map((document) => [JSON.stringify(document._id), document]));
|
|
120
125
|
return ids.map((id) => {
|
|
121
126
|
const document = found.get(JSON.stringify(id));
|
|
@@ -131,6 +136,7 @@ const createMongoAdapter = (options) => {
|
|
|
131
136
|
...Object.fromEntries(index.eq.map((column, at) => [column, request.eq[at]])),
|
|
132
137
|
...bounds.length > 0 && { $and: bounds }
|
|
133
138
|
}, {
|
|
139
|
+
...PRIMARY,
|
|
134
140
|
sort: Object.fromEntries(columns.map((column) => [column, direction])),
|
|
135
141
|
limit: request.limit,
|
|
136
142
|
...options.batchSize && { batchSize: options.batchSize }
|
|
@@ -181,8 +187,14 @@ const createMongoAdapter = (options) => {
|
|
|
181
187
|
if (mongoError(error)?.code !== 48) throw error;
|
|
182
188
|
});
|
|
183
189
|
if (table.retention) await collection(table).createIndexes([TTL]);
|
|
184
|
-
|
|
185
|
-
|
|
190
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
191
|
+
for (const index of table.indexes) {
|
|
192
|
+
const description = indexDescription(table, index);
|
|
193
|
+
const keys = JSON.stringify([description.key, description.unique]);
|
|
194
|
+
if (!indexes.has(keys)) indexes.set(keys, description);
|
|
195
|
+
}
|
|
196
|
+
if (indexes.size === 0) continue;
|
|
197
|
+
await collection(table).createIndexes([...indexes.values()]);
|
|
186
198
|
}
|
|
187
199
|
} }
|
|
188
200
|
};
|
|
@@ -51,6 +51,11 @@ const indexDescription = (table, index) => {
|
|
|
51
51
|
};
|
|
52
52
|
const mongoError = (error) => error instanceof MongoError ? error : void 0;
|
|
53
53
|
/**
|
|
54
|
+
* Every read goes to the primary, whatever the client's read preference: a
|
|
55
|
+
* secondary can lag, and `get` and `query` promise every committed write.
|
|
56
|
+
*/
|
|
57
|
+
const PRIMARY = { readPreference: "primary" };
|
|
58
|
+
/**
|
|
54
59
|
* The storage engine's adapter over MongoDB: one collection per table, the
|
|
55
60
|
* key as `_id`, and indexes as declared, with multi-valued fields as multikey
|
|
56
61
|
* indexes. A write runs in one transaction. Guards are conditional updates,
|
|
@@ -115,7 +120,7 @@ const createMongoAdapter = (options) => {
|
|
|
115
120
|
async get(table, keys) {
|
|
116
121
|
if (keys.length === 0) return [];
|
|
117
122
|
const ids = keys.map((key) => idOf(table, key));
|
|
118
|
-
const documents = await collection(table).find(byId({ $in: ids })).toArray();
|
|
123
|
+
const documents = await collection(table).find(byId({ $in: ids }), PRIMARY).toArray();
|
|
119
124
|
const found = new Map(documents.map((document) => [JSON.stringify(document._id), document]));
|
|
120
125
|
return ids.map((id) => {
|
|
121
126
|
const document = found.get(JSON.stringify(id));
|
|
@@ -131,6 +136,7 @@ const createMongoAdapter = (options) => {
|
|
|
131
136
|
...Object.fromEntries(index.eq.map((column, at) => [column, request.eq[at]])),
|
|
132
137
|
...bounds.length > 0 && { $and: bounds }
|
|
133
138
|
}, {
|
|
139
|
+
...PRIMARY,
|
|
134
140
|
sort: Object.fromEntries(columns.map((column) => [column, direction])),
|
|
135
141
|
limit: request.limit,
|
|
136
142
|
...options.batchSize && { batchSize: options.batchSize }
|
|
@@ -181,8 +187,14 @@ const createMongoAdapter = (options) => {
|
|
|
181
187
|
if (mongoError(error)?.code !== 48) throw error;
|
|
182
188
|
});
|
|
183
189
|
if (table.retention) await collection(table).createIndexes([TTL]);
|
|
184
|
-
|
|
185
|
-
|
|
190
|
+
const indexes = /* @__PURE__ */ new Map();
|
|
191
|
+
for (const index of table.indexes) {
|
|
192
|
+
const description = indexDescription(table, index);
|
|
193
|
+
const keys = JSON.stringify([description.key, description.unique]);
|
|
194
|
+
if (!indexes.has(keys)) indexes.set(keys, description);
|
|
195
|
+
}
|
|
196
|
+
if (indexes.size === 0) continue;
|
|
197
|
+
await collection(table).createIndexes([...indexes.values()]);
|
|
186
198
|
}
|
|
187
199
|
} }
|
|
188
200
|
};
|
package/dist/adapters/prisma.cjs
CHANGED
|
@@ -26,19 +26,15 @@ const prismaAdapter = (config) => {
|
|
|
26
26
|
path: "prisma/schema.prisma"
|
|
27
27
|
};
|
|
28
28
|
}),
|
|
29
|
-
createMigrator: ({ schema, settings } = _hot_updater_plugin_core.coreTarget) => {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
statements: collations
|
|
39
|
-
} }
|
|
40
|
-
});
|
|
41
|
-
}
|
|
29
|
+
createMigrator: ({ schema, settings, ordered } = _hot_updater_plugin_core.coreTarget) => (0, _hot_updater_plugin_core.createSettingsMigrator)({
|
|
30
|
+
adapterName: "prisma",
|
|
31
|
+
executor,
|
|
32
|
+
schema,
|
|
33
|
+
settings,
|
|
34
|
+
ordered,
|
|
35
|
+
applyTables: "`npx prisma db push`",
|
|
36
|
+
collate: (column) => require_enginePrismaSchema.prismaCollates(provider, column)
|
|
37
|
+
})
|
|
42
38
|
};
|
|
43
39
|
};
|
|
44
40
|
//#endregion
|
package/dist/adapters/prisma.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { checkSqlProvider } from "./sqlProviders.mjs";
|
|
2
|
-
import { generatePrismaEngineSchema,
|
|
2
|
+
import { generatePrismaEngineSchema, prismaCollates } from "../db/enginePrismaSchema.mjs";
|
|
3
3
|
import { prismaExecutor } from "./prismaExecutor.mjs";
|
|
4
4
|
import { coreSettings, coreTarget, createEngineDatabase, createSettingsMigrator, createSqlAdapter } from "@hot-updater/plugin-core";
|
|
5
5
|
//#region src/adapters/prisma.ts
|
|
@@ -25,19 +25,15 @@ const prismaAdapter = (config) => {
|
|
|
25
25
|
path: "prisma/schema.prisma"
|
|
26
26
|
};
|
|
27
27
|
}),
|
|
28
|
-
createMigrator: ({ schema, settings } = coreTarget) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
statements: collations
|
|
38
|
-
} }
|
|
39
|
-
});
|
|
40
|
-
}
|
|
28
|
+
createMigrator: ({ schema, settings, ordered } = coreTarget) => createSettingsMigrator({
|
|
29
|
+
adapterName: "prisma",
|
|
30
|
+
executor,
|
|
31
|
+
schema,
|
|
32
|
+
settings,
|
|
33
|
+
ordered,
|
|
34
|
+
applyTables: "`npx prisma db push`",
|
|
35
|
+
collate: (column) => prismaCollates(provider, column)
|
|
36
|
+
})
|
|
41
37
|
};
|
|
42
38
|
};
|
|
43
39
|
//#endregion
|
|
@@ -36,28 +36,33 @@ const writeLock = (dialect) => `UPDATE ${(0, _hot_updater_plugin_core.quoteSql)(
|
|
|
36
36
|
/**
|
|
37
37
|
* The SQL core's executor over a Prisma client, through raw queries and
|
|
38
38
|
* interactive transactions. A SQLite transaction takes the write lock with
|
|
39
|
-
* its first statement, as BEGIN IMMEDIATE would.
|
|
39
|
+
* its first statement, as BEGIN IMMEDIATE would. Under a read-replica
|
|
40
|
+
* extension, every statement runs on `$primary()`: the engine's reads must
|
|
41
|
+
* see every committed write, which a lagging replica may not have.
|
|
40
42
|
*/
|
|
41
|
-
const prismaExecutor = (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
const prismaExecutor = (root, dialect) => {
|
|
44
|
+
const client = typeof root.$primary === "function" ? root.$primary() : root;
|
|
45
|
+
return {
|
|
46
|
+
dialect,
|
|
47
|
+
...over(dialect, client),
|
|
48
|
+
async transaction(fn) {
|
|
49
|
+
try {
|
|
50
|
+
return await client.$transaction(async (tx) => {
|
|
51
|
+
const connection = over(dialect, tx);
|
|
52
|
+
if (dialect === "sqlite") await connection.execute({
|
|
53
|
+
sql: writeLock(dialect),
|
|
54
|
+
params: []
|
|
55
|
+
});
|
|
56
|
+
return fn(connection);
|
|
57
|
+
}, {
|
|
58
|
+
maxWait: 1e4,
|
|
59
|
+
timeout: 3e4
|
|
51
60
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
timeout: 3e4
|
|
56
|
-
});
|
|
57
|
-
} catch (error) {
|
|
58
|
-
throw withDatabaseCode(dialect, error);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw withDatabaseCode(dialect, error);
|
|
63
|
+
}
|
|
59
64
|
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
65
|
+
};
|
|
66
|
+
};
|
|
62
67
|
//#endregion
|
|
63
68
|
exports.prismaExecutor = prismaExecutor;
|
|
@@ -36,28 +36,33 @@ const writeLock = (dialect) => `UPDATE ${quoteSql(dialect, SETTINGS_TABLE.name)}
|
|
|
36
36
|
/**
|
|
37
37
|
* The SQL core's executor over a Prisma client, through raw queries and
|
|
38
38
|
* interactive transactions. A SQLite transaction takes the write lock with
|
|
39
|
-
* its first statement, as BEGIN IMMEDIATE would.
|
|
39
|
+
* its first statement, as BEGIN IMMEDIATE would. Under a read-replica
|
|
40
|
+
* extension, every statement runs on `$primary()`: the engine's reads must
|
|
41
|
+
* see every committed write, which a lagging replica may not have.
|
|
40
42
|
*/
|
|
41
|
-
const prismaExecutor = (
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
43
|
+
const prismaExecutor = (root, dialect) => {
|
|
44
|
+
const client = typeof root.$primary === "function" ? root.$primary() : root;
|
|
45
|
+
return {
|
|
46
|
+
dialect,
|
|
47
|
+
...over(dialect, client),
|
|
48
|
+
async transaction(fn) {
|
|
49
|
+
try {
|
|
50
|
+
return await client.$transaction(async (tx) => {
|
|
51
|
+
const connection = over(dialect, tx);
|
|
52
|
+
if (dialect === "sqlite") await connection.execute({
|
|
53
|
+
sql: writeLock(dialect),
|
|
54
|
+
params: []
|
|
55
|
+
});
|
|
56
|
+
return fn(connection);
|
|
57
|
+
}, {
|
|
58
|
+
maxWait: 1e4,
|
|
59
|
+
timeout: 3e4
|
|
51
60
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
timeout: 3e4
|
|
56
|
-
});
|
|
57
|
-
} catch (error) {
|
|
58
|
-
throw withDatabaseCode(dialect, error);
|
|
61
|
+
} catch (error) {
|
|
62
|
+
throw withDatabaseCode(dialect, error);
|
|
63
|
+
}
|
|
59
64
|
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
65
|
+
};
|
|
66
|
+
};
|
|
62
67
|
//#endregion
|
|
63
68
|
export { prismaExecutor };
|
package/dist/core/api.cjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const require_reads = require("./reads.cjs");
|
|
2
|
+
const require_iosDevices = require("./iosDevices.cjs");
|
|
2
3
|
const require_nativeBuilds = require("./nativeBuilds.cjs");
|
|
3
4
|
const require_operations = require("./operations.cjs");
|
|
4
5
|
//#region src/core/api.ts
|
|
@@ -43,6 +44,7 @@ const createCoreApi = (db, storage, options = {}) => {
|
|
|
43
44
|
...reads,
|
|
44
45
|
...require_operations.createCoreOperations(purgingCachedRoutes(db, options.onCachedRoutesChange), options),
|
|
45
46
|
...require_nativeBuilds.createNativeBuildApi(db, options),
|
|
47
|
+
...require_iosDevices.createIosDeviceApi(db, options),
|
|
46
48
|
/** One read, which checks the schema settings first. */
|
|
47
49
|
ready: async () => {
|
|
48
50
|
await reads.listReleaseCatalogs({ limit: 1 });
|
package/dist/core/api.d.cts
CHANGED
|
@@ -9,11 +9,41 @@ interface CoreApiOptions {
|
|
|
9
9
|
declare const createCoreApi: (db: CoreDatabase, storage: CoreStorage, options?: CoreApiOptions) => {
|
|
10
10
|
/** One read, which checks the schema settings first. */
|
|
11
11
|
ready: () => Promise<void>;
|
|
12
|
+
listIosDevices: (input: import("@hot-updater/plugin-core").KeysetInput & {
|
|
13
|
+
readonly status?: import("@hot-updater/plugin-core").IosDeviceStatus;
|
|
14
|
+
}) => Promise<import("@hot-updater/plugin-core").IosDeviceRow[]>;
|
|
15
|
+
findIosDevice: (udid: string) => Promise<import("@hot-updater/plugin-core").IosDeviceRow | null>;
|
|
16
|
+
requestIosDevice: (input: {
|
|
17
|
+
readonly udid: string;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly requestedBy: string | null;
|
|
20
|
+
}) => Promise<import("@hot-updater/plugin-core").IosDeviceRequestResult>;
|
|
21
|
+
approveIosDevice: (id: string, input: {
|
|
22
|
+
readonly name?: string;
|
|
23
|
+
readonly approvedBy: string | null;
|
|
24
|
+
}) => Promise<import("@hot-updater/plugin-core").IosDeviceRow | null>;
|
|
25
|
+
renameIosDevice: (id: string, name: string) => Promise<import("@hot-updater/plugin-core").IosDeviceRow | null>;
|
|
26
|
+
recordIosDeviceOutcome: (input: import("@hot-updater/plugin-core").IosDeviceOutcomeInput) => Promise<import("@hot-updater/plugin-core").IosDeviceRow | null>;
|
|
27
|
+
markIosDevicesInBuild: (input: {
|
|
28
|
+
readonly buildId: string;
|
|
29
|
+
readonly ids: readonly string[];
|
|
30
|
+
}) => Promise<void>;
|
|
31
|
+
deleteIosDevice: (id: string, only?: {
|
|
32
|
+
readonly status?: import("@hot-updater/plugin-core").IosDeviceStatus;
|
|
33
|
+
readonly requestedBy?: string;
|
|
34
|
+
}) => Promise<import("@hot-updater/plugin-core").IosDeviceRow | null>;
|
|
35
|
+
claimIosDeviceAccount: (issuerId: string) => Promise<import("@hot-updater/plugin-core").IosDeviceAccountClaim>;
|
|
36
|
+
findIosDeviceAccount: () => Promise<import("@hot-updater/plugin-core").IosDeviceAccount | null>;
|
|
12
37
|
registerNativeBuild: (registration: import("@hot-updater/plugin-core").NativeBuildRegistration) => Promise<import("@hot-updater/plugin-core").NativeBuildRow>;
|
|
13
38
|
getNativeBuild: (id: string) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
39
|
+
findNativeBuildByBuiltInBundle: (bundleId: string) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
14
40
|
findNativeBuild: (scope: import("@hot-updater/plugin-core").NativeBuildScope, options?: {
|
|
15
41
|
readonly buildKey?: string;
|
|
42
|
+
readonly storeBuild?: true;
|
|
43
|
+
readonly builtInOlderThan?: string;
|
|
44
|
+
readonly artifactKind?: import("@hot-updater/plugin-core").NativeBuildArtifactKind;
|
|
16
45
|
}) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
46
|
+
findNativeBuildSibling: (build: import("@hot-updater/plugin-core").NativeBuildRow) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
17
47
|
listNativeBuilds: (input: import("@hot-updater/plugin-core").KeysetInput & {
|
|
18
48
|
readonly channelId?: string;
|
|
19
49
|
}) => Promise<import("@hot-updater/plugin-core").NativeBuildRow[]>;
|
|
@@ -22,6 +52,9 @@ declare const createCoreApi: (db: CoreDatabase, storage: CoreStorage, options?:
|
|
|
22
52
|
readonly destination: import("@hot-updater/plugin-core").NativeBuildSubmissionDestination;
|
|
23
53
|
readonly version: string;
|
|
24
54
|
}) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
55
|
+
markNativeBuild: (id: string, mark: {
|
|
56
|
+
readonly storeBuild: boolean;
|
|
57
|
+
}) => Promise<import("@hot-updater/plugin-core").NativeBuildMarkResult | null>;
|
|
25
58
|
deploy: (deployments: readonly import("@hot-updater/plugin-core").Deployment[]) => Promise<import("@hot-updater/plugin-core").ReleaseCatalogMutationResult[]>;
|
|
26
59
|
updateReleasePolicy: (input: import("@hot-updater/plugin-core").ReleaseTarget & {
|
|
27
60
|
readonly patch: import("@hot-updater/plugin-core").ReleasePolicyPatch;
|
|
@@ -35,6 +68,10 @@ declare const createCoreApi: (db: CoreDatabase, storage: CoreStorage, options?:
|
|
|
35
68
|
readonly action?: "copy" | "move";
|
|
36
69
|
}) => Promise<import("@hot-updater/plugin-core").PromoteReleaseResult>;
|
|
37
70
|
rebuildReleaseCatalog: (scopeKey: string) => Promise<import("@hot-updater/plugin-core").ReleaseCatalogRebuildResult>;
|
|
71
|
+
fillReleaseLabels: (input?: {
|
|
72
|
+
readonly dryRun?: boolean;
|
|
73
|
+
readonly catalogs?: boolean;
|
|
74
|
+
}) => Promise<import("@hot-updater/plugin-core").ReleaseLabelFill>;
|
|
38
75
|
preflightReleaseCatalogRebuild: (scopeKey: string) => Promise<import("@hot-updater/plugin-core").ReleaseCatalogRebuildPreflight>;
|
|
39
76
|
ensureChannel: (name: string) => Promise<import("@hot-updater/plugin-core").ChannelRow>;
|
|
40
77
|
deleteChannel: (id: string) => Promise<import("@hot-updater/plugin-core").ChannelDeleteResult>;
|
|
@@ -61,8 +98,18 @@ declare const createCoreApi: (db: CoreDatabase, storage: CoreStorage, options?:
|
|
|
61
98
|
latestReleaseId(scopeKey: string): Promise<string | null>;
|
|
62
99
|
getReleaseCatalogRow(scopeKey: string): Promise<import("@hot-updater/plugin-core").ReleaseCatalogRow | null>;
|
|
63
100
|
listReleaseCatalogs(input: import("@hot-updater/plugin-core").KeysetInput): Promise<import("@hot-updater/plugin-core").ReleaseCatalogRow[]>;
|
|
64
|
-
listChannels(): Promise<import("@hot-updater/plugin-core").ChannelRow[]>;
|
|
101
|
+
listChannels(input?: import("@hot-updater/plugin-core").KeysetInput): Promise<import("@hot-updater/plugin-core").ChannelRow[]>;
|
|
102
|
+
getChannels(ids: readonly string[]): Promise<import("@hot-updater/plugin-core").ChannelRow[]>;
|
|
65
103
|
findChannelByName(name: string): Promise<import("@hot-updater/plugin-core").ChannelRow | null>;
|
|
104
|
+
listReleaseScopeKeys: (input: {
|
|
105
|
+
readonly after?: string;
|
|
106
|
+
readonly limit: number;
|
|
107
|
+
}) => Promise<string[]>;
|
|
108
|
+
getReleaseByLabel: (input: {
|
|
109
|
+
readonly channel: string;
|
|
110
|
+
readonly platform: import("@hot-updater/protocol").Platform;
|
|
111
|
+
readonly label: number;
|
|
112
|
+
}) => Promise<import("@hot-updater/plugin-core").ReleaseRow | null>;
|
|
66
113
|
};
|
|
67
114
|
type CoreApi = ReturnType<typeof createCoreApi>;
|
|
68
115
|
//#endregion
|
package/dist/core/api.d.mts
CHANGED
|
@@ -9,11 +9,41 @@ interface CoreApiOptions {
|
|
|
9
9
|
declare const createCoreApi: (db: CoreDatabase, storage: CoreStorage, options?: CoreApiOptions) => {
|
|
10
10
|
/** One read, which checks the schema settings first. */
|
|
11
11
|
ready: () => Promise<void>;
|
|
12
|
+
listIosDevices: (input: import("@hot-updater/plugin-core").KeysetInput & {
|
|
13
|
+
readonly status?: import("@hot-updater/plugin-core").IosDeviceStatus;
|
|
14
|
+
}) => Promise<import("@hot-updater/plugin-core").IosDeviceRow[]>;
|
|
15
|
+
findIosDevice: (udid: string) => Promise<import("@hot-updater/plugin-core").IosDeviceRow | null>;
|
|
16
|
+
requestIosDevice: (input: {
|
|
17
|
+
readonly udid: string;
|
|
18
|
+
readonly name: string;
|
|
19
|
+
readonly requestedBy: string | null;
|
|
20
|
+
}) => Promise<import("@hot-updater/plugin-core").IosDeviceRequestResult>;
|
|
21
|
+
approveIosDevice: (id: string, input: {
|
|
22
|
+
readonly name?: string;
|
|
23
|
+
readonly approvedBy: string | null;
|
|
24
|
+
}) => Promise<import("@hot-updater/plugin-core").IosDeviceRow | null>;
|
|
25
|
+
renameIosDevice: (id: string, name: string) => Promise<import("@hot-updater/plugin-core").IosDeviceRow | null>;
|
|
26
|
+
recordIosDeviceOutcome: (input: import("@hot-updater/plugin-core").IosDeviceOutcomeInput) => Promise<import("@hot-updater/plugin-core").IosDeviceRow | null>;
|
|
27
|
+
markIosDevicesInBuild: (input: {
|
|
28
|
+
readonly buildId: string;
|
|
29
|
+
readonly ids: readonly string[];
|
|
30
|
+
}) => Promise<void>;
|
|
31
|
+
deleteIosDevice: (id: string, only?: {
|
|
32
|
+
readonly status?: import("@hot-updater/plugin-core").IosDeviceStatus;
|
|
33
|
+
readonly requestedBy?: string;
|
|
34
|
+
}) => Promise<import("@hot-updater/plugin-core").IosDeviceRow | null>;
|
|
35
|
+
claimIosDeviceAccount: (issuerId: string) => Promise<import("@hot-updater/plugin-core").IosDeviceAccountClaim>;
|
|
36
|
+
findIosDeviceAccount: () => Promise<import("@hot-updater/plugin-core").IosDeviceAccount | null>;
|
|
12
37
|
registerNativeBuild: (registration: import("@hot-updater/plugin-core").NativeBuildRegistration) => Promise<import("@hot-updater/plugin-core").NativeBuildRow>;
|
|
13
38
|
getNativeBuild: (id: string) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
39
|
+
findNativeBuildByBuiltInBundle: (bundleId: string) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
14
40
|
findNativeBuild: (scope: import("@hot-updater/plugin-core").NativeBuildScope, options?: {
|
|
15
41
|
readonly buildKey?: string;
|
|
42
|
+
readonly storeBuild?: true;
|
|
43
|
+
readonly builtInOlderThan?: string;
|
|
44
|
+
readonly artifactKind?: import("@hot-updater/plugin-core").NativeBuildArtifactKind;
|
|
16
45
|
}) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
46
|
+
findNativeBuildSibling: (build: import("@hot-updater/plugin-core").NativeBuildRow) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
17
47
|
listNativeBuilds: (input: import("@hot-updater/plugin-core").KeysetInput & {
|
|
18
48
|
readonly channelId?: string;
|
|
19
49
|
}) => Promise<import("@hot-updater/plugin-core").NativeBuildRow[]>;
|
|
@@ -22,6 +52,9 @@ declare const createCoreApi: (db: CoreDatabase, storage: CoreStorage, options?:
|
|
|
22
52
|
readonly destination: import("@hot-updater/plugin-core").NativeBuildSubmissionDestination;
|
|
23
53
|
readonly version: string;
|
|
24
54
|
}) => Promise<import("@hot-updater/plugin-core").NativeBuildRow | null>;
|
|
55
|
+
markNativeBuild: (id: string, mark: {
|
|
56
|
+
readonly storeBuild: boolean;
|
|
57
|
+
}) => Promise<import("@hot-updater/plugin-core").NativeBuildMarkResult | null>;
|
|
25
58
|
deploy: (deployments: readonly import("@hot-updater/plugin-core").Deployment[]) => Promise<import("@hot-updater/plugin-core").ReleaseCatalogMutationResult[]>;
|
|
26
59
|
updateReleasePolicy: (input: import("@hot-updater/plugin-core").ReleaseTarget & {
|
|
27
60
|
readonly patch: import("@hot-updater/plugin-core").ReleasePolicyPatch;
|
|
@@ -35,6 +68,10 @@ declare const createCoreApi: (db: CoreDatabase, storage: CoreStorage, options?:
|
|
|
35
68
|
readonly action?: "copy" | "move";
|
|
36
69
|
}) => Promise<import("@hot-updater/plugin-core").PromoteReleaseResult>;
|
|
37
70
|
rebuildReleaseCatalog: (scopeKey: string) => Promise<import("@hot-updater/plugin-core").ReleaseCatalogRebuildResult>;
|
|
71
|
+
fillReleaseLabels: (input?: {
|
|
72
|
+
readonly dryRun?: boolean;
|
|
73
|
+
readonly catalogs?: boolean;
|
|
74
|
+
}) => Promise<import("@hot-updater/plugin-core").ReleaseLabelFill>;
|
|
38
75
|
preflightReleaseCatalogRebuild: (scopeKey: string) => Promise<import("@hot-updater/plugin-core").ReleaseCatalogRebuildPreflight>;
|
|
39
76
|
ensureChannel: (name: string) => Promise<import("@hot-updater/plugin-core").ChannelRow>;
|
|
40
77
|
deleteChannel: (id: string) => Promise<import("@hot-updater/plugin-core").ChannelDeleteResult>;
|
|
@@ -61,8 +98,18 @@ declare const createCoreApi: (db: CoreDatabase, storage: CoreStorage, options?:
|
|
|
61
98
|
latestReleaseId(scopeKey: string): Promise<string | null>;
|
|
62
99
|
getReleaseCatalogRow(scopeKey: string): Promise<import("@hot-updater/plugin-core").ReleaseCatalogRow | null>;
|
|
63
100
|
listReleaseCatalogs(input: import("@hot-updater/plugin-core").KeysetInput): Promise<import("@hot-updater/plugin-core").ReleaseCatalogRow[]>;
|
|
64
|
-
listChannels(): Promise<import("@hot-updater/plugin-core").ChannelRow[]>;
|
|
101
|
+
listChannels(input?: import("@hot-updater/plugin-core").KeysetInput): Promise<import("@hot-updater/plugin-core").ChannelRow[]>;
|
|
102
|
+
getChannels(ids: readonly string[]): Promise<import("@hot-updater/plugin-core").ChannelRow[]>;
|
|
65
103
|
findChannelByName(name: string): Promise<import("@hot-updater/plugin-core").ChannelRow | null>;
|
|
104
|
+
listReleaseScopeKeys: (input: {
|
|
105
|
+
readonly after?: string;
|
|
106
|
+
readonly limit: number;
|
|
107
|
+
}) => Promise<string[]>;
|
|
108
|
+
getReleaseByLabel: (input: {
|
|
109
|
+
readonly channel: string;
|
|
110
|
+
readonly platform: import("@hot-updater/protocol").Platform;
|
|
111
|
+
readonly label: number;
|
|
112
|
+
}) => Promise<import("@hot-updater/plugin-core").ReleaseRow | null>;
|
|
66
113
|
};
|
|
67
114
|
type CoreApi = ReturnType<typeof createCoreApi>;
|
|
68
115
|
//#endregion
|
package/dist/core/api.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createCoreReads } from "./reads.mjs";
|
|
2
|
+
import { createIosDeviceApi } from "./iosDevices.mjs";
|
|
2
3
|
import { createNativeBuildApi } from "./nativeBuilds.mjs";
|
|
3
4
|
import { createCoreOperations } from "./operations.mjs";
|
|
4
5
|
//#region src/core/api.ts
|
|
@@ -43,6 +44,7 @@ const createCoreApi = (db, storage, options = {}) => {
|
|
|
43
44
|
...reads,
|
|
44
45
|
...createCoreOperations(purgingCachedRoutes(db, options.onCachedRoutesChange), options),
|
|
45
46
|
...createNativeBuildApi(db, options),
|
|
47
|
+
...createIosDeviceApi(db, options),
|
|
46
48
|
/** One read, which checks the schema settings first. */
|
|
47
49
|
ready: async () => {
|
|
48
50
|
await reads.listReleaseCatalogs({ limit: 1 });
|