@madewithremy/admin 0.1.32 → 0.1.34
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/index.d.ts +82 -10
- package/dist/index.js +13 -12
- package/dist/index.js.map +1 -1
- package/dist/prod.js +56 -21
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1326,6 +1326,13 @@ type DataSourceJobSource = {
|
|
|
1326
1326
|
unread: boolean;
|
|
1327
1327
|
/** Only documents matching this metadata filter. */
|
|
1328
1328
|
filter: Record<string, unknown> | null;
|
|
1329
|
+
} | {
|
|
1330
|
+
/**
|
|
1331
|
+
* The rest of one file a `datasources add` (or an app's `add()`) took
|
|
1332
|
+
* that maps to more than a thousand documents; `ref` is its filename.
|
|
1333
|
+
*/
|
|
1334
|
+
type: 'object';
|
|
1335
|
+
ref: string;
|
|
1329
1336
|
};
|
|
1330
1337
|
/**
|
|
1331
1338
|
* planning → planned → running ⇄ paused → done | failed | cancelled.
|
|
@@ -1941,7 +1948,24 @@ interface DataSourceMapTestDocument {
|
|
|
1941
1948
|
}
|
|
1942
1949
|
type DataSourceMapTestOutcome = {
|
|
1943
1950
|
kind: 'documents';
|
|
1951
|
+
/** The first twenty of them. */
|
|
1944
1952
|
documents: DataSourceMapTestDocument[];
|
|
1953
|
+
/** Every valid document the object produced. */
|
|
1954
|
+
count: number;
|
|
1955
|
+
/**
|
|
1956
|
+
* Its documents that failed validation, by their index in the mapper's
|
|
1957
|
+
* output: a job leaves them out and quarantines the object for them.
|
|
1958
|
+
* Null when every one passed.
|
|
1959
|
+
*/
|
|
1960
|
+
invalid: {
|
|
1961
|
+
count: number;
|
|
1962
|
+
examples: {
|
|
1963
|
+
document: number;
|
|
1964
|
+
reason: string;
|
|
1965
|
+
}[];
|
|
1966
|
+
} | null;
|
|
1967
|
+
/** Parts of the frame's documents that storage did not have. */
|
|
1968
|
+
missingParts?: number;
|
|
1945
1969
|
} | {
|
|
1946
1970
|
kind: 'passthrough';
|
|
1947
1971
|
metadata: Record<string, string | number | boolean> | null;
|
|
@@ -2311,8 +2335,10 @@ interface DataSourcesDocumentsResult {
|
|
|
2311
2335
|
type DataSourcesUploadTokenResult = {
|
|
2312
2336
|
alreadyCurrent: true;
|
|
2313
2337
|
document: DataSourcesDocument;
|
|
2314
|
-
/** Mapped sources:
|
|
2338
|
+
/** Mapped sources: what this mapper version produced from the bytes, the first thousand at most. */
|
|
2315
2339
|
documents?: DataSourcesDocument[];
|
|
2340
|
+
/** Mapped sources: how many it produced in all. */
|
|
2341
|
+
documentCount?: number;
|
|
2316
2342
|
} | {
|
|
2317
2343
|
alreadyCurrent: false;
|
|
2318
2344
|
contentType: string;
|
|
@@ -2326,16 +2352,30 @@ type DataSourcesUploadTokenResult = {
|
|
|
2326
2352
|
* POST /datasources/documents — confirm an uploaded object and queue its
|
|
2327
2353
|
* builds. On a mapped source the object is a raw copy and the mapper decides
|
|
2328
2354
|
* what it becomes: `documents` holds everything produced, `document` the first
|
|
2329
|
-
* of them (null only for a `deletes` outcome).
|
|
2355
|
+
* of them (null only for a `deletes` outcome). An object that maps to more
|
|
2356
|
+
* than a thousand documents returns the first thousand and `job`, which
|
|
2357
|
+
* registers and builds the rest.
|
|
2330
2358
|
*/
|
|
2331
2359
|
interface DataSourcesDocumentConfirmResult {
|
|
2332
2360
|
document: DataSourcesDocument | null;
|
|
2333
2361
|
documents: DataSourcesDocument[];
|
|
2362
|
+
/** Every document the object maps to; `documents.length` unless `job` is set. */
|
|
2363
|
+
documentCount: number;
|
|
2334
2364
|
/** Whether any document was queued for a build. */
|
|
2335
2365
|
queued: boolean;
|
|
2336
2366
|
outcome: 'unmapped' | 'documents' | 'passthrough' | 'deletes';
|
|
2337
2367
|
/** Documents removed or superseded as a result. */
|
|
2338
2368
|
removed: number;
|
|
2369
|
+
/** Documents that failed validation and were not registered; null when none did. */
|
|
2370
|
+
invalid: {
|
|
2371
|
+
count: number;
|
|
2372
|
+
examples: {
|
|
2373
|
+
document: number;
|
|
2374
|
+
reason: string;
|
|
2375
|
+
}[];
|
|
2376
|
+
} | null;
|
|
2377
|
+
/** The job taking the rest of an object larger than a thousand documents. */
|
|
2378
|
+
job: DataSourceJob | null;
|
|
2339
2379
|
}
|
|
2340
2380
|
/** Build progress counts used in several list and status shapes. */
|
|
2341
2381
|
interface DataSourcesBuildProgress {
|
|
@@ -2770,6 +2810,11 @@ interface AddDocumentParams {
|
|
|
2770
2810
|
* no whitespace or commas). Every passage carries them; `[]` clears them.
|
|
2771
2811
|
*/
|
|
2772
2812
|
entities?: string[];
|
|
2813
|
+
/**
|
|
2814
|
+
* The budget in dollars of the job that takes the rest of a file mapping
|
|
2815
|
+
* to more than a thousand documents (`AddDocumentResult.job`).
|
|
2816
|
+
*/
|
|
2817
|
+
budgetDollars?: number;
|
|
2773
2818
|
/**
|
|
2774
2819
|
* Receives the exact progress strings the CLI prints today:
|
|
2775
2820
|
* - `${filename}: unchanged, skipped`
|
|
@@ -2786,10 +2831,28 @@ interface AddDocumentResult {
|
|
|
2786
2831
|
* source's mapper answered `deletes` for the file.
|
|
2787
2832
|
*/
|
|
2788
2833
|
document: DataSourcesDocument | null;
|
|
2789
|
-
/**
|
|
2834
|
+
/**
|
|
2835
|
+
* Every document the file became — one on an unmapped source — or the
|
|
2836
|
+
* first thousand of a file that maps to more.
|
|
2837
|
+
*/
|
|
2790
2838
|
documents: DataSourcesDocument[];
|
|
2839
|
+
/** How many documents the file maps to in all. */
|
|
2840
|
+
documentCount: number;
|
|
2791
2841
|
/** How the source took the file; absent when it was already current. */
|
|
2792
2842
|
outcome?: 'unmapped' | 'documents' | 'passthrough' | 'deletes';
|
|
2843
|
+
/** Documents the mapper produced that failed validation and were not registered. */
|
|
2844
|
+
invalid?: {
|
|
2845
|
+
count: number;
|
|
2846
|
+
examples: {
|
|
2847
|
+
document: number;
|
|
2848
|
+
reason: string;
|
|
2849
|
+
}[];
|
|
2850
|
+
} | null;
|
|
2851
|
+
/**
|
|
2852
|
+
* The job registering and building the rest of a file that maps to more
|
|
2853
|
+
* than a thousand documents; it plans and starts on its own.
|
|
2854
|
+
*/
|
|
2855
|
+
job?: DataSourceJob | null;
|
|
2793
2856
|
}
|
|
2794
2857
|
/**
|
|
2795
2858
|
* Add one document to a data source.
|
|
@@ -4037,8 +4100,8 @@ declare namespace dataSourceMappers {
|
|
|
4037
4100
|
* Response types for the db command group.
|
|
4038
4101
|
*
|
|
4039
4102
|
* Sources in youai-api:
|
|
4040
|
-
* POST /db/query → src/http/routes/
|
|
4041
|
-
*
|
|
4103
|
+
* POST /db/query → apps/api/src/roles/http/routes/Apps/manage/dbQuery.ts
|
|
4104
|
+
* AppDatabasesDao.executeSqlBatch returns
|
|
4042
4105
|
* Array<{ rows: any[]; changes: number }>
|
|
4043
4106
|
*/
|
|
4044
4107
|
/**
|
|
@@ -4053,6 +4116,16 @@ interface DbQueryResult {
|
|
|
4053
4116
|
/** Rows modified by a DML statement; 0 for SELECT. */
|
|
4054
4117
|
changes: number;
|
|
4055
4118
|
}>;
|
|
4119
|
+
/**
|
|
4120
|
+
* Display info for the people the rows reference (user-typed columns hold
|
|
4121
|
+
* `@@user@@<id>`), keyed by user id. Only people the workspace may see.
|
|
4122
|
+
*/
|
|
4123
|
+
resolvedUsers: Record<string, {
|
|
4124
|
+
id: string;
|
|
4125
|
+
username: string;
|
|
4126
|
+
displayName: string | null;
|
|
4127
|
+
profilePictureUrl: string | null;
|
|
4128
|
+
}>;
|
|
4056
4129
|
}
|
|
4057
4130
|
|
|
4058
4131
|
/**
|
|
@@ -4071,16 +4144,15 @@ interface DbQueryResult {
|
|
|
4071
4144
|
* accepted. The `results` array always has exactly one element for a single
|
|
4072
4145
|
* statement; `changes` is 0 for SELECT.
|
|
4073
4146
|
*
|
|
4074
|
-
*
|
|
4075
|
-
*
|
|
4076
|
-
*
|
|
4147
|
+
* A statement the database refuses (a syntax error, a constraint, a result
|
|
4148
|
+
* too large) throws with `errorString: 'sql_error'`, and the body's
|
|
4149
|
+
* `errorMessage` is the database's own message.
|
|
4077
4150
|
*
|
|
4078
4151
|
* @param sql The SQL statement to execute.
|
|
4079
4152
|
* @throws AdminApiError `no_live_release` (404) — the app has not been
|
|
4080
4153
|
* deployed; `no_database` (404) — the live release has no database;
|
|
4081
4154
|
* `invalid_request` (400) — `queries[]` missing or malformed;
|
|
4082
|
-
* `
|
|
4083
|
-
* `unique_constraint_violated` (400) — a UNIQUE constraint was violated.
|
|
4155
|
+
* `sql_error` (400) — the database refused the statement.
|
|
4084
4156
|
* @example
|
|
4085
4157
|
* const { results } = await admin.db.query('SELECT * FROM users LIMIT 10');
|
|
4086
4158
|
*/
|
package/dist/index.js
CHANGED
|
@@ -552,6 +552,7 @@ var summarize = (d) => ({
|
|
|
552
552
|
});
|
|
553
553
|
async function addDocument(ctx, params) {
|
|
554
554
|
const { slug, filename, content, metadata, entities: entities2, onProgress } = params;
|
|
555
|
+
const { budgetDollars } = params;
|
|
555
556
|
const contentHash = createHash("sha256").update(content).digest("hex");
|
|
556
557
|
const token = await call(
|
|
557
558
|
ctx,
|
|
@@ -567,11 +568,13 @@ async function addDocument(ctx, params) {
|
|
|
567
568
|
);
|
|
568
569
|
if (token.alreadyCurrent) {
|
|
569
570
|
onProgress?.(`${filename}: unchanged, skipped`);
|
|
571
|
+
const documents3 = token.documents ?? [token.document];
|
|
570
572
|
return {
|
|
571
573
|
filename,
|
|
572
574
|
skipped: true,
|
|
573
575
|
document: token.document,
|
|
574
|
-
documents:
|
|
576
|
+
documents: documents3,
|
|
577
|
+
documentCount: token.documentCount ?? documents3.length
|
|
575
578
|
};
|
|
576
579
|
}
|
|
577
580
|
onProgress?.(
|
|
@@ -589,16 +592,21 @@ async function addDocument(ctx, params) {
|
|
|
589
592
|
contentType: token.contentType,
|
|
590
593
|
size: content.length,
|
|
591
594
|
...metadata ? { metadata } : {},
|
|
592
|
-
...entities2 ? { entities: entities2 } : {}
|
|
595
|
+
...entities2 ? { entities: entities2 } : {},
|
|
596
|
+
...budgetDollars !== void 0 ? { budgetDollars } : {}
|
|
593
597
|
}
|
|
594
598
|
);
|
|
599
|
+
const documents2 = confirmed.documents ?? (confirmed.document ? [confirmed.document] : []);
|
|
595
600
|
return {
|
|
596
601
|
filename,
|
|
597
602
|
skipped: false,
|
|
598
603
|
queued: confirmed.queued,
|
|
599
604
|
document: confirmed.document,
|
|
600
|
-
documents:
|
|
601
|
-
|
|
605
|
+
documents: documents2,
|
|
606
|
+
documentCount: confirmed.documentCount ?? documents2.length,
|
|
607
|
+
outcome: confirmed.outcome,
|
|
608
|
+
invalid: confirmed.invalid ?? null,
|
|
609
|
+
job: confirmed.job ?? null
|
|
602
610
|
};
|
|
603
611
|
}
|
|
604
612
|
async function waitForIngest(ctx, params) {
|
|
@@ -1649,13 +1657,6 @@ async function dashboardLive(ctx) {
|
|
|
1649
1657
|
);
|
|
1650
1658
|
return dashboard.liveRelease;
|
|
1651
1659
|
}
|
|
1652
|
-
function buildFailureReason(release) {
|
|
1653
|
-
const log = Array.isArray(release.buildLog) ? release.buildLog : [];
|
|
1654
|
-
const errors = log.filter(
|
|
1655
|
-
(entry) => entry?.phase === "error" && typeof entry.message === "string"
|
|
1656
|
-
);
|
|
1657
|
-
return errors.length ? errors[errors.length - 1].message : null;
|
|
1658
|
-
}
|
|
1659
1660
|
function summarizeRelease(release) {
|
|
1660
1661
|
const summary2 = {
|
|
1661
1662
|
releaseId: release.id,
|
|
@@ -1678,7 +1679,7 @@ function summarizeRelease(release) {
|
|
|
1678
1679
|
}
|
|
1679
1680
|
return {
|
|
1680
1681
|
...summary2,
|
|
1681
|
-
error: release.failureReason ??
|
|
1682
|
+
error: release.failureReason ?? "Build failed (no error entry in the build log)",
|
|
1682
1683
|
...release.failureKind ? { failureKind: release.failureKind } : {},
|
|
1683
1684
|
...release.failurePhase ? { failurePhase: release.failurePhase } : {}
|
|
1684
1685
|
};
|