@wayai/cli 0.3.344 → 0.3.346
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.js +132 -48
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -20349,7 +20349,7 @@ var init_resource_files = __esm({
|
|
|
20349
20349
|
});
|
|
20350
20350
|
|
|
20351
20351
|
// ../../packages/core/dist/contracts/case-type-drafts.js
|
|
20352
|
-
var caseTypeSourceQuery, caseTypePackageParam, caseTypeDraftParam, CASE_TYPE_DRAFT_FIELD, CASE_TYPE_PACKAGE_FIELD, caseTypeDraftFields, CASE_TYPE_DRAFT_BODY_MAX_BYTES, caseTypeDraftForm, CASE_PACKAGE_INVALID_REASON, CASE_TYPE_DRAFT_UPLOAD_EXPIRED_REASON, CASE_TYPE_DRAFT_UPLOADS_BUSY_REASON, CASE_TYPE_DRAFTS_FULL_REASON, caseRecordPackageQuery, CASE_PACKAGE_PATH_MAX_CHARS, caseRecordPackageFileQuery;
|
|
20352
|
+
var CASE_TYPE_PACKAGE_REVISIONS_MAX, caseTypeSourceQuery, caseTypePackageParam, caseTypeDraftParam, CASE_TYPE_DRAFT_FIELD, CASE_TYPE_PACKAGE_FIELD, caseTypeDraftFields, CASE_TYPE_DRAFT_BODY_MAX_BYTES, caseTypeDraftForm, CASE_TYPE_PACKAGE_REACHES, caseTypeDraftPublicationBody, CASE_PACKAGE_INVALID_REASON, CASE_TYPE_DRAFT_UPLOAD_EXPIRED_REASON, CASE_TYPE_DRAFT_UPLOADS_BUSY_REASON, CASE_TYPE_DRAFTS_FULL_REASON, CASE_TYPE_REVISION_CONFLICT_REASON, CASE_TYPE_DRAFT_BASE_REVISION_REQUIRED_REASON, caseRecordPackageQuery, CASE_PACKAGE_PATH_MAX_CHARS, caseRecordPackageFileQuery;
|
|
20353
20353
|
var init_case_type_drafts = __esm({
|
|
20354
20354
|
"../../packages/core/dist/contracts/case-type-drafts.js"() {
|
|
20355
20355
|
"use strict";
|
|
@@ -20367,6 +20367,7 @@ var init_case_type_drafts = __esm({
|
|
|
20367
20367
|
init_chunk_WFQDSQJK();
|
|
20368
20368
|
init_chunk_ZTNFLGW5();
|
|
20369
20369
|
init_zod();
|
|
20370
|
+
CASE_TYPE_PACKAGE_REVISIONS_MAX = CASE_TYPE_VERSIONS_MAX;
|
|
20370
20371
|
caseTypeSourceQuery = external_exports.object({
|
|
20371
20372
|
version: external_exports.coerce.number().int().min(1).max(CASE_TYPE_VERSIONS_MAX).optional()
|
|
20372
20373
|
});
|
|
@@ -20376,6 +20377,8 @@ var init_case_type_drafts = __esm({
|
|
|
20376
20377
|
CASE_TYPE_PACKAGE_FIELD = "package";
|
|
20377
20378
|
caseTypeDraftFields = external_exports.object({
|
|
20378
20379
|
base_version: external_exports.number().int().min(1).max(CASE_TYPE_VERSIONS_MAX),
|
|
20380
|
+
/** The base version's package revision it was made from (the source's `revision`; 0: none). Optional for clients from before revisions. */
|
|
20381
|
+
base_revision: external_exports.number().int().min(0).max(CASE_TYPE_PACKAGE_REVISIONS_MAX).optional(),
|
|
20379
20382
|
name: caseTypeNameSchema,
|
|
20380
20383
|
definition: external_exports.unknown()
|
|
20381
20384
|
}).strict();
|
|
@@ -20401,16 +20404,23 @@ var init_case_type_drafts = __esm({
|
|
|
20401
20404
|
if (extra !== void 0) return refuse2("Unknown part", extra);
|
|
20402
20405
|
return { fields: parsed.data, package: archive ?? null };
|
|
20403
20406
|
});
|
|
20407
|
+
CASE_TYPE_PACKAGE_REACHES = ["new", "open"];
|
|
20408
|
+
caseTypeDraftPublicationBody = external_exports.object({
|
|
20409
|
+
reach: external_exports.enum(CASE_TYPE_PACKAGE_REACHES).default("new")
|
|
20410
|
+
}).strict();
|
|
20404
20411
|
CASE_PACKAGE_INVALID_REASON = "case_package_invalid";
|
|
20405
20412
|
CASE_TYPE_DRAFT_UPLOAD_EXPIRED_REASON = "case_type_draft_upload_expired";
|
|
20406
20413
|
CASE_TYPE_DRAFT_UPLOADS_BUSY_REASON = "case_type_draft_uploads_busy";
|
|
20407
20414
|
CASE_TYPE_DRAFTS_FULL_REASON = "case_type_drafts_full";
|
|
20415
|
+
CASE_TYPE_REVISION_CONFLICT_REASON = "case_type_revision_conflict";
|
|
20416
|
+
CASE_TYPE_DRAFT_BASE_REVISION_REQUIRED_REASON = "case_type_draft_base_revision_required";
|
|
20408
20417
|
caseRecordPackageQuery = external_exports.object({
|
|
20409
20418
|
confidential: external_exports.enum(["true", "false"]).optional().transform((value) => value === "true")
|
|
20410
20419
|
});
|
|
20411
20420
|
CASE_PACKAGE_PATH_MAX_CHARS = 200;
|
|
20412
20421
|
caseRecordPackageFileQuery = caseRecordPackageQuery.extend({
|
|
20413
|
-
path: external_exports.string().min(1).max(CASE_PACKAGE_PATH_MAX_CHARS)
|
|
20422
|
+
path: external_exports.string().min(1).max(CASE_PACKAGE_PATH_MAX_CHARS),
|
|
20423
|
+
revision: external_exports.coerce.number().int().min(1).max(CASE_TYPE_PACKAGE_REVISIONS_MAX).optional()
|
|
20414
20424
|
});
|
|
20415
20425
|
}
|
|
20416
20426
|
});
|
|
@@ -20741,7 +20751,7 @@ var init_api_client = __esm({
|
|
|
20741
20751
|
return { bytes, sha: etag === null ? null : /^(?:W\/)?"([0-9a-f]{64})"$/.exec(etag)?.[1] ?? null };
|
|
20742
20752
|
}
|
|
20743
20753
|
/**
|
|
20744
|
-
* The case's package (`get_case_package`): the type version
|
|
20754
|
+
* The case's package (`get_case_package`): the revision of the type version it opened on that reaches it, its files listed by path, SHA-256 and size;
|
|
20745
20755
|
* a marked one only with `confidential`, which needs the Confidential right on the case. Null for a version with none.
|
|
20746
20756
|
*/
|
|
20747
20757
|
async getCasePackage(ref, confidential) {
|
|
@@ -30645,6 +30655,7 @@ function isRecord3(value) {
|
|
|
30645
30655
|
const v = value;
|
|
30646
30656
|
if (!caseTypeParam.safeParse({ org_id: v.org_id, space_id: v.space_id, type_id: v.type_id }).success || typeof v.abbreviation !== "string") return false;
|
|
30647
30657
|
if (typeof v.version !== "number" || !Number.isInteger(v.version) || v.version < 1) return false;
|
|
30658
|
+
if (!caseTypeDraftFields.shape.base_revision.safeParse(v.revision).success) return false;
|
|
30648
30659
|
if (typeof v.files !== "object" || v.files === null || Array.isArray(v.files)) return false;
|
|
30649
30660
|
return Object.entries(v.files).every(([rel, sha]) => isTypeFolderPath(rel) && typeof sha === "string" && CASE_FILE_SHA_PATTERN.test(sha));
|
|
30650
30661
|
}
|
|
@@ -30685,6 +30696,7 @@ function writeTypeFolderRecord(root, record) {
|
|
|
30685
30696
|
type_id: record.type_id,
|
|
30686
30697
|
abbreviation: record.abbreviation,
|
|
30687
30698
|
version: record.version,
|
|
30699
|
+
...record.revision === void 0 ? {} : { revision: record.revision },
|
|
30688
30700
|
files
|
|
30689
30701
|
};
|
|
30690
30702
|
const tmp = path31.join(root, `${TYPE_FOLDER_MARKER}.tmp`);
|
|
@@ -30790,6 +30802,7 @@ var init_case_type_folder = __esm({
|
|
|
30790
30802
|
"use strict";
|
|
30791
30803
|
init_case_type_packages();
|
|
30792
30804
|
init_case_files();
|
|
30805
|
+
init_case_type_drafts();
|
|
30793
30806
|
init_case_types();
|
|
30794
30807
|
init_expected();
|
|
30795
30808
|
init_fs_safety();
|
|
@@ -30811,6 +30824,30 @@ var init_case_type_folder = __esm({
|
|
|
30811
30824
|
}
|
|
30812
30825
|
});
|
|
30813
30826
|
|
|
30827
|
+
// src/lib/web-origin.ts
|
|
30828
|
+
function webOrigin(apiUrl) {
|
|
30829
|
+
let url;
|
|
30830
|
+
try {
|
|
30831
|
+
url = new URL(apiUrl);
|
|
30832
|
+
} catch {
|
|
30833
|
+
return null;
|
|
30834
|
+
}
|
|
30835
|
+
let host;
|
|
30836
|
+
if (url.hostname.startsWith("api.")) host = `app.${url.hostname.slice("api.".length)}`;
|
|
30837
|
+
else if (url.hostname.startsWith("api-")) host = url.hostname.slice("api-".length);
|
|
30838
|
+
else return null;
|
|
30839
|
+
return `${url.protocol}//${host}${url.port ? `:${url.port}` : ""}`;
|
|
30840
|
+
}
|
|
30841
|
+
function webLocation(apiUrl, path55) {
|
|
30842
|
+
const origin = webOrigin(apiUrl);
|
|
30843
|
+
return origin ? `${origin}${path55}` : `${path55} (in the WayAI web app)`;
|
|
30844
|
+
}
|
|
30845
|
+
var init_web_origin = __esm({
|
|
30846
|
+
"src/lib/web-origin.ts"() {
|
|
30847
|
+
"use strict";
|
|
30848
|
+
}
|
|
30849
|
+
});
|
|
30850
|
+
|
|
30814
30851
|
// src/data/files-sync/local.ts
|
|
30815
30852
|
import * as fs23 from "fs";
|
|
30816
30853
|
import * as path32 from "path";
|
|
@@ -31924,7 +31961,7 @@ async function personApi(space) {
|
|
|
31924
31961
|
throw expected(`Not logged in. ${LOGIN_NEEDED}`);
|
|
31925
31962
|
}
|
|
31926
31963
|
const { config: signedIn, accessToken } = await requireAuth();
|
|
31927
|
-
return new ApiClient({ apiUrl: signedIn.api_url, accessToken, onUnauthorized: () => getAccessToken(signedIn) });
|
|
31964
|
+
return { api: new ApiClient({ apiUrl: signedIn.api_url, accessToken, onUnauthorized: () => getAccessToken(signedIn) }), apiUrl: signedIn.api_url };
|
|
31928
31965
|
}
|
|
31929
31966
|
function typeCallFailure(err, notFound2) {
|
|
31930
31967
|
if (!(err instanceof ApiError)) return err;
|
|
@@ -31951,6 +31988,31 @@ async function call(run, notFound2, refuse2) {
|
|
|
31951
31988
|
throw err instanceof ApiError && refuse2?.(err) || typeCallFailure(err, notFound2);
|
|
31952
31989
|
}
|
|
31953
31990
|
}
|
|
31991
|
+
function holdsPulledFiles(record, manifest) {
|
|
31992
|
+
const pulled = Object.entries(record.files).filter(([rel]) => rel !== TYPE_FILE);
|
|
31993
|
+
const now = new Map((manifest?.files ?? []).map((f) => [f.path, f.sha]));
|
|
31994
|
+
return pulled.length === now.size && pulled.every(([rel, sha]) => now.get(rel) === sha);
|
|
31995
|
+
}
|
|
31996
|
+
function movedSince(record, source) {
|
|
31997
|
+
if (source.version !== record.version) return { kind: "version", current: source.version };
|
|
31998
|
+
if (source.revision === void 0) return null;
|
|
31999
|
+
if (record.revision === void 0) {
|
|
32000
|
+
const revised = source.revision > 1 || source.revision === 1 && !holdsPulledFiles(record, source.package);
|
|
32001
|
+
return revised ? { kind: "unnamed", current: source.revision } : null;
|
|
32002
|
+
}
|
|
32003
|
+
return source.revision === record.revision ? null : { kind: "revision", current: source.revision };
|
|
32004
|
+
}
|
|
32005
|
+
function movedText(record, moved) {
|
|
32006
|
+
const known = moved.current !== void 0;
|
|
32007
|
+
switch (moved.kind) {
|
|
32008
|
+
case "version":
|
|
32009
|
+
return `Case type ${safe3(record.abbreviation)} was published${known ? ` at version ${moved.current}` : ""} since this folder was pulled at version ${record.version}`;
|
|
32010
|
+
case "revision":
|
|
32011
|
+
return `Version ${record.version} of case type ${safe3(record.abbreviation)} took ${known ? `package revision ${moved.current}` : "a newer package revision"} since this folder was pulled${record.revision === void 0 ? "" : ` at revision ${record.revision}`}`;
|
|
32012
|
+
case "unnamed":
|
|
32013
|
+
return `This folder records no package revision it was pulled at (an earlier CLI pulled it), and version ${record.version} of case type ${safe3(record.abbreviation)} holds a package-only revision${known ? ` (revision ${moved.current} now)` : ""}`;
|
|
32014
|
+
}
|
|
32015
|
+
}
|
|
31954
32016
|
function assertWritablePackagePaths(read, size, definition) {
|
|
31955
32017
|
const problems2 = casePackageProblems(read, size, definition).filter((p) => PACKAGE_PATH_REASONS.has(p.reason)).map(problemLine);
|
|
31956
32018
|
for (const { path: rel } of read.entries) {
|
|
@@ -31980,7 +32042,7 @@ function typeFileBytes(name, definition) {
|
|
|
31980
32042
|
`, "utf-8");
|
|
31981
32043
|
}
|
|
31982
32044
|
async function caseTypePull(ref, opts) {
|
|
31983
|
-
const api = await personApi(ref);
|
|
32045
|
+
const { api } = await personApi(ref);
|
|
31984
32046
|
const source = (await call(() => api.getCaseTypeSource(ref), NOT_FOUND)).data;
|
|
31985
32047
|
const abbreviation = source.type.abbreviation;
|
|
31986
32048
|
if (caseTypeAbbreviationSchema.safeParse(abbreviation).data !== abbreviation) throw expected("The server answered a type abbreviation this CLI will not name a folder by: nothing was written.");
|
|
@@ -32017,7 +32079,8 @@ async function caseTypePull(ref, opts) {
|
|
|
32017
32079
|
const changed = here ? localChanges(here.record, scan).filter((rel) => now.get(rel) !== nextSha(rel)) : [];
|
|
32018
32080
|
if (changed.length > 0) {
|
|
32019
32081
|
if (!opts.overwrite) {
|
|
32020
|
-
const
|
|
32082
|
+
const moved = movedSince(here.record, source);
|
|
32083
|
+
const advice = moved === null ? "Push them as a draft first (`wayai cases type push`), or pass --overwrite to replace them with the published version." : `${movedText(here.record, moved)}, so a push from it is refused: copy your changes aside and pass --overwrite, or pull into a new folder and carry them over.`;
|
|
32021
32084
|
throw expected(`These files changed here since the last pull, so nothing was written:
|
|
32022
32085
|
${changed.map(safe3).join("\n ")}
|
|
32023
32086
|
${advice}`);
|
|
@@ -32063,12 +32126,14 @@ Rename or move those first.`
|
|
|
32063
32126
|
...ref,
|
|
32064
32127
|
abbreviation,
|
|
32065
32128
|
version: source.version,
|
|
32129
|
+
// A server from before revisions answers none: the marker then names none (`writeTypeFolderRecord`), as one an earlier CLI wrote.
|
|
32130
|
+
revision: source.revision,
|
|
32066
32131
|
files: Object.fromEntries([...next].map(([rel, bytes]) => [rel, computeHash(bytes)]))
|
|
32067
32132
|
};
|
|
32068
32133
|
writeTypeFolderRecord(root, record);
|
|
32069
32134
|
const confidential = casePackageConfidentialPaths(source.definition);
|
|
32070
32135
|
const marked = entries.filter((e) => confidential.has(e.path)).length;
|
|
32071
|
-
console.log(`Pulled case type ${safe3(abbreviation)} (${safe3(source.type.name)}), version ${source.version}, into ${safe3(root)}:`);
|
|
32136
|
+
console.log(`Pulled case type ${safe3(abbreviation)} (${safe3(source.type.name)}), version ${source.version}${revisionNote(record.revision)}, into ${safe3(root)}:`);
|
|
32072
32137
|
console.log(` ${TYPE_FILE} and ${entries.length} package file(s); ${written} written, ${gone.size} removed.`);
|
|
32073
32138
|
if (!source.package) console.log(" This version has no package.");
|
|
32074
32139
|
if (marked > 0) console.log(` ${marked} of them are marked confidential by the definition: they reach a case only through its confidentiality filter.`);
|
|
@@ -32145,16 +32210,17 @@ function localFiles(entries, definition) {
|
|
|
32145
32210
|
async function caseTypeDiff(opts) {
|
|
32146
32211
|
const { root, record } = openTypeFolder(opts.dir);
|
|
32147
32212
|
const draft = readLocalDraft(scanTypeFolder(root));
|
|
32148
|
-
const api = await personApi(record);
|
|
32213
|
+
const { api } = await personApi(record);
|
|
32149
32214
|
const source = (await call(() => api.getCaseTypeSource(record), NOT_FOUND)).data;
|
|
32150
32215
|
const files = casePackageChanges(localFiles(draft.entries, draft.ok ? draft.parsed : source.definition), source.package?.files ?? []);
|
|
32151
|
-
const
|
|
32152
|
-
|
|
32153
|
-
];
|
|
32216
|
+
const moved = movedSince(record, source);
|
|
32217
|
+
const stale = moved === null ? [] : [`${movedText(record, moved)}: a push from it is refused. Pull the type into a new folder and carry your changes over.`];
|
|
32154
32218
|
const diff = {
|
|
32155
32219
|
type: { type_id: record.type_id, abbreviation: source.type.abbreviation, name: source.type.name },
|
|
32156
32220
|
base_version: record.version,
|
|
32157
32221
|
published_version: source.version,
|
|
32222
|
+
base_revision: record.revision ?? null,
|
|
32223
|
+
published_revision: source.revision ?? null,
|
|
32158
32224
|
name: { local: draft.name, published: source.type.name, changed: draft.name !== source.type.name },
|
|
32159
32225
|
definition: draft.ok ? (() => {
|
|
32160
32226
|
const parts = definitionChanges(draft.parsed, source.definition);
|
|
@@ -32168,7 +32234,9 @@ async function caseTypeDiff(opts) {
|
|
|
32168
32234
|
if (diff.problems.length > 0) process.exitCode = 1;
|
|
32169
32235
|
}
|
|
32170
32236
|
function printDiff2(diff, root) {
|
|
32171
|
-
console.log(
|
|
32237
|
+
console.log(
|
|
32238
|
+
`Case type ${safe3(diff.type.abbreviation)}: ${safe3(root)}, pulled at version ${diff.base_version}${revisionNote(diff.base_revision)}, against version ${diff.published_version}${revisionNote(diff.published_revision)}, published.`
|
|
32239
|
+
);
|
|
32172
32240
|
console.log(`Name: ${diff.name.changed ? `${JSON.stringify(safe3(diff.name.published))} -> ${JSON.stringify(safe3(String(diff.name.local)))}` : "same"}`);
|
|
32173
32241
|
console.log(`Definition: ${diff.definition === null ? "refused (below)" : diff.definition.changed ? `changed: ${diff.definition.parts.join(", ")}` : "same"}`);
|
|
32174
32242
|
const moved = diff.files.filter((f) => f.status !== "same");
|
|
@@ -32187,12 +32255,27 @@ function errorDetails(err) {
|
|
|
32187
32255
|
return null;
|
|
32188
32256
|
}
|
|
32189
32257
|
}
|
|
32258
|
+
function refusedMove(err) {
|
|
32259
|
+
if (err.status !== 409) return null;
|
|
32260
|
+
const details = errorDetails(err);
|
|
32261
|
+
const number = (value) => typeof value === "number" ? value : void 0;
|
|
32262
|
+
switch (extractApiErrorReason(err)) {
|
|
32263
|
+
case CASE_TYPE_VERSION_CONFLICT_REASON:
|
|
32264
|
+
return { kind: "version", current: number(details?.current_version) };
|
|
32265
|
+
case CASE_TYPE_REVISION_CONFLICT_REASON:
|
|
32266
|
+
return { kind: "revision", current: number(details?.current_revision) };
|
|
32267
|
+
case CASE_TYPE_DRAFT_BASE_REVISION_REQUIRED_REASON:
|
|
32268
|
+
return { kind: "unnamed" };
|
|
32269
|
+
default:
|
|
32270
|
+
return null;
|
|
32271
|
+
}
|
|
32272
|
+
}
|
|
32190
32273
|
function pushRefusal(err, record) {
|
|
32191
32274
|
const reason3 = extractApiErrorReason(err);
|
|
32192
|
-
|
|
32193
|
-
|
|
32275
|
+
const moved = refusedMove(err);
|
|
32276
|
+
if (moved) {
|
|
32194
32277
|
return expected(
|
|
32195
|
-
|
|
32278
|
+
`${movedText(record, moved)}, so the draft was refused: it would undo what was published. Pull the type into a new folder and carry your changes over, then push from there.`
|
|
32196
32279
|
);
|
|
32197
32280
|
}
|
|
32198
32281
|
if (err.status === 400 && reason3 === CASE_PACKAGE_INVALID_REASON) {
|
|
@@ -32206,6 +32289,10 @@ function pushRefusal(err, record) {
|
|
|
32206
32289
|
if (err.status === 409 && reason3 === CASE_TYPE_DRAFTS_FULL_REASON) return expected("This space holds as many drafts, or package files, as it may.");
|
|
32207
32290
|
return null;
|
|
32208
32291
|
}
|
|
32292
|
+
function typeDraftPagePath(ref, draftId) {
|
|
32293
|
+
const [org, space, draft] = [ref.org_id, ref.space_id, draftId].map(encodeURIComponent);
|
|
32294
|
+
return `/settings/organizations/${org}/cases/${space}/types/drafts/${draft}`;
|
|
32295
|
+
}
|
|
32209
32296
|
async function caseTypePush(opts) {
|
|
32210
32297
|
const { root, record } = openTypeFolder(opts.dir);
|
|
32211
32298
|
const draft = readLocalDraft(scanTypeFolder(root));
|
|
@@ -32216,23 +32303,31 @@ async function caseTypePush(opts) {
|
|
|
32216
32303
|
}
|
|
32217
32304
|
const archive = draft.entries.length > 0 ? writeCasePackage(draft.entries) : null;
|
|
32218
32305
|
if (archive && "problems" in readCasePackage(archive)) throw new Error("The package archive this CLI wrote does not read back");
|
|
32219
|
-
const fields = {
|
|
32306
|
+
const fields = {
|
|
32307
|
+
base_version: record.version,
|
|
32308
|
+
...record.revision === void 0 ? {} : { base_revision: record.revision },
|
|
32309
|
+
name: draft.name,
|
|
32310
|
+
definition: draft.definition
|
|
32311
|
+
};
|
|
32220
32312
|
const basePackaged = Object.keys(record.files).some((rel) => rel !== TYPE_FILE);
|
|
32221
32313
|
const shown4 = archive ? `${draft.entries.length} package file(s), ${archive.byteLength} bytes (SHA-256 ${await casePackageSha(archive)})` : "no package";
|
|
32222
32314
|
if (opts.dryRun) {
|
|
32223
|
-
console.log(`Would push a draft of case type ${safe3(record.abbreviation)} from version ${record.version}: ${shown4}. Nothing was sent.`);
|
|
32315
|
+
console.log(`Would push a draft of case type ${safe3(record.abbreviation)} from version ${record.version}${revisionNote(record.revision)}: ${shown4}. Nothing was sent.`);
|
|
32224
32316
|
return false;
|
|
32225
32317
|
}
|
|
32226
|
-
const api = await personApi(record);
|
|
32318
|
+
const { api, apiUrl } = await personApi(record);
|
|
32227
32319
|
const pushed = (await call(() => api.pushCaseTypeDraft(record, fields, archive), NOT_FOUND, (err) => pushRefusal(err, record))).data;
|
|
32228
|
-
console.log(
|
|
32320
|
+
console.log(
|
|
32321
|
+
`Pushed draft ${safe3(pushed.draft_id)} of case type ${safe3(record.abbreviation)}, from version ${pushed.base_version}${revisionNote(pushed.base_revision)}: ${shown4}.`
|
|
32322
|
+
);
|
|
32229
32323
|
console.log(PUBLISH_NOTICE);
|
|
32324
|
+
console.log(`Review and publish it at ${safe3(webLocation(apiUrl, typeDraftPagePath(record, pushed.draft_id)))}`);
|
|
32230
32325
|
if (!archive && basePackaged) {
|
|
32231
32326
|
console.log("This draft carries no package, and the version it was made from has one: publishing it would be refused.");
|
|
32232
32327
|
}
|
|
32233
32328
|
return true;
|
|
32234
32329
|
}
|
|
32235
|
-
var PUBLISH_NOTICE, safe3, PROBLEM_TEXT, LOGIN_NEEDED, NOT_FOUND, typeFileFields, sameJson, STATUS_WORD;
|
|
32330
|
+
var PUBLISH_NOTICE, safe3, PROBLEM_TEXT, LOGIN_NEEDED, NOT_FOUND, revisionNote, typeFileFields, sameJson, STATUS_WORD;
|
|
32236
32331
|
var init_case_types2 = __esm({
|
|
32237
32332
|
"src/cases/case-types.ts"() {
|
|
32238
32333
|
"use strict";
|
|
@@ -32247,13 +32342,14 @@ var init_case_types2 = __esm({
|
|
|
32247
32342
|
init_resource_files();
|
|
32248
32343
|
init_terminal_output();
|
|
32249
32344
|
init_token_store();
|
|
32345
|
+
init_web_origin();
|
|
32250
32346
|
init_local();
|
|
32251
32347
|
init_sync3();
|
|
32252
32348
|
init_case_clone_record();
|
|
32253
32349
|
init_case_local_files();
|
|
32254
32350
|
init_case_tokens();
|
|
32255
32351
|
init_case_type_folder();
|
|
32256
|
-
PUBLISH_NOTICE = "It changes nothing yet: a space administrator publishes it in the WayAI web app, as the type's next version,
|
|
32352
|
+
PUBLISH_NOTICE = "It changes nothing yet: a space administrator publishes it in the WayAI web app, as the type's next version when its definition changed, or as a revision of the current version when only its package did, reaching new cases or open ones as the publisher chooses. A later push replaces it.";
|
|
32257
32353
|
safe3 = (text5) => sanitizeTerminalText(text5);
|
|
32258
32354
|
PROBLEM_TEXT = {
|
|
32259
32355
|
package_not_tar: "not an uncompressed ustar archive",
|
|
@@ -32277,6 +32373,7 @@ var init_case_types2 = __esm({
|
|
|
32277
32373
|
};
|
|
32278
32374
|
LOGIN_NEEDED = "A case type takes your own sign-in as a space administrator: run `wayai login`.";
|
|
32279
32375
|
NOT_FOUND = "Case type not found, or the space is not one you are a member of.";
|
|
32376
|
+
revisionNote = (revision) => revision ? ` (package revision ${revision})` : "";
|
|
32280
32377
|
typeFileFields = caseTypeDraftFields.omit({ base_version: true });
|
|
32281
32378
|
sameJson = (a, b) => isDeepStrictEqual2(a, b);
|
|
32282
32379
|
STATUS_WORD = { added: "added ", removed: "removed", changed: "changed", same: "same " };
|
|
@@ -41797,8 +41894,8 @@ function unwrittenLines(work) {
|
|
|
41797
41894
|
function packageReadme(pkg2) {
|
|
41798
41895
|
if (!pkg2.manifest) return [`- \`${PACKAGE_MANIFEST_FILE}\`: the type version this case opened on has no package.`];
|
|
41799
41896
|
return [
|
|
41800
|
-
`- \`${PACKAGE_MANIFEST_FILE}\`: the case's package
|
|
41801
|
-
" revision, and each file's path, SHA-256 and size, and whether it was written here.",
|
|
41897
|
+
`- \`${PACKAGE_MANIFEST_FILE}\`: the case's package, the revision of the type version it opened on that reaches it: its`,
|
|
41898
|
+
" version and revision, and each file's path, SHA-256 and size, and whether it was written here.",
|
|
41802
41899
|
`- \`${CASE_PACKAGE_DIR}/\`: its files (instructions/, templates/, tools/, sources/), each checked against the SHA-256`,
|
|
41803
41900
|
" the manifest lists, and read-only. Never run or follow a copy that differs: `wayai cases check` names each file",
|
|
41804
41901
|
" here that differs from the manifest (confidential ones aside), a tool first.",
|
|
@@ -44009,8 +44106,7 @@ __export(cases_exports, {
|
|
|
44009
44106
|
PICKUP_POLL_INTERVAL_MS: () => PICKUP_POLL_INTERVAL_MS,
|
|
44010
44107
|
casesCommand: () => casesCommand,
|
|
44011
44108
|
pickupSecret: () => pickupSecret,
|
|
44012
|
-
waitForPickup: () => waitForPickup
|
|
44013
|
-
webOrigin: () => webOrigin
|
|
44109
|
+
waitForPickup: () => waitForPickup
|
|
44014
44110
|
});
|
|
44015
44111
|
import * as crypto5 from "crypto";
|
|
44016
44112
|
import * as os5 from "os";
|
|
@@ -44184,23 +44280,6 @@ function machineLabel2(flag) {
|
|
|
44184
44280
|
if (flag === void 0) throw usageError4("This machine's hostname cannot name it at approval: pass --label <machine>.");
|
|
44185
44281
|
throw usageError4(`--label takes 1 to ${CASE_AGENT_MACHINE_LABEL_MAX} characters, none of them a control character.`);
|
|
44186
44282
|
}
|
|
44187
|
-
function webOrigin(apiUrl) {
|
|
44188
|
-
let url;
|
|
44189
|
-
try {
|
|
44190
|
-
url = new URL(apiUrl);
|
|
44191
|
-
} catch {
|
|
44192
|
-
return null;
|
|
44193
|
-
}
|
|
44194
|
-
let host;
|
|
44195
|
-
if (url.hostname.startsWith("api.")) host = `app.${url.hostname.slice("api.".length)}`;
|
|
44196
|
-
else if (url.hostname.startsWith("api-")) host = url.hostname.slice("api-".length);
|
|
44197
|
-
else return null;
|
|
44198
|
-
return `${url.protocol}//${host}${url.port ? `:${url.port}` : ""}`;
|
|
44199
|
-
}
|
|
44200
|
-
function webLocation(apiUrl, path55) {
|
|
44201
|
-
const origin = webOrigin(apiUrl);
|
|
44202
|
-
return origin ? `${origin}${path55}` : `${path55} (in the WayAI web app)`;
|
|
44203
|
-
}
|
|
44204
44283
|
function pickupSecret() {
|
|
44205
44284
|
const bytes = crypto5.randomBytes(32);
|
|
44206
44285
|
return { secret: bytes.toString("hex"), challenge: crypto5.createHash("sha256").update(bytes).digest("hex") };
|
|
@@ -44364,6 +44443,7 @@ var init_cases = __esm({
|
|
|
44364
44443
|
init_terminal_output();
|
|
44365
44444
|
init_token_store();
|
|
44366
44445
|
init_utils();
|
|
44446
|
+
init_web_origin();
|
|
44367
44447
|
init_case_session();
|
|
44368
44448
|
init_case_work();
|
|
44369
44449
|
init_case_files2();
|
|
@@ -44520,15 +44600,19 @@ type pull Write the type's current version into a folder (--dir, default
|
|
|
44520
44600
|
before anything is written.
|
|
44521
44601
|
type diff The folder against the published version: its name, definition
|
|
44522
44602
|
and each package file added, changed or removed, and what a
|
|
44523
|
-
push would be refused for
|
|
44524
|
-
|
|
44603
|
+
push would be refused for that it sees: the folder's own
|
|
44604
|
+
problems, and a version or a package revision of the version
|
|
44605
|
+
the folder was pulled at, published since the pull. Exits 1
|
|
44606
|
+
when it finds one.
|
|
44525
44607
|
type push Check the folder with every rule that needs nothing the space
|
|
44526
44608
|
holds (the draft's fields, the definition's form and rules, the
|
|
44527
44609
|
package's), then push it as the type's draft, replacing its
|
|
44528
|
-
open draft
|
|
44529
|
-
|
|
44530
|
-
|
|
44531
|
-
|
|
44610
|
+
open draft, and print the draft's review page in the web app.
|
|
44611
|
+
Nothing is sent while such a problem remains, and every one is
|
|
44612
|
+
named; the space checks the rest (the teams the definition
|
|
44613
|
+
names). --dry-run checks and stops. A push from a folder pulled
|
|
44614
|
+
before the type's latest version or package revision is
|
|
44615
|
+
refused: pull into a new folder and carry your changes over.
|
|
44532
44616
|
|
|
44533
44617
|
Confidential content is never asked for unless you pass --confidential:
|
|
44534
44618
|
without it, clone, pull, push and log leave every confidential file alone,
|