@madewithremy/admin 0.1.59 → 0.1.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/CHANGELOG.md +26 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +2 -2
- package/dist/ops/data.d.ts +2 -0
- package/dist/ops/dataSources.d.ts +3 -3
- package/dist/ops/db.d.ts +22 -8
- package/dist/prod.js +60 -17
- package/dist/types/db.d.ts +15 -1
- package/package.json +1 -1
package/dist/ops/data.d.ts
CHANGED
|
@@ -58,6 +58,8 @@ export interface LiftFromLiveParams {
|
|
|
58
58
|
*
|
|
59
59
|
* @throws AdminApiError `no_dev_session` (404) — no dev release exists (start a dev session first);
|
|
60
60
|
* `no_live_release` (404) — no live release (copy mode only; not thrown when `truncate` is true);
|
|
61
|
+
* `live_too_large_to_copy` (422) — live's databases are past the 1 GB that may be copied into dev
|
|
62
|
+
* (copy mode only): seed dev with scenarios instead;
|
|
61
63
|
* `not_your_dev_session` (403) — `releaseId` names someone else's dev session.
|
|
62
64
|
* @example
|
|
63
65
|
* // Pull live data into dev for debugging:
|
|
@@ -601,9 +601,9 @@ export declare function rmWhereAll(ctx: AdminContext, params: RmWhereParams & {
|
|
|
601
601
|
/**
|
|
602
602
|
* Delete a whole data source — every version, every document, and every byte.
|
|
603
603
|
*
|
|
604
|
-
*
|
|
605
|
-
*
|
|
606
|
-
* Manage-plane only: running app code has no equivalent.
|
|
604
|
+
* Extracted text is shared across the app's sources by content hash, so a
|
|
605
|
+
* document's goes too unless another source in the app still holds the same
|
|
606
|
+
* bytes. Manage-plane only: running app code has no equivalent.
|
|
607
607
|
*
|
|
608
608
|
* @throws AdminApiError `data_source_not_found` (404).
|
|
609
609
|
* @example
|
package/dist/ops/db.d.ts
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* all output.
|
|
7
7
|
*/
|
|
8
8
|
import type { AdminContext } from '../ctx.js';
|
|
9
|
-
import type { DbHistoryResult, DbQueryResult } from '../types/db.js';
|
|
9
|
+
import type { DbHistoryPurgeResult, DbHistoryResult, DbQueryResult } from '../types/db.js';
|
|
10
10
|
/**
|
|
11
11
|
* Execute one SQL statement against the app's live-release database.
|
|
12
12
|
*
|
|
@@ -35,13 +35,15 @@ export interface DbHistoryParams {
|
|
|
35
35
|
cursor?: string;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* The app's releases that were ever live
|
|
39
|
-
* it was live for and its
|
|
38
|
+
* The app's releases that were ever live and still keep a copy of the
|
|
39
|
+
* database, newest first, each with the window it was live for and its
|
|
40
|
+
* databases.
|
|
40
41
|
*
|
|
41
42
|
* A deploy copies live into the new release and keeps the release it
|
|
42
|
-
* replaces, database and all, as it stood at that moment
|
|
43
|
-
* database is live as of its `liveUntil`; the
|
|
44
|
-
* with `current: true`. Nothing between two
|
|
43
|
+
* replaces, database and all, as it stood at that moment, until its
|
|
44
|
+
* `keptUntil`. So each entry's database is live as of its `liveUntil`; the
|
|
45
|
+
* release live now heads the list with `current: true`. Nothing between two
|
|
46
|
+
* deploys is kept.
|
|
45
47
|
*
|
|
46
48
|
* @throws AdminApiError `invalid_request` (400) — `limit` isn't an integer.
|
|
47
49
|
* @example
|
|
@@ -56,8 +58,9 @@ export declare function history(ctx: AdminContext, params?: DbHistoryParams): Pr
|
|
|
56
58
|
* @param releaseId A release from `history()` that isn't `current`.
|
|
57
59
|
* @throws AdminApiError `release_not_found` (404) — no release of this app
|
|
58
60
|
* that was ever live has that id; `release_is_live` (400) — it's the live
|
|
59
|
-
* release, so use `query`; `
|
|
60
|
-
*
|
|
61
|
+
* release, so use `query`; `copy_expired` (404) — that release's copy was
|
|
62
|
+
* deleted, its window passed or purged; `no_database` (404) — that release
|
|
63
|
+
* has no database of live's name; `no_live_release` (404) — the app isn't
|
|
61
64
|
* deployed; `sql_error` (400) — the database refused the statement,
|
|
62
65
|
* a write included.
|
|
63
66
|
* @example
|
|
@@ -79,3 +82,14 @@ export declare function historyQuery(ctx: AdminContext, releaseId: string, sql:
|
|
|
79
82
|
* 'UPDATE orders SET note = h.note FROM history.orders h WHERE h.id = orders.id AND orders.note IS NULL');
|
|
80
83
|
*/
|
|
81
84
|
export declare function historyAttach(ctx: AdminContext, releaseId: string, sql: string): Promise<DbQueryResult>;
|
|
85
|
+
/**
|
|
86
|
+
* Delete every copy of the database the app's replaced releases keep, now,
|
|
87
|
+
* rather than when each one's window passes: for a deletion that can't wait.
|
|
88
|
+
* Live is untouched, and `history` lists only the live release afterwards.
|
|
89
|
+
*
|
|
90
|
+
* @throws AdminApiError `app_moving` (503) — the app's data is moving between
|
|
91
|
+
* workspaces or regions; try again once the move is done.
|
|
92
|
+
* @example
|
|
93
|
+
* const { purged } = await admin.db.historyPurge();
|
|
94
|
+
*/
|
|
95
|
+
export declare function historyPurge(ctx: AdminContext): Promise<DbHistoryPurgeResult>;
|
package/dist/prod.js
CHANGED
|
@@ -2283,6 +2283,14 @@ function historyAttach(ctx, releaseId, sql) {
|
|
|
2283
2283
|
{ releaseId, queries: [{ sql }] }
|
|
2284
2284
|
);
|
|
2285
2285
|
}
|
|
2286
|
+
function historyPurge(ctx) {
|
|
2287
|
+
return call(
|
|
2288
|
+
ctx,
|
|
2289
|
+
"POST",
|
|
2290
|
+
`/_internal/v2/apps/${ctx.appId}/db/history/purge`,
|
|
2291
|
+
{}
|
|
2292
|
+
);
|
|
2293
|
+
}
|
|
2286
2294
|
|
|
2287
2295
|
// src/commands/db.ts
|
|
2288
2296
|
var dbSpecs = {
|
|
@@ -2319,6 +2327,9 @@ var dbSpecs = {
|
|
|
2319
2327
|
{ name: "releaseId", required: true },
|
|
2320
2328
|
{ name: "sql", required: true }
|
|
2321
2329
|
]
|
|
2330
|
+
},
|
|
2331
|
+
"db history purge": {
|
|
2332
|
+
usage: "Usage: remy-admin db history purge"
|
|
2322
2333
|
}
|
|
2323
2334
|
};
|
|
2324
2335
|
async function dbQuery(ctx, a) {
|
|
@@ -2335,6 +2346,9 @@ async function dbHistoryQuery(ctx, a) {
|
|
|
2335
2346
|
async function dbHistoryAttach(ctx, a) {
|
|
2336
2347
|
out(await historyAttach(ctx, a.req("releaseId"), a.req("sql")));
|
|
2337
2348
|
}
|
|
2349
|
+
async function dbHistoryPurge(ctx) {
|
|
2350
|
+
out(await historyPurge(ctx));
|
|
2351
|
+
}
|
|
2338
2352
|
async function dbTables(ctx) {
|
|
2339
2353
|
out(
|
|
2340
2354
|
await query2(
|
|
@@ -2348,16 +2362,18 @@ var dbHandlers = {
|
|
|
2348
2362
|
"db tables": dbTables,
|
|
2349
2363
|
"db history": dbHistory,
|
|
2350
2364
|
"db history query": dbHistoryQuery,
|
|
2351
|
-
"db history attach": dbHistoryAttach
|
|
2365
|
+
"db history attach": dbHistoryAttach,
|
|
2366
|
+
"db history purge": dbHistoryPurge
|
|
2352
2367
|
};
|
|
2353
2368
|
var dbHelp = `remy-admin db \u2014 Query the production database, and the copies of it past releases kept.
|
|
2354
2369
|
|
|
2355
2370
|
Subcommands:
|
|
2356
2371
|
query Execute a SQL query against the live release's database
|
|
2357
2372
|
tables List all tables in the database
|
|
2358
|
-
history List past releases
|
|
2373
|
+
history List the copies past releases keep, newest first, with when each was live
|
|
2359
2374
|
history query Read a past release's database (read-only)
|
|
2360
2375
|
history attach Run SQL against live with a past release's database attached as "history"
|
|
2376
|
+
history purge Delete every copy past releases keep, now
|
|
2361
2377
|
|
|
2362
2378
|
Usage:
|
|
2363
2379
|
remy-admin db <sql>
|
|
@@ -2366,14 +2382,17 @@ Usage:
|
|
|
2366
2382
|
remy-admin db history [--limit 20] [--cursor <nextCursor>]
|
|
2367
2383
|
remy-admin db history query <releaseId> <sql>
|
|
2368
2384
|
remy-admin db history attach <releaseId> <sql>
|
|
2385
|
+
remy-admin db history purge
|
|
2369
2386
|
|
|
2370
2387
|
Past releases:
|
|
2371
2388
|
Every deploy copies the live database into the new release and keeps the
|
|
2372
|
-
release it replaces, database and all, exactly as it stood at that moment
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2376
|
-
|
|
2389
|
+
release it replaces, database and all, exactly as it stood at that moment,
|
|
2390
|
+
until its keptUntil: 28 days after it was replaced, when the copy is
|
|
2391
|
+
deleted. So each entry 'db history' lists holds live as of its liveUntil:
|
|
2392
|
+
anything written after that is only in later copies and in live, and
|
|
2393
|
+
nothing that happened between two deploys is kept anywhere. The release
|
|
2394
|
+
live now is listed first (current: true); its database is live, so use
|
|
2395
|
+
'db query'.
|
|
2377
2396
|
|
|
2378
2397
|
'db history query' reads one of those copies, and nothing can change it: a
|
|
2379
2398
|
write is refused. Its schema is that release's, which may differ from
|
|
@@ -2409,6 +2428,11 @@ Past releases:
|
|
|
2409
2428
|
If no copy covers the moment that matters, say so plainly rather than
|
|
2410
2429
|
restoring from the nearest one.
|
|
2411
2430
|
|
|
2431
|
+
'db history purge' deletes every copy now, for a deletion request that
|
|
2432
|
+
can't wait the 28 days: rows deleted from live then leave every copy at
|
|
2433
|
+
once. Live is untouched, and nothing can bring a purged copy back, so get
|
|
2434
|
+
the user's go-ahead first.
|
|
2435
|
+
|
|
2412
2436
|
Notes:
|
|
2413
2437
|
- SQL is taken verbatim: 'db query' and the two history commands that take
|
|
2414
2438
|
SQL don't parse flags, so a statement may safely begin with a '--'
|
|
@@ -2418,9 +2442,11 @@ Notes:
|
|
|
2418
2442
|
large database; the ones after it are quick.
|
|
2419
2443
|
- Errors: release_not_found (no release of this app that was ever live has
|
|
2420
2444
|
that id), release_is_live (it's the live release: use 'db query'),
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2445
|
+
copy_expired (that release's copy was deleted: its 28 days passed, or it
|
|
2446
|
+
was purged), no_database (that release has no database of live's name),
|
|
2447
|
+
sql_error (the database refused the statement, a write to a past copy
|
|
2448
|
+
included; nothing in it was applied), app_moving (purge: the app's data
|
|
2449
|
+
is moving; try again once the move is done).
|
|
2424
2450
|
|
|
2425
2451
|
Examples:
|
|
2426
2452
|
remy-admin db tables
|
|
@@ -2939,9 +2965,11 @@ What lift-from-live does:
|
|
|
2939
2965
|
The reverse \u2014 pulls live's databases down over dev's, so the sandbox matches
|
|
2940
2966
|
prod. Useful for reproducing a prod bug against real data or re-syncing a
|
|
2941
2967
|
stale sandbox. Only dev is overwritten; live/prod data is never touched.
|
|
2942
|
-
Requires an existing dev release (start a dev session first).
|
|
2943
|
-
|
|
2944
|
-
|
|
2968
|
+
Requires an existing dev release (start a dev session first). Refused with
|
|
2969
|
+
live_too_large_to_copy once live's databases are past 1 GB: seed dev with
|
|
2970
|
+
scenarios instead. With --truncate it instead empties the dev databases
|
|
2971
|
+
(keeps schema + IDs, no data pulled from live). Writes an audit row tagged
|
|
2972
|
+
'lift-live-to-dev'.
|
|
2945
2973
|
|
|
2946
2974
|
Critical constraints:
|
|
2947
2975
|
- Whole-database overwrite, INCLUDING auth tables. lift-from-dev wipes live's
|
|
@@ -7344,7 +7372,8 @@ Tuning a corpus:
|
|
|
7344
7372
|
|
|
7345
7373
|
FREE \u2014 take effect on the next search, no rebuild:
|
|
7346
7374
|
--rerank <true|false> Cross-encoder reranking (default true)
|
|
7347
|
-
--rerank-model <id> Which
|
|
7375
|
+
--rerank-model <id> Which reranking model reranks (live, no rebuild);
|
|
7376
|
+
a chat model is refused, rerank_model_invalid
|
|
7348
7377
|
--hybrid <true|false> Semantic + keyword matching (default true)
|
|
7349
7378
|
--top-k <n> Default results per search
|
|
7350
7379
|
|
|
@@ -7379,7 +7408,16 @@ Tuning a corpus:
|
|
|
7379
7408
|
one it lists; the error names the choices.
|
|
7380
7409
|
Smaller vectors cut index memory, and dedicated
|
|
7381
7410
|
capacity needs, roughly in proportion.
|
|
7382
|
-
--extraction-model <id>
|
|
7411
|
+
--extraction-model <id> Reads PDFs and images; Office documents,
|
|
7412
|
+
spreadsheets, HTML and text never reach it.
|
|
7413
|
+
|
|
7414
|
+
Every model setting takes <model>@<routeKey> to hold that model's calls to
|
|
7415
|
+
one of its serving routes (\`routes\` in listModels), for a data-boundary
|
|
7416
|
+
need: \`--embedding-model text-embedding-3-large@openai\`. The pin is part of
|
|
7417
|
+
the setting, so it costs what the setting does, and it holds ingest and
|
|
7418
|
+
search alike. \`config\` shows it as stored; a route the model doesn't
|
|
7419
|
+
declare is refused with model_route_unavailable. The bare id routes
|
|
7420
|
+
automatically.
|
|
7383
7421
|
|
|
7384
7422
|
Placement (shared pool vs dedicated capacity, see \`infra --help\`):
|
|
7385
7423
|
--source defaults to "${DEFAULT_SOURCE}" and is created on first use, on the
|
|
@@ -7432,8 +7470,13 @@ Notes:
|
|
|
7432
7470
|
recorded, e.g. '{"externalIdPrefix":"archive/2019/"}'). An empty filter
|
|
7433
7471
|
is refused; to remove everything, delete the source.
|
|
7434
7472
|
delete requires an explicit --source (no default) and refuses while documents
|
|
7435
|
-
are still ingesting.
|
|
7436
|
-
|
|
7473
|
+
are still ingesting.
|
|
7474
|
+
Extracted text is kept by content hash and shared across the app's sources.
|
|
7475
|
+
It goes once no document in the app holds the same bytes (rm, rm --filter,
|
|
7476
|
+
delete), so a file still in another source keeps its extraction and
|
|
7477
|
+
re-adding it costs no re-extraction. Dropping a version (\`drop\`, or the
|
|
7478
|
+
sweep after \`promote\`) also deletes the extracted text of any extraction
|
|
7479
|
+
or image model no other version in the app uses.
|
|
7437
7480
|
Re-vectorizing reuses stored extractions, so changing chunking never re-runs
|
|
7438
7481
|
document extraction \u2014 only re-chunking and re-embedding.
|
|
7439
7482
|
|
package/dist/types/db.d.ts
CHANGED
|
@@ -9,10 +9,12 @@
|
|
|
9
9
|
* (PublishedRelease, AppReleases/types/release.ts)
|
|
10
10
|
* POST /db/history/query, /db/history/attach → the same file; answered as
|
|
11
11
|
* /db/query is
|
|
12
|
+
* POST /db/history/purge → the same file, over AppDatabases/recoveryCopies.ts
|
|
12
13
|
*/
|
|
13
14
|
/**
|
|
14
15
|
* Response from GET /_internal/v2/apps/:appId/db/history: the app's releases
|
|
15
|
-
* that were ever live
|
|
16
|
+
* that were ever live and still keep a copy of the database, newest first,
|
|
17
|
+
* with the window each was live for.
|
|
16
18
|
*/
|
|
17
19
|
export interface DbHistoryResult {
|
|
18
20
|
copies: Array<{
|
|
@@ -27,6 +29,11 @@ export interface DbHistoryResult {
|
|
|
27
29
|
* stood at that moment. Null for the release live now.
|
|
28
30
|
*/
|
|
29
31
|
liveUntil: string | null;
|
|
32
|
+
/**
|
|
33
|
+
* When this copy is deleted (ISO): a replaced release's copy is kept for a
|
|
34
|
+
* window after it's replaced. Null for the release live now.
|
|
35
|
+
*/
|
|
36
|
+
keptUntil: string | null;
|
|
30
37
|
/** The release live now, whose database is live: query it with `db query`. */
|
|
31
38
|
current: boolean;
|
|
32
39
|
/** The release's databases; history commands use the one named as live's default. */
|
|
@@ -61,3 +68,10 @@ export interface DbQueryResult {
|
|
|
61
68
|
profilePictureUrl: string | null;
|
|
62
69
|
}>;
|
|
63
70
|
}
|
|
71
|
+
/** Response from POST /_internal/v2/apps/:appId/db/history/purge. */
|
|
72
|
+
export interface DbHistoryPurgeResult {
|
|
73
|
+
/** The releases whose copies were deleted. */
|
|
74
|
+
purged: Array<{
|
|
75
|
+
releaseId: string;
|
|
76
|
+
}>;
|
|
77
|
+
}
|